projectops 4.109.0 → 4.110.1
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 +2 -2
- package/package.json +1 -1
- package/src/cli/help.js +19 -4
- package/src/commands/interactive.js +16 -3
- package/src/commands/workflows.js +27 -2
- package/src/context.js +2 -4
- package/src/core/branch-diff.js +67 -0
- package/src/core/branch-report.js +49 -0
- package/src/core/branch-sub.js +5 -9
- package/src/core/copy/workflows.js +65 -7
- package/src/core/detect-fs.js +6 -5
- package/src/core/detect.js +72 -32
- package/src/core/ide/skills-copy.js +2 -2
- package/src/core/options-ask.js +47 -26
- package/src/core/options-schema.js +2 -2
- package/src/core/paths-resolve.js +11 -26
- package/src/core/project-types.js +98 -0
- package/src/core/project-types.json +215 -0
- package/src/core/run-trace.js +1 -0
- package/src/core/version-yml.js +52 -14
- 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/prompts.js +2 -1
- package/src/ui/summary.js +30 -0
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ If you only need one piece of this, a smaller tool may suit you better ([full co
|
|
|
150
150
|
- **Frequent releases.** `latest` follows `main`; `npx projectops@<version>` pins the installer only, not the workflow templates.
|
|
151
151
|
- **Server deploys assume a Docker host reachable over SSH.** A personal access token is optional ([setup](https://cassiiopeia.github.io/projectops/getting-started)).
|
|
152
152
|
|
|
153
|
-
Supported types:
|
|
153
|
+
Supported types: <!-- generated: project-types:types-list -->`flutter`, `spring`, `python`, `react`, `react-native`, `react-native-expo`, `node`, `basic`<!-- /generated --> (`react` includes Next.js). Comment commands such as `@projectops server build` and `@projectops build app`: [PR Preview](https://cassiiopeia.github.io/projectops/pr-preview), [Flutter builds](https://cassiiopeia.github.io/projectops/flutter-test-build-trigger), [Issue automation](https://cassiiopeia.github.io/projectops/issue-automation).
|
|
154
154
|
|
|
155
155
|
## Community
|
|
156
156
|
|
|
@@ -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.1 (2026-11-21)
|
|
167
167
|
|
|
168
168
|
[View full version history](CHANGELOG.md)
|
|
169
169
|
|
package/package.json
CHANGED
package/src/cli/help.js
CHANGED
|
@@ -5,6 +5,23 @@
|
|
|
5
5
|
// Value lists and per-flag details live in src/core/options-schema.js (source of truth); `--mode options --json` prints them as is.
|
|
6
6
|
// Every flag in args.js must appear in both the English and Korean help texts — add new flags to both.
|
|
7
7
|
import { getLang } from "../i18n/index.js";
|
|
8
|
+
import { VALID_TYPES } from "../core/project-types.js";
|
|
9
|
+
|
|
10
|
+
// Help column where option descriptions start
|
|
11
|
+
const HELP_DESCRIPTION_INDENT = " ".repeat(27);
|
|
12
|
+
// Type ids per help line (keeps lines under 80 columns)
|
|
13
|
+
const TYPES_PER_HELP_LINE = 4;
|
|
14
|
+
|
|
15
|
+
// "supported:" list from the registry, wrapped and aligned under the first id
|
|
16
|
+
function typeListLines(prefix) {
|
|
17
|
+
const lines = [];
|
|
18
|
+
for (let index = 0; index < VALID_TYPES.length; index += TYPES_PER_HELP_LINE) {
|
|
19
|
+
// Hangul and other wide characters take two terminal columns
|
|
20
|
+
const lead = index === 0 ? prefix : " ".repeat(prefix.length + (prefix.match(/[^\x00-\x7f]/g) || []).length);
|
|
21
|
+
lines.push(HELP_DESCRIPTION_INDENT + lead + VALID_TYPES.slice(index, index + TYPES_PER_HELP_LINE).join(" "));
|
|
22
|
+
}
|
|
23
|
+
return lines.join("\n");
|
|
24
|
+
}
|
|
8
25
|
|
|
9
26
|
const HELP_EN = `projectops — installs and updates GitHub automation (versioning, release notes, CI/CD, issue templates, agent skills)
|
|
10
27
|
|
|
@@ -34,8 +51,7 @@ Modes (-m, --mode MODE)
|
|
|
34
51
|
|
|
35
52
|
Options
|
|
36
53
|
-t, --type CSV project types, comma separated, first = primary (e.g. spring,react,python)
|
|
37
|
-
|
|
38
|
-
react-native-expo node python basic
|
|
54
|
+
${typeListLines("supported: ")}
|
|
39
55
|
omitted: auto-detected from files in the repo root (nothing found = basic)
|
|
40
56
|
(next was merged into react: use react for Next.js)
|
|
41
57
|
--project-version V initial version, only when version.yml does not exist yet (an existing value is always kept)
|
|
@@ -120,8 +136,7 @@ AI agent 나 CI 는 항상 이렇게 실행한다: npx projectops --mode <
|
|
|
120
136
|
|
|
121
137
|
옵션
|
|
122
138
|
-t, --type CSV 프로젝트 타입 csv, 첫 항목이 primary (예: spring,react,python)
|
|
123
|
-
|
|
124
|
-
react-native-expo node python basic
|
|
139
|
+
${typeListLines("지원: ")}
|
|
125
140
|
생략: 레포 루트의 파일로 자동 감지 (못 찾으면 basic)
|
|
126
141
|
(next는 react로 흡수됨 — Next.js 프로젝트는 react 사용)
|
|
127
142
|
--project-version V 초기 버전. version.yml 이 아직 없을 때만 쓰인다 (기존 값은 항상 유지)
|
|
@@ -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).
|
package/src/context.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// Wizard global state made explicit as one object (replaces the bash global variables)
|
|
2
2
|
// The next type was merged into react in v4.1.0 (breaking)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"react-native", "react-native-expo", "node", "python", "basic",
|
|
6
|
-
];
|
|
3
|
+
// Project types come from the registry (src/core/project-types.json, #1244)
|
|
4
|
+
export { VALID_TYPES } from "./core/project-types.js";
|
|
7
5
|
|
|
8
6
|
export const DEFAULT_VERSION = "1.3.14"; // When the template version is unknown (banner fallback — not used for breaking comparison)
|
|
9
7
|
|
|
@@ -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
|
+
}
|
package/src/core/branch-sub.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// 7) CI minutes saver (#1114): with ciMinutesSaver, ci-minutes-sub.js (before branch substitution, on the raw template)
|
|
14
14
|
|
|
15
15
|
import { substituteCiMinutesSaver } from "./ci-minutes-sub.js";
|
|
16
|
+
import { deployTriggerWorkflows } from "./project-types.js";
|
|
16
17
|
|
|
17
18
|
// main (default branch) substitutions
|
|
18
19
|
function subDefault(s, db) {
|
|
@@ -33,15 +34,10 @@ function subDeploy(s, dev) {
|
|
|
33
34
|
|
|
34
35
|
// Workflows that deploy when pushed (exact file name match). Used only in repos that split the default and deploy branches.
|
|
35
36
|
// Common workflows (version bump · README version · release notes · issue close) are not here: they follow the default branch.
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"PROJECT-REACT-NATIVE-EXPO-ANDROID-PLAYSTORE-CICD.yaml", "PROJECT-REACT-NATIVE-EXPO-IOS-TESTFLIGHT.yaml",
|
|
41
|
-
"PROJECT-SPRING-SIMPLE-CICD.yaml", "PROJECT-PYTHON-SIMPLE-CICD.yaml", "PROJECT-REACT-CICD.yaml",
|
|
42
|
-
"PROJECT-COMMON-VERCEL-DEPLOY.yaml", "PROJECT-NODE-NPM-PUBLISH.yaml",
|
|
43
|
-
"PROJECT-SPRING-NEXUS-PUBLISH.yml", "PROJECT-SPRING-GITHUB-PACKAGES-PUBLISH.yml",
|
|
44
|
-
]);
|
|
37
|
+
// Type-owned files come from the registry (deploy_trigger_workflows); a missing file deploys from the default branch.
|
|
38
|
+
// Vercel is the only type-independent one
|
|
39
|
+
const TYPE_INDEPENDENT_DEPLOY_WORKFLOWS = ["PROJECT-COMMON-VERCEL-DEPLOY.yaml"];
|
|
40
|
+
export const DEPLOY_TRIGGER_WORKFLOWS = new Set([...deployTriggerWorkflows(), ...TYPE_INDEPENDENT_DEPLOY_WORKFLOWS]);
|
|
45
41
|
|
|
46
42
|
// Deploy trigger branch substitution: main in triggers · checkout ref · pull · run conditions
|
|
47
43
|
function subDeployTrigger(s, trigger) {
|
|
@@ -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/detect-fs.js
CHANGED
|
@@ -6,6 +6,7 @@ import { execFileSync } from "node:child_process";
|
|
|
6
6
|
import { detectTypesFromMarkers, detectVersionFromFiles, suggestTypesByExtScan } from "./detect.js";
|
|
7
7
|
import { parseExisting, convertLegacySingularType } from "./version-yml.js";
|
|
8
8
|
import { VALID_TYPES } from "../context.js";
|
|
9
|
+
import { PROJECT_TYPES } from "./project-types.js";
|
|
9
10
|
|
|
10
11
|
const hasFile = (root) => (rel) => existsSync(join(root, rel));
|
|
11
12
|
const readFile = (root) => (rel) => {
|
|
@@ -48,8 +49,8 @@ export function listScanFiles(root, maxDepth = 3) {
|
|
|
48
49
|
|
|
49
50
|
// Monorepo marker scan: folders up to 2 levels down, a folder with markers is a project (not descended into) (#1243)
|
|
50
51
|
const MONOREPO_MARKER_DEPTH = 2;
|
|
51
|
-
//
|
|
52
|
-
const MARKER_TYPE_ORDER =
|
|
52
|
+
// Registry order = root scan order (first = primary type)
|
|
53
|
+
const MARKER_TYPE_ORDER = VALID_TYPES;
|
|
53
54
|
export function detectTypesInSubfolders(root, maxDepth = MONOREPO_MARKER_DEPTH) {
|
|
54
55
|
const found = [];
|
|
55
56
|
const walk = (rel, depth) => {
|
|
@@ -171,8 +172,8 @@ export function makeResolvers(root, repoName, paths) {
|
|
|
171
172
|
return f ? f.split("/").slice(0, -1).join("/") : "";
|
|
172
173
|
},
|
|
173
174
|
"spring-app-yml-path": (t) => findSpringAppYml(root, springBase(t)) || "",
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
// Type folder resolvers (APP_ROOT of app workflows): registry root_resolver names, e.g. flutter-root, expo-root
|
|
176
|
+
...Object.fromEntries(PROJECT_TYPES.filter((type) => type.root_resolver)
|
|
177
|
+
.map((type) => [type.root_resolver, () => paths.get(type.id) || "."])),
|
|
177
178
|
};
|
|
178
179
|
}
|