@skathi-native/cli 0.1.0-beta.1 → 0.1.0-beta.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.
Files changed (53) hide show
  1. package/aot/host-globals.json +105 -0
  2. package/aot/native.ts +142 -0
  3. package/aot/pin.ts +67 -0
  4. package/aot/toolchain.lock.json +17 -0
  5. package/aot/transform.ts +69 -0
  6. package/cli/aot-build.ts +189 -0
  7. package/cli/build-app.ts +67 -25
  8. package/cli/config.ts +44 -101
  9. package/cli/create.ts +107 -234
  10. package/cli/help.ts +159 -0
  11. package/cli/host-fetch.ts +87 -48
  12. package/cli/host.ts +18 -8
  13. package/cli/sk.ts +35 -110
  14. package/cli/skpk.ts +4 -0
  15. package/package.json +4 -2
  16. package/templates/icon.png +0 -0
  17. package/templates/minimal/.vscode/settings.json +3 -0
  18. package/templates/minimal/assets/hello.txt +1 -0
  19. package/templates/minimal/src/App.vue +142 -0
  20. package/templates/minimal/src/main.ts +4 -0
  21. package/templates/showcase/.vscode/settings.json +3 -0
  22. package/templates/showcase/assets/hello.txt +1 -0
  23. package/templates/showcase/assets/media/aurora.png +0 -0
  24. package/templates/showcase/assets/media/clip.mp4 +0 -0
  25. package/templates/showcase/assets/media/sticker.tgs +0 -0
  26. package/templates/showcase/src/App.vue +128 -0
  27. package/templates/showcase/src/components/Card.vue +41 -0
  28. package/templates/showcase/src/components/Icon.vue +29 -0
  29. package/templates/showcase/src/components/Page.vue +41 -0
  30. package/templates/showcase/src/components/Titlebar.vue +132 -0
  31. package/templates/showcase/src/engine.ts +10 -0
  32. package/templates/showcase/src/icons.ts +22 -0
  33. package/templates/showcase/src/main.ts +7 -0
  34. package/templates/showcase/src/pages/AudioPage.vue +121 -0
  35. package/templates/showcase/src/pages/FilesPage.vue +87 -0
  36. package/templates/showcase/src/pages/FormsPage.vue +138 -0
  37. package/templates/showcase/src/pages/GraphicsPage.vue +154 -0
  38. package/templates/showcase/src/pages/HomePage.vue +140 -0
  39. package/templates/showcase/src/pages/LocalePage.vue +71 -0
  40. package/templates/showcase/src/pages/MediaPage.vue +85 -0
  41. package/templates/showcase/src/pages/MotionPage.vue +199 -0
  42. package/templates/showcase/src/pages/NetworkPage.vue +104 -0
  43. package/templates/showcase/src/pages/PermissionsPage.vue +80 -0
  44. package/templates/showcase/src/pages/StoragePage.vue +104 -0
  45. package/templates/showcase/src/pages/StylesPage.vue +199 -0
  46. package/templates/showcase/src/pages/SystemPage.vue +89 -0
  47. package/templates/showcase/src/pages/TrayPage.vue +66 -0
  48. package/templates/showcase/src/pages/WindowPage.vue +128 -0
  49. package/templates/showcase/src/product.ts +2 -0
  50. package/templates/showcase/src/router.ts +149 -0
  51. package/templates/showcase/src/stores/counter.ts +9 -0
  52. package/templates/showcase/src/stores/desktop.ts +115 -0
  53. package/templates/showcase/src/styles.css +140 -0
package/cli/host-fetch.ts CHANGED
@@ -8,10 +8,12 @@
8
8
 
