electron-cli 0.3.0-alpha.1 → 0.3.0-alpha.11

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.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "electron-cli"
3
- version = "0.3.0-alpha.1"
3
+ version = "0.3.0-alpha.11"
4
4
  edition = "2021"
5
5
  description = "Experimental Rust CLI for Electron project diagnostics and workflow automation"
6
6
  license = "MIT"
@@ -8,7 +8,17 @@ repository = "https://github.com/Ikana/electron-cli"
8
8
 
9
9
  [dependencies]
10
10
  anyhow = "1.0"
11
+ apple-dmg = "0.5"
11
12
  camino = { version = "1.1", features = ["serde1"] }
12
13
  clap = { version = "4.6", features = ["derive"] }
14
+ fatfs = "0.3"
15
+ flate2 = { version = "1.1", default-features = false, features = ["rust_backend"] }
16
+ fscommon = "0.1"
17
+ md5 = "0.7"
18
+ plist = "1"
19
+ rpm = { version = "0.24", default-features = false, features = ["payload", "gzip-compression"] }
13
20
  serde = { version = "1.0", features = ["derive"] }
14
21
  serde_json = "1.0"
22
+ tar = "0.4"
23
+ ureq = { version = "3.3", features = ["json"] }
24
+ zip = { version = "8.6.0", default-features = false, features = ["deflate-flate2-zlib-rs"] }
package/README.md CHANGED
@@ -6,7 +6,7 @@ This is an independent learning project. It is not affiliated with Electron, Ele
6
6
 
7
7
  ## Status
8
8
 
9
- This repository is intentionally small and public-learning friendly. The first useful surface area is inspection and diagnostics, because those commands are valuable for humans and easy for agents to consume safely.
9
+ This repository is intentionally small and public-learning friendly. The first useful surface area is inspection and diagnostics, because those commands are valuable for humans and easy for agents to consume safely. The next surface area is a Rust-owned version of the main Electron Forge flow: initialize, start, package, make, and eventually publish.
10
10
 
11
11
  Current commands:
12
12
 
@@ -14,28 +14,59 @@ Current commands:
14
14
  electron-cli inspect
15
15
  electron-cli doctor
16
16
  electron-cli plan
17
+ electron-cli init my-app
18
+ electron-cli start
19
+ electron-cli package
20
+ electron-cli make
21
+ electron-cli publish
17
22
  electron-cli inspect --json
18
23
  electron-cli doctor --json
19
24
  electron-cli plan --json
25
+ electron-cli init my-app --dry-run --json
26
+ electron-cli start --dry-run --json
27
+ electron-cli package --dry-run --json
28
+ electron-cli make --dry-run --json
29
+ electron-cli publish --dry-run --json
20
30
  ```
21
31
 
22
- Planned commands:
32
+ The default `init` template is `minimal`, a built-in starter written by this project. Non-native template names are still passed to `create-electron-app` as an escape hatch while this project grows.
23
33
 
24
- ```sh
25
- electron-cli dev
26
- electron-cli init
27
- electron-cli package
28
- electron-cli make
34
+ The Rust-native flow currently owns:
35
+
36
+ - `init --template minimal`: writes a local Electron starter without Electron Forge.
37
+ - `start`: launches the installed Electron runtime directly.
38
+ - `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.
39
+ - `make`: runs `package` and writes a distributable under `out/make/<target>/<platform>/<arch>/`; ZIP works on all platforms, `--target dmg` writes a basic macOS disk image, and `--target deb` / `--target rpm` write Linux packages.
40
+ - `publish`: runs `make` and publishes the distributable to a local directory with a manifest or to GitHub Releases.
41
+
42
+ The GitHub publisher creates or reuses a release, uploads the selected make artifact, and can replace an existing asset with `--force`. It reads `GITHUB_TOKEN` or `GH_TOKEN` and can infer `OWNER/REPO` from `package.json` `repository`, or you can pass `--github-repo`.
43
+
44
+ The DMG maker is currently a pure-Rust FAT32 image with the app bundle and an Applications entry. HFS+/APFS layout customization, Windows installers, Windows/Linux icon embedding, signing, and notarization are still TODO.
45
+
46
+ Package metadata can be configured in `package.json`:
47
+
48
+ ```json
49
+ {
50
+ "productName": "My App",
51
+ "electronCli": {
52
+ "packagerConfig": {
53
+ "appBundleId": "com.example.my-app",
54
+ "appCategoryType": "public.app-category.developer-tools",
55
+ "icon": "assets/icon",
56
+ "extraResource": "assets/config.json"
57
+ }
58
+ }
59
+ }
29
60
  ```
30
61
 
31
- The planned workflow commands may start by wrapping Electron Forge or other established tools. Rust-native implementations can replace narrow pieces over time when there is a clear reason.
62
+ The package command also reads JSON-shaped `config.forge.packagerConfig` and `electronPackagerConfig` entries for the same fields. JavaScript Forge config files are not evaluated.
32
63
 
33
64
  ## Install
34
65
 
35
66
  During the experimental phase, the npm package downloads a prebuilt binary from GitHub Releases when one is available. If a prebuilt binary is not available for your platform, it falls back to running from Rust source.
36
67
 
37
68
  ```sh
