1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// SPDX-License-Identifier: MIT OR Apache-2.0
mod bench;
mod dev;
mod doctor;
mod project;
mod release;
use std::path::PathBuf;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "auro",
version,
about = "Native Rust desktop apps: Tauri's app model, GPUI's renderer"
)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
#[allow(clippy::large_enum_variant)]
enum Command {
/// Create a new Auro app
New {
/// Directory to create
path: PathBuf,
},
/// Build, run and watch the app
Dev {
/// App directory (defaults to the current one)
#[arg(long)]
dir: Option<PathBuf>,
/// Override a config key, e.g. `app.product-name=Demo`
#[arg(long = "config", value_name = "KEY=VALUE")]
overrides: Vec<String>,
},
/// Build the app in release mode
Build {
/// App directory (defaults to the current one)
#[arg(long)]
dir: Option<PathBuf>,
},
/// Build the app and produce its installers
Bundle {
/// App directory (defaults to the current one)
#[arg(long)]
dir: Option<PathBuf>,
},
/// Generate an Ed25519 release signing key
GenerateKey {
/// Key file to create
#[arg(long)]
out: PathBuf,
},
/// Create a signed update manifest for an artifact
Manifest {
/// Artifact to describe
#[arg(long)]
artifact: PathBuf,
/// Release version
#[arg(long)]
version: String,
/// URL where the artifact will be served
#[arg(long)]
url: String,
/// Signing key file
#[arg(long)]
key: PathBuf,
/// Manifest file to write
#[arg(long)]
out: PathBuf,
/// Release notes
#[arg(long, default_value = "")]
notes: String,
/// Platform key (defaults to the current host)
#[arg(long)]
platform: Option<String>,
/// Publication timestamp (RFC 3339 or any stable text)
#[arg(long)]
published_at: String,
/// Rollout percentage (0-100)
#[arg(long, value_parser = clap::value_parser!(u8).range(0..=100))]
rollout_percentage: Option<u8>,
/// Previous artifact for an optional delta
#[arg(long)]
delta_from: Option<PathBuf>,
/// Version of `--delta-from`
#[arg(long)]
delta_from_version: Option<String>,
/// URL of the delta patch
#[arg(long)]
delta_url: Option<String>,
/// Write the generated delta patch here
#[arg(long)]
delta_out: Option<PathBuf>,
},
/// Submit a macOS artifact for notarization, or verify a notarized one
Notarize {
/// Artifact to submit or verify (`.app`, `.pkg`, `.dmg`, or a zipped `.app`)
#[arg(long)]
artifact: PathBuf,
/// Keychain profile created by `xcrun notarytool store-credentials`
#[arg(long, required_unless_present = "verify")]
profile: Option<String>,
/// Submit without stapling the ticket
#[arg(long, conflicts_with = "verify")]
skip_staple: bool,
/// Check the stapled ticket and Gatekeeper assessment instead of submitting
#[arg(long)]
verify: bool,
},
/// Create a bsdiff-compatible update patch
Delta {
/// Previous artifact
#[arg(long)]
from: PathBuf,
/// New artifact
#[arg(long)]
to: PathBuf,
/// Patch file to write
#[arg(long)]
out: PathBuf,
},
/// Measure startup, idle RSS and binary size for an app
Bench {
/// App directory (defaults to the current one)
#[arg(long)]
dir: Option<PathBuf>,
/// Number of process runs
#[arg(long, default_value_t = 5)]
runs: u32,
/// Seconds to wait before sampling idle RSS
#[arg(long, default_value_t = 5)]
idle_seconds: u64,
/// Emit machine-readable JSON
#[arg(long)]
json: bool,
},
/// Report toolchain, config and platform status
Doctor {
/// App directory (defaults to the current one)
#[arg(long)]
dir: Option<PathBuf>,
},
}
fn main() {
let cli = Cli::parse();
let current = || std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
let result = match cli.command {
Command::New { path } => project::new(&path),
Command::Dev { dir, overrides } => dev::run(dir.unwrap_or_else(current), &overrides),
Command::Build { dir } => project::build(&dir.unwrap_or_else(current)),
Command::Bundle { dir } => project::bundle(&dir.unwrap_or_else(current)),
Command::GenerateKey { out } => release::generate_key(&out),
Command::Manifest {
artifact,
version,
url,
key,
out,
notes,
platform,
published_at,
rollout_percentage,
delta_from,
delta_from_version,
delta_url,
delta_out,
} => release::manifest(
&artifact,
&version,
&url,
&key,
&out,
¬es,
platform.as_deref(),
&published_at,
rollout_percentage,
delta_from.as_deref(),
delta_from_version.as_deref(),
delta_url.as_deref(),
delta_out.as_deref(),
),
Command::Notarize {
artifact,
profile,
skip_staple,
verify,
} => {
if verify {
release::verify(&artifact)
} else {
release::notarize(
&artifact,
profile.as_deref().unwrap_or_default(),
skip_staple,
)
}
}
Command::Delta { from, to, out } => release::delta(&from, &to, &out),
Command::Bench {
dir,
runs,
idle_seconds,
json,
} => bench::run(&dir.unwrap_or_else(current), runs, idle_seconds, json),
Command::Doctor { dir } => doctor::run(&dir.unwrap_or_else(current)),
};
if let Err(error) = result {
eprintln!("auro: {error}");
std::process::exit(1);
}
}