Skip to content

Commit

Permalink
feat(cli) rewrite the core CLI in Rust (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Jan 30, 2021
1 parent 23132ac commit 3e8abe3
Show file tree
Hide file tree
Showing 87 changed files with 11,428 additions and 14,064 deletions.
6 changes: 6 additions & 0 deletions .changes/cli-rust.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": minor
"tauri-bundler": minor
---

The `dev` and `build` pipeline is now written in Rust.
27 changes: 21 additions & 6 deletions .changes/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,36 @@
}
},
"packages": {
"tauri.js": {
"path": "./cli/tauri.js",
"api": {
"path": "./api",
"manager": "javascript",
"dependencies": ["tauri"],
"assets": [
{
"path": "./cli/tauri.js/tauri-${ pkgFile.version }.tgz",
"name": "tauri.js-${ pkgFile.version }.tgz"
"path": "./api/tauri-${ pkgFile.version }.tgz",
"name": "api-${ pkgFile.version }.tgz"
}
]
},
"tauri-bundler": {
"path": "./cli/tauri-bundler",
"manager": "rust"
},
"tauri-cli": {
"path": "./cli/core",
"manager": "rust",
"dependencies": ["api", "tauri-bundler", "tauri"]
},
"tauri.js": {
"path": "./cli/tauri.js",
"manager": "javascript",
"dependencies": ["tauri-cli"],
"assets": [
{
"path": "./cli/tauri.js/tauri-${ pkgFile.version }.tgz",
"name": "tauri.js-${ pkgFile.version }.tgz"
}
]
},
"tauri-utils": {
"path": "./tauri-utils",
"manager": "rust"
Expand All @@ -171,7 +186,7 @@
"tauri": {
"path": "./tauri",
"manager": "rust",
"dependencies": ["tauri-api", "tauri-updater"]
"dependencies": ["api", "tauri-api", "tauri-updater"]
}
}
}
8 changes: 8 additions & 0 deletions .changes/tauri-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"tauri.js": minor
---

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

The Tauri Node.js CLI package is now `@tauri-apps/cli`.
To use the new CLI, delete the old `tauri` from your `package.json` and install the new package:
`$ yarn remove tauri && yarn add --dev @tauri-apps/cli` or `$ npm uninstall tauri && npm install --save-dev @tauri-apps/cli`.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/cli/tauri-bundler/ @tauri-apps/bundler

/cli/core/ @tauri-apps/core

/cli/tauri.js/ @tauri-apps/js-cli

/tauri-update/ @tauri-apps/core
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/core-lint-fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'tauri/**'
- 'tauri-utils/**'
- 'tauri-api/**'
- 'cli/core/**'

jobs:
workspace_clippy_fmt_check:
Expand Down Expand Up @@ -38,6 +39,28 @@ jobs:
command: fmt
args: --all -- --check

cli_clippy_fmt_check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --manifest-path ./cli/core/Cargo.toml --all-targets -- -D warnings
name: cli
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ./cli/core/Cargo.toml --all -- --check

core_clippy_check:
runs-on: ubuntu-latest
strategy:
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/test-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@ jobs:
TAURI_DIST_DIR: ${{ runner.workspace }}/tauri/tauri/examples/communication/dist
TAURI_DIR: ${{ runner.workspace }}/tauri/tauri/examples/communication/src-tauri

test-tauri-cli:
runs-on: ${{ matrix.platform }}

strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- name: install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: build api
working-directory: ./api
run: yarn && yarn build
- name: build CLI
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path ./cli/core/Cargo.toml

test-tauri-js-cli:
runs-on: ${{ matrix.platform }}

Expand All @@ -61,9 +85,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0
- run: cargo install --path ./cli/tauri-bundler --force
- name: test
timeout-minutes: 15
timeout-minutes: 30
run: |
cd ./cli/tauri.js
yarn
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TODO.md
target

# lock for libs
Cargo.lock
/Cargo.lock
yarn.lock

/cli/tauri.js/test/jest/tmp
Expand Down
1 change: 1 addition & 0 deletions api/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/src/types/config.validator.ts
56 changes: 56 additions & 0 deletions api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = {
root: true,

env: {
node: true,
jest: true,
},

parser: "@typescript-eslint/parser",

extends: [
"standard-with-typescript",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:lodash-template/recommended",
// TODO: make this work with typescript
// 'plugin:node/recommended'
"prettier",
"prettier/@typescript-eslint",
],

plugins: ["@typescript-eslint", "node", "security"],

parserOptions: {
tsconfigRootDir: __dirname,
project: "./tsconfig.json",
},

globals: {
__statics: true,
process: true,
},

// add your custom rules here
rules: {
// allow console.log during development only
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
// allow debugger during development only
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
"no-process-exit": "off",
"security/detect-non-literal-fs-filename": "warn",
"security/detect-unsafe-regex": "error",
"security/detect-buffer-noassert": "error",
"security/detect-child-process": "warn",
"security/detect-disable-mustache-escape": "error",
"security/detect-eval-with-expression": "error",
"security/detect-no-csrf-before-method-override": "error",
"security/detect-non-literal-regexp": "error",
"security/detect-non-literal-require": "warn",
"security/detect-object-injection": "warn",
"security/detect-possible-timing-attacks": "error",
"security/detect-pseudoRandomBytes": "error",
"space-before-function-paren": "off",
"@typescript-eslint/default-param-last": "off",
"@typescript-eslint/strict-boolean-expressions": 0,
},
};
64 changes: 64 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Build output
dist/

# 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
14 changes: 14 additions & 0 deletions api/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current",
},
modules: "commonjs",
},
],
"@babel/preset-typescript",
],
};
84 changes: 84 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"name": "@tauri-apps/api",
"version": "0.1.0",
"description": "Tauri API definitions",
"main": "./dist/index",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
},
"scripts": {
"build": "rimraf ./dist && rollup -c --silent",
"prepublishOnly": "yarn build",
"lint": "eslint --ext ts \"./src/**/*.ts\"",
"lint-fix": "eslint --fix --ext ts \"./src/**/*.ts\"",
"lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts npm yarn",
"format": "prettier --write --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"format:check": "prettier --check --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tauri-apps/tauri.git"
},
"contributors": [
"Tauri Team <team@tauri-apps.org> (https://tauri.studio)",
"Daniel Thompson-Yvetot <denjell@sfosc.org>",
"Lucas Fernandes Gonçalves Nogueira <lucas@tauri.studio>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/tauri-apps/tauri/issues"
},
"homepage": "https://github.com/tauri-apps/tauri#readme",
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">= 10.17.0",
"npm": ">= 6.6.0",
"yarn": ">= 1.19.1"
},
"devDependencies": {
"@babel/core": "7.12.9",
"@babel/preset-env": "7.12.7",
"@babel/preset-typescript": "7.12.7",
"@rollup/plugin-babel": "5.2.2",
"@rollup/plugin-commonjs": "17.0.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "11.0.0",
"@rollup/plugin-sucrase": "3.1.0",
"@rollup/plugin-typescript": "8.0.0",
"@typescript-eslint/eslint-plugin": "4.9.0",
"@typescript-eslint/parser": "4.9.0",
"eslint": "7.14.0",
"eslint-config-prettier": "6.15.0",
"eslint-config-standard-with-typescript": "19.0.1",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-lodash-template": "0.19.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-security": "1.4.0",
"eslint-plugin-standard": "4.1.0",
"husky": "4.3.0",
"lint-staged": "10.5.3",
"lockfile-lint": "4.3.7",
"prettier": "2.2.1",
"rimraf": "3.0.2",
"rollup": "2.34.1",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.29.0",
"typescript": "4.1.2"
},
"resolutions": {
"**/lodash": ">=4.17.19"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx,md,html,css,json}": "prettier --write --end-of-line=auto \"./**/*.{js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
"*.{ts,tsx}": "eslint --fix --ext ts ./src/**/*.ts"
}
}
Loading

0 comments on commit 3e8abe3

Please sign in to comment.