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