chore: adjust prettier config, .gitignore and use taplo to format toml files (#1728)

* chore: adjust prettier config, .gitignore and use taplo to format toml files

This brings the plugins-workspace repository to the same code style of the main tauri repo

* format toml

* ignore examples gen dir

* add .vscode/extensions.json

* remove packageManager field

* fmt

* fix audit

* taplo ignore permissions autogenerated files

* remove create dummy dist

* fix prettier workflow

* install fmt in prettier workflow

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
Amr Bashir
2024-09-04 14:54:23 +03:00
committed by GitHub
parent 72c2ce82c1
commit cf4d7d4e6c
227 changed files with 2534 additions and 2505 deletions
-1
View File
@@ -1 +0,0 @@
.tauri
+4 -4
View File
@@ -10,15 +10,15 @@ repository = { workspace = true }
links = "tauri-plugin-dialog"
[package.metadata.docs.rs]
rustc-args = [ "--cfg", "docsrs" ]
rustdoc-args = [ "--cfg", "docsrs" ]
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]
targets = ["x86_64-unknown-linux-gnu", "x86_64-linux-android"]
[build-dependencies]
tauri-plugin = { workspace = true, features = [ "build" ] }
tauri-plugin = { workspace = true, features = ["build"] }
[dev-dependencies]
tauri = { workspace = true, features = [ "wry" ] }
tauri = { workspace = true, features = ["wry"] }
[dependencies]
serde = { workspace = true }
+1 -1
View File
@@ -20,4 +20,4 @@ We prefer to receive reports in English.
Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new).
Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app).
Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app).
+52 -52
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/core";
import { invoke } from '@tauri-apps/api/core'
/**
* Extension filters for the file dialog.
@@ -11,7 +11,7 @@ import { invoke } from "@tauri-apps/api/core";
*/
interface DialogFilter {
/** Filter name. */
name: string;
name: string
/**
* Extensions to filter, without a `.` prefix.
* @example
@@ -19,7 +19,7 @@ interface DialogFilter {
* extensions: ['svg', 'png']
* ```
*/
extensions: string[];
extensions: string[]
}
/**
@@ -29,9 +29,9 @@ interface DialogFilter {
*/
interface OpenDialogOptions {
/** The title of the dialog window (desktop only). */
title?: string;
title?: string
/** The filters of the dialog. */
filters?: DialogFilter[];
filters?: DialogFilter[]
/**
* Initial directory or file path.
* If it's a directory path, the dialog interface will change to that folder.
@@ -40,18 +40,18 @@ interface OpenDialogOptions {
* On mobile the file name is always used on the dialog's file name input.
* If not provided, Android uses `(invalid).txt` as default file name.
*/
defaultPath?: string;
defaultPath?: string
/** Whether the dialog allows multiple selection or not. */
multiple?: boolean;
multiple?: boolean
/** Whether the dialog is a directory selection or not. */
directory?: boolean;
directory?: boolean
/**
* If `directory` is true, indicates that it will be read recursively later.
* Defines whether subdirectories will be allowed on the scope or not.
*/
recursive?: boolean;
recursive?: boolean
/** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */
canCreateDirectories?: boolean;
canCreateDirectories?: boolean
}
/**
@@ -61,9 +61,9 @@ interface OpenDialogOptions {
*/
interface SaveDialogOptions {
/** The title of the dialog window (desktop only). */
title?: string;
title?: string
/** The filters of the dialog. */
filters?: DialogFilter[];
filters?: DialogFilter[]
/**
* Initial directory or file path.
* If it's a directory path, the dialog interface will change to that folder.
@@ -72,9 +72,9 @@ interface SaveDialogOptions {
* On mobile the file name is always used on the dialog's file name input.
* If not provided, Android uses `(invalid).txt` as default file name.
*/
defaultPath?: string;
defaultPath?: string
/** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */
canCreateDirectories?: boolean;
canCreateDirectories?: boolean
}
/**
@@ -82,31 +82,31 @@ interface SaveDialogOptions {
*/
interface MessageDialogOptions {
/** The title of the dialog. Defaults to the app name. */
title?: string;
title?: string
/** The kind of the dialog. Defaults to `info`. */
kind?: "info" | "warning" | "error";
kind?: 'info' | 'warning' | 'error'
/** The label of the confirm button. */
okLabel?: string;
okLabel?: string
}
interface ConfirmDialogOptions {
/** The title of the dialog. Defaults to the app name. */
title?: string;
title?: string
/** The kind of the dialog. Defaults to `info`. */
kind?: "info" | "warning" | "error";
kind?: 'info' | 'warning' | 'error'
/** The label of the confirm button. */
okLabel?: string;
okLabel?: string
/** The label of the cancel button. */
cancelLabel?: string;
cancelLabel?: string
}
type OpenDialogReturn<T extends OpenDialogOptions> = T["directory"] extends true
? T["multiple"] extends true
type OpenDialogReturn<T extends OpenDialogOptions> = T['directory'] extends true
? T['multiple'] extends true
? string[] | null
: string | null
: T["multiple"] extends true
: T['multiple'] extends true
? string[] | null
: string | null;
: string | null
/**
* Open a file/directory selection dialog.
@@ -161,13 +161,13 @@ type OpenDialogReturn<T extends OpenDialogOptions> = T["directory"] extends true
* @since 2.0.0
*/
async function open<T extends OpenDialogOptions>(
options: T = {} as T,
options: T = {} as T
): Promise<OpenDialogReturn<T>> {
if (typeof options === "object") {
Object.freeze(options);
if (typeof options === 'object') {
Object.freeze(options)
}
return await invoke("plugin:dialog|open", { options });
return await invoke('plugin:dialog|open', { options })
}
/**
@@ -195,11 +195,11 @@ async function open<T extends OpenDialogOptions>(
* @since 2.0.0
*/
async function save(options: SaveDialogOptions = {}): Promise<string | null> {
if (typeof options === "object") {
Object.freeze(options);
if (typeof options === 'object') {
Object.freeze(options)
}
return await invoke("plugin:dialog|save", { options });
return await invoke('plugin:dialog|save', { options })
}
/**
@@ -221,15 +221,15 @@ async function save(options: SaveDialogOptions = {}): Promise<string | null> {
*/
async function message(
message: string,
options?: string | MessageDialogOptions,
options?: string | MessageDialogOptions
): Promise<void> {
const opts = typeof options === "string" ? { title: options } : options;
await invoke("plugin:dialog|message", {
const opts = typeof options === 'string' ? { title: options } : options
await invoke('plugin:dialog|message', {
message: message.toString(),
title: opts?.title?.toString(),
kind: opts?.kind,
okButtonLabel: opts?.okLabel?.toString(),
});
okButtonLabel: opts?.okLabel?.toString()
})
}
/**
@@ -250,16 +250,16 @@ async function message(
*/
async function ask(
message: string,
options?: string | ConfirmDialogOptions,
options?: string | ConfirmDialogOptions
): Promise<boolean> {
const opts = typeof options === "string" ? { title: options } : options;
return await invoke("plugin:dialog|ask", {
const opts = typeof options === 'string' ? { title: options } : options
return await invoke('plugin:dialog|ask', {
message: message.toString(),
title: opts?.title?.toString(),
kind: opts?.kind,
okButtonLabel: opts?.okLabel?.toString() ?? "Yes",
cancelButtonLabel: opts?.cancelLabel?.toString() ?? "No",
});
okButtonLabel: opts?.okLabel?.toString() ?? 'Yes',
cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'No'
})
}
/**
@@ -280,16 +280,16 @@ async function ask(
*/
async function confirm(
message: string,
options?: string | ConfirmDialogOptions,
options?: string | ConfirmDialogOptions
): Promise<boolean> {
const opts = typeof options === "string" ? { title: options } : options;
return await invoke("plugin:dialog|confirm", {
const opts = typeof options === 'string' ? { title: options } : options
return await invoke('plugin:dialog|confirm', {
message: message.toString(),
title: opts?.title?.toString(),
kind: opts?.kind,
okButtonLabel: opts?.okLabel?.toString() ?? "Ok",
cancelButtonLabel: opts?.cancelLabel?.toString() ?? "Cancel",
});
okButtonLabel: opts?.okLabel?.toString() ?? 'Ok',
cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'Cancel'
})
}
export type {
@@ -298,7 +298,7 @@ export type {
OpenDialogReturn,
SaveDialogOptions,
MessageDialogOptions,
ConfirmDialogOptions,
};
ConfirmDialogOptions
}
export { open, save, message, ask, confirm };
export { open, save, message, ask, confirm }
+9 -9
View File
@@ -2,17 +2,17 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/core";
import { invoke } from '@tauri-apps/api/core'
window.alert = function (message: string) {
void invoke("plugin:dialog|message", {
message: message.toString(),
});
};
void invoke('plugin:dialog|message', {
message: message.toString()
})
}
// @ts-expect-error tauri does not have sync IPC :(
window.confirm = async function (message: string) {
return await invoke("plugin:dialog|confirm", {
message: message.toString(),
});
};
return await invoke('plugin:dialog|confirm', {
message: message.toString()
})
}
+5 -5
View File
@@ -12,9 +12,9 @@ All dialog types are enabled.
"""
permissions = [
"allow-ask",
"allow-confirm",
"allow-message",
"allow-save",
"allow-open",
"allow-ask",
"allow-confirm",
"allow-message",
"allow-save",
"allow-open",
]
+11 -11
View File
@@ -2,21 +2,21 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { createConfig } from "../../shared/rollup.config.js";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import { createConfig } from '../../shared/rollup.config.js'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import terser from '@rollup/plugin-terser'
export default createConfig({
additionalConfigs: {
input: "guest-js/init.ts",
input: 'guest-js/init.ts',
output: {
file: "src/init-iife.js",
format: "iife",
file: 'src/init-iife.js',
format: 'iife'
},
plugins: [typescript(), terser(), nodeResolve()],
onwarn: (warning) => {
throw Object.assign(new Error(), warning);
},
},
});
throw Object.assign(new Error(), warning)
}
}
})