@timekast/factory 1.7.0 → 1.8.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.
- package/dist/commands/new.js +19 -3
- package/dist/index.js +6 -2
- package/dist/lib/constants.js +46 -0
- package/dist/lib/package-json.js +26 -8
- package/package.json +1 -1
package/dist/commands/new.js
CHANGED
|
@@ -52,9 +52,20 @@ async function createRepo(name) {
|
|
|
52
52
|
throw new CLIError(`No se pudo crear el repo \`${FACTORY_ORG}/${name}\` en GitHub.${detail}`);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Parse `new`'s argv slice into flags. Lets a GUI launcher / headless caller run
|
|
57
|
+
* non-interactively (`new <Name> --full`); without a flag, `new` still prompts.
|
|
58
|
+
*/
|
|
59
|
+
export function parseNewFlags(argv) {
|
|
60
|
+
return { core: argv.includes('--core'), full: argv.includes('--full') };
|
|
61
|
+
}
|
|
62
|
+
export async function runNew(name, flags = { core: false, full: false }) {
|
|
56
63
|
// 1. Validate offline, before any network call.
|
|
57
64
|
const validName = validateProjectName(name);
|
|
65
|
+
// Reject contradictory profile flags before any network call (mirrors `add`).
|
|
66
|
+
if (flags.core && flags.full) {
|
|
67
|
+
throw new CLIError('No puedes combinar `--core` con `--full`.');
|
|
68
|
+
}
|
|
58
69
|
// 2. Refuse to run inside an existing repo (before any destructive action).
|
|
59
70
|
const cwd = process.cwd();
|
|
60
71
|
if (existsSync(path.join(cwd, '.git'))) {
|
|
@@ -68,8 +79,13 @@ export async function runNew(name) {
|
|
|
68
79
|
}
|
|
69
80
|
// 4. Preflight: gh installed + authed + org member.
|
|
70
81
|
await runPreflight();
|
|
71
|
-
// 5. Choose profile.
|
|
72
|
-
|
|
82
|
+
// 5. Choose profile. A `--full`/`--core` flag skips the prompt (lets a GUI or
|
|
83
|
+
// headless caller run non-interactively); absent → interactive select.
|
|
84
|
+
const profile = flags.full
|
|
85
|
+
? PROFILES.full
|
|
86
|
+
: flags.core
|
|
87
|
+
? PROFILES.core
|
|
88
|
+
: await promptProfile();
|
|
73
89
|
// 6. Network: create the repo.
|
|
74
90
|
await createRepo(validName);
|
|
75
91
|
// 7. Download + unpack into a temp dir, validate, then move into place (M2).
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
12
12
|
import { CLIError } from './lib/cli-error.js';
|
|
13
13
|
import { parseAddFlags, runAdd } from './commands/add.js';
|
|
14
14
|
import { runDoctor } from './commands/doctor.js';
|
|
15
|
-
import { runNew } from './commands/new.js';
|
|
15
|
+
import { parseNewFlags, runNew } from './commands/new.js';
|
|
16
16
|
import { parsePublishArgs, runPublish } from './commands/publish.js';
|
|
17
17
|
import { runStatus } from './commands/status.js';
|
|
18
18
|
import { parseUnpublishTargets, runUnpublish } from './commands/unpublish.js';
|
|
@@ -33,6 +33,10 @@ Comandos:
|
|
|
33
33
|
publish <qué> Publica el entregable (proposal|mockup|both) a proposals.timekast.mx
|
|
34
34
|
unpublish [qué] Baja del hub un entregable publicado (proposal|mockup|both; default both)
|
|
35
35
|
|
|
36
|
+
Sobre \`new\`:
|
|
37
|
+
Pregunta el perfil de forma interactiva. Los flags \`--full\` / \`--core\` lo
|
|
38
|
+
fijan sin preguntar (útil para un lanzador GUI o uso headless).
|
|
39
|
+
|
|
36
40
|
Sobre \`add\`:
|
|
37
41
|
Requiere estar dentro de un repo git (al menos \`git init\`). Por default instala
|
|
38
42
|
el cerebro \`full\` (incluye sk-* + SK.md) si el repo es un derivado del Factory
|
|
@@ -97,7 +101,7 @@ async function main(argv) {
|
|
|
97
101
|
if (!name) {
|
|
98
102
|
throw new CLIError('Falta el nombre del proyecto. Uso: `factory new <Nombre>`.');
|
|
99
103
|
}
|
|
100
|
-
await runNew(name);
|
|
104
|
+
await runNew(name, parseNewFlags(rest));
|
|
101
105
|
return;
|
|
102
106
|
}
|
|
103
107
|
case 'add': {
|
package/dist/lib/constants.js
CHANGED
|
@@ -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';
|
package/dist/lib/package-json.js
CHANGED
|
@@ -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
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
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
|
-
|
|
101
|
-
|
|
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
|