Skip to content

Commit 3e8abe3

Browse files
authored
feat(cli) rewrite the core CLI in Rust (#851)
1 parent 23132ac commit 3e8abe3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+11428
-14064
lines changed

.changes/cli-rust.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": minor
3+
"tauri-bundler": minor
4+
---
5+
6+
The `dev` and `build` pipeline is now written in Rust.

.changes/config.json

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,36 @@
139139
}
140140
},
141141
"packages": {
142-
"tauri.js": {
143-
"path": "./cli/tauri.js",
142+
"api": {
143+
"path": "./api",
144144
"manager": "javascript",
145-
"dependencies": ["tauri"],
146145
"assets": [
147146
{
148-
"path": "./cli/tauri.js/tauri-${ pkgFile.version }.tgz",
149-
"name": "tauri.js-${ pkgFile.version }.tgz"
147+
"path": "./api/tauri-${ pkgFile.version }.tgz",
148+
"name": "api-${ pkgFile.version }.tgz"
150149
}
151150
]
152151
},
153152
"tauri-bundler": {
154153
"path": "./cli/tauri-bundler",
155154
"manager": "rust"
156155
},
156+
"tauri-cli": {
157+
"path": "./cli/core",
158+
"manager": "rust",
159+
"dependencies": ["api", "tauri-bundler", "tauri"]
160+
},
161+
"tauri.js": {
162+
"path": "./cli/tauri.js",
163+
"manager": "javascript",
164+
"dependencies": ["tauri-cli"],
165+
"assets": [
166+
{
167+
"path": "./cli/tauri.js/tauri-${ pkgFile.version }.tgz",
168+
"name": "tauri.js-${ pkgFile.version }.tgz"
169+
}
170+
]
171+
},
157172
"tauri-utils": {
158173
"path": "./tauri-utils",
159174
"manager": "rust"
@@ -171,7 +186,7 @@
171186
"tauri": {
172187
"path": "./tauri",
173188
"manager": "rust",
174-
"dependencies": ["tauri-api", "tauri-updater"]
189+
"dependencies": ["api", "tauri-api", "tauri-updater"]
175190
}
176191
}
177192
}

.changes/tauri-api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"tauri.js": minor
3+
---
4+
5+
The Tauri API interface is now shipped with the `@tauri-apps/api` package instead of the deprecated `tauri` package.
6+
To use the new API package, delete the old `tauri` from your `package.json` and install the new package:
7+
`$ yarn remove tauri && yarn add @tauri-apps/api` or `$ npm uninstall tauri && npm install @tauri-apps/api`.
8+
And change all `import { someApi } from 'tauri/api` to `import { someApi } from '@tauri-apps/api'`.

.changes/tauri-cli.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri.js": minor
3+
---
4+
5+
The Tauri Node.js CLI package is now `@tauri-apps/cli`.
6+
To use the new CLI, delete the old `tauri` from your `package.json` and install the new package:
7+
`$ yarn remove tauri && yarn add --dev @tauri-apps/cli` or `$ npm uninstall tauri && npm install --save-dev @tauri-apps/cli`.

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/cli/tauri-bundler/ @tauri-apps/bundler
1717

18+
/cli/core/ @tauri-apps/core
19+
1820
/cli/tauri.js/ @tauri-apps/js-cli
1921

2022
/tauri-update/ @tauri-apps/core

.github/workflows/core-lint-fmt.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- 'tauri/**'
88
- 'tauri-utils/**'
99
- 'tauri-api/**'
10+
- 'cli/core/**'
1011

1112
jobs:
1213
workspace_clippy_fmt_check:
@@ -38,6 +39,28 @@ jobs:
3839
command: fmt
3940
args: --all -- --check
4041

42+
cli_clippy_fmt_check:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v2
47+
- run: rustup component add clippy
48+
- uses: actions-rs/clippy-check@v1
49+
with:
50+
token: ${{ secrets.GITHUB_TOKEN }}
51+
args: --manifest-path ./cli/core/Cargo.toml --all-targets -- -D warnings
52+
name: cli
53+
- uses: actions-rs/toolchain@v1
54+
with:
55+
profile: minimal
56+
toolchain: nightly
57+
override: true
58+
components: rustfmt
59+
- uses: actions-rs/cargo@v1
60+
with:
61+
command: fmt
62+
args: --manifest-path ./cli/core/Cargo.toml --all -- --check
63+
4164
core_clippy_check:
4265
runs-on: ubuntu-latest
4366
strategy:

.github/workflows/test-core.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,30 @@ jobs:
4646
TAURI_DIST_DIR: ${{ runner.workspace }}/tauri/tauri/examples/communication/dist
4747
TAURI_DIR: ${{ runner.workspace }}/tauri/tauri/examples/communication/src-tauri
4848

49+
test-tauri-cli:
50+
runs-on: ${{ matrix.platform }}
51+
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
platform: [ubuntu-latest, macos-latest, windows-latest]
56+
57+
steps:
58+
- uses: actions/checkout@v2
59+
- name: install stable
60+
uses: actions-rs/toolchain@v1
61+
with:
62+
toolchain: stable
63+
override: true
64+
- name: build api
65+
working-directory: ./api
66+
run: yarn && yarn build
67+
- name: build CLI
68+
uses: actions-rs/cargo@v1
69+
with:
70+
command: build
71+
args: --manifest-path ./cli/core/Cargo.toml
72+
4973
test-tauri-js-cli:
5074
runs-on: ${{ matrix.platform }}
5175

@@ -61,9 +85,8 @@ jobs:
6185
run: |
6286
sudo apt-get update
6387
sudo apt-get install -y webkit2gtk-4.0
64-
- run: cargo install --path ./cli/tauri-bundler --force
6588
- name: test
66-
timeout-minutes: 15
89+
timeout-minutes: 30
6790
run: |
6891
cd ./cli/tauri.js
6992
yarn

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ TODO.md
7676
target
7777

7878
# lock for libs
79-
Cargo.lock
79+
/Cargo.lock
8080
yarn.lock
8181

8282
/cli/tauri.js/test/jest/tmp

api/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/src/types/config.validator.ts

api/.eslintrc.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module.exports = {
2+
root: true,
3+
4+
env: {
5+
node: true,
6+
jest: true,
7+
},
8+
9+
parser: "@typescript-eslint/parser",
10+
11+
extends: [
12+
"standard-with-typescript",
13+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
14+
"plugin:lodash-template/recommended",
15+
// TODO: make this work with typescript
16+
// 'plugin:node/recommended'
17+
"prettier",
18+
"prettier/@typescript-eslint",
19+
],
20+
21+
plugins: ["@typescript-eslint", "node", "security"],
22+
23+
parserOptions: {
24+
tsconfigRootDir: __dirname,
25+
project: "./tsconfig.json",
26+
},
27+
28+
globals: {
29+
__statics: true,
30+
process: true,
31+
},
32+
33+
// add your custom rules here
34+
rules: {
35+
// allow console.log during development only
36+
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
37+
// allow debugger during development only
38+
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
39+
"no-process-exit": "off",
40+
"security/detect-non-literal-fs-filename": "warn",
41+
"security/detect-unsafe-regex": "error",
42+
"security/detect-buffer-noassert": "error",
43+
"security/detect-child-process": "warn",
44+
"security/detect-disable-mustache-escape": "error",
45+
"security/detect-eval-with-expression": "error",
46+
"security/detect-no-csrf-before-method-override": "error",
47+
"security/detect-non-literal-regexp": "error",
48+
"security/detect-non-literal-require": "warn",
49+
"security/detect-object-injection": "warn",
50+
"security/detect-possible-timing-attacks": "error",
51+
"security/detect-pseudoRandomBytes": "error",
52+
"space-before-function-paren": "off",
53+
"@typescript-eslint/default-param-last": "off",
54+
"@typescript-eslint/strict-boolean-expressions": 0,
55+
},
56+
};

0 commit comments

Comments
 (0)