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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//
|
|
1
|
+
// The single place that decides install option values (#851).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
3
|
+
// Non-interactive (src/index.js) and interactive (src/commands/interactive.js) use the same result.
|
|
4
|
+
// Deciding separately splits the rules: the interactive PR summary choice was lost (aiPrSummary),
|
|
5
|
+
// and version mode, which skips questions, left deploy: docker-ssh in mobile-only repos.
|
|
6
|
+
// The rule is the same for every option: CLI flag > saved version.yml value > default.
|
|
7
|
+
// Interactive uses this result as initial values and overwrites only what the user answered.
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { applicableTargets, migrateProvider } from "./options-ask.js";
|
|
@@ -12,11 +12,11 @@ import { DEFAULT_CODE_REVIEW_CODERABBIT } from "./constants.js";
|
|
|
12
12
|
import { resolveLabelStyle } from "./label-style.js";
|
|
13
13
|
import { resolveRepoLanguage } from "./repo-language.js";
|
|
14
14
|
|
|
15
|
-
//
|
|
15
|
+
// File that marks Projects sync as on when already installed (#716)
|
|
16
16
|
export const PROJECTS_SYNC_WORKFLOW = ".github/workflows/PROJECT-COMMON-PROJECTS-SYNC-MANAGER.yaml";
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
// intent
|
|
18
|
+
// Clean up axis values that do not apply to the type (#498). Mobile app or basic alone leaves both axes empty
|
|
19
|
+
// and intent settles as none. Kept separate so the same rule can be reapplied to values from questions.
|
|
20
20
|
export function normalizeAxes({ deploy, publish, intent, types }) {
|
|
21
21
|
const applicable = applicableTargets(types);
|
|
22
22
|
const outDeploy = deploy !== "none" && !applicable.deploy.includes(deploy) ? "none" : deploy;
|
|
@@ -25,20 +25,20 @@ export function normalizeAxes({ deploy, publish, intent, types }) {
|
|
|
25
25
|
return { deploy: outDeploy, publish: outPublish, intent: noAxes ? "none" : intent, applicable };
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// flags:
|
|
29
|
-
// existing: parseExisting
|
|
30
|
-
//
|
|
28
|
+
// flags: option-related values from parseArgs (none → {} — interactive initial values)
|
|
29
|
+
// existing: parseExisting result or null
|
|
30
|
+
// Returns { values, sources } — sources lets the trace record "why this value" (#561).
|
|
31
31
|
export function resolveOptions({ flags = {}, existing = null, types = [], cwd = "." }) {
|
|
32
32
|
const stored = existing?.options ?? {};
|
|
33
33
|
const applicable = applicableTargets(types);
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// Project nature (#485): CLI --intent → saved value. Basis for deriving deploy/publish.
|
|
36
36
|
let intent = flags.intent ?? stored.intent ?? null;
|
|
37
|
-
//
|
|
37
|
+
// Deploy/publish axes (#439): flag → saved value → default (docker-ssh only when applicable — #498).
|
|
38
38
|
let deploy = flags.deployTarget ?? stored.deploy
|
|
39
39
|
?? (applicable.deploy.includes("docker-ssh") ? "docker-ssh" : "none");
|
|
40
40
|
let publish = flags.publishTargets ?? stored.publish ?? [];
|
|
41
|
-
// --intent
|
|
41
|
+
// With --intent and no flag for that axis, intent derives the axis (#485 non-interactive)
|
|
42
42
|
if (flags.intent != null) {
|
|
43
43
|
if ((intent === "library" || intent === "none") && flags.deployTarget == null) deploy = "none";
|
|
44
44
|
if ((intent === "app" || intent === "none") && flags.publishTargets == null) publish = [];
|
|
@@ -49,33 +49,33 @@ export function resolveOptions({ flags = {}, existing = null, types = [], cwd =
|
|
|
49
49
|
const values = {
|
|
50
50
|
intent, deployTarget: deploy, publishTargets: publish,
|
|
51
51
|
includeSecretBackup: flags.includeSecretBackup ?? stored.secretBackup ?? false,
|
|
52
|
-
// #566 —
|
|
52
|
+
// #566 — works with no setup, so on by default
|
|
53
53
|
aiPrSummary: flags.aiPrSummary ?? stored.aiPrSummary ?? true,
|
|
54
|
-
// #716 —
|
|
54
|
+
// #716 — installed in a new repo without setup (Secret, PROJECT_URL) it only piles up notices. Existing installs keep it.
|
|
55
55
|
projectsSync: flags.projectsSync ?? stored.projectsSync ?? existsSync(join(cwd, PROJECTS_SYNC_WORKFLOW)),
|
|
56
|
-
// #502 — version
|
|
56
|
+
// #502 — keeps version mode from downgrading an existing full integration record (full wins)
|
|
57
57
|
recordMode: existing?.templateMode === "full" ? "full" : "version",
|
|
58
|
-
// #456 —
|
|
58
|
+
// #456 — not written to version.yml when empty (skills fall back to develop). Records only what the user chose or passed as a flag.
|
|
59
59
|
deployBranch: flags.deployBranch || stored.deployBranch || "",
|
|
60
|
-
// #1114 —
|
|
60
|
+
// #1114 — when empty, workflows are untouched and nothing is written to version.yml (existing repos unchanged)
|
|
61
61
|
deployTriggerBranch: flags.deployTriggerBranch || stored.deployTriggerBranch || "",
|
|
62
|
-
// #1114 —
|
|
62
|
+
// #1114 — recorded and substituted only when on. When off, install output is byte-identical
|
|
63
63
|
ciMinutesSaver: flags.ciMinutesSaver ?? stored.ciMinutesSaver ?? false,
|
|
64
|
-
// #455 — null
|
|
64
|
+
// #455 — prevents the bug where null flowed through and was recorded as provider:"null"
|
|
65
65
|
changelogProvider: migrateProvider(stored.changelogProvider) ?? "commit",
|
|
66
66
|
changelogBaseUrl: stored.changelogBaseUrl ?? "",
|
|
67
67
|
codeReviewCoderabbit: flags.codeReviewCoderabbit ?? stored.codeReviewCoderabbit ?? DEFAULT_CODE_REVIEW_CODERABBIT,
|
|
68
|
-
// #546, #814 —
|
|
68
|
+
// #546, #814 — an explicit false is respected; when the key is missing, on for both new and existing
|
|
69
69
|
semverAuto: stored.semverAuto ?? true,
|
|
70
|
-
//
|
|
70
|
+
// Values the wizard does not ask about keep only the saved value (full regeneration drops anything not passed)
|
|
71
71
|
appRelease: stored.appRelease ?? null, // #553
|
|
72
72
|
excludedWorkflows: stored.excludedWorkflows ?? null, // #810
|
|
73
73
|
storeLocales: stored.storeLocales ?? null, // #829
|
|
74
74
|
storeLocalesIos: stored.storeLocalesIos ?? null,
|
|
75
75
|
storeLocalesPlay: stored.storeLocalesPlay ?? null,
|
|
76
|
-
// #771 —
|
|
76
|
+
// #771 — on for new installs only. Existing repos get no key and keep current behavior
|
|
77
77
|
closeOnRelease: stored.closeOnRelease ?? (existing ? null : true),
|
|
78
|
-
// #769, #776 —
|
|
78
|
+
// #769, #776 — new en / existing ko. An update alone never changes existing repo text or labels
|
|
79
79
|
language: resolveRepoLanguage({ flag: flags.language ?? null, stored: stored.language, existing: !!existing }),
|
|
80
80
|
labelStyle: resolveLabelStyle({ flag: flags.labelStyle ?? null, stored: stored.labelStyle, existing: !!existing }),
|
|
81
81
|
};
|
|
@@ -88,14 +88,14 @@ export function resolveOptions({ flags = {}, existing = null, types = [], cwd =
|
|
|
88
88
|
deploy: from(flags.deployTarget, stored.deploy, "--deploy"),
|
|
89
89
|
publish: from(flags.publishTargets, stored.publish, "--publish"),
|
|
90
90
|
before, applicable,
|
|
91
|
-
//
|
|
91
|
+
// Whether semver_auto was turned on for the first time in an existing repo — the finish screen reports it
|
|
92
92
|
semverAutoNewlyOn: !!existing && stored.semverAuto == null,
|
|
93
93
|
};
|
|
94
94
|
return { values, sources };
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
// version.yml options
|
|
98
|
-
//
|
|
97
|
+
// Values recorded as version.yml options (same names as the resolveOptions result)
|
|
98
|
+
// If each entry point (full, version) picked its own, missing options revert to generator defaults (#909: version mode ai_summary false > true)
|
|
99
99
|
const TEMPLATE_OPTION_FIELDS = [
|
|
100
100
|
"intent", "deployTarget", "publishTargets", "includeSecretBackup", "aiPrSummary", "projectsSync",
|
|
101
101
|
"changelogProvider", "changelogBaseUrl", "codeReviewCoderabbit", "semverAuto", "appRelease",
|
|
@@ -103,7 +103,7 @@ const TEMPLATE_OPTION_FIELDS = [
|
|
|
103
103
|
"deployTriggerBranch", "ciMinutesSaver",
|
|
104
104
|
];
|
|
105
105
|
|
|
106
|
-
/**
|
|
106
|
+
/** Run context (resolveOptions values spread out) > buildVersionYml templateOptions */
|
|
107
107
|
export function toTemplateOptions(context, { mode, optionsDate }) {
|
|
108
108
|
const options = Object.fromEntries(TEMPLATE_OPTION_FIELDS.map((field) => [field, context[field]]));
|
|
109
109
|
return { ...options, templateVersion: context.templateVersion, mode, optionsDate };
|
package/src/core/run-trace.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// "
|
|
4
|
-
// Layer 1(
|
|
1
|
+
// Wizard run trace (#494) — Layer 2 (JSONL events) + Layer 3 (terminal mirror) of the 3-layer record.
|
|
2
|
+
// Records every wizard decision and action as one event line, so people and AI agents can later trace
|
|
3
|
+
// "everything the wizard did to this file" in time order with one file name grep (automates the v4.2.15 manual log-copy diagnosis).
|
|
4
|
+
// Layer 1 (curated guide) is migration-guide.js — it consumes this module's events as the single source.
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { writeText } from "./fsutil.js";
|
|
7
7
|
import { getLang } from "../i18n/index.js";
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
9
|
+
// Diagnostic log location (#561). Kept outside the tracked docs/ — this record is not a document for people
|
|
10
|
+
// but material for agents to check "what happened in the last run".
|
|
11
|
+
// A .gitignore is written inside the folder so it carries its own rule (root .gitignore untouched).
|
|
12
|
+
// The sibling .github/.projectops/baseline.json is shared with the team, so it stays tracked.
|
|
13
13
|
export const MIGRATION_DIR = ".github/.projectops/logs";
|
|
14
14
|
export const LOGS_GITIGNORE = [
|
|
15
|
-
"# projectops
|
|
16
|
-
"#
|
|
15
|
+
"# projectops run diagnostic logs — not tracked in the repository.",
|
|
16
|
+
"# The wizard writes a record here on every run; nothing here is meant to be committed.",
|
|
17
17
|
"*",
|
|
18
18
|
"!.gitignore",
|
|
19
19
|
"",
|
|
20
20
|
].join("\n");
|
|
21
21
|
export const TRACE_SCHEMA = 1;
|
|
22
22
|
|
|
23
|
-
//
|
|
23
|
+
// Sensitive value guard — PATs, tokens, secrets and passwords never go into any event (#494 safety rule).
|
|
24
24
|
const SENSITIVE_KEY_RE = /pat|token|secret|password|credential/i;
|
|
25
25
|
export function scrubDetail(detail) {
|
|
26
26
|
if (detail == null || typeof detail !== "object" || Array.isArray(detail)) return detail;
|
|
@@ -32,22 +32,22 @@ export function scrubDetail(detail) {
|
|
|
32
32
|
return out;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// Step duration. Omitted when a fixed clock is injected (tests) so results stay stable.
|
|
36
36
|
function elapsed(t0, clockIso) {
|
|
37
37
|
return clockIso ? {} : { ms: Date.now() - t0 };
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
//
|
|
41
|
-
// [
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
// ERROR —
|
|
45
|
-
// WARN —
|
|
46
|
-
// INFO —
|
|
47
|
-
// DEBUG —
|
|
40
|
+
// Turn an event into one server-log style line (#561).
|
|
41
|
+
// [time] LEVEL phase/action target key=value ...
|
|
42
|
+
// The level is inferred from action — only what needs action (unreplaced, cancelled, failed) should stand out.
|
|
43
|
+
// Levels split by "what to look at first".
|
|
44
|
+
// ERROR — failure. Must be acted on.
|
|
45
|
+
// WARN — may fail later if left as is, or needs a user decision.
|
|
46
|
+
// INFO — the main flow of the run. Step boundaries and settled decisions.
|
|
47
|
+
// DEBUG — per-item detail (one file, one substitution). Default is INFO, but everything goes to the file.
|
|
48
48
|
//
|
|
49
|
-
// DEBUG
|
|
50
|
-
//
|
|
49
|
+
// Why DEBUG goes to the file: after a problem hits, "if only DEBUG had been on" is useless.
|
|
50
|
+
// Keep the screen quiet but write everything to the file.
|
|
51
51
|
const ERROR_ACTIONS = new Set(["error", "failed"]);
|
|
52
52
|
const WARN_ACTIONS = new Set([
|
|
53
53
|
"unresolved", "cancelled", "skipped-conflict", "leftover-old-gen",
|
|
@@ -78,22 +78,22 @@ export function formatLogLine(e) {
|
|
|
78
78
|
return parts.join("") + "\n";
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
//
|
|
82
|
-
//
|
|
81
|
+
// Strip color and cursor control sequences (#561). Log files are read by editors and agents, so leftover
|
|
82
|
+
// escapes get in the way. Terminal output itself is untouched (only the copy is cleaned).
|
|
83
83
|
// eslint-disable-next-line no-control-regex
|
|
84
84
|
const ANSI_RE = /\u001b\[[0-9;]*[A-Za-z]/g;
|
|
85
85
|
export function stripAnsi(text) {
|
|
86
86
|
return String(text).replace(ANSI_RE, "");
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// now("YYYY-MM-DD HH:MM:SS") →
|
|
89
|
+
// now("YYYY-MM-DD HH:MM:SS") → file name stamp "YYYYMMDD_HHMMSS". Falls back to "run" if not in that format (safe for test-injected clocks).
|
|
90
90
|
export function stampFromNow(now) {
|
|
91
91
|
const digits = String(now ?? "").replace(/[^0-9]/g, "");
|
|
92
92
|
if (digits.length < 14) return "run";
|
|
93
93
|
return `${digits.slice(0, 8)}_${digits.slice(8, 14)}`;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
//
|
|
96
|
+
// Trace factory. clockIso can be injected (test determinism) — default is the real UTC.
|
|
97
97
|
export function createRunTrace({ clockIso = null } = {}) {
|
|
98
98
|
const events = [];
|
|
99
99
|
const lines = [];
|
|
@@ -107,9 +107,9 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
107
107
|
events,
|
|
108
108
|
lines,
|
|
109
109
|
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
110
|
+
// Record one event. detail is stored after scrubbing sensitive keys.
|
|
111
|
+
// Also writes it as a human-readable log line (#561) — internal behavior not shown in the terminal
|
|
112
|
+
// must be traceable in time order in the one .log file so problems can be handled right away.
|
|
113
113
|
event(phase, action, target = "", detail = null) {
|
|
114
114
|
const e = { ts: nowIso(), phase, action, target };
|
|
115
115
|
const d = scrubDetail(detail);
|
|
@@ -119,11 +119,11 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
119
119
|
return e;
|
|
120
120
|
},
|
|
121
121
|
|
|
122
|
-
//
|
|
123
|
-
//
|
|
122
|
+
// Start the terminal output mirror — wraps stdout/stderr write and collects a copy (output itself passes through).
|
|
123
|
+
// Enabled only in a real CLI run (not called on the test stub io path).
|
|
124
124
|
mirrorStart() {
|
|
125
125
|
if (restore) return;
|
|
126
|
-
const so = process.stdout.write; //
|
|
126
|
+
const so = process.stdout.write; // Keep the original reference — identity is kept on restore
|
|
127
127
|
const se = process.stderr.write;
|
|
128
128
|
// The run log is always English (agents read it later, and it must not change with the user's locale).
|
|
129
129
|
// When the screen is in another language the raw terminal text is not copied; the caller appends an
|
|
@@ -133,7 +133,7 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
133
133
|
try {
|
|
134
134
|
const s = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
135
135
|
lines.push(stripAnsi(s));
|
|
136
|
-
} catch { /*
|
|
136
|
+
} catch { /* A mirror failure does not affect the run */ }
|
|
137
137
|
};
|
|
138
138
|
process.stdout.write = function (chunk, ...rest) { capture(chunk); return so.apply(process.stdout, [chunk, ...rest]); };
|
|
139
139
|
process.stderr.write = function (chunk, ...rest) { capture(chunk); return se.apply(process.stderr, [chunk, ...rest]); };
|
|
@@ -149,9 +149,9 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
149
149
|
if (restore) { restore(); restore = null; }
|
|
150
150
|
},
|
|
151
151
|
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
//
|
|
152
|
+
// Step wrapper (#561) — records "where it entered, when it left and how long it took" automatically,
|
|
153
|
+
// like a server log. Scattering start/done over call sites always misses some.
|
|
154
|
+
// On an exception, records failed and rethrows — never swallows.
|
|
155
155
|
step(name, fn, detail = null) {
|
|
156
156
|
this.event("step", "start", name, detail);
|
|
157
157
|
const t0 = Date.now();
|
|
@@ -165,7 +165,7 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
165
165
|
}
|
|
166
166
|
},
|
|
167
167
|
|
|
168
|
-
// async
|
|
168
|
+
// async version — for interactive steps (including waits for answers).
|
|
169
169
|
async stepAsync(name, fn, detail = null) {
|
|
170
170
|
this.event("step", "start", name, detail);
|
|
171
171
|
const t0 = Date.now();
|
|
@@ -179,10 +179,10 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
|
|
182
|
-
//
|
|
183
|
-
// SIGINT
|
|
184
|
-
// "
|
|
185
|
-
//
|
|
182
|
+
// Leave a record even on forced exit (Ctrl+C) (#561).
|
|
183
|
+
// If SIGINT's default kills the process, finally never runs — yet when the user cuts it off is exactly when
|
|
184
|
+
// "how far did it get" matters most, so missing it here halves the log's value.
|
|
185
|
+
// The handler only records, then exits as before (behavior unchanged).
|
|
186
186
|
armSignals(opts = {}) {
|
|
187
187
|
if (signalsArmed) return () => {};
|
|
188
188
|
signalsArmed = true;
|
|
@@ -190,10 +190,10 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
190
190
|
const handlers = [];
|
|
191
191
|
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
192
192
|
const h = () => {
|
|
193
|
-
self.event("run", "cancelled", sig, { reason: "
|
|
193
|
+
self.event("run", "cancelled", sig, { reason: "user forced exit (signal received)" });
|
|
194
194
|
self.finalize(opts);
|
|
195
195
|
process.removeListener(sig, h);
|
|
196
|
-
process.kill(process.pid, sig); //
|
|
196
|
+
process.kill(process.pid, sig); // Hand over to the original exit behavior
|
|
197
197
|
};
|
|
198
198
|
process.on(sig, h);
|
|
199
199
|
handlers.push([sig, h]);
|
|
@@ -204,12 +204,12 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
204
204
|
};
|
|
205
205
|
},
|
|
206
206
|
|
|
207
|
-
//
|
|
208
|
-
//
|
|
209
|
-
//
|
|
207
|
+
// Leave a record however it ends (#561) — normal finish, mid-run cancel, exception, forced exit.
|
|
208
|
+
// When the user cuts it off midway is exactly when "how far did it get" matters most,
|
|
209
|
+
// so a record kept only on a full run is half as useful.
|
|
210
210
|
//
|
|
211
|
-
//
|
|
212
|
-
//
|
|
211
|
+
// Writes once even if called twice (normal path + duplicate call in finally). Failures are swallowed —
|
|
212
|
+
// a recording failure must not block exit.
|
|
213
213
|
finalize(opts = {}) {
|
|
214
214
|
if (finalized) return null;
|
|
215
215
|
finalized = true;
|
|
@@ -221,8 +221,8 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
|
|
224
|
-
//
|
|
225
|
-
//
|
|
224
|
+
// Only computes the record file paths (no write). Capturing the finish screen means delaying write until after screen output,
|
|
225
|
+
// but the guide entry needs the traceFile path before that, so the two are separated.
|
|
226
226
|
paths({ fromVersion = "", toVersion = "", now = "" } = {}) {
|
|
227
227
|
const stamp = stampFromNow(now);
|
|
228
228
|
const from = String(fromVersion || "new").replace(/[^0-9a-zA-Z.-]/g, "");
|
|
@@ -231,15 +231,15 @@ export function createRunTrace({ clockIso = null } = {}) {
|
|
|
231
231
|
return { base, traceFile: `${MIGRATION_DIR}/${base}.jsonl`, logFile: `${MIGRATION_DIR}/${base}.log` };
|
|
232
232
|
},
|
|
233
233
|
|
|
234
|
-
// Layer 2/3
|
|
235
|
-
//
|
|
236
|
-
//
|
|
234
|
+
// Layer 2/3 file record — .github/.projectops/logs/{stamp}_v{from}_to_v{to}.{jsonl,log}
|
|
235
|
+
// Returns { traceFile, logFile } (relative to targetRoot — used as guide meta pointers).
|
|
236
|
+
// Writes nothing when there are 0 events (avoids polluting no-op runs) — returns null.
|
|
237
237
|
write({ targetRoot = ".", fromVersion = "", toVersion = "", now = "" } = {}) {
|
|
238
238
|
if (events.length === 0) return null;
|
|
239
239
|
const from = String(fromVersion || "new").replace(/[^0-9a-zA-Z.-]/g, "");
|
|
240
240
|
const to = String(toVersion || "unknown").replace(/[^0-9a-zA-Z.-]/g, "");
|
|
241
241
|
const planned = this.paths({ fromVersion, toVersion, now });
|
|
242
|
-
//
|
|
242
|
+
// Ensure the folder rule every time — stays untracked even if the user deleted it or the folder is new.
|
|
243
243
|
writeText(join(targetRoot, `${MIGRATION_DIR}/.gitignore`), LOGS_GITIGNORE);
|
|
244
244
|
const header = JSON.stringify({ schema: TRACE_SCHEMA, kind: "projectops-migration-trace", from, to, started: events[0]?.ts ?? "" });
|
|
245
245
|
writeText(join(targetRoot, planned.traceFile), [header, ...events.map((e) => JSON.stringify(e))].join("\n") + "\n");
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Store multi-language setup detection (#843): only finds and reports repos that push one text to many languages without store_locales.
|
|
2
|
+
// Changes neither behavior nor version.yml. Output is one line on the finish screen + one migration guide checklist item.
|
|
3
3
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
4
4
|
import { join, relative } from "node:path";
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// Shape of a language folder name (ko, ko-KR, en-US, zh-Hans)
|
|
7
7
|
const LOCALE_NAME = /^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/;
|
|
8
|
-
// DELIVER_LOCALES
|
|
8
|
+
// DELIVER_LOCALES assignment (yaml `KEY: "a,b"`, shell `KEY=a,b`, Ruby `ENV["KEY"] = "a,b"`). A `||` default is not an assignment and is excluded
|
|
9
9
|
const DELIVER_LOCALES_ASSIGN = /DELIVER_LOCALES["']?\]?\s*[:=]\s*["']?([A-Za-z0-9_, -]+)/g;
|
|
10
10
|
const MINIMUM_LOCALE_COUNT = 2;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* storeLocales
|
|
13
|
+
* Collect 3 multi-language store signals: DELIVER_LOCALES with 2+ entries, Play metadata language folders, release-notes language folders
|
|
14
|
+
* null if storeLocales already exists (not null) or there is no signal
|
|
15
15
|
*/
|
|
16
16
|
export function detectMultiLocaleStore({ root, flutterPath = ".", storeLocales = null }) {
|
|
17
17
|
if (storeLocales != null) return null;
|
|
@@ -21,14 +21,14 @@ export function detectMultiLocaleStore({ root, flutterPath = ".", storeLocales =
|
|
|
21
21
|
...findLocaleDirectories(root, join(appRoot, "android/fastlane/metadata/android"), "play-metadata"),
|
|
22
22
|
...findLocaleDirectories(root, join(appRoot, "release-notes"), "release-notes"),
|
|
23
23
|
];
|
|
24
|
-
//
|
|
24
|
+
// Also check the root release-notes only when the root and app folder differ (same would be a duplicate)
|
|
25
25
|
if (appRoot !== join(root, ".")) signals.push(...findLocaleDirectories(root, join(root, "release-notes"), "release-notes"));
|
|
26
26
|
if (signals.length === 0) return null;
|
|
27
27
|
const locales = [...new Set(signals.flatMap((s) => s.locales))];
|
|
28
28
|
return { signals, locales };
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
//
|
|
31
|
+
// DELIVER_LOCALES in workflows (.yml/.yaml) + Fastfiles (ios, android, root)
|
|
32
32
|
function findDeliverLocales(root, appRoot) {
|
|
33
33
|
const candidates = [];
|
|
34
34
|
const workflowsDir = join(root, ".github/workflows");
|
|
@@ -48,14 +48,14 @@ function findDeliverLocales(root, appRoot) {
|
|
|
48
48
|
const locales = match[1].split(",").map((s) => s.trim()).filter((s) => LOCALE_NAME.test(s));
|
|
49
49
|
if (locales.length >= MINIMUM_LOCALE_COUNT) {
|
|
50
50
|
found.push({ source: "deliver-locales", path: toRelative(root, file), locales });
|
|
51
|
-
break; //
|
|
51
|
+
break; // One hit per file is enough
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
return found;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
// <dir>/<lang>/
|
|
58
|
+
// 2+ <dir>/<lang>/ folders count as one signal
|
|
59
59
|
function findLocaleDirectories(root, dir, source) {
|
|
60
60
|
if (!existsSync(dir) || !statSync(dir).isDirectory()) return [];
|
|
61
61
|
const locales = readdirSync(dir)
|
|
@@ -68,14 +68,14 @@ function isFile(path) {
|
|
|
68
68
|
return existsSync(path) && statSync(path).isFile();
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
//
|
|
71
|
+
// Screen and guide text use the / separator regardless of OS
|
|
72
72
|
function toRelative(root, path) {
|
|
73
73
|
return relative(root, path).split("\\").join("/");
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
77
|
+
* Shared by both entry points (non-interactive, interactive): detect only for an existing repo with storeLocales unset > write trace > return the result
|
|
78
|
+
* null for new installs (the target is repos already running in several languages)
|
|
79
79
|
*/
|
|
80
80
|
export function detectStoreLocalesHint({ root, existing, paths, trace = null }) {
|
|
81
81
|
if (!existing) return null;
|
package/src/core/verify.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Post-install verification (#549) — rereads installed workflows to see "will this run as is".
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Why after, not before install: substitution happens scattered per file, and auto tokens depend on
|
|
4
|
+
// resolver results. Looking at the final disk content is the only way to see what will actually deploy.
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
7
7
|
import { PATHS } from "./paths.js";
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
9
|
+
// Tokens that are not substitution targets — heredoc delimiters inside workflow scripts. They are syntax,
|
|
10
|
+
// not values, so they are excluded from the unreplaced check. (e.g. cat <<'__SUH_FILE_CONTENT_EOF__')
|
|
11
11
|
const SENTINEL_RE = /^__SUH_[A-Z0-9_]*__$/;
|
|
12
12
|
const PLACEHOLDER_RE = /__[A-Z][A-Z0-9_]*__/g;
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
14
|
+
// Commented-out lines — they never run, so they are not checked.
|
|
15
|
+
// Templates ship whole "[optional] ..." sample steps commented out; counting them would
|
|
16
|
+
// tell users to "register" secrets they never use.
|
|
17
17
|
const isCommented = (line) => /^\s*#/.test(line);
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
// (
|
|
19
|
+
// Files to check. If the caller does not specify, scan every installed workflow
|
|
20
|
+
// (looking at the final disk state fits the purpose better than assembling the copy result list).
|
|
21
21
|
function listWorkflowFiles(workflowsDir, filenames) {
|
|
22
22
|
if (filenames && filenames.length) return filenames;
|
|
23
23
|
if (!existsSync(workflowsDir)) return [];
|
|
@@ -41,12 +41,12 @@ function readLines(workflowsDir, filename) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
//
|
|
45
|
-
// auto
|
|
46
|
-
//
|
|
47
|
-
//
|
|
44
|
+
// Unreplaced placeholder scan.
|
|
45
|
+
// When an auto token computation fails (e.g. application.yaml not found, empty path), the line is left
|
|
46
|
+
// untouched, so a workflow still holding __APPLICATION_YML_DIR__ ends as "install succeeded".
|
|
47
|
+
// The problem only shows at deploy time, when a directory with that name gets created.
|
|
48
48
|
//
|
|
49
|
-
//
|
|
49
|
+
// Returns [{ filename, line, token, text }] — includes line numbers so people can fix it right away.
|
|
50
50
|
export function scanUnsubstituted(workflowsDir, filenames = []) {
|
|
51
51
|
const found = [];
|
|
52
52
|
for (const filename of listWorkflowFiles(workflowsDir, filenames)) {
|
|
@@ -63,23 +63,23 @@ export function scanUnsubstituted(workflowsDir, filenames = []) {
|
|
|
63
63
|
return found;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// GITHUB_TOKEN
|
|
66
|
+
// GITHUB_TOKEN is injected by Actions automatically, so users do not register it.
|
|
67
67
|
const AUTO_SECRETS = new Set(["GITHUB_TOKEN"]);
|
|
68
68
|
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
// MODEL_API_KEY →
|
|
72
|
-
// _GITHUB_PAT_TOKEN →
|
|
69
|
+
// Secrets the workflow runs without — the fallback is documented. Mixing them with required ones under "needed to work"
|
|
70
|
+
// would make the notice itself untrustworthy, so they are kept separate.
|
|
71
|
+
// MODEL_API_KEY → if registered, external AI summary; otherwise Copilot → commit analysis (#455·#566 ladder)
|
|
72
|
+
// _GITHUB_PAT_TOKEN → if missing, merge with GITHUB_TOKEN and wake follow-up workflows directly (#551)
|
|
73
73
|
export const OPTIONAL_SECRETS = new Set(["MODEL_API_KEY", "_GITHUB_PAT_TOKEN"]);
|
|
74
74
|
|
|
75
75
|
const SECRET_RE = /secrets\.([A-Z_][A-Z0-9_]*)/g;
|
|
76
76
|
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
// SERVER_HOST
|
|
80
|
-
//
|
|
77
|
+
// GitHub secrets required by the installed workflows.
|
|
78
|
+
// Because the finish screen said nothing, values the deploy workflows actually need, like
|
|
79
|
+
// SERVER_HOST and SSH_KEY, never surfaced. Right after install the deploy cannot run,
|
|
80
|
+
// and there was no way to know it.
|
|
81
81
|
//
|
|
82
|
-
//
|
|
82
|
+
// Returns Map<secretName, string[] file names using that secret> (sorted by name)
|
|
83
83
|
export function collectRequiredSecrets(workflowsDir, filenames = []) {
|
|
84
84
|
const out = new Map();
|
|
85
85
|
for (const filename of listWorkflowFiles(workflowsDir, filenames)) {
|
|
@@ -99,8 +99,8 @@ export function collectRequiredSecrets(workflowsDir, filenames = []) {
|
|
|
99
99
|
return new Map([...out.entries()].sort(([a], [b]) => a.localeCompare(b)));
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
//
|
|
103
|
-
//
|
|
102
|
+
// Entry point run once right after install. Finds the workflow folder under targetRoot.
|
|
103
|
+
// Returns { unresolved: [...], secrets: Map, ok: boolean }
|
|
104
104
|
export function verifyInstall(targetRoot = ".", filenames = []) {
|
|
105
105
|
const workflowsDir = join(targetRoot, PATHS.workflowsDir);
|
|
106
106
|
const unresolved = scanUnsubstituted(workflowsDir, filenames);
|