38
- npm install -g electron-cli
69
+ npm install -g electron-cli@alpha
39
70
  electron-cli doctor
40
71
  ```
41
72
 
@@ -59,6 +90,16 @@ Or use Cargo directly:
59
90
  ```sh
60
91
  cargo run -- doctor
61
92
  cargo run -- inspect --json
93
+ cargo run -- init my-app
94
+ cargo run -- start --dry-run
95
+ cargo run -- package --dry-run
96
+ cargo run -- make --dry-run
97
+ cargo run -- make --target dmg --dry-run
98
+ cargo run -- make --target deb --dry-run
99
+ cargo run -- make --target rpm --dry-run
100
+ cargo run -- publish --dry-run
101
+ cargo run -- publish --publisher github --dry-run
102
+ cargo run -- publish --publisher github --github-repo OWNER/REPO --github-tag v0.1.0
62
103
  ```
63
104
 
64
105
  ## Design Goals
@@ -66,7 +107,7 @@ cargo run -- inspect --json
66
107
  - Learn Rust through a real developer tool.
67
108
  - Make Electron project state easy to inspect.
68
109
  - Prefer structured output for agentic workflows.
69
- - Wrap proven ecosystem tools before replacing them.
110
+ - Replace the main Forge-style app flow with narrow Rust-owned pieces.
70
111
  - Keep the project clearly independent and experimental.
71
112
 
72
113
  ## Non-Goals
@@ -77,8 +118,13 @@ cargo run -- inspect --json
77
118
 
78
119
  ## JSON Output
79
120
 
80
- Both initial commands support `--json` so agents and scripts can consume project state without scraping terminal output.
121
+ The inspection and planning commands support `--json` so agents and scripts can consume project state without scraping terminal output.
81
122
  `plan` is designed around that workflow: it recommends stable commands and reports missing project conventions as structured data.
123
+ `init --dry-run --json` shows whether the CLI will write native template files or delegate to `create-electron-app`.
124
+ `start --dry-run --json` shows the Electron executable that will be launched.
125
+ `package --dry-run --json` shows the runtime, app file, metadata, icon, and extra-resource copy plan.
126
+ `make --dry-run --json` shows the package prerequisite and selected maker artifact path.
127
+ `publish --dry-run --json` shows the make prerequisite plus either the local destination/manifest path or the GitHub release/upload plan.
82
128
 
83
129
  ```sh
84
130
  electron-cli plan --json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-cli",
3
- "version": "0.3.0-alpha.1",
3
+ "version": "0.3.0-alpha.11",
4
4
  "description": "Experimental Rust CLI for Electron project diagnostics and workflow automation",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,6 +18,7 @@
