@acryldev/blends 1.7.11 → 1.7.13

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/dist/index.d.ts CHANGED
@@ -34,6 +34,18 @@ export declare const HELP: string;
34
34
  * Run the CLI and return the exit code: 0 done, 1 failed or refused, 2 a usage error. Never calls `process.exit`.
35
35
  */
36
36
  export declare function runCli(argv: readonly string[], io?: Io): Promise<number>;
37
+ /** The app's desktop shell: where its files are and its Electron entry, relative to the app (POSIX separators, as package.json `main` wants). */
38
+ type DesktopShell = {
39
+ readonly kind: 'copy';
40
+ readonly root: string;
41
+ readonly main: string;
42
+ } | {
43
+ readonly kind: 'package';
44
+ readonly root: string;
45
+ readonly main: string;
46
+ };
47
+ /** The app's desktop shell, or undefined for an app without one (a web-only app). A copy wins over the package: it is what the app runs. */
48
+ export declare function findDesktopShell(appDir: string): DesktopShell | undefined;
37
49
  /**
38
50
  * Whether the app is in the frame already, by its packages: it depends on the desktop shell package and its `cordis.patch.yml` mounts the Blends frame or the workbench. A starter
39
51
  * built that way (ACRYL ADE and Control Center, made from the monorepo) needs neither `add desktop-shell` nor the framing `upgrade`: both would refuse it (the
@@ -208,10 +220,10 @@ interface UpdateOptions {
208
220
  export declare function parseUpdateOptions(argv: readonly string[]): UpdateOptions;
209
221
  /** What the update needs outside the app folder. Tests pass their own. */
210
222
  interface UpdateWorld {
211
- /** The registry's version of Blend `id`, or undefined when the registry does not list it. */
212
- latest(id: string): Promise<string | undefined>;
213
- /** Make Blend `id` as a new app named `name` inside `folder` (git repository, no install); resolves to the exit code. */
214
- make(id: string, name: string, folder: string): Promise<number>;
223
+ /** The newest release of `source` (a registry id: its version; `github:owner/repo`: its newest version tag), or undefined when there is none. */
224
+ latest(source: string): Promise<string | undefined>;
225
+ /** Make `source` at `release` as a new app named `name` inside `folder` (git repository, no install); resolves to the exit code. */
226
+ make(source: string, name: string, folder: string, release: string): Promise<number>;
215
227
  }
216
228
  export declare function update(options: UpdateOptions, io: Io, world?: UpdateWorld): Promise<number>;
217
229
  interface UpgradeOptions {
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ var packages = {
47
47
  "path": "../plugins/app-shell"
48
48
  },
49
49
  "@acryldev/workspace": {
50
- "version": "0.2.2",
50
+ "version": "0.2.3",
51
51
  "path": "../plugins/workspace"
52
52
  },
53
53
  "@acryldev/settings": {
@@ -75,7 +75,7 @@ var packages = {
75
75
  "path": "../plugins/support"
76
76
  },
77
77
  "@acryldev/loopback-http": {
78
- "version": "0.2.0",
78
+ "version": "0.2.1",
79
79
  "path": "../runtime/loopback-http"
80
80
  },
81
81
  "@acryldev/web": {
@@ -95,7 +95,7 @@ var packages = {
95
95
  "path": "../plugins/versions"
96
96
  },
97
97
  "@acryldev/blends-frame": {
98
- "version": "0.2.9",
98
+ "version": "0.2.10",
99
99
  "path": "../plugins/blends-frame"
100
100
  }
101
101
  };
@@ -3207,6 +3207,20 @@ async function kvImport(options, io) {
3207
3207
  await source.close();
3208
3208
  }
3209
3209
  }
3210
+ // src/pack.ts
3211
+ /**
3212
+ * `acrylblends pack`: the app in a folder as an installer for this machine's OS (a DMG, an NSIS installer or a Debian package), made with the published
3213
+ * packages, so a Blend's own repository releases its product without ACRYL's source. The packer is ACRYL's framework/scripts/pack-blank-mac.mjs, which
3214
+ * the published package carries in pack/ (scripts-pack.mjs copies it); in ACRYL's checkout the CLI runs it from there.
3215
+ */
3216
+ function pack(args, io) {
3217
+ const script = [new URL("../pack/pack-blank-mac.mjs", import.meta.url), new URL("../../../scripts/pack-blank-mac.mjs", import.meta.url)].map((url) => fileURLToPath(url)).find((file) => existsSync(file));
3218
+ if (script === void 0) {
3219
+ io.stderr.write("error: this copy of @acryldev/blends carries no packer (pack/pack-blank-mac.mjs)\n");
3220
+ return 1;
3221
+ }
3222
+ return spawnSync(process.execPath, [script, ...args], { stdio: "inherit" }).status ?? 1;
3223
+ }
3210
3224
  // src/preflight.ts
3211
3225
  /** The Node the framework needs (the bin refuses an older one before loading anything). */
3212
3226
  const NODE_MINIMUM = [22, 19];
@@ -3519,6 +3533,25 @@ function blendOfApp(yaml) {
3519
3533
  version
3520
3534
  };
3521
3535
  }
