@tauri-apps/cli 1.0.0-rc.2 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE_APACHE-2.0 +177 -0
- package/LICENSE_MIT +21 -0
- package/index.d.ts +1 -1
- package/main.d.ts +4 -0
- package/main.js +13 -0
- package/package.json +11 -11
- package/src/lib.rs +16 -3
- package/tauri.js +5 -6
- package/.github-example/workflows/CI.yml +0 -469
- package/test/jest/__tests__/template.spec.js +0 -41
- package/test/jest/fixtures/app/dist/index.html +0 -140
- package/test/jest/fixtures/app/index.js +0 -53
- package/test/jest/fixtures/app/package.json +0 -22
- package/test/jest/fixtures/app/src-tauri/Cargo.toml +0 -34
- package/test/jest/fixtures/app/src-tauri/build.rs +0 -7
- package/test/jest/fixtures/app/src-tauri/icons/128x128.png +0 -0
- package/test/jest/fixtures/app/src-tauri/icons/128x128@2x.png +0 -0
- package/test/jest/fixtures/app/src-tauri/icons/32x32.png +0 -0
- package/test/jest/fixtures/app/src-tauri/icons/icon.icns +0 -0
- package/test/jest/fixtures/app/src-tauri/icons/icon.ico +0 -0
- package/test/jest/fixtures/app/src-tauri/icons/icon.png +0 -0
- package/test/jest/fixtures/app/src-tauri/src/main.rs +0 -20
- package/test/jest/fixtures/app/src-tauri/tauri.conf.json +0 -28
- package/test/jest/fixtures/app-test-setup.js +0 -86
- package/test/jest/fixtures/empty/dist/index.html +0 -6
- package/test/jest/fixtures/empty/package.json +0 -1
- package/test/jest/helpers/logger.js +0 -25
- package/test/jest/helpers/spawn.js +0 -73
- package/test/jest/jest.setup.js +0 -6
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "test",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"tauri:prod": "tauri",
|
|
8
|
-
"tauri:source": "node ../../../../bin/tauri",
|
|
9
|
-
"tauri:source:init": "yarn tauri:source init --tauriPath ..",
|
|
10
|
-
"tauri:prod:init": "yarn tauri:prod init",
|
|
11
|
-
"tauri:source:dev": "yarn tauri:source dev",
|
|
12
|
-
"tauri:prod:dev": "yarn tauri:prod dev",
|
|
13
|
-
"tauri:source:build": "yarn tauri:source build",
|
|
14
|
-
"tauri:prod:build": "yarn tauri:prod build"
|
|
15
|
-
},
|
|
16
|
-
"author": "",
|
|
17
|
-
"license": "Apache-2.0 OR MIT",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"cors": "^2.8.5",
|
|
20
|
-
"express": "^4.17.1"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
workspace = { }
|
|
2
|
-
|
|
3
|
-
[package]
|
|
4
|
-
name = "app"
|
|
5
|
-
version = "0.1.0"
|
|
6
|
-
description = "A Tauri App"
|
|
7
|
-
authors = [ "Tauri Programme within The Commons Conservancy" ]
|
|
8
|
-
license = ""
|
|
9
|
-
repository = ""
|
|
10
|
-
edition = "2021"
|
|
11
|
-
rust-version = "1.57"
|
|
12
|
-
|
|
13
|
-
[package.metadata.bundle]
|
|
14
|
-
identifier = "com.tauri.dev"
|
|
15
|
-
icon = [
|
|
16
|
-
"icons/32x32.png",
|
|
17
|
-
"icons/128x128.png",
|
|
18
|
-
"icons/128x128@2x.png",
|
|
19
|
-
"icons/icon.icns",
|
|
20
|
-
"icons/icon.ico"
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
[build-dependencies]
|
|
24
|
-
tauri-build = { path = "../../../../../../../core/tauri-build", features = [] }
|
|
25
|
-
|
|
26
|
-
[dependencies]
|
|
27
|
-
serde_json = "1.0.74"
|
|
28
|
-
serde = "1.0"
|
|
29
|
-
serde_derive = "1.0"
|
|
30
|
-
tauri = { path = "../../../../../../../core/tauri", features = ["api-all"] }
|
|
31
|
-
|
|
32
|
-
[features]
|
|
33
|
-
default = [ "custom-protocol" ]
|
|
34
|
-
custom-protocol = [ "tauri/custom-protocol" ]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#[tauri::command(with_window)]
|
|
2
|
-
fn exit(window: tauri::Window) {
|
|
3
|
-
window.close().unwrap();
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
fn main() {
|
|
7
|
-
tauri::Builder::default()
|
|
8
|
-
.on_page_load(|window, _| {
|
|
9
|
-
let window_ = window.clone();
|
|
10
|
-
window.listen("hello".into(), move |_| {
|
|
11
|
-
window_
|
|
12
|
-
.emit(&"reply".to_string(), Some("{ msg: 'TEST' }".to_string()))
|
|
13
|
-
.unwrap();
|
|
14
|
-
});
|
|
15
|
-
window.eval("window.onTauriInit()").unwrap();
|
|
16
|
-
})
|
|
17
|
-
.invoke_handler(tauri::generate_handler![exit])
|
|
18
|
-
.run(tauri::generate_context!())
|
|
19
|
-
.expect("error encountered while running tauri application");
|
|
20
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"build": {
|
|
3
|
-
"devPath": "../dist",
|
|
4
|
-
"distDir": "../dist",
|
|
5
|
-
"withGlobalTauri": true
|
|
6
|
-
},
|
|
7
|
-
"tauri": {
|
|
8
|
-
"allowlist": {
|
|
9
|
-
"all": true
|
|
10
|
-
},
|
|
11
|
-
"bundle": {
|
|
12
|
-
"icon": [
|
|
13
|
-
"icons/32x32.png",
|
|
14
|
-
"icons/128x128.png",
|
|
15
|
-
"icons/128x128@2x.png",
|
|
16
|
-
"icons/icon.icns",
|
|
17
|
-
"icons/icon.ico"
|
|
18
|
-
],
|
|
19
|
-
"identifier": "fixture.app"
|
|
20
|
-
},
|
|
21
|
-
"windows": [
|
|
22
|
-
{
|
|
23
|
-
"title": "Fixture",
|
|
24
|
-
"visible": false
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const http = require('http')
|
|
3
|
-
|
|
4
|
-
const currentDirName = __dirname
|
|
5
|
-
const mockFixtureDir = path.resolve(currentDirName, '../fixtures')
|
|
6
|
-
|
|
7
|
-
module.exports.fixtureDir = mockFixtureDir
|
|
8
|
-
|
|
9
|
-
module.exports.initJest = (mockFixture) => {
|
|
10
|
-
jest.setTimeout(1200000)
|
|
11
|
-
|
|
12
|
-
const mockAppDir = path.join(mockFixtureDir, mockFixture)
|
|
13
|
-
process.env.__TAURI_TEST_APP_DIR = mockAppDir
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports.startServer = (onSuccess) => {
|
|
17
|
-
const responses = {
|
|
18
|
-
writeFile: null,
|
|
19
|
-
readFile: null,
|
|
20
|
-
writeFileWithDir: null,
|
|
21
|
-
readFileWithDir: null,
|
|
22
|
-
readDir: null,
|
|
23
|
-
readDirWithDir: null,
|
|
24
|
-
copyFile: null,
|
|
25
|
-
copyFileWithDir: null,
|
|
26
|
-
createDir: null,
|
|
27
|
-
createDirWithDir: null,
|
|
28
|
-
removeDir: null,
|
|
29
|
-
removeDirWithDir: null,
|
|
30
|
-
renameFile: null,
|
|
31
|
-
renameFileWithDir: null,
|
|
32
|
-
removeFile: null,
|
|
33
|
-
renameFileWithDir: null,
|
|
34
|
-
listen: null
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function addResponse(response) {
|
|
38
|
-
responses[response.cmd] = true
|
|
39
|
-
if (!Object.values(responses).some((c) => c === null)) {
|
|
40
|
-
server.close(onSuccess)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const app = http.createServer((req, res) => {
|
|
45
|
-
// Set CORS headers
|
|
46
|
-
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
47
|
-
res.setHeader('Access-Control-Request-Method', '*')
|
|
48
|
-
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET')
|
|
49
|
-
res.setHeader('Access-Control-Allow-Headers', '*')
|
|
50
|
-
|
|
51
|
-
if (req.method === 'OPTIONS') {
|
|
52
|
-
res.writeHead(200)
|
|
53
|
-
res.end()
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (req.method === 'POST') {
|
|
58
|
-
let body = ''
|
|
59
|
-
req.on('data', (chunk) => {
|
|
60
|
-
body += chunk.toString()
|
|
61
|
-
})
|
|
62
|
-
if (req.url === '/reply') {
|
|
63
|
-
req.on('end', () => {
|
|
64
|
-
const json = JSON.parse(body)
|
|
65
|
-
addResponse(json)
|
|
66
|
-
res.writeHead(200)
|
|
67
|
-
res.end()
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
if (req.url === '/error') {
|
|
71
|
-
req.on('end', () => {
|
|
72
|
-
res.writeHead(200)
|
|
73
|
-
res.end()
|
|
74
|
-
throw new Error(body)
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const port = 7000
|
|
81
|
-
const server = app.listen(port)
|
|
82
|
-
return {
|
|
83
|
-
server,
|
|
84
|
-
responses
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
|
|
5
|
-
const ms = require('ms')
|
|
6
|
-
|
|
7
|
-
let prevTime
|
|
8
|
-
|
|
9
|
-
module.exports = (banner) => {
|
|
10
|
-
return (msg) => {
|
|
11
|
-
const curr = +new Date()
|
|
12
|
-
const diff = curr - (prevTime || curr)
|
|
13
|
-
|
|
14
|
-
prevTime = curr
|
|
15
|
-
|
|
16
|
-
if (msg) {
|
|
17
|
-
console.log(
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-call
|
|
19
|
-
` ${String(banner)} ${msg} ${`+${ms(diff)}`}`
|
|
20
|
-
)
|
|
21
|
-
} else {
|
|
22
|
-
console.log()
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
|
|
5
|
-
const crossSpawn = require('cross-spawn')
|
|
6
|
-
const logger = require('./logger')
|
|
7
|
-
|
|
8
|
-
const log = logger('app:spawn')
|
|
9
|
-
const warn = logger('app:spawn')
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
Returns pid, takes onClose
|
|
13
|
-
*/
|
|
14
|
-
module.exports.spawn = (
|
|
15
|
-
cmd,
|
|
16
|
-
params,
|
|
17
|
-
cwd,
|
|
18
|
-
onClose
|
|
19
|
-
) => {
|
|
20
|
-
log(`Running "${cmd} ${params.join(' ')}"`)
|
|
21
|
-
log()
|
|
22
|
-
|
|
23
|
-
// TODO: move to execa?
|
|
24
|
-
const runner = crossSpawn(cmd, params, {
|
|
25
|
-
stdio: 'inherit',
|
|
26
|
-
cwd,
|
|
27
|
-
env: process.env
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
runner.on('close', (code) => {
|
|
31
|
-
log()
|
|
32
|
-
if (code) {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
34
|
-
log(`Command "${cmd}" failed with exit code: ${code}`)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
38
|
-
onClose && onClose(code || 0, runner.pid || 0)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
return runner.pid || 0
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/*
|
|
45
|
-
Returns nothing, takes onFail
|
|
46
|
-
*/
|
|
47
|
-
module.exports.spawnSync = (
|
|
48
|
-
cmd,
|
|
49
|
-
params,
|
|
50
|
-
cwd,
|
|
51
|
-
onFail
|
|
52
|
-
) => {
|
|
53
|
-
log(`[sync] Running "${cmd} ${params.join(' ')}"`)
|
|
54
|
-
log()
|
|
55
|
-
|
|
56
|
-
const runner = crossSpawn.sync(cmd, params, {
|
|
57
|
-
stdio: 'inherit',
|
|
58
|
-
cwd
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
62
|
-
if (runner.status || runner.error) {
|
|
63
|
-
warn()
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
65
|
-
warn(`⚠️ Command "${cmd}" failed with exit code: ${runner.status}`)
|
|
66
|
-
if (runner.status === null) {
|
|
67
|
-
warn(`⚠️ Please globally install "${cmd}"`)
|
|
68
|
-
}
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
70
|
-
onFail && onFail()
|
|
71
|
-
process.exit(1)
|
|
72
|
-
}
|
|
73
|
-
}
|