lua-cli 3.42.0-beta.1 → 3.42.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.
@@ -0,0 +1,94 @@
1
+ /**
2
+ * U34 (LUA-1008) — generate the machine-readable platform catalogue (`catalog.json`) for a lua-cli release,
3
+ * and optionally diff it against the previous release's catalogue.
4
+ *
5
+ * Run from the repo root after `pnpm run build:shared` (an unbuilt shared dist fails the run on purpose —
6
+ * otherwise every imported SDK type would read as `any`):
7
+ *
8
+ * node_modules/.bin/tsx packages/lua-cli/scripts/generate-catalog.ts \
9
+ * --out packages/lua-cli/temp/catalog/catalog.json \
10
+ * [--previous <previous catalog.json>] \
11
+ * [--diff-out packages/lua-cli/temp/catalog/catalog-diff.json] \
12
+ * [--summary <markdown file to append the diff to, e.g. $GITHUB_STEP_SUMMARY>]
13
+ *
14
+ * `--previous` pointing at a missing file is not an error: the diff then lists everything as added.
15
+ * The logic lives in `generate-catalog.lib.ts` (fixture-tested); this file only wires argv and files.
16
+ */
17
+ import fs from 'fs';
18
+ import path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+ import { WAVE2_FLAGS, WAVE2_REUSED_FLAGS } from '@lua/shared-types';
21
+ import type { PlatformCatalog } from '@lua/shared-types';
22
+ import {
23
+ CatalogError,
24
+ diffCatalogs,
25
+ generateCatalog,
26
+ renderDiffMarkdown,
27
+ serializeCatalog,
28
+ type CatalogStatusManifest,
29
+ } from './generate-catalog.lib.js';
30
+
31
+ function parseArgs(argv: string[]): Record<string, string> {
32
+ const out: Record<string, string> = {};
33
+ for (let i = 0; i < argv.length; i++) {
34
+ const arg = argv[i];
35
+ if (!arg.startsWith('--')) throw new CatalogError(`unexpected argument '${arg}'`);
36
+ const value = argv[i + 1];
37
+ if (value === undefined || value.startsWith('--')) throw new CatalogError(`${arg} needs a value`);
38
+ out[arg.slice(2)] = value;
39
+ i++;
40
+ }
41
+ return out;
42
+ }
43
+
44
+ function writeFile(file: string, content: string): void {
45
+ fs.mkdirSync(path.dirname(path.resolve(file)), { recursive: true });
46
+ fs.writeFileSync(file, content);
47
+ }
48
+
49
+ function main(): void {
50
+ const args = parseArgs(process.argv.slice(2));
51
+ const packageDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
52
+ const pkg = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { version: string };
53
+ const manifest = JSON.parse(
54
+ fs.readFileSync(path.join(packageDir, 'catalog-status.json'), 'utf8')
55
+ ) as CatalogStatusManifest;
56
+
57
+ const { catalog, warnings } = generateCatalog({
58
+ packageDir,
59
+ manifest,
60
+ knownFlags: [...Object.keys(WAVE2_FLAGS), ...WAVE2_REUSED_FLAGS],
61
+ cliVersion: pkg.version,
62
+ now: new Date(),
63
+ });
64
+ for (const w of warnings) console.warn(`warning: ${w}`);
65
+
66
+ const out = args.out ?? path.join(packageDir, 'temp', 'catalog', 'catalog.json');
67
+ writeFile(out, serializeCatalog(catalog));
68
+ console.log(
69
+ `catalog.json v${catalog.cliVersion}: ${catalog.sdk.length} SDK exports, ${catalog.commands.length} commands, ` +
70
+ `${catalog.primitives.length} primitives, ${catalog.limits.length} limits, ${catalog.features.length} features → ${out}`
71
+ );
72
+
73
+ if (args.previous !== undefined || args['diff-out'] !== undefined || args.summary !== undefined) {
74
+ const previous =
75
+ args.previous && fs.existsSync(args.previous)
76
+ ? (JSON.parse(fs.readFileSync(args.previous, 'utf8')) as PlatformCatalog)
77
+ : null;
78
+ if (!previous) console.log('no previous catalogue: every entry counts as added');
79
+ const diff = diffCatalogs(previous, catalog);
80
+ if (args['diff-out']) writeFile(args['diff-out'], serializeCatalog(diff));
81
+ const markdown = renderDiffMarkdown(diff);
82
+ if (args.summary) fs.appendFileSync(args.summary, markdown);
83
+ console.log(
84
+ `diff vs ${diff.fromVersion || '(none)'}: +${diff.added.length} -${diff.removed.length} ~${diff.changed.length}`
85
+ );
86
+ }
87
+ }
88
+
89
+ try {
90
+ main();
91
+ } catch (err) {
92
+ console.error(err instanceof CatalogError ? `generate-catalog: ${err.message}` : err);
93
+ process.exit(1);
94
+ }
@@ -20,7 +20,7 @@
20
20
  "inquirer": "^12.9.6",
21
21
  "stripe": "^17.5.0",
22
22
  "js-yaml": "^4.1.0",
23
- "lua-cli": "^3.42.0-beta.1",
23
+ "lua-cli": "^3.42.0-beta.3",
24
24
  "openai": "^5.23.0",
25
25
  "uuid": "^13.0.0",
26
26
  "zod": "^3.24.1"
@@ -244,10 +244,20 @@ class LuaAppClient {
244
244
  /**
245
245
  * One post per allowed shell origin: the browser delivers it only when the
246
246
  * framing window really has that origin, so no other page ever receives it.
247
+ * A browser refuses some shell origins as a target outright (a web browser
248
+ * throws on the desktop app's `tauri://localhost`), so each post stands
249
+ * alone: one origin this browser cannot address must not stop the others,
250
+ * or fail the session that posts `lua:ready` when it opens.
247
251
  */
248
252
  private post(message: { type: string; v: number }): void {
249
253
  if (window.parent === window) return;
250
- for (const origin of this.hostOrigins()) window.parent.postMessage(message, origin);
254
+ for (const origin of this.hostOrigins()) {
255
+ try {
256
+ window.parent.postMessage(message, origin);
257
+ } catch {
258
+ // Not addressable from this browser; the shell that framed us has one of the others.
259
+ }
260
+ }
251
261
  }
252
262
  }
253
263