projectops 4.109.0 → 4.110.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/README.md +1 -1
- package/package.json +1 -1
- package/src/commands/interactive.js +16 -3
- package/src/commands/workflows.js +27 -2
- package/src/core/branch-diff.js +67 -0
- package/src/core/branch-report.js +49 -0
- package/src/core/copy/workflows.js +65 -7
- package/src/core/options-ask.js +42 -5
- package/src/core/options-schema.js +2 -2
- package/src/core/run-trace.js +1 -0
- package/src/core/version-yml.js +46 -0
- package/src/i18n/options.en.js +7 -0
- package/src/i18n/options.ko.js +7 -0
- package/src/i18n/summary.en.js +13 -0
- package/src/i18n/summary.ko.js +13 -0
- package/src/index.js +9 -0
- package/src/ui/summary.js +30 -0
package/README.md
CHANGED
|
@@ -163,7 +163,7 @@ Supported types: `spring`, `flutter`, `react` (incl. Next.js), `node`, `python`,
|
|
|
163
163
|
Everything is on the **[docs site](https://cassiiopeia.github.io/projectops/)**, in English and [Korean](https://cassiiopeia.github.io/projectops/ko/): [Getting started](https://cassiiopeia.github.io/projectops/getting-started) · [CLI](https://cassiiopeia.github.io/projectops/cli) · [Agent Skills](https://cassiiopeia.github.io/projectops/skills) · [Versioning](https://cassiiopeia.github.io/projectops/version-control) · [Changelog](https://cassiiopeia.github.io/projectops/changelog-automation) · [SSH + Docker deploy](https://cassiiopeia.github.io/projectops/ssh-docker-deployment-guide) · [Flutter CI/CD](https://cassiiopeia.github.io/projectops/flutter-cicd-overview) · [Troubleshooting](https://cassiiopeia.github.io/projectops/troubleshooting)
|
|
164
164
|
|
|
165
165
|
<!-- AUTO-VERSION-SECTION: DO NOT EDIT MANUALLY -->
|
|
166
|
-
## Latest version : v4.
|
|
166
|
+
## Latest version : v4.110.0 (2026-11-21)
|
|
167
167
|
|
|
168
168
|
[View full version history](CHANGELOG.md)
|
|
169
169
|
|
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@ import { t, getLang, withLang } from "../i18n/index.js";
|
|
|
33
33
|
import { resolveLabelStyle } from "../core/label-style.js";
|
|
34
34
|
import { resolveRepoLanguage } from "../core/repo-language.js";
|
|
35
35
|
import { printSummary } from "../ui/summary.js";
|
|
36
|
+
import { listUnappliedBranchValues } from "../core/branch-report.js";
|
|
36
37
|
|
|
37
38
|
const CANCEL = prompts.CANCEL;
|
|
38
39
|
const isCancel = (v) => v === CANCEL || typeof v === "symbol";
|
|
@@ -141,9 +142,10 @@ export async function runInteractive(baseCtx, { cwd = process.cwd(), source = {
|
|
|
141
142
|
let deployBranch = init.deployBranch; // #456 — not recorded when empty. Only a value picked in the question is kept
|
|
142
143
|
let deployBranchReady = null; // #490 — whether the development branch was confirmed/created in this run
|
|
143
144
|
let deployBranchCreated = null; // #493 — whether the wizard created it (for the guide record)
|
|
145
|
+
let deployTriggerBranch = init.deployTriggerBranch; // #1248 — asked right after the development branch ("" = the default branch)
|
|
144
146
|
let intent = init.intent; // #485 project nature
|
|
145
147
|
// Values not asked — the saved-value rule lives in resolve-options.js
|
|
146
|
-
const { semverAuto, appRelease, closeOnRelease, excludedWorkflows, storeLocales, storeLocalesIos, storeLocalesPlay, projectsSync,
|
|
148
|
+
const { semverAuto, appRelease, closeOnRelease, excludedWorkflows, storeLocales, storeLocalesIos, storeLocalesPlay, projectsSync, ciMinutesSaver } = init;
|
|
147
149
|
const semverAutoNewlyOn = initSources.semverAutoNewlyOn;
|
|
148
150
|
// Repo text language (#769) and label style (#776): existing repos get the English switch offered only once (below).
|
|
149
151
|
let language = init.language;
|
|
@@ -174,6 +176,7 @@ export async function runInteractive(baseCtx, { cwd = process.cwd(), source = {
|
|
|
174
176
|
changelogProvider: existing?.options?.changelogProvider ?? null,
|
|
175
177
|
changelogBaseUrl: existing?.options?.changelogBaseUrl ?? null,
|
|
176
178
|
deployBranch: existing?.options?.deployBranch ?? null,
|
|
179
|
+
deployTriggerBranch: existing?.options?.deployTriggerBranch ?? null,
|
|
177
180
|
intent: existing?.options?.intent ?? null,
|
|
178
181
|
},
|
|
179
182
|
force: false, tty: realTty,
|
|
@@ -194,6 +197,7 @@ export async function runInteractive(baseCtx, { cwd = process.cwd(), source = {
|
|
|
194
197
|
deployBranch = r.deployBranch;
|
|
195
198
|
deployBranchReady = r.deployBranchReady ?? deployBranchReady; // #490
|
|
196
199
|
deployBranchCreated = r.deployBranchCreated ?? deployBranchCreated; // #493
|
|
200
|
+
deployTriggerBranch = r.deployTriggerBranch; // #1248
|
|
197
201
|
intent = r.intent;
|
|
198
202
|
}
|
|
199
203
|
|
|
@@ -251,7 +255,7 @@ export async function runInteractive(baseCtx, { cwd = process.cwd(), source = {
|
|
|
251
255
|
tempDir, types, targetRoot: cwd, defaultBranch: branch,
|
|
252
256
|
current: {
|
|
253
257
|
deploy: deployTarget, publish: publishTargets, secretBackup: includeSecretBackup,
|
|
254
|
-
codeReviewCoderabbit, aiPrSummary, changelogProvider, changelogBaseUrl, deployBranch, intent,
|
|
258
|
+
codeReviewCoderabbit, aiPrSummary, changelogProvider, changelogBaseUrl, deployBranch, deployTriggerBranch, intent,
|
|
255
259
|
},
|
|
256
260
|
force: false, tty: realTty, forceAsk: true, scope: [what],
|
|
257
261
|
io: {
|
|
@@ -271,6 +275,7 @@ export async function runInteractive(baseCtx, { cwd = process.cwd(), source = {
|
|
|
271
275
|
deployBranch = r.deployBranch;
|
|
272
276
|
deployBranchReady = r.deployBranchReady ?? deployBranchReady; // #490
|
|
273
277
|
deployBranchCreated = r.deployBranchCreated ?? deployBranchCreated; // #493
|
|
278
|
+
deployTriggerBranch = r.deployTriggerBranch; // #1248
|
|
274
279
|
intent = r.intent;
|
|
275
280
|
}
|
|
276
281
|
}
|
|
@@ -308,7 +313,7 @@ export async function runInteractive(baseCtx, { cwd = process.cwd(), source = {
|
|
|
308
313
|
// the key to keeping values the user filled in (FIREBASE_APP_ID, etc.) from being reset by default re-substitution.
|
|
309
314
|
let updateDecisions = null;
|
|
310
315
|
if (showOptional && updateRun) {
|
|
311
|
-
const liteCtx = { types, paths, deployTarget, publishTargets, repoName, resolvers, branch, deployBranch };
|
|
316
|
+
const liteCtx = { types, paths, deployTarget, publishTargets, repoName, resolvers, branch, deployBranch, deployTriggerBranch, ciMinutesSaver };
|
|
312
317
|
const conflicts = listWorkflowConflicts(liteCtx, tempDir, cwd);
|
|
313
318
|
if (conflicts.length) {
|
|
314
319
|
io.note?.(conflicts.map((c) => `• ${c.filename}`).join("\n"), t("flow.conflictsTitle", { count: conflicts.length }));
|
|
@@ -408,6 +413,12 @@ export async function runInteractive(baseCtx, { cwd = process.cwd(), source = {
|
|
|
408
413
|
else if (mode === "version") result = trace.step("install-version", () => runVersion(ctx, tempDir, cwd));
|
|
409
414
|
else if (mode === "workflows") result = trace.step("install-workflows", () => runWorkflows(ctx, tempDir, cwd, { ...hooks, trace }));
|
|
410
415
|
|
|
416
|
+
// Typed branch values not applied (#1248) — listed in the finish summary with the reason
|
|
417
|
+
const unappliedBranches = (mode === "full" || mode === "workflows") ? listUnappliedBranchValues({
|
|
418
|
+
targetRoot: cwd, defaultBranch: branch, deployBranch, deployTriggerBranch,
|
|
419
|
+
workflowsResult: result?.workflows, isBranchRecorded: result?.isBranchRecorded !== false, trace,
|
|
420
|
+
}) : [];
|
|
421
|
+
|
|
411
422
|
// IDE skills offer after integration (gate question first, default N)
|
|
412
423
|
// Update mode (#502): update only already-installed IDE skills without asking (IDEs not installed are left alone)
|
|
413
424
|
if (updateRun) {
|
|
@@ -445,6 +456,8 @@ export async function runInteractive(baseCtx, { cwd = process.cwd(), source = {
|
|
|
445
456
|
replacedBak: result?.workflows?.replacedBak ?? [], // #673 notice for files replaced without a reference point
|
|
446
457
|
legacyLeftover: migrationsResult?.confirmPending ?? [], // #809 notice for old and new generations running together
|
|
447
458
|
notInstalled: result?.workflows?.notInstalled ?? [], // #810 notice for workflows not installed
|
|
459
|
+
branchSynced: result?.workflows?.branchSynced ?? [], // #1248 kept files applied (branch-only diff)
|
|
460
|
+
unappliedBranches, defaultBranch: branch, // #1248 typed branch values not applied
|
|
448
461
|
semverAutoNewlyOn,
|
|
449
462
|
storeLocalesHint, // #843 multi-language store notice
|
|
450
463
|
verification: result?.verification, // #549 install verification result
|
|
@@ -8,7 +8,7 @@ import { copyWorkflows } from "../core/copy/workflows.js";
|
|
|
8
8
|
import { applyLabelStyle } from "../core/label-style.js";
|
|
9
9
|
import { copyScripts, copyConfigFolder, copySetupGuide } from "../core/copy/simple.js";
|
|
10
10
|
import { copyUtilModules } from "../core/copy/util.js";
|
|
11
|
-
import { convertLegacySingularType, mergeDeployValues, commentsFor } from "../core/version-yml.js";
|
|
11
|
+
import { convertLegacySingularType, mergeDeployValues, commentsFor, upsertBranchKeys } from "../core/version-yml.js";
|
|
12
12
|
import { installAgentGuide } from "../core/agent-guide.js";
|
|
13
13
|
import { verifyInstall } from "../core/verify.js";
|
|
14
14
|
|
|
@@ -31,6 +31,10 @@ export function runWorkflows(context, tempDir, targetRoot = ".", hooks = {}) {
|
|
|
31
31
|
writeFileSync(vy, upsertDeployBlock(cur, mergeDeployValues(cur, wf.deployValues), context.language)); // Existing values first (#670)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// Branch keys (#1248) — workflows mode does not regenerate version.yml, so the typed branches are written here
|
|
35
|
+
// (same result as full mode). Without a version.yml there is nowhere to record them: the run summary says so.
|
|
36
|
+
const isBranchRecorded = writeBranchKeys(vy, context, hooks.trace);
|
|
37
|
+
|
|
34
38
|
copyScripts(tempDir, targetRoot);
|
|
35
39
|
copyConfigFolder(tempDir, targetRoot);
|
|
36
40
|
applyLabelStyle(targetRoot, labelStyle); // #776 — aligns workflows (QA bot) and label definitions to the same style
|
|
@@ -55,7 +59,28 @@ export function runWorkflows(context, tempDir, targetRoot = ".", hooks = {}) {
|
|
|
55
59
|
hooks.trace?.event("verify", "required-key", name, { workflows: users });
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
return { workflows: wf, verification };
|
|
62
|
+
return { workflows: wf, verification, isBranchRecorded };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Typed branches > existing version.yml (development_branch, deploy_trigger_branch)
|
|
67
|
+
* Returns true = written or nothing to write, false = values given but no version.yml
|
|
68
|
+
*/
|
|
69
|
+
function writeBranchKeys(versionYmlPath, context, trace = null) {
|
|
70
|
+
const deployBranch = context.deployBranch || "";
|
|
71
|
+
const deployTriggerBranch = context.deployTriggerBranch || "";
|
|
72
|
+
if (!existsSync(versionYmlPath)) {
|
|
73
|
+
const hasBranchValues = !!(deployBranch || deployTriggerBranch);
|
|
74
|
+
if (hasBranchValues) trace?.event("branch", "not-recorded", "version.yml", { deployBranch, deployTriggerBranch, reason: "version-yml-missing" });
|
|
75
|
+
return !hasBranchValues;
|
|
76
|
+
}
|
|
77
|
+
const current = readFileSync(versionYmlPath, "utf8");
|
|
78
|
+
const updated = upsertBranchKeys(current, { deployBranch, deployTriggerBranch, language: context.language });
|
|
79
|
+
if (updated !== current) {
|
|
80
|
+
writeFileSync(versionYmlPath, updated);
|
|
81
|
+
trace?.event("branch", "recorded", "version.yml", { deployBranch: deployBranch || null, deployTriggerBranch: deployTriggerBranch || null });
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
59
84
|
}
|
|
60
85
|
|
|
61
86
|
// Remove the deploy: block from the existing version.yml and append a new one (idempotent).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Branch-only diff check (#1248) — tells "the user edited this workflow" apart from "only the branch names changed".
|
|
2
|
+
// A kept user-modified workflow whose sole difference from the incoming render is branch names would leave the
|
|
3
|
+
// release pipeline on the old branch (e.g. head.ref == 'main'), so the copy engine applies those files instead of skipping.
|
|
4
|
+
import { readDevelopmentBranch } from "./version-yml.js";
|
|
5
|
+
|
|
6
|
+
const BRANCH_PLACEHOLDER = "__PJOPS_BRANCH__";
|
|
7
|
+
// Branch name boundaries: letters, digits, `_`, `.`, `-` glue a name to its neighbors; `/` may precede it (refs/heads/main)
|
|
8
|
+
const NAME_BEFORE = "(?<![A-Za-z0-9_.-])";
|
|
9
|
+
const NAME_AFTER = "(?![A-Za-z0-9_/-])";
|
|
10
|
+
|
|
11
|
+
const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Branch names a workflow line may mention: standard pair + this run's values + values recorded before this run
|
|
15
|
+
* previousYml: version.yml text before this run (old default/development/deploy trigger branch)
|
|
16
|
+
*/
|
|
17
|
+
export function collectBranchNames(branches = {}, previousYml = "") {
|
|
18
|
+
const names = new Set(["main", "develop"]);
|
|
19
|
+
for (const v of [branches.defaultBranch, branches.deployBranch, branches.deployTriggerBranch]) if (v) names.add(v);
|
|
20
|
+
const text = String(previousYml || "");
|
|
21
|
+
const defaultMatch = text.match(/^\s*default_branch:\s*"([^"]+)"/m);
|
|
22
|
+
if (defaultMatch) names.add(defaultMatch[1]);
|
|
23
|
+
const developmentBranch = readDevelopmentBranch(text);
|
|
24
|
+
if (developmentBranch) names.add(developmentBranch);
|
|
25
|
+
const triggerMatch = text.match(/^\s*deploy_trigger_branch:\s*"([^"]+)"/m);
|
|
26
|
+
if (triggerMatch) names.add(triggerMatch[1]);
|
|
27
|
+
return [...names];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// One line with every branch name masked (longest first, so `main-v2` is not split into `main` + `-v2`)
|
|
31
|
+
function maskBranchNames(line, branchNames) {
|
|
32
|
+
let out = line;
|
|
33
|
+
for (const name of [...branchNames].sort((a, b) => b.length - a.length)) {
|
|
34
|
+
out = out.replace(new RegExp(`${NAME_BEFORE}${escapeRegExp(name)}${NAME_AFTER}`, "g"), BRANCH_PLACEHOLDER);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* installed <-> incoming line comparison with branch names masked
|
|
41
|
+
* Returns { isBranchOnly, branchLineCount }
|
|
42
|
+
* isBranchOnly : same line count, at least one differing line, every differing line equal once masked
|
|
43
|
+
* branchLineCount : incoming lines absent from installed whose masked form exists in installed (= same line, other branch)
|
|
44
|
+
*/
|
|
45
|
+
export function compareBranchLines(installed, incoming, branchNames) {
|
|
46
|
+
const installedLines = String(installed).split(/\r?\n/);
|
|
47
|
+
const incomingLines = String(incoming).split(/\r?\n/);
|
|
48
|
+
|
|
49
|
+
// Lines the typed branch did not reach (any line count — counted by masked lookup)
|
|
50
|
+
const installedSet = new Set(installedLines);
|
|
51
|
+
const installedMasked = new Set(installedLines.map((l) => maskBranchNames(l, branchNames)));
|
|
52
|
+
let branchLineCount = 0;
|
|
53
|
+
for (const line of incomingLines) {
|
|
54
|
+
if (installedSet.has(line)) continue;
|
|
55
|
+
if (installedMasked.has(maskBranchNames(line, branchNames))) branchLineCount++;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Branch-only: aligned line pairs, every difference disappears once masked
|
|
59
|
+
let isBranchOnly = installedLines.length === incomingLines.length;
|
|
60
|
+
let differingLineCount = 0;
|
|
61
|
+
for (let i = 0; isBranchOnly && i < incomingLines.length; i++) {
|
|
62
|
+
if (installedLines[i] === incomingLines[i]) continue;
|
|
63
|
+
differingLineCount++;
|
|
64
|
+
if (maskBranchNames(installedLines[i], branchNames) !== maskBranchNames(incomingLines[i], branchNames)) isBranchOnly = false;
|
|
65
|
+
}
|
|
66
|
+
return { isBranchOnly: isBranchOnly && differingLineCount > 0, branchLineCount };
|
|
67
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Typed branch values the run could not apply (#1248) — the run summary lists each with its reason instead of
|
|
2
|
+
// silently keeping the old branch. Reasons 4: version-yml-missing, missing-on-remote, not-pushed, kept-user-modified
|
|
3
|
+
import { branchStatus } from "./git-branch.js";
|
|
4
|
+
|
|
5
|
+
// notInstalled reason for workflows that run only on the development branch (copy/workflows.js skipNew)
|
|
6
|
+
const DEVELOPMENT_ONLY_REASON = "no-dev-branch";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed branches (development, deploy trigger) > entries not applied in this run
|
|
10
|
+
* workflowsResult: copyWorkflows counters (skippedConflicts, notInstalled)
|
|
11
|
+
* isBranchRecorded: false = values given but version.yml missing (workflows mode)
|
|
12
|
+
* Returns [{ kind: development|deploy-trigger|workflow-files, branch, reason, files[] }]
|
|
13
|
+
*/
|
|
14
|
+
export function listUnappliedBranchValues({
|
|
15
|
+
targetRoot = ".", defaultBranch = "", deployBranch = "", deployTriggerBranch = "",
|
|
16
|
+
workflowsResult = null, isBranchRecorded = true, isNonInteractive = false, trace = null,
|
|
17
|
+
}) {
|
|
18
|
+
const typedBranches = [];
|
|
19
|
+
if (deployBranch && deployBranch !== defaultBranch) typedBranches.push({ kind: "development", branch: deployBranch });
|
|
20
|
+
if (deployTriggerBranch && deployTriggerBranch !== defaultBranch) typedBranches.push({ kind: "deploy-trigger", branch: deployTriggerBranch });
|
|
21
|
+
const entries = [];
|
|
22
|
+
|
|
23
|
+
// Nowhere to record (workflows mode without version.yml)
|
|
24
|
+
if (!isBranchRecorded) {
|
|
25
|
+
for (const typed of typedBranches) entries.push({ ...typed, reason: "version-yml-missing", files: [] });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Branch missing on origin (remote null = could not check > not reported)
|
|
29
|
+
for (const typed of typedBranches) {
|
|
30
|
+
const status = branchStatus(targetRoot, typed.branch, { isNonInteractive });
|
|
31
|
+
if (!status.isRepo || status.remote !== false) continue;
|
|
32
|
+
const files = typed.kind === "development"
|
|
33
|
+
? (workflowsResult?.notInstalled ?? []).filter((n) => n.reason === DEVELOPMENT_ONLY_REASON).map((n) => n.filename)
|
|
34
|
+
: [];
|
|
35
|
+
entries.push({ ...typed, reason: status.local ? "not-pushed" : "missing-on-remote", files });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Kept user-modified workflows that still name the old branch
|
|
39
|
+
const keptFiles = (workflowsResult?.skippedConflicts ?? []).filter((k) => k.branchLineCount > 0).map((k) => k.filename);
|
|
40
|
+
if (keptFiles.length) {
|
|
41
|
+
const branch = [deployBranch, deployTriggerBranch].filter(Boolean).join(", ") || defaultBranch;
|
|
42
|
+
entries.push({ kind: "workflow-files", branch, reason: "kept-user-modified", files: keptFiles });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
trace?.event("branch", "not-applied", entry.branch, { kind: entry.kind, reason: entry.reason, files: entry.files });
|
|
47
|
+
}
|
|
48
|
+
return entries;
|
|
49
|
+
}
|
|
@@ -9,6 +9,7 @@ import { exists, copyFileSync, listYamlFiles } from "../fsutil.js";
|
|
|
9
9
|
import { isUnchanged, substituteEnv, resolveGlobalTokens, extractEnvValues } from "../wizard-env.js";
|
|
10
10
|
import { isUserModified, readBaseline, writeBaseline, sha256 } from "../baseline.js";
|
|
11
11
|
import { substituteBranches } from "../branch-sub.js";
|
|
12
|
+
import { collectBranchNames, compareBranchLines } from "../branch-diff.js";
|
|
12
13
|
import { saveIncoming, lineDiffCounts } from "../incoming.js";
|
|
13
14
|
import { branchStatus } from "../git-branch.js";
|
|
14
15
|
import { PUBLISH_TARGETS } from "../constants.js";
|
|
@@ -58,6 +59,30 @@ function utilSyncApplies(tempDir, targetRoot, types) {
|
|
|
58
59
|
return types.some((t) => exists(join(tempDir, ".github", "util", t)));
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
// version.yml before this run — holds the branch names the installed workflows were rendered with
|
|
63
|
+
function readPreviousVersionYml(targetRoot) {
|
|
64
|
+
const vy = join(targetRoot, PATHS.versionFile);
|
|
65
|
+
try { return existsSync(vy) ? readFileSync(vy, "utf8") : ""; } catch { return ""; }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Incoming render against the installed copy, same pipeline as install: template > env (installed values kept) > branches
|
|
69
|
+
// envOpts null = common files (copied raw, no env substitution)
|
|
70
|
+
function renderAgainstInstalled(srcDir, filename, envOpts, branches, installed) {
|
|
71
|
+
let content = readFileSync(join(srcDir, filename), "utf8");
|
|
72
|
+
if (envOpts) content = substituteEnv(content, { ...envOpts, values: extractEnvValues(installed), useDefaults: false });
|
|
73
|
+
return substituteBranches(content, branches, filename);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Kept user-modified workflow whose only difference from the incoming render is branch names (#1248)
|
|
77
|
+
function isBranchOnlyConflict({ srcDir, filename, workflowsDir, envOpts, branches, branchNames }) {
|
|
78
|
+
const dst = join(workflowsDir, filename);
|
|
79
|
+
if (!existsSync(dst)) return false;
|
|
80
|
+
try {
|
|
81
|
+
const installed = readFileSync(dst, "utf8");
|
|
82
|
+
return compareBranchLines(installed, renderAgainstInstalled(srcDir, filename, envOpts, branches, installed), branchNames).isBranchOnly;
|
|
83
|
+
} catch { return false; }
|
|
84
|
+
}
|
|
85
|
+
|
|
61
86
|
// 4 classes (new/unchanged/upstream/changed) — relative to the target workflow directory.
|
|
62
87
|
//
|
|
63
88
|
// upstream (#557): the user did not touch it, only the template changed. No reason to ask,
|
|
@@ -111,6 +136,15 @@ export function copyWorkflows(context, tempDir, targetRoot = ".", hooks = {}) {
|
|
|
111
136
|
const branches = { defaultBranch: branch || "main", deployBranch: deployBranch || "develop", deployTriggerBranch: deployTriggerBranch || "", ciMinutesSaver: !!ciMinutesSaver };
|
|
112
137
|
// values/useDefaults matter only on the substitution path (isUnchanged forces useDefaults:true internally — virtual comparison intact)
|
|
113
138
|
const envOptsFor = (type) => ({ type, projectPath: paths.get(type) || ".", repoName, resolvers, values: envValues, useDefaults: envUseDefaults, branches });
|
|
139
|
+
// Branch names old and new (#1248) — basis for spotting kept workflows that differ only in branch names
|
|
140
|
+
const branchNames = collectBranchNames(branches, readPreviousVersionYml(targetRoot));
|
|
141
|
+
const branchSynced = []; // Files applied because only branch names differed (original kept as .bak)
|
|
142
|
+
Object.defineProperty(counters, "branchSynced", { value: branchSynced, enumerable: false });
|
|
143
|
+
Object.defineProperty(counters, "isBranchOnly", {
|
|
144
|
+
value: (srcDir, filename, type) => isBranchOnlyConflict({
|
|
145
|
+
srcDir, filename, workflowsDir, envOpts: type === "common" ? null : envOptsFor(type), branches, branchNames }),
|
|
146
|
+
enumerable: false,
|
|
147
|
+
});
|
|
114
148
|
|
|
115
149
|
// New files not to install (#810) — the ones that came back on every install.
|
|
116
150
|
// excluded : files the user listed in version.yml options.excluded_workflows
|
|
@@ -152,14 +186,18 @@ export function copyWorkflows(context, tempDir, targetRoot = ".", hooks = {}) {
|
|
|
152
186
|
// When keeping a user-edited file, leave a copy of the new template in incoming (#654).
|
|
153
187
|
// Failures shrink to one warning line — the merge notice must not kill the whole copy.
|
|
154
188
|
const onSkip = (srcDir, filename, type) => {
|
|
155
|
-
const info = { filename, incoming: "", added: null, removed: null };
|
|
189
|
+
const info = { filename, incoming: "", added: null, removed: null, branchLineCount: 0 };
|
|
156
190
|
try {
|
|
157
191
|
// Must go through the same render as install (default substitution + branch substitution) so the diff shows only "real differences"
|
|
158
192
|
const rendered = substituteBranches(
|
|
159
193
|
substituteEnv(readFileSync(join(srcDir, filename), "utf8"), { ...envOptsFor(type), useDefaults: true }), branches, filename);
|
|
160
194
|
info.incoming = saveIncoming(targetRoot, filename, rendered);
|
|
161
|
-
const
|
|
195
|
+
const installed = readFileSync(join(workflowsDir, filename), "utf8");
|
|
196
|
+
const d = lineDiffCounts(installed, rendered);
|
|
162
197
|
info.added = d.added; info.removed = d.removed;
|
|
198
|
+
// Lines still naming the old branch (#1248) — the run summary lists the typed branch as not applied in this file
|
|
199
|
+
const againstInstalled = renderAgainstInstalled(srcDir, filename, type === "common" ? null : envOptsFor(type), branches, installed);
|
|
200
|
+
info.branchLineCount = compareBranchLines(installed, againstInstalled, branchNames).branchLineCount;
|
|
163
201
|
} catch (e) {
|
|
164
202
|
trace?.event("copy", "incoming-failed", filename, { message: e?.message || String(e) });
|
|
165
203
|
console.error(t("copy.incomingSaveFailed", { file: filename, error: e?.message || e }));
|
|
@@ -317,9 +355,23 @@ function recordBaseline(workflowsDir, targetRoot, counters, previous, templateVe
|
|
|
317
355
|
|
|
318
356
|
// Handle one changed file (exists and content changed) by decision (3 choices: backup and replace, template copy, keep).
|
|
319
357
|
// 'skip' (default): keep existing. 'backup': existing → .bak then replace. 'template': keep existing + new version as .template.yaml.
|
|
320
|
-
|
|
358
|
+
// carry(filename, installedContent): keeps the installed env values for re-substitution (per-type files only)
|
|
359
|
+
function applyDecision(decision, srcDir, workflowsDir, filename, counters, trace = null, type = "", carry = null) {
|
|
321
360
|
const src = join(srcDir, filename);
|
|
322
361
|
const dst = join(workflowsDir, filename);
|
|
362
|
+
// Only branch names differ (#1248): apply the configured branches instead of keeping the old ones (.bak kept)
|
|
363
|
+
if (decision !== "backup" && decision !== "template" && counters.isBranchOnly?.(srcDir, filename, type)) {
|
|
364
|
+
carry?.(filename, readFileSync(dst, "utf8"));
|
|
365
|
+
renameSync(dst, dst + ".bak");
|
|
366
|
+
copyFileSync(src, dst);
|
|
367
|
+
counters.copied++;
|
|
368
|
+
counters.copiedFiles?.push(filename);
|
|
369
|
+
counters.branchSynced?.push(filename);
|
|
370
|
+
trace?.event("copy", "branch-synced", filename, {
|
|
371
|
+
decision: decision ?? "skip", note: "only branch names differed — applied the configured branches, original kept as .bak",
|
|
372
|
+
});
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
323
375
|
if (decision === "backup") {
|
|
324
376
|
// Backup and replace: back up the existing file as .bak, then replace with the new version
|
|
325
377
|
renameSync(dst, dst + ".bak");
|
|
@@ -356,6 +408,9 @@ export function listWorkflowConflicts(context, tempDir, targetRoot = ".") {
|
|
|
356
408
|
const projectTypesDir = join(tempDir, PATHS.workflowsDir, PATHS.projectTypesDir);
|
|
357
409
|
const conflicts = []; // [{ filename, type }] — same order as the engine (common → type loop → server-deploy)
|
|
358
410
|
const branches = { defaultBranch: branch || "main", deployBranch: deployBranch || "develop", deployTriggerBranch: deployTriggerBranch || "", ciMinutesSaver: !!ciMinutesSaver }; // #477 — same rules as the engine
|
|
411
|
+
// Branch-only differences are applied by the engine without asking (#1248), so they are not listed
|
|
412
|
+
const branchNames = collectBranchNames(branches, readPreviousVersionYml(targetRoot));
|
|
413
|
+
const isAsked = (srcDir, filename, envOpts) => !isBranchOnlyConflict({ srcDir, filename, workflowsDir, envOpts, branches, branchNames });
|
|
359
414
|
|
|
360
415
|
// common (#560) — only files "confirmed" as touched by the user are asked about.
|
|
361
416
|
// Files that cannot be decided (no reference point) are not asked; the engine leaves a .bak and overwrites them.
|
|
@@ -366,6 +421,7 @@ export function listWorkflowConflicts(context, tempDir, targetRoot = ".") {
|
|
|
366
421
|
const dst = join(workflowsDir, f);
|
|
367
422
|
if (!existsSync(dst)) continue;
|
|
368
423
|
if (isUserModified(baseline, f, readFileSync(dst, "utf8")) !== true) continue;
|
|
424
|
+
if (!isAsked(commonDir, f, null)) continue;
|
|
369
425
|
conflicts.push({ filename: f, type: "common" });
|
|
370
426
|
}
|
|
371
427
|
}
|
|
@@ -374,11 +430,11 @@ export function listWorkflowConflicts(context, tempDir, targetRoot = ".") {
|
|
|
374
430
|
const envOpts = { type, projectPath: paths.get(type) || ".", repoName, resolvers, branches };
|
|
375
431
|
const typeDir = join(projectTypesDir, type);
|
|
376
432
|
if (exists(typeDir)) {
|
|
377
|
-
for (const f of classify(typeDir, workflowsDir, envOpts, baseline).changed) conflicts.push({ filename: f, type });
|
|
433
|
+
for (const f of classify(typeDir, workflowsDir, envOpts, baseline).changed) if (isAsked(typeDir, f, envOpts)) conflicts.push({ filename: f, type });
|
|
378
434
|
}
|
|
379
435
|
const serverDeployDir = join(typeDir, SERVER_DEPLOY_DIR);
|
|
380
436
|
if (exists(serverDeployDir) && serverDeployEnabled(deployTarget)) {
|
|
381
|
-
for (const f of classify(serverDeployDir, workflowsDir, envOpts, baseline).changed) conflicts.push({ filename: f, type });
|
|
437
|
+
for (const f of classify(serverDeployDir, workflowsDir, envOpts, baseline).changed) if (isAsked(serverDeployDir, f, envOpts)) conflicts.push({ filename: f, type });
|
|
382
438
|
}
|
|
383
439
|
}
|
|
384
440
|
return conflicts;
|
|
@@ -398,6 +454,8 @@ function copyWorkflowsForType(type, projectTypesDir, workflowsDir, ctx, counters
|
|
|
398
454
|
counters.copied++; counters.copiedFiles.push(f);
|
|
399
455
|
trace?.event("copy", "upstream-updated", f, { group, reason: "baseline-match", carried: carried.get(f)?.size ?? 0 });
|
|
400
456
|
};
|
|
457
|
+
// Branch-only sync (#1248) keeps the installed env values the same way
|
|
458
|
+
const carryEnv = (f, installed) => { try { carried.set(f, extractEnvValues(installed)); } catch { /* Use defaults */ } };
|
|
401
459
|
|
|
402
460
|
// Per-type workflows (direct children)
|
|
403
461
|
if (exists(typeDir)) {
|
|
@@ -408,7 +466,7 @@ function copyWorkflowsForType(type, projectTypesDir, workflowsDir, ctx, counters
|
|
|
408
466
|
// upstream (#557): not touched by the user, only the template changed — bring it up to date without asking.
|
|
409
467
|
for (const f of upstream) upstreamCopy(typeDir, f, type);
|
|
410
468
|
// changed: handled by the decision Map (unset = skip → same as the current force behavior)
|
|
411
|
-
for (const f of changed) applyDecision(decisions.get(f), typeDir, workflowsDir, f, counters, trace, type);
|
|
469
|
+
for (const f of changed) applyDecision(decisions.get(f), typeDir, workflowsDir, f, counters, trace, type, carryEnv);
|
|
412
470
|
}
|
|
413
471
|
|
|
414
472
|
// server-deploy — included only with deploy=docker-ssh (#439)
|
|
@@ -418,7 +476,7 @@ function copyWorkflowsForType(type, projectTypesDir, workflowsDir, ctx, counters
|
|
|
418
476
|
for (const f of unchanged) { counters.skipped++; trace?.event("copy", "skipped-unchanged", f, { group: `${type}/server-deploy` }); }
|
|
419
477
|
for (const f of newFiles) { if (counters.skipNew(serverDeployDir, f, `${type}/server-deploy`)) continue; copyFileSync(join(serverDeployDir, f), join(workflowsDir, f)); counters.copied++; counters.copiedFiles.push(f); trace?.event("copy", "copied", f, { group: `${type}/server-deploy` }); }
|
|
420
478
|
for (const f of upstream) upstreamCopy(serverDeployDir, f, `${type}/server-deploy`);
|
|
421
|
-
for (const f of changed) applyDecision(decisions.get(f), serverDeployDir, workflowsDir, f, counters, trace, type);
|
|
479
|
+
for (const f of changed) applyDecision(decisions.get(f), serverDeployDir, workflowsDir, f, counters, trace, type, carryEnv);
|
|
422
480
|
}
|
|
423
481
|
|
|
424
482
|
// publish/<target> (opt-in — #439 publish axis. The type is only the file location, not a gate)
|
package/src/core/options-ask.js
CHANGED
|
@@ -24,7 +24,12 @@ import { DEPLOY_TARGETS, PUBLISH_TARGETS, CHANGELOG_PROVIDERS, DEFAULT_CODE_REVI
|
|
|
24
24
|
// Returns state (#715 — for recording non-interactive results): not-checked · not-a-repo · exists-local · exists-remote ·
|
|
25
25
|
// declined · create-failed · push-declined · pushed · push-failed
|
|
26
26
|
// isNonInteractive: blocks credential prompts in remote lookup and push (#988 — interactive unchanged)
|
|
27
|
-
|
|
27
|
+
// missingMessageKey · createInitialValue · pushInitialValue: the deploy branch (#1248) reuses this flow with its own
|
|
28
|
+
// notice and both answers defaulting to no (its first push runs the deploy workflows)
|
|
29
|
+
export async function ensureDeployBranch({
|
|
30
|
+
targetRoot = ".", deployBranch = "", defaultBranch = "", io = {}, say = () => {}, isNonInteractive = false,
|
|
31
|
+
missingMessageKey = "options.branch.missing", createInitialValue = true, pushInitialValue = true,
|
|
32
|
+
}) {
|
|
28
33
|
if (!deployBranch || typeof io.confirm !== "function") return { created: false, pushed: false, ready: null, state: "not-checked" };
|
|
29
34
|
const st = branchStatus(targetRoot, deployBranch, { isNonInteractive });
|
|
30
35
|
if (!st.isRepo) return { created: false, pushed: false, ready: null, state: "not-a-repo" };
|
|
@@ -33,8 +38,8 @@ export async function ensureDeployBranch({ targetRoot = ".", deployBranch = "",
|
|
|
33
38
|
say(msg("options.branch.remoteOnly", { branch: deployBranch }));
|
|
34
39
|
return { created: false, pushed: false, ready: true, state: "exists-remote" };
|
|
35
40
|
}
|
|
36
|
-
say(msg(
|
|
37
|
-
const mk = await io.confirm({ message: msg("options.branch.createPrompt", { base: defaultBranch || msg("options.branch.currentFallback"), branch: deployBranch }), initialValue:
|
|
41
|
+
say(msg(missingMessageKey, { branch: deployBranch, base: defaultBranch || msg("options.branch.baseFallback") }));
|
|
42
|
+
const mk = await io.confirm({ message: msg("options.branch.createPrompt", { base: defaultBranch || msg("options.branch.currentFallback"), branch: deployBranch }), initialValue: createInitialValue });
|
|
38
43
|
if (mk !== true) {
|
|
39
44
|
say(msg("options.branch.skipped", { branch: deployBranch }));
|
|
40
45
|
return { created: false, pushed: false, ready: false, state: "declined" };
|
|
@@ -45,7 +50,7 @@ export async function ensureDeployBranch({ targetRoot = ".", deployBranch = "",
|
|
|
45
50
|
}
|
|
46
51
|
say(msg("options.branch.created", { branch: deployBranch }));
|
|
47
52
|
// #481 — name the branch in the push question (avoids "which branch is being pushed" confusion)
|
|
48
|
-
const up = await io.confirm({ message: msg("options.branch.pushPrompt", { branch: deployBranch }), initialValue:
|
|
53
|
+
const up = await io.confirm({ message: msg("options.branch.pushPrompt", { branch: deployBranch }), initialValue: pushInitialValue });
|
|
49
54
|
if (up !== true) return { created: true, pushed: false, ready: true, state: "push-declined" };
|
|
50
55
|
if (pushBranch(targetRoot, deployBranch, { isNonInteractive })) {
|
|
51
56
|
say(msg("options.branch.pushed", { branch: deployBranch }));
|
|
@@ -142,6 +147,30 @@ async function askOptionalWorkflow({ dir, icon, short, desc, current, force, tty
|
|
|
142
147
|
return include;
|
|
143
148
|
}
|
|
144
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Deploy (trigger) branch question (#1248): explain the 3 branches > typed value > existence check (create only if asked)
|
|
152
|
+
* Default = current value, else the default branch. Answering the default branch means no separate deploy branch ("").
|
|
153
|
+
* Returns { deployTriggerBranch, deployTriggerBranchReady }
|
|
154
|
+
*/
|
|
155
|
+
async function askDeployTriggerBranch({ targetRoot, defaultBranch, current, io, say }) {
|
|
156
|
+
say("");
|
|
157
|
+
say(msg("options.deployBranch.intro"));
|
|
158
|
+
say(msg("options.deployBranch.roles", { base: defaultBranch }));
|
|
159
|
+
say(msg("options.deployBranch.why", { base: defaultBranch }));
|
|
160
|
+
const ans = await io.text({ message: msg("options.deployBranch.prompt"), initialValue: current || defaultBranch });
|
|
161
|
+
const typed = (typeof ans === "string" && !isCancel(ans) && ans.trim()) ? ans.trim() : (current || defaultBranch);
|
|
162
|
+
if (typed === defaultBranch) {
|
|
163
|
+
say(msg("options.deployBranch.chosenDefault", { base: defaultBranch }));
|
|
164
|
+
return { deployTriggerBranch: "", deployTriggerBranchReady: null };
|
|
165
|
+
}
|
|
166
|
+
say(msg("options.deployBranch.chosen", { value: typed }));
|
|
167
|
+
const br = await ensureDeployBranch({
|
|
168
|
+
targetRoot, deployBranch: typed, defaultBranch, io, say,
|
|
169
|
+
missingMessageKey: "options.deployBranch.missing", createInitialValue: false, pushInitialValue: false,
|
|
170
|
+
});
|
|
171
|
+
return { deployTriggerBranch: typed, deployTriggerBranchReady: br.ready };
|
|
172
|
+
}
|
|
173
|
+
|
|
145
174
|
// Axis keys of the option questions (#483 edit scope unit) — the edit menu re-asks one axis at a time.
|
|
146
175
|
// intent (#485) is the project nature — re-asking it re-derives the deploy/publish axes.
|
|
147
176
|
export const OPTION_AXES = ["intent", "deploy", "publish", "code-review", "changelog", "release-branch", "secret"];
|
|
@@ -155,7 +184,7 @@ const INTENT_ASKS_PUBLISH = { library: true, both: true, manual: true, app: fals
|
|
|
155
184
|
// current: { deploy: string|null, publish: string[]|null, secretBackup: bool|null } — explicit CLI values
|
|
156
185
|
// scope: null means all axes (initial integration, re-ask all). A Set/array limits forceAsk to those axes (#483 edit menu isolation).
|
|
157
186
|
// Axes outside the scope keep current/saved values even with forceAsk and are not asked again.
|
|
158
|
-
// Returns { deploy, publish, secretBackup, codeReviewCoderabbit, aiPrSummary, changelogProvider, changelogBaseUrl, deployBranch }
|
|
187
|
+
// Returns { deploy, publish, secretBackup, codeReviewCoderabbit, aiPrSummary, changelogProvider, changelogBaseUrl, deployBranch, deployTriggerBranch }
|
|
159
188
|
export async function askAllOptionalWorkflows({
|
|
160
189
|
tempDir, types = [], current = {}, targetRoot = ".",
|
|
161
190
|
force = false, tty = true, io = {}, forceAsk = false, defaultBranch = "", scope = null,
|
|
@@ -174,6 +203,8 @@ export async function askAllOptionalWorkflows({
|
|
|
174
203
|
let deployBranch = current.deployBranch ?? null; // #456 release PR head branch
|
|
175
204
|
let deployBranchReady = null; // #490 — whether the branch was confirmed/created in this run (null = not checked)
|
|
176
205
|
let deployBranchCreated = null; // #493 — whether the wizard created it in this run (for the guide record)
|
|
206
|
+
let deployTriggerBranch = current.deployTriggerBranch ?? null; // #1248 deploy branch ("" = the default branch)
|
|
207
|
+
let deployTriggerBranchReady = null; // #1248 — same meaning as deployBranchReady
|
|
177
208
|
let intent = current.intent ?? null; // #485 project nature (app/library/both/none/manual)
|
|
178
209
|
|
|
179
210
|
// Type combinations with both axes empty (#498 — basic alone, or a mobile app like flutter alone) have neither server deploy
|
|
@@ -208,6 +239,7 @@ export async function askAllOptionalWorkflows({
|
|
|
208
239
|
if (changelogBaseUrl === null && saved.changelogBaseUrl !== null) changelogBaseUrl = saved.changelogBaseUrl;
|
|
209
240
|
// #456 reuse the saved development branch
|
|
210
241
|
if (deployBranch === null && saved.deployBranch != null) deployBranch = saved.deployBranch;
|
|
242
|
+
if (deployTriggerBranch === null && saved.deployTriggerBranch != null) deployTriggerBranch = saved.deployTriggerBranch;
|
|
211
243
|
// #485 reuse the saved intent — if missing, infer it from saved deploy/publish (compat with old version.yml)
|
|
212
244
|
if (intent === null) intent = saved.intent ?? inferIntent(saved.deploy, saved.publish);
|
|
213
245
|
}
|
|
@@ -414,6 +446,9 @@ export async function askAllOptionalWorkflows({
|
|
|
414
446
|
const br = await ensureDeployBranch({ targetRoot, deployBranch, defaultBranch, io, say });
|
|
415
447
|
deployBranchReady = br.ready;
|
|
416
448
|
deployBranchCreated = br.created;
|
|
449
|
+
// Deploy branch right after the development branch (#1248) — typed by the user, never created without asking
|
|
450
|
+
({ deployTriggerBranch, deployTriggerBranchReady } = await askDeployTriggerBranch({
|
|
451
|
+
targetRoot, defaultBranch: base, current: deployTriggerBranch, io, say }));
|
|
417
452
|
}
|
|
418
453
|
}
|
|
419
454
|
|
|
@@ -439,6 +474,8 @@ export async function askAllOptionalWorkflows({
|
|
|
439
474
|
deployBranch: deployBranch ?? "",
|
|
440
475
|
deployBranchReady, // #490 — true = confirmed/created, false = declined/failed, null = not checked
|
|
441
476
|
deployBranchCreated, // #493 — true = created by the wizard in this run, null = not checked
|
|
477
|
+
deployTriggerBranch: deployTriggerBranch ?? "", // #1248 — "" = deploys run on the default branch
|
|
478
|
+
deployTriggerBranchReady, // #1248 — null = not asked or not checked
|
|
442
479
|
|
|
443
480
|
// #485 intent — settled value first, else inferred from the final deploy/publish (fixes basic and non-interactive paths)
|
|
444
481
|
intent: intent ?? inferIntent(finalDeploy, finalPublish) ?? "manual",
|
|
@@ -194,13 +194,13 @@ export const FLAG_DETAILS = {
|
|
|
194
194
|
},
|
|
195
195
|
"--deploy-trigger-branch": {
|
|
196
196
|
when: "Only if deploys must run from a branch other than the default branch (for example develop > main > deploy).",
|
|
197
|
-
effect: "Writes metadata.template.options.deploy_trigger_branch and rewrites main to that branch in the deploy workflows only: push trigger, checkout ref, git pull, branch check. Version bump, README version, release notes and issue closing keep following the default branch.
|
|
197
|
+
effect: "Writes metadata.template.options.deploy_trigger_branch and rewrites main to that branch in the deploy workflows only: push trigger, checkout ref, git pull, branch check. Version bump, README version, release notes and issue closing keep following the default branch. Written in every mode, including workflows. The branch is NOT created by this flag; if it is missing on origin, the run summary says so. The interactive wizard asks this right after the development branch.",
|
|
198
198
|
omitted: "The deploy workflows follow the default branch, unchanged.",
|
|
199
199
|
example: "npx projectops --mode workflows --force --deploy-trigger-branch deploy",
|
|
200
200
|
},
|
|
201
201
|
"--deploy-branch": {
|
|
202
202
|
when: "Only if your development branch is not named develop.",
|
|
203
|
-
effect: "Writes metadata.development_branch (and the old deploy_branch with the same value) and rewrites the branch name inside the installed workflows (release PR head, CI triggers, PR summary base). The branch is NOT created by this flag (use --create-development-branch).",
|
|
203
|
+
effect: "Writes metadata.development_branch (and the old deploy_branch with the same value) in every mode, including workflows, and rewrites the branch name inside the installed workflows (release PR head, CI triggers, PR summary base). Workflows you modified whose only difference is the branch name are updated too (original kept as .bak). The branch is NOT created by this flag (use --create-development-branch).",
|
|
204
204
|
omitted: "develop.",
|
|
205
205
|
example: "npx projectops --mode full --force --deploy-branch dev",
|
|
206
206
|
caution: "Despite the name this is the development branch (head of the release PR), not the branch that deploys. The deploying branch is the repository default branch.",
|
package/src/core/run-trace.js
CHANGED
|
@@ -52,6 +52,7 @@ const ERROR_ACTIONS = new Set(["error", "failed"]);
|
|
|
52
52
|
const WARN_ACTIONS = new Set([
|
|
53
53
|
"unresolved", "cancelled", "skipped-conflict", "leftover-old-gen",
|
|
54
54
|
"neutralized", "detected", "replaced-bak", "incoming-failed", "baseline-failed",
|
|
55
|
+
"branch-synced", "not-applied", "not-recorded", // #1248 typed branch values
|
|
55
56
|
]);
|
|
56
57
|
const DEBUG_ACTIONS = new Set([
|
|
57
58
|
"copied", "skipped-unchanged", "excluded", "substituted", "branch-substituted",
|
package/src/core/version-yml.js
CHANGED
|
@@ -394,6 +394,52 @@ export function readDevelopmentBranch(content) {
|
|
|
394
394
|
return null;
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
/**
|
|
398
|
+
* Branch keys in an existing version.yml: development_branch + deploy_branch, deploy_trigger_branch (#1248)
|
|
399
|
+
* For modes that do not regenerate version.yml (workflows), so flags and the wizard give the same file as full mode
|
|
400
|
+
* deployBranch : "" = leave as is
|
|
401
|
+
* deployTriggerBranch : "" = remove the key (deploys follow the default branch), otherwise set
|
|
402
|
+
* Returns the new content (unchanged when nothing applies)
|
|
403
|
+
*/
|
|
404
|
+
export function upsertBranchKeys(content, { deployBranch = "", deployTriggerBranch = "", language = null } = {}) {
|
|
405
|
+
const C = commentsFor(language === "ko" ? "ko" : "en");
|
|
406
|
+
const eol = String(content).includes("\r\n") ? "\r\n" : "\n";
|
|
407
|
+
const lines = String(content).split(/\r?\n/);
|
|
408
|
+
const findLine = (re) => lines.findIndex((l) => !l.startsWith("#") && re.test(l));
|
|
409
|
+
|
|
410
|
+
// metadata.development_branch / deploy_branch (both keys, same value — #915)
|
|
411
|
+
if (deployBranch) {
|
|
412
|
+
const developmentLine = ` development_branch: "${deployBranch}"`;
|
|
413
|
+
const legacyLine = ` deploy_branch: "${deployBranch}" # ${C.legacyDeployBranch}`;
|
|
414
|
+
const developmentIndex = findLine(/^ {2}development_branch:/);
|
|
415
|
+
const legacyIndex = findLine(/^ {2}deploy_branch:/);
|
|
416
|
+
if (developmentIndex >= 0) lines[developmentIndex] = developmentLine;
|
|
417
|
+
if (legacyIndex >= 0) lines[legacyIndex] = legacyLine;
|
|
418
|
+
if (developmentIndex < 0 || legacyIndex < 0) {
|
|
419
|
+
// Missing keys go right after default_branch (else right after metadata:), same order as buildVersionYml
|
|
420
|
+
const anchorIndex = findLine(/^ {2}default_branch:/) >= 0 ? findLine(/^ {2}default_branch:/) : findLine(/^metadata:/);
|
|
421
|
+
const missing = [];
|
|
422
|
+
if (developmentIndex < 0) missing.push(developmentLine);
|
|
423
|
+
if (legacyIndex < 0) missing.push(legacyLine);
|
|
424
|
+
if (anchorIndex >= 0) lines.splice(anchorIndex + 1, 0, ...missing);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// metadata.template.options.deploy_trigger_branch
|
|
429
|
+
const triggerIndex = findLine(/^ {6}deploy_trigger_branch:/);
|
|
430
|
+
if (deployTriggerBranch) {
|
|
431
|
+
const triggerLine = ` deploy_trigger_branch: "${deployTriggerBranch}" # ${C.deployTriggerBranch}`;
|
|
432
|
+
if (triggerIndex >= 0) lines[triggerIndex] = triggerLine;
|
|
433
|
+
else {
|
|
434
|
+
const optionsIndex = findLine(/^ {4}options:\s*$/);
|
|
435
|
+
if (optionsIndex >= 0) lines.splice(optionsIndex + 1, 0, triggerLine);
|
|
436
|
+
}
|
|
437
|
+
} else if (triggerIndex >= 0) {
|
|
438
|
+
lines.splice(triggerIndex, 1);
|
|
439
|
+
}
|
|
440
|
+
return lines.join(eol);
|
|
441
|
+
}
|
|
442
|
+
|
|
397
443
|
// Extract values from the existing version.yml (line regexes, avoiding false hits on comment lines).
|
|
398
444
|
export function parseExisting(content) {
|
|
399
445
|
const text = String(content || "");
|
package/src/i18n/options.en.js
CHANGED
|
@@ -71,6 +71,13 @@ export default {
|
|
|
71
71
|
"options.devBranch.hint": " Unless you have a reason, keep develop.",
|
|
72
72
|
"options.devBranch.prompt": "Development (release source) branch",
|
|
73
73
|
"options.devBranch.chosen": "Development (release source) branch: {value}",
|
|
74
|
+
"options.deployBranch.intro": "Which branch should run the deploys (store upload, server deploy)?",
|
|
75
|
+
"options.deployBranch.roles": " Default branch '{base}': version bump and release notes land here. Deploy branch: a push to it runs the deploy workflows.",
|
|
76
|
+
"options.deployBranch.why": " Keep '{base}' to deploy from the default branch as today. A separate branch (e.g. deploy) keeps the CI version and changelog commits on the default branch apart from deploys.",
|
|
77
|
+
"options.deployBranch.prompt": "Deploy branch",
|
|
78
|
+
"options.deployBranch.chosen": "Deploy branch: {value}",
|
|
79
|
+
"options.deployBranch.chosenDefault": "Deploy branch: {base} (the default branch, no separate deploy branch)",
|
|
80
|
+
"options.deployBranch.missing": "Deploy branch '{branch}' does not exist yet. The deploy workflows will run on it once it exists, and the first push to it runs them (store upload, server deploy).",
|
|
74
81
|
"options.secret.short": "Secret server backup",
|
|
75
82
|
"options.secret.desc": "A workflow that uploads config files stored in GitHub Secrets to a server over SSH and keeps their history.",
|
|
76
83
|
"paths.multi": "Multi-type project detected: {total} types in total",
|
package/src/i18n/options.ko.js
CHANGED
|
@@ -71,6 +71,13 @@ export default {
|
|
|
71
71
|
"options.devBranch.hint": " 특별한 이유가 없으면 develop 그대로 두세요.",
|
|
72
72
|
"options.devBranch.prompt": "개발(릴리스 소스) 브랜치",
|
|
73
73
|
"options.devBranch.chosen": "개발(릴리스 소스) 브랜치: {value}",
|
|
74
|
+
"options.deployBranch.intro": "배포(스토어 업로드, 서버 배포)를 실행할 브랜치는 무엇인가요?",
|
|
75
|
+
"options.deployBranch.roles": " 기본 브랜치 '{base}': 버전 올림과 릴리스 노트가 여기에 쌓입니다. 배포 브랜치: 여기에 push되면 배포 워크플로가 실행됩니다.",
|
|
76
|
+
"options.deployBranch.why": " 지금처럼 기본 브랜치에서 배포하려면 '{base}' 그대로 두세요. 별도 브랜치(예: deploy)를 두면 기본 브랜치에 쌓이는 CI 버전·체인지로그 커밋과 배포가 분리됩니다.",
|
|
77
|
+
"options.deployBranch.prompt": "배포 브랜치",
|
|
78
|
+
"options.deployBranch.chosen": "배포 브랜치: {value}",
|
|
79
|
+
"options.deployBranch.chosenDefault": "배포 브랜치: {base} (기본 브랜치, 별도 배포 브랜치 없음)",
|
|
80
|
+
"options.deployBranch.missing": "배포 브랜치 '{branch}'가 아직 없습니다. 브랜치가 생기면 배포 워크플로가 그 브랜치에서 실행되고, 처음 push할 때 배포(스토어 업로드, 서버 배포)가 실행됩니다.",
|
|
74
81
|
"options.secret.short": "Secret 서버 백업",
|
|
75
82
|
"options.secret.desc": "GitHub Secret에 저장한 설정 파일을 SSH로 서버에 업로드·이력관리하는 워크플로우입니다.",
|
|
76
83
|
"paths.multi": "멀티타입 프로젝트가 감지되었습니다. 총 {total}개 타입",
|
package/src/i18n/summary.en.js
CHANGED
|
@@ -33,6 +33,19 @@ export default {
|
|
|
33
33
|
"done.notInstalled.deleted-by-user": "you deleted it earlier",
|
|
34
34
|
"done.notInstalled.no-dev-branch": "only runs on {branch}, which this repo does not have",
|
|
35
35
|
"done.notInstalledHint": "To install one anyway, copy the file shown above. To stop being told, add it to options.excluded_workflows in version.yml.",
|
|
36
|
+
// #1248 typed branch values
|
|
37
|
+
"done.branchSyncedTitle": "Applied the branch settings to {count} workflow(s) you had modified: only branch names differed (originals saved as .bak)",
|
|
38
|
+
"done.branchNotAppliedTitle": "{count} typed branch value(s) were not applied",
|
|
39
|
+
"done.branchKind.development": "Development branch '{branch}'",
|
|
40
|
+
"done.branchKind.deploy-trigger": "Deploy branch '{branch}'",
|
|
41
|
+
"done.branchKind.workflow-files": "Branch setting ({branch})",
|
|
42
|
+
"done.branchReason.version-yml-missing": "not recorded: this repo has no version.yml. Run --mode version (or full) first, then run again.",
|
|
43
|
+
"done.branchReason.missing-on-remote": "does not exist on origin yet. Workflows that run on it wait until you create and push it.",
|
|
44
|
+
"done.branchReason.not-pushed": "exists only locally. Push it so the workflows can run on it: git push -u origin {branch}",
|
|
45
|
+
"done.branchReason.kept-user-modified": "not applied in workflows you modified (they still name the old branch). Merge the incoming copy shown above:",
|
|
46
|
+
"done.branchFilesSkipped": "not installed because the branch is missing:",
|
|
47
|
+
"done.branchDeployWarn": "The first push to the deploy branch runs the deploy workflows (store upload, server deploy). Create it when you are ready to deploy.",
|
|
48
|
+
"done.branchCreateHint": "Create it from the default branch: git branch {branch} {base} && git push -u origin {branch}",
|
|
36
49
|
"done.legacyTitle": "{count} retired workflow(s) are still installed and run alongside their replacements",
|
|
37
50
|
"done.legacyHint": "Delete them once the new workflow works, or rerun with --remove-legacy to rename them to .bak.",
|
|
38
51
|
"done.replacedHint": "If you had edits, copy them over from the .bak files. (The update baseline is recorded by this run.)",
|
package/src/i18n/summary.ko.js
CHANGED
|
@@ -33,6 +33,19 @@ export default {
|
|
|
33
33
|
"done.notInstalled.deleted-by-user": "예전에 직접 지운 파일",
|
|
34
34
|
"done.notInstalled.no-dev-branch": "{branch} 브랜치에서만 실행되는데 이 레포에는 그 브랜치가 없음",
|
|
35
35
|
"done.notInstalledHint": "그래도 쓰려면 위에 적힌 파일을 복사하세요. 안내를 그만 보려면 version.yml 의 options.excluded_workflows 에 추가하세요.",
|
|
36
|
+
// #1248 입력한 브랜치 값
|
|
37
|
+
"done.branchSyncedTitle": "직접 수정한 워크플로 {count}개에 브랜치 설정을 반영했습니다: 브랜치 이름만 달랐습니다 (원본은 .bak 으로 백업)",
|
|
38
|
+
"done.branchNotAppliedTitle": "입력한 브랜치 값 {count}개를 반영하지 못했습니다",
|
|
39
|
+
"done.branchKind.development": "개발 브랜치 '{branch}'",
|
|
40
|
+
"done.branchKind.deploy-trigger": "배포 브랜치 '{branch}'",
|
|
41
|
+
"done.branchKind.workflow-files": "브랜치 설정 ({branch})",
|
|
42
|
+
"done.branchReason.version-yml-missing": "기록하지 못함: 이 레포에 version.yml 이 없습니다. --mode version (또는 full) 을 먼저 실행한 뒤 다시 실행하세요.",
|
|
43
|
+
"done.branchReason.missing-on-remote": "origin 에 아직 없습니다. 이 브랜치에서 도는 워크플로는 브랜치를 만들어 push할 때까지 실행되지 않습니다.",
|
|
44
|
+
"done.branchReason.not-pushed": "로컬에만 있습니다. 워크플로가 돌 수 있게 push하세요: git push -u origin {branch}",
|
|
45
|
+
"done.branchReason.kept-user-modified": "직접 수정한 워크플로에는 반영하지 못했습니다 (아직 이전 브랜치 이름). 위에 안내한 새 템플릿 사본과 합치세요:",
|
|
46
|
+
"done.branchFilesSkipped": "브랜치가 없어 설치하지 않은 워크플로:",
|
|
47
|
+
"done.branchDeployWarn": "배포 브랜치에 처음 push하면 배포 워크플로(스토어 업로드, 서버 배포)가 실행됩니다. 배포할 준비가 됐을 때 만드세요.",
|
|
48
|
+
"done.branchCreateHint": "기본 브랜치에서 만들기: git branch {branch} {base} && git push -u origin {branch}",
|
|
36
49
|
"done.legacyTitle": "은퇴한 구세대 워크플로우 {count}개가 남아 신형과 함께 실행됩니다",
|
|
37
50
|
"done.legacyHint": "신형이 동작하는 걸 확인한 뒤 지우거나, --remove-legacy 로 다시 실행하면 .bak 으로 치웁니다.",
|
|
38
51
|
"done.replacedHint": "직접 수정한 내용이 있었다면 .bak 에서 옮겨 오세요. (업데이트 기준점은 이번 실행으로 새로 기록됩니다)",
|
package/src/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { resolveProjectPaths, markerForType } from "./core/paths-resolve.js";
|
|
|
23
23
|
import { resolveOptions } from "./core/resolve-options.js";
|
|
24
24
|
import { detectStoreLocalesHint } from "./core/store-locales-hint.js";
|
|
25
25
|
import { runDevelopmentBranchStep } from "./core/development-branch.js";
|
|
26
|
+
import { listUnappliedBranchValues } from "./core/branch-report.js";
|
|
26
27
|
import { printBannerCompact } from "./ui/banner.js";
|
|
27
28
|
import { printSummary } from "./ui/summary.js";
|
|
28
29
|
import { runFull } from "./commands/full.js";
|
|
@@ -240,6 +241,7 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
240
241
|
changelogProvider: context.changelogProvider,
|
|
241
242
|
coderabbit: context.codeReviewCoderabbit,
|
|
242
243
|
deployBranch: context.deployBranch || "(not given, falls back to develop)",
|
|
244
|
+
deployTriggerBranch: context.deployTriggerBranch || "(not given, the default branch)",
|
|
243
245
|
recordMode: context.recordMode,
|
|
244
246
|
});
|
|
245
247
|
trace.event("resolve", "semver-auto", String(context.semverAuto), {
|
|
@@ -317,6 +319,11 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
317
319
|
say: (line) => console.error(line),
|
|
318
320
|
});
|
|
319
321
|
const isDevelopmentBranchReady = developmentBranchResult ? developmentBranchResult.status !== "failed" : null;
|
|
322
|
+
// Typed branch values not applied (#1248) — after branch creation, so a branch created just now is not reported
|
|
323
|
+
const unappliedBranches = recordArtifacts ? listUnappliedBranchValues({
|
|
324
|
+
targetRoot: cwd, defaultBranch: branch, deployBranch: context.deployBranch, deployTriggerBranch: context.deployTriggerBranch,
|
|
325
|
+
workflowsResult: result?.workflows, isBranchRecorded: result?.isBranchRecorded !== false, isNonInteractive: true, trace,
|
|
326
|
+
}) : [];
|
|
320
327
|
|
|
321
328
|
// Migration record (#493/#494) — Layer 2/3 trace files + Layer 1 guide entry
|
|
322
329
|
let migrationGuidePath = null;
|
|
@@ -349,6 +356,8 @@ async function runCore(argv, { cwd = process.cwd(), source = { type: "git" }, cl
|
|
|
349
356
|
replacedBak: result?.workflows?.replacedBak ?? [], // #673 notice for files replaced without a reference point
|
|
350
357
|
legacyLeftover: migrationsResult?.confirmPending ?? [], // #809 notice for old and new generations running together
|
|
351
358
|
notInstalled: result?.workflows?.notInstalled ?? [], // #810 notice for workflows not installed
|
|
359
|
+
branchSynced: result?.workflows?.branchSynced ?? [], // #1248 kept files applied (branch-only diff)
|
|
360
|
+
unappliedBranches, defaultBranch: branch, // #1248 typed branch values not applied
|
|
352
361
|
semverAutoNewlyOn: sources.semverAutoNewlyOn && context.semverAuto === true, // Notice that the update turned it on
|
|
353
362
|
storeLocalesHint, // #843 multi-language store notice
|
|
354
363
|
verification: result?.verification, // #549 post-install verification result (only in full/workflows modes)
|
package/src/ui/summary.js
CHANGED
|
@@ -147,6 +147,22 @@ export function printSummary(ctx, targetRoot = ".", write = null) {
|
|
|
147
147
|
err(` ${t("done.notInstalledHint")}`);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
// Kept user-modified workflows that differed only in branch names were applied (#1248).
|
|
151
|
+
const branchSynced = ctx?.branchSynced ?? [];
|
|
152
|
+
if (branchSynced.length > 0) {
|
|
153
|
+
err("");
|
|
154
|
+
err(` ${CYAN}ℹ️ ${t("done.branchSyncedTitle", { count: branchSynced.length })}${NC}`);
|
|
155
|
+
for (const f of branchSynced) err(` 🔀 .github/workflows/${f} (.bak)`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Typed branch values this run could not apply, with the reason (#1248) — never keep the old branch silently.
|
|
159
|
+
const unappliedBranches = ctx?.unappliedBranches ?? [];
|
|
160
|
+
if (unappliedBranches.length > 0) {
|
|
161
|
+
err("");
|
|
162
|
+
err(` ${YELLOW}⚠️ ${t("done.branchNotAppliedTitle", { count: unappliedBranches.length })}${NC}`);
|
|
163
|
+
for (const entry of unappliedBranches) printUnappliedBranch(entry, ctx?.defaultBranch || "main", err);
|
|
164
|
+
}
|
|
165
|
+
|
|
150
166
|
// Retired old-generation workflows still installed: they run next to their replacements (#809).
|
|
151
167
|
const legacy = ctx?.legacyLeftover ?? [];
|
|
152
168
|
if (legacy.length > 0) {
|
|
@@ -327,3 +343,17 @@ export function printSummary(ctx, targetRoot = ".", write = null) {
|
|
|
327
343
|
err("");
|
|
328
344
|
}
|
|
329
345
|
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* One unapplied branch entry: kind + reason > files > next step (create command, deploy warning)
|
|
349
|
+
*/
|
|
350
|
+
function printUnappliedBranch(entry, defaultBranch, err) {
|
|
351
|
+
const { kind, branch, reason, files = [] } = entry;
|
|
352
|
+
err(` ⏭️ ${t(`done.branchKind.${kind}`, { branch })}: ${t(`done.branchReason.${reason}`, { branch })}`);
|
|
353
|
+
if (reason === "missing-on-remote" && files.length) err(` ${t("done.branchFilesSkipped")}`);
|
|
354
|
+
for (const f of files) err(` • ${f}`);
|
|
355
|
+
if (reason === "missing-on-remote") {
|
|
356
|
+
err(` ${t("done.branchCreateHint", { branch, base: defaultBranch })}`);
|
|
357
|
+
if (kind === "deploy-trigger") err(` ${t("done.branchDeployWarn")}`);
|
|
358
|
+
}
|
|
359
|
+
}
|