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
+29 -29
View File
@@ -2,12 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { readFileSync } from "fs";
import { join } from "path";
import { cwd } from "process";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import { readFileSync } from 'fs'
import { join } from 'path'
import { cwd } from 'process'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import terser from '@rollup/plugin-terser'
/**
* Create a base rollup config
@@ -21,21 +21,21 @@ import terser from "@rollup/plugin-terser";
*/
export function createConfig(options = {}) {
const {
input = "guest-js/index.ts",
input = 'guest-js/index.ts',
external = [/^@tauri-apps\/api/],
additionalConfigs = [],
} = options;
additionalConfigs = []
} = options
// eslint-disable-next-line security/detect-non-literal-fs-filename
const pkg = JSON.parse(readFileSync(join(cwd(), "package.json"), "utf8"));
const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json'), 'utf8'))
const pluginJsName = pkg.name
.replace("@tauri-apps/plugin-", "")
.replace(/-./g, (x) => x[1].toUpperCase());
.replace('@tauri-apps/plugin-', '')
.replace(/-./g, (x) => x[1].toUpperCase())
const iifeVarName = `__TAURI_PLUGIN_${pkg.name
.replace("@tauri-apps/plugin-", "")
.replace("-", (x) => "_")
.toUpperCase()}__`;
.replace('@tauri-apps/plugin-', '')
.replace('-', (x) => '_')
.toUpperCase()}__`
return [
{
@@ -43,50 +43,50 @@ export function createConfig(options = {}) {
output: [
{
file: pkg.exports.import,
format: "esm",
format: 'esm'
},
{
file: pkg.exports.require,
format: "cjs",
},
format: 'cjs'
}
],
plugins: [
typescript({
declaration: true,
declarationDir: `./${pkg.exports.import.split("/")[0]}`,
}),
declarationDir: `./${pkg.exports.import.split('/')[0]}`
})
],
external: [
...external,
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...Object.keys(pkg.peerDependencies || {})
],
onwarn: (warning) => {
throw Object.assign(new Error(), warning);
},
throw Object.assign(new Error(), warning)
}
},
{
input,
output: {
format: "iife",
format: 'iife',
name: iifeVarName,
// IIFE is in the format `var ${iifeVarName} = (() => {})()`
// we check if __TAURI__ exists and inject the API object
banner: "if ('__TAURI__' in window) {",
// the last `}` closes the if in the banner
footer: `Object.defineProperty(window.__TAURI__, '${pluginJsName}', { value: ${iifeVarName} }) }`,
file: "api-iife.js",
file: 'api-iife.js'
},
// and var is not guaranteed to assign to the global `window` object so we make sure to assign it
plugins: [typescript(), terser(), nodeResolve()],
onwarn: (warning) => {
throw Object.assign(new Error(), warning);
},
throw Object.assign(new Error(), warning)
}
},
...(Array.isArray(additionalConfigs)
? additionalConfigs
: [additionalConfigs]),
];
: [additionalConfigs])
]
}
-1
View File
@@ -1 +0,0 @@
/.tauri
+3 -3
View File
@@ -8,11 +8,11 @@ repository = { workspace = true }
links = "tauri-plugin-PLUGIN_NAME"
[package.metadata.docs.rs]
rustc-args = [ "--cfg", "docsrs" ]
rustdoc-args = [ "--cfg", "docsrs" ]
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]
[build-dependencies]
tauri-plugin = { workspace = true, features = [ "build" ] }
tauri-plugin = { workspace = true, features = ["build"] }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+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).
+2 -2
View File
@@ -2,6 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { createConfig } from "../../shared/rollup.config.js";
import { createConfig } from '../../shared/rollup.config.js'
export default createConfig();
export default createConfig()