18
18
  "bin/electron-cli.js",
19
19
  "scripts",
20
20
  "src",
21
+ "templates",
21
22
  "tests",
22
23
  "Cargo.toml",
23
24
  "Cargo.lock",
package/src/cli.rs CHANGED
@@ -1,6 +1,6 @@
1
1
  use std::path::PathBuf;
2
2
 
3
- use clap::{Args, Parser, Subcommand};
3
+ use clap::{Args, Parser, Subcommand, ValueEnum};
4
4
 
5
5
  #[derive(Debug, Parser)]
6
6
  #[command(
@@ -18,10 +18,20 @@ pub struct Cli {
18
18
  pub enum Commands {
19
19
  /// Check whether the current project looks ready for Electron development.
20
20
  Doctor(CommandArgs),
21
+ /// Bootstrap a new Electron app.
22
+ Init(InitArgs),
21
23
  /// Print a structured snapshot of the current JavaScript/Electron project.
22
24
  Inspect(CommandArgs),
25
+ /// Create distributable artifacts from a packaged Electron app.
26
+ Make(MakeArgs),
27
+ /// Create a local Electron application bundle without Electron Forge.
28
+ Package(PackageArgs),
23
29
  /// Recommend next commands and risks from the project snapshot.
24
30
  Plan(CommandArgs),
31
+ /// Publish made artifacts to a distribution target.
32
+ Publish(PublishArgs),
33
+ /// Launch the current Electron app without Electron Forge.
34
+ Start(StartArgs),
25
35
  }
26
36
 
27
37
  #[derive(Debug, Clone, Args)]
@@ -34,3 +44,278 @@ pub struct CommandArgs {
34
44
  #[arg(long)]
35
45
  pub json: bool,
36
46
  }
47
+
48
+ #[derive(Debug, Clone, Args)]
49
+ pub struct InitArgs {
50
+ /// Directory to initialize. Defaults to the current directory.
51
+ #[arg(default_value = ".", value_name = "DIR")]
52
+ pub dir: PathBuf,
53
+
54
+ /// Directory to run the create command from.
55
+ #[arg(long, default_value = ".", value_name = "PATH")]
56
+ pub cwd: PathBuf,
57
+
58
+ /// Template to use. "minimal" is native; other names are passed to create-electron-app.
59
+ #[arg(long, short = 't', default_value = "minimal")]
60
+ pub template: String,
61
+
62
+ /// Package manager command strategy to use.
63
+ #[arg(long, value_enum)]
64
+ pub package_manager: Option<PackageManager>,
65
+
66
+ /// Set a specific Electron version, or use latest/beta/nightly.
67
+ #[arg(long, value_name = "VERSION")]
68
+ pub electron_version: Option<String>,
69
+
70
+ /// Copy template CI files when the Forge template supports them.
71
+ #[arg(long)]
72
+ pub copy_ci_files: bool,
73
+
74
+ /// Overwrite an existing target directory.
75
+ #[arg(long)]
76
+ pub force: bool,
77
+
78
+ /// Skip initializing a git repository in the created project.
79
+ #[arg(long)]
80
+ pub skip_git: bool,
81
+
82
+ /// Print the command and metadata without creating files.
83
+ #[arg(long)]
84
+ pub dry_run: bool,
85
+
86
+ /// Emit machine-readable JSON.
87
+ #[arg(long)]
88
+ pub json: bool,
89
+ }
90
+
91
+ #[derive(Debug, Clone, Args)]
92
+ pub struct StartArgs {
93
+ /// Project directory to launch.
94
+ #[arg(long, default_value = ".", value_name = "PATH")]
95
+ pub cwd: PathBuf,
96
+
97
+ /// Print the launch command without starting Electron.
98
+ #[arg(long)]
99
+ pub dry_run: bool,
100
+
101
+ /// Emit machine-readable JSON.
102
+ #[arg(long)]
103
+ pub json: bool,
104
+
105
+ /// Extra arguments passed to Electron after `--`.
106
+ #[arg(last = true, value_name = "ELECTRON_ARG")]
107
+ pub electron_args: Vec<String>,
108
+ }
109
+
110
+ #[derive(Debug, Clone, Args)]
111
+ pub struct PackageArgs {
112
+ /// Project directory to package.
113
+ #[arg(long, default_value = ".", value_name = "PATH")]
114
+ pub cwd: PathBuf,
115
+
116
+ /// Output directory for packaged app bundles.
117
+ #[arg(long, default_value = "out", value_name = "PATH")]
118
+ pub out_dir: PathBuf,
119
+
120
+ /// Override the packaged application name.
121
+ #[arg(long)]
122
+ pub name: Option<String>,
123
+
124
+ /// Target platform label. Defaults to the current platform.
125
+ #[arg(long)]
126
+ pub platform: Option<String>,
127
+
128
+ /// Target architecture label. Defaults to the current architecture.
129
+ #[arg(long)]
130
+ pub arch: Option<String>,
131
+
132
+ /// Overwrite an existing package output directory.
133
+ #[arg(long)]
134
+ pub force: bool,
135
+
136
+ /// Print the package plan without creating files.
137
+ #[arg(long)]
138
+ pub dry_run: bool,
139
+
140
+ /// Emit machine-readable JSON.
141
+ #[arg(long)]
142
+ pub json: bool,
143
+ }
144
+
145
+ #[derive(Debug, Clone, Args)]
146
+ pub struct MakeArgs {
147
+ /// Project directory to make distributables for.
148
+ #[arg(long, default_value = ".", value_name = "PATH")]
149
+ pub cwd: PathBuf,
150
+
151
+ /// Output directory used for package and make artifacts.
152
+ #[arg(long, default_value = "out", value_name = "PATH")]
153
+ pub out_dir: PathBuf,
154
+
155
+ /// Override the application name.
156
+ #[arg(long)]
157
+ pub name: Option<String>,
158
+
159
+ /// Target platform label. Defaults to the current platform.
160
+ #[arg(long)]
161
+ pub platform: Option<String>,
162
+
163
+ /// Target architecture label. Defaults to the current architecture.
164
+ #[arg(long)]
165
+ pub arch: Option<String>,
166
+
167
+ /// Maker target to run.
168
+ #[arg(long, value_enum, default_value_t = MakeTarget::Zip)]
169
+ pub target: MakeTarget,
170
+
171
+ /// Reuse an existing package output instead of running package first.
172
+ #[arg(long)]
173
+ pub skip_package: bool,
174
+
175
+ /// Overwrite existing package and make artifacts.
176
+ #[arg(long)]
177
+ pub force: bool,
178
+
179
+ /// Print the make plan without creating files.
180
+ #[arg(long)]
181
+ pub dry_run: bool,
182
+
183
+ /// Emit machine-readable JSON.
184
+ #[arg(long)]
185
+ pub json: bool,
186
+ }
187
+
188
+ #[derive(Debug, Clone, Args)]
189
+ pub struct PublishArgs {
190
+ /// Project directory to publish from.
191
+ #[arg(long, default_value = ".", value_name = "PATH")]
192
+ pub cwd: PathBuf,
193
+
194
+ /// Output directory used for package, make, and publish artifacts.
195
+ #[arg(long, default_value = "out", value_name = "PATH")]
196
+ pub out_dir: PathBuf,
197
+
198
+ /// Override the application name.
199
+ #[arg(long)]
200
+ pub name: Option<String>,
201
+
202
+ /// Target platform label. Defaults to the current platform.
203
+ #[arg(long)]
204
+ pub platform: Option<String>,
205
+
206
+ /// Target architecture label. Defaults to the current architecture.
207
+ #[arg(long)]
208
+ pub arch: Option<String>,
209
+
210
+ /// Maker target whose artifact should be published.
211
+ #[arg(long, value_enum, default_value_t = MakeTarget::Zip)]
212
+ pub target: MakeTarget,
213
+
214
+ /// Publisher target to use.
215
+ #[arg(long, value_enum, default_value_t = PublishTarget::Local)]
216
+ pub publisher: PublishTarget,
217
+
218
+ /// Destination for local published artifacts.
219
+ #[arg(long, default_value = "out/publish/local", value_name = "PATH")]
220
+ pub to: PathBuf,
221
+
222
+ /// GitHub repository to publish to, in OWNER/REPO form.
223
+ #[arg(long, value_name = "OWNER/REPO")]
224
+ pub github_repo: Option<String>,
225
+
226
+ /// GitHub release tag. Defaults to v<package version>, then channel.
227
+ #[arg(long)]
228
+ pub github_tag: Option<String>,
229
+
230
+ /// GitHub release name. Defaults to the release tag.
231
+ #[arg(long)]
232
+ pub github_release_name: Option<String>,
233
+
234
+ /// Mark a newly created GitHub release as draft.
235
+ #[arg(long)]
236
+ pub github_draft: bool,
237
+
238
+ /// Mark a newly created GitHub release as prerelease.
239
+ #[arg(long)]
240
+ pub github_prerelease: bool,
241
+
242
+ /// GitHub API base URL, useful for GitHub Enterprise.
243
+ #[arg(long, default_value = "https://api.github.com", value_name = "URL")]
244
+ pub github_api_url: String,
245
+
246
+ /// Release channel label written into the publish manifest.
247
+ #[arg(long, default_value = "default")]
248
+ pub channel: String,
249
+
250
+ /// Reuse an existing make artifact instead of running package and make first.
251
+ #[arg(long)]
252
+ pub skip_make: bool,
253
+
254
+ /// Overwrite existing publish artifacts.
255
+ #[arg(long)]
256
+ pub force: bool,
257
+
258
+ /// Print the publish plan without creating files.
259
+ #[arg(long)]
260
+ pub dry_run: bool,
261
+
262
+ /// Emit machine-readable JSON.
263
+ #[arg(long)]
264
+ pub json: bool,
265
+ }
266
+
267
+ #[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
268
+ #[value(rename_all = "lower")]
269
+ pub enum PackageManager {
270
+ Npm,
271
+ Pnpm,
272
+ Yarn,
273
+ Bun,
274
+ }
275
+
276
+ impl PackageManager {
277
+ pub fn as_str(self) -> &'static str {
278
+ match self {
279
+ PackageManager::Npm => "npm",
280
+ PackageManager::Pnpm => "pnpm",
281
+ PackageManager::Yarn => "yarn",
282
+ PackageManager::Bun => "bun",
283
+ }
284
+ }
285
+ }
286
+
287
+ #[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
288
+ #[value(rename_all = "lower")]
289
+ pub enum MakeTarget {
290
+ Deb,
291
+ Dmg,
292
+ Rpm,
293
+ Zip,
294
+ }
295
+
296
+ impl MakeTarget {
297
+ pub fn as_str(self) -> &'static str {
298
+ match self {
299
+ MakeTarget::Deb => "deb",
300
+ MakeTarget::Dmg => "dmg",
301
+ MakeTarget::Rpm => "rpm",
302
+ MakeTarget::Zip => "zip",
303
+ }
304
+ }
305
+ }
306
+
307
+ #[derive(Debug, Clone, Copy, ValueEnum)]
308
+ #[value(rename_all = "lower")]
309
+ pub enum PublishTarget {
310
+ Github,
311
+ Local,
312
+ }
313
+
314
+ impl PublishTarget {
315
+ pub fn as_str(self) -> &'static str {
316
+ match self {
317
+ PublishTarget::Github => "github",
318
+ PublishTarget::Local => "local",
319
+ }
320
+ }
321
+ }