diff --git a/tooling/cli/src/plugin/init.rs b/tooling/cli/src/plugin/init.rs
index 013cdd47a..6566e0c37 100644
--- a/tooling/cli/src/plugin/init.rs
+++ b/tooling/cli/src/plugin/init.rs
@@ -194,10 +194,10 @@ pub fn command(mut options: Options) -> Result<()> {
}
}
"ios" if !(options.ios || options.mobile) => return Ok(None),
- "webview-dist" | "webview-src" | "package.json" => {
- if options.no_api {
- return Ok(None);
- }
+ "guest-js" | "rollup.config.js" | "tsconfig.json" | "package.json"
+ if options.no_api =>
+ {
+ return Ok(None);
}
_ => (),
}
diff --git a/tooling/cli/templates/plugin/.changes/config.json b/tooling/cli/templates/plugin/.changes/config.json
deleted file mode 100755
index b12ed4829..000000000
--- a/tooling/cli/templates/plugin/.changes/config.json
+++ /dev/null
@@ -1,91 +0,0 @@
-{
- "gitSiteUrl": "https://www.github.com/your-org/tauri-plugin-{{ plugin_name }}/",
- "pkgManagers": {
- "rust": {
- "version": true,
- "getPublishedVersion": "cargo search ${ pkg.pkg } --limit 1 | sed -nE 's/^[^\"]*\"//; s/\".*//1p' -",
- "prepublish": [
- "sudo apt-get update",
- "sudo apt-get install -y webkit2gtk-4.1",
- "cargo install cargo-audit",
- {
- "command": "cargo generate-lockfile",
- "dryRunCommand": true,
- "pipe": true
- },
- {
- "command": "echo '\nCargo Audit
\n\n```'",
- "dryRunCommand": true,
- "pipe": true
- },
- {
- "command": "cargo audit ${ process.env.CARGO_AUDIT_OPTIONS || '' }",
- "dryRunCommand": true,
- "pipe": true
- },
- {
- "command": "echo '```\n\n \n'",
- "dryRunCommand": true,
- "pipe": true
- }
- ],
- "publish": [
- {
- "command": "cargo package --no-verify",
- "dryRunCommand": true
- },
- {
- "command": "echo '\nCargo Publish
\n\n```'",
- "dryRunCommand": true,
- "pipe": true
- },
- {
- "command": "cargo publish",
- "dryRunCommand": "cargo publish --dry-run",
- "pipe": true
- },
- {
- "command": "echo '```\n\n \n'",
- "dryRunCommand": true,
- "pipe": true
- }
- ]
- },
- "javascript": {
- "version": true,
- "getPublishedVersion": "npm view ${ pkgFile.pkg.name } version",
- "publish": [
- {
- "command": "echo '\nYarn Publish
\n\n```'",
- "dryRunCommand": true,
- "pipe": true
- },
- {
- "command": "yarn publish --access public --loglevel silly",
- "dryRunCommand": "npm publish --dry-run --access public",
- "pipe": true
- },
- {
- "command": "echo '```\n\n \n'",
- "dryRunCommand": true,
- "pipe": true
- }
- ]
- }
- },
- "packages": {
- "tauri-plugin-{{ plugin_name }}": {
- "path": ".",
- "manager": "rust",
- "releaseTag": "crate-v${ pkgFile.version }"
- },
- "tauri-plugin-{{ plugin_name }}-api": {
- "path": ".",
- "manager": "javascript",
- "dependencies": [
- "tauri-plugin-{{ plugin_name }}"
- ],
- "releaseTag": "npm-v${ pkgFile.version }"
- }
- }
-}
diff --git a/tooling/cli/templates/plugin/.changes/initial-release.md b/tooling/cli/templates/plugin/.changes/initial-release.md
deleted file mode 100644
index 25379021b..000000000
--- a/tooling/cli/templates/plugin/.changes/initial-release.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-"tauri-plugin-{{ plugin_name }}": "minor"
-"tauri-plugin-{{ plugin_name }}-api": "minor"
----
-
-Initial release.
diff --git a/tooling/cli/templates/plugin/.changes/readme.md b/tooling/cli/templates/plugin/.changes/readme.md
deleted file mode 100755
index 273eeae49..000000000
--- a/tooling/cli/templates/plugin/.changes/readme.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Changes
-##### via https://github.com/jbolda/covector
-
-As you create PRs and make changes that require a version bump, please add a new markdown file in this folder. You do not note the version *number*, but rather the type of bump that you expect: major, minor, or patch. The filename is not important, as long as it is a `.md`, but we recommend it represents the overall change for our sanity.
-
-When you select the version bump required, you do *not* need to consider dependencies. Only note the package with the actual change, and any packages that depend on that package will be bumped automatically in the process.
-
-Use the following format:
-```md
----
-"tauri-plugin-{{ plugin_name }}": 'patch:enhance'
----
-
-Change summary goes here
-
-```
diff --git a/tooling/cli/templates/plugin/.github/workflows/audit.yml b/tooling/cli/templates/plugin/.github/workflows/audit.yml
index 352a6da28..4121fa647 100644
--- a/tooling/cli/templates/plugin/.github/workflows/audit.yml
+++ b/tooling/cli/templates/plugin/.github/workflows/audit.yml
@@ -8,24 +8,27 @@ on:
branches:
- main
paths:
+ - ".github/workflows/audit.yml"
- "**/Cargo.lock"
- "**/Cargo.toml"
pull_request:
branches:
- main
paths:
+ - ".github/workflows/audit.yml"
- "**/Cargo.lock"
- "**/Cargo.toml"
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
audit:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: rustsec/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- permissions:
- issues: write
- checks: write
{{{{/raw}}}}
diff --git a/tooling/cli/templates/plugin/.github/workflows/clippy.yml b/tooling/cli/templates/plugin/.github/workflows/clippy.yml
index f8b742c45..23556aeb3 100644
--- a/tooling/cli/templates/plugin/.github/workflows/clippy.yml
+++ b/tooling/cli/templates/plugin/.github/workflows/clippy.yml
@@ -1,35 +1,55 @@
{{{{raw}}}}
-name: Clippy
+name: Check
on:
push:
branches:
- main
+ paths:
+ - ".github/workflows/check.yml"
+ - "**/*.rs"
+ - "**/Cargo.toml"
pull_request:
branches:
- main
- - dev
+ paths:
+ - ".github/workflows/check.yml"
+ - "**/*.rs"
+ - "**/Cargo.toml"
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
jobs:
- clippy:
+ fmt:
runs-on: ubuntu-latest
- strategy:
- fail-fast: false
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ components: rustfmt
+ - run: cargo fmt --all -- --check
- - name: Install dependencies
+ clippy:
+ strategy:
+ fail-fast: false
+ matrix:
+ platform: [ubuntu-latest, macos-latest, windows-latest]
+
+ runs-on: ${{ matrix.platform }}
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ components: clippy
+ - name: install webkit2gtk
+ if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.1
-
- - name: Install clippy with stable toolchain
- uses: dtolnay/rust-toolchain@stable
- with:
- components: clippy
-
- uses: Swatinem/rust-cache@v2
-
- - run: cargo clippy --manifest-path=Cargo.toml --all-targets --all-features -- -D warnings
+ - run: cargo clippy --all-targets --all-features -- -D warnings
{{{{/raw}}}}
diff --git a/tooling/cli/templates/plugin/.github/workflows/covector-version-or-publish.yml b/tooling/cli/templates/plugin/.github/workflows/covector-version-or-publish.yml
deleted file mode 100644
index d39e72acf..000000000
--- a/tooling/cli/templates/plugin/.github/workflows/covector-version-or-publish.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-{{{{raw}}}}
-name: covector version or publish
-on:
- push:
- branches:
- - dev
-
-jobs:
- covector:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
- - uses: actions/setup-node@v3
- with:
- node-version: 18
- registry-url: 'https://registry.npmjs.org'
-
- - name: cargo login
- run: cargo login ${{ secrets.ORG_CRATES_IO_TOKEN }}
-
- - name: git config
- run: |
- git config --global user.name "${{ github.event.pusher.name }}"
- git config --global user.email "${{ github.event.pusher.email }}"
-
- - name: covector version-or-publish
- uses: jbolda/covector/packages/action@covector-v0
- id: covector
- with:
- token: ${{ secrets.GITHUB_TOKEN }}
- command: 'version-or-publish'
- createRelease: true
-
- - name: Create Pull Request With Versions Bumped
- if: steps.covector.outputs.commandRan == 'version'
- uses: tauri-apps/create-pull-request@v3
- with:
- token: ${{ secrets.GITHUB_TOKEN }}
- branch: release/version-updates
- title: Apply Version Updates From Current Changes
- commit-message: "apply version updates"
- labels: "version updates"
- body: ${{ steps.covector.outputs.change }}
-
-{{{{/raw}}}}
diff --git a/tooling/cli/templates/plugin/.github/workflows/format.yml b/tooling/cli/templates/plugin/.github/workflows/format.yml
deleted file mode 100644
index c031d6238..000000000
--- a/tooling/cli/templates/plugin/.github/workflows/format.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-{{{{raw}}}}
-name: Format
-
-on:
- push:
- branches:
- - main
- pull_request:
- branches:
- - main
- - dev
-
-jobs:
- format:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
-
- steps:
- - uses: actions/checkout@v3
-
- - name: Install rustfmt with stable toolchain
- uses: dtolnay/rust-toolchain@stable
- with:
- components: rustfmt
-
- - uses: Swatinem/rust-cache@v2
-
- - run: cargo fmt --manifest-path=Cargo.toml --all -- --check
-{{{{/raw}}}}
diff --git a/tooling/cli/templates/plugin/.github/workflows/test.yml b/tooling/cli/templates/plugin/.github/workflows/test.yml
index 3b4999657..c528a4506 100644
--- a/tooling/cli/templates/plugin/.github/workflows/test.yml
+++ b/tooling/cli/templates/plugin/.github/workflows/test.yml
@@ -8,36 +8,28 @@ on:
pull_request:
branches:
- main
- - dev
- paths-ignore:
- - 'webview-src/**'
- - 'webview-dist/**'
- - 'examples/**'
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
jobs:
- build-and-test:
- runs-on: ${{ matrix.os }}
+ test:
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
+ platform: [ubuntu-latest, macos-latest, windows-latest]
+
+ runs-on: ${{ matrix.platform }}
steps:
- - uses: actions/checkout@v3
-
- - name: Install stable toolchain
- uses: dtolnay/rust-toolchain@stable
- with:
- components: clippy
-
- - name: Install Linux dependencies
- if: matrix.os == 'ubuntu-latest'
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@stable
+ - name: install webkit2gtk
+ if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.1
-
- uses: Swatinem/rust-cache@v2
-
- - name: Run tests
- run: cargo test --manifest-path=Cargo.toml --release
+ - run: cargo test --all-targets --all-features -- -D warnings
{{{{/raw}}}}
diff --git a/tooling/cli/templates/plugin/.gitignore b/tooling/cli/templates/plugin/.gitignore
index 9863270e5..50d8e32e8 100644
--- a/tooling/cli/templates/plugin/.gitignore
+++ b/tooling/cli/templates/plugin/.gitignore
@@ -12,3 +12,6 @@ yarn.lock
/target
Cargo.lock
node_modules/
+
+dist-js
+dist
diff --git a/tooling/cli/templates/plugin/webview-src/index.ts b/tooling/cli/templates/plugin/guest-js/index.ts
similarity index 100%
rename from tooling/cli/templates/plugin/webview-src/index.ts
rename to tooling/cli/templates/plugin/guest-js/index.ts
diff --git a/tooling/cli/templates/plugin/package.json b/tooling/cli/templates/plugin/package.json
index 0a6f3c593..1779e9020 100644
--- a/tooling/cli/templates/plugin/package.json
+++ b/tooling/cli/templates/plugin/package.json
@@ -3,23 +3,31 @@
"version": "0.0.0",
"author": "{{ author }}",
"description": "",
- "browser": "webview-dist/index.js",
- "main": "webview-dist/index.js",
- "types": "webview-dist/index.d.ts",
+ "type": "module",
+ "types": "./dist-js/index.d.ts",
+ "main": "./dist-js/index.cjs",
+ "module": "./dist-js/index.js",
+ "exports": {
+ "types": "./dist-js/index.d.ts",
+ "import": "./dist-js/index.js",
+ "require": "./dist-js/index.cjs"
+ },
+ "files": [
+ "dist-js",
+ "README.md"
+ ],
"scripts": {
- "build": "rollup -c ./webview-src/rollup.config.js",
+ "build": "rollup -c",
"prepublishOnly": "yarn build",
"pretest": "yarn build"
},
- "devDependencies": {
- "@rollup/plugin-node-resolve": "13.3.0",
- "@rollup/plugin-typescript": "8.3.3",
- "@rollup/plugin-terser": "0.4.4",
- "rollup": "2.75.6",
- "typescript": "4.7.3"
- },
"dependencies": {
- "@tauri-apps/api": "^2.0.0-alpha.11",
- "tslib": "^2.1.0"
+ "@tauri-apps/api": ">=2.0.0-beta.6"
+ },
+ "devDependencies": {
+ "@rollup/plugin-typescript": "^11.1.6",
+ "rollup": "^4.9.6",
+ "typescript": "^5.3.3",
+ "tslib": "^2.6.2"
}
}
diff --git a/tooling/cli/templates/plugin/rollup.config.js b/tooling/cli/templates/plugin/rollup.config.js
new file mode 100644
index 000000000..d83436352
--- /dev/null
+++ b/tooling/cli/templates/plugin/rollup.config.js
@@ -0,0 +1,31 @@
+import { readFileSync } from 'fs'
+import { join } from 'path'
+import { cwd } from 'process'
+import typescript from '@rollup/plugin-typescript'
+
+const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json'), 'utf8'))
+
+export default {
+ input: 'guest-js/index.ts',
+ output: [
+ {
+ file: pkg.exports.import,
+ format: 'esm'
+ },
+ {
+ file: pkg.exports.require,
+ format: 'cjs'
+ }
+ ],
+ plugins: [
+ typescript({
+ declaration: true,
+ declarationDir: `./${pkg.exports.import.split('/')[0]}`
+ })
+ ],
+ external: [
+ /^@tauri-apps\/api/,
+ ...Object.keys(pkg.dependencies || {}),
+ ...Object.keys(pkg.peerDependencies || {})
+ ]
+}
diff --git a/tooling/cli/templates/plugin/tsconfig.json b/tooling/cli/templates/plugin/tsconfig.json
new file mode 100644
index 000000000..059112270
--- /dev/null
+++ b/tooling/cli/templates/plugin/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "compilerOptions": {
+ "target": "es2021",
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "skipLibCheck": true,
+ "strict": true,
+ "noUnusedLocals": true,
+ "noImplicitAny": true,
+ "noEmit": true
+ },
+ "include": ["guest-js/*.ts"],
+ "exclude": ["dist-js", "node_modules"]
+}
diff --git a/tooling/cli/templates/plugin/webview-dist/index.d.ts b/tooling/cli/templates/plugin/webview-dist/index.d.ts
deleted file mode 100644
index fb4a9c9dd..000000000
--- a/tooling/cli/templates/plugin/webview-dist/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare function execute(): Promise
diff --git a/tooling/cli/templates/plugin/webview-dist/index.js b/tooling/cli/templates/plugin/webview-dist/index.js
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tooling/cli/templates/plugin/webview-src/.gitignore b/tooling/cli/templates/plugin/webview-src/.gitignore
deleted file mode 100644
index 82eea5f8a..000000000
--- a/tooling/cli/templates/plugin/webview-src/.gitignore
+++ /dev/null
@@ -1,66 +0,0 @@
-# Build output
-/dist
-/api
-
-
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-
-# Runtime data
-pids
-*.pid
-*.seed
-*.pid.lock
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-lib-cov
-
-# Coverage directory used by tools like istanbul
-coverage
-
-# nyc test coverage
-.nyc_output
-
-# node-waf configuration
-.lock-wscript
-
-# Compiled binary addons (http://nodejs.org/api/addons.html)
-build/Release
-
-# Dependency directories
-node_modules/
-jspm_packages/
-
-# Typescript v1 declaration files
-typings/
-
-# Optional npm cache directory
-.npm
-
-# Optional eslint cache
-.eslintcache
-
-# Optional REPL history
-.node_repl_history
-
-# Output of 'npm pack'
-*.tgz
-
-# Yarn Integrity file
-.yarn-integrity
-
-# dotenv environment variables file
-.env
-
-/.vs
-.DS_Store
-.Thumbs.db
-*.sublime*
-.idea/
-debug.log
-package-lock.json
-.vscode/settings.json
diff --git a/tooling/cli/templates/plugin/webview-src/rollup.config.js b/tooling/cli/templates/plugin/webview-src/rollup.config.js
deleted file mode 100644
index bf8450c7b..000000000
--- a/tooling/cli/templates/plugin/webview-src/rollup.config.js
+++ /dev/null
@@ -1,21 +0,0 @@
-import { nodeResolve } from '@rollup/plugin-node-resolve'
-import typescript from '@rollup/plugin-typescript'
-import terser from '@rollup/plugin-terser'
-
-export default {
- input: './webview-src/index.ts',
- output: {
- dir: './webview-dist',
- entryFileNames: '[name].js',
- format: 'es',
- exports: 'auto'
- },
- plugins: [
- nodeResolve(),
- terser(),
- typescript({
- tsconfig: './webview-src/tsconfig.json',
- moduleResolution: 'node'
- })
- ]
-}
diff --git a/tooling/cli/templates/plugin/webview-src/tsconfig.json b/tooling/cli/templates/plugin/webview-src/tsconfig.json
deleted file mode 100644
index a120087de..000000000
--- a/tooling/cli/templates/plugin/webview-src/tsconfig.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "compilerOptions": {
- "target": "ES5",
- "strict": true,
- "allowJs": true,
- "esModuleInterop": true,
- "baseUrl": ".",
- "paths": {
- "types": ["@types"]
- },
- "declaration": true,
- "declarationDir": "../webview-dist",
- "rootDir": "./"
- },
- "include": ["./"]
-}