9
9
  import { chmodSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
10
10
  import { dirname, join } from "node:path";
11
- import { partsLeftOut, VARIANTS, type Variant } from "./config";
11
+ import type { CompilerInfo } from "../aot/pin";
12
+ import type { Variant } from "./config";
12
13
  import {
13
14
  CLI_VERSION,
14
15
  cachedHost,
16
+ cacheRoot,
15
17
  HostError,
16
18
  resolveHost,
17
19
  type HostInfo,
@@ -35,14 +37,31 @@ export interface HostManifestEntry {
35
37
  info: HostInfo;
36
38
  }
37
39
 
40
+ /** sk-aot (`sk build --aot`), matching the release's hosts. */
41
+ export interface AotCompilerEntry {
42
+ platform: Platform;
43
+ arch: string;
44
+ /** The release asset: sk-aot, gzipped. */
45
+ file: string;
46
+ /** Of sk-aot itself, not of the gzip. */
47
+ sha256: string;
48
+ size: number;
49
+ /** What `sk-aot info` prints: the frontend, engine and builtin table it compiles for. */
50
+ info: CompilerInfo;
51
+ }
52
+
38
53
  export interface HostManifest {
39
54
  skathi: string;
40
55
  hosts: HostManifestEntry[];
56
+ aot?: AotCompilerEntry[];
41
57
  }
42
58
 
43
59
  export const hostAssetName = (platform: Platform, arch: string, variant: Variant): string =>
44
60
  `sk-host-${platform}-${arch}-${variant}${platform === "windows" ? ".exe" : ""}.gz`;
45
61
 
62
+ export const aotCompilerAssetName = (platform: Platform, arch: string): string =>
63
+ `sk-aot-${platform}-${arch}${platform === "windows" ? ".exe" : ""}.gz`;
64
+
46
65
  export const sha256 = (bytes: Uint8Array): string =>
47
66
  new Bun.CryptoHasher("sha256").update(new Uint8Array(bytes)).digest("hex");
48
67
 
@@ -75,14 +94,16 @@ async function download(asset: ReleaseAsset, headers: Record<string, string>): P
75
94
  return new Uint8Array(await res.arrayBuffer());
76
95
  }
77
96
 
78
- /** Downloads the host for `variant` from the release of `version` into the local cache, checked against `hosts.json`. */
79
- export async function fetchHost(options: FetchOptions): Promise<{ path: string; info: HostInfo }> {
80
- const version = options.version ?? CLI_VERSION;
81
- const platform = options.platform ?? currentPlatform();
82
- const arch = options.arch ?? process.arch;
83
- const log = options.log ?? (() => {});
84
- const { repo, api, headers } = source();
97
+ interface Release {
98
+ tag: string;
99
+ repo: string;
100
+ headers: Record<string, string>;
101
+ manifest: HostManifest;
102
+ asset: (name: string) => ReleaseAsset | undefined;
103
+ }
85
104
 
105
+ async function readRelease(version: string): Promise<Release> {
106
+ const { repo, api, headers } = source();
86
107
  const tag = `v${version}`;
87
108
  const res = await fetch(`${api}/repos/${repo}/releases/tags/${tag}`, {
88
109
  headers: { ...headers, Accept: "application/vnd.github+json" },
@@ -100,6 +121,41 @@ export async function fetchHost(options: FetchOptions): Promise<{ path: string;
100
121
  const manifestAsset = asset(MANIFEST_NAME);
101
122
  if (!manifestAsset) throw new HostError(`release ${tag} of github.com/${repo} has no ${MANIFEST_NAME}`);
102
123
  const manifest = JSON.parse(new TextDecoder().decode(await download(manifestAsset, headers))) as HostManifest;
124
+ return { tag, repo, headers, manifest, asset };
125
+ }
126
+
127
+ /** Gunzips `name` and writes it to `dest` only when it matches `size` and `sha256`. */
128
+ async function cacheAsset(
129
+ release: Release,
130
+ name: string,
131
+ size: number,
132
+ digest: string,
133
+ dest: string,
134
+ log: (line: string) => void,
135
+ ): Promise<void> {
136
+ const asset = release.asset(name);
137
+ if (!asset) throw new HostError(`release ${release.tag} lists ${name} in ${MANIFEST_NAME} but does not carry it`);
138
+ log(`downloading ${name} (${(asset.size / 1048576).toFixed(1)} MB) from github.com/${release.repo} ${release.tag}`);
139
+ const bytes = Bun.gunzipSync(await download(asset, release.headers));
140
+ if (bytes.length !== size || sha256(bytes) !== digest) {
141
+ throw new HostError(`${name} does not match the sha256 in ${MANIFEST_NAME}; nothing was cached`);
142
+ }
143
+ mkdirSync(dirname(dest), { recursive: true });
144
+ const tmp = `${dest}.partial`;
145
+ writeFileSync(tmp, bytes);
146
+ if (process.platform !== "win32") chmodSync(tmp, 0o755);
147
+ rmSync(dest, { force: true });
148
+ renameSync(tmp, dest);
149
+ }
150
+
151
+ /** Downloads the host for `variant` from the release of `version` into the local cache, checked against `hosts.json`. */
152
+ export async function fetchHost(options: FetchOptions): Promise<{ path: string; info: HostInfo }> {
153
+ const version = options.version ?? CLI_VERSION;
154
+ const platform = options.platform ?? currentPlatform();
155
+ const arch = options.arch ?? process.arch;
156
+ const log = options.log ?? (() => {});
157
+ const release = await readRelease(version);
158
+ const { manifest, tag } = release;
103
159
  const entry = manifest.hosts.find((h) => h.platform === platform && h.arch === arch && h.variant === options.variant);
104
160
  if (!entry) {
105
161
  const offered = manifest.hosts
@@ -111,63 +167,46 @@ export async function fetchHost(options: FetchOptions): Promise<{ path: string;
111
167
  (offered ? ` (it has: ${offered}); other variants are built from a checkout with sk host build` : ""),
112
168
  );
113
169
  }
114
- const hostAsset = asset(entry.file);
115
- if (!hostAsset) throw new HostError(`release ${tag} lists ${entry.file} in ${MANIFEST_NAME} but does not carry it`);
116
-
117
- log(`downloading ${entry.file} (${(hostAsset.size / 1048576).toFixed(1)} MB) from github.com/${repo} ${tag}`);
118
- const bytes = Bun.gunzipSync(await download(hostAsset, headers));
119
- if (bytes.length !== entry.size || sha256(bytes) !== entry.sha256) {
120
- throw new HostError(`${entry.file} does not match the sha256 in ${MANIFEST_NAME}; nothing was cached`);
121
- }
122
-
123
170
  const dest = cachedHost(version, options.variant, platform);
124
- mkdirSync(dirname(dest), { recursive: true });
125
- const tmp = `${dest}.partial`;
126
- writeFileSync(tmp, bytes);
127
- if (process.platform !== "win32") chmodSync(tmp, 0o755);
128
- rmSync(dest, { force: true });
129
- renameSync(tmp, dest);
171
+ await cacheAsset(release, entry.file, entry.size, entry.sha256, dest, log);
130
172
  writeFileSync(join(dirname(dest), "host.json"), JSON.stringify(entry.info, null, 2) + "\n");
131
173
  log(`cached ${options.variant} host ${version} → ${dest}`);
132
174
  return { path: dest, info: entry.info };
133
175
  }
134
176
 
135
- /**
136
- * The published variant that can stand in for `variant`: devtools exactly as asked, and every other
137
- * part the app may use, with the fewest extra. A host with a part the app does not use only costs size.
138
- */
139
- export function standIn(variant: Variant, published: readonly Variant[] = VARIANTS): Variant | null {
140
- const off = new Set(partsLeftOut(variant));
141
- const fits = published.filter((v) => {
142
- const o = partsLeftOut(v);
143
- return o.includes("devtools") === off.has("devtools") && o.every((p) => off.has(p));
144
- });
145
- return fits.sort((a, b) => partsLeftOut(b).length - partsLeftOut(a).length)[0] ?? null;
177
+ /** Where the sk-aot of Skathi `version` is cached. */
178
+ export const cachedAotCompiler = (version: string, platform: Platform = currentPlatform()) =>
179
+ join(cacheRoot(platform), version, "aot", `sk-aot${platform === "windows" ? ".exe" : ""}`);
180
+
181
+ /** Downloads sk-aot from the release of `version` into the local cache, checked against `hosts.json`. */
182
+ export async function fetchAotCompiler(
183
+ options: Omit<FetchOptions, "variant"> = {},
184
+ ): Promise<{ path: string; info: CompilerInfo }> {
185
+ const version = options.version ?? CLI_VERSION;
186
+ const platform = options.platform ?? currentPlatform();
187
+ const arch = options.arch ?? process.arch;
188
+ const log = options.log ?? (() => {});
189
+ const release = await readRelease(version);
190
+ const entry = release.manifest.aot?.find((c) => c.platform === platform && c.arch === arch);
191
+ if (!entry) throw new HostError(`release ${release.tag} has no sk-aot for ${platform}-${arch}`);
192
+ const dest = cachedAotCompiler(version, platform);
193
+ await cacheAsset(release, entry.file, entry.size, entry.sha256, dest, log);
194
+ writeFileSync(join(dirname(dest), "compiler.json"), JSON.stringify(entry.info, null, 2) + "\n");
195
+ log(`cached sk-aot ${version} → ${dest}`);
196
+ return { path: dest, info: entry.info };
146
197
  }
147
198
 
148
199
  /**
149
200
  * {@link resolveHost}, and when it finds nothing for this OS and no host was named, a download into the
150
- * cache first. A variant no release carries falls back to its {@link standIn}, with `substitute` saying
151
- * so. SK_HOST_OFFLINE=1 turns the download off.
201
+ * cache first. SK_HOST_OFFLINE=1 turns the download off.
152
202
  */
153
- export async function resolveOrFetchHost(options: ResolveOptions): Promise<ResolvedHost & { substitute?: string }> {
203
+ export async function resolveOrFetchHost(options: ResolveOptions): Promise<ResolvedHost> {
154
204
  try {
155
205
  return resolveHost(options);
156
206
  } catch (e) {
157
207
  const named = options.host ?? process.env.SK_HOST;
158
208
  const cross = (options.platform ?? currentPlatform()) !== currentPlatform();
159
209
  if (!(e instanceof HostError) || named || cross || process.env.SK_HOST_OFFLINE === "1") throw e;
160
- const instead = VARIANTS.includes(options.variant) ? null : standIn(options.variant);
161
- if (instead) {
162
- const host = await resolveOrFetchHost({ ...options, variant: instead });
163
- const extra = partsLeftOut(instead).length < partsLeftOut(options.variant).length;
164
- return {
165
- ...host,
166
- substitute:
167
- `no prebuilt ${options.variant} host: using ${instead}` +
168
- (extra ? ", which also carries parts this app leaves out (sk host build makes an exact one)" : ""),
169
- };
170
- }
171
210
  try {
172
211
  await fetchHost({ variant: options.variant, ...(options.log && { log: options.log }) });
173
212
  } catch (f) {
package/cli/host.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Where `sk build` gets the prebuilt bare host it stamps: `cargo build --release -p sk-app
2
- // --features prod` (the whole engine, no app), built once per Skathi version and variant. A
3
- // variant names the engine parts left out (config.ts `OPTIONAL`).
2
+ // --features prod` (the whole engine, no app), built once per Skathi version and variant: `standard`, or
3
+ // `no-devtools` with the devtools compiled out.
4
4
  //
5
5
  // Resolution, first hit wins: 1. `--host <exe>` or `SK_HOST`; 2. in-repo
6
6
  // target/x86_64-pc-windows-msvc/release/sk-app.exe, when that is a prod host of this variant and
@@ -29,7 +29,8 @@ import {
29
29
  } from "node:fs";
30
30
  import { homedir } from "node:os";
31
31
  import { dirname, join, resolve } from "node:path";
32
- import { cargoFeatureArgs, OPTIONAL, partsLeftOut, type Variant } from "./config";
32
+ import type { CompilerInfo } from "../aot/pin";
33
+ import { cargoFeatureArgs, ENGINE_FEATURES, VARIANTS, type Variant } from "./config";
33
34
  import { appendedPayloadOf, elfMachineOf } from "./elf";
34
35
  import { bundlePayloadPath, machOArchs } from "./macos-bundle";
35
36
  import { readPe, RT } from "./pe";
@@ -56,6 +57,13 @@ export interface HostInfo {
56
57
  jscPin: string;
57
58
  payloadFormat: number;
58
59
  profile: string;
60
+ /** A host built with the native AOT loader: what an app image must be compiled against. */
61
+ aot?: HostAot | null;
62
+ }
63
+
64
+ export interface HostAot extends CompilerInfo {
65
+ transform: string;
66
+ preludeSha256: string;
59
67
  }
60
68
 
61
69
  export interface ResolvedHost {
@@ -110,14 +118,14 @@ export function crossHostInfo(
110
118
  }
111
119
  } catch {}
112
120
  }
113
- const off = partsLeftOut(variant);
121
+ const devtools = variant !== "no-devtools";
114
122
  const info: HostInfo = {
115
123
  mode: "prod",
116
124
  skathi: CLI_VERSION,
117
125
  crate: "unknown",
118
126
  variant,
119
- devtools: !off.includes("devtools"),
120
- features: ["prod", ...OPTIONAL.filter((p) => p !== "devtools" && !off.includes(p))],
127
+ devtools,
128
+ features: ["prod", ...(devtools ? [] : ["no-devtools"]), ...ENGINE_FEATURES],
121
129
  jscPin: "unknown",
122
130
  payloadFormat: 1,
123
131
  profile: "unknown",
@@ -173,9 +181,11 @@ export function checkHost(exe: string, info: HostInfo, variant: Variant | null,
173
181
  }
174
182
  if (info.mode !== "prod") return `${exe} is a ${info.mode} host — sk build needs one built with --features prod`;
175
183
  if (variant && info.variant !== variant) return `${exe} is the ${info.variant} variant, not ${variant}`;
176
- if (!partsLeftOut(variant ?? info.variant).includes("webgpu") && !info.features?.includes("webgpu")) {
177
- return `${exe} lacks native WebGPU required by ${variant} — rebuild or replace the cached host`;
184
+ if (!VARIANTS.includes(info.variant)) {
185
+ return `${exe} is the ${info.variant} variant, which leaves engine parts out — sk build stamps only ${VARIANTS.join(" or ")} hosts`;
178
186
  }
187
+ const missing = ENGINE_FEATURES.filter((f) => !info.features?.includes(f));
188
+ if (missing.length) return `${exe} lacks ${missing.join(", ")} — rebuild or replace the cached host`;
179
189
  return mismatch;
180
190
  }
181
191
 
package/cli/sk.ts CHANGED
@@ -3,99 +3,16 @@
3
3
  // Rust toolchain.
4
4
 
5
5
  import { spawn } from "node:child_process";
6
+ import { aotFlags } from "./aot-build";
6
7
  import { buildApp, summary } from "./build-app";
7
- import {
8
- ConfigError,
9
- OPTIONAL,
10
- parseParts,
11
- partsLeftOut,
12
- selectVariant,
13
- VARIANTS,
14
- variantFor,
15
- type Variant,
16
- } from "./config";
8
+ import { ConfigError, parseVariant, PARTS_NOT_SELECTABLE, VARIANTS, type Variant } from "./config";
17
9
  import { dev } from "./dev";
18
10
  import { addHost, buildHost, CLI_VERSION, DEV_HOST, HostError, hostInfo, resolveHost } from "./host";
19
11
  import { fetchHost } from "./host-fetch";
20
12
  import { colorEnabled, colorFlag, lineProgress, logTo, paint, progressFor } from "./term";
21
13
  import { createCommand } from "./create";
22
14
  import { currentPlatform, parsePlatform } from "./platform";
23
-
24
- const USAGE = `sk ${CLI_VERSION} — package a Skathi app for Windows, macOS or Linux
25
-
26
- usage
27
- sk dev [app] [--exe <h>] the dev loop: build.ts --watch + a dev host (hot reload); the
28
- host is the checkout's debug sk-app, else this version's,
29
- cached or downloaded from its release
30
- sk build [app] [options] a debug exe in <app>/dist/debug: devtools (F12) in, the bundle
31
- not minified
32
- sk publish [app] [options] the release exe in <app>/dist/release: the engine parts
33
- sk.config.json selects, and without a selection no devtools;
34
- minified (macOS: <exeName>.app, signed per macos.sign)
35
- sk run [app] [options] sk build, then start the exe with its stderr in this terminal
36
- sk host info [exe] what a host exe says about itself (--sk-host-info)
37
- sk host path [selection] which host \`sk build\` would stamp
38
- sk host fetch [selection | --variant both | --variant dev]
39
- download prebuilt hosts of this version from its GitHub
40
- release into the local cache (no selection: every published
41
- one and the dev host; sk build and sk dev do it on demand)
42
- sk host add <exe> verify a prod host and copy it into the local cache
43
- sk host build [selection | --variant both]
44
- maintainers, in a checkout: cargo-build the bare host(s)
45
- (no selection: standard and no-devtools)
46
- sk check [app] [options] what in the bundle (app code and node_modules) breaks or slows
47
- down under native AOT, and how well it is typed
48
- --format pretty|json json: one versioned report on stdout (schema skathi.check)
49
- --deny-warnings warnings fail the check too
50
- --no-deps the app's own code only
51
- --config <path> external config, as for sk build
52
- --color | --no-color colours on or off (default: a terminal, unless NO_COLOR is set)
53
- exit 0: clean; 1: errors; 2: usage, config or internal failure
54
- sk.config.json "check": { "allow": { "SK2001": ["pkg", "src/legacy/**"] } }
55
- sk explain <CODE> | --list what a check code means and how to fix it
56
- sk create [dir] [options] a new app; in a terminal it asks for what the options leave open
57
- --name <n> the app's name (default: the directory's)
58
- --os windows,macos what sk publish packages for (default: this OS)
59
- --without audio,… engine parts to leave out (${OPTIONAL.filter((p) => p !== "devtools").join(", ")})
60
- --devtools | --no-devtools whether sk publish keeps devtools (default: no)
61
- --router | --no-router vue-router and pinia (asked: yes; with --yes: no)
62
- --pm bun|npm|pnpm|yarn the package manager (default: the one running this, else bun)
63
- --yes, -y ask nothing; defaults for the rest
64
-
65
- [app] is an app directory (default: .), its entry module, or its sk.config.json.
66
-
67
- build and publish options
68
- --out <dir> output directory (default <app>/dist/debug or dist/release)
69
- --config <path> external config; entry and relative assets stay under [app]
70
- --host <exe> the bare host to stamp (default: SK_HOST, the checkout's
71
- target/…/release/sk-app.exe, the local cache, then a
72
- download from the release; SK_HOST_OFFLINE=1 skips that)
73
- selection — which engine parts the host carries (default: sk.config.json
74
- "windows": "without" / "features" / "host", else every part; sk build always keeps
75
- devtools, sk publish drops them unless the config selects them). One of:
76
- --without audio,clipboard leave these parts out
77
- --features audio,storages take only these parts
78
- --variant no-devtools+no-audio
79
- a host variant by name ("standard" = every part)
80
- parts: ${OPTIONAL.join(", ")}
81
- --console keep the console subsystem (a console window opens with it)
82
- --platform windows|macos|linux what to package for (default: this OS). Another OS's
83
- build needs --host <its sk-app>, and is not signed
84
- --sign <identity> macOS: codesign with this identity, hardened runtime and
85
- entitlements ("-" = ad hoc; over sk.config.json macos.sign)
86
- --no-sign macOS: leave the bundle unsigned (default: ad hoc)
87
- --payload-only write dist/.sk/app.skpk and stop; no host needed
88
- --aot-inputs retain typed TS/Vue source inputs in dist/.sk/aot-inputs/
89
- (preparation archive; does not enable native AOT)
90
- --allow-host-mismatch stamp a host from another Skathi version (maintainers)
91
- --define K=V a Vite-style define on top of sk.config.json "define"
92
- (V is an expression: --define __FLAG__=true,
93
- --define 'APP_NAME="argon"'); repeatable
94
- --json one JSON line instead of the summary (build, host path)
95
-
96
- sk.config.json "packs" splits the assets into <name>.skpk files beside the payload
97
- (or the exe), e.g. [{ "name": "fonts", "match": ["**/*.woff2"] }, { "name": "assets" }].
98
- `;
15
+ import { commandHelp, topHelp } from "./help";
99
16
 
100
17
  type Flags = Record<string, string | boolean>;
101
18
  const BOOLEAN = new Set([
@@ -106,14 +23,15 @@ const BOOLEAN = new Set([
106
23
  "payload-only",
107
24
  "allow-host-mismatch",
108
25
  "aot-inputs",
26
+ "aot",
27
+ "no-aot",
109
28
  "help",
29
+ "version",
110
30
  "json",
111
31
  "no-sign",
112
32
  "yes",
113
33
  "devtools",
114
34
  "no-devtools",
115
- "router",
116
- "no-router",
117
35
  "color",
118
36
  "no-color",
119
37
  ]);
@@ -137,6 +55,7 @@ function parse(argv: string[]): {
137
55
  }
138
56
  if (a === "-h") flags.help = true;
139
57
  else if (a === "-y") flags.yes = true;
58
+ else if (a === "-v") flags.version = true;
140
59
  else if (a.startsWith("--")) {
141
60
  // Split at the FIRST "=" only: `--define=K=V` keeps its own "=".
142
61
  const body = a.slice(2);
@@ -151,34 +70,37 @@ function parse(argv: string[]): {
151
70
  return { positional, flags, repeated, rest };
152
71
  }
153
72
 
73
+ function refuseParts(flags: Flags): void {
74
+ for (const gone of ["without", "features"]) {
75
+ if (flags[gone] !== undefined) throw new ConfigError(`--${gone}: ${PARTS_NOT_SELECTABLE}`);
76
+ }
77
+ }
78
+
154
79
  function variantOf(flags: Flags): Variant | undefined {
155
- const list = (name: string) => {
156
- const v = flags[name];
157
- if (v === undefined) return undefined;
158
- if (typeof v !== "string" || !v.trim())
159
- throw new ConfigError(`--${name} needs a list of parts (${OPTIONAL.join(", ")})`);
160
- return parseParts(v, `--${name}`);
161
- };
162
- const host = flags.variant;
163
- if (host !== undefined && (typeof host !== "string" || !host.trim()))
164
- throw new ConfigError("--variant needs a variant name");
165
- const sel = { features: list("features"), without: list("without"), host: host as string | undefined };
166
- if (!sel.features && !sel.without && !sel.host) return undefined;
167
- // Normalised: `no-audio+no-devtools` and `no-devtools+no-audio` are one host.
168
- return variantFor(partsLeftOut(selectVariant(sel, "the command line")));
80
+ refuseParts(flags);
81
+ return flags.variant === undefined ? undefined : parseVariant(flags.variant, "--variant");
169
82
  }
170
83
 
171
84
  async function main(argv: string[]): Promise<number> {
172
85
  const { positional, flags, repeated, rest } = parse(argv);
173
86
  const [command, ...args] = positional;
174
- if (!command || flags.help || command === "help") {
175
- console.log(USAGE);
176
- return command || flags.help ? 0 : 1;
177
- }
178
- if (command === "version" || command === "--version") {
87
+ if (command === "version" || (!command && flags.version === true)) {
179
88
  console.log(CLI_VERSION);
180
89
  return 0;
181
90
  }
91
+ const color = colorEnabled(process.stdout, colorFlag(flags));
92
+ const about = command === "help" ? args[0] : flags.help ? command : undefined;
93
+ if (about !== undefined) {
94
+ const text = commandHelp(about, color);
95
+ if (text) {
96
+ console.log(text);
97
+ return 0;
98
+ }
99
+ }
100
+ if (!command || flags.help || command === "help") {
101
+ console.log(topHelp(color));
102
+ return command || flags.help ? 0 : 1;
103
+ }
182
104
 
183
105
  if (command === "build" || command === "publish" || command === "run") {
184
106
  const platform = flags.platform === undefined ? undefined : parsePlatform(flags.platform);
@@ -205,6 +127,8 @@ async function main(argv: string[]): Promise<number> {
205
127
  allowHostMismatch: flags["allow-host-mismatch"] === true,
206
128
  defines: repeated.define,
207
129
  aotInputs: flags["aot-inputs"] === true,
130
+ ...aotFlags(flags),
131
+ color: colorEnabled(process.stderr, colorFlag(flags)),
208
132
  platform,
209
133
  sign: flags["no-sign"] ? false : typeof flags.sign === "string" ? flags.sign.trim() : undefined,
210
134
  mode: command === "publish" ? "release" : "debug",
@@ -216,6 +140,7 @@ async function main(argv: string[]): Promise<number> {
216
140
  exe: result.exe,
217
141
  skpk: result.skpk,
218
142
  aotInputs: result.aotInputs,
143
+ native: result.native,
219
144
  name: result.config.name,
220
145
  productName: result.config.productName,
221
146
  version: result.config.version,
@@ -321,21 +246,21 @@ async function main(argv: string[]): Promise<number> {
321
246
  }
322
247
 
323
248
  if (command === "create") {
249
+ refuseParts(flags);
324
250
  const str = (k: string) => (typeof flags[k] === "string" ? (flags[k] as string) : undefined);
325
251
  const yesNo = (k: string) => (flags[k] ? true : flags[`no-${k}`] ? false : undefined);
326
252
  return await createCommand(args[0], {
327
253
  name: str("name"),
328
254
  os: str("os"),
329
- without: str("without"),
330
255
  devtools: yesNo("devtools"),
331
- router: yesNo("router"),
256
+ template: str("template"),
332
257
  pm: str("pm"),
333
258
  yes: flags.yes === true,
334
259
  });
335
260
  }
336
261
 
337
262
  console.error(
338
- `${paint(colorEnabled(process.stderr)).red("error")}: unknown command ${JSON.stringify(command)}\n\n${USAGE}`,
263
+ `${paint(colorEnabled(process.stderr)).red("error")}: unknown command ${JSON.stringify(command)} (sk --help lists them)`,
339
264
  );
340
265
  return 1;
341
266
  }
package/cli/skpk.ts CHANGED
@@ -25,6 +25,8 @@ export const KIND = {
25
25
  WINDOW: 2,
26
26
  SCRIPT: 3,
27
27
  BYTECODE: 4,
28
+ NATIVE_MANIFEST: 5,
29
+ NATIVE_IMAGE: 6,
28
30
  ASSET: 16,
29
31
  } as const;
30
32
 
@@ -33,6 +35,8 @@ export const NAMES = {
33
35
  WINDOW: "sk/window.json",
34
36
  SCRIPT: "sk/app.js",
35
37
  BYTECODE: "sk/app.bc",
38
+ NATIVE_MANIFEST: "sk/app.native.json",
39
+ NATIVE_IMAGE: "sk/app.image",
36
40
  } as const;
37
41
 
38
42
  export const FLAG_HAS_BYTECODE = 1;
package/package.json CHANGED
@@ -6,11 +6,13 @@
6
6
  "url": "git+https://github.com/argon-chat/skathi.git",
7
7
  "directory": "packages/cli"
8
8
  },
9
- "version": "0.1.0-beta.1",
9
+ "version": "0.1.0-beta.3",
10
10
  "type": "module",
11
11
  "files": [
12
+ "aot",
12
13
  "cli",
13
14
  "check",
15
+ "templates",
14
16
  "devtools/apps.ts",
15
17
  "devtools/commands.ts",
16
18
  "devtools/ctl.ts",
@@ -29,7 +31,7 @@
29
31
  },
30
32
  "dependencies": {
31
33
  "@clack/prompts": "^1.9.0",
32
- "@skathi-native/runtime": "0.1.0-beta.1",
34
+ "@skathi-native/runtime": "0.1.0-beta.3",
33
35
  "@vue/compiler-sfc": "^3.5.41",
34
36
  "postcss": "^8.4.31",
35
37
  "tailwindcss": "3.4",
Binary file
@@ -0,0 +1,3 @@
1
+ {
2
+ "css.customData": ["./node_modules/@skathi-native/runtime/css-data.json"]
3
+ }
@@ -0,0 +1 @@
1
+ Hello from assets/hello.txt, packaged with {{productName}}.