@nwire/cli 0.10.1 → 0.11.0

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.
@@ -31,12 +31,12 @@ async function main() {
31
31
  // "App" means either:
32
32
  // - `AppDefinition` (legacy `defineApp(name, { modules })`)
33
33
  // - bootable `App` (modern `createApp({ modules })`)
34
- // Resolve the app(s). 0.10 createApp returns an App marked with
35
- // `$nwireApp: true`. Recognized export names:
34
+ // `createApp` returns an App marked with `$nwireApp: true`.
35
+ // Recognized export names:
36
36
  // - allApps: App[] | apps: App[]
37
37
  // - default: App | App[]
38
38
  // - app: App
39
- // - buildApp(): App | Promise<App> ← 0.10 factory pattern
39
+ // - buildApp(): App | Promise<App> ← factory pattern
40
40
  // - bootstrap(): { app: App, ... } ← test-bootstrap pattern
41
41
  // - bootstrap(opts): { app: App, ... }
42
42
  //
@@ -143,8 +143,9 @@ async function main() {
143
143
  const outDir = resolve(cwd, config.cacheDir ?? ".nwire");
144
144
  await writeCache(cache, outDir);
145
145
  // eslint-disable-next-line no-console
146
- console.log(`nwire cache: wrote ${cache.apps.length} apps, ${cache.modules.length} modules, ` +
146
+ console.log(`nwire cache: wrote ${cache.apps.length} apps, ${cache.plugins.length} plugins, ` +
147
147
  `${cache.actions.length} actions, ${cache.events.length} events, ` +
148
+ `${cache.hooks.length} hooks, ${cache.sinks.length} sinks, ` +
148
149
  `${cache.resolvers.length} resolvers to ${outDir}/`);
149
150
  // Some bootstrap functions leave foreign-framework servers (Nest,
150
151
  // Fastify) listening even after we tear down the Nwire side. Force
@@ -179,21 +180,22 @@ function findAppInResult(result) {
179
180
  */
180
181
  function toAppDefinitionShape(x) {
181
182
  const a = x;
183
+ const name = a.appName ?? a.name ?? "app";
182
184
  return {
183
- name: a.name ?? a.appName ?? "app",
185
+ // Forward both fields — the scanner reads `appName`; legacy
186
+ // consumers may still read `name`.
187
+ name,
188
+ appName: name,
184
189
  description: a.description,
185
- modules: a.modules ?? [],
186
190
  plugins: a.plugins ?? [],
187
- // Forward operator commands defensively. Apps registered via
188
- // `defineApp` won't carry this; consumers who attach a
189
- // `commands: defineCommand[]` to their AppDefinition flow it through to
190
- // the scan emitter so `.nwire/commands.json` reflects ops surface.
191
+ // Forward operator commands defensively. Consumers who attach a
192
+ // `commands: defineCommand[]` to their app flow it through to the
193
+ // scan emitter so `.nwire/commands.json` reflects ops surface.
191
194
  commands: a.commands ?? [],
192
195
  tenantModel: a.tenantModel,
193
196
  tenantKey: a.tenantKey,
194
- // Forward the container so the scanner can walk `container.list()` and
195
- // emit `.nwire/di.json`. `defineApp` shape may carry it on `.runtime`;
196
- // `createApp` exposes it directly.
197
+ // Forward the container so the scanner can walk `container.list()`,
198
+ // resolve the forge dispatcher, and emit DI bindings.
197
199
  container: a.container ?? a.runtime?.container,
198
200
  runtime: a.runtime,
199
201
  };
@@ -1,6 +1,23 @@
1
1
  /**
2
- * `nwire cache` — rebuild `.nwire/` (manifest + per-kind JSON files).
3
- * Equivalent to `ensureScanFresh({ force: true })`: skips the
4
- * fingerprint cheap-path and always re-runs the cache builder.
2
+ * `nwire cache` — refresh `.nwire/` cache.
3
+ *
4
+ * nwire cache # rebuild unconditionally (force)
5
+ * nwire cache --if-stale # only rebuild when the source fingerprint moved
6
+ *
7
+ * `--if-stale` is the cheap path Studio's middleware uses on every
8
+ * manifest request: when nothing changed, the fingerprint check skips
9
+ * the rebuild in a few ms; when it did, the cache catches up before
10
+ * Studio renders a single page.
5
11
  */
6
- export declare const cacheCommand: import("citty").CommandDef<import("citty").ArgsDef>;
12
+ export declare const cacheCommand: import("citty").CommandDef<{
13
+ "if-stale": {
14
+ type: "boolean";
15
+ description: string;
16
+ default: false;
17
+ };
18
+ quiet: {
19
+ type: "boolean";
20
+ description: string;
21
+ default: false;
22
+ };
23
+ }>;
@@ -1,7 +1,13 @@
1
1
  /**
2
- * `nwire cache` — rebuild `.nwire/` (manifest + per-kind JSON files).
3
- * Equivalent to `ensureScanFresh({ force: true })`: skips the
4
- * fingerprint cheap-path and always re-runs the cache builder.
2
+ * `nwire cache` — refresh `.nwire/` cache.
3
+ *
4
+ * nwire cache # rebuild unconditionally (force)
5
+ * nwire cache --if-stale # only rebuild when the source fingerprint moved
6
+ *
7
+ * `--if-stale` is the cheap path Studio's middleware uses on every
8
+ * manifest request: when nothing changed, the fingerprint check skips
9
+ * the rebuild in a few ms; when it did, the cache catches up before
10
+ * Studio renders a single page.
5
11
  */
6
12
  import { defineCommand } from "citty";
7
13
  import { ensureScanFresh } from "../lib/ensure-scan.js";
@@ -10,8 +16,24 @@ export const cacheCommand = defineCommand({
10
16
  name: "cache",
11
17
  description: "Rebuild .nwire/ cache (manifest + per-kind JSON)",
12
18
  },
13
- async run() {
14
- const { rebuilt } = ensureScanFresh(process.cwd(), { force: true });
15
- process.exit(rebuilt ? 0 : 1);
19
+ args: {
20
+ "if-stale": {
21
+ type: "boolean",
22
+ description: "Only rebuild when the source fingerprint moved.",
23
+ default: false,
24
+ },
25
+ quiet: {
26
+ type: "boolean",
27
+ description: "Suppress 'scanning project…' progress output.",
28
+ default: false,
29
+ },
30
+ },
31
+ async run({ args }) {
32
+ const force = !args["if-stale"];
33
+ const result = ensureScanFresh(process.cwd(), { force, quiet: args.quiet });
34
+ // exit 0 when the cache is current — whether we just rebuilt it or
35
+ // the cheap-path skipped. exit 1 only when we tried to rebuild and
36
+ // the builder failed.
37
+ process.exit(result.rebuilt || !force ? 0 : 1);
16
38
  },
17
39
  });
@@ -31,8 +31,7 @@ export const studioCommand = defineCommand({
31
31
  }
32
32
  };
33
33
  studioDir =
34
- tryResolveFrom(resolve(process.cwd(), "package.json")) ??
35
- tryResolveFrom(import.meta.url);
34
+ tryResolveFrom(resolve(process.cwd(), "package.json")) ?? tryResolveFrom(import.meta.url);
36
35
  if (!studioDir) {
37
36
  // eslint-disable-next-line no-console
38
37
  console.error(palette.err("nwire studio:") +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwire/cli",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Nwire CLI — branded TUI. Dev, run, please, build, test, fmt, lint, check, ps, logs, cache, ls, studio. One surface for the whole framework.",
5
5
  "keywords": [
6
6
  "cli",
@@ -36,9 +36,9 @@
36
36
  "listr2": "^9.0.4",
37
37
  "picocolors": "^1.1.1",
38
38
  "react": "^18.3.1",
39
- "@nwire/mcp": "0.10.1",
40
- "@nwire/scan": "0.10.1",
41
- "@nwire/hooks": "0.10.1"
39
+ "@nwire/hooks": "0.11.0",
40
+ "@nwire/scan": "0.11.0",
41
+ "@nwire/mcp": "0.11.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^22.19.9",