Skip to content

Commit

Permalink
refactor(tauri): support for building without environmental variables (
Browse files Browse the repository at this point in the history
…#850)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
chippers and lucasfernog committed Feb 9, 2021
1 parent bffbf7d commit e02c941
Show file tree
Hide file tree
Showing 60 changed files with 1,302 additions and 947 deletions.
8 changes: 8 additions & 0 deletions .changes/config-refactor.md
@@ -0,0 +1,8 @@
---
"tauri-utils": minor
"tauri-api": minor
"tauri": minor
---

The Tauri files are now read on the app space instead of the `tauri` create.
Also, the `AppBuilder` `build` function now returns a Result.
7 changes: 6 additions & 1 deletion .changes/config.json
Expand Up @@ -178,6 +178,11 @@
"manager": "rust",
"dependencies": ["tauri-utils"]
},
"tauri-macros": {
"path": "./tauri-macros",
"manager": "rust",
"dependencies": ["tauri-utils"]
},
"tauri-updater": {
"path": "./tauri-updater",
"manager": "rust",
Expand All @@ -186,7 +191,7 @@
"tauri": {
"path": "./tauri",
"manager": "rust",
"dependencies": ["api", "tauri-api", "tauri-updater"]
"dependencies": ["api", "tauri-api", "tauri-macros", "tauri-updater"]
}
}
}
4 changes: 0 additions & 4 deletions .changes/tauri-async.md
Expand Up @@ -3,7 +3,3 @@
---

