@timekast/factory 0.1.8 → 0.1.9

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.
@@ -9,10 +9,15 @@
9
9
  * Invariants:
10
10
  * - `add` ONLY ever installs `core`. The profile is the literal `PROFILES.core`,
11
11
  * never a flag — `full` is structurally unreachable from this command.
12
- * - `add` never touches `src/`, `package.json`, `pj-*`, or any file outside the
13
- * `core` manifest. The `core` tarball contains only `core` files, so moving
14
- * its contents in cannot reach dev-owned paths; files in the cwd that are not
15
- * in the tarball are left byte-identical.
12
+ * - `add` never touches `src/`, `pj-*`, or any file outside the `core` manifest.
13
+ * The `core` tarball contains only `core` files, so moving its contents in
14
+ * cannot reach dev-owned paths; cwd files not in the tarball stay byte-identical.
15
+ * ONE surgical exception (H5): if the repo is a Node project — a `package.json`
16
+ * sits next to the installed `.claude/` — `add` inserts the `factory:update`
17
+ * script (a single key, never overwriting a divergent value) so the dev gets
18
+ * `pnpm factory:update`, matching the `full` profile. A non-Node repo
19
+ * (Python/Flutter/Go) gets NO `package.json` created — it updates via
20
+ * `npx @timekast/factory update` (or a global install of the CLI).
16
21
  * - `add` overwrites manifest files without prompting — the conflict prompt is
17
22
  * exclusive to `update` (DIST-005). Documented in the command's `--help`.
18
23
  * - Atomicity (§7.5): extract + validate in a temp dir before touching the cwd;
@@ -20,12 +25,13 @@
20
25
  *
21
26
  * Expected failures throw `CLIError`; the top-level handler prints + exits.
22
27
  */
23
- import { mkdtempSync, rmSync } from 'node:fs';
28
+ import { existsSync, mkdtempSync, rmSync } from 'node:fs';
24
29
  import { tmpdir } from 'node:os';
25
30
  import path from 'node:path';
26
31
  import { CLIError } from '../lib/cli-error.js';
27
32
  import { PROFILES } from '../lib/constants.js';
28
33
  import { writeInitialLockfile } from '../lib/lockfile.js';
34
+ import { insertFactoryUpdateScript } from '../lib/package-json.js';
29
35
  import { runPreflight } from '../lib/preflight.js';
30
36
  import { detectRepo } from '../lib/repo-detection.js';
31
37
  import { downloadProfileTarball, moveContentsInto, stageProfileTarball } from '../lib/unpack.js';
@@ -74,5 +80,29 @@ export async function runAdd() {
74
80
  process.removeListener('SIGTERM', onSignal);
75
81
  cleanup();
76
82
  }
83
+ // H5: if the repo is a Node project, add the `pnpm factory:update` convenience by
84
+ // surgically inserting the script into the EXISTING package.json. Non-fatal — a
85
+ // missing/invalid package.json just means the dev uses `npx` (the brain is already
86
+ // installed). We NEVER create a package.json in a non-Node repo.
87
+ const pkgPath = path.join(cwd, 'package.json');
88
+ let scriptAction = 'none';
89
+ if (existsSync(pkgPath)) {
90
+ try {
91
+ scriptAction = insertFactoryUpdateScript(pkgPath).action;
92
+ }
93
+ catch {
94
+ scriptAction = 'none'; // invalid package.json — skip the alias, brain still installed
95
+ }
96
+ }
77
97
  console.log('\n✔ Cerebro `core` instalado. Lockfile escrito en `.timekast/lockfile.json`.');
98
+ if (scriptAction === 'added' || scriptAction === 'already-correct') {
99
+ console.log('Para actualizar: `pnpm factory:update` (alias de `npx @timekast/factory update`).');
100
+ }
101
+ else {
102
+ if (scriptAction === 'conflict') {
103
+ console.warn('Aviso: `factory:update` ya existe en package.json con otro valor; no se sobrescribió.');
104
+ }
105
+ console.log('Para actualizar: `npx @timekast/factory update` desde la raíz del repo,');
106
+ console.log('o instala el CLI una vez (`npm i -g @timekast/factory`) y corre `factory update`.');
107
+ }
78
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timekast/factory",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Public, thin CLI to bootstrap and maintain TimeKast Factory derived projects.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",