projectops 4.104.6 → 4.104.8
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/README.md +1 -1
- package/bin/projectops.js +4 -4
- package/package.json +1 -1
- package/src/cli/args.js +43 -43
- package/src/cli/errors.js +8 -8
- package/src/cli/help.js +4 -4
- package/src/commands/doctor.js +39 -39
- package/src/commands/full.js +29 -29
- package/src/commands/interactive.js +86 -86
- package/src/commands/issues.js +5 -5
- package/src/commands/skills.js +13 -13
- package/src/commands/version.js +8 -8
- package/src/commands/workflows.js +23 -22
- package/src/context.js +24 -24
- package/src/core/agent-guide.js +5 -5
- package/src/core/assets.js +11 -11
- package/src/core/baseline.js +24 -24
- package/src/core/branch-sub.js +23 -23
- package/src/core/breaking-check.js +21 -21
- package/src/core/breaking.js +6 -6
- package/src/core/ci-minutes-sub.js +13 -13
- package/src/core/constants.js +17 -17
- package/src/core/copy/coderabbit.js +10 -10
- package/src/core/copy/gitignore.js +9 -9
- package/src/core/copy/readme.js +7 -7
- package/src/core/copy/simple.js +35 -35
- package/src/core/copy/util.js +9 -9
- package/src/core/copy/workflows.js +99 -99
- package/src/core/detect-fs.js +21 -21
- package/src/core/detect.js +12 -12
- package/src/core/development-branch.js +11 -11
- package/src/core/exclusions.js +12 -12
- package/src/core/fsutil.js +9 -9
- package/src/core/git-branch.js +11 -11
- package/src/core/ide/adapter.js +23 -23
- package/src/core/ide/adapters/claude.js +12 -12
- package/src/core/ide/adapters/codex.js +4 -4
- package/src/core/ide/adapters/copilot.js +12 -12
- package/src/core/ide/adapters/cursor.js +7 -7
- package/src/core/ide/adapters/gemini.js +5 -5
- package/src/core/ide/adapters/pi-common.js +12 -12
- package/src/core/ide/adapters/pi-harness.js +7 -7
- package/src/core/ide/adapters/pi.js +3 -3
- package/src/core/ide/home-skills.js +6 -6
- package/src/core/ide/legacy.js +8 -8
- package/src/core/ide/registry.js +6 -6
- package/src/core/ide/runner.js +15 -15
- package/src/core/ide/skills-copy.js +34 -34
- package/src/core/ide/stable-entry.js +11 -11
- package/src/core/ide/util.js +4 -4
- package/src/core/incoming.js +13 -13
- package/src/core/label-style.js +12 -12
- package/src/core/migration-guide.js +19 -19
- package/src/core/migrations/index.js +16 -16
- package/src/core/migrations/registry.js +39 -39
- package/src/core/migrations/rules/legacy-dirs.js +6 -6
- package/src/core/migrations/rules/obsolete-workflows.js +4 -4
- package/src/core/migrations/rules/root-files.js +3 -3
- package/src/core/migrations/rules/settings-extractors.js +8 -8
- package/src/core/options-ask.js +104 -104
- package/src/core/options-schema.js +23 -23
- package/src/core/orphan-workflows.js +14 -14
- package/src/core/paths-resolve.js +54 -54
- package/src/core/paths.js +2 -2
- package/src/core/placeholder-triggers.js +10 -10
- package/src/core/repo-language.js +10 -10
- package/src/core/resolve-options.js +30 -30
- package/src/core/run-trace.js +54 -54
- package/src/core/store-locales-hint.js +13 -13
- package/src/core/verify.js +27 -27
- package/src/core/version-yml.js +117 -116
- package/src/core/wizard-env.js +42 -42
- package/src/core/wizard-labels.js +31 -31
- package/src/core/workflow-groups.js +14 -14
- package/src/i18n/core.en.js +1 -1
- package/src/i18n/doctor.en.js +1 -1
- package/src/i18n/ide.en.js +1 -1
- package/src/i18n/migrate.en.js +1 -1
- package/src/i18n/options.en.js +1 -1
- package/src/index.js +60 -60
- package/src/ui/ansi.js +5 -5
- package/src/ui/env-plan.js +44 -44
- package/src/ui/prompts.js +21 -21
- package/src/ui/readline-engine.js +38 -38
- package/src/ui/skills-prompts.js +4 -4
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// projectops CLI
|
|
2
|
-
//
|
|
1
|
+
// projectops CLI entry pipeline (args > detect > per-mode integration > summary).
|
|
2
|
+
// Detect → download → route by mode → run integration → clean up. Non-interactive (--force) first.
|
|
3
3
|
import { join, dirname } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { readFileSync, existsSync } from "node:fs";
|
|
@@ -32,7 +32,7 @@ import { runIssues } from "./commands/issues.js";
|
|
|
32
32
|
import { runInteractive } from "./commands/interactive.js";
|
|
33
33
|
import { runSkills } from "./commands/skills.js";
|
|
34
34
|
|
|
35
|
-
// projectops
|
|
35
|
+
// Read the projectops package version (for -v/--version output). src/../package.json.
|
|
36
36
|
function readPkgVersion() {
|
|
37
37
|
try {
|
|
38
38
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
@@ -43,7 +43,7 @@ function readPkgVersion() {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// Deterministic UTC timestamp (injectable — for tests/goldens)
|
|
47
47
|
function utcNow(date = new Date()) {
|
|
48
48
|
const p = (n) => String(n).padStart(2, "0");
|
|
49
49
|
const d = `${date.getUTCFullYear()}-${p(date.getUTCMonth() + 1)}-${p(date.getUTCDate())}`;
|
|
@@ -52,14 +52,14 @@ function utcNow(date = new Date()) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// run(argv, opts) → exitCode. opts: { cwd, source?, clock? }
|
|
55
|
-
// source: acquireTemplate
|
|
56
|
-
// clock: {now, today}
|
|
55
|
+
// source: for acquireTemplate (default git clone). Tests inject {type:'local', path}.
|
|
56
|
+
// clock: inject {now, today} (default current UTC).
|
|
57
57
|
export async function run(argv, options = {}) {
|
|
58
58
|
try {
|
|
59
59
|
return await runCore(argv, options);
|
|
60
60
|
} catch (err) {
|
|
61
|
-
//
|
|
62
|
-
//
|
|
61
|
+
// Environment problems like network, git or permissions are reported as a one-line cause + action instead of a stack trace (#672).
|
|
62
|
+
// The run trace was already closed in runCore's finally.
|
|
63
63
|
reportFatal(err);
|
|
64
64
|
return 1;
|
|
65
65
|
}
|
|
@@ -80,7 +80,7 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
80
80
|
if (opts.showVersion) { console.log(readPkgVersion()); return 0; }
|
|
81
81
|
if (opts.help) { console.log(helpText()); return 0; }
|
|
82
82
|
|
|
83
|
-
// options
|
|
83
|
+
// options mode — prints the option source of truth. AI agents read it in one go without digging through docs. Read-only, no network.
|
|
84
84
|
if (opts.mode === "options") {
|
|
85
85
|
const { buildSchema, renderText } = await import("./core/options-schema.js");
|
|
86
86
|
const schema = buildSchema(readPkgVersion());
|
|
@@ -88,20 +88,20 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
88
88
|
return 0;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// doctor
|
|
91
|
+
// doctor mode (#558) — read-only diagnosis. Does not download the template, so it works without a network.
|
|
92
92
|
if (opts.mode === "doctor") {
|
|
93
93
|
const { runDoctor } = await import("./commands/doctor.js");
|
|
94
94
|
await runDoctor({ cwd });
|
|
95
|
-
return 0; //
|
|
95
|
+
return 0; // A diagnosis is not a failure — ends with 0 even when there are items to look at
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
// skills
|
|
99
|
-
//
|
|
98
|
+
// skills mode — install/update/remove IDE skills (no template integration).
|
|
99
|
+
// Needs the skills/ source for the Cursor copy, so it runs after fetching the template.
|
|
100
100
|
if (opts.mode === "skills") {
|
|
101
101
|
const tempDir = join(cwd, PATHS.tempDir);
|
|
102
102
|
const interactive = !opts.force && process.stdout.isTTY;
|
|
103
103
|
try {
|
|
104
|
-
// skills
|
|
104
|
+
// skills mode: skill CLIs import scripts/common > keep it out of the exclusions (#994)
|
|
105
105
|
acquireTemplate({ tempDir, source, keep: [SHARED_SCRIPTS_DIR_NAME] });
|
|
106
106
|
const templateVersion = readTemplateVersion(tempDir);
|
|
107
107
|
return await runSkills({ templateVersion, tempDir, interactive });
|
|
@@ -109,7 +109,7 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
109
109
|
remove(tempDir);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
//
|
|
112
|
+
// Interactive mode — run with no args or --mode interactive
|
|
113
113
|
if (opts.mode === "interactive") {
|
|
114
114
|
if (!process.stdout.isTTY) {
|
|
115
115
|
console.error(t("cli.nonTty"));
|
|
@@ -117,24 +117,24 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
117
117
|
}
|
|
118
118
|
return await runInteractive({}, { cwd, source, clock });
|
|
119
119
|
}
|
|
120
|
-
//
|
|
120
|
+
// Explicit mode without --force (the non-interactive CLI needs --force)
|
|
121
121
|
if (!opts.force && !process.stdout.isTTY) {
|
|
122
122
|
console.error(t("cli.needForce"));
|
|
123
123
|
return 1;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
//
|
|
126
|
+
// Run trace (#494/#561) — recording must start at the detect/decide steps so "why it was decided this way" is kept.
|
|
127
127
|
const trace = createRunTrace();
|
|
128
128
|
const recordArtifacts = opts.mode === "full" || opts.mode === "workflows";
|
|
129
129
|
let disarmSignals = () => {};
|
|
130
130
|
if (recordArtifacts) {
|
|
131
131
|
trace.mirrorStart();
|
|
132
|
-
// Ctrl+C
|
|
133
|
-
//
|
|
132
|
+
// Even when cut off with Ctrl+C, the record up to here stays (#561). The path is settled below, but
|
|
133
|
+
// a signal can come at any time, so arm with targetRoot alone first.
|
|
134
134
|
disarmSignals = trace.armSignals({ targetRoot: cwd, now: "" });
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
//
|
|
137
|
+
// Load the existing version.yml — single source of truth for keeping version/version_code/project_paths
|
|
138
138
|
const vyPath = join(cwd, "version.yml");
|
|
139
139
|
const existing = existsSync(vyPath) ? parseExisting(readFileSync(vyPath, "utf8")) : null;
|
|
140
140
|
trace.event("detect", "existing-install", existing ? "found" : "none", {
|
|
@@ -143,26 +143,26 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
143
143
|
types: existing?.types || null,
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
//
|
|
146
|
+
// Detection (CLI args first, else auto-detect — the version.yml-first rule lives inside detectTypes/detectVersion)
|
|
147
147
|
const types = opts.types.length ? opts.types : detectTypes(cwd);
|
|
148
148
|
trace.event("detect", "types", types.join(",") || "(none)", {
|
|
149
149
|
source: opts.types.length ? "cli-flag(--type)" : "auto-detect(marker file scan)",
|
|
150
150
|
});
|
|
151
|
-
// version:
|
|
151
|
+
// version: existing version.yml first (SSoT — prevents overwriting on re-run) → CLI value → file detection
|
|
152
152
|
const version = (existing?.version) || opts.version || detectVersion(cwd);
|
|
153
153
|
trace.event("detect", "version", version, {
|
|
154
154
|
source: existing?.version ? "version.yml(existing value kept)"
|
|
155
155
|
: (opts.version ? "cli-flag(--project-version)" : "project file detection"),
|
|
156
156
|
});
|
|
157
|
-
const versionCode = existing?.versionCode ?? 1; //
|
|
157
|
+
const versionCode = existing?.versionCode ?? 1; // Keep the existing build number
|
|
158
158
|
const branch = detectDefaultBranch(cwd);
|
|
159
159
|
const repoName = detectRepoName(cwd);
|
|
160
160
|
trace.event("detect", "repo", repoName || "(unknown)", { defaultBranch: branch, versionCode });
|
|
161
|
-
//
|
|
161
|
+
// Settle paths (non-interactive — --paths first → saved value → single candidate automatically → root fallback)
|
|
162
162
|
let cliPaths;
|
|
163
163
|
try {
|
|
164
164
|
cliPaths = parsePathsCsv(opts.pathsCsv);
|
|
165
|
-
validatePathsMap(cliPaths, { root: cwd, types }); // #674 —
|
|
165
|
+
validatePathsMap(cliPaths, { root: cwd, types }); // #674 — filter before writing any file
|
|
166
166
|
} catch (e) {
|
|
167
167
|
if (e instanceof CliError) {
|
|
168
168
|
console.error(e.message);
|
|
@@ -178,7 +178,7 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
for (const [ty, pth] of paths) {
|
|
181
|
-
//
|
|
181
|
+
// Record the basis too: "what was seen to choose that path" — the starting point for tracing a wrong path.
|
|
182
182
|
const marker = markerForType(ty);
|
|
183
183
|
const at = pth === "." ? marker : `${pth}/${marker}`;
|
|
184
184
|
trace.event("detect", "project-path", ty, {
|
|
@@ -192,7 +192,7 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
192
192
|
const { now, today } = clock || utcNow();
|
|
193
193
|
const tempDir = join(cwd, PATHS.tempDir);
|
|
194
194
|
|
|
195
|
-
//
|
|
195
|
+
// Option values are decided in one place, resolve-options.js (#851) — same rules as interactive.
|
|
196
196
|
const { values: resolved, sources } = resolveOptions({
|
|
197
197
|
flags: {
|
|
198
198
|
intent: opts.intent, deployTarget: opts.deployTarget, publishTargets: opts.publishTargets,
|
|
@@ -204,11 +204,11 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
204
204
|
});
|
|
205
205
|
const { intent, deployTarget, publishTargets } = resolved;
|
|
206
206
|
const { before: beforeCleanup, applicable } = sources;
|
|
207
|
-
//
|
|
207
|
+
// Multi-language store with store_locales unset: notice only (#843) — judged on the state before copying
|
|
208
208
|
const storeLocalesHint = detectStoreLocalesHint({ root: cwd, existing, paths, trace });
|
|
209
209
|
|
|
210
|
-
//
|
|
211
|
-
// CLI
|
|
210
|
+
// Basis for settling the axes (#561) — "why this value" is the most confusing spot.
|
|
211
|
+
// Records which won: CLI flag / saved value / intent derivation / type applicability cleanup.
|
|
212
212
|
trace.event("resolve", "intent", String(intent ?? "(unset)"), { source: sources.intent });
|
|
213
213
|
trace.event("resolve", "deploy", deployTarget, {
|
|
214
214
|
source: sources.deploy,
|
|
@@ -227,12 +227,12 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
227
227
|
mode: opts.mode, force: true, types, version, versionCode, branch, paths,
|
|
228
228
|
...resolved,
|
|
229
229
|
repoName,
|
|
230
|
-
//
|
|
230
|
+
// The 4 real resolvers (including spring-app-yml)
|
|
231
231
|
resolvers: makeResolvers(cwd, repoName, paths),
|
|
232
232
|
now, today,
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
//
|
|
235
|
+
// Snapshot of the final values (#561) — this one line pins down "what will be installed and how".
|
|
236
236
|
trace.event("resolve", "context", opts.mode || "", {
|
|
237
237
|
types, version, versionCode, branch,
|
|
238
238
|
deploy: deployTarget, publish: publishTargets, intent,
|
|
@@ -252,11 +252,11 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
let result = null;
|
|
255
|
-
// trace/recordArtifacts
|
|
255
|
+
// trace/recordArtifacts were already created above to record the detection steps (#561)
|
|
256
256
|
let breakingReport = null;
|
|
257
257
|
let migrationsResult = null;
|
|
258
258
|
let orphanPending = [];
|
|
259
|
-
//
|
|
259
|
+
// Run boundary (#561) — the log alone must show "what ran with which arguments".
|
|
260
260
|
trace.event("run", "start", opts.mode || "", {
|
|
261
261
|
cli: "non-interactive", types, version, branch,
|
|
262
262
|
force: true, deploy: deployTarget, publish: publishTargets, intent,
|
|
@@ -266,10 +266,10 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
266
266
|
context.templateVersion = readTemplateVersion(tempDir);
|
|
267
267
|
trace.event("detect", "template-version", context.templateVersion, { tempDir: PATHS.tempDir });
|
|
268
268
|
|
|
269
|
-
//
|
|
269
|
+
// Short non-interactive banner (settled in #446 — 1 line, minimal log noise)
|
|
270
270
|
printBannerCompact({ version: context.templateVersion, mode: opts.mode });
|
|
271
271
|
|
|
272
|
-
// Breaking
|
|
272
|
+
// Breaking changes gate (non-interactive warns and proceeds)
|
|
273
273
|
const proceed = await trace.stepAsync("breaking-check", () => runBreakingCheck({
|
|
274
274
|
cwd, tempDir, templateVersion: context.templateVersion,
|
|
275
275
|
onItems: (items) => { breakingReport = items; },
|
|
@@ -280,18 +280,18 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
280
280
|
return 0;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
//
|
|
283
|
+
// Legacy migration (#470) — only in modes that touch workflows. Non-interactive applies the safe tier automatically.
|
|
284
284
|
if (recordArtifacts) {
|
|
285
285
|
migrationsResult = await trace.stepAsync("legacy-migrations", () => runMigrations({ targetRoot: cwd, removeLegacy: opts.removeLegacy === true }));
|
|
286
286
|
for (const a of migrationsResult.applied ?? []) trace.event("legacy", a.action === "error" ? "error" : "neutralized", a.from ?? a.id ?? "", { to: a.to ?? "", id: a.id ?? "" });
|
|
287
287
|
for (const e of migrationsResult.confirmPending ?? []) trace.event("legacy", "leftover-old-gen", e.file, { replacement: e.replacedBy ?? "", reason: e.reason ?? "" });
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
//
|
|
290
|
+
// Orphan type workflow notice (#487) — non-interactive never neutralizes automatically (may be a deploy pipeline), notice only
|
|
291
291
|
if (recordArtifacts) {
|
|
292
292
|
const orphans = trace.step("orphan-scan",
|
|
293
293
|
() => detectOrphanWorkflows({ tempDir, targetRoot: cwd, selectedTypes: types,
|
|
294
|
-
//
|
|
294
|
+
// Also catch workflows that were turned off but remain and keep running (#566)
|
|
295
295
|
options: { includeSecretBackup: context.includeSecretBackup, aiPrSummary: context.aiPrSummary, projectsSync: context.projectsSync, deployTarget } }),
|
|
296
296
|
{ selectedTypes: types });
|
|
297
297
|
orphanPending = orphans.map((o) => o.filename);
|
|
@@ -307,10 +307,10 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
307
307
|
case "workflows": result = trace.step("install-workflows", () => runWorkflows(context, tempDir, cwd, { trace })); break;
|
|
308
308
|
case "issues": result = trace.step("install-issues", () => runIssues(context, tempDir, cwd)); break;
|
|
309
309
|
default:
|
|
310
|
-
//
|
|
310
|
+
// Unknown mode → 0 copies, not an error
|
|
311
311
|
break;
|
|
312
312
|
}
|
|
313
|
-
//
|
|
313
|
+
// Development branch creation (#715) — only with --create-development-branch. The run continues on failure (manual command shown)
|
|
314
314
|
const developmentBranchResult = await runDevelopmentBranchStep({
|
|
315
315
|
isRequested: opts.createDevelopmentBranch === true, targetRoot: cwd,
|
|
316
316
|
branch: context.deployBranch || "develop", defaultBranch: branch, trace,
|
|
@@ -318,10 +318,10 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
318
318
|
});
|
|
319
319
|
const isDevelopmentBranchReady = developmentBranchResult ? developmentBranchResult.status !== "failed" : null;
|
|
320
320
|
|
|
321
|
-
//
|
|
321
|
+
// Migration record (#493/#494) — Layer 2/3 trace files + Layer 1 guide entry
|
|
322
322
|
let migrationGuidePath = null;
|
|
323
|
-
//
|
|
324
|
-
//
|
|
323
|
+
// Compute the record file paths first (the guide references them) and delay the actual write until after the finish screen —
|
|
324
|
+
// so the terminal mirror captures the finish screen too (#561).
|
|
325
325
|
const files = recordArtifacts
|
|
326
326
|
? trace.paths({ fromVersion: existing?.templateVersion || "", toVersion: context.templateVersion, now })
|
|
327
327
|
: null;
|
|
@@ -330,7 +330,7 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
330
330
|
now, mode: opts.mode, types, repoName,
|
|
331
331
|
templateFrom: existing?.templateVersion || "", templateTo: context.templateVersion,
|
|
332
332
|
options: { deploy: deployTarget, publish: publishTargets, secretBackup: context.includeSecretBackup, coderabbit: context.codeReviewCoderabbit, changelogProvider: context.changelogProvider, intent, semverAuto: context.semverAuto , appRelease: context.appRelease, language: context.language, labelStyle: context.labelStyle, closeOnRelease: context.closeOnRelease, projectsSync: context.projectsSync, excludedWorkflows: context.excludedWorkflows, storeLocales: context.storeLocales, storeLocalesIos: context.storeLocalesIos, storeLocalesPlay: context.storeLocalesPlay },
|
|
333
|
-
storeLocalesHint, // #843
|
|
333
|
+
storeLocalesHint, // #843 one checklist item
|
|
334
334
|
branches: { defaultBranch: branch, deployBranch: context.deployBranch || "develop", ready: isDevelopmentBranchReady,
|
|
335
335
|
created: developmentBranchResult ? developmentBranchResult.status === "created" : null, result: developmentBranchResult },
|
|
336
336
|
breaking: breakingReport, migrations: migrationsResult, orphans: { cleaned: [], pending: orphanPending },
|
|
@@ -339,22 +339,22 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
339
339
|
}).guidePath;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
//
|
|
342
|
+
// Finish summary (printed in CLI mode too)
|
|
343
343
|
printSummary({
|
|
344
344
|
mode: opts.mode, types, version, deployBranch: context.deployBranch, migrationGuidePath,
|
|
345
|
-
developmentBranchResult, // #715
|
|
346
|
-
shouldSuggestCreateBranchFlag: !developmentBranchResult, // #715
|
|
345
|
+
developmentBranchResult, // #715 creation result (null without the flag)
|
|
346
|
+
shouldSuggestCreateBranchFlag: !developmentBranchResult, // #715 ran without the flag, so suggest it next time
|
|
347
347
|
counters: { workflows: result?.workflows?.copied ?? 0, workflowFiles: result?.workflows?.copiedFiles ?? [], utilModules: 0 },
|
|
348
|
-
skippedConflicts: result?.workflows?.skippedConflicts ?? [], // #654
|
|
349
|
-
replacedBak: result?.workflows?.replacedBak ?? [], // #673
|
|
350
|
-
legacyLeftover: migrationsResult?.confirmPending ?? [], // #809
|
|
351
|
-
notInstalled: result?.workflows?.notInstalled ?? [], // #810
|
|
352
|
-
semverAutoNewlyOn: sources.semverAutoNewlyOn && context.semverAuto === true, //
|
|
353
|
-
storeLocalesHint, // #843
|
|
354
|
-
verification: result?.verification, // #549
|
|
355
|
-
// #569 —
|
|
348
|
+
skippedConflicts: result?.workflows?.skippedConflicts ?? [], // #654 merge notice
|
|
349
|
+
replacedBak: result?.workflows?.replacedBak ?? [], // #673 notice for files replaced without a reference point
|
|
350
|
+
legacyLeftover: migrationsResult?.confirmPending ?? [], // #809 notice for old and new generations running together
|
|
351
|
+
notInstalled: result?.workflows?.notInstalled ?? [], // #810 notice for workflows not installed
|
|
352
|
+
semverAutoNewlyOn: sources.semverAutoNewlyOn && context.semverAuto === true, // Notice that the update turned it on
|
|
353
|
+
storeLocalesHint, // #843 multi-language store notice
|
|
354
|
+
verification: result?.verification, // #549 post-install verification result (only in full/workflows modes)
|
|
355
|
+
// #569 — the chosen values are needed to mention only what was picked
|
|
356
356
|
aiPrSummary: context.aiPrSummary, codeReviewCoderabbit: context.codeReviewCoderabbit,
|
|
357
|
-
logDir: files ? MIGRATION_DIR : null, // #561
|
|
357
|
+
logDir: files ? MIGRATION_DIR : null, // #561 record location notice
|
|
358
358
|
logFile: files?.logFile ?? null,
|
|
359
359
|
traceFile: files?.traceFile ?? null,
|
|
360
360
|
}, cwd);
|
|
@@ -364,15 +364,15 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
364
364
|
workflowsSkipped: result?.workflows?.skipped ?? 0,
|
|
365
365
|
});
|
|
366
366
|
} catch (err) {
|
|
367
|
-
//
|
|
367
|
+
// Log the failure cause (#561) — like a server log, it must be easy to pinpoint afterwards.
|
|
368
368
|
trace.event("run", "error", opts.mode || "", {
|
|
369
369
|
message: err?.message || String(err),
|
|
370
370
|
stack: String(err?.stack || "").split("\n").slice(0, 3).join(" | "),
|
|
371
371
|
});
|
|
372
372
|
throw err;
|
|
373
373
|
} finally {
|
|
374
|
-
//
|
|
375
|
-
//
|
|
374
|
+
// Leave a record however it exits (#561) — including early return, mid-run cancel and exceptions.
|
|
375
|
+
// The finish screen output must be inside try so it is captured in the mirror before closing here.
|
|
376
376
|
if (recordArtifacts) {
|
|
377
377
|
trace.finalize({ targetRoot: cwd, fromVersion: existing?.templateVersion || "", toVersion: context.templateVersion, now });
|
|
378
378
|
} else {
|
package/src/ui/ansi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Shared ANSI helpers — shared by banner/status-cards (independent of readline-engine's internal helpers, zero dependencies)
|
|
2
2
|
const E = "\x1b[";
|
|
3
3
|
export const A = {
|
|
4
4
|
reset: `${E}0m`,
|
|
@@ -12,21 +12,21 @@ export const A = {
|
|
|
12
12
|
};
|
|
13
13
|
export const paint = (s, color) => `${color}${s}${A.reset}`;
|
|
14
14
|
|
|
15
|
-
//
|
|
15
|
+
// Approximate display width (CJK 2 cells · ANSI sequences 0) — for aligning the box's right edge
|
|
16
16
|
export function visualWidth(s) {
|
|
17
17
|
const plain = String(s).replace(/\x1b\[[0-9;]*m/g, "");
|
|
18
18
|
let w = 0;
|
|
19
19
|
for (const ch of plain) {
|
|
20
20
|
const cp = ch.codePointAt(0);
|
|
21
|
-
//
|
|
21
|
+
// Korean, CJK and emoji are roughly 2 cells (terminal convention)
|
|
22
22
|
w += (cp >= 0x1100 && (cp <= 0x115f || (cp >= 0x2e80 && cp <= 0xa4cf) || (cp >= 0xac00 && cp <= 0xd7a3)
|
|
23
23
|
|| (cp >= 0xf900 && cp <= 0xfaff) || (cp >= 0xff00 && cp <= 0xff60) || cp >= 0x1f300)) ? 2 : 1;
|
|
24
24
|
}
|
|
25
25
|
return w;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
//
|
|
29
|
-
// JS
|
|
28
|
+
// Pad with spaces on the right by visual width (CJK 2 cells) — for aligning columns of mixed Korean/English labels.
|
|
29
|
+
// JS's built-in String.padEnd counts characters, so columns drift when Korean is mixed in.
|
|
30
30
|
export function padEndVisual(s, targetWidth) {
|
|
31
31
|
const pad = targetWidth - visualWidth(s);
|
|
32
32
|
return pad > 0 ? String(s) + " ".repeat(pad) : String(s);
|
package/src/ui/env-plan.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @wizard env
|
|
2
|
-
// io
|
|
1
|
+
// @wizard env plan question UI: build usages, collect ask KEYs, field cards, defaults and per-field input.
|
|
2
|
+
// io-injected — tests pass {select, multiselect, text} stubs. Default is the real readline-engine.
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
import { stdin, stderr } from "node:process";
|
|
@@ -12,11 +12,11 @@ import { t } from "../i18n/index.js";
|
|
|
12
12
|
|
|
13
13
|
const CANCEL = engine.CANCEL;
|
|
14
14
|
|
|
15
|
-
//
|
|
15
|
+
// Progress notices go to stderr (keeps the stdout pipe clean).
|
|
16
16
|
const defaultLog = (s = "") => stderr.write(s + "\n");
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
// usages: [{type, workflowName}] —
|
|
18
|
+
// Build the usages string.
|
|
19
|
+
// usages: [{type, workflowName}] — with several types, just "t1·t2"; with one, "type name1·name2".
|
|
20
20
|
export function scopeString(usages = []) {
|
|
21
21
|
const types = []; const names = [];
|
|
22
22
|
for (const { type, workflowName } of usages) {
|
|
@@ -27,14 +27,14 @@ export function scopeString(usages = []) {
|
|
|
27
27
|
return `${types.join("·")} ${names.join("·")}`.trim();
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
// ask
|
|
31
|
-
// tempDir:
|
|
30
|
+
// Collect ask KEYs — scans the same source as the workflows actually installed.
|
|
31
|
+
// tempDir: downloaded source root. types: list of types to install.
|
|
32
32
|
// opts:
|
|
33
|
-
// resolvers -
|
|
34
|
-
// deployTarget - #439
|
|
35
|
-
// publishTargets - #439 publish
|
|
36
|
-
// prompts - wizard-labels
|
|
37
|
-
//
|
|
33
|
+
// resolvers - for resolving @-prefixed defaults (@repo, etc.) (resolved at collection time)
|
|
34
|
+
// deployTarget - #439 deploy axis: scan server-deploy only for docker-ssh (default) (matches the copy engine)
|
|
35
|
+
// publishTargets - #439 publish axis: scan publish/<target>/ of the selected targets
|
|
36
|
+
// prompts - wizard-labels parsed object (for workflow display names; null falls back to stripping the extension)
|
|
37
|
+
// Returns { keys:[], defaults:Map<key,default>, typeDefaults:Map<"type|key",default>,
|
|
38
38
|
// usages:Map<key,[{type,workflowName}]> }
|
|
39
39
|
export function collectAsks(tempDir, types = [], opts = {}) {
|
|
40
40
|
const { resolvers = {}, deployTarget = "docker-ssh", publishTargets = [], prompts = null, repoName = "" } = opts;
|
|
@@ -47,7 +47,7 @@ export function collectAsks(tempDir, types = [], opts = {}) {
|
|
|
47
47
|
for (const type of types) {
|
|
48
48
|
const typeDir = join(baseDir, type);
|
|
49
49
|
if (!exists(typeDir)) continue;
|
|
50
|
-
//
|
|
50
|
+
// Same folder set as the copy engine: type direct children + (with docker-ssh) server-deploy + selected publish/<target>
|
|
51
51
|
const dirs = [typeDir];
|
|
52
52
|
if ((deployTarget || "docker-ssh") === "docker-ssh") dirs.push(join(typeDir, "server-deploy"));
|
|
53
53
|
for (const pt of publishTargets) dirs.push(join(typeDir, "publish", pt));
|
|
@@ -59,12 +59,12 @@ export function collectAsks(tempDir, types = [], opts = {}) {
|
|
|
59
59
|
if (!content.includes("@wizard")) continue;
|
|
60
60
|
const workflowName = workflowDisplayName(prompts, filename);
|
|
61
61
|
for (const line of content.split(/\r?\n/)) {
|
|
62
|
-
const p = parseWizardLine(line); // KEY
|
|
62
|
+
const p = parseWizardLine(line); // KEY regex [A-Z_]+
|
|
63
63
|
if (!p || p.action !== "ask") continue;
|
|
64
|
-
//
|
|
65
|
-
// #489 —
|
|
66
|
-
//
|
|
67
|
-
//
|
|
64
|
+
// Per-type default: resolve via resolver if @-prefixed, else literal
|
|
65
|
+
// #489 — global tokens like __PROJECT_NAME__ are resolved before showing the card.
|
|
66
|
+
// Not showing the same value as the install (global substitution when copying files)
|
|
67
|
+
// would make users think "the literal gets written as is?".
|
|
68
68
|
const typeDefault = resolveGlobalTokens(
|
|
69
69
|
p.arg.startsWith("@") ? resolveToken(p.arg.slice(1), type, resolvers) : p.arg,
|
|
70
70
|
repoName,
|
|
@@ -81,13 +81,13 @@ export function collectAsks(tempDir, types = [], opts = {}) {
|
|
|
81
81
|
return { keys, defaults, typeDefaults, usages };
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// KEY
|
|
84
|
+
// The type where the KEY first appeared (for type override priority in label lookup)
|
|
85
85
|
function firstTypeFor(usages, key) {
|
|
86
86
|
return usages.get(key)?.[0]?.type ?? "";
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// KEY
|
|
90
|
-
// info: { default, usages } — idx/tot
|
|
89
|
+
// Print one KEY as a 'label · usages · description · example · default' card.
|
|
90
|
+
// info: { default, usages } — with idx/tot, shows "(i/t)" progress. log is injectable (silenced in tests).
|
|
91
91
|
export function printFieldCard(prompts, key, info, idx = null, tot = null, log = defaultLog) {
|
|
92
92
|
const ty = info.usages?.[0]?.type ?? "";
|
|
93
93
|
const label = wfField(prompts, ty, key, "label");
|
|
@@ -104,8 +104,8 @@ export function printFieldCard(prompts, key, info, idx = null, tot = null, log =
|
|
|
104
104
|
log("");
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
//
|
|
108
|
-
//
|
|
107
|
+
// Ask for the given KEYs one by one and record them in values.
|
|
108
|
+
// Empty input (Enter)/ESC → keep the KEY's shared default.
|
|
109
109
|
async function promptEach(io, prompts, asks, todoKeys, values, log) {
|
|
110
110
|
const tot = todoKeys.length;
|
|
111
111
|
if (tot === 0) return;
|
|
@@ -126,17 +126,17 @@ async function promptEach(io, prompts, asks, todoKeys, values, log) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
// - useDefaults=true →
|
|
132
|
-
// - useDefaults=false → values
|
|
133
|
-
// (⚠️ substituteEnv
|
|
134
|
-
//
|
|
135
|
-
// tempDir/types/resolvers/deployTarget/publishTargets —
|
|
136
|
-
// targetRoot — wizard-prompts.yml
|
|
137
|
-
// force — true
|
|
138
|
-
// io — {select, multiselect, text}
|
|
139
|
-
// log —
|
|
129
|
+
// Deploy env setup plan.
|
|
130
|
+
// Returns { values: Map<key,value>, useDefaults: boolean }
|
|
131
|
+
// - useDefaults=true → the caller passes it as is to substituteEnv for the per-type default path
|
|
132
|
+
// - useDefaults=false → only keys in values are substituted with confirmed user values; the rest use defaults
|
|
133
|
+
// (⚠️ substituteEnv reads values only when useDefaults=false, so always pass this flag along)
|
|
134
|
+
// Arguments:
|
|
135
|
+
// tempDir/types/resolvers/deployTarget/publishTargets — same meaning as in collectAsks
|
|
136
|
+
// targetRoot — first place to look for wizard-prompts.yml (default ".")
|
|
137
|
+
// force — when true, all defaults without questions
|
|
138
|
+
// io — {select, multiselect, text} injection (default readline-engine). Test stub point.
|
|
139
|
+
// log — injected output function for cards and notices (default stderr)
|
|
140
140
|
export async function promptEnvPlan({
|
|
141
141
|
tempDir, types = [], io = null, force = false, resolvers = {},
|
|
142
142
|
deployTarget = "docker-ssh", publishTargets = [], targetRoot = ".", repoName = "", log = defaultLog,
|
|
@@ -145,17 +145,17 @@ export async function promptEnvPlan({
|
|
|
145
145
|
const asks = collectAsks(tempDir, types, { resolvers, deployTarget, publishTargets, prompts, repoName });
|
|
146
146
|
const defaults = asks.defaults;
|
|
147
147
|
|
|
148
|
-
//
|
|
148
|
+
// 0 collected keys → no questions at all
|
|
149
149
|
if (asks.keys.length === 0) return { values: new Map(), useDefaults: true };
|
|
150
150
|
|
|
151
|
-
//
|
|
152
|
-
// io
|
|
151
|
+
// Non-interactive: force or (no io injected && non-TTY) → all defaults
|
|
152
|
+
// If io is injected (tests/parent wizard), proceed interactively regardless of TTY.
|
|
153
153
|
const interactive = !force && (io != null || stdin.isTTY);
|
|
154
154
|
if (!interactive) return { values: new Map(defaults), useDefaults: true };
|
|
155
155
|
|
|
156
156
|
const ui = io ?? engine;
|
|
157
157
|
|
|
158
|
-
//
|
|
158
|
+
// Print the whole default preview card
|
|
159
159
|
log("");
|
|
160
160
|
log(t("envPlan.title"));
|
|
161
161
|
log("");
|
|
@@ -176,20 +176,20 @@ export async function promptEnvPlan({
|
|
|
176
176
|
{ value: "some", label: t("envPlan.optSome") },
|
|
177
177
|
],
|
|
178
178
|
});
|
|
179
|
-
// ESC
|
|
179
|
+
// ESC/cancel → all defaults
|
|
180
180
|
if (choice === CANCEL || choice == null || choice === "all") {
|
|
181
181
|
return { values: new Map(defaults), useDefaults: true };
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
//
|
|
185
|
-
//
|
|
184
|
+
// Only keys the user confirmed go into values — substituteEnv (useDefaults:false)
|
|
185
|
+
// fills keys missing from values with per-type defaults (input overrides defaults).
|
|
186
186
|
const values = new Map();
|
|
187
187
|
if (choice === "each") {
|
|
188
188
|
await promptEach(ui, prompts, asks, asks.keys, values, log);
|
|
189
189
|
return { values, useDefaults: false };
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
// some:
|
|
192
|
+
// some: multi-select only the items to change → input only those
|
|
193
193
|
const options = asks.keys.map((key) => ({
|
|
194
194
|
value: key,
|
|
195
195
|
label: `${wfField(prompts, firstTypeFor(asks.usages, key), key, "label")} ${t("envPlan.defaultTag", { value: defaults.get(key) })}`,
|
|
@@ -199,11 +199,11 @@ export async function promptEnvPlan({
|
|
|
199
199
|
options,
|
|
200
200
|
initialValues: [],
|
|
201
201
|
});
|
|
202
|
-
// ESC
|
|
202
|
+
// ESC/empty selection → all defaults
|
|
203
203
|
if (selected === CANCEL || !Array.isArray(selected) || selected.length === 0) {
|
|
204
204
|
return { values: new Map(defaults), useDefaults: true };
|
|
205
205
|
}
|
|
206
|
-
//
|
|
206
|
+
// Keep the collected key order + accept only collected ask KEYs
|
|
207
207
|
const todo = asks.keys.filter((k) => selected.includes(k));
|
|
208
208
|
await promptEach(ui, prompts, asks, todo, values, log);
|
|
209
209
|
return { values, useDefaults: false };
|