projectops 4.104.6 → 4.104.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/projectops.js +4 -4
- package/package.json +1 -1
- package/src/cli/args.js +43 -43
- package/src/cli/errors.js +8 -8
- package/src/cli/help.js +4 -4
- package/src/commands/doctor.js +39 -39
- package/src/commands/full.js +29 -29
- package/src/commands/interactive.js +86 -86
- package/src/commands/issues.js +5 -5
- package/src/commands/skills.js +13 -13
- package/src/commands/version.js +8 -8
- package/src/commands/workflows.js +23 -22
- package/src/context.js +24 -24
- package/src/core/agent-guide.js +5 -5
- package/src/core/assets.js +11 -11
- package/src/core/baseline.js +24 -24
- package/src/core/branch-sub.js +23 -23
- package/src/core/breaking-check.js +21 -21
- package/src/core/breaking.js +6 -6
- package/src/core/ci-minutes-sub.js +13 -13
- package/src/core/constants.js +17 -17
- package/src/core/copy/coderabbit.js +10 -10
- package/src/core/copy/gitignore.js +9 -9
- package/src/core/copy/readme.js +7 -7
- package/src/core/copy/simple.js +35 -35
- package/src/core/copy/util.js +9 -9
- package/src/core/copy/workflows.js +99 -99
- package/src/core/detect-fs.js +21 -21
- package/src/core/detect.js +12 -12
- package/src/core/development-branch.js +11 -11
- package/src/core/exclusions.js +12 -12
- package/src/core/fsutil.js +9 -9
- package/src/core/git-branch.js +11 -11
- package/src/core/ide/adapter.js +23 -23
- package/src/core/ide/adapters/claude.js +12 -12
- package/src/core/ide/adapters/codex.js +4 -4
- package/src/core/ide/adapters/copilot.js +12 -12
- package/src/core/ide/adapters/cursor.js +7 -7
- package/src/core/ide/adapters/gemini.js +5 -5
- package/src/core/ide/adapters/pi-common.js +12 -12
- package/src/core/ide/adapters/pi-harness.js +7 -7
- package/src/core/ide/adapters/pi.js +3 -3
- package/src/core/ide/home-skills.js +6 -6
- package/src/core/ide/legacy.js +8 -8
- package/src/core/ide/registry.js +6 -6
- package/src/core/ide/runner.js +15 -15
- package/src/core/ide/skills-copy.js +34 -34
- package/src/core/ide/stable-entry.js +11 -11
- package/src/core/ide/util.js +4 -4
- package/src/core/incoming.js +13 -13
- package/src/core/label-style.js +12 -12
- package/src/core/migration-guide.js +19 -19
- package/src/core/migrations/index.js +16 -16
- package/src/core/migrations/registry.js +39 -39
- package/src/core/migrations/rules/legacy-dirs.js +6 -6
- package/src/core/migrations/rules/obsolete-workflows.js +4 -4
- package/src/core/migrations/rules/root-files.js +3 -3
- package/src/core/migrations/rules/settings-extractors.js +8 -8
- package/src/core/options-ask.js +104 -104
- package/src/core/options-schema.js +23 -23
- package/src/core/orphan-workflows.js +14 -14
- package/src/core/paths-resolve.js +54 -54
- package/src/core/paths.js +2 -2
- package/src/core/placeholder-triggers.js +10 -10
- package/src/core/repo-language.js +10 -10
- package/src/core/resolve-options.js +30 -30
- package/src/core/run-trace.js +54 -54
- package/src/core/store-locales-hint.js +13 -13
- package/src/core/verify.js +27 -27
- package/src/core/version-yml.js +117 -116
- package/src/core/wizard-env.js +42 -42
- package/src/core/wizard-labels.js +31 -31
- package/src/core/workflow-groups.js +14 -14
- package/src/i18n/core.en.js +1 -1
- package/src/i18n/doctor.en.js +1 -1
- package/src/i18n/ide.en.js +1 -1
- package/src/i18n/migrate.en.js +1 -1
- package/src/i18n/options.en.js +1 -1
- package/src/index.js +60 -60
- package/src/ui/ansi.js +5 -5
- package/src/ui/env-plan.js +44 -44
- package/src/ui/prompts.js +21 -21
- package/src/ui/readline-engine.js +38 -38
- package/src/ui/skills-prompts.js +4 -4
package/src/core/version-yml.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// version.yml
|
|
2
|
-
// ⚠️ YAML
|
|
1
|
+
// version.yml parse and generate (full regeneration strategy D4).
|
|
2
|
+
// ⚠️ No YAML re-serialization — comments are data. Pinned byte for byte with template strings.
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
import { DEPLOY_TARGETS, LABEL_STYLES } from "./constants.js";
|
|
6
6
|
import { REPO_LANGUAGES } from "./repo-language.js";
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
// (
|
|
8
|
+
// Match patterns built from the value lists — adding a language or style to a list makes the parser read it automatically.
|
|
9
|
+
// (Hardcoding languages in the pattern means a newly saved language is unreadable on the next update and reverts to ko.)
|
|
10
10
|
const alt = (values) => values.map((v) => v.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")).join("|");
|
|
11
11
|
const LANGUAGE_RE = new RegExp(`^\\s+language:\\s*["']?(${alt(REPO_LANGUAGES)})["']?`);
|
|
12
12
|
const DEPLOY_TRIGGER_BRANCH_RE = /^\s+deploy_trigger_branch:\s*["']?([A-Za-z0-9._\/-]+)["']?/;
|
|
@@ -56,8 +56,8 @@ const HEADER_EN = `# ===========================================================
|
|
|
56
56
|
# ===================================================================
|
|
57
57
|
`;
|
|
58
58
|
|
|
59
|
-
//
|
|
60
|
-
//
|
|
59
|
+
// Korean repos (options.language: ko) get Korean comments too (#811).
|
|
60
|
+
// Every update (--force fixes the screen to en) turned the Korean comments English, making the version.yml diff 86 lines.
|
|
61
61
|
const HEADER_KO = `# ===================================================================
|
|
62
62
|
# 프로젝트 버전 관리 파일
|
|
63
63
|
# ===================================================================
|
|
@@ -101,7 +101,7 @@ const HEADER_KO = `# ===========================================================
|
|
|
101
101
|
# ===================================================================
|
|
102
102
|
`;
|
|
103
103
|
|
|
104
|
-
//
|
|
104
|
+
// One-line comment next to each key. Language follows the repo text language (options.language), not the screen language.
|
|
105
105
|
const COMMENTS = {
|
|
106
106
|
en: {
|
|
107
107
|
versionCode: "app build number",
|
|
@@ -144,39 +144,40 @@ const COMMENTS = {
|
|
|
144
144
|
legacyDeployBranch: "development_branch 의 구 이름 — 구버전 스킬용으로 같은 값 유지",
|
|
145
145
|
},
|
|
146
146
|
};
|
|
147
|
-
|
|
147
|
+
// Comment table for a repo language: ko > Korean, anything else > English
|
|
148
|
+
export const commentsFor = (lang) => COMMENTS[lang === "ko" ? "ko" : "en"];
|
|
148
149
|
|
|
149
|
-
// last_updated_by
|
|
150
|
-
//
|
|
150
|
+
// Decide last_updated_by (#811): the git user who ran it → existing value → template_integrator.
|
|
151
|
+
// Overwriting with "template_integrator" every time loses who made the change.
|
|
151
152
|
export function resolveUpdatedBy(existingContent = "", cwd = ".") {
|
|
152
153
|
try {
|
|
153
154
|
const name = execFileSync("git", ["config", "user.name"],
|
|
154
155
|
{ cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
155
156
|
if (name) return name;
|
|
156
|
-
} catch { /* git
|
|
157
|
+
} catch { /* No git or no config (CI) — use the existing value */ }
|
|
157
158
|
const m = String(existingContent || "").match(/^\s+last_updated_by:\s*"([^"]*)"/m);
|
|
158
159
|
return m && m[1] ? m[1] : "template_integrator";
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
// metadata.template.options
|
|
162
|
-
//
|
|
163
|
-
// deploy: 'docker-ssh'|'vercel'|'none', publish: ['nexus','npm','github-packages']
|
|
164
|
-
//
|
|
165
|
-
// nexus:true →
|
|
166
|
-
// npm_publish:true →
|
|
167
|
-
// synology:true → secret_backup
|
|
168
|
-
//
|
|
169
|
-
// (options-ask.js
|
|
162
|
+
// State-machine parse of metadata.template.options.
|
|
163
|
+
// Returns (#439 deploy/publish axes): { deploy: string|null, publish: string[]|null, secretBackup: bool|null }
|
|
164
|
+
// deploy: 'docker-ssh'|'vercel'|'none', publish: subset of ['nexus','npm','github-packages']. null = not set.
|
|
165
|
+
// Old keys (nexus/npm_publish/synology) are migrated to the new axes on read (compat with files before v4.2.0):
|
|
166
|
+
// nexus:true → 'nexus' in publish + 'none' if deploy is unset (old behavior: nexus excluded server deploy)
|
|
167
|
+
// npm_publish:true → 'npm' in publish
|
|
168
|
+
// synology:true → secret_backup true if unset (#473 — the old Synology option included the secret upload, so
|
|
169
|
+
// without carrying it over, a non-interactive update silently loses the secret backup workflow)
|
|
170
|
+
// (options-ask.js imports this function — defined here (version-yml) to avoid a circular import.)
|
|
170
171
|
export function parseTemplateOptions(content) {
|
|
171
172
|
const out = { deploy: null, publish: null, secretBackup: null,
|
|
172
173
|
changelogProvider: null, changelogBaseUrl: null, codeReviewCoderabbit: null, aiPrSummary: null, projectsSync: null,
|
|
173
174
|
deployBranch: null, deployTriggerBranch: null, ciMinutesSaver: null, intent: null, semverAuto: null, appRelease: null, labelStyle: null, closeOnRelease: null, language: null, excludedWorkflows: null, storeLocales: null, storeLocalesIos: null, storeLocalesPlay: null };
|
|
174
|
-
//
|
|
175
|
+
// The development branch sits directly under metadata (#456) — outside template.options, so scanned separately.
|
|
175
176
|
out.deployBranch = readDevelopmentBranch(content);
|
|
176
177
|
let legacyNexus = null;
|
|
177
178
|
let legacyNpm = null;
|
|
178
179
|
let legacySynology = null;
|
|
179
|
-
//
|
|
180
|
+
// Normalize a value: strip quotes + trim
|
|
180
181
|
const strip = (s) => String(s).replace(/["']/g, "").trim();
|
|
181
182
|
let inTemplate = false;
|
|
182
183
|
let inOptions = false;
|
|
@@ -186,14 +187,14 @@ export function parseTemplateOptions(content) {
|
|
|
186
187
|
if (/^\s*template:/.test(line)) { inTemplate = true; continue; }
|
|
187
188
|
if (inTemplate && /^\s+options:/.test(line)) { inOptions = true; continue; }
|
|
188
189
|
if (inTemplate && inOptions) {
|
|
189
|
-
//
|
|
190
|
+
// Detect nested block headers (one level under options) — code_review / changelog (#455)
|
|
190
191
|
if (/^\s+code_review:\s*$/.test(line)) { inCodeReview = true; inChangelog = false; continue; }
|
|
191
192
|
if (/^\s+changelog:\s*$/.test(line)) { inChangelog = true; inCodeReview = false; continue; }
|
|
192
193
|
if (inCodeReview) {
|
|
193
194
|
const cm = line.match(/^\s+coderabbit:\s*(.+)/);
|
|
194
195
|
if (cm) { const v = strip(cm[1]); if (v === "true") out.codeReviewCoderabbit = true; if (v === "false") out.codeReviewCoderabbit = false; continue; }
|
|
195
|
-
// #566 — AI
|
|
196
|
-
//
|
|
196
|
+
// #566 — whether the AI change summary workflow is included. A missing key stays null (unset)
|
|
197
|
+
// so the wizard can ask once when an existing repo updates.
|
|
197
198
|
const am = line.match(/^\s+ai_summary:\s*(.+)/);
|
|
198
199
|
if (am) { const v = strip(am[1]); if (v === "true") out.aiPrSummary = true; if (v === "false") out.aiPrSummary = false; continue; }
|
|
199
200
|
}
|
|
@@ -203,8 +204,8 @@ export function parseTemplateOptions(content) {
|
|
|
203
204
|
const bm = line.match(/^\s+base_url:\s*(.*)/);
|
|
204
205
|
if (bm) { out.changelogBaseUrl = strip(bm[1]); continue; }
|
|
205
206
|
}
|
|
206
|
-
// intent(
|
|
207
|
-
//
|
|
207
|
+
// intent (project nature, #485) — matched before the deploy line (tells deploy: from intent:).
|
|
208
|
+
// An inline comment (# ...) follows the value, so take only the quoted value or the first token.
|
|
208
209
|
let im = line.match(/^\s+intent:\s*["']?([a-z]+)["']?/);
|
|
209
210
|
if (im) {
|
|
210
211
|
const v = im[1];
|
|
@@ -236,69 +237,69 @@ export function parseTemplateOptions(content) {
|
|
|
236
237
|
if (v === "false") out.secretBackup = false;
|
|
237
238
|
continue;
|
|
238
239
|
}
|
|
239
|
-
// semver
|
|
240
|
-
//
|
|
241
|
-
// strip()
|
|
240
|
+
// Automatic semver bump (#546). null (unset) is read as ON (true) by the caller (#814). Only an explicit false turns it off.
|
|
241
|
+
// Capture is limited to true|false (same as intent) — if the trailing inline comment came along with the value,
|
|
242
|
+
// strip() only removes quotes and spaces, leaving "true # ..." and the match fails silently.
|
|
242
243
|
m = line.match(/^\s+semver_auto:\s*["']?(true|false)["']?/);
|
|
243
244
|
if (m) {
|
|
244
245
|
out.semverAuto = m[1] === "true";
|
|
245
246
|
continue;
|
|
246
247
|
}
|
|
247
|
-
//
|
|
248
|
+
// Repo text language (#769) — en | ko. Unset signals an "existing integrated repo", which the caller reads as ko.
|
|
248
249
|
m = line.match(LANGUAGE_RE);
|
|
249
250
|
if (m) {
|
|
250
251
|
out.language = m[1];
|
|
251
252
|
continue;
|
|
252
253
|
}
|
|
253
|
-
//
|
|
254
|
+
// Status label style (#776) — en (English standard) | ko (legacy Korean). Unset signals an "existing integrated repo", which the caller reads as ko.
|
|
254
255
|
m = line.match(LABEL_STYLE_RE);
|
|
255
256
|
if (m) {
|
|
256
257
|
out.labelStyle = m[1];
|
|
257
258
|
continue;
|
|
258
259
|
}
|
|
259
|
-
//
|
|
260
|
+
// Deploy trigger branch (#1114) — same as the default branch when unset.
|
|
260
261
|
m = line.match(DEPLOY_TRIGGER_BRANCH_RE);
|
|
261
262
|
if (m) {
|
|
262
263
|
out.deployTriggerBranch = m[1];
|
|
263
264
|
continue;
|
|
264
265
|
}
|
|
265
|
-
// CI
|
|
266
|
+
// CI minutes saver (#1114) — off when unset.
|
|
266
267
|
m = line.match(CI_MINUTES_SAVER_RE);
|
|
267
268
|
if (m) {
|
|
268
269
|
out.ciMinutesSaver = m[1] === "true";
|
|
269
270
|
continue;
|
|
270
271
|
}
|
|
271
|
-
// Projects
|
|
272
|
+
// Projects board sync (#716). null (unset) is read by the caller as "keep if already installed, else exclude".
|
|
272
273
|
m = line.match(/^\s+projects_sync:\s*["']?(true|false)["']?/);
|
|
273
274
|
if (m) {
|
|
274
275
|
out.projectsSync = m[1] === "true";
|
|
275
276
|
continue;
|
|
276
277
|
}
|
|
277
|
-
//
|
|
278
|
+
// Close done issues on release (#771). null (unset) signals an "existing integrated repo" — the workflow does nothing.
|
|
278
279
|
m = line.match(/^\s+close_on_release:\s*["']?(true|false)["']?/);
|
|
279
280
|
if (m) {
|
|
280
281
|
out.closeOnRelease = m[1] === "true";
|
|
281
282
|
continue;
|
|
282
283
|
}
|
|
283
|
-
//
|
|
284
|
+
// Workflows not to install (#810) — inline array. The explicit way to keep updates from restoring deleted files.
|
|
284
285
|
m = line.match(/^\s+excluded_workflows:\s*\[([^\]]*)\]/);
|
|
285
286
|
if (m) {
|
|
286
287
|
out.excludedWorkflows = m[1].split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
287
288
|
continue;
|
|
288
289
|
}
|
|
289
|
-
//
|
|
290
|
+
// Store release note languages (#829) — inline array, first entry is the default. Unset keeps current behavior (one text for every language).
|
|
290
291
|
m = line.match(/^\s+store_locales:\s*\[([^\]]*)\]/);
|
|
291
292
|
if (m) {
|
|
292
293
|
out.storeLocales = m[1].split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
293
294
|
continue;
|
|
294
295
|
}
|
|
295
|
-
//
|
|
296
|
+
// Optional key used only when stores support different languages — if present, that store uses it instead of the shared store_locales.
|
|
296
297
|
m = line.match(/^\s+store_locales_(ios|play):\s*\[([^\]]*)\]/);
|
|
297
298
|
if (m) {
|
|
298
299
|
out[m[1] === "ios" ? "storeLocalesIos" : "storeLocalesPlay"] = m[2].split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
299
300
|
continue;
|
|
300
301
|
}
|
|
301
|
-
//
|
|
302
|
+
// Project nature (#553) — whether the repo goes through app review. Workflows and skills read the same value.
|
|
302
303
|
m = line.match(/^\s+app_release:\s*["']?(true|false)["']?/);
|
|
303
304
|
if (m) {
|
|
304
305
|
out.appRelease = m[1] === "true";
|
|
@@ -318,13 +319,13 @@ export function parseTemplateOptions(content) {
|
|
|
318
319
|
if (v === "false") legacySynology = false;
|
|
319
320
|
continue;
|
|
320
321
|
}
|
|
321
|
-
//
|
|
322
|
+
// Another key indented 0-4 spaces → end of the options section
|
|
322
323
|
if (/^\s{0,4}[a-z_]+:/.test(line)) { inOptions = false; inTemplate = false; }
|
|
323
324
|
}
|
|
324
|
-
//
|
|
325
|
+
// Top-level key → end of the template section
|
|
325
326
|
if (inTemplate && /^[a-z_]+:/.test(line)) { inTemplate = false; inOptions = false; }
|
|
326
327
|
}
|
|
327
|
-
// ──
|
|
328
|
+
// ── Old key migration — only when the new publish key is absent ──
|
|
328
329
|
if (out.publish === null && (legacyNexus !== null || legacyNpm !== null)) {
|
|
329
330
|
out.publish = [];
|
|
330
331
|
if (legacyNexus === true) {
|
|
@@ -333,17 +334,17 @@ export function parseTemplateOptions(content) {
|
|
|
333
334
|
}
|
|
334
335
|
if (legacyNpm === true) out.publish.push("npm");
|
|
335
336
|
}
|
|
336
|
-
//
|
|
337
|
+
// Old synology key → carry over to secret_backup (#473) — if the new key is explicit, it wins
|
|
337
338
|
if (out.secretBackup === null && legacySynology === true) out.secretBackup = true;
|
|
338
339
|
return out;
|
|
339
340
|
}
|
|
340
341
|
|
|
341
|
-
//
|
|
342
|
-
// deploy≠none & publish=[] → app (
|
|
343
|
-
// deploy=none & publish≠[] → library (
|
|
342
|
+
// Infer intent (project nature) back from saved deploy/publish values (#485 — compat with old version.yml without an intent key).
|
|
343
|
+
// deploy≠none & publish=[] → app (server/app only)
|
|
344
|
+
// deploy=none & publish≠[] → library (library only)
|
|
344
345
|
// deploy≠none & publish≠[] → both
|
|
345
346
|
// deploy=none & publish=[] → none
|
|
346
|
-
// deploy/publish
|
|
347
|
+
// If deploy/publish are still null (unset), intent cannot be inferred either → return null (so the intro question is asked).
|
|
347
348
|
export function inferIntent(deploy, publish) {
|
|
348
349
|
if (deploy == null && (publish == null)) return null;
|
|
349
350
|
const hasServer = deploy != null && deploy !== "none";
|
|
@@ -354,11 +355,11 @@ export function inferIntent(deploy, publish) {
|
|
|
354
355
|
return "none";
|
|
355
356
|
}
|
|
356
357
|
|
|
357
|
-
// v4.1.0
|
|
358
|
-
// version.yml
|
|
359
|
-
//
|
|
360
|
-
//
|
|
361
|
-
//
|
|
358
|
+
// Minimal conversion of the pre-v4.1.0 singular project_type key → project_types array (#471).
|
|
359
|
+
// On paths that do not regenerate version.yml (workflows mode), keeps it consistent with the new version_manager (which rejects
|
|
360
|
+
// an explicit singular key) — replaces only that line and leaves the rest untouched.
|
|
361
|
+
// If the array key already exists, only the leftover singular key is removed (4.1.0: singular ignored when both exist — cleanup).
|
|
362
|
+
// Returns the full converted content string, or null when there is nothing to convert.
|
|
362
363
|
export function convertLegacySingularType(content) {
|
|
363
364
|
const lines = String(content || "").split(/\r?\n/);
|
|
364
365
|
let hasArray = false, idx = -1, value = "";
|
|
@@ -372,14 +373,14 @@ export function convertLegacySingularType(content) {
|
|
|
372
373
|
lines.splice(idx, 1);
|
|
373
374
|
return lines.join("\n");
|
|
374
375
|
}
|
|
375
|
-
const type = value === "next" ? "react" : value; // next
|
|
376
|
+
const type = value === "next" ? "react" : value; // The next type was merged into react in 4.1.0
|
|
376
377
|
lines[idx] = `project_types: ["${type}"] # array of types, first entry is primary, safe to edit by hand`;
|
|
377
378
|
return lines.join("\n");
|
|
378
379
|
}
|
|
379
380
|
|
|
380
|
-
//
|
|
381
|
-
//
|
|
382
|
-
//
|
|
381
|
+
// Development (release source) branch = release PR head (#915)
|
|
382
|
+
// 2 keys: development_branch (source of truth) > deploy_branch (old name — written too, as old skills read only that)
|
|
383
|
+
// Returns the branch name, or null if neither exists
|
|
383
384
|
export const DEVELOPMENT_BRANCH_KEYS = ["development_branch", "deploy_branch"];
|
|
384
385
|
export function readDevelopmentBranch(content) {
|
|
385
386
|
const lines = String(content || "").split("\n").filter((l) => !l.startsWith("#"));
|
|
@@ -393,27 +394,27 @@ export function readDevelopmentBranch(content) {
|
|
|
393
394
|
return null;
|
|
394
395
|
}
|
|
395
396
|
|
|
396
|
-
//
|
|
397
|
+
// Extract values from the existing version.yml (line regexes, avoiding false hits on comment lines).
|
|
397
398
|
export function parseExisting(content) {
|
|
398
399
|
const text = String(content || "");
|
|
399
400
|
const line = (re) => {
|
|
400
401
|
for (const l of text.split("\n")) {
|
|
401
|
-
if (l.startsWith("#")) continue; //
|
|
402
|
+
if (l.startsWith("#")) continue; // Skip comments
|
|
402
403
|
const m = l.match(re);
|
|
403
404
|
if (m) return m[1];
|
|
404
405
|
}
|
|
405
406
|
return null;
|
|
406
407
|
};
|
|
407
|
-
// version: "x.y.z" (
|
|
408
|
+
// version: "x.y.z" (only number.number.number)
|
|
408
409
|
const version = line(/^version:\s*["']?([0-9][0-9.]*)["']?/) || "";
|
|
409
|
-
// version_code: N (
|
|
410
|
+
// version_code: N (positive integer, else 1)
|
|
410
411
|
let versionCode = parseInt(line(/^version_code:\s*([0-9]+)/) || "", 10);
|
|
411
412
|
if (!Number.isInteger(versionCode) || versionCode <= 0) versionCode = 1;
|
|
412
413
|
// project_types: ["a","b"]
|
|
413
414
|
const typesRaw = line(/^project_types:\s*(\[[^\]]*\])/);
|
|
414
415
|
let types = [];
|
|
415
416
|
if (typesRaw) types = [...typesRaw.matchAll(/"([^"]+)"/g)].map((m) => m[1]);
|
|
416
|
-
// project_paths
|
|
417
|
+
// project_paths block: " type: "path""
|
|
417
418
|
const paths = new Map();
|
|
418
419
|
let inPaths = false;
|
|
419
420
|
for (const l of text.split("\n")) {
|
|
@@ -421,10 +422,10 @@ export function parseExisting(content) {
|
|
|
421
422
|
if (inPaths) {
|
|
422
423
|
const m = l.match(/^\s+([a-z-]+):\s*"([^"]*)"/);
|
|
423
424
|
if (m) paths.set(m[1], m[2]);
|
|
424
|
-
else if (/^\S/.test(l)) inPaths = false; //
|
|
425
|
+
else if (/^\S/.test(l)) inPaths = false; // Indentation ends → end of block
|
|
425
426
|
}
|
|
426
427
|
}
|
|
427
|
-
//
|
|
428
|
+
// version + mode in the template: block (#502 — the integration scope that update mode re-runs)
|
|
428
429
|
let templateVersion = "";
|
|
429
430
|
let templateMode = null;
|
|
430
431
|
let inTemplate = false;
|
|
@@ -438,29 +439,29 @@ export function parseExisting(content) {
|
|
|
438
439
|
if (/^\S/.test(l)) break;
|
|
439
440
|
}
|
|
440
441
|
}
|
|
441
|
-
//
|
|
442
|
+
// Branch info (#456) — default_branch (repo default) and the development branch (release PR head) are separate.
|
|
442
443
|
const defaultBranch = line(/^\s*default_branch:\s*"([^"]*)"/);
|
|
443
444
|
const deployBranch = readDevelopmentBranch(text);
|
|
444
|
-
//
|
|
445
|
+
// Optional workflow options (metadata.template.options — nexus/secret_backup)
|
|
445
446
|
const options = parseTemplateOptions(text);
|
|
446
447
|
return { version, versionCode, types, paths, templateVersion, templateMode, options, defaultBranch, deployBranch };
|
|
447
448
|
}
|
|
448
449
|
|
|
449
|
-
// ──
|
|
450
|
-
// version.yml
|
|
451
|
-
//
|
|
452
|
-
//
|
|
453
|
-
// project_type(
|
|
450
|
+
// ── Keep keys the generator does not know (#835) ─────────────────────────────────────────────
|
|
451
|
+
// version.yml is rewritten from scratch on every full/version run. Writing only known keys drops what the user added —
|
|
452
|
+
// notably the documented `options.issue_helper` (branch prefix, commit template, time zone …) was silently reset on every update.
|
|
453
|
+
// So known keys are built as now, and unknown keys are written back **verbatim** (including indentation and comments).
|
|
454
|
+
// project_type (singular) was removed in v4.1.0 — keeping it makes version_manager reject the file. So it is dropped, not kept.
|
|
454
455
|
const OWNED_TOP = new Set(["version", "version_code", "project_types", "project_type", "project_paths", "metadata", "deploy"]);
|
|
455
|
-
// metadata.template.options
|
|
456
|
-
//
|
|
457
|
-
// nexus · npm_publish · synology
|
|
456
|
+
// Keys under metadata.template.options that the generator writes itself. Only keys not listed here are kept.
|
|
457
|
+
// Must match the 6-space keys buildVersionYml writes — a missing one gets written twice on every re-run.
|
|
458
|
+
// nexus · npm_publish · synology are old keys — the parser rewrites them in the new form (publish · secret_backup), so keeping them would double-record.
|
|
458
459
|
export const OWNED_OPTION_KEYS = new Set(["intent", "deploy", "publish", "secret_backup", "semver_auto", "projects_sync", "close_on_release",
|
|
459
460
|
"language", "label_style", "deploy_trigger_branch", "ci_minutes_saver", "app_release", "excluded_workflows", "store_locales", "store_locales_ios", "store_locales_play",
|
|
460
461
|
"code_review", "changelog",
|
|
461
462
|
"nexus", "npm_publish", "synology"]);
|
|
462
463
|
|
|
463
|
-
// indent
|
|
464
|
+
// Cut one key line starting at indent spaces together with its children (deeper indentation, blank lines, comments below) as one chunk.
|
|
464
465
|
function keyBlocks(lines, indent, isOwned) {
|
|
465
466
|
const keyRe = new RegExp(`^ {${indent}}([A-Za-z_][\\w-]*):`);
|
|
466
467
|
const blocks = [];
|
|
@@ -470,7 +471,7 @@ function keyBlocks(lines, indent, isOwned) {
|
|
|
470
471
|
let j = i + 1;
|
|
471
472
|
while (j < lines.length && (lines[j].trim() === "" || /^\s/.test(lines[j]) && lines[j].search(/\S/) > indent
|
|
472
473
|
|| (lines[j].trim().startsWith("#") && lines[j].search(/\S/) > indent))) j++;
|
|
473
|
-
while (j > i + 1 && lines[j - 1].trim() === "") j--; //
|
|
474
|
+
while (j > i + 1 && lines[j - 1].trim() === "") j--; // Drop blank lines at the end of the chunk
|
|
474
475
|
const block = lines.slice(i, j).join("\n");
|
|
475
476
|
if (!isOwned(m[1]) && looksWellFormed(block)) blocks.push(block);
|
|
476
477
|
i = j - 1;
|
|
@@ -478,10 +479,10 @@ function keyBlocks(lines, indent, isOwned) {
|
|
|
478
479
|
return blocks;
|
|
479
480
|
}
|
|
480
481
|
|
|
481
|
-
//
|
|
482
|
-
//
|
|
482
|
+
// If a chunk written back is broken YAML, the whole version.yml breaks — and no workflow can read the version.
|
|
483
|
+
// Check only what is possible without dependencies: matching brackets/braces, unclosed quotes. Drop it when in doubt (file integrity before preservation).
|
|
483
484
|
function looksWellFormed(block) {
|
|
484
|
-
const text = block.split("\n").map((l) => l.replace(/\s#.*$/, "")).join("\n"); //
|
|
485
|
+
const text = block.split("\n").map((l) => l.replace(/\s#.*$/, "")).join("\n"); // Leave trailing comments out of the pair check
|
|
485
486
|
const stack = [];
|
|
486
487
|
const pairs = { "]": "[", "}": "{" };
|
|
487
488
|
let quote = null;
|
|
@@ -494,11 +495,11 @@ function looksWellFormed(block) {
|
|
|
494
495
|
return !quote && stack.length === 0;
|
|
495
496
|
}
|
|
496
497
|
|
|
497
|
-
/**
|
|
498
|
+
/** Extract only what the generator does not know from the existing version.yml. { optionBlocks: string[], topBlocks: string[] } */
|
|
498
499
|
export function extractCustomYml(content) {
|
|
499
500
|
const lines = String(content || "").split(/\r?\n/);
|
|
500
501
|
const topBlocks = keyBlocks(lines, 0, (k) => OWNED_TOP.has(k));
|
|
501
|
-
// metadata → template → options
|
|
502
|
+
// Cut only the metadata → template → options range and look at 6-space indented keys
|
|
502
503
|
const find = (from, to, re) => { for (let i = from; i < to; i++) if (re.test(lines[i])) return i; return -1; };
|
|
503
504
|
const end = (start, indent) => { let j = start + 1; while (j < lines.length && (lines[j].trim() === "" || lines[j].search(/\S/) > indent)) j++; return j; };
|
|
504
505
|
const md = find(0, lines.length, /^metadata:/);
|
|
@@ -516,8 +517,8 @@ export function extractCustomYml(content) {
|
|
|
516
517
|
}
|
|
517
518
|
|
|
518
519
|
/**
|
|
519
|
-
*
|
|
520
|
-
*
|
|
520
|
+
* Helper spread straight into buildVersionYml: `...customYml(path)`.
|
|
521
|
+
* Keeps nothing if the file is missing or unreadable — a read failure must not block the update.
|
|
521
522
|
*/
|
|
522
523
|
export function customYml(file) {
|
|
523
524
|
try {
|
|
@@ -528,9 +529,9 @@ export function customYml(file) {
|
|
|
528
529
|
}
|
|
529
530
|
}
|
|
530
531
|
|
|
531
|
-
//
|
|
532
|
-
// 4.28.0
|
|
533
|
-
// 2
|
|
532
|
+
// deploy block of the existing version.yml → Map<type, Map<key,value>> (#670 — keeps user edits on re-run).
|
|
533
|
+
// To also read the broken structure 4.28.0 produced (a 2-space indented template hanging under deploy),
|
|
534
|
+
// the 2-space key `template` is treated as the end of the block, not a type.
|
|
534
535
|
export function parseDeployBlock(content) {
|
|
535
536
|
const out = new Map();
|
|
536
537
|
let inDeploy = false;
|
|
@@ -548,8 +549,8 @@ export function parseDeployBlock(content) {
|
|
|
548
549
|
return out;
|
|
549
550
|
}
|
|
550
551
|
|
|
551
|
-
//
|
|
552
|
-
//
|
|
552
|
+
// On re-run, merge with existing deploy values first (#670) — values the user edited in version.yml are not
|
|
553
|
+
// overwritten by template defaults. Existing values win; only keys newly asked this time are added.
|
|
553
554
|
export function mergeDeployValues(existingContent, fresh) {
|
|
554
555
|
const merged = parseDeployBlock(existingContent);
|
|
555
556
|
for (const [t, kv] of fresh) {
|
|
@@ -559,13 +560,13 @@ export function mergeDeployValues(existingContent, fresh) {
|
|
|
559
560
|
return merged;
|
|
560
561
|
}
|
|
561
562
|
|
|
562
|
-
// version.yml
|
|
563
|
+
// Generate the whole version.yml (metadata > template options > deploy > user blocks).
|
|
563
564
|
// opts: { version, types:[], paths:Map, pathMarkers?:Map, branch, versionCode, now, today, templateOptions? }
|
|
564
|
-
// primary
|
|
565
|
-
// now = "YYYY-MM-DD HH:MM:SS" (UTC) —
|
|
565
|
+
// The primary type has no separate key; it is project_types[0] (v4.1.0 SSOT — singular project_type key removed).
|
|
566
|
+
// now = "YYYY-MM-DD HH:MM:SS" (UTC) — injected for determinism
|
|
566
567
|
// today = "YYYY-MM-DD" (UTC)
|
|
567
|
-
// pathMarkers = Map<type, markerFilename> (project_paths
|
|
568
|
-
// templateOptions = { templateVersion, deployTarget, publishTargets, includeSecretBackup, optionsDate } (template
|
|
568
|
+
// pathMarkers = Map<type, markerFilename> (for project_paths comments)
|
|
569
|
+
// templateOptions = { templateVersion, deployTarget, publishTargets, includeSecretBackup, optionsDate } (template block)
|
|
569
570
|
export function buildVersionYml({ version, types = [], paths = new Map(), pathMarkers = new Map(), branch = "main", deployBranch = "", versionCode = 1, now, today, templateOptions = null, deployValues = new Map(), updatedBy = "template_integrator", customOptionBlocks = [], customTopBlocks = [] }) {
|
|
570
571
|
const lang = templateOptions?.language === "ko" ? "ko" : "en";
|
|
571
572
|
const C = commentsFor(lang);
|
|
@@ -573,10 +574,10 @@ export function buildVersionYml({ version, types = [], paths = new Map(), pathMa
|
|
|
573
574
|
|
|
574
575
|
let out = (lang === "ko" ? HEADER_KO : HEADER_EN) + "\n";
|
|
575
576
|
out += `version: "${version}"\n`;
|
|
576
|
-
out += `version_code: ${versionCode} # ${C.versionCode}\n`; //
|
|
577
|
+
out += `version_code: ${versionCode} # ${C.versionCode}\n`; // One space — must match what version_manager.py writes so updates produce no diff
|
|
577
578
|
out += `project_types: ${typesJson} # ${C.projectTypes}\n`;
|
|
578
579
|
|
|
579
|
-
// project_paths
|
|
580
|
+
// project_paths block. pathMarkers: Map<type, markerFilename> (if present, a " type: "path" # path/marker" comment).
|
|
580
581
|
if (paths.size) {
|
|
581
582
|
out += `project_paths: # ${C.projectPaths}\n`;
|
|
582
583
|
for (const [t, p] of paths) {
|
|
@@ -590,9 +591,9 @@ export function buildVersionYml({ version, types = [], paths = new Map(), pathMa
|
|
|
590
591
|
out += ` last_updated: "${now}"\n`;
|
|
591
592
|
out += ` last_updated_by: "${String(updatedBy || "template_integrator").replace(/"/g, "")}"\n`;
|
|
592
593
|
out += ` default_branch: "${branch}"\n`;
|
|
593
|
-
//
|
|
594
|
-
//
|
|
595
|
-
//
|
|
594
|
+
// Development (release source) branch = release PR head (#456). A separate concept from default_branch (repo default).
|
|
595
|
+
// Written only when set — if unset, skills fall back to develop.
|
|
596
|
+
// Also write deploy_branch: so old skills (changelog_cli) that read only that key do not fall back to develop (#915)
|
|
596
597
|
if (deployBranch) {
|
|
597
598
|
out += ` development_branch: "${deployBranch}"\n`;
|
|
598
599
|
out += ` deploy_branch: "${deployBranch}" # ${C.legacyDeployBranch}\n`;
|
|
@@ -600,18 +601,18 @@ export function buildVersionYml({ version, types = [], paths = new Map(), pathMa
|
|
|
600
601
|
out += ` integrated_from: "projectops"\n`;
|
|
601
602
|
out += ` integration_date: "${today}"\n`;
|
|
602
603
|
|
|
603
|
-
// template
|
|
604
|
+
// template options block. When templateOptions is given.
|
|
604
605
|
if (templateOptions) {
|
|
605
606
|
const { templateVersion = "unknown", deployTarget = "docker-ssh", publishTargets = [], includeSecretBackup = false, optionsDate = today,
|
|
606
607
|
changelogProvider = "commit", changelogBaseUrl = "", codeReviewCoderabbit = true, aiPrSummary = true, intent = null, mode = null,
|
|
607
608
|
semverAuto = true, appRelease = null, labelStyle = null, deployTriggerBranch = "", ciMinutesSaver = false, closeOnRelease = null, projectsSync = null, language = null, excludedWorkflows = null, storeLocales = null, storeLocalesIos = null, storeLocalesPlay = null } = templateOptions;
|
|
608
609
|
const publishJson = `[${publishTargets.map((t) => `"${t}"`).join(",")}]`;
|
|
609
|
-
// intent(
|
|
610
|
+
// intent (project nature, #485) — if unset, inferred from deploy/publish and recorded (skips the intro question on re-integration)
|
|
610
611
|
const intentVal = intent || inferIntent(deployTarget, publishTargets) || "manual";
|
|
611
612
|
out += ` template:\n`;
|
|
612
613
|
out += ` source: "projectops"\n`;
|
|
613
614
|
out += ` version: "${templateVersion}"\n`;
|
|
614
|
-
// mode(#502) —
|
|
615
|
+
// mode (#502) — the scope integrated into this repo. The basis for update mode re-running the same scope.
|
|
615
616
|
if (mode) out += ` mode: "${mode}" # ${C.mode}\n`;
|
|
616
617
|
out += ` integrated_date: "${optionsDate}"\n`;
|
|
617
618
|
out += ` last_update_date: "${optionsDate}"\n`;
|
|
@@ -620,27 +621,27 @@ export function buildVersionYml({ version, types = [], paths = new Map(), pathMa
|
|
|
620
621
|
out += ` deploy: "${deployTarget}"\n`;
|
|
621
622
|
out += ` publish: ${publishJson}\n`;
|
|
622
623
|
out += ` secret_backup: ${includeSecretBackup}\n`;
|
|
623
|
-
// semver
|
|
624
|
+
// Automatic semver bump (#546) — on release, decides major/minor/patch from commit titles. false means always patch.
|
|
624
625
|
out += ` semver_auto: ${semverAuto} # ${C.semverAuto}\n`;
|
|
625
|
-
// Projects
|
|
626
|
+
// Projects board sync (#716) — no key written when unset.
|
|
626
627
|
if (projectsSync !== null) out += ` projects_sync: ${projectsSync} # ${C.projectsSync}\n`;
|
|
627
|
-
//
|
|
628
|
+
// Close done issues on release (#771) — no key written when unset (existing repos keep current behavior).
|
|
628
629
|
if (closeOnRelease !== null) out += ` close_on_release: ${closeOnRelease} # ${C.closeOnRelease}\n`;
|
|
629
|
-
//
|
|
630
|
-
//
|
|
631
|
-
//
|
|
630
|
+
// Status label style (#776) — no key written when unset (existing repos unchanged).
|
|
631
|
+
// Repo text language (#769) — no key written when unset (existing repos unchanged).
|
|
632
|
+
// Install exclusion list (#810) — full regeneration, so not rewriting it would drop the user's list.
|
|
632
633
|
if (excludedWorkflows && excludedWorkflows.length) out += ` excluded_workflows: [${excludedWorkflows.map((f) => `"${f}"`).join(", ")}] # ${C.excluded}\n`;
|
|
633
|
-
//
|
|
634
|
+
// Store release note languages (#829) — no key written when unset. Full regeneration, so not rewriting it would drop the user's value.
|
|
634
635
|
if (storeLocales && storeLocales.length) out += ` store_locales: [${storeLocales.map((l) => `"${l}"`).join(", ")}] # ${C.storeLocales}\n`;
|
|
635
636
|
if (storeLocalesIos && storeLocalesIos.length) out += ` store_locales_ios: [${storeLocalesIos.map((l) => `"${l}"`).join(", ")}] # App Store: ${C.storeLocalesStore}\n`;
|
|
636
637
|
if (storeLocalesPlay && storeLocalesPlay.length) out += ` store_locales_play: [${storeLocalesPlay.map((l) => `"${l}"`).join(", ")}] # Play: ${C.storeLocalesStore}\n`;
|
|
637
638
|
if (language) out += ` language: ${language} # ${C.language}\n`;
|
|
638
639
|
if (labelStyle) out += ` label_style: ${labelStyle} # ${C.labelStyle}\n`;
|
|
639
|
-
//
|
|
640
|
+
// Deploy trigger branch (#1114) — no key written when unset (existing repos unchanged).
|
|
640
641
|
if (deployTriggerBranch) out += ` deploy_trigger_branch: "${deployTriggerBranch}" # ${C.deployTriggerBranch}\n`;
|
|
641
|
-
// CI
|
|
642
|
+
// CI minutes saver (#1114) — written only when on (existing repos unchanged).
|
|
642
643
|
if (ciMinutesSaver) out += ` ci_minutes_saver: true # ${C.ciMinutesSaver}\n`;
|
|
643
|
-
//
|
|
644
|
+
// Whether the repo deploys through app review (#553) — no key written when unset (existing repos unchanged).
|
|
644
645
|
if (appRelease !== null) {
|
|
645
646
|
out += ` app_release: ${appRelease} # ${C.appRelease}\n`;
|
|
646
647
|
}
|
|
@@ -650,13 +651,13 @@ export function buildVersionYml({ version, types = [], paths = new Map(), pathMa
|
|
|
650
651
|
out += ` changelog:\n`;
|
|
651
652
|
out += ` provider: "${changelogProvider}"\n`;
|
|
652
653
|
out += ` base_url: "${changelogBaseUrl}"\n`;
|
|
653
|
-
//
|
|
654
|
+
// Options the generator does not know (issue_helper, etc.) are written back as is (#835)
|
|
654
655
|
for (const b of customOptionBlocks) out += `${b}\n`;
|
|
655
656
|
}
|
|
656
657
|
|
|
657
|
-
// deploy
|
|
658
|
-
// WF ask
|
|
659
|
-
//
|
|
658
|
+
// deploy block. deployValues: Map<type, Map<key,value>>.
|
|
659
|
+
// Only types with WF ask values. Must be a separate top-level key after template — placed between metadata and template,
|
|
660
|
+
// template would become a child of deploy and break the metadata.template.options structure (#670).
|
|
660
661
|
const deployTypes = [...deployValues.keys()].filter((t) => deployValues.get(t) && deployValues.get(t).size > 0);
|
|
661
662
|
if (deployTypes.length) {
|
|
662
663
|
out += `\n`;
|
|
@@ -666,7 +667,7 @@ export function buildVersionYml({ version, types = [], paths = new Map(), pathMa
|
|
|
666
667
|
for (const [k, v] of deployValues.get(t)) out += ` ${k}: "${v}"\n`;
|
|
667
668
|
}
|
|
668
669
|
}
|
|
669
|
-
//
|
|
670
|
+
// Unknown top-level keys are also kept as is (#835)
|
|
670
671
|
for (const b of customTopBlocks) out += `\n${b}\n`;
|
|
671
672
|
return out;
|
|
672
673
|
}
|