Added `async` support to the Tauri Rust core on commit [#a169b67](https://github.com/tauri-apps/tauri/commit/a169b67ef0277b958bdac97e33c6e4c41b6844c3).
This is a breaking change:
- Change `.setup(|webview, source| {` to `.setup(|webview, _source| async move {`.
- Change `.invoke_handler(|_webview, arg| {` to `.invoke_handler(|_webview, arg| async move {`.
- Add `.await` after `tauri::execute_promise()` calls.
2 changes: 0 additions & 2 deletions .changes/tauri-cli.md
Expand Up @@ -3,5 +3,3 @@
---

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`.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -2,6 +2,7 @@
members = [
"tauri",
"tauri-api",
"tauri-macros",
"tauri-utils",
]
exclude = [
Expand Down
60 changes: 30 additions & 30 deletions api/.eslintrc.js
Expand Up @@ -3,54 +3,54 @@ module.exports = {

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

parser: "@typescript-eslint/parser",
parser: '@typescript-eslint/parser',

extends: [
"standard-with-typescript",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:lodash-template/recommended",
'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",
'prettier',
'prettier/@typescript-eslint'
],

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

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

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

// add your custom rules here
rules: {
// allow console.log during development only
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
'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,
},
};
'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
}
}
5 changes: 5 additions & 0 deletions api/.prettierrc.js
@@ -0,0 +1,5 @@
module.exports = {
singleQuote: true,
semi: false,
trailingComma: 'none'
}
14 changes: 7 additions & 7 deletions api/babel.config.js
@@ -1,14 +1,14 @@
module.exports = {
presets: [
[
"@babel/preset-env",
'@babel/preset-env',
{
targets: {
node: "current",
node: 'current'
},
modules: "commonjs",
},
modules: 'commonjs'
}
],
"@babel/preset-typescript",
],
};
'@babel/preset-typescript'
]
}
114 changes: 57 additions & 57 deletions api/rollup.config.js
@@ -1,107 +1,107 @@
// rollup.config.js
import { terser } from "rollup-plugin-terser";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import sucrase from "@rollup/plugin-sucrase";
import babel, { getBabelOutputPlugin } from "@rollup/plugin-babel";
import typescript from "@rollup/plugin-typescript";
import pkg from "./package.json";
import { terser } from 'rollup-plugin-terser'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import sucrase from '@rollup/plugin-sucrase'
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel'
import typescript from '@rollup/plugin-typescript'
import pkg from './package.json'

export default [
{
input: {
fs: "./src/fs.ts",
path: "./src/path.ts",
dialog: "./src/dialog.ts",
event: "./src/event.ts",
http: "./src/http.ts",
index: "./src/index.ts",
process: "./src/process.ts",
tauri: "./src/tauri.ts",
window: "./src/window.ts",
cli: "./src/cli.ts",
notification: "./src/notification.ts",
fs: './src/fs.ts',
path: './src/path.ts',
dialog: './src/dialog.ts',
event: './src/event.ts',
http: './src/http.ts',
index: './src/index.ts',
process: './src/process.ts',
tauri: './src/tauri.ts',
window: './src/window.ts',
cli: './src/cli.ts',
notification: './src/notification.ts'
},
treeshake: true,
perf: true,
output: [
{
dir: "dist/",
entryFileNames: "[name].js",
format: "cjs",
exports: "named",
globals: {},
dir: 'dist/',
entryFileNames: '[name].js',
format: 'cjs',
exports: 'named',
globals: {}
},
{
dir: "dist/",
entryFileNames: "[name].mjs",
format: "esm",
exports: "named",
globals: {},
},
dir: 'dist/',
entryFileNames: '[name].mjs',
format: 'esm',
exports: 'named',
globals: {}
}
],
plugins: [
commonjs({}),
resolve({
// pass custom options to the resolve plugin
customResolveOptions: {
moduleDirectory: "node_modules",
},
moduleDirectory: 'node_modules'
}
}),
typescript({
tsconfig: "./tsconfig.json",
tsconfig: './tsconfig.json'
}),
babel({
configFile: false,
presets: [["@babel/preset-env"], ["@babel/preset-typescript"]],
presets: [['@babel/preset-env'], ['@babel/preset-typescript']]
}),
terser(),
terser()
],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...Object.keys(pkg.peerDependencies || {})
],
watch: {
chokidar: true,
include: "src/**",
exclude: "node_modules/**",
},
include: 'src/**',
exclude: 'node_modules/**'
}
},
{
input: {
bundle: "./src/bundle.ts",
bundle: './src/bundle.ts'
},
output: [
{
name: "__TAURI__",
dir: "dist/", // if it needs to run in the browser
entryFileNames: "tauri.bundle.umd.js",
format: "umd",
name: '__TAURI__',
dir: 'dist/', // if it needs to run in the browser
entryFileNames: 'tauri.bundle.umd.js',
format: 'umd',
plugins: [
getBabelOutputPlugin({
presets: [["@babel/preset-env", { modules: "umd" }]],
allowAllFormats: true,
presets: [['@babel/preset-env', { modules: 'umd' }]],
allowAllFormats: true
}),
terser(),
terser()
],
globals: {},
},
globals: {}
}
],
plugins: [
sucrase({
exclude: ["node_modules"],
transforms: ["typescript"],
exclude: ['node_modules'],
transforms: ['typescript']
}),
resolve({
// pass custom options to the resolve plugin
customResolveOptions: {
moduleDirectory: "node_modules",
},
}),
moduleDirectory: 'node_modules'
}
})
],
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
],
},
];
...Object.keys(pkg.peerDependencies || {})
]
}
]
26 changes: 13 additions & 13 deletions api/src/bundle.ts
@@ -1,14 +1,14 @@
import "regenerator-runtime/runtime";
import * as cli from "./cli";
import * as dialog from "./dialog";
import * as event from "./event";
import * as fs from "./fs";
import * as path from "./path";
import http from "./http";
import * as process from "./process";
import * as tauri from "./tauri";
import * as window from "./window";
import * as notification from "./notification";
import 'regenerator-runtime/runtime'
import * as cli from './cli'
import * as dialog from './dialog'
import * as event from './event'
import * as fs from './fs'
import * as path from './path'
import http from './http'
import * as process from './process'
import * as tauri from './tauri'
import * as window from './window'
import * as notification from './notification'

export {
cli,
Expand All @@ -20,5 +20,5 @@ export {
process,
tauri,
window,
notification,
};
notification
}

0 comments on commit e02c941

Please sign in to comment.