@azrico/azcli 1.2.3 → 1.2.5
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 +5 -0
- package/dist/cli/create-cli.js +37 -0
- package/dist/cli/create-cli.js.map +1 -0
- package/dist/cli/index.js +23 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/options.js +17 -0
- package/dist/cli/options.js.map +1 -0
- package/dist/core/files.js +82 -0
- package/dist/core/files.js.map +1 -0
- package/dist/core/json.js +16 -0
- package/dist/core/json.js.map +1 -0
- package/dist/core/logger.js +26 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/process.js +125 -0
- package/dist/core/process.js.map +1 -0
- package/dist/core/project-type.js +41 -0
- package/dist/core/project-type.js.map +1 -0
- package/dist/core/strings.js +20 -0
- package/dist/core/strings.js.map +1 -0
- package/dist/features/build/build.js +46 -0
- package/dist/features/build/build.js.map +1 -0
- package/dist/features/build/command.js +17 -0
- package/dist/features/build/command.js.map +1 -0
- package/dist/features/build/wordpress.js +135 -0
- package/dist/features/build/wordpress.js.map +1 -0
- package/dist/features/clean/clean.js +27 -0
- package/dist/features/clean/clean.js.map +1 -0
- package/dist/features/clean/command.js +13 -0
- package/dist/features/clean/command.js.map +1 -0
- package/dist/features/optimize-transcripts/agent-runner.js +40 -0
- package/dist/features/optimize-transcripts/agent-runner.js.map +1 -0
- package/dist/features/optimize-transcripts/command.js +24 -0
- package/dist/features/optimize-transcripts/command.js.map +1 -0
- package/dist/features/optimize-transcripts/optimize.js +72 -0
- package/dist/features/optimize-transcripts/optimize.js.map +1 -0
- package/dist/features/optimize-transcripts/prompts.js +39 -0
- package/dist/features/optimize-transcripts/prompts.js.map +1 -0
- package/dist/features/optimize-transcripts/redact.js +57 -0
- package/dist/features/optimize-transcripts/redact.js.map +1 -0
- package/dist/features/optimize-transcripts/secret-remover.js +85 -0
- package/dist/features/optimize-transcripts/secret-remover.js.map +1 -0
- package/dist/features/package/command.js +13 -0
- package/dist/features/package/command.js.map +1 -0
- package/dist/features/package/packager.js +132 -0
- package/dist/features/package/packager.js.map +1 -0
- package/dist/features/publish/command.js +13 -0
- package/dist/features/publish/command.js.map +1 -0
- package/dist/features/publish/publish.js +29 -0
- package/dist/features/publish/publish.js.map +1 -0
- package/dist/features/transcripts/command.js +27 -0
- package/dist/features/transcripts/command.js.map +1 -0
- package/dist/features/transcripts/extract.js +148 -0
- package/dist/features/transcripts/extract.js.map +1 -0
- package/dist/features/transcripts/jsonl.js +100 -0
- package/dist/features/transcripts/jsonl.js.map +1 -0
- package/dist/features/transcripts/options.js +53 -0
- package/dist/features/transcripts/options.js.map +1 -0
- package/dist/features/transcripts/render-markdown.js +105 -0
- package/dist/features/transcripts/render-markdown.js.map +1 -0
- package/dist/features/transcripts/sources/claude.js +150 -0
- package/dist/features/transcripts/sources/claude.js.map +1 -0
- package/dist/features/transcripts/sources/codex.js +171 -0
- package/dist/features/transcripts/sources/codex.js.map +1 -0
- package/dist/features/transcripts/types.js +5 -0
- package/dist/features/transcripts/types.js.map +1 -0
- package/dist/features/update/command.js +16 -0
- package/dist/features/update/command.js.map +1 -0
- package/dist/features/update/composer.js +35 -0
- package/dist/features/update/composer.js.map +1 -0
- package/dist/features/update/filter-options.js +23 -0
- package/dist/features/update/filter-options.js.map +1 -0
- package/dist/features/update/update.js +28 -0
- package/dist/features/update/update.js.map +1 -0
- package/dist/features/update/yarn.js +30 -0
- package/dist/features/update/yarn.js.map +1 -0
- package/dist/features/verify-changes/changed-files.js +36 -0
- package/dist/features/verify-changes/changed-files.js.map +1 -0
- package/dist/features/verify-changes/command.js +27 -0
- package/dist/features/verify-changes/command.js.map +1 -0
- package/dist/features/verify-changes/config.js +91 -0
- package/dist/features/verify-changes/config.js.map +1 -0
- package/dist/features/verify-changes/report.js +30 -0
- package/dist/features/verify-changes/report.js.map +1 -0
- package/dist/features/verify-changes/select.js +39 -0
- package/dist/features/verify-changes/select.js.map +1 -0
- package/dist/features/verify-changes/verify.js +54 -0
- package/dist/features/verify-changes/verify.js.map +1 -0
- package/dist/features/worktree/command.js +55 -0
- package/dist/features/worktree/command.js.map +1 -0
- package/dist/features/worktree/config.js +115 -0
- package/dist/features/worktree/config.js.map +1 -0
- package/dist/features/worktree/git.js +62 -0
- package/dist/features/worktree/git.js.map +1 -0
- package/dist/features/worktree/start.js +156 -0
- package/dist/features/worktree/start.js.map +1 -0
- package/dist/features/worktree/status.js +50 -0
- package/dist/features/worktree/status.js.map +1 -0
- package/dist/features/worktree/sync.js +107 -0
- package/dist/features/worktree/sync.js.map +1 -0
- package/dist/features/yarn/commands.js +18 -0
- package/dist/features/yarn/commands.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChangedFiles = exports.resolveBase = void 0;
|
|
4
|
+
const defaultBases = ['origin/main', 'origin/master', 'main', 'master'];
|
|
5
|
+
const lines = (text) => text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
6
|
+
async function refExists(run, cwd, ref) {
|
|
7
|
+
try {
|
|
8
|
+
await run('git', ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`], { cwd, quiet: true });
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function resolveBase(run, cwd, requested) {
|
|
16
|
+
if (requested) {
|
|
17
|
+
if (!(await refExists(run, cwd, requested)))
|
|
18
|
+
throw new Error(`Base ref not found: ${requested}`);
|
|
19
|
+
return requested;
|
|
20
|
+
}
|
|
21
|
+
for (const ref of defaultBases)
|
|
22
|
+
if (await refExists(run, cwd, ref))
|
|
23
|
+
return ref;
|
|
24
|
+
return 'HEAD';
|
|
25
|
+
}
|
|
26
|
+
exports.resolveBase = resolveBase;
|
|
27
|
+
/** Paths relative to `cwd` changed since the merge-base with `base`: committed, staged, unstaged, and untracked. */
|
|
28
|
+
async function getChangedFiles(run, cwd, base) {
|
|
29
|
+
const options = { cwd, quiet: true };
|
|
30
|
+
const mergeBase = (await run('git', ['merge-base', base, 'HEAD'], options)).stdout.trim();
|
|
31
|
+
const diff = await run('git', ['diff', '--name-only', '--no-renames', '--relative', mergeBase], options);
|
|
32
|
+
const untracked = await run('git', ['ls-files', '--others', '--exclude-standard'], options);
|
|
33
|
+
return [...new Set([...lines(diff.stdout), ...lines(untracked.stdout)])].sort();
|
|
34
|
+
}
|
|
35
|
+
exports.getChangedFiles = getChangedFiles;
|
|
36
|
+
//# sourceMappingURL=changed-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changed-files.js","sourceRoot":"","sources":["../../../src/features/verify-changes/changed-files.ts"],"names":[],"mappings":";;;AAEA,MAAM,YAAY,GAAG,CAAC,aAAa,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAExE,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAE/F,KAAK,UAAU,SAAS,CAAC,GAAkB,EAAE,GAAW,EAAE,GAAW;IACpE,IAAI;QACH,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,GAAG,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAChG,OAAO,IAAI,CAAC;KACZ;IAAC,MAAM;QACP,OAAO,KAAK,CAAC;KACb;AACF,CAAC;AAEM,KAAK,UAAU,WAAW,CAAC,GAAkB,EAAE,GAAW,EAAE,SAAkB;IACpF,IAAI,SAAS,EAAE;QACd,IAAI,CAA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../../core/logger");
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const report_1 = require("./report");
|
|
6
|
+
const verify_1 = require("./verify");
|
|
7
|
+
const command = {
|
|
8
|
+
command: 'verify-changes',
|
|
9
|
+
describe: 'Run the project checks that apply to the changed files',
|
|
10
|
+
builder: (cli) => cli
|
|
11
|
+
.option('path', { type: 'string', describe: 'Project directory' })
|
|
12
|
+
.option('base', { type: 'string', describe: 'Compare against this ref (default: config base, else main/master)' })
|
|
13
|
+
.option('profile', { type: 'string', array: true, describe: 'Profiles from .azcli/verify.json (default: all)' })
|
|
14
|
+
.option('json', { type: 'boolean', describe: 'Print the full report as JSON' })
|
|
15
|
+
.option('strict', { type: 'boolean', describe: 'Treat checks that were not run as failures' })
|
|
16
|
+
.epilog(config_1.configHelp),
|
|
17
|
+
handler: async (args) => {
|
|
18
|
+
const report = await (0, verify_1.verifyChanges)(args);
|
|
19
|
+
if (args.json)
|
|
20
|
+
console.log(JSON.stringify(report, null, 2));
|
|
21
|
+
else
|
|
22
|
+
(0, logger_1.showMessage)((0, report_1.formatReport)(report, args.strict), 'text', false);
|
|
23
|
+
process.exitCode = (0, report_1.reportExitCode)(report, args.strict);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
exports.default = command;
|
|
27
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/features/verify-changes/command.ts"],"names":[],"mappings":";;AACA,8CAAgD;AAChD,qCAAsC;AACtC,qCAAwD;AACxD,qCAAyC;AASzC,MAAM,OAAO,GAA4C;IACxD,OAAO,EAAE,gBAAgB;IACzB,QAAQ,EAAE,wDAAwD;IAClE,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;SACnB,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;SACjE,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,mEAAmE,EAAE,CAAC;SACjH,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,iDAAiD,EAAE,CAAC;SAC/G,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,+BAA+B,EAAE,CAAC;SAC9E,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,4CAA4C,EAAE,CAAC;SAC7F,MAAM,CAAC,mBAAU,CAAC;IACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACvB,MAAM,MAAM,GAAG,MAAM,IAAA,sBAAa,EAAC,IAAI,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;;YACvD,IAAA,oBAAW,EAAC,IAAA,qBAAY,EAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACnE,OAAO,CAAC,QAAQ,GAAG,IAAA,uBAAc,EAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;CACD,CAAC;AACF,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadConfig = exports.parseConfig = exports.configHelp = exports.configFile = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const json_1 = require("../../core/json");
|
|
10
|
+
exports.configFile = node_path_1.default.join('.azcli', 'verify.json');
|
|
11
|
+
exports.configHelp = `Config file: .azcli/verify.json in the project root (JSON). Example:
|
|
12
|
+
|
|
13
|
+
{
|
|
14
|
+
"base": "master",
|
|
15
|
+
"profiles": {
|
|
16
|
+
"web": [
|
|
17
|
+
{
|
|
18
|
+
"name": "typescript",
|
|
19
|
+
"command": "yarn",
|
|
20
|
+
"args": ["tsc", "--noEmit"],
|
|
21
|
+
"cwd": "web",
|
|
22
|
+
"paths": ["web/**/*.ts"]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Fields:
|
|
29
|
+
base optional. Ref to compare against. Default: first existing of
|
|
30
|
+
origin/main, origin/master, main, master, else HEAD.
|
|
31
|
+
profiles required. Profile name -> array of checks. Pick with --profile.
|
|
32
|
+
name required. Label shown in the report.
|
|
33
|
+
command required. Executable on PATH; run without a shell.
|
|
34
|
+
args optional. Array of strings, one entry per argument.
|
|
35
|
+
cwd optional. Directory relative to the project root, inside it.
|
|
36
|
+
paths optional. Globs relative to the project root: * stays within a
|
|
37
|
+
folder, ** spans folders, ? is one character. Omit to always run.
|
|
38
|
+
|
|
39
|
+
A check runs only if a file changed since the base (committed, staged,
|
|
40
|
+
unstaged, or untracked) matches its paths. Each check ends as passed, failed
|
|
41
|
+
(nonzero exit), or not-run (no matching changes, or the command could not
|
|
42
|
+
start). Exit code is 1 if any check failed; --strict also fails on not-run.`;
|
|
43
|
+
function stringArray(value, label) {
|
|
44
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string'))
|
|
45
|
+
throw new Error(`${label} must be an array of strings`);
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
function parseConfig(value) {
|
|
49
|
+
if (!(0, json_1.isRecord)(value) || !(0, json_1.isRecord)(value.profiles))
|
|
50
|
+
throw new Error(`${exports.configFile} must contain a "profiles" object`);
|
|
51
|
+
const profiles = {};
|
|
52
|
+
for (const [profile, checks] of Object.entries(value.profiles)) {
|
|
53
|
+
if (!Array.isArray(checks))
|
|
54
|
+
throw new Error(`Profile "${profile}" must be an array of checks`);
|
|
55
|
+
profiles[profile] = checks.map((check, index) => {
|
|
56
|
+
const label = `Profile "${profile}" check ${index + 1}`;
|
|
57
|
+
if (!(0, json_1.isRecord)(check))
|
|
58
|
+
throw new Error(`${label} must be an object`);
|
|
59
|
+
const name = (0, json_1.asString)(check.name);
|
|
60
|
+
const command = (0, json_1.asString)(check.command);
|
|
61
|
+
if (!name)
|
|
62
|
+
throw new Error(`${label} needs a "name"`);
|
|
63
|
+
if (!command)
|
|
64
|
+
throw new Error(`${label} ("${name}") needs a "command"`);
|
|
65
|
+
return {
|
|
66
|
+
name,
|
|
67
|
+
command,
|
|
68
|
+
args: check.args === undefined ? [] : stringArray(check.args, `${label} "args"`),
|
|
69
|
+
cwd: (0, json_1.asString)(check.cwd),
|
|
70
|
+
paths: check.paths === undefined ? undefined : stringArray(check.paths, `${label} "paths"`),
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return { base: (0, json_1.asString)(value.base), profiles };
|
|
75
|
+
}
|
|
76
|
+
exports.parseConfig = parseConfig;
|
|
77
|
+
function loadConfig(root) {
|
|
78
|
+
const file = node_path_1.default.join(root, exports.configFile);
|
|
79
|
+
if (!node_fs_1.default.existsSync(file))
|
|
80
|
+
throw new Error(`Missing ${exports.configFile} in ${root}.`);
|
|
81
|
+
let parsed;
|
|
82
|
+
try {
|
|
83
|
+
parsed = JSON.parse(node_fs_1.default.readFileSync(file, 'utf8'));
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new Error(`Could not read ${exports.configFile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
87
|
+
}
|
|
88
|
+
return parseConfig(parsed);
|
|
89
|
+
}
|
|
90
|
+
exports.loadConfig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C;QAAE,MAAM,IAAI,KAAK,CAAC,WAAW,kBAAU,OAAO,IAAI,GAAG,CAAC,CAAC;IAC/E,IAAI,MAAe,CAAC;IACpB,IAAI;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;KACnD;IAAC,OAAO,KAAK,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,kBAAU,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KAC3G;IACD,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAVD,gCAUC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatReport = exports.reportExitCode = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const colors = { passed: chalk_1.default.green, failed: chalk_1.default.red, 'not-run': chalk_1.default.yellow };
|
|
9
|
+
/** Failed checks always fail; not-run checks fail only in strict mode. */
|
|
10
|
+
function reportExitCode(report, strict = false) {
|
|
11
|
+
return report.results.some((r) => r.status === 'failed' || (strict && r.status === 'not-run')) ? 1 : 0;
|
|
12
|
+
}
|
|
13
|
+
exports.reportExitCode = reportExitCode;
|
|
14
|
+
function formatResult(result) {
|
|
15
|
+
const detail = result.reason ? ` (${result.reason})` : '';
|
|
16
|
+
const header = `${colors[result.status](result.status.padEnd(7))} ${result.profile}/${result.name}${detail}`;
|
|
17
|
+
if (result.status !== 'failed')
|
|
18
|
+
return header;
|
|
19
|
+
return [header, result.stdout.trimEnd(), result.stderr.trimEnd()].filter(Boolean).join('\n');
|
|
20
|
+
}
|
|
21
|
+
function formatReport(report, strict = false) {
|
|
22
|
+
const count = (status) => report.results.filter((r) => r.status === status).length;
|
|
23
|
+
return [
|
|
24
|
+
`Base ${report.base}, ${report.changed.length} changed file(s)`,
|
|
25
|
+
...report.results.map(formatResult),
|
|
26
|
+
`${count('passed')} passed, ${count('failed')} failed, ${count('not-run')} not run${strict && count('not-run') ? ' (strict: not-run fails)' : ''}`,
|
|
27
|
+
].join('\n');
|
|
28
|
+
}
|
|
29
|
+
exports.formatReport = formatReport;
|
|
30
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/features/verify-changes/report.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,MAAM,MAAM,GAAkD,EAAE,MAAM,EAAE,eAAK,CAAC,KAAK,EAAE,MAAM,EAAE,eAAK,CAAC,GAAG,EAAE,SAAS,EAAE,eAAK,CAAC,MAAM,EAAE,CAAC;AAElI,0EAA0E;AAC1E,SAAgB,cAAc,CAAC,MAAoB,EAAE,MAAM,GAAG,KAAK;IAClE,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxG,CAAC;AAFD,wCAEC;AAED,SAAS,YAAY,CAAC,MAAmB;IACxC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC;IAC7G,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC9C,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9F,CAAC;AAED,SAAgB,YAAY,CAAC,MAAoB,EAAE,MAAM,GAAG,KAAK;IAChE,MAAM,KAAK,GAAG,CAAC,MAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;IAChG,OAAO;QACN,QAAQ,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,CAAC,MAAM,kBAAkB;QAC/D,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;QACnC,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,KAAK,CAAC,QAAQ,CAAC,YAAY,KAAK,CAAC,SAAS,CAAC,WAAW,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,EAAE;KAClJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAPD,oCAOC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchFiles = exports.globToRegExp = void 0;
|
|
4
|
+
/** Convert a path glob (`*`, `**`, `?`) to a regular expression over forward-slash paths. */
|
|
5
|
+
function globToRegExp(glob) {
|
|
6
|
+
const pattern = glob.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
7
|
+
let source = '';
|
|
8
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
9
|
+
const char = pattern[i];
|
|
10
|
+
if (char === '*') {
|
|
11
|
+
if (pattern[i + 1] === '*') {
|
|
12
|
+
i++;
|
|
13
|
+
if (pattern[i + 1] === '/') {
|
|
14
|
+
i++;
|
|
15
|
+
source += '(?:.*/)?';
|
|
16
|
+
}
|
|
17
|
+
else
|
|
18
|
+
source += '.*';
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
source += '[^/]*';
|
|
22
|
+
}
|
|
23
|
+
else if (char === '?')
|
|
24
|
+
source += '[^/]';
|
|
25
|
+
else
|
|
26
|
+
source += char.replace(/[.+^${}()|[\]\\]/g, '\\$&');
|
|
27
|
+
}
|
|
28
|
+
return new RegExp(`^${source}$`);
|
|
29
|
+
}
|
|
30
|
+
exports.globToRegExp = globToRegExp;
|
|
31
|
+
/** Files matching any glob; with no globs every file matches. */
|
|
32
|
+
function matchFiles(files, globs) {
|
|
33
|
+
if (!globs)
|
|
34
|
+
return [...files];
|
|
35
|
+
const patterns = globs.map(globToRegExp);
|
|
36
|
+
return files.filter((file) => patterns.some((pattern) => pattern.test(file)));
|
|
37
|
+
}
|
|
38
|
+
exports.matchFiles = matchFiles;
|
|
39
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/features/verify-changes/select.ts"],"names":[],"mappings":";;;AAAA,6FAA6F;AAC7F,SAAgB,YAAY,CAAC,IAAY;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC9D,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,IAAI,KAAK,GAAG,EAAE;YACjB,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC3B,CAAC,EAAE,CAAC;gBACJ,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;oBAC3B,CAAC,EAAE,CAAC;oBACJ,MAAM,IAAI,UAAU,CAAC;iBACrB;;oBAAM,MAAM,IAAI,IAAI,CAAC;aACtB;;gBAAM,MAAM,IAAI,OAAO,CAAC;SACzB;aAAM,IAAI,IAAI,KAAK,GAAG;YAAE,MAAM,IAAI,MAAM,CAAC;;YACrC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;KACzD;IACD,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;AAClC,CAAC;AAjBD,oCAiBC;AAED,iEAAiE;AACjE,SAAgB,UAAU,CAAC,KAAwB,EAAE,KAAyB;IAC7E,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC;AAJD,gCAIC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.verifyChanges = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const process_1 = require("../../core/process");
|
|
9
|
+
const files_1 = require("../../core/files");
|
|
10
|
+
const changed_files_1 = require("./changed-files");
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
const select_1 = require("./select");
|
|
13
|
+
async function runCheck(run, root, profile, check) {
|
|
14
|
+
const started = Date.now();
|
|
15
|
+
const result = (fields) => ({
|
|
16
|
+
profile, name: check.name, durationMs: Date.now() - started, stdout: '', stderr: '', ...fields,
|
|
17
|
+
});
|
|
18
|
+
try {
|
|
19
|
+
const cwd = check.cwd ? (0, files_1.resolveInside)(root, check.cwd) : root;
|
|
20
|
+
const { code, stdout, stderr } = await run(check.command, check.args, { cwd, quiet: true });
|
|
21
|
+
return result({ status: 'passed', exitCode: code, stdout, stderr });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error instanceof process_1.CommandError) {
|
|
25
|
+
const reason = error.signal ? `terminated by ${error.signal}` : `exit code ${error.code}`;
|
|
26
|
+
return result({ status: 'failed', reason, exitCode: error.code, stdout: error.stdout, stderr: error.stderr });
|
|
27
|
+
}
|
|
28
|
+
// The command could not be started at all, so nothing was verified.
|
|
29
|
+
return result({ status: 'not-run', reason: error instanceof Error ? error.message : String(error) });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function verifyChanges(options, run = process_1.runCommand) {
|
|
33
|
+
const root = node_path_1.default.resolve(options.path ?? process.cwd());
|
|
34
|
+
const config = (0, config_1.loadConfig)(root);
|
|
35
|
+
const names = options.profile?.length ? options.profile : Object.keys(config.profiles);
|
|
36
|
+
for (const name of names)
|
|
37
|
+
if (!config.profiles[name])
|
|
38
|
+
throw new Error(`Unknown profile "${name}". Available: ${Object.keys(config.profiles).join(', ') || 'none'}`);
|
|
39
|
+
const base = await (0, changed_files_1.resolveBase)(run, root, options.base ?? config.base);
|
|
40
|
+
const changed = await (0, changed_files_1.getChangedFiles)(run, root, base);
|
|
41
|
+
const results = [];
|
|
42
|
+
for (const profile of names) {
|
|
43
|
+
for (const check of config.profiles[profile]) {
|
|
44
|
+
if (!(0, select_1.matchFiles)(changed, check.paths).length) {
|
|
45
|
+
results.push({ profile, name: check.name, status: 'not-run', reason: 'no matching changes', durationMs: 0, stdout: '', stderr: '' });
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
results.push(await runCheck(run, root, profile, check));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { base, changed, results };
|
|
52
|
+
}
|
|
53
|
+
exports.verifyChanges = verifyChanges;
|
|
54
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../src/features/verify-changes/verify.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,gDAA6E;AAC7E,4CAAiD;AACjD,mDAA+D;AAC/D,qCAAmD;AACnD,qCAAsC;AAkBtC,KAAK,UAAU,QAAQ,CAAC,GAAkB,EAAE,IAAY,EAAE,OAAe,EAAE,KAAkB;IAC5F,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,CAAC,MAAsD,EAAe,EAAE,CAAC,CAAC;QACxF,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM;KAC9F,CAAC,CAAC;IACH,IAAI;QACH,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,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|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("../../core/logger");
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const start_1 = require("./start");
|
|
6
|
+
const status_1 = require("./status");
|
|
7
|
+
const sync_1 = require("./sync");
|
|
8
|
+
function print(args, value, text) {
|
|
9
|
+
if (args.json)
|
|
10
|
+
console.log(JSON.stringify(value, null, 2));
|
|
11
|
+
else
|
|
12
|
+
(0, logger_1.showMessage)(text, 'text', false);
|
|
13
|
+
}
|
|
14
|
+
const command = {
|
|
15
|
+
command: 'worktree <action> <worktree>',
|
|
16
|
+
describe: 'Start a dev server in, inspect, or merge a git worktree',
|
|
17
|
+
builder: (cli) => cli
|
|
18
|
+
.positional('action', { choices: ['start', 'status', 'sync'], type: 'string', demandOption: true, describe: 'start: install, then run the dev server; status: branch and dependency overview; sync: merge in the requested direction' })
|
|
19
|
+
.positional('worktree', { type: 'string', demandOption: true, describe: 'Worktree directory' })
|
|
20
|
+
.option('project', { type: 'string', describe: 'Project directory used when the worktree has no .azcli/worktree.json' })
|
|
21
|
+
.option('target', { type: 'string', describe: 'Branch to compare with or merge (default: "target" in config)' })
|
|
22
|
+
.option('direction', { choices: ['in', 'out', 'both'], type: 'string', describe: 'sync only. in: merge target into the worktree branch; out: merge the worktree branch into the target' })
|
|
23
|
+
.option('port', { type: 'number', describe: 'start only. Port to use (default: first free port above the configured default)' })
|
|
24
|
+
.option('page', { type: 'string', describe: 'start only. Page name from the config, used for the reported URL' })
|
|
25
|
+
.option('timeout', { type: 'number', describe: 'start only. Seconds to wait for readiness' })
|
|
26
|
+
.option('skip-install', { type: 'boolean', describe: 'start only. Do not install dependencies first' })
|
|
27
|
+
.option('json', { type: 'boolean', describe: 'Print the full report as JSON' })
|
|
28
|
+
.check((args) => {
|
|
29
|
+
if (args.action === 'sync' && !args.direction)
|
|
30
|
+
throw new Error('sync needs --direction in|out|both');
|
|
31
|
+
return true;
|
|
32
|
+
})
|
|
33
|
+
.epilog(config_1.configHelp),
|
|
34
|
+
handler: async (args) => {
|
|
35
|
+
const base = { path: args.worktree, project: args.project };
|
|
36
|
+
if (args.action === 'status') {
|
|
37
|
+
const status = await (0, status_1.worktreeStatus)({ ...base, target: args.target });
|
|
38
|
+
print(args, status, (0, status_1.formatStatus)(status));
|
|
39
|
+
}
|
|
40
|
+
else if (args.action === 'sync') {
|
|
41
|
+
const report = await (0, sync_1.syncWorktree)({ ...base, target: args.target, direction: args.direction });
|
|
42
|
+
print(args, report, (0, sync_1.formatSync)(report));
|
|
43
|
+
if (report.steps.some((step) => step.result === 'conflict'))
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const report = await (0, start_1.startWorktree)({ ...base, port: args.port, page: args.page, timeout: args.timeout, skipInstall: args.skipInstall, quiet: args.quiet || args.json });
|
|
48
|
+
print(args, report, (0, start_1.formatStart)(report));
|
|
49
|
+
if (report.state !== 'running' || report.compile === 'failed')
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
exports.default = command;
|
|
55
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/features/worktree/command.ts"],"names":[],"mappings":";;AACA,8CAAgD;AAChD,qCAAsC;AACtC,mCAAqD;AACrD,qCAAwD;AACxD,iCAAiE;AAgBjE,SAAS,KAAK,CAAC,IAAqB,EAAE,KAAc,EAAE,IAAY;IACjE,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;;QACtD,IAAA,oBAAW,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,OAAO,GAAuC;IACnD,O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AAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACxK,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAA,mBAAW,EAAC,MAAM,CAAC,CAAC,CAAC;YACzC,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,QAAQ;gBAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;SACpF;IACF,CAAC;CACD,CAAC;AACF,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadConfig = exports.parseConfig = exports.configHelp = exports.configFile = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const json_1 = require("../../core/json");
|
|
10
|
+
exports.configFile = node_path_1.default.join('.azcli', 'worktree.json');
|
|
11
|
+
exports.configHelp = `Config file: .azcli/worktree.json (JSON), read from the worktree, else the project. Example:
|
|
12
|
+
|
|
13
|
+
{
|
|
14
|
+
"target": "development",
|
|
15
|
+
"install": { "command": "yarn", "args": ["install", "--immutable"] },
|
|
16
|
+
"dev": {
|
|
17
|
+
"command": "react-app-rewired",
|
|
18
|
+
"args": ["start"],
|
|
19
|
+
"cwd": "packages_main/web",
|
|
20
|
+
"defaultPort": 3000,
|
|
21
|
+
"pages": { "order": "/order" },
|
|
22
|
+
"binDirs": ["node_modules/.bin"],
|
|
23
|
+
"timeoutSeconds": 120
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Fields:
|
|
28
|
+
target optional. Branch that status and sync compare against (--target overrides).
|
|
29
|
+
install optional. Default: yarn install --immutable at the worktree root.
|
|
30
|
+
dev required for "start". command and args run without a shell, in cwd.
|
|
31
|
+
portEnv optional. Environment variable receiving the port. Default PORT.
|
|
32
|
+
"{port}" inside args is replaced too.
|
|
33
|
+
defaultPort optional. Port used by the main checkout. Default 3000; start picks
|
|
34
|
+
the first free port above it.
|
|
35
|
+
readyPath optional. Path polled until the server answers. Default "/".
|
|
36
|
+
pages optional. Page name -> path, selected with --page.
|
|
37
|
+
timeoutSeconds optional. Maximum wait for readiness. Default 120.
|
|
38
|
+
binDirs optional. Directories searched for the command before PATH, relative to
|
|
39
|
+
the worktree root and to cwd. Default ["node_modules/.bin"].
|
|
40
|
+
compiledPattern, failedPattern
|
|
41
|
+
optional. Regexes matched against the dev log.`;
|
|
42
|
+
function stringArray(value, label) {
|
|
43
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string'))
|
|
44
|
+
throw new Error(`${label} must be an array of strings`);
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function commandConfig(value, label) {
|
|
48
|
+
if (!(0, json_1.isRecord)(value))
|
|
49
|
+
throw new Error(`${label} must be an object`);
|
|
50
|
+
const command = (0, json_1.asString)(value.command);
|
|
51
|
+
if (!command)
|
|
52
|
+
throw new Error(`${label} needs a "command"`);
|
|
53
|
+
return { command, args: value.args === undefined ? [] : stringArray(value.args, `${label} "args"`), cwd: (0, json_1.asString)(value.cwd) };
|
|
54
|
+
}
|
|
55
|
+
function positive(value, label, fallback) {
|
|
56
|
+
if (value === undefined)
|
|
57
|
+
return fallback;
|
|
58
|
+
if (typeof value !== 'number' || !Number.isInteger(value) || value <= 0)
|
|
59
|
+
throw new Error(`${label} must be a positive integer`);
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
function parseConfig(value) {
|
|
63
|
+
if (!(0, json_1.isRecord)(value))
|
|
64
|
+
throw new Error(`${exports.configFile} must contain a JSON object`);
|
|
65
|
+
const config = {
|
|
66
|
+
target: (0, json_1.asString)(value.target),
|
|
67
|
+
install: value.install === undefined ? { command: 'yarn', args: ['install', '--immutable'] } : commandConfig(value.install, '"install"'),
|
|
68
|
+
};
|
|
69
|
+
if (value.dev !== undefined) {
|
|
70
|
+
const base = commandConfig(value.dev, '"dev"');
|
|
71
|
+
const dev = value.dev;
|
|
72
|
+
const pages = {};
|
|
73
|
+
if (dev.pages !== undefined) {
|
|
74
|
+
if (!(0, json_1.isRecord)(dev.pages))
|
|
75
|
+
throw new Error('"dev" "pages" must be an object');
|
|
76
|
+
for (const [name, page] of Object.entries(dev.pages)) {
|
|
77
|
+
if (typeof page !== 'string')
|
|
78
|
+
throw new Error(`"dev" page "${name}" must be a string`);
|
|
79
|
+
pages[name] = page;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
config.dev = {
|
|
83
|
+
...base,
|
|
84
|
+
portEnv: (0, json_1.asString)(dev.portEnv) ?? 'PORT',
|
|
85
|
+
defaultPort: positive(dev.defaultPort, '"dev" "defaultPort"', 3000),
|
|
86
|
+
readyPath: (0, json_1.asString)(dev.readyPath) ?? '/',
|
|
87
|
+
pages,
|
|
88
|
+
timeoutSeconds: positive(dev.timeoutSeconds, '"dev" "timeoutSeconds"', 120),
|
|
89
|
+
binDirs: dev.binDirs === undefined ? ['node_modules/.bin'] : stringArray(dev.binDirs, '"dev" "binDirs"'),
|
|
90
|
+
compiledPattern: (0, json_1.asString)(dev.compiledPattern) ?? 'Compiled (successfully|with warnings)',
|
|
91
|
+
failedPattern: (0, json_1.asString)(dev.failedPattern) ?? 'Failed to compile|Module not found|error TS\\d+',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return config;
|
|
95
|
+
}
|
|
96
|
+
exports.parseConfig = parseConfig;
|
|
97
|
+
/** Read the config from the first root that has one; a missing file everywhere yields the defaults. */
|
|
98
|
+
function loadConfig(...roots) {
|
|
99
|
+
for (const root of roots) {
|
|
100
|
+
const file = node_path_1.default.join(root, exports.configFile);
|
|
101
|
+
if (!node_fs_1.default.existsSync(file))
|
|
102
|
+
continue;
|
|
103
|
+
let parsed;
|
|
104
|
+
try {
|
|
105
|
+
parsed = JSON.parse(node_fs_1.default.readFileSync(file, 'utf8'));
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
throw new Error(`Could not read ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
109
|
+
}
|
|
110
|
+
return parseConfig(parsed);
|
|
111
|
+
}
|
|
112
|
+
return parseConfig({});
|
|
113
|
+
}
|
|
114
|
+
exports.loadConfig = loadConfig;
|
|
115
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/features/worktree/config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,0CAAqD;AAExC,QAAA,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AA6BlD,QAAA,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEA8BuC,CAAC;AAElE,SAAS,WAAW,CAAC,KAAc,EAAE,KAAa;IACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,8BAA8B,CAAC,CAAC;IACrI,OAAO,KAAiB,CAAC;AAC1B,CAAC;AACD,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IACnD,IAAI,CAAC,IAAA,eAAQ,EAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAC;IACpE,MAAM,O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,GAAG,CAAC,aAAa,CAAC,IAAI,iDAAiD;SAC/F,CAAC;KACF;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AA9BD,kCA8BC;AAED,uGAAuG;AACvG,SAAgB,UAAU,CAAC,GAAG,KAAe;IAC5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACzB,MAAM,IAAI,GAAG,mBAAI,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAU,CAAC,CAAC;QACzC,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QACnC,IAAI,MAAe,CAAC;QACpB,IAAI;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;SACnD;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SACrG;QACD,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;KAC3B;IACD,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAbD,gCAaC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveTarget = exports.gitDir = exports.treeState = exports.listWorktrees = exports.gitOk = exports.git = exports.lines = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const lines = (text) => text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
9
|
+
exports.lines = lines;
|
|
10
|
+
async function git(run, cwd, args) {
|
|
11
|
+
return (await run('git', args, { cwd, quiet: true })).stdout.trim();
|
|
12
|
+
}
|
|
13
|
+
exports.git = git;
|
|
14
|
+
async function gitOk(run, cwd, args) {
|
|
15
|
+
try {
|
|
16
|
+
await run('git', args, { cwd, quiet: true });
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.gitOk = gitOk;
|
|
24
|
+
async function listWorktrees(run, cwd) {
|
|
25
|
+
const text = (await run('git', ['worktree', 'list', '--porcelain'], { cwd, quiet: true })).stdout;
|
|
26
|
+
return text.split(/\r?\n\r?\n/).map((block) => {
|
|
27
|
+
const entry = {};
|
|
28
|
+
for (const line of (0, exports.lines)(block)) {
|
|
29
|
+
if (line.startsWith('worktree '))
|
|
30
|
+
entry.path = node_path_1.default.resolve(line.slice(9));
|
|
31
|
+
else if (line.startsWith('HEAD '))
|
|
32
|
+
entry.head = line.slice(5);
|
|
33
|
+
else if (line.startsWith('branch '))
|
|
34
|
+
entry.branch = line.slice(7).replace(/^refs\/heads\//, '');
|
|
35
|
+
}
|
|
36
|
+
return entry;
|
|
37
|
+
}).filter((entry) => Boolean(entry.path));
|
|
38
|
+
}
|
|
39
|
+
exports.listWorktrees = listWorktrees;
|
|
40
|
+
/** `dirty` holds `git status --porcelain` lines: tracked and untracked changes. */
|
|
41
|
+
async function treeState(run, cwd) {
|
|
42
|
+
const branch = await git(run, cwd, ['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
43
|
+
const tip = await git(run, cwd, ['rev-parse', '--short', 'HEAD']);
|
|
44
|
+
const status = (await run('git', ['status', '--porcelain'], { cwd, quiet: true })).stdout;
|
|
45
|
+
return { path: cwd, branch: branch === 'HEAD' ? null : branch, tip, dirty: status.split(/\r?\n/).filter(Boolean) };
|
|
46
|
+
}
|
|
47
|
+
exports.treeState = treeState;
|
|
48
|
+
/** Per-worktree git directory; a safe place for logs and scratch files that never dirties the tree. */
|
|
49
|
+
async function gitDir(run, cwd) {
|
|
50
|
+
return node_path_1.default.resolve(cwd, await git(run, cwd, ['rev-parse', '--absolute-git-dir']));
|
|
51
|
+
}
|
|
52
|
+
exports.gitDir = gitDir;
|
|
53
|
+
async function resolveTarget(run, cwd, requested, configured) {
|
|
54
|
+
const target = requested ?? configured;
|
|
55
|
+
if (!target)
|
|
56
|
+
throw new Error('No target branch: pass --target or set "target" in .azcli/worktree.json');
|
|
57
|
+
if (!(await gitOk(run, cwd, ['rev-parse', '--verify', '--quiet', `refs/heads/${target}`])))
|
|
58
|
+
throw new Error(`Target branch not found: ${target}`);
|
|
59
|
+
return target;
|
|
60
|
+
}
|
|
61
|
+
exports.resolveTarget = resolveTarget;
|
|
62
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/features/worktree/git.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAGtB,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAAzF,QAAA,KAAK,SAAoF;AAE/F,KAAK,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAW,EAAE,IAAc;IACxE,OAAO,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AACrE,CAAC;AAFD,kBAEC;AAEM,KAAK,UAAU,KAAK,CAAC,GAAkB,EAAE,GAAW,EAAE,IAAc;IAC1E,IAAI;QACH,MAAM,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,I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