projectops 4.104.6 → 4.104.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/projectops.js +4 -4
- package/package.json +1 -1
- package/src/cli/args.js +43 -43
- package/src/cli/errors.js +8 -8
- package/src/cli/help.js +4 -4
- package/src/commands/doctor.js +39 -39
- package/src/commands/full.js +29 -29
- package/src/commands/interactive.js +86 -86
- package/src/commands/issues.js +5 -5
- package/src/commands/skills.js +13 -13
- package/src/commands/version.js +8 -8
- package/src/commands/workflows.js +19 -19
- package/src/context.js +24 -24
- package/src/core/agent-guide.js +5 -5
- package/src/core/assets.js +11 -11
- package/src/core/baseline.js +24 -24
- package/src/core/branch-sub.js +23 -23
- package/src/core/breaking-check.js +21 -21
- package/src/core/breaking.js +6 -6
- package/src/core/ci-minutes-sub.js +13 -13
- package/src/core/constants.js +17 -17
- package/src/core/copy/coderabbit.js +10 -10
- package/src/core/copy/gitignore.js +9 -9
- package/src/core/copy/readme.js +7 -7
- package/src/core/copy/simple.js +35 -35
- package/src/core/copy/util.js +9 -9
- package/src/core/copy/workflows.js +99 -99
- package/src/core/detect-fs.js +21 -21
- package/src/core/detect.js +12 -12
- package/src/core/development-branch.js +11 -11
- package/src/core/exclusions.js +12 -12
- package/src/core/fsutil.js +9 -9
- package/src/core/git-branch.js +11 -11
- package/src/core/ide/adapter.js +23 -23
- package/src/core/ide/adapters/claude.js +12 -12
- package/src/core/ide/adapters/codex.js +4 -4
- package/src/core/ide/adapters/copilot.js +12 -12
- package/src/core/ide/adapters/cursor.js +7 -7
- package/src/core/ide/adapters/gemini.js +5 -5
- package/src/core/ide/adapters/pi-common.js +12 -12
- package/src/core/ide/adapters/pi-harness.js +7 -7
- package/src/core/ide/adapters/pi.js +3 -3
- package/src/core/ide/home-skills.js +6 -6
- package/src/core/ide/legacy.js +8 -8
- package/src/core/ide/registry.js +6 -6
- package/src/core/ide/runner.js +15 -15
- package/src/core/ide/skills-copy.js +34 -34
- package/src/core/ide/stable-entry.js +11 -11
- package/src/core/ide/util.js +4 -4
- package/src/core/incoming.js +13 -13
- package/src/core/label-style.js +12 -12
- package/src/core/migration-guide.js +19 -19
- package/src/core/migrations/index.js +16 -16
- package/src/core/migrations/registry.js +39 -39
- package/src/core/migrations/rules/legacy-dirs.js +6 -6
- package/src/core/migrations/rules/obsolete-workflows.js +4 -4
- package/src/core/migrations/rules/root-files.js +3 -3
- package/src/core/migrations/rules/settings-extractors.js +8 -8
- package/src/core/options-ask.js +104 -104
- package/src/core/options-schema.js +23 -23
- package/src/core/orphan-workflows.js +14 -14
- package/src/core/paths-resolve.js +54 -54
- package/src/core/paths.js +2 -2
- package/src/core/placeholder-triggers.js +10 -10
- package/src/core/repo-language.js +10 -10
- package/src/core/resolve-options.js +30 -30
- package/src/core/run-trace.js +54 -54
- package/src/core/store-locales-hint.js +13 -13
- package/src/core/verify.js +27 -27
- package/src/core/version-yml.js +115 -115
- package/src/core/wizard-env.js +42 -42
- package/src/core/wizard-labels.js +31 -31
- package/src/core/workflow-groups.js +14 -14
- package/src/i18n/core.en.js +1 -1
- package/src/i18n/doctor.en.js +1 -1
- package/src/i18n/ide.en.js +1 -1
- package/src/i18n/migrate.en.js +1 -1
- package/src/i18n/options.en.js +1 -1
- package/src/index.js +60 -60
- package/src/ui/ansi.js +5 -5
- package/src/ui/env-plan.js +44 -44
- package/src/ui/prompts.js +21 -21
- package/src/ui/readline-engine.js +38 -38
- package/src/ui/skills-prompts.js +4 -4
package/src/commands/skills.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
// IDE
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// IDE skills install orchestrator.
|
|
2
|
+
// Registry based — does not know individual IDEs by name, only iterates the ADAPTERS array.
|
|
3
|
+
// A new IDE works with just a file in adapters/ + registry entry, with no changes here.
|
|
4
4
|
import { ADAPTERS } from "../core/ide/registry.js";
|
|
5
5
|
import { versionTag } from "../core/ide/util.js";
|
|
6
6
|
import { defaultIo } from "../core/ide/runner.js";
|
|
7
7
|
import * as skillsPrompts from "../ui/skills-prompts.js";
|
|
8
8
|
import { t } from "../i18n/index.js";
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// Collect status → [{adapter, status}]. Optional adapters are left out when undetectable (cliMissing).
|
|
11
11
|
export function collectStatuses(io) {
|
|
12
12
|
const rows = [];
|
|
13
13
|
for (const a of ADAPTERS) {
|
|
14
14
|
const status = safe(() => a.detect(io), { installed: false, version: null, cliMissing: true });
|
|
15
|
-
if (a.optional && status.cliMissing) continue; //
|
|
15
|
+
if (a.optional && status.cliMissing) continue; // Conditional items like the harness are hidden when unavailable
|
|
16
16
|
rows.push({ adapter: a, status });
|
|
17
17
|
}
|
|
18
18
|
return rows;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
//
|
|
21
|
+
// Status display strings (for display, pure).
|
|
22
22
|
export function formatStatuses(rows, templateVersion) {
|
|
23
23
|
return rows.map(({ adapter, status }) => {
|
|
24
24
|
const label = adapter.label.padEnd(12);
|
|
@@ -31,9 +31,9 @@ export function formatStatuses(rows, templateVersion) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
//
|
|
35
|
-
// installedOnly(#502 —
|
|
36
|
-
//
|
|
34
|
+
// Shared entry for interactive/non-interactive. opts: {io, templateVersion, sourceSkillsDir, tempDir, interactive, ui, installedOnly}
|
|
35
|
+
// installedOnly (#502 — update mode): limits non-interactive apply to already-installed adapters.
|
|
36
|
+
// Never installs into IDEs not yet installed — an update's contract is "bring what exists up to date".
|
|
37
37
|
export async function runSkills(opts = {}) {
|
|
38
38
|
const io = opts.io || defaultIo();
|
|
39
39
|
const ui = opts.ui || skillsPrompts;
|
|
@@ -45,8 +45,8 @@ export async function runSkills(opts = {}) {
|
|
|
45
45
|
for (const line of formatStatuses(rows, ctx.templateVersion)) io.log(line);
|
|
46
46
|
io.log("");
|
|
47
47
|
|
|
48
|
-
//
|
|
49
|
-
// installedOnly
|
|
48
|
+
// Non-interactive: run apply (install/update) in order on every detected (= manageable) adapter.
|
|
49
|
+
// With installedOnly, installed adapters only (update mode — IDEs not installed are left alone).
|
|
50
50
|
if (!opts.interactive) {
|
|
51
51
|
for (const { adapter, status } of rows) {
|
|
52
52
|
if (opts.installedOnly && !status.installed) continue;
|
|
@@ -55,7 +55,7 @@ export async function runSkills(opts = {}) {
|
|
|
55
55
|
return 0;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
//
|
|
58
|
+
// Interactive: choose action → IDE multiselect → run.
|
|
59
59
|
const action = await ui.selectAction();
|
|
60
60
|
if (action == null || action === skillsPrompts.CANCEL || action === "skip") {
|
|
61
61
|
io.log(t("skills.unchanged"));
|
|
@@ -64,7 +64,7 @@ export async function runSkills(opts = {}) {
|
|
|
64
64
|
|
|
65
65
|
const choices = rows.map(({ adapter, status }) => ({
|
|
66
66
|
id: adapter.id, label: adapter.label,
|
|
67
|
-
disabled: action === "apply" && status.cliMissing, //
|
|
67
|
+
disabled: action === "apply" && status.cliMissing, // Install needs the CLI; removal is always a candidate
|
|
68
68
|
}));
|
|
69
69
|
const preselect = rows
|
|
70
70
|
.filter(({ status }) => action === "apply" ? !status.cliMissing : true)
|
package/src/commands/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// version
|
|
2
|
-
//
|
|
3
|
-
// (
|
|
1
|
+
// version mode (generate/update version.yml).
|
|
2
|
+
// Order: version.yml → readme → scripts → config → gitignore → setup_guide.
|
|
3
|
+
// (No workflow copy → no deploy block. No util, issue or coderabbit either.)
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { writeText } from "../core/fsutil.js";
|
|
@@ -15,14 +15,14 @@ import { ensureGitignore } from "../core/copy/gitignore.js";
|
|
|
15
15
|
import { toTemplateOptions } from "../core/resolve-options.js";
|
|
16
16
|
|
|
17
17
|
export function runVersion(context, tempDir, targetRoot = ".") {
|
|
18
|
-
//
|
|
18
|
+
// Option values are decided by resolveOptions and put in context — defaults are not picked again here
|
|
19
19
|
const { version, types = [], paths = new Map(), branch = "main", versionCode = 1,
|
|
20
20
|
now, today, templateVersion, deployBranch = "", recordMode = "version", labelStyle } = context;
|
|
21
21
|
|
|
22
22
|
const pathMarkers = new Map();
|
|
23
23
|
for (const [t] of paths) pathMarkers.set(t, markerForType(t));
|
|
24
24
|
|
|
25
|
-
// version.yml
|
|
25
|
+
// version.yml is fully regenerated, so without reading it, deploy values left by a previous integration (including user edits) vanish (#670)
|
|
26
26
|
const vyFile = join(targetRoot, PATHS.versionFile);
|
|
27
27
|
const deployValues = mergeDeployValues(existsSync(vyFile) ? readFileSync(vyFile, "utf8") : "", new Map());
|
|
28
28
|
|
|
@@ -30,11 +30,11 @@ export function runVersion(context, tempDir, targetRoot = ".") {
|
|
|
30
30
|
buildVersionYml({
|
|
31
31
|
version, types, paths, pathMarkers, branch, deployBranch, versionCode, now, today,
|
|
32
32
|
deployValues,
|
|
33
|
-
//
|
|
33
|
+
// Keep keys the generator does not know (issue_helper, etc.) — version.yml is rewritten every time, so otherwise they vanish on every update (#835)
|
|
34
34
|
...customYml(vyFile),
|
|
35
35
|
updatedBy: resolveUpdatedBy(existsSync(vyFile) ? readFileSync(vyFile, "utf8") : "", targetRoot), // #811
|
|
36
|
-
// mode(#502): version
|
|
37
|
-
//
|
|
36
|
+
// mode (#502): so version mode does not downgrade an existing full integration record to "version",
|
|
37
|
+
// the caller passes the existing value as recordMode (full wins — prevents shrinking the update re-run scope).
|
|
38
38
|
templateOptions: toTemplateOptions(context, { mode: recordMode, optionsDate: today }),
|
|
39
39
|
}));
|
|
40
40
|
addVersionSectionToReadme(version, targetRoot, context.language);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// workflows
|
|
2
|
-
//
|
|
3
|
-
// (version.yml
|
|
1
|
+
// workflows mode (installs workflows only).
|
|
2
|
+
// Order: copy_workflows → update_version_yml_deploy (only if version.yml exists) → scripts → config → util (per type) → setup_guide.
|
|
3
|
+
// (Does not generate version.yml — adds the deploy block only when a version.yml already exists.)
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { PATHS } from "../core/paths.js";
|
|
@@ -13,41 +13,41 @@ import { installAgentGuide } from "../core/agent-guide.js";
|
|
|
13
13
|
import { verifyInstall } from "../core/verify.js";
|
|
14
14
|
|
|
15
15
|
export function runWorkflows(context, tempDir, targetRoot = ".", hooks = {}) {
|
|
16
|
-
const { types = [], force = true, labelStyle } = context; // labelStyle
|
|
16
|
+
const { types = [], force = true, labelStyle } = context; // labelStyle is decided by resolveOptions
|
|
17
17
|
const wf = copyWorkflows(context, tempDir, targetRoot, hooks);
|
|
18
18
|
|
|
19
19
|
const vy = join(targetRoot, PATHS.versionFile);
|
|
20
20
|
|
|
21
|
-
// v4.1.0
|
|
22
|
-
//
|
|
21
|
+
// Minimal conversion of the pre-v4.1.0 singular project_type (#471) — the new version_manager copied here
|
|
22
|
+
// rejects the singular key, so without converting, every version workflow fails in a broken state.
|
|
23
23
|
if (existsSync(vy)) {
|
|
24
24
|
const converted = convertLegacySingularType(readFileSync(vy, "utf8"));
|
|
25
25
|
if (converted !== null) writeFileSync(vy, converted);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// update_version_yml_deploy:
|
|
28
|
+
// update_version_yml_deploy: update the deploy block only when a version.yml exists and there are ask values
|
|
29
29
|
if (existsSync(vy) && wf.deployValues && wf.deployValues.size) {
|
|
30
30
|
const cur = readFileSync(vy, "utf8");
|
|
31
|
-
writeFileSync(vy, upsertDeployBlock(cur, mergeDeployValues(cur, wf.deployValues))); //
|
|
31
|
+
writeFileSync(vy, upsertDeployBlock(cur, mergeDeployValues(cur, wf.deployValues))); // Existing values first (#670)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
copyScripts(tempDir, targetRoot);
|
|
35
35
|
copyConfigFolder(tempDir, targetRoot);
|
|
36
|
-
applyLabelStyle(targetRoot, labelStyle); // #776 —
|
|
36
|
+
applyLabelStyle(targetRoot, labelStyle); // #776 — aligns workflows (QA bot) and label definitions to the same style
|
|
37
37
|
for (const t of types) copyUtilModules(tempDir, t, { force }, targetRoot);
|
|
38
38
|
copySetupGuide(tempDir, targetRoot);
|
|
39
39
|
installAgentGuide(targetRoot, context.templateVersion);
|
|
40
40
|
|
|
41
|
-
//
|
|
41
|
+
// Post-install verification (#549) — all the more needed in a mode that installs only workflows.
|
|
42
42
|
const verification = verifyInstall(targetRoot);
|
|
43
|
-
// detail
|
|
44
|
-
//
|
|
45
|
-
// "
|
|
43
|
+
// Mind the detail key names: the run-trace sensitive value guard filters pat|token|secret|password|credential
|
|
44
|
+
// out of keys (#494). These values are not secrets but "substitution placeholder names" and
|
|
45
|
+
// "key names that need registering", so names that do not trip the guard are used — the guard itself is not bypassed.
|
|
46
46
|
hooks.trace?.event("verify", "scan", "", {
|
|
47
47
|
unresolved: verification.unresolved.length,
|
|
48
48
|
requiredKeys: verification.secrets.size,
|
|
49
49
|
});
|
|
50
|
-
//
|
|
50
|
+
// Unreplaced values are spots that will fail at deploy time — log which file and line.
|
|
51
51
|
for (const u of verification.unresolved) {
|
|
52
52
|
hooks.trace?.event("verify", "unresolved", u.filename, { line: u.line, placeholder: u.token });
|
|
53
53
|
}
|
|
@@ -58,24 +58,24 @@ export function runWorkflows(context, tempDir, targetRoot = ".", hooks = {}) {
|
|
|
58
58
|
return { workflows: wf, verification };
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
//
|
|
61
|
+
// Remove the deploy: block from the existing version.yml and append a new one (idempotent).
|
|
62
62
|
export function upsertDeployBlock(content, deployValues) {
|
|
63
|
-
//
|
|
63
|
+
// Remove the existing deploy: block (from the deploy: line up to the next top-level key)
|
|
64
64
|
const lines = content.split(/\r?\n/);
|
|
65
65
|
const out = [];
|
|
66
66
|
let inDeploy = false;
|
|
67
67
|
for (const line of lines) {
|
|
68
68
|
if (/^deploy:/.test(line)) { inDeploy = true; continue; }
|
|
69
69
|
if (inDeploy) {
|
|
70
|
-
// 4.28.0
|
|
70
|
+
// Broken structure made by 4.28.0: a 2-space `template:` under deploy is a child of metadata, not deploy content (#670)
|
|
71
71
|
if (/^ {2}template:/.test(line)) inDeploy = false;
|
|
72
|
-
else if (/^\s/.test(line) || line === "") continue; //
|
|
72
|
+
else if (/^\s/.test(line) || line === "") continue; // Indented/blank line = inside deploy
|
|
73
73
|
else inDeploy = false;
|
|
74
74
|
}
|
|
75
75
|
out.push(line);
|
|
76
76
|
}
|
|
77
77
|
let text = out.join("\n").replace(/\n+$/, "\n");
|
|
78
|
-
//
|
|
78
|
+
// Append the new deploy block
|
|
79
79
|
const deployTypes = [...deployValues.keys()].filter((t) => deployValues.get(t)?.size);
|
|
80
80
|
if (deployTypes.length) {
|
|
81
81
|
text += `\ndeploy: # 마법사가 기억하는 배포 설정 (비민감 / 직접 수정 가능)\n`;
|
package/src/context.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
// next
|
|
1
|
+
// Wizard global state made explicit as one object (replaces the bash global variables)
|
|
2
|
+
// The next type was merged into react in v4.1.0 (breaking)
|
|
3
3
|
export const VALID_TYPES = [
|
|
4
4
|
"spring", "flutter", "react",
|
|
5
5
|
"react-native", "react-native-expo", "node", "python", "basic",
|
|
6
6
|
];
|
|
7
7
|
|
|
8
|
-
export const DEFAULT_VERSION = "1.3.14"; //
|
|
8
|
+
export const DEFAULT_VERSION = "1.3.14"; // When the template version is unknown (banner fallback — not used for breaking comparison)
|
|
9
9
|
|
|
10
10
|
export function createContext(overrides = {}) {
|
|
11
11
|
return {
|
|
@@ -15,29 +15,29 @@ export function createContext(overrides = {}) {
|
|
|
15
15
|
version: "",
|
|
16
16
|
branch: "",
|
|
17
17
|
paths: new Map(), // type -> path
|
|
18
|
-
//
|
|
19
|
-
deployTarget: null, // 'docker-ssh'(
|
|
20
|
-
publishTargets: null, // ['nexus','npm','github-packages']
|
|
18
|
+
// Deploy/publish axes (#439 — type-independent. null = unset)
|
|
19
|
+
deployTarget: null, // 'docker-ssh' (default) | 'vercel' | 'none'
|
|
20
|
+
publishTargets: null, // subset of ['nexus','npm','github-packages']
|
|
21
21
|
includeSecretBackup: null,
|
|
22
|
-
projectsSync: null, //
|
|
23
|
-
aiPrSummary: null, // #566 —
|
|
24
|
-
// changelog provider
|
|
25
|
-
changelogProvider: null, // 'commit'(
|
|
26
|
-
changelogBaseUrl: null, //
|
|
22
|
+
projectsSync: null, // Whether to include Projects board sync (#716). null = unset (new false / already-installed repos keep it)
|
|
23
|
+
aiPrSummary: null, // #566 — whether to include the AI change summary workflow
|
|
24
|
+
// changelog provider axis (#455 — null = unset)
|
|
25
|
+
changelogProvider: null, // 'commit' (default) | 'coderabbit' | 'openai' | 'gemini' | 'claude' | 'ollama' | 'commit'
|
|
26
|
+
changelogBaseUrl: null, // Only for ollama
|
|
27
27
|
codeReviewCoderabbit: null,
|
|
28
|
-
deployBranch: "", //
|
|
29
|
-
deployTriggerBranch: "", //
|
|
30
|
-
ciMinutesSaver: false, // CI
|
|
31
|
-
intent: null, //
|
|
32
|
-
semverAuto: null, // semver
|
|
33
|
-
closeOnRelease: null, //
|
|
34
|
-
language: null, //
|
|
35
|
-
labelStyle: null, //
|
|
36
|
-
excludedWorkflows: null, //
|
|
37
|
-
storeLocales: null, //
|
|
38
|
-
storeLocalesIos: null, // App Store
|
|
39
|
-
storeLocalesPlay: null, // Play
|
|
40
|
-
appRelease: null, //
|
|
28
|
+
deployBranch: "", // Release PR head branch (#456). Empty = metadata.development_branch not written
|
|
29
|
+
deployTriggerBranch: "", // Branch whose push runs the deploy (#1114). Empty = same as the default branch (workflows as is)
|
|
30
|
+
ciMinutesSaver: false, // CI minutes saver substitution (#1114). false = workflows as is
|
|
31
|
+
intent: null, // Project nature (#485 — app/library/both/none/manual). null = unset (inferred)
|
|
32
|
+
semverAuto: null, // Automatic semver bump (#546). null = unset → true for new and existing (#814). Only an explicit false turns it off
|
|
33
|
+
closeOnRelease: null, // Close done issues on release (#771). null = unset (new true / no key in existing repos)
|
|
34
|
+
language: null, // Repo text language (#769). null = unset (new en / existing repos ko)
|
|
35
|
+
labelStyle: null, // Status label style (#776). null = unset (new en / existing repos ko)
|
|
36
|
+
excludedWorkflows: null, // Workflow file names not to install (#810). null = none
|
|
37
|
+
storeLocales: null, // Store release note languages (#829). null = unset → current behavior kept
|
|
38
|
+
storeLocalesIos: null, // When only the App Store has a different language set (#829). null = use the shared store_locales
|
|
39
|
+
storeLocalesPlay: null, // When only Play has a different language set (#829)
|
|
40
|
+
appRelease: null, // Whether the repo deploys through app review (#553). null = unset (no key written)
|
|
41
41
|
templateVersion: "",
|
|
42
42
|
tempDir: "",
|
|
43
43
|
deployValues: new Map(), // "type.KEY" -> value
|
package/src/core/agent-guide.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//
|
|
1
|
+
// AI agent guide installed into the user repo (.github/.projectops/AGENT-GUIDE.md).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// Why a file: this repo's AGENTS.md is template-only and never reaches user projects, so agents working in a
|
|
4
|
+
// repo with projectops installed had no way to know what manages the repo or where to check options.
|
|
5
|
+
// The repo-root AGENTS.md and CLAUDE.md belong to the user, so we leave them alone, keep this inside the folder, and point to it in one line.
|
|
6
6
|
//
|
|
7
|
-
//
|
|
7
|
+
// No option table in the content — it would go stale fast. `npx projectops --mode options --json` is always the source of truth.
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
import { writeText } from "./fsutil.js";
|
|
10
10
|
import { TEMPLATE_REPO_WEB_URL } from "./paths.js";
|
package/src/core/assets.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Fetch template assets + apply exclusions.
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
3
|
import { mkdirSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
@@ -7,12 +7,12 @@ import { DOCS_TO_REMOVE, PLUGIN_ITEMS_TO_REMOVE } from "./exclusions.js";
|
|
|
7
7
|
import { DEFAULT_VERSION } from "../context.js";
|
|
8
8
|
import { TEMPLATE_REPO } from "./paths.js";
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// Fetch the template into tempDir.
|
|
11
11
|
// source:
|
|
12
|
-
// {type:'git', repo?} → git clone --depth 1 (
|
|
13
|
-
// {type:'local', path} →
|
|
14
|
-
//
|
|
15
|
-
// keep:
|
|
12
|
+
// {type:'git', repo?} → git clone --depth 1 (default repo=TEMPLATE_REPO)
|
|
13
|
+
// {type:'local', path} → copy a local tree (for offline equivalence checks)
|
|
14
|
+
// Skip if tempDir/.github already exists (prevents duplicate calls). Calls applyExclusions automatically after fetching.
|
|
15
|
+
// keep: exclusion entries to keep (skill install path needs scripts/common > ["scripts"], #994)
|
|
16
16
|
export function acquireTemplate({ tempDir, source = { type: "git" }, keep = [] }) {
|
|
17
17
|
if (exists(join(tempDir, ".github"))) {
|
|
18
18
|
applyExclusions(tempDir, { keep });
|
|
@@ -23,23 +23,23 @@ export function acquireTemplate({ tempDir, source = { type: "git" }, keep = [] }
|
|
|
23
23
|
copyDirSync(source.path, tempDir);
|
|
24
24
|
} else {
|
|
25
25
|
const repo = source.repo || TEMPLATE_REPO;
|
|
26
|
-
// clone
|
|
27
|
-
//
|
|
26
|
+
// clone discards stdio, so the cause of failure is lost — a read-only folder would be misreported as "could not download".
|
|
27
|
+
// Create it first so permission errors (EACCES/EPERM/EROFS) surface as is (#720). clone works into an empty folder.
|
|
28
28
|
mkdirSync(tempDir, { recursive: true });
|
|
29
29
|
execFileSync("git", ["clone", "-c", "core.longpaths=true", "--depth", "1", "--quiet", repo, tempDir], { stdio: ["ignore", "ignore", "pipe"] });
|
|
30
30
|
}
|
|
31
31
|
applyExclusions(tempDir, { keep });
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
// DOCS_TO_REMOVE + PLUGIN_ITEMS_TO_REMOVE
|
|
35
|
-
//
|
|
34
|
+
// Delete DOCS_TO_REMOVE + PLUGIN_ITEMS_TO_REMOVE (except keep entries). skills/ is kept.
|
|
35
|
+
// The integration copy reads only explicit paths such as .github > scripts/ left in tempDir never reaches the user repo
|
|
36
36
|
export function applyExclusions(tempDir, { keep = [] } = {}) {
|
|
37
37
|
const keptItems = new Set(keep);
|
|
38
38
|
for (const doc of DOCS_TO_REMOVE) remove(join(tempDir, doc));
|
|
39
39
|
for (const item of PLUGIN_ITEMS_TO_REMOVE) if (!keptItems.has(item)) remove(join(tempDir, item));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
// tempDir/version.yml
|
|
42
|
+
// The ^version: value in tempDir/version.yml. DEFAULT_VERSION if missing.
|
|
43
43
|
export function readTemplateVersion(tempDir) {
|
|
44
44
|
const p = join(tempDir, "version.yml");
|
|
45
45
|
if (!exists(p)) return DEFAULT_VERSION;
|
package/src/core/baseline.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Install-time baseline (#557) — the reference point that tells, during an update, "who changed it".
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// base
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// Why: isUnchanged() compares the template (theirs) with the installed copy (ours) 2-way.
|
|
4
|
+
// With no base, a one-character upstream fix makes a file the user never touched fall into changed,
|
|
5
|
+
// leaving only two choices: "skip everything (no updates)" or "overwrite everything (all user edits lost)".
|
|
6
|
+
// The real conflicts that need sorting get buried among the rest.
|
|
7
7
|
//
|
|
8
|
-
//
|
|
8
|
+
// Stores hashes, not file copies — the goal is classification, not automatic merging.
|
|
9
9
|
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
// - installed :
|
|
13
|
-
// - rendered :
|
|
10
|
+
// Why two hashes: a file with user values substituted via env differs on disk from the "render with
|
|
11
|
+
// defaults" from the start. One hash cannot answer both questions.
|
|
12
|
+
// - installed : what we wrote to disk at install time → "did the user edit it since?"
|
|
13
|
+
// - rendered : the template rendered with defaults then → "did upstream change since?"
|
|
14
14
|
//
|
|
15
|
-
// installed
|
|
16
|
-
// "
|
|
15
|
+
// installed is filled only for files we actually wrote. Recording a user-edited file as installed
|
|
16
|
+
// would falsely claim "we wrote it", and the next update would silently overwrite that file.
|
|
17
17
|
import { createHash } from "node:crypto";
|
|
18
18
|
import { join } from "node:path";
|
|
19
19
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -26,8 +26,8 @@ export function sha256(text) {
|
|
|
26
26
|
return "sha256:" + createHash("sha256").update(String(text), "utf8").digest("hex");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
//
|
|
30
|
-
//
|
|
29
|
+
// null when missing or broken — the caller falls back to "base unknown" (never silently use an empty baseline;
|
|
30
|
+
// an empty baseline could be read as "everything was deleted" rather than "no record").
|
|
31
31
|
export function readBaseline(targetRoot = ".") {
|
|
32
32
|
const p = join(targetRoot, BASELINE_PATH);
|
|
33
33
|
if (!existsSync(p)) return null;
|
|
@@ -36,18 +36,18 @@ export function readBaseline(targetRoot = ".") {
|
|
|
36
36
|
if (!data || typeof data !== "object" || typeof data.files !== "object" || data.files === null) return null;
|
|
37
37
|
return data;
|
|
38
38
|
} catch {
|
|
39
|
-
return null; //
|
|
39
|
+
return null; // Treat a corrupt baseline as missing — do not block the update
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// entries: Map<filename, {installed?:string|null, rendered:string}>
|
|
44
|
-
//
|
|
44
|
+
// The existing baseline is merged — files not touched in this run keep their reference point.
|
|
45
45
|
export function writeBaseline(targetRoot, { templateVersion, installedAt, entries, previous = null }) {
|
|
46
46
|
const files = { ...(previous?.files || {}) };
|
|
47
47
|
for (const [filename, entry] of entries) {
|
|
48
48
|
const prev = files[filename] || {};
|
|
49
49
|
files[filename] = {
|
|
50
|
-
// installed
|
|
50
|
+
// installed is updated only when actually written this time. Kept (skipped) files keep the old reference point.
|
|
51
51
|
installed: entry.installed ?? prev.installed ?? null,
|
|
52
52
|
rendered: entry.rendered,
|
|
53
53
|
};
|
|
@@ -61,23 +61,23 @@ export function writeBaseline(targetRoot, { templateVersion, installedAt, entrie
|
|
|
61
61
|
return out;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
//
|
|
65
|
-
// baseline
|
|
66
|
-
//
|
|
64
|
+
// Did the user edit this file after install?
|
|
65
|
+
// null when there is no baseline or no record for the file — that means "unknown", not "untouched".
|
|
66
|
+
// The caller must fall back to the current 2-way check on null.
|
|
67
67
|
export function isUserModified(baseline, filename, installedContent) {
|
|
68
68
|
const rec = baseline?.files?.[filename];
|
|
69
69
|
if (!rec || !rec.installed) return null;
|
|
70
70
|
return rec.installed !== sha256(installedContent);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
// baseline
|
|
74
|
-
//
|
|
75
|
-
// candidates:
|
|
73
|
+
// In the baseline but missing on disk = deleted by the user.
|
|
74
|
+
// A by-product of this design: no separate deletion history file is needed.
|
|
75
|
+
// candidates: file names the template wants to install this time (other baseline entries are irrelevant)
|
|
76
76
|
export function detectRemoved(baseline, candidates, workflowsDir) {
|
|
77
77
|
if (!baseline) return [];
|
|
78
78
|
const removed = [];
|
|
79
79
|
for (const filename of candidates) {
|
|
80
|
-
if (!baseline.files[filename]) continue; //
|
|
80
|
+
if (!baseline.files[filename]) continue; // We never installed this file — no basis to judge
|
|
81
81
|
if (existsSync(join(workflowsDir, filename))) continue;
|
|
82
82
|
removed.push(filename);
|
|
83
83
|
}
|
package/src/core/branch-sub.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// isUnchanged
|
|
1
|
+
// Workflow branch substitution (#477) — when the target repo's branch strategy differs from the standard (main/develop),
|
|
2
|
+
// replace branch literals in the copied workflows with the configured values.
|
|
3
|
+
// For standard values the input is returned as is (no-op) — staying byte-identical to the template keeps
|
|
4
|
+
// the isUnchanged skip logic and the "standard repo stays unchanged" contract intact.
|
|
5
5
|
//
|
|
6
|
-
//
|
|
7
|
-
// 1)
|
|
8
|
-
// 2)
|
|
9
|
-
// 3)
|
|
10
|
-
// 4) step
|
|
11
|
-
// 5)
|
|
12
|
-
// 6)
|
|
13
|
-
// 7) CI
|
|
6
|
+
// Only patterns found by a full survey (#477) are substituted (no globs or blanket replace — avoids collateral damage):
|
|
7
|
+
// 1) inline trigger: branches: ["main"] / [develop] / [ develop ] / ["develop"]
|
|
8
|
+
// 2) multi-line trigger: " - main" / " - develop" alone on a line (trailing comment allowed)
|
|
9
|
+
// 3) release guard: == 'develop' (RELEASE-CHANGELOG automerge head guard)
|
|
10
|
+
// 4) inside a step: git fetch origin main (RELEASE-CHANGELOG commit analysis)
|
|
11
|
+
// 5) deploy trigger (#1114): deploy workflow files only, main > deployTriggerBranch (DEPLOY_TRIGGER_WORKFLOWS below)
|
|
12
|
+
// 6) branch check in deploy scripts (#1114): [ "$BRANCH" == "main" ] (REACT-CICD allowed-branch check)
|
|
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
16
|
|
|
17
|
-
// main(
|
|
17
|
+
// main (default branch) substitutions
|
|
18
18
|
function subDefault(s, db) {
|
|
19
19
|
s = s.replace(/^(\s*branches:\s*\[\s*["']?)main(["']?\s*\])/gm, `$1${db}$2`);
|
|
20
20
|
s = s.replace(/^(\s*-\s*)main(\s*(?:#.*)?)$/gm, `$1${db}$2`);
|
|
@@ -23,7 +23,7 @@ function subDefault(s, db) {
|
|
|
23
23
|
return s;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// develop(
|
|
26
|
+
// develop (development/release head branch) substitutions
|
|
27
27
|
function subDeploy(s, dev) {
|
|
28
28
|
s = s.replace(/^(\s*branches:\s*\[\s*["']?)develop(["']?\s*\])/gm, `$1${dev}$2`);
|
|
29
29
|
s = s.replace(/^(\s*-\s*)develop(\s*(?:#.*)?)$/gm, `$1${dev}$2`);
|
|
@@ -31,9 +31,9 @@ function subDeploy(s, dev) {
|
|
|
31
31
|
return s;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
34
|
+
// Workflows that deploy when pushed (exact file name match). Used only in repos that split the default and deploy branches.
|
|
35
|
+
// Common workflows (version bump · README version · release notes · issue close) are not here: they follow the default branch.
|
|
36
|
+
// Add new deploy workflows to this table too (otherwise that file deploys from the default branch)
|
|
37
37
|
export const DEPLOY_TRIGGER_WORKFLOWS = new Set([
|
|
38
38
|
"PROJECT-FLUTTER-ANDROID-FIREBASE-CICD.yaml", "PROJECT-FLUTTER-ANDROID-PLAYSTORE-CICD.yaml",
|
|
39
39
|
"PROJECT-FLUTTER-ANDROID-SELFHOSTED-CICD.yaml", "PROJECT-FLUTTER-IOS-TESTFLIGHT.yaml",
|
|
@@ -42,7 +42,7 @@ export const DEPLOY_TRIGGER_WORKFLOWS = new Set([
|
|
|
42
42
|
"PROJECT-SPRING-NEXUS-PUBLISH.yml", "PROJECT-SPRING-GITHUB-PACKAGES-PUBLISH.yml",
|
|
43
43
|
]);
|
|
44
44
|
|
|
45
|
-
//
|
|
45
|
+
// Deploy trigger branch substitution: main in triggers · checkout ref · pull · run conditions
|
|
46
46
|
function subDeployTrigger(s, trigger) {
|
|
47
47
|
s = s.replace(/^(\s*branches:\s*\[\s*["']?)main(["']?\s*\])/gm, `$1${trigger}$2`);
|
|
48
48
|
s = s.replace(/^(\s*-\s*)main(\s*(?:#.*)?)$/gm, `$1${trigger}$2`);
|
|
@@ -53,10 +53,10 @@ function subDeployTrigger(s, trigger) {
|
|
|
53
53
|
return s;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// content
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
// filename:
|
|
56
|
+
// Returns content with the branch settings (+ CI minutes saver) applied. Unchanged when branches is unset or standard.
|
|
57
|
+
// Two-stage placeholder substitution prevents value collisions (e.g. in a repo whose default branch is develop, the main→develop
|
|
58
|
+
// result would otherwise be caught again by the following develop→X substitution).
|
|
59
|
+
// filename: limits the deploy trigger substitution (#1114) to deploy workflow files. Without it, that substitution is skipped.
|
|
60
60
|
export function substituteBranches(content, branches = null, filename = "") {
|
|
61
61
|
if (!branches) return content;
|
|
62
62
|
const db = branches.defaultBranch || "main";
|
|
@@ -67,7 +67,7 @@ export function substituteBranches(content, branches = null, filename = "") {
|
|
|
67
67
|
const T_DB = "__PJOPS_DEFAULT__";
|
|
68
68
|
const T_DEV = "__PJOPS_DEPLOY__";
|
|
69
69
|
const T_TRIGGER = "__PJOPS_TRIGGER__";
|
|
70
|
-
//
|
|
70
|
+
// main in deploy workflows goes to the deploy trigger branch, not the default branch (moved out to a placeholder first)
|
|
71
71
|
if (trigger && DEPLOY_TRIGGER_WORKFLOWS.has(filename)) s = subDeployTrigger(s, T_TRIGGER);
|
|
72
72
|
if (dev !== "develop") s = subDeploy(s, T_DEV);
|
|
73
73
|
if (db !== "main") s = subDefault(s, T_DB);
|