@timekast/factory 1.7.0 → 1.7.1

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.
@@ -94,3 +94,49 @@ export const FACTORY_SCRIPTS = {
94
94
  export const PREFLIGHT_SCRIPT_NAME = 'preflight';
95
95
  export const PREFLIGHT_SCRIPT_CMD = 'tsx scripts/tools/preflight.ts';
96
96
  export const PREFLIGHT_SCRIPT_FILE = 'scripts/tools/preflight.ts';
97
+ /**
98
+ * Kit-local reference generators — autogen of `project/reference/*` (INVENTORY,
99
+ * CODEBASE, HOOKS, SCHEMA, API). Each shells a `scripts/tools/generate-*.mjs`
100
+ * that ships with the FULL brain, so the installer ensures each alias ONLY when
101
+ * its backing file exists (file-gated, insert-if-missing — same contract as
102
+ * `preflight`). A derivative bootstrapped before a generator existed self-heals
103
+ * the alias on the next `update`/`beta` (the script file arrives via `scripts/**`
104
+ * in the tracked set, then the alias appears). Never overwrites a dev's own value.
105
+ */
106
+ export const GENERATOR_SCRIPTS = [
107
+ {
108
+ name: 'generate:inventory',
109
+ cmd: 'node scripts/tools/generate-inventory.mjs',
110
+ file: 'scripts/tools/generate-inventory.mjs',
111
+ },
112
+ {
113
+ name: 'generate:codebase',
114
+ cmd: 'node scripts/tools/generate-codebase.mjs',
115
+ file: 'scripts/tools/generate-codebase.mjs',
116
+ },
117
+ {
118
+ name: 'generate:hooks',
119
+ cmd: 'node scripts/tools/generate-hooks.mjs',
120
+ file: 'scripts/tools/generate-hooks.mjs',
121
+ },
122
+ {
123
+ name: 'generate:schema',
124
+ cmd: 'node scripts/tools/generate-schema.mjs',
125
+ file: 'scripts/tools/generate-schema.mjs',
126
+ },
127
+ {
128
+ name: 'generate:api',
129
+ cmd: 'node scripts/tools/generate-api.mjs',
130
+ file: 'scripts/tools/generate-api.mjs',
131
+ },
132
+ ];
133
+ /**
134
+ * Aggregate that runs every shipped reference generator in one shot (the
135
+ * one-command "regenerate everything" alias). Shells the files directly (not
136
+ * `pnpm generate:*`) so it works even if the individual aliases were not added.
137
+ * Gated on the schema generator's presence — a proxy for "the current full
138
+ * generator set shipped" (they ship together in the FULL brain).
139
+ */
140
+ export const GENERATE_REFERENCE_NAME = 'generate:reference';
141
+ export const GENERATE_REFERENCE_CMD = 'node scripts/tools/generate-inventory.mjs && node scripts/tools/generate-codebase.mjs && node scripts/tools/generate-hooks.mjs && node scripts/tools/generate-schema.mjs && node scripts/tools/generate-api.mjs';
142
+ export const GENERATE_REFERENCE_GATE_FILE = 'scripts/tools/generate-schema.mjs';
@@ -8,7 +8,7 @@
8
8
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
9
9
  import path from 'node:path';
10
10
  import { CLIError } from './cli-error.js';
11
- import { FACTORY_SCRIPTS, PREFLIGHT_SCRIPT_CMD, PREFLIGHT_SCRIPT_FILE, PREFLIGHT_SCRIPT_NAME, PROFILES, UPDATE_SCRIPT_NAME, } from './constants.js';
11
+ import { FACTORY_SCRIPTS, GENERATE_REFERENCE_CMD, GENERATE_REFERENCE_GATE_FILE, GENERATE_REFERENCE_NAME, GENERATOR_SCRIPTS, PREFLIGHT_SCRIPT_CMD, PREFLIGHT_SCRIPT_FILE, PREFLIGHT_SCRIPT_NAME, PROFILES, UPDATE_SCRIPT_NAME, } from './constants.js';
12
12
  /**
13
13
  * Auto-detect the profile to install into an existing repo from its
14
14
  * `package.json`: a `factoryVersion` field means the repo was born from the
@@ -91,15 +91,33 @@ function ensureFactoryScripts(pkg, extraScripts = {}) {
91
91
  return { changed, primary };
92
92
  }
93
93
  /**
94
- * The kit-local scripts to ensure for THIS repo: `preflight` only when its
95
- * backing file ships here (full brain). File-gated so a core/non-Factory repo
96
- * never gets an entry that shells a file it does not have — and it self-heals:
97
- * the entry appears on the first install/update after the file lands.
94
+ * The kit-local scripts to ensure for THIS repo, each file-gated so a
95
+ * core/non-Factory repo never gets an entry that shells a file it lacks — and
96
+ * each self-heals: the entry appears on the first install/update after its
97
+ * backing file lands.
98
+ *
99
+ * - `preflight` — when its sweep script ships (full brain).
100
+ * - `generate:*` — one alias per reference generator whose `scripts/tools/
101
+ * generate-*.mjs` ships (full brain). These arrive via the `scripts/**`
102
+ * tracked set on `update`/`beta`, so an existing derivative self-heals the
103
+ * aliases without the dev hand-editing `package.json`.
104
+ * - `generate:reference` — the aggregate that runs the whole set in one command.
105
+ *
106
+ * Insert-if-missing for all: a dev's own value for any of these is never
107
+ * overwritten (see `ensureFactoryScripts`).
98
108
  */
99
109
  export function kitLocalScripts(rootDir) {
100
- return existsSync(path.join(rootDir, PREFLIGHT_SCRIPT_FILE))
101
- ? { [PREFLIGHT_SCRIPT_NAME]: PREFLIGHT_SCRIPT_CMD }
102
- : {};
110
+ const has = (relPath) => existsSync(path.join(rootDir, relPath));
111
+ const scripts = {};
112
+ if (has(PREFLIGHT_SCRIPT_FILE))
113
+ scripts[PREFLIGHT_SCRIPT_NAME] = PREFLIGHT_SCRIPT_CMD;
114
+ for (const gen of GENERATOR_SCRIPTS) {
115
+ if (has(gen.file))
116
+ scripts[gen.name] = gen.cmd;
117
+ }
118
+ if (has(GENERATE_REFERENCE_GATE_FILE))
119
+ scripts[GENERATE_REFERENCE_NAME] = GENERATE_REFERENCE_CMD;
120
+ return scripts;
103
121
  }
104
122
  /**
105
123
  * Source dirs that never ship to a derivative — excluded from BOTH dist profiles
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timekast/factory",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Public, thin CLI to bootstrap and maintain TimeKast Factory derived projects.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",