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
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// projectops
|
|
1
|
+
// projectops option source of truth (AI agents, people and docs all read the same table).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// agent
|
|
3
|
+
// Why: option descriptions were spread over 6 docs (NPX-WIZARD, VERSION-CONTROL, ISSUE-AUTOMATION ...), so an
|
|
4
|
+
// agent had to dig through docs to learn "does this option exist, what is its default". Now one call answers it:
|
|
5
5
|
// npx projectops --mode options --json
|
|
6
6
|
//
|
|
7
|
-
//
|
|
8
|
-
// - args.js
|
|
9
|
-
// - parseTemplateOptions
|
|
10
|
-
//
|
|
7
|
+
// The table is hand-written, but test/options-schema.test.js checks it against the real code.
|
|
8
|
+
// - every CLI flag in args.js must be in flags
|
|
9
|
+
// - every key parseTemplateOptions reads must be in versionYml
|
|
10
|
+
// Adding a flag or option without listing it here fails the test.
|
|
11
11
|
//
|
|
12
|
-
//
|
|
12
|
+
// Descriptions are English — this is a machine-read table and must not change with the screen language (i18n).
|
|
13
13
|
|
|
14
14
|
import { DEPLOY_TARGETS, PUBLISH_TARGETS, INTENT_VALUES, LABEL_STYLES, CHANGELOG_PROVIDERS } from "./constants.js";
|
|
15
15
|
import { REPO_LANGUAGES } from "./repo-language.js";
|
|
@@ -29,7 +29,7 @@ export const MODES = [
|
|
|
29
29
|
{ name: "options", description: "Print this option table (add --json for machine-readable output). Read-only, no network." },
|
|
30
30
|
];
|
|
31
31
|
|
|
32
|
-
//
|
|
32
|
+
// Project types must match VALID_TYPES in context.js (checked by the test).
|
|
33
33
|
export const FLAGS = [
|
|
34
34
|
{ flag: "--mode", alias: "-m", value: "MODE", values: MODES.map((m) => m.name), default: "interactive",
|
|
35
35
|
description: "What to do. Agents and CI should always pass an explicit non-interactive mode together with --force." },
|
|
@@ -79,12 +79,12 @@ export const FLAGS = [
|
|
|
79
79
|
{ flag: "--json", description: "With --mode options: print machine-readable JSON instead of a table.", default: "off" },
|
|
80
80
|
{ flag: "--version", alias: "-v", description: "Print the projectops package version and exit." },
|
|
81
81
|
{ flag: "--help", alias: "-h", description: "Print the human-readable help and exit." },
|
|
82
|
-
//
|
|
82
|
+
// Scheduled for removal — do not use in new setups
|
|
83
83
|
{ flag: "--nexus", negation: "--no-nexus", deprecated: "Use --publish nexus. Also implies --deploy none." },
|
|
84
84
|
{ flag: "--npm-publish", negation: "--no-npm-publish", deprecated: "Use --publish npm." },
|
|
85
85
|
];
|
|
86
86
|
|
|
87
|
-
// version.yml
|
|
87
|
+
// version.yml keys. path is the location in the file; parserKey is the name parseTemplateOptions returns.
|
|
88
88
|
export const VERSION_YML = [
|
|
89
89
|
{ path: "version", type: "string", description: "Project version (x.y.z). The single source of truth; workflows sync it into build files.", edit: "workflow-managed" },
|
|
90
90
|
{ path: "version_code", type: "integer", description: "App build number. +1 on every release. Android release only; iOS and test builds use build_number.py.", edit: "workflow-managed" },
|
|
@@ -136,15 +136,15 @@ export const VERSION_YML = [
|
|
|
136
136
|
{ path: "metadata.template.options.changelog.base_url", parserKey: "changelogBaseUrl", type: "string", description: "Only for provider ollama.", edit: "by hand" },
|
|
137
137
|
];
|
|
138
138
|
|
|
139
|
-
// ── agent
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
// when :
|
|
143
|
-
// effect :
|
|
144
|
-
// omitted :
|
|
145
|
-
// example :
|
|
146
|
-
// caution :
|
|
147
|
-
// test/options-schema.test.js
|
|
139
|
+
// ── Detailed notes so an agent can read and decide on its own ───────────────────────────────────────────────
|
|
140
|
+
// A short description alone does not say "when to use it · what exactly changes in the repo · what happens if omitted".
|
|
141
|
+
// Written per entry so an AI agent calling this CLI without a person does not guess.
|
|
142
|
+
// when : when you must set this value yourself / when leaving it is fine
|
|
143
|
+
// effect : what actually changes in the repo (which files appear or disappear, which workflows run)
|
|
144
|
+
// omitted : how the value is decided when not given
|
|
145
|
+
// example : a command you can run as is
|
|
146
|
+
// caution : what is hard to undo or easy to miss
|
|
147
|
+
// test/options-schema.test.js checks that every (non-deprecated) flag and option has when and effect — add new entries here too.
|
|
148
148
|
export const FLAG_DETAILS = {
|
|
149
149
|
"--mode": {
|
|
150
150
|
when: "Always pass it explicitly from an agent or CI. Without it the CLI opens interactive questions.",
|
|
@@ -316,7 +316,7 @@ export const KEY_DETAILS = {
|
|
|
316
316
|
"metadata.template.options.changelog.base_url": { when: "Only with provider ollama.", effect: "Base URL of the Ollama server (OpenAI-compatible, ending in /v1).", omitted: "" },
|
|
317
317
|
};
|
|
318
318
|
|
|
319
|
-
//
|
|
319
|
+
// Common tasks → commands to run as is. Keeps agents from combining options wrong.
|
|
320
320
|
export const RECIPES = [
|
|
321
321
|
{ goal: "Install everything in a new repo (stack auto-detected)", command: "npx projectops --mode full --force", note: "Add --type spring,react for several stacks." },
|
|
322
322
|
{ goal: "Update an existing install to the newest templates", command: "npx projectops --mode full --force", note: "Files you modified are kept; read .github/.projectops/incoming/ and the completion summary for what was skipped." },
|
|
@@ -331,7 +331,7 @@ export const RECIPES = [
|
|
|
331
331
|
{ goal: "Install a library publish workflow", command: "npx projectops --mode workflows --force --type node --publish npm", note: "Needs the NPM_TOKEN secret." },
|
|
332
332
|
];
|
|
333
333
|
|
|
334
|
-
//
|
|
334
|
+
// Rules for an agent using this CLI without a person
|
|
335
335
|
export const AGENT_RULES = [
|
|
336
336
|
"Always pass an explicit --mode and --force. Without --force and without a TTY the command stops; with --mode interactive it needs a human.",
|
|
337
337
|
"Read before you write: run --mode doctor (state) and --mode options --json (this table). Both are read-only and need no network.",
|
|
@@ -375,7 +375,7 @@ export function buildSchema(packageVersion = "") {
|
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
//
|
|
378
|
+
// Human-readable table — printed when not JSON.
|
|
379
379
|
export function renderText(schema) {
|
|
380
380
|
const lines = [`projectops ${schema.packageVersion} — options (schema v${schema.schemaVersion})`, "", schema.usage, "", "MODES"];
|
|
381
381
|
for (const m of schema.modes) lines.push(` ${m.name.padEnd(12)} ${m.description}`);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// (
|
|
1
|
+
// Orphan type workflow detection and cleanup (#487) — detects template workflows of types dropped from the selection
|
|
2
|
+
// by a type change and neutralizes them as .bak (same approach as the legacy migration).
|
|
3
|
+
// Safety rule: only exact file name matches against the template inventory — no prefix matching
|
|
4
|
+
// (avoids hitting user custom workflows). common/ is not a type, so it is skipped in the loop.
|
|
5
5
|
import { existsSync, renameSync, rmSync, readdirSync } from "node:fs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { PATHS } from "./paths.js";
|
|
8
8
|
import { exists, listYamlFiles } from "./fsutil.js";
|
|
9
9
|
import { commonOptionalGroups, SERVER_DEPLOY_DIR } from "./workflow-groups.js";
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// Template inventory of project-types/<type>/ — direct children + server-deploy/ + publish/*/ (same scope as the copy engine)
|
|
12
12
|
function typeInventory(projectTypesDir, type) {
|
|
13
13
|
const typeDir = join(projectTypesDir, type);
|
|
14
14
|
const dirs = [typeDir, join(typeDir, SERVER_DEPLOY_DIR)];
|
|
@@ -26,10 +26,10 @@ function typeInventory(projectTypesDir, type) {
|
|
|
26
26
|
return files;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// common/
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
29
|
+
// Folders under common/ that are "copied only when selected" (#566).
|
|
30
|
+
// Turning one on makes the copy engine add it, but turning it off left the existing files in place, still running.
|
|
31
|
+
// For a user who turned the axis off that means "I turned it off, why does it run" — caught here as orphans.
|
|
32
|
+
// On/off is read from the same table as the copy engine (workflow-groups.js) (#851).
|
|
33
33
|
function commonOptionalOrphans(commonDir, opts) {
|
|
34
34
|
const out = [];
|
|
35
35
|
for (const group of commonOptionalGroups(commonDir, opts)) {
|
|
@@ -41,12 +41,12 @@ function commonOptionalOrphans(commonDir, opts) {
|
|
|
41
41
|
return out;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
//
|
|
44
|
+
// Returns as orphans the template workflows of unselected types/options that exist in the target repo.
|
|
45
45
|
export function detectOrphanWorkflows({ tempDir, targetRoot = ".", selectedTypes = [], options = null }) {
|
|
46
46
|
const projectTypesDir = join(tempDir, PATHS.workflowsDir, PATHS.projectTypesDir);
|
|
47
47
|
if (!exists(projectTypesDir)) return [];
|
|
48
48
|
const selected = new Set(selectedTypes);
|
|
49
|
-
//
|
|
49
|
+
// File names used by the selected types — cross-check (names are unique by type prefix, but as a safety net)
|
|
50
50
|
const keep = new Set();
|
|
51
51
|
for (const t of selected) for (const f of typeInventory(projectTypesDir, t)) keep.add(f);
|
|
52
52
|
const workflowsDir = join(targetRoot, PATHS.workflowsDir);
|
|
@@ -58,7 +58,7 @@ export function detectOrphanWorkflows({ tempDir, targetRoot = ".", selectedTypes
|
|
|
58
58
|
if (existsSync(join(workflowsDir, f))) orphans.push({ filename: f, type: e.name });
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
//
|
|
61
|
+
// Conditional folders under common — checked only for callers that pass options (keeps old callers' behavior).
|
|
62
62
|
if (options) {
|
|
63
63
|
const commonDir = join(projectTypesDir, "common");
|
|
64
64
|
for (const o of commonOptionalOrphans(commonDir, options)) {
|
|
@@ -69,7 +69,7 @@ export function detectOrphanWorkflows({ tempDir, targetRoot = ".", selectedTypes
|
|
|
69
69
|
return orphans.sort((a, b) => a.filename.localeCompare(b.filename));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
// .bak
|
|
72
|
+
// .bak neutralizer — tolerates partial failure (same principle as migrations applySafeMigrations).
|
|
73
73
|
export function applyOrphanCleanup(targetRoot, orphans) {
|
|
74
74
|
const workflowsDir = join(targetRoot, PATHS.workflowsDir);
|
|
75
75
|
const results = [];
|
|
@@ -77,7 +77,7 @@ export function applyOrphanCleanup(targetRoot, orphans) {
|
|
|
77
77
|
try {
|
|
78
78
|
const src = join(workflowsDir, filename);
|
|
79
79
|
const bak = `${src}.bak`;
|
|
80
|
-
if (existsSync(bak)) rmSync(bak, { force: true }); // Windows rename
|
|
80
|
+
if (existsSync(bak)) rmSync(bak, { force: true }); // Windows rename fails when the target exists
|
|
81
81
|
renameSync(src, bak);
|
|
82
82
|
results.push({ filename, action: "bak" });
|
|
83
83
|
} catch (err) {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Detect and settle per-type project paths. In a monorepo, decides which folder holds
|
|
2
|
+
// each type's version file using a 5-step priority.
|
|
3
3
|
//
|
|
4
|
-
// io
|
|
4
|
+
// io injection contract (same signatures as readline-engine):
|
|
5
5
|
// io.select({message, options:[{value,label}]}) → value | CANCEL(symbol)
|
|
6
6
|
// io.text({message, defaultValue}) → string | CANCEL
|
|
7
7
|
// io.confirm({message, initialValue}) → bool | CANCEL
|
|
8
|
-
// io.log(line) →
|
|
8
|
+
// io.log(line) → notice output (stderr if missing)
|
|
9
9
|
import { existsSync, readdirSync } from "node:fs";
|
|
10
10
|
import { join } from "node:path";
|
|
11
11
|
import { t as msg } from "../i18n/index.js";
|
|
12
12
|
import { markerForType as baseMarkerForType, extraMarkers } from "./detect.js";
|
|
13
13
|
import { normalizePath } from "../cli/args.js";
|
|
14
14
|
|
|
15
|
-
//
|
|
15
|
+
// Cancel (ESC/Ctrl+C) is the CANCEL symbol — judged only by symbol identity, without importing ui (avoids a core→ui back reference)
|
|
16
16
|
const isCancel = (v) => typeof v === "symbol";
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
// detect.js
|
|
18
|
+
// Main marker file name of a type.
|
|
19
|
+
// detect.js returns package.json for unknown types by default — wrapped here so it becomes an empty string.
|
|
20
20
|
const KNOWN_MARKER_TYPES = new Set([
|
|
21
21
|
"flutter", "react", "node", "react-native", "react-native-expo", "python", "spring",
|
|
22
22
|
]);
|
|
@@ -24,7 +24,7 @@ export function markerForType(type) {
|
|
|
24
24
|
return KNOWN_MARKER_TYPES.has(type) ? baseMarkerForType(type) : "";
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// Returns the marker file name that actually exists in the directory — including secondary markers, else the main marker (for display).
|
|
28
28
|
// (spring build.gradle/.kts/pom.xml, python pyproject/setup.py/requirements.txt)
|
|
29
29
|
export function existingMarkerInDir(type, dir) {
|
|
30
30
|
const primary = markerForType(type);
|
|
@@ -35,8 +35,8 @@ export function existingMarkerInDir(type, dir) {
|
|
|
35
35
|
return primary;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
//
|
|
39
|
-
// find
|
|
38
|
+
// Recursive file search with maxdepth 3 — collects the relative "directory" path of matching files (root is ".").
|
|
39
|
+
// find's maxdepth counts path components of the file (./a/b/f = depth 3), so compute the same way.
|
|
40
40
|
function walkFindDirs(root, { prune, match, maxDepth = 3 }) {
|
|
41
41
|
const hits = [];
|
|
42
42
|
const walk = (rel, depth) => {
|
|
@@ -46,34 +46,34 @@ function walkFindDirs(root, { prune, match, maxDepth = 3 }) {
|
|
|
46
46
|
const childDepth = depth + 1;
|
|
47
47
|
const childRel = rel ? `${rel}/${e.name}` : e.name;
|
|
48
48
|
if (e.isDirectory()) {
|
|
49
|
-
//
|
|
49
|
+
// Pruned folders exclude everything below them
|
|
50
50
|
if (prune.has(e.name)) continue;
|
|
51
|
-
//
|
|
51
|
+
// Descend only when child files stay within depth ≤ maxDepth
|
|
52
52
|
if (childDepth < maxDepth) walk(childRel, childDepth);
|
|
53
|
-
// childDepth === maxDepth-0
|
|
54
|
-
else if (childDepth === maxDepth) { /*
|
|
53
|
+
// Files inside a directory at childDepth === maxDepth-0 are at depth maxDepth+1 → find does not see them
|
|
54
|
+
else if (childDepth === maxDepth) { /* Files only up to maxDepth — no need to descend */ }
|
|
55
55
|
} else if (childDepth <= maxDepth && match(e.name)) {
|
|
56
56
|
hits.push(rel === "" ? "." : rel);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
walk("", 0);
|
|
61
|
-
return [...new Set(hits)].sort(); //
|
|
61
|
+
return [...new Set(hits)].sort(); // Dedupe + sort
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
//
|
|
65
|
-
//
|
|
64
|
+
// Search marker file candidates per type.
|
|
65
|
+
// Returns an array of candidate directory relative paths (root is ".").
|
|
66
66
|
export function findTypePathCandidates(root, type) {
|
|
67
|
-
// ── Spring
|
|
68
|
-
// version_manager
|
|
69
|
-
// android/
|
|
67
|
+
// ── Spring multi-module: collapse to the settings.gradle(.kts) folder = module root ──
|
|
68
|
+
// version_manager updates every build.gradle under that folder, so submodules are not expanded.
|
|
69
|
+
// settings.gradle under android/ (Flutter/RN) is not spring, so prune it.
|
|
70
70
|
if (type === "spring") {
|
|
71
71
|
const mm = walkFindDirs(root, {
|
|
72
72
|
prune: new Set(["node_modules", ".git", "build", "dist", ".gradle", "android", "ios"]),
|
|
73
73
|
match: (n) => n === "settings.gradle" || n === "settings.gradle.kts",
|
|
74
74
|
});
|
|
75
75
|
if (mm.length) return mm;
|
|
76
|
-
// settings.gradle
|
|
76
|
+
// No settings.gradle → single module, fall back to build.gradle below
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const namesByType = {
|
|
@@ -91,7 +91,7 @@ export function findTypePathCandidates(root, type) {
|
|
|
91
91
|
"node_modules", ".git", "build", "dist", ".dart_tool", "android", "ios",
|
|
92
92
|
".gradle", "venv", ".venv", "__pycache__",
|
|
93
93
|
]);
|
|
94
|
-
//
|
|
94
|
+
// If found by a higher-priority marker, use only that
|
|
95
95
|
let found = [];
|
|
96
96
|
for (const n of names) {
|
|
97
97
|
found = walkFindDirs(root, { prune, match: (name) => name === n });
|
|
@@ -100,37 +100,37 @@ export function findTypePathCandidates(root, type) {
|
|
|
100
100
|
|
|
101
101
|
return found.filter((d) => {
|
|
102
102
|
if (type === "flutter") {
|
|
103
|
-
// example/
|
|
103
|
+
// Exclude example/ + require lib/ alongside — avoids false hits
|
|
104
104
|
if (d.includes("example")) return false;
|
|
105
105
|
const libDir = d === "." ? join(root, "lib") : join(root, d, "lib");
|
|
106
106
|
if (!existsSync(libDir)) return false;
|
|
107
107
|
}
|
|
108
108
|
if (type === "spring") {
|
|
109
|
-
//
|
|
109
|
+
// Exclude false hits on android/build.gradle from Flutter/RN
|
|
110
110
|
if (d.includes("android")) return false;
|
|
111
111
|
}
|
|
112
112
|
return true;
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
//
|
|
117
|
-
// (5
|
|
118
|
-
// ① paths
|
|
119
|
-
// ②
|
|
120
|
-
// ③ existingPaths(version.yml
|
|
121
|
-
// ④
|
|
122
|
-
// ⑤
|
|
116
|
+
// Detect and confirm paths for all selected types and settle a Map<type,path>
|
|
117
|
+
// (5-step priority).
|
|
118
|
+
// ① already in paths (--paths) → keep
|
|
119
|
+
// ② marker at the root → "." automatically
|
|
120
|
+
// ③ existingPaths (saved in version.yml)
|
|
121
|
+
// ④ candidate scan
|
|
122
|
+
// ⑤ branch — non-interactive: existing value → single candidate → root fallback / interactive: confirm, select, manual input
|
|
123
123
|
export async function resolveProjectPaths({
|
|
124
124
|
root, types = [], paths = new Map(), existingPaths = new Map(),
|
|
125
125
|
force = false, tty = true, io = {},
|
|
126
126
|
}) {
|
|
127
127
|
const say = io.log || ((m) => process.stderr.write(`${m}\n`));
|
|
128
|
-
const result = new Map(paths); // --paths
|
|
129
|
-
const targets = types.filter((t) => t !== "basic"); // basic
|
|
128
|
+
const result = new Map(paths); // Keep --paths presets (the caller's Map is not mutated)
|
|
129
|
+
const targets = types.filter((t) => t !== "basic"); // basic needs no path
|
|
130
130
|
if (targets.length === 0) return result;
|
|
131
131
|
|
|
132
132
|
const total = targets.length;
|
|
133
|
-
// ──
|
|
133
|
+
// ── Intro notice (detection result + what will happen) ──
|
|
134
134
|
say("");
|
|
135
135
|
if (total > 1) say(msg("paths.multi", { total }));
|
|
136
136
|
else say(msg("paths.single", { type: targets[0] }));
|
|
@@ -144,13 +144,13 @@ export async function resolveProjectPaths({
|
|
|
144
144
|
idx += 1;
|
|
145
145
|
const prog = `[${idx}/${total}]`;
|
|
146
146
|
|
|
147
|
-
// ① --paths
|
|
147
|
+
// ① already given via --paths etc. → top priority
|
|
148
148
|
if (result.get(t)) {
|
|
149
149
|
say(msg("paths.byFlag", { type: t, path: result.get(t) }));
|
|
150
150
|
continue;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
// ②
|
|
153
|
+
// ② marker at the root → settle "." automatically (including secondary markers)
|
|
154
154
|
const rootMarker = existingMarkerInDir(t, root);
|
|
155
155
|
if (rootMarker && existsSync(join(root, rootMarker))) {
|
|
156
156
|
result.set(t, ".");
|
|
@@ -158,14 +158,14 @@ export async function resolveProjectPaths({
|
|
|
158
158
|
continue;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
// ③
|
|
161
|
+
// ③ saved value in the existing version.yml → default suggestion
|
|
162
162
|
const existing = existingPaths.get(t) || "";
|
|
163
163
|
|
|
164
|
-
// ④
|
|
164
|
+
// ④ candidate search
|
|
165
165
|
const candidates = findTypePathCandidates(root, t);
|
|
166
166
|
let chosen = "";
|
|
167
167
|
|
|
168
|
-
// ── ⑤-a
|
|
168
|
+
// ── ⑤-a non-interactive (--force or no TTY) ──
|
|
169
169
|
if (force || !tty) {
|
|
170
170
|
if (existing) {
|
|
171
171
|
chosen = existing;
|
|
@@ -181,8 +181,8 @@ export async function resolveProjectPaths({
|
|
|
181
181
|
continue;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
// ── ⑤-b
|
|
185
|
-
const EXCLUDE = "이 타입 제외"; //
|
|
184
|
+
// ── ⑤-b interactive: branch by candidate count + type escape hatch (#487) ──
|
|
185
|
+
const EXCLUDE = "이 타입 제외"; // Sentinel — exposed as a Korean value (same pattern as the existing "직접 입력")
|
|
186
186
|
let excluded = false;
|
|
187
187
|
if (candidates.length === 1) {
|
|
188
188
|
const cand = candidates[0];
|
|
@@ -201,11 +201,11 @@ export async function resolveProjectPaths({
|
|
|
201
201
|
});
|
|
202
202
|
if (sel === EXCLUDE) excluded = true;
|
|
203
203
|
else if (!isCancel(sel) && sel != null && sel !== "직접 입력") chosen = sel;
|
|
204
|
-
// ESC
|
|
204
|
+
// ESC/manual input → manual input loop below
|
|
205
205
|
} else if (candidates.length > 1) {
|
|
206
206
|
say("");
|
|
207
207
|
say(msg("paths.multiFound", { prog, type: t, count: candidates.length }));
|
|
208
|
-
//
|
|
208
|
+
// Candidates + 'manual input'/'exclude this type' menu — the value itself is Korean (avoids exposing a sentinel)
|
|
209
209
|
const options = candidates.map((c) => ({
|
|
210
210
|
value: c,
|
|
211
211
|
label: `${c} (${existingMarkerInDir(t, c === "." ? root : join(root, c))})`,
|
|
@@ -213,7 +213,7 @@ export async function resolveProjectPaths({
|
|
|
213
213
|
options.push({ value: "직접 입력", label: msg("paths.manual") });
|
|
214
214
|
options.push({ value: EXCLUDE, label: msg("paths.exclude", { type: t }) });
|
|
215
215
|
const sel = await io.select({ message: msg("paths.selectPrompt", { type: t }), options });
|
|
216
|
-
// ESC(
|
|
216
|
+
// ESC (cancel) also falls back to manual input
|
|
217
217
|
if (sel === EXCLUDE) excluded = true;
|
|
218
218
|
else if (!isCancel(sel) && sel != null && sel !== "직접 입력") chosen = sel;
|
|
219
219
|
} else {
|
|
@@ -221,18 +221,18 @@ export async function resolveProjectPaths({
|
|
|
221
221
|
say(msg("paths.notFound", { prog, type: t }));
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
// ──
|
|
224
|
+
// ── Manual input loop (when not settled above) — includes the exclude escape hatch (#487) ──
|
|
225
225
|
while (!chosen && !excluded) {
|
|
226
226
|
const hintMarker = existingMarkerInDir(t, root);
|
|
227
227
|
let prompt = msg("paths.inputPrompt", { type: t, marker: hintMarker });
|
|
228
228
|
if (existing) prompt += msg("paths.inputCurrent", { value: existing });
|
|
229
229
|
prompt += "): ";
|
|
230
230
|
let input = await io.text({ message: prompt, defaultValue: "" });
|
|
231
|
-
if (isCancel(input) || input == null) input = ""; // ESC →
|
|
231
|
+
if (isCancel(input) || input == null) input = ""; // ESC → empty (fallback below)
|
|
232
232
|
input = String(input).trim();
|
|
233
|
-
//
|
|
233
|
+
// Empty → existing value or root — decided before normalizePath
|
|
234
234
|
input = input === "" ? (existing || ".") : normalizePath(input);
|
|
235
|
-
//
|
|
235
|
+
// Validate: check the marker exists at the entered path (including secondary markers)
|
|
236
236
|
const m = existingMarkerInDir(t, input === "." ? root : join(root, input));
|
|
237
237
|
if (m && existsSync(join(root, input === "." ? "" : input, m))) {
|
|
238
238
|
chosen = input;
|
|
@@ -248,7 +248,7 @@ export async function resolveProjectPaths({
|
|
|
248
248
|
});
|
|
249
249
|
if (act === "force") chosen = input;
|
|
250
250
|
else if (act === EXCLUDE) excluded = true;
|
|
251
|
-
// retry/ESC →
|
|
251
|
+
// retry/ESC → keep looping
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
@@ -261,10 +261,10 @@ export async function resolveProjectPaths({
|
|
|
261
261
|
say(` ✅ ${t} → ${chosen}`);
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
// ──
|
|
264
|
+
// ── Summary + warning for duplicate marker files ──
|
|
265
265
|
say("");
|
|
266
266
|
say(msg("paths.summary"));
|
|
267
|
-
const fileToTypes = new Map(); //
|
|
267
|
+
const fileToTypes = new Map(); // Marker file relative path → types using that file
|
|
268
268
|
for (const [pt, pp] of result) {
|
|
269
269
|
const m = existingMarkerInDir(pt, pp === "." ? root : join(root, pp));
|
|
270
270
|
const file = pp === "." ? m : `${pp}/${m}`;
|
|
@@ -274,7 +274,7 @@ export async function resolveProjectPaths({
|
|
|
274
274
|
}
|
|
275
275
|
for (const [file, ts] of fileToTypes) {
|
|
276
276
|
if (ts.length > 1) {
|
|
277
|
-
//
|
|
277
|
+
// Idempotent, so warn only instead of blocking
|
|
278
278
|
say(msg("paths.duplicate", { types: ts.join(" "), file }));
|
|
279
279
|
say(msg("paths.duplicateNote"));
|
|
280
280
|
}
|
|
@@ -283,8 +283,8 @@ export async function resolveProjectPaths({
|
|
|
283
283
|
return result;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
//
|
|
287
|
-
//
|
|
286
|
+
// Apply types excluded at the path step (#487) — remove non-basic types missing from paths.
|
|
287
|
+
// If all are excluded, fall back to basic (zero types is not allowed). No-op for non-interactive, which cannot exclude.
|
|
288
288
|
export function filterExcludedTypes(types, paths) {
|
|
289
289
|
const kept = types.filter((t) => t === "basic" || paths.has(t));
|
|
290
290
|
return kept.length ? kept : ["basic"];
|
package/src/core/paths.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Path constants
|
|
2
2
|
export const PATHS = {
|
|
3
3
|
tempDir: ".template_download_temp",
|
|
4
4
|
versionFile: "version.yml",
|
|
@@ -7,7 +7,7 @@ export const PATHS = {
|
|
|
7
7
|
projectTypesDir: "project-types",
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// Template repo address source of truth: owner/name > web, git, raw URLs (the no-repo-url-literal rule blocks literals in src/)
|
|
11
11
|
export const TEMPLATE_REPO_OWNER = "Cassiiopeia";
|
|
12
12
|
export const TEMPLATE_REPO_SLUG = `${TEMPLATE_REPO_OWNER}/projectops`;
|
|
13
13
|
export const TEMPLATE_REPO_WEB_URL = `https://github.com/${TEMPLATE_REPO_SLUG}`;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// ⚠️
|
|
1
|
+
// Detect workflows that keep both an automatic trigger and sample values (#662)
|
|
2
|
+
// Sample values (your-project, etc.) slip past the unreplaced token (__X__) check, so doctor passed while failed runs piled up on every push or label.
|
|
3
|
+
// ⚠️ Line-based, no YAML parser (zero dependencies — the installer CLI has empty dependencies).
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// The 3 triggers a person must fire by hand — everything else counts as automatic
|
|
8
8
|
const MANUAL_EVENTS = new Set(["workflow_dispatch", "workflow_call", "repository_dispatch"]);
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// Sample value test: your-/your_ prefixed words, example.com-style domains, unreplaced tokens (excluding heredoc delimiters __SUH_*__)
|
|
11
11
|
const PLACEHOLDER_VALUE_RES = [
|
|
12
12
|
/(^|[^a-z0-9])your[-_][a-z0-9]/i,
|
|
13
13
|
/(^|[.@/])example\.(com|org|net)\b/i,
|
|
14
14
|
/__(?!SUH_)[A-Z][A-Z0-9_]*__/,
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
-
//
|
|
17
|
+
// Only env-style lines: ` KEY: "value"` (avoids false hits on URLs and text inside run scripts)
|
|
18
18
|
const ENV_LINE_RE = /^\s*([A-Z][A-Z0-9_]*):\s*(?:"([^"]*)"|'([^']*)'|([^\s#][^#]*?))\s*(?:#.*)?$/;
|
|
19
19
|
|
|
20
20
|
const isCommented = (line) => /^\s*#/.test(line);
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* on:
|
|
23
|
+
* on: block > event names (inline `on: push`, `on: [a, b]`, and block form — 3 shapes)
|
|
24
24
|
*/
|
|
25
25
|
export function parseTriggerEvents(text) {
|
|
26
26
|
const lines = String(text || "").split(/\r?\n/);
|
|
@@ -29,7 +29,7 @@ export function parseTriggerEvents(text) {
|
|
|
29
29
|
const inline = lines[start].replace(/^[^:]*:\s*/, "").replace(/#.*$/, "").trim();
|
|
30
30
|
if (inline) return inline.replace(/^\[|\]$/g, "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
31
31
|
|
|
32
|
-
//
|
|
32
|
+
// Block form: only keys at the indent depth of the first child line count as events
|
|
33
33
|
const events = [];
|
|
34
34
|
let depth = null;
|
|
35
35
|
for (const line of lines.slice(start + 1)) {
|
|
@@ -45,7 +45,7 @@ export function parseTriggerEvents(text) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Workflow body > env lines that still hold sample values [{ key, value, line }]
|
|
49
49
|
*/
|
|
50
50
|
export function findPlaceholderValues(text) {
|
|
51
51
|
const found = [];
|
|
@@ -62,7 +62,7 @@ export function findPlaceholderValues(text) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Installed workflow folder > files with both an automatic trigger and sample values [{ file, triggers, values }]
|
|
66
66
|
*/
|
|
67
67
|
export function scanPlaceholderTriggers(workflowsDir) {
|
|
68
68
|
if (!existsSync(workflowsDir)) return [];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// language: ko
|
|
1
|
+
// Repo text language (#769): English ("en") is the source, Korean ("ko") is an overlay.
|
|
2
|
+
// Keeping a Korean copy next to every file lets the two drift, so the Korean version lives only in .github/i18n/ko/
|
|
3
|
+
// and, with language: ko, is copied over the same relative paths right after the copy.
|
|
4
4
|
import { join, relative, dirname } from "node:path";
|
|
5
5
|
import { existsSync, readdirSync, copyFileSync, mkdirSync, statSync } from "node:fs";
|
|
6
6
|
|
|
7
7
|
export const REPO_LANGUAGES = ["en", "ko"];
|
|
8
8
|
|
|
9
|
-
// version.yml
|
|
10
|
-
// (
|
|
9
|
+
// Decision when version.yml has no saved value. New installs get English; existing installs keep Korean.
|
|
10
|
+
// (Same principle as label_style — an update alone must not change the text in a user repo.)
|
|
11
11
|
export function resolveRepoLanguage({ flag, stored, existing }) {
|
|
12
12
|
if (REPO_LANGUAGES.includes(flag)) return flag;
|
|
13
13
|
if (REPO_LANGUAGES.includes(stored)) return stored;
|
|
@@ -24,11 +24,11 @@ function walk(dir) {
|
|
|
24
24
|
return out;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
// failed
|
|
30
|
-
//
|
|
31
|
-
//
|
|
27
|
+
// Korean mode: copy every overlay file to the same relative path under targetRoot/.github/.
|
|
28
|
+
// Returns { changed, failed }. changed holds copied paths relative to the repo root (.github/...),
|
|
29
|
+
// failed holds { file, error } entries that could not be copied. Both are empty for en or when there is no overlay.
|
|
30
|
+
// One failure does not stop the rest — stopping at the first failure would leave English and Korean mixed, or all English.
|
|
31
|
+
// Never throws: the English template simply remains, which is no reason to kill the install. The caller reports failed instead.
|
|
32
32
|
export function applyRepoLanguage(tempDir, targetRoot, language) {
|
|
33
33
|
const changed = [];
|
|
34
34
|
const failed = [];
|