electron-cli 0.3.0-alpha.5 → 0.3.0-alpha.7
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/Cargo.lock +82 -1
- package/Cargo.toml +2 -1
- package/README.md +21 -3
- package/package.json +1 -1
- package/src/commands/init.rs +30 -0
- package/src/commands/package.rs +944 -25
package/Cargo.lock
CHANGED
|
@@ -64,6 +64,12 @@ version = "1.0.102"
|
|
|
64
64
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
65
65
|
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
|
|
66
66
|
|
|
67
|
+
[[package]]
|
|
68
|
+
name = "base64"
|
|
69
|
+
version = "0.22.1"
|
|
70
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
71
|
+
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
|
72
|
+
|
|
67
73
|
[[package]]
|
|
68
74
|
name = "camino"
|
|
69
75
|
version = "1.2.2"
|
|
@@ -134,13 +140,23 @@ dependencies = [
|
|
|
134
140
|
"cfg-if",
|
|
135
141
|
]
|
|
136
142
|
|
|
143
|
+
[[package]]
|
|
144
|
+
name = "deranged"
|
|
145
|
+
version = "0.5.8"
|
|
146
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
147
|
+
checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
|
|
148
|
+
dependencies = [
|
|
149
|
+
"powerfmt",
|
|
150
|
+
]
|
|
151
|
+
|
|
137
152
|
[[package]]
|
|
138
153
|
name = "electron-cli"
|
|
139
|
-
version = "0.3.0-alpha.
|
|
154
|
+
version = "0.3.0-alpha.7"
|
|
140
155
|
dependencies = [
|
|
141
156
|
"anyhow",
|
|
142
157
|
"camino",
|
|
143
158
|
"clap",
|
|
159
|
+
"plist",
|
|
144
160
|
"serde",
|
|
145
161
|
"serde_json",
|
|
146
162
|
"zip",
|
|
@@ -212,12 +228,37 @@ dependencies = [
|
|
|
212
228
|
"simd-adler32",
|
|
213
229
|
]
|
|
214
230
|
|
|
231
|
+
[[package]]
|
|
232
|
+
name = "num-conv"
|
|
233
|
+
version = "0.2.2"
|
|
234
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
235
|
+
checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
|
|
236
|
+
|
|
215
237
|
[[package]]
|
|
216
238
|
name = "once_cell_polyfill"
|
|
217
239
|
version = "1.70.2"
|
|
218
240
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
219
241
|
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
|
220
242
|
|
|
243
|
+
[[package]]
|
|
244
|
+
name = "plist"
|
|
245
|
+
version = "1.9.0"
|
|
246
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
247
|
+
checksum = "092791278e026273c1b65bbdcfbba3a300f2994c896bd01ab01da613c29c46f1"
|
|
248
|
+
dependencies = [
|
|
249
|
+
"base64",
|
|
250
|
+
"indexmap",
|
|
251
|
+
"quick-xml",
|
|
252
|
+
"serde",
|
|
253
|
+
"time",
|
|
254
|
+
]
|
|
255
|
+
|
|
256
|
+
[[package]]
|
|
257
|
+
name = "powerfmt"
|
|
258
|
+
version = "0.2.0"
|
|
259
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
260
|
+
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
|
261
|
+
|
|
221
262
|
[[package]]
|
|
222
263
|
name = "proc-macro2"
|
|
223
264
|
version = "1.0.106"
|
|
@@ -227,6 +268,15 @@ dependencies = [
|
|
|
227
268
|
"unicode-ident",
|
|
228
269
|
]
|
|
229
270
|
|
|
271
|
+
[[package]]
|
|
272
|
+
name = "quick-xml"
|
|
273
|
+
version = "0.39.4"
|
|
274
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
275
|
+
checksum = "cdcc8dd4e2f670d309a5f0e83fe36dfdc05af317008fea29144da1a2ac858e5e"
|
|
276
|
+
dependencies = [
|
|
277
|
+
"memchr",
|
|
278
|
+
]
|
|
279
|
+
|
|
230
280
|
[[package]]
|
|
231
281
|
name = "quote"
|
|
232
282
|
version = "1.0.45"
|
|
@@ -302,6 +352,37 @@ dependencies = [
|
|
|
302
352
|
"unicode-ident",
|
|
303
353
|
]
|
|
304
354
|
|
|
355
|
+
[[package]]
|
|
356
|
+
name = "time"
|
|
357
|
+
version = "0.3.47"
|
|
358
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
359
|
+
checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c"
|
|
360
|
+
dependencies = [
|
|
361
|
+
"deranged",
|
|
362
|
+
"itoa",
|
|
363
|
+
"num-conv",
|
|
364
|
+
"powerfmt",
|
|
365
|
+
"serde_core",
|
|
366
|
+
"time-core",
|
|
367
|
+
"time-macros",
|
|
368
|
+
]
|
|
369
|
+
|
|
370
|
+
[[package]]
|
|
371
|
+
name = "time-core"
|
|
372
|
+
version = "0.1.8"
|
|
373
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
374
|
+
checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca"
|
|
375
|
+
|
|
376
|
+
[[package]]
|
|
377
|
+
name = "time-macros"
|
|
378
|
+
version = "0.2.27"
|
|
379
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
380
|
+
checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215"
|
|
381
|
+
dependencies = [
|
|
382
|
+
"num-conv",
|
|
383
|
+
"time-core",
|
|
384
|
+
]
|
|
385
|
+
|
|
305
386
|
[[package]]
|
|
306
387
|
name = "typed-path"
|
|
307
388
|
version = "0.12.3"
|
package/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "electron-cli"
|
|
3
|
-
version = "0.3.0-alpha.
|
|
3
|
+
version = "0.3.0-alpha.7"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
description = "Experimental Rust CLI for Electron project diagnostics and workflow automation"
|
|
6
6
|
license = "MIT"
|
|
@@ -12,4 +12,5 @@ camino = { version = "1.1", features = ["serde1"] }
|
|
|
12
12
|
clap = { version = "4.6", features = ["derive"] }
|
|
13
13
|
serde = { version = "1.0", features = ["derive"] }
|
|
14
14
|
serde_json = "1.0"
|
|
15
|
+
plist = "1"
|
|
15
16
|
zip = { version = "8.6.0", default-features = false, features = ["deflate-flate2-zlib-rs"] }
|
package/README.md
CHANGED
|
@@ -41,11 +41,29 @@ The Rust-native flow currently owns:
|
|
|
41
41
|
|
|
42
42
|
- `init --template minimal`: writes a local Electron starter without Electron Forge.
|
|
43
43
|
- `start`: launches the installed Electron runtime directly.
|
|
44
|
-
- `package`: copies the installed Electron runtime
|
|
44
|
+
- `package`: copies the installed Electron runtime, app files, installed production dependency closure, app metadata, macOS icon, and extra resources into a local app bundle for the current platform and architecture.
|
|
45
45
|
- `make`: runs `package` and writes a ZIP distributable under `out/make/zip/<platform>/<arch>/`.
|
|
46
46
|
- `publish`: runs `make` and publishes the distributable to a local directory with a manifest.
|
|
47
47
|
|
|
48
|
-
Remote publishers such as GitHub Releases are not implemented yet.
|
|
48
|
+
Remote publishers such as GitHub Releases are not implemented yet. Platform-specific makers, Windows/Linux icon embedding, signing, and notarization are also still TODO.
|
|
49
|
+
|
|
50
|
+
Package metadata can be configured in `package.json`:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"productName": "My App",
|
|
55
|
+
"electronCli": {
|
|
56
|
+
"packagerConfig": {
|
|
57
|
+
"appBundleId": "com.example.my-app",
|
|
58
|
+
"appCategoryType": "public.app-category.developer-tools",
|
|
59
|
+
"icon": "assets/icon",
|
|
60
|
+
"extraResource": "assets/config.json"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The package command also reads JSON-shaped `config.forge.packagerConfig` and `electronPackagerConfig` entries for the same fields. JavaScript Forge config files are not evaluated.
|
|
49
67
|
|
|
50
68
|
## Install
|
|
51
69
|
|
|
@@ -103,7 +121,7 @@ The inspection and planning commands support `--json` so agents and scripts can
|
|
|
103
121
|
`plan` is designed around that workflow: it recommends stable commands and reports missing project conventions as structured data.
|
|
104
122
|
`init --dry-run --json` shows whether the CLI will write native template files or delegate to `create-electron-app`.
|
|
105
123
|
`start --dry-run --json` shows the Electron executable that will be launched.
|
|
106
|
-
`package --dry-run --json` shows the runtime
|
|
124
|
+
`package --dry-run --json` shows the runtime, app file, metadata, icon, and extra-resource copy plan.
|
|
107
125
|
`make --dry-run --json` shows the package prerequisite and ZIP artifact path.
|
|
108
126
|
`publish --dry-run --json` shows the make prerequisite, destination artifact, and manifest path.
|
|
109
127
|
|
package/package.json
CHANGED
package/src/commands/init.rs
CHANGED
|
@@ -447,8 +447,11 @@ fn write_template_file(target: &Path, relative_path: &str, contents: &str) -> Re
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
fn package_json(package_name: &str, electron_version: &str) -> Result<String> {
|
|
450
|
+
let product_name = product_name(package_name);
|
|
451
|
+
let app_bundle_id = format!("com.electron.{package_name}");
|
|
450
452
|
let package = serde_json::json!({
|
|
451
453
|
"name": package_name,
|
|
454
|
+
"productName": product_name,
|
|
452
455
|
"version": "0.1.0",
|
|
453
456
|
"private": true,
|
|
454
457
|
"description": "Minimal Electron app generated by electron-cli",
|
|
@@ -459,6 +462,11 @@ fn package_json(package_name: &str, electron_version: &str) -> Result<String> {
|
|
|
459
462
|
},
|
|
460
463
|
"devDependencies": {
|
|
461
464
|
"electron": electron_version
|
|
465
|
+
},
|
|
466
|
+
"electronCli": {
|
|
467
|
+
"packagerConfig": {
|
|
468
|
+
"appBundleId": app_bundle_id
|
|
469
|
+
}
|
|
462
470
|
}
|
|
463
471
|
});
|
|
464
472
|
|
|
@@ -639,6 +647,25 @@ fn sanitize_package_name(raw_name: &str) -> String {
|
|
|
639
647
|
}
|
|
640
648
|
}
|
|
641
649
|
|
|
650
|
+
fn product_name(package_name: &str) -> String {
|
|
651
|
+
package_name
|
|
652
|
+
.split(['-', '_', '.'])
|
|
653
|
+
.filter(|part| !part.is_empty())
|
|
654
|
+
.map(|part| {
|
|
655
|
+
let mut chars = part.chars();
|
|
656
|
+
match chars.next() {
|
|
657
|
+
Some(first) => {
|
|
658
|
+
let mut word = first.to_uppercase().collect::<String>();
|
|
659
|
+
word.push_str(chars.as_str());
|
|
660
|
+
word
|
|
661
|
+
}
|
|
662
|
+
None => String::new(),
|
|
663
|
+
}
|
|
664
|
+
})
|
|
665
|
+
.collect::<Vec<_>>()
|
|
666
|
+
.join(" ")
|
|
667
|
+
}
|
|
668
|
+
|
|
642
669
|
fn utf8_path(path: PathBuf) -> Result<Utf8PathBuf> {
|
|
643
670
|
Utf8PathBuf::from_path_buf(path).map_err(|path| {
|
|
644
671
|
anyhow::anyhow!(
|
|
@@ -756,7 +783,9 @@ mod tests {
|
|
|
756
783
|
assert!(target.join("src/renderer.js").exists());
|
|
757
784
|
assert!(target.join(".github/workflows/ci.yml").exists());
|
|
758
785
|
assert!(package_json.contains("\"name\": \"native-app\""));
|
|
786
|
+
assert!(package_json.contains("\"productName\": \"Native App\""));
|
|
759
787
|
assert!(package_json.contains("\"electron\": \"30.0.0\""));
|
|
788
|
+
assert!(package_json.contains("\"appBundleId\": \"com.electron.native-app\""));
|
|
760
789
|
assert!(config.contains("\"generator\": \"electron-cli\""));
|
|
761
790
|
|
|
762
791
|
let _ = fs::remove_dir_all(cwd);
|
|
@@ -767,6 +796,7 @@ mod tests {
|
|
|
767
796
|
assert_eq!(sanitize_package_name("Native App"), "native-app");
|
|
768
797
|
assert_eq!(sanitize_package_name("..."), "electron-app");
|
|
769
798
|
assert_eq!(sanitize_package_name("@Scope/App"), "scope-app");
|
|
799
|
+
assert_eq!(product_name("native-app"), "Native App");
|
|
770
800
|
}
|
|
771
801
|
|
|
772
802
|
fn unique_temp_dir() -> PathBuf {
|