electron-cli 0.3.0-alpha.1 → 0.3.0-alpha.3
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 +1 -1
- package/Cargo.toml +1 -1
- package/README.md +26 -8
- package/package.json +2 -1
- package/src/cli.rs +124 -1
- package/src/commands/init.rs +784 -0
- package/src/commands/mod.rs +3 -0
- package/src/commands/package.rs +665 -0
- package/src/commands/plan.rs +43 -4
- package/src/commands/start.rs +287 -0
- package/src/main.rs +3 -0
- package/templates/minimal/gitignore +5 -0
- package/templates/minimal/src/index.html +82 -0
- package/templates/minimal/src/main.js +33 -0
- package/templates/minimal/src/preload.js +6 -0
- package/templates/minimal/src/renderer.js +5 -0
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
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,40 @@ 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
|
|
17
20
|
electron-cli inspect --json
|
|
18
21
|
electron-cli doctor --json
|
|
19
22
|
electron-cli plan --json
|
|
23
|
+
electron-cli init my-app --dry-run --json
|
|
24
|
+
electron-cli start --dry-run --json
|
|
25
|
+
electron-cli package --dry-run --json
|
|
20
26
|
```
|
|
21
27
|
|
|
22
28
|
Planned commands:
|
|
23
29
|
|
|
24
30
|
```sh
|
|
25
|
-
electron-cli dev
|
|
26
|
-
electron-cli init
|
|
27
|
-
electron-cli package
|
|
28
31
|
electron-cli make
|
|
32
|
+
electron-cli publish
|
|
29
33
|
```
|
|
30
34
|
|
|
31
|
-
The
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
The Rust-native flow currently owns:
|
|
38
|
+
|
|
39
|
+
- `init --template minimal`: writes a local Electron starter without Electron Forge.
|
|
40
|
+
- `start`: launches the installed Electron runtime directly.
|
|
41
|
+
- `package`: copies the installed Electron runtime and app files into a local app bundle for the current platform and architecture. The first package pass supports apps without production `dependencies`; dependency pruning and bundled runtime dependencies are still TODO.
|
|
42
|
+
|
|
43
|
+
`make` and `publish` are not implemented yet. They are the next pieces of the Forge lifecycle to replace.
|
|
32
44
|
|
|
33
45
|
## Install
|
|
34
46
|
|
|
35
47
|
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
48
|
|
|
37
49
|
```sh
|
|
38
|
-
npm install -g electron-cli
|
|
50
|
+
npm install -g electron-cli@alpha
|
|
39
51
|
electron-cli doctor
|
|
40
52
|
```
|
|
41
53
|
|
|
@@ -59,6 +71,9 @@ Or use Cargo directly:
|
|
|
59
71
|
```sh
|
|
60
72
|
cargo run -- doctor
|
|
61
73
|
cargo run -- inspect --json
|
|
74
|
+
cargo run -- init my-app
|
|
75
|
+
cargo run -- start --dry-run
|
|
76
|
+
cargo run -- package --dry-run
|
|
62
77
|
```
|
|
63
78
|
|
|
64
79
|
## Design Goals
|
|
@@ -66,7 +81,7 @@ cargo run -- inspect --json
|
|
|
66
81
|
- Learn Rust through a real developer tool.
|
|
67
82
|
- Make Electron project state easy to inspect.
|
|
68
83
|
- Prefer structured output for agentic workflows.
|
|
69
|
-
-
|
|
84
|
+
- Replace the main Forge-style app flow with narrow Rust-owned pieces.
|
|
70
85
|
- Keep the project clearly independent and experimental.
|
|
71
86
|
|
|
72
87
|
## Non-Goals
|
|
@@ -77,8 +92,11 @@ cargo run -- inspect --json
|
|
|
77
92
|
|
|
78
93
|
## JSON Output
|
|
79
94
|
|
|
80
|
-
|
|
95
|
+
The inspection and planning commands support `--json` so agents and scripts can consume project state without scraping terminal output.
|
|
81
96
|
`plan` is designed around that workflow: it recommends stable commands and reports missing project conventions as structured data.
|
|
97
|
+
`init --dry-run --json` shows whether the CLI will write native template files or delegate to `create-electron-app`.
|
|
98
|
+
`start --dry-run --json` shows the Electron executable that will be launched.
|
|
99
|
+
`package --dry-run --json` shows the runtime and app file copy plan.
|
|
82
100
|
|
|
83
101
|
```sh
|
|
84
102
|
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.
|
|
3
|
+
"version": "0.3.0-alpha.3",
|
|
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,16 @@ 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 a local Electron application bundle without Electron Forge.
|
|
26
|
+
Package(PackageArgs),
|
|
23
27
|
/// Recommend next commands and risks from the project snapshot.
|
|
24
28
|
Plan(CommandArgs),
|
|
29
|
+
/// Launch the current Electron app without Electron Forge.
|
|
30
|
+
Start(StartArgs),
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
#[derive(Debug, Clone, Args)]
|
|
@@ -34,3 +40,120 @@ pub struct CommandArgs {
|
|
|
34
40
|
#[arg(long)]
|
|
35
41
|
pub json: bool,
|
|
36
42
|
}
|
|
43
|
+
|
|
44
|
+
#[derive(Debug, Clone, Args)]
|
|
45
|
+
pub struct InitArgs {
|
|
46
|
+
/// Directory to initialize. Defaults to the current directory.
|
|
47
|
+
#[arg(default_value = ".", value_name = "DIR")]
|
|
48
|
+
pub dir: PathBuf,
|
|
49
|
+
|
|
50
|
+
/// Directory to run the create command from.
|
|
51
|
+
#[arg(long, default_value = ".", value_name = "PATH")]
|
|
52
|
+
pub cwd: PathBuf,
|
|
53
|
+
|
|
54
|
+
/// Template to use. "minimal" is native; other names are passed to create-electron-app.
|
|
55
|
+
#[arg(long, short = 't', default_value = "minimal")]
|
|
56
|
+
pub template: String,
|
|
57
|
+
|
|
58
|
+
/// Package manager command strategy to use.
|
|
59
|
+
#[arg(long, value_enum)]
|
|
60
|
+
pub package_manager: Option<PackageManager>,
|
|
61
|
+
|
|
62
|
+
/// Set a specific Electron version, or use latest/beta/nightly.
|
|
63
|
+
#[arg(long, value_name = "VERSION")]
|
|
64
|
+
pub electron_version: Option<String>,
|
|
65
|
+
|
|
66
|
+
/// Copy template CI files when the Forge template supports them.
|
|
67
|
+
#[arg(long)]
|
|
68
|
+
pub copy_ci_files: bool,
|
|
69
|
+
|
|
70
|
+
/// Overwrite an existing target directory.
|
|
71
|
+
#[arg(long)]
|
|
72
|
+
pub force: bool,
|
|
73
|
+
|
|
74
|
+
/// Skip initializing a git repository in the created project.
|
|
75
|
+
#[arg(long)]
|
|
76
|
+
pub skip_git: bool,
|
|
77
|
+
|
|
78
|
+
/// Print the command and metadata without creating files.
|
|
79
|
+
#[arg(long)]
|
|
80
|
+
pub dry_run: bool,
|
|
81
|
+
|
|
82
|
+
/// Emit machine-readable JSON.
|
|
83
|
+
#[arg(long)]
|
|
84
|
+
pub json: bool,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#[derive(Debug, Clone, Args)]
|
|
88
|
+
pub struct StartArgs {
|
|
89
|
+
/// Project directory to launch.
|
|
90
|
+
#[arg(long, default_value = ".", value_name = "PATH")]
|
|
91
|
+
pub cwd: PathBuf,
|
|
92
|
+
|
|
93
|
+
/// Print the launch command without starting Electron.
|
|
94
|
+
#[arg(long)]
|
|
95
|
+
pub dry_run: bool,
|
|
96
|
+
|
|
97
|
+
/// Emit machine-readable JSON.
|
|
98
|
+
#[arg(long)]
|
|
99
|
+
pub json: bool,
|
|
100
|
+
|
|
101
|
+
/// Extra arguments passed to Electron after `--`.
|
|
102
|
+
#[arg(last = true, value_name = "ELECTRON_ARG")]
|
|
103
|
+
pub electron_args: Vec<String>,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#[derive(Debug, Clone, Args)]
|
|
107
|
+
pub struct PackageArgs {
|
|
108
|
+
/// Project directory to package.
|
|
109
|
+
#[arg(long, default_value = ".", value_name = "PATH")]
|
|
110
|
+
pub cwd: PathBuf,
|
|
111
|
+
|
|
112
|
+
/// Output directory for packaged app bundles.
|
|
113
|
+
#[arg(long, default_value = "out", value_name = "PATH")]
|
|
114
|
+
pub out_dir: PathBuf,
|
|
115
|
+
|
|
116
|
+
/// Override the packaged application name.
|
|
117
|
+
#[arg(long)]
|
|
118
|
+
pub name: Option<String>,
|
|
119
|
+
|
|
120
|
+
/// Target platform label. Defaults to the current platform.
|
|
121
|
+
#[arg(long)]
|
|
122
|
+
pub platform: Option<String>,
|
|
123
|
+
|
|
124
|
+
/// Target architecture label. Defaults to the current architecture.
|
|
125
|
+
#[arg(long)]
|
|
126
|
+
pub arch: Option<String>,
|
|
127
|
+
|
|
128
|
+
/// Overwrite an existing package output directory.
|
|
129
|
+
#[arg(long)]
|
|
130
|
+
pub force: bool,
|
|
131
|
+
|
|
132
|
+
/// Print the package plan without creating files.
|
|
133
|
+
#[arg(long)]
|
|
134
|
+
pub dry_run: bool,
|
|
135
|
+
|
|
136
|
+
/// Emit machine-readable JSON.
|
|
137
|
+
#[arg(long)]
|
|
138
|
+
pub json: bool,
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#[derive(Debug, Clone, Copy, ValueEnum)]
|
|
142
|
+
#[value(rename_all = "lower")]
|
|
143
|
+
pub enum PackageManager {
|
|
144
|
+
Npm,
|
|
145
|
+
Pnpm,
|
|
146
|
+
Yarn,
|
|
147
|
+
Bun,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
impl PackageManager {
|
|
151
|
+
pub fn as_str(self) -> &'static str {
|
|
152
|
+
match self {
|
|
153
|
+
PackageManager::Npm => "npm",
|
|
154
|
+
PackageManager::Pnpm => "pnpm",
|
|
155
|
+
PackageManager::Yarn => "yarn",
|
|
156
|
+
PackageManager::Bun => "bun",
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|