@tauri-apps/cli 2.6.2 → 2.7.0

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## \[2.7.0]
4
+
5
+ ### New Features
6
+
7
+ - [`33d079392`](https://www.github.com/tauri-apps/tauri/commit/33d079392ac4a5a153b7d8a6d82fefd6f54a2bdf) ([#13811](https://www.github.com/tauri-apps/tauri/pull/13811) by [@mhbagheri-99](https://www.github.com/tauri-apps/tauri/../../mhbagheri-99)) Allow runner configuration to be an object with cmd, cwd, and args properties. The runner can now be configured as `{ "cmd": "my_runner", "cwd": "/path", "args": ["--quiet"] }` while maintaining backwards compatibility with the existing string format.
8
+
9
+ ### Enhancements
10
+
11
+ - [`232265c70`](https://www.github.com/tauri-apps/tauri/commit/232265c70e1c213bbb3f84b5541ddc07d330fce1) ([#13209](https://www.github.com/tauri-apps/tauri/pull/13209) by [@kandrelczyk](https://www.github.com/tauri-apps/tauri/../../kandrelczyk)) Binaries are patched before bundling to add the type of a bundle they will placed in. This information will be used during update process to select the correct target.
12
+
13
+ ### Bug Fixes
14
+
15
+ - [`916aeaa48`](https://www.github.com/tauri-apps/tauri/commit/916aeaa48646a483a78e51cfe1633800ee62c37c) ([#13781](https://www.github.com/tauri-apps/tauri/pull/13781) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Fixes Android dev and build commands reading `tauri.ios.conf.json` instead of `tauri.android.conf.json` to merge platform-specific configuration.
16
+ - [`0f248b111`](https://www.github.com/tauri-apps/tauri/commit/0f248b111ffb8af934eaf64bd8f4591e628da786) ([#13799](https://www.github.com/tauri-apps/tauri/pull/13799) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Install iOS dependencies when needed.
17
+ - [`7a6fd5b75`](https://www.github.com/tauri-apps/tauri/commit/7a6fd5b75d61071e2771f6277c0376ec206d302a) ([#13863](https://www.github.com/tauri-apps/tauri/pull/13863) by [@FabianLars](https://www.github.com/tauri-apps/tauri/../../FabianLars)) The AppImage bundler now pulls the AppRun binaries from our GitHub mirror, fixing 404 errors.
18
+ - [`bda830410`](https://www.github.com/tauri-apps/tauri/commit/bda8304107da7ca60caaba5674faa793491898c6) ([#13833](https://www.github.com/tauri-apps/tauri/pull/13833) by [@Legend-Master](https://www.github.com/tauri-apps/tauri/../../Legend-Master)) Fail with an error when trying to migrate from v2 alpha
19
+ - [`bda830410`](https://www.github.com/tauri-apps/tauri/commit/bda8304107da7ca60caaba5674faa793491898c6) ([#13833](https://www.github.com/tauri-apps/tauri/pull/13833) by [@Legend-Master](https://www.github.com/tauri-apps/tauri/../../Legend-Master)) Use v2 stable instead of v2-rc when migrating from v2-beta
20
+
21
+ ### Dependencies
22
+
23
+ - Upgraded to `tauri-cli@2.7.0`
24
+
3
25
  ## \[2.6.2]
4
26
 
5
27
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://schema.tauri.app/config/2.6.2",
3
+ "$id": "https://schema.tauri.app/config/2.7.0",
4
4
  "title": "Config",
5
5
  "description": "The Tauri configuration object.\n It is read from a file where you can define your frontend assets,\n configure the bundler and define a tray icon.\n\n The configuration file is generated by the\n [`tauri init`](https://v2.tauri.app/reference/cli/#init) command that lives in\n your Tauri application source directory (src-tauri).\n\n Once generated, you may modify it at will to customize your Tauri application.\n\n ## File Formats\n\n By default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\n Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively.\n The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`.\n The TOML file name is `Tauri.toml`.\n\n ## Platform-Specific Configuration\n\n In addition to the default configuration file, Tauri can\n read a platform-specific configuration from `tauri.linux.conf.json`,\n `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json`\n (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used),\n which gets merged with the main configuration object.\n\n ## Configuration Structure\n\n The configuration is composed of the following objects:\n\n - [`app`](#appconfig): The Tauri configuration\n - [`build`](#buildconfig): The build configuration\n - [`bundle`](#bundleconfig): The bundle configurations\n - [`plugins`](#pluginconfig): The plugins configuration\n\n Example tauri.config.json file:\n\n ```json\n {\n \"productName\": \"tauri-app\",\n \"version\": \"0.1.0\",\n \"build\": {\n \"beforeBuildCommand\": \"\",\n \"beforeDevCommand\": \"\",\n \"devUrl\": \"http://localhost:3000\",\n \"frontendDist\": \"../dist\"\n },\n \"app\": {\n \"security\": {\n \"csp\": null\n },\n \"windows\": [\n {\n \"fullscreen\": false,\n \"height\": 600,\n \"resizable\": true,\n \"title\": \"Tauri App\",\n \"width\": 800\n }\n ]\n },\n \"bundle\": {},\n \"plugins\": {}\n }\n ```",
6
6
  "type": "object",
@@ -1805,9 +1805,13 @@
1805
1805
  "properties": {
1806
1806
  "runner": {
1807
1807
  "description": "The binary used to build and run the application.",
1808
- "type": [
1809
- "string",
1810
- "null"
1808
+ "anyOf": [
1809
+ {
1810
+ "$ref": "#/definitions/RunnerConfig"
1811
+ },
1812
+ {
1813
+ "type": "null"
1814
+ }
1811
1815
  ]
1812
1816
  },
1813
1817
  "devUrl": {
@@ -1880,6 +1884,45 @@
1880
1884
  },
1881
1885
  "additionalProperties": false
1882
1886
  },
1887
+ "RunnerConfig": {
1888
+ "description": "The runner configuration.",
1889
+ "anyOf": [
1890
+ {
1891
+ "description": "A string specifying the binary to run.",
1892
+ "type": "string"
1893
+ },
1894
+ {
1895
+ "description": "An object with advanced configuration options.",
1896
+ "type": "object",
1897
+ "required": [
1898
+ "cmd"
1899
+ ],
1900
+ "properties": {
1901
+ "cmd": {
1902
+ "description": "The binary to run.",
1903
+ "type": "string"
1904
+ },
1905
+ "cwd": {
1906
+ "description": "The current working directory to run the command from.",
1907
+ "type": [
1908
+ "string",
1909
+ "null"
1910
+ ]
1911
+ },
1912
+ "args": {
1913
+ "description": "Arguments to pass to the command.",
1914
+ "type": [
1915
+ "array",
1916
+ "null"
1917
+ ],
1918
+ "items": {
1919
+ "type": "string"
1920
+ }
1921
+ }
1922
+ }
1923
+ }
1924
+ ]
1925
+ },
1883
1926
  "FrontendDist": {
1884
1927
  "description": "Defines the URL or assets to embed in the application.",
1885
1928
  "anyOf": [
package/index.d.ts CHANGED
@@ -2,10 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-License-Identifier: MIT
4
4
 
5
- /* tslint:disable */
6
- /* eslint-disable */
7
-
8
5
  /* auto-generated by NAPI-RS */
9
-
10
- export declare function run(args: Array<string>, binName: string | undefined | null, callback: (...args: any[]) => any): void
6
+ /* eslint-disable */
11
7
  export declare function logError(error: string): void
8
+
9
+ export declare function run(args: Array<string>, binName: string | undefined | null, callback: ((err: Error | null, arg: boolean) => any)): void
package/index.js CHANGED
@@ -2,319 +2,400 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-License-Identifier: MIT
4
4
 
5
- /* tslint:disable */
5
+ // prettier-ignore
6
6
  /* eslint-disable */
7
- /* prettier-ignore */
8
-
7
+ // @ts-nocheck
9
8
  /* auto-generated by NAPI-RS */
10
9
 
11
- const { existsSync, readFileSync } = require('fs')
12
- const { join } = require('path')
13
-
14
- const { platform, arch } = process
10
+ const { createRequire } = require('node:module')
11
+ require = createRequire(__filename)
15
12
 
13
+ const { readFileSync } = require('node:fs')
16
14
  let nativeBinding = null
17
- let localFileExisted = false
18
- let loadError = null
15
+ const loadErrors = []
19
16
 
20
- function isMusl() {
21
- // For Node 10
22
- if (!process.report || typeof process.report.getReport !== 'function') {
23
- try {
24
- const lddPath = require('child_process').execSync('which ldd').toString().trim()
25
- return readFileSync(lddPath, 'utf8').includes('musl')
26
- } catch (e) {
17
+ const isMusl = () => {
18
+ let musl = false
19
+ if (process.platform === 'linux') {
20
+ musl = isMuslFromFilesystem()
21
+ if (musl === null) {
22
+ musl = isMuslFromReport()
23
+ }
24
+ if (musl === null) {
25
+ musl = isMuslFromChildProcess()
26
+ }
27
+ }
28
+ return musl
29
+ }
30
+
31
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
32
+
33
+ const isMuslFromFilesystem = () => {
34
+ try {
35
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
36
+ } catch {
37
+ return null
38
+ }
39
+ }
40
+
41
+ const isMuslFromReport = () => {
42
+ let report = null
43
+ if (typeof process.report?.getReport === 'function') {
44
+ process.report.excludeNetwork = true
45
+ report = process.report.getReport()
46
+ }
47
+ if (!report) {
48
+ return null
49
+ }
50
+ if (report.header && report.header.glibcVersionRuntime) {
51
+ return false
52
+ }
53
+ if (Array.isArray(report.sharedObjects)) {
54
+ if (report.sharedObjects.some(isFileMusl)) {
27
55
  return true
28
56
  }
29
- } else {
30
- const { glibcVersionRuntime } = process.report.getReport().header
31
- return !glibcVersionRuntime
32
57
  }
58
+ return false
33
59
  }
34
60
 
35
- switch (platform) {
36
- case 'android':
37
- switch (arch) {
38
- case 'arm64':
39
- localFileExisted = existsSync(join(__dirname, 'cli.android-arm64.node'))
61
+ const isMuslFromChildProcess = () => {
62
+ try {
63
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
64
+ } catch (e) {
65
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
66
+ return false
67
+ }
68
+ }
69
+
70
+ function requireNative() {
71
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
72
+ try {
73
+ nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
74
+ } catch (err) {
75
+ loadErrors.push(err)
76
+ }
77
+ } else if (process.platform === 'android') {
78
+ if (process.arch === 'arm64') {
79
+ try {
80
+ return require('./cli.android-arm64.node')
81
+ } catch (e) {
82
+ loadErrors.push(e)
83
+ }
84
+ try {
85
+ return require('@tauri-apps/cli-android-arm64')
86
+ } catch (e) {
87
+ loadErrors.push(e)
88
+ }
89
+ } else if (process.arch === 'arm') {
90
+ try {
91
+ return require('./cli.android-arm-eabi.node')
92
+ } catch (e) {
93
+ loadErrors.push(e)
94
+ }
95
+ try {
96
+ return require('@tauri-apps/cli-android-arm-eabi')
97
+ } catch (e) {
98
+ loadErrors.push(e)
99
+ }
100
+ } else {
101
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
102
+ }
103
+ } else if (process.platform === 'win32') {
104
+ if (process.arch === 'x64') {
105
+ try {
106
+ return require('./cli.win32-x64-msvc.node')
107
+ } catch (e) {
108
+ loadErrors.push(e)
109
+ }
110
+ try {
111
+ return require('@tauri-apps/cli-win32-x64-msvc')
112
+ } catch (e) {
113
+ loadErrors.push(e)
114
+ }
115
+ } else if (process.arch === 'ia32') {
116
+ try {
117
+ return require('./cli.win32-ia32-msvc.node')
118
+ } catch (e) {
119
+ loadErrors.push(e)
120
+ }
121
+ try {
122
+ return require('@tauri-apps/cli-win32-ia32-msvc')
123
+ } catch (e) {
124
+ loadErrors.push(e)
125
+ }
126
+ } else if (process.arch === 'arm64') {
127
+ try {
128
+ return require('./cli.win32-arm64-msvc.node')
129
+ } catch (e) {
130
+ loadErrors.push(e)
131
+ }
132
+ try {
133
+ return require('@tauri-apps/cli-win32-arm64-msvc')
134
+ } catch (e) {
135
+ loadErrors.push(e)
136
+ }
137
+ } else {
138
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
139
+ }
140
+ } else if (process.platform === 'darwin') {
141
+ try {
142
+ return require('./cli.darwin-universal.node')
143
+ } catch (e) {
144
+ loadErrors.push(e)
145
+ }
146
+ try {
147
+ return require('@tauri-apps/cli-darwin-universal')
148
+ } catch (e) {
149
+ loadErrors.push(e)
150
+ }
151
+ if (process.arch === 'x64') {
152
+ try {
153
+ return require('./cli.darwin-x64.node')
154
+ } catch (e) {
155
+ loadErrors.push(e)
156
+ }
157
+ try {
158
+ return require('@tauri-apps/cli-darwin-x64')
159
+ } catch (e) {
160
+ loadErrors.push(e)
161
+ }
162
+ } else if (process.arch === 'arm64') {
163
+ try {
164
+ return require('./cli.darwin-arm64.node')
165
+ } catch (e) {
166
+ loadErrors.push(e)
167
+ }
168
+ try {
169
+ return require('@tauri-apps/cli-darwin-arm64')
170
+ } catch (e) {
171
+ loadErrors.push(e)
172
+ }
173
+ } else {
174
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
175
+ }
176
+ } else if (process.platform === 'freebsd') {
177
+ if (process.arch === 'x64') {
178
+ try {
179
+ return require('./cli.freebsd-x64.node')
180
+ } catch (e) {
181
+ loadErrors.push(e)
182
+ }
183
+ try {
184
+ return require('@tauri-apps/cli-freebsd-x64')
185
+ } catch (e) {
186
+ loadErrors.push(e)
187
+ }
188
+ } else if (process.arch === 'arm64') {
189
+ try {
190
+ return require('./cli.freebsd-arm64.node')
191
+ } catch (e) {
192
+ loadErrors.push(e)
193
+ }
194
+ try {
195
+ return require('@tauri-apps/cli-freebsd-arm64')
196
+ } catch (e) {
197
+ loadErrors.push(e)
198
+ }
199
+ } else {
200
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
201
+ }
202
+ } else if (process.platform === 'linux') {
203
+ if (process.arch === 'x64') {
204
+ if (isMusl()) {
40
205
  try {
41
- if (localFileExisted) {
42
- nativeBinding = require('./cli.android-arm64.node')
43
- } else {
44
- nativeBinding = require('@tauri-apps/cli-android-arm64')
45
- }
206
+ return require('./cli.linux-x64-musl.node')
46
207
  } catch (e) {
47
- loadError = e
208
+ loadErrors.push(e)
48
209
  }
49
- break
50
- case 'arm':
51
- localFileExisted = existsSync(join(__dirname, 'cli.android-arm-eabi.node'))
52
210
  try {
53
- if (localFileExisted) {
54
- nativeBinding = require('./cli.android-arm-eabi.node')
55
- } else {
56
- nativeBinding = require('@tauri-apps/cli-android-arm-eabi')
57
- }
211
+ return require('@tauri-apps/cli-linux-x64-musl')
58
212
  } catch (e) {
59
- loadError = e
213
+ loadErrors.push(e)
60
214
  }
61
- break
62
- default:
63
- throw new Error(`Unsupported architecture on Android ${arch}`)
64
- }
65
- break
66
- case 'win32':
67
- switch (arch) {
68
- case 'x64':
69
- localFileExisted = existsSync(
70
- join(__dirname, 'cli.win32-x64-msvc.node')
71
- )
215
+ } else {
72
216
  try {
73
- if (localFileExisted) {
74
- nativeBinding = require('./cli.win32-x64-msvc.node')
75
- } else {
76
- nativeBinding = require('@tauri-apps/cli-win32-x64-msvc')
77
- }
217
+ return require('./cli.linux-x64-gnu.node')
78
218
  } catch (e) {
79
- loadError = e
219
+ loadErrors.push(e)
80
220
  }
81
- break
82
- case 'ia32':
83
- localFileExisted = existsSync(
84
- join(__dirname, 'cli.win32-ia32-msvc.node')
85
- )
86
221
  try {
87
- if (localFileExisted) {
88
- nativeBinding = require('./cli.win32-ia32-msvc.node')
89
- } else {
90
- nativeBinding = require('@tauri-apps/cli-win32-ia32-msvc')
91
- }
222
+ return require('@tauri-apps/cli-linux-x64-gnu')
92
223
  } catch (e) {
93
- loadError = e
224
+ loadErrors.push(e)
94
225
  }
95
- break
96
- case 'arm64':
97
- localFileExisted = existsSync(
98
- join(__dirname, 'cli.win32-arm64-msvc.node')
99
- )
226
+ }
227
+ } else if (process.arch === 'arm64') {
228
+ if (isMusl()) {
100
229
  try {
101
- if (localFileExisted) {
102
- nativeBinding = require('./cli.win32-arm64-msvc.node')
103
- } else {
104
- nativeBinding = require('@tauri-apps/cli-win32-arm64-msvc')
105
- }
230
+ return require('./cli.linux-arm64-musl.node')
106
231
  } catch (e) {
107
- loadError = e
232
+ loadErrors.push(e)
233
+ }
234
+ try {
235
+ return require('@tauri-apps/cli-linux-arm64-musl')
236
+ } catch (e) {
237
+ loadErrors.push(e)
108
238
  }
109
- break
110
- default:
111
- throw new Error(`Unsupported architecture on Windows: ${arch}`)
112
- }
113
- break
114
- case 'darwin':
115
- localFileExisted = existsSync(join(__dirname, 'cli.darwin-universal.node'))
116
- try {
117
- if (localFileExisted) {
118
- nativeBinding = require('./cli.darwin-universal.node')
119
239
  } else {
120
- nativeBinding = require('@tauri-apps/cli-darwin-universal')
240
+ try {
241
+ return require('./cli.linux-arm64-gnu.node')
242
+ } catch (e) {
243
+ loadErrors.push(e)
244
+ }
245
+ try {
246
+ return require('@tauri-apps/cli-linux-arm64-gnu')
247
+ } catch (e) {
248
+ loadErrors.push(e)
249
+ }
121
250
  }
122
- break
123
- } catch {}
124
- switch (arch) {
125
- case 'x64':
126
- localFileExisted = existsSync(join(__dirname, 'cli.darwin-x64.node'))
251
+ } else if (process.arch === 'arm') {
252
+ if (isMusl()) {
127
253
  try {
128
- if (localFileExisted) {
129
- nativeBinding = require('./cli.darwin-x64.node')
130
- } else {
131
- nativeBinding = require('@tauri-apps/cli-darwin-x64')
132
- }
254
+ return require('./cli.linux-arm-musleabihf.node')
133
255
  } catch (e) {
134
- loadError = e
256
+ loadErrors.push(e)
135
257
  }
136
- break
137
- case 'arm64':
138
- localFileExisted = existsSync(
139
- join(__dirname, 'cli.darwin-arm64.node')
140
- )
141
258
  try {
142
- if (localFileExisted) {
143
- nativeBinding = require('./cli.darwin-arm64.node')
144
- } else {
145
- nativeBinding = require('@tauri-apps/cli-darwin-arm64')
146
- }
259
+ return require('@tauri-apps/cli-linux-arm-musleabihf')
147
260
  } catch (e) {
148
- loadError = e
261
+ loadErrors.push(e)
149
262
  }
150
- break
151
- default:
152
- throw new Error(`Unsupported architecture on macOS: ${arch}`)
153
- }
154
- break
155
- case 'freebsd':
156
- if (arch !== 'x64') {
157
- throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
158
- }
159
- localFileExisted = existsSync(join(__dirname, 'cli.freebsd-x64.node'))
160
- try {
161
- if (localFileExisted) {
162
- nativeBinding = require('./cli.freebsd-x64.node')
163
263
  } else {
164
- nativeBinding = require('@tauri-apps/cli-freebsd-x64')
165
- }
166
- } catch (e) {
167
- loadError = e
168
- }
169
- break
170
- case 'linux':
171
- switch (arch) {
172
- case 'x64':
173
- if (isMusl()) {
174
- localFileExisted = existsSync(
175
- join(__dirname, 'cli.linux-x64-musl.node')
176
- )
177
- try {
178
- if (localFileExisted) {
179
- nativeBinding = require('./cli.linux-x64-musl.node')
180
- } else {
181
- nativeBinding = require('@tauri-apps/cli-linux-x64-musl')
182
- }
183
- } catch (e) {
184
- loadError = e
185
- }
186
- } else {
187
- localFileExisted = existsSync(
188
- join(__dirname, 'cli.linux-x64-gnu.node')
189
- )
190
- try {
191
- if (localFileExisted) {
192
- nativeBinding = require('./cli.linux-x64-gnu.node')
193
- } else {
194
- nativeBinding = require('@tauri-apps/cli-linux-x64-gnu')
195
- }
196
- } catch (e) {
197
- loadError = e
198
- }
264
+ try {
265
+ return require('./cli.linux-arm-gnueabihf.node')
266
+ } catch (e) {
267
+ loadErrors.push(e)
199
268
  }
200
- break
201
- case 'arm64':
202
- if (isMusl()) {
203
- localFileExisted = existsSync(
204
- join(__dirname, 'cli.linux-arm64-musl.node')
205
- )
206
- try {
207
- if (localFileExisted) {
208
- nativeBinding = require('./cli.linux-arm64-musl.node')
209
- } else {
210
- nativeBinding = require('@tauri-apps/cli-linux-arm64-musl')
211
- }
212
- } catch (e) {
213
- loadError = e
214
- }
215
- } else {
216
- localFileExisted = existsSync(
217
- join(__dirname, 'cli.linux-arm64-gnu.node')
218
- )
219
- try {
220
- if (localFileExisted) {
221
- nativeBinding = require('./cli.linux-arm64-gnu.node')
222
- } else {
223
- nativeBinding = require('@tauri-apps/cli-linux-arm64-gnu')
224
- }
225
- } catch (e) {
226
- loadError = e
227
- }
269
+ try {
270
+ return require('@tauri-apps/cli-linux-arm-gnueabihf')
271
+ } catch (e) {
272
+ loadErrors.push(e)
228
273
  }
229
- break
230
- case 'arm':
231
- if (isMusl()) {
232
- localFileExisted = existsSync(
233
- join(__dirname, 'cli.linux-arm-musleabihf.node')
234
- )
235
- try {
236
- if (localFileExisted) {
237
- nativeBinding = require('./cli.linux-arm-musleabihf.node')
238
- } else {
239
- nativeBinding = require('@tauri-apps/cli-linux-arm-musleabihf')
240
- }
241
- } catch (e) {
242
- loadError = e
243
- }
244
- } else {
245
- localFileExisted = existsSync(
246
- join(__dirname, 'cli.linux-arm-gnueabihf.node')
247
- )
248
- try {
249
- if (localFileExisted) {
250
- nativeBinding = require('./cli.linux-arm-gnueabihf.node')
251
- } else {
252
- nativeBinding = require('@tauri-apps/cli-linux-arm-gnueabihf')
253
- }
254
- } catch (e) {
255
- loadError = e
256
- }
274
+ }
275
+ } else if (process.arch === 'riscv64') {
276
+ if (isMusl()) {
277
+ try {
278
+ return require('./cli.linux-riscv64-musl.node')
279
+ } catch (e) {
280
+ loadErrors.push(e)
257
281
  }
258
- break
259
- case 'riscv64':
260
- if (isMusl()) {
261
- localFileExisted = existsSync(
262
- join(__dirname, 'cli.linux-riscv64-musl.node')
263
- )
264
- try {
265
- if (localFileExisted) {
266
- nativeBinding = require('./cli.linux-riscv64-musl.node')
267
- } else {
268
- nativeBinding = require('@tauri-apps/cli-linux-riscv64-musl')
269
- }
270
- } catch (e) {
271
- loadError = e
272
- }
273
- } else {
274
- localFileExisted = existsSync(
275
- join(__dirname, 'cli.linux-riscv64-gnu.node')
276
- )
277
- try {
278
- if (localFileExisted) {
279
- nativeBinding = require('./cli.linux-riscv64-gnu.node')
280
- } else {
281
- nativeBinding = require('@tauri-apps/cli-linux-riscv64-gnu')
282
- }
283
- } catch (e) {
284
- loadError = e
285
- }
282
+ try {
283
+ return require('@tauri-apps/cli-linux-riscv64-musl')
284
+ } catch (e) {
285
+ loadErrors.push(e)
286
286
  }
287
- break
288
- case 's390x':
289
- localFileExisted = existsSync(
290
- join(__dirname, 'cli.linux-s390x-gnu.node')
291
- )
287
+ } else {
292
288
  try {
293
- if (localFileExisted) {
294
- nativeBinding = require('./cli.linux-s390x-gnu.node')
295
- } else {
296
- nativeBinding = require('@tauri-apps/cli-linux-s390x-gnu')
297
- }
289
+ return require('./cli.linux-riscv64-gnu.node')
298
290
  } catch (e) {
299
- loadError = e
291
+ loadErrors.push(e)
300
292
  }
301
- break
302
- default:
303
- throw new Error(`Unsupported architecture on Linux: ${arch}`)
293
+ try {
294
+ return require('@tauri-apps/cli-linux-riscv64-gnu')
295
+ } catch (e) {
296
+ loadErrors.push(e)
297
+ }
298
+ }
299
+ } else if (process.arch === 'ppc64') {
300
+ try {
301
+ return require('./cli.linux-ppc64-gnu.node')
302
+ } catch (e) {
303
+ loadErrors.push(e)
304
+ }
305
+ try {
306
+ return require('@tauri-apps/cli-linux-ppc64-gnu')
307
+ } catch (e) {
308
+ loadErrors.push(e)
309
+ }
310
+ } else if (process.arch === 's390x') {
311
+ try {
312
+ return require('./cli.linux-s390x-gnu.node')
313
+ } catch (e) {
314
+ loadErrors.push(e)
315
+ }
316
+ try {
317
+ return require('@tauri-apps/cli-linux-s390x-gnu')
318
+ } catch (e) {
319
+ loadErrors.push(e)
320
+ }
321
+ } else {
322
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
323
+ }
324
+ } else if (process.platform === 'openharmony') {
325
+ if (process.arch === 'arm64') {
326
+ try {
327
+ return require('./cli.linux-arm64-ohos.node')
328
+ } catch (e) {
329
+ loadErrors.push(e)
330
+ }
331
+ try {
332
+ return require('@tauri-apps/cli-linux-arm64-ohos')
333
+ } catch (e) {
334
+ loadErrors.push(e)
335
+ }
336
+ } else if (process.arch === 'x64') {
337
+ try {
338
+ return require('./cli.linux-x64-ohos.node')
339
+ } catch (e) {
340
+ loadErrors.push(e)
341
+ }
342
+ try {
343
+ return require('@tauri-apps/cli-linux-x64-ohos')
344
+ } catch (e) {
345
+ loadErrors.push(e)
346
+ }
347
+ } else if (process.arch === 'arm') {
348
+ try {
349
+ return require('./cli.linux-arm-ohos.node')
350
+ } catch (e) {
351
+ loadErrors.push(e)
352
+ }
353
+ try {
354
+ return require('@tauri-apps/cli-linux-arm-ohos')
355
+ } catch (e) {
356
+ loadErrors.push(e)
357
+ }
358
+ } else {
359
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
304
360
  }
305
- break
306
- default:
307
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
361
+ } else {
362
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
363
+ }
364
+ }
365
+
366
+ nativeBinding = requireNative()
367
+
368
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
369
+ try {
370
+ nativeBinding = require('./cli.wasi.cjs')
371
+ } catch (err) {
372
+ if (process.env.NAPI_RS_FORCE_WASI) {
373
+ loadErrors.push(err)
374
+ }
375
+ }
376
+ if (!nativeBinding) {
377
+ try {
378
+ nativeBinding = require('@tauri-apps/cli-wasm32-wasi')
379
+ } catch (err) {
380
+ if (process.env.NAPI_RS_FORCE_WASI) {
381
+ loadErrors.push(err)
382
+ }
383
+ }
384
+ }
308
385
  }
309
386
 
310
387
  if (!nativeBinding) {
311
- if (loadError) {
312
- throw loadError
388
+ if (loadErrors.length > 0) {
389
+ throw new Error(
390
+ `Cannot find native binding. ` +
391
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
392
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
393
+ { cause: loadErrors }
394
+ )
313
395
  }
314
396
  throw new Error(`Failed to load native binding`)
315
397
  }
316
398
 
317
- const { run, logError } = nativeBinding
318
-
319
- module.exports.run = run
320
- module.exports.logError = logError
399
+ module.exports = nativeBinding
400
+ module.exports.logError = nativeBinding.logError
401
+ module.exports.run = nativeBinding.run
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/cli",
3
- "version": "2.6.2",
3
+ "version": "2.7.0",
4
4
  "description": "Command line interface for building Tauri apps",
5
5
  "funding": {
6
6
  "type": "opencollective",
@@ -24,22 +24,23 @@
24
24
  "main": "main.js",
25
25
  "types": "main.d.ts",
26
26
  "napi": {
27
- "name": "cli",
28
- "triples": {
29
- "additional": [
30
- "aarch64-apple-darwin",
31
- "aarch64-unknown-linux-gnu",
32
- "aarch64-unknown-linux-musl",
33
- "armv7-unknown-linux-gnueabihf",
34
- "x86_64-unknown-linux-musl",
35
- "riscv64gc-unknown-linux-gnu",
36
- "i686-pc-windows-msvc",
37
- "aarch64-pc-windows-msvc"
38
- ]
39
- }
27
+ "binaryName": "cli",
28
+ "targets": [
29
+ "x86_64-unknown-linux-gnu",
30
+ "x86_64-pc-windows-msvc",
31
+ "x86_64-apple-darwin",
32
+ "aarch64-apple-darwin",
33
+ "aarch64-unknown-linux-gnu",
34
+ "aarch64-unknown-linux-musl",
35
+ "armv7-unknown-linux-gnueabihf",
36
+ "x86_64-unknown-linux-musl",
37
+ "riscv64gc-unknown-linux-gnu",
38
+ "i686-pc-windows-msvc",
39
+ "aarch64-pc-windows-msvc"
40
+ ]
40
41
  },
41
42
  "devDependencies": {
42
- "@napi-rs/cli": "2.18.4",
43
+ "@napi-rs/cli": "^3.0.0",
43
44
  "@types/node": "^22.15.32",
44
45
  "cross-env": "7.0.3",
45
46
  "vitest": "^3.2.4"
@@ -63,16 +64,16 @@
63
64
  "tauri": "node ./tauri.js"
64
65
  },
65
66
  "optionalDependencies": {
66
- "@tauri-apps/cli-win32-x64-msvc": "2.6.2",
67
- "@tauri-apps/cli-darwin-x64": "2.6.2",
68
- "@tauri-apps/cli-linux-x64-gnu": "2.6.2",
69
- "@tauri-apps/cli-darwin-arm64": "2.6.2",
70
- "@tauri-apps/cli-linux-arm64-gnu": "2.6.2",
71
- "@tauri-apps/cli-linux-arm64-musl": "2.6.2",
72
- "@tauri-apps/cli-linux-arm-gnueabihf": "2.6.2",
73
- "@tauri-apps/cli-linux-x64-musl": "2.6.2",
74
- "@tauri-apps/cli-linux-riscv64-gnu": "2.6.2",
75
- "@tauri-apps/cli-win32-ia32-msvc": "2.6.2",
76
- "@tauri-apps/cli-win32-arm64-msvc": "2.6.2"
67
+ "@tauri-apps/cli-linux-x64-gnu": "2.7.0",
68
+ "@tauri-apps/cli-win32-x64-msvc": "2.7.0",
69
+ "@tauri-apps/cli-darwin-x64": "2.7.0",
70
+ "@tauri-apps/cli-darwin-arm64": "2.7.0",
71
+ "@tauri-apps/cli-linux-arm64-gnu": "2.7.0",
72
+ "@tauri-apps/cli-linux-arm64-musl": "2.7.0",
73
+ "@tauri-apps/cli-linux-arm-gnueabihf": "2.7.0",
74
+ "@tauri-apps/cli-linux-x64-musl": "2.7.0",
75
+ "@tauri-apps/cli-linux-riscv64-gnu": "2.7.0",
76
+ "@tauri-apps/cli-win32-ia32-msvc": "2.7.0",
77
+ "@tauri-apps/cli-win32-arm64-msvc": "2.7.0"
77
78
  }
78
79
  }
package/Cargo.toml DELETED
@@ -1,22 +0,0 @@
1
- [package]
2
- edition = "2021"
3
- name = "tauri-cli-node"
4
- version = "0.0.0"
5
-
6
- [lib]
7
- crate-type = ["cdylib"]
8
-
9
- [dependencies]
10
- # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
11
- napi = { version = "2.16", default-features = false, features = ["napi4"] }
12
- napi-derive = "2.16"
13
- tauri-cli = { path = "../../crates/tauri-cli", default-features = false }
14
- log = "0.4.21"
15
-
16
- [build-dependencies]
17
- napi-build = "2.1"
18
-
19
- [features]
20
- default = ["tauri-cli/default"]
21
- native-tls = ["tauri-cli/native-tls"]
22
- native-tls-vendored = ["tauri-cli/native-tls-vendored"]
@@ -1,6 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <body>
4
- <div></div>
5
- </body>
6
- </html>
@@ -1,5 +0,0 @@
1
- {
2
- "scripts": {
3
- "build": ""
4
- }
5
- }
@@ -1,89 +0,0 @@
1
- // Copyright 2019-2024 Tauri Programme within The Commons Conservancy
2
- // SPDX-License-Identifier: Apache-2.0
3
- // SPDX-License-Identifier: MIT
4
-
5
- import { resolve } from 'node:path'
6
- import { spawnSync } from 'node:child_process'
7
- import {
8
- existsSync,
9
- readFileSync,
10
- writeFileSync,
11
- rmSync,
12
- renameSync
13
- } from 'node:fs'
14
- import { beforeAll, describe, it } from 'vitest'
15
-
16
- // Build CLI before tests, for local usage only.
17
- // CI builds the CLI on different platforms and architectures
18
- if (!process.env.CI) {
19
- beforeAll(() => {
20
- const cliDir = resolve(__dirname, '..')
21
- exec('pnpm', ['build:debug'], { cwd: cliDir })
22
- })
23
- }
24
-
25
- describe('[CLI] @tauri-apps/cli template', () => {
26
- it('init a project and builds it', { timeout: 15 * 60 * 1000 }, async () => {
27
- const cwd = process.cwd()
28
- const fixturePath = resolve(__dirname, './fixtures/empty')
29
- const tauriFixturePath = resolve(fixturePath, 'src-tauri')
30
- const outPath = resolve(tauriFixturePath, 'target')
31
- const cacheOutPath = resolve(fixturePath, 'target')
32
-
33
- process.chdir(fixturePath)
34
-
35
- const outExists = existsSync(outPath)
36
- if (outExists) {
37
- if (existsSync(cacheOutPath)) {
38
- rmSync(cacheOutPath, { recursive: true, force: true })
39
- }
40
- renameSync(outPath, cacheOutPath)
41
- }
42
-
43
- const cli = await import('../main.js')
44
-
45
- await cli.run([
46
- 'init',
47
- '-vvv',
48
- '--directory',
49
- process.cwd(),
50
- '--force',
51
- '--tauri-path',
52
- resolve(__dirname, '../../..'),
53
- '--before-build-command',
54
- '',
55
- '--before-dev-command',
56
- '',
57
- '--ci'
58
- ])
59
-
60
- if (outExists) {
61
- renameSync(cacheOutPath, outPath)
62
- }
63
-
64
- process.chdir(tauriFixturePath)
65
-
66
- const manifestPath = resolve(tauriFixturePath, 'Cargo.toml')
67
- const manifestFile = readFileSync(manifestPath).toString()
68
- writeFileSync(manifestPath, `workspace = { }\n${manifestFile}`)
69
-
70
- const configPath = resolve(tauriFixturePath, 'tauri.conf.json')
71
- const config = readFileSync(configPath).toString()
72
- writeFileSync(configPath, config.replace('com.tauri.dev', 'com.tauri.test'))
73
-
74
- await cli.run(['build', '-vvv'])
75
- process.chdir(cwd)
76
- })
77
- })
78
-
79
- function exec(
80
- bin: string,
81
- args?: string[],
82
- opts?: {
83
- cwd?: string
84
- }
85
- ) {
86
- process.platform === 'win32'
87
- ? spawnSync('cmd', ['/c', bin, ...(args ?? [])], { cwd: opts?.cwd })
88
- : spawnSync(bin, args, { cwd: opts?.cwd })
89
- }
package/build.rs DELETED
@@ -1,7 +0,0 @@
1
- // Copyright 2019-2024 Tauri Programme within The Commons Conservancy
2
- // SPDX-License-Identifier: Apache-2.0
3
- // SPDX-License-Identifier: MIT
4
-
5
- fn main() {
6
- ::napi_build::setup();
7
- }
package/src/lib.rs DELETED
@@ -1,50 +0,0 @@
1
- // Copyright 2019-2024 Tauri Programme within The Commons Conservancy
2
- // SPDX-License-Identifier: Apache-2.0
3
- // SPDX-License-Identifier: MIT
4
-
5
- #![cfg(any(target_os = "macos", target_os = "linux", windows))]
6
-
7
- use napi::{
8
- threadsafe_function::{ErrorStrategy, ThreadsafeFunction, ThreadsafeFunctionCallMode},
9
- Error, JsFunction, Result, Status,
10
- };
11
-
12
- #[napi_derive::napi]
13
- pub fn run(args: Vec<String>, bin_name: Option<String>, callback: JsFunction) -> Result<()> {
14
- let function: ThreadsafeFunction<bool, ErrorStrategy::CalleeHandled> = callback
15
- .create_threadsafe_function(0, |ctx| ctx.env.get_boolean(ctx.value).map(|v| vec![v]))?;
16
-
17
- // we need to run in a separate thread so Node.js consumers
18
- // can do work while `tauri dev` is running.
19
- std::thread::spawn(move || {
20
- let res = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
21
- tauri_cli::try_run(args, bin_name).inspect_err(|e| eprintln!("{e:#}"))
22
- })) {
23
- Ok(t) => t,
24
- Err(_) => {
25
- return function.call(
26
- Err(Error::new(
27
- Status::GenericFailure,
28
- "Tauri CLI unexpected panic",
29
- )),
30
- ThreadsafeFunctionCallMode::Blocking,
31
- );
32
- }
33
- };
34
-
35
- match res {
36
- Ok(_) => function.call(Ok(true), ThreadsafeFunctionCallMode::Blocking),
37
- Err(e) => function.call(
38
- Err(Error::new(Status::GenericFailure, format!("{e:#}"))),
39
- ThreadsafeFunctionCallMode::Blocking,
40
- ),
41
- }
42
- });
43
-
44
- Ok(())
45
- }
46
-
47
- #[napi_derive::napi]
48
- pub fn log_error(error: String) {
49
- log::error!("{}", error);
50
- }