3536
+ function sourceOfApp(yaml) {
3537
+ const blend = blendOfApp(yaml);
3538
+ if (blend === void 0) return void 0;
3539
+ const metadata = /^metadata:\n((?:[ \t]+.*\n?)*)/mu.exec(yaml)?.[1] ?? "";
3540
+ const from = /^[ \t]+from:[ \t]*["']?([^"'\s]+)/mu.exec(metadata)?.[1];
3541
+ if (from === void 0) return {
3542
+ source: blend.id,
3543
+ current: blend.version
3544
+ };
3545
+ const [source = blend.id, release] = from.split("#");
3546
+ return {
3547
+ source,
3548
+ current: release === void 0 ? blend.version : release.replace(/^v/u, "")
3549
+ };
3550
+ }
3551
+ /** The newest `vX.Y.Z` (or `X.Y.Z`) tag among `git ls-remote --tags` lines, as tagged. */
3552
+ function newestTag(lsRemote) {
3553
+ return lsRemote.split("\n").map((line) => /refs\/tags\/(v?\d+\.\d+\.\d+)$/u.exec(line.trim())?.[1]).filter((tag) => tag !== void 0).reduce((best, tag) => best === void 0 || isNewerVersion(tag.replace(/^v/u, ""), best.replace(/^v/u, "")) ? tag : best, void 0);
3554
+ }
3522
3555
  /** `0.2.0` is newer than `0.1.9`; anything that is not three numbers is never newer. */
3523
3556
  function isNewerVersion(candidate, current) {
3524
3557
  const parse = (text) => /^(\d+)\.(\d+)\.(\d+)$/u.exec(text)?.slice(1).map(Number);
@@ -3531,11 +3564,29 @@ function isNewerVersion(candidate, current) {
3531
3564
  function registryWorld(io) {
3532
3565
  return {
3533
3566
  async latest(id) {
3567
+ if (id.startsWith("github:")) {
3568
+ const run = spawnSync("git", [
3569
+ "ls-remote",
3570
+ "--tags",
3571
+ "--refs",
3572
+ `https://github.com/${id.slice(7)}.git`
3573
+ ], {
3574
+ encoding: "utf8",
3575
+ windowsHide: true,
3576
+ timeout: 3e4,
3577
+ env: {
3578
+ ...process.env,
3579
+ GIT_TERMINAL_PROMPT: "0"
3580
+ }
3581
+ });
3582
+ if (run.status !== 0) throw new Error(`${id} could not be read: ${(run.stderr ?? "").trim() || "git ls-remote failed"}`);
3583
+ return newestTag(run.stdout ?? "");
3584
+ }
3534
3585
  const answer = await fetch(REGISTRY_INDEX, { signal: AbortSignal.timeout(2e4) });
3535
3586
  if (!answer.ok) throw new Error(`the registry answered ${answer.status} (${REGISTRY_INDEX})`);
3536
3587
  return (await answer.json()).entries?.find((entry) => entry.id === id)?.version;
3537
3588
  },
3538
- make: (id, name, folder) => new Promise((done) => {
3589
+ make: (id, name, folder, release) => new Promise((done) => {
3539
3590
  const { file, args } = packageManagerInvocation("npm", [
3540
3591
  "exec",
3541
3592
  "--yes",
@@ -3543,7 +3594,7 @@ function registryWorld(io) {
3543
3594
  "--",
3544
3595
  name,
3545
3596
  "--from",
3546
- id,
3597
+ id.startsWith("github:") ? `${id}#${release}` : id,
3547
3598
  "--no-install"
3548
3599
  ]);
3549
3600
  const run = spawnSync(file, args, {
@@ -3567,14 +3618,20 @@ async function update(options, io, world = registryWorld(io)) {
3567
3618
  const say = (line) => io.stdout.write(`${line}\n`);
3568
3619
  const manifest = join(app, "blend.yaml");
3569
3620
  if (!existsSync(manifest)) throw new Error(`${app} has no blend.yaml: it was not made from a Blend, so there is nothing to update from`);
3570
- const blend = blendOfApp(readFileSync(manifest, "utf8"));
3571
- if (blend === void 0) throw new Error(`${manifest} names no metadata id and version`);
3572
- say(`${basename(app)} was made from ${blend.id} ${blend.version}. Asking the registry for its latest release...`);
3573
- const latest = await world.latest(blend.id);
3574
- if (latest === void 0) {
3575
- say(`${blend.id} is not a Blend in the registry, so there is nothing to update from it. An app shared from a repository gets its changes with git pull.`);
3621
+ const origin = sourceOfApp(readFileSync(manifest, "utf8"));
3622
+ if (origin === void 0) throw new Error(`${manifest} names no metadata id and version`);
3623
+ const fromRepository = origin.source.startsWith("github:");
3624
+ const blend = {
3625
+ id: origin.source,
3626
+ version: origin.current
3627
+ };
3628
+ say(`${basename(app)} was made from ${blend.id} ${blend.version}. Asking ${fromRepository ? "the repository" : "the registry"} for its latest release...`);
3629
+ const newest = await world.latest(blend.id);
3630
+ if (newest === void 0) {
3631
+ say(fromRepository ? `${blend.id} has no release tags (vX.Y.Z), so there is nothing to update from it yet.` : `${blend.id} is not a Blend in the registry, so there is nothing to update from it.`);
3576
3632
  return 0;
3577
3633
  }
3634
+ const latest = newest.replace(/^v/u, "");
3578
3635
  if (!isNewerVersion(latest, blend.version)) {
3579
3636
  say(`${blend.id} ${blend.version} is the latest release: nothing to update.`);
3580
3637
  return 0;
@@ -3622,9 +3679,9 @@ async function update(options, io, world = registryWorld(io)) {
3622
3679
  }
3623
3680
  const scratch = mkdtempSync(join(tmpdir(), "acrylblends-update-"));
3624
3681
  try {
3625
- say(`Getting ${blend.id} ${latest} (@acryldev/create-blends@latest, as the app was made)...`);
3682
+ say(`Getting ${blend.id} ${newest} (@acryldev/create-blends@latest, as the app was made)...`);
3626
3683
  const name = basename(app);
3627
- if (await world.make(blend.id, name, scratch) !== 0) throw new Error(`${blend.id} ${latest} could not be made; the app is unchanged`);
3684
+ if (await world.make(blend.id, name, scratch, newest) !== 0) throw new Error(`${blend.id} ${latest} could not be made; the app is unchanged`);
3628
3685
  const fetched = git([
3629
3686
  "fetch",
3630
3687
  "-q",
@@ -3640,7 +3697,7 @@ async function update(options, io, world = registryWorld(io)) {
3640
3697
  "-p",
3641
3698
  base,
3642
3699
  "-m",
3643
- `${blend.id} ${latest} from the registry`
3700
+ `${blend.id} ${latest} from ${fromRepository ? "its repository" : "the registry"}`
3644
3701
  ]).out;
3645
3702
  if (!release) throw new Error("the new release could not be recorded in the app");
3646
3703
  say(`Merging ${blend.id} ${latest} into ${name} (your changes are kept)...`);
@@ -4459,13 +4516,17 @@ Usage:
4459
4516
  acrylblends upgrade [plugin...] [--dir d] [--dry-run] [--force] [--diff]
4460
4517
  Bring the library plugins an app carries (the router, the server, the door, ...) up to this
4461
4518
  version: untouched files are replaced, an edited file stops it (diff shown) unless --force
4462
- acrylblends update [--dir d] [--check] Bring the newer release of the Blend this app was made from (blend.yaml) into it from the
4463
- registry, keeping your changes (a git merge); --check only says whether there is one
4519
+ acrylblends update [--dir d] [--check] Bring the newer release of what this app was made from (blend.yaml metadata.from: a registry
4520
+ Blend, or a shared GitHub repository's newest vX.Y.Z tag) into it, keeping your changes
4521
+ (a git merge); --check only says whether there is one
4464
4522
  acrylblends plugins List the plugin library
4465
4523
  acrylblends open [dir] Print the address of the frame running this app (the URL npm run dev printed),
4466
4524
  for a page that has to be opened again after its session ended
4467
4525
  acrylblends preflight Check this machine for the workshop: Node, npm, git, a coding agent, a free port
4468
4526
  (and on Windows PowerShell and long paths); one line per check, PASS or the fix
4527
+ acrylblends pack --from <dir> [--product "Name"] [--arch arm64|x64] [--out d]
4528
+ The app in <dir> as an installer for this OS (DMG, NSIS .exe, .deb), made
4529
+ with the published packages; updates come from <dir>'s GitHub releases
4469
4530
  acrylblends build-client [root] [out] Compile the client modules once for production (src/client to dist/client)
4470
4531
  acrylblends kv import <kv.json> <db> Move a JSON-file kv store into the kv table of a SQLite database [--overwrite] [--table t] [--migrations dir]
4471
4532
  acrylblends check-deps [dir] Fail when app code imports a database driver or opener outside the file named in
@@ -4510,6 +4571,7 @@ async function runCli(argv, io = processIo()) {
4510
4571
  if (command === "plugins") return listPlugins(io);
4511
4572
  if (command === "open") return await openFrame(args, io);
4512
4573
  if (command === "preflight") return await runPreflight(io);
4574
+ if (command === "pack") return pack(args, io);
4513
4575
  throw new UsageError(`unknown command "${command}"`);
4514
4576
  } catch (error) {
4515
4577
  if (error instanceof UsageError) {
@@ -4530,6 +4592,6 @@ function parseCheckDeps(args) {
4530
4592
  function parseKv(args) {
4531
4593
  return parseKvOptions(args);
4532
4594
  }
4533
- export { FRAME_URL_FILE, HELP, TEMPLATES, TEMPLATE_ALIASES, TEMPLATE_SUMMARY, TargetNotEmptyError, UsageError, VERSION, add, assertTargetFree, closure, copyPlugin, copyTemplate, frameHome, frameUrlPath, init, isFramedByPackages, isOmitted, isTemplate, isValidName, libraryRoot, listPlugins, lookUpFrameUrl, mergeDependencies, mergeTooling, nameFrom, openFrame, parseAddOptions, parseInitOptions, parseUpdateOptions, parseUpgradeOptions, readFrameUrl, readLibrary, readTemplatePlugins, removeFrameUrl, resolveTemplate, runCli, templateDir, templatesRoot, tokenOfFrameUrl, update, upgrade, writeFrameUrl };
4595
+ export { FRAME_URL_FILE, HELP, TEMPLATES, TEMPLATE_ALIASES, TEMPLATE_SUMMARY, TargetNotEmptyError, UsageError, VERSION, add, assertTargetFree, closure, copyPlugin, copyTemplate, findDesktopShell, frameHome, frameUrlPath, init, isFramedByPackages, isOmitted, isTemplate, isValidName, libraryRoot, listPlugins, lookUpFrameUrl, mergeDependencies, mergeTooling, nameFrom, openFrame, parseAddOptions, parseInitOptions, parseUpdateOptions, parseUpgradeOptions, readFrameUrl, readLibrary, readTemplatePlugins, removeFrameUrl, resolveTemplate, runCli, templateDir, templatesRoot, tokenOfFrameUrl, update, upgrade, writeFrameUrl };
4534
4596
 
4535
4597
  //# sourceMappingURL=index.js.map