yadflow 4.7.0 → 4.9.0
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/CHANGELOG.md +116 -0
- package/README.md +43 -4
- package/bin/commands.mjs +5 -1
- package/bin/yad.mjs +169 -22
- package/cli/agent-guard.mjs +511 -0
- package/cli/agent-guide.mjs +83 -0
- package/cli/agent-rules.mjs +388 -0
- package/cli/argv-flags.mjs +7 -0
- package/cli/build.mjs +1 -1
- package/cli/ci-check.mjs +492 -0
- package/cli/docs.mjs +1 -1
- package/cli/doctor.mjs +148 -7
- package/cli/epic-state.mjs +3 -3
- package/cli/errors.mjs +1 -0
- package/cli/guide.mjs +549 -0
- package/cli/hook.mjs +32 -3
- package/cli/lib.mjs +46 -0
- package/cli/lifecycle/defaults/2.json +124 -0
- package/cli/lifecycle/lifecycle.schema.json +5 -2
- package/cli/lifecycle.mjs +16 -3
- package/cli/machine.mjs +141 -0
- package/cli/manifest.mjs +75 -0
- package/cli/marked-block.mjs +48 -0
- package/cli/members.mjs +19 -5
- package/cli/migrate.mjs +17 -19
- package/cli/next.mjs +1 -1
- package/cli/openpr.mjs +46 -6
- package/cli/plan.mjs +326 -22
- package/cli/preview.mjs +253 -0
- package/cli/protection.mjs +50 -0
- package/cli/reconcile.mjs +187 -26
- package/cli/repo.mjs +64 -3
- package/cli/report.mjs +62 -14
- package/cli/review.mjs +4 -0
- package/cli/setup.mjs +244 -25
- package/cli/signing.mjs +377 -0
- package/cli/story-frames.mjs +296 -0
- package/cli/test-agents-file.mjs +993 -0
- package/cli/test-ci-check.mjs +616 -0
- package/cli/test-guide.mjs +1267 -0
- package/cli/test-machine.mjs +140 -0
- package/cli/test-node.mjs +129 -0
- package/cli/test-preview.mjs +511 -0
- package/cli/test-setup-agent.mjs +352 -0
- package/cli/test-signing.mjs +524 -0
- package/cli/test-story-frames.mjs +339 -0
- package/cli/toolbox.mjs +35 -1
- package/cli/update-commit.mjs +313 -11
- package/cli/workspace.mjs +37 -12
- package/package.json +6 -4
- package/skills/sdlc/config.yaml +4 -4
- package/skills/sdlc/module-help.csv +1 -0
- package/skills/yad-change/SKILL.md +3 -2
- package/skills/yad-checks/SKILL.md +29 -9
- package/skills/yad-checks/references/check-gates.md +9 -4
- package/skills/yad-checks/templates/checks/package-manager.sh +1 -1
- package/skills/yad-checks/templates/github/yad-checks.yml +1 -1
- package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +1 -1
- package/skills/yad-checks/templates/hooks/agent-guard.mjs +116 -0
- package/skills/yad-commit/SKILL.md +4 -3
- package/skills/yad-connect-design/SKILL.md +7 -4
- package/skills/yad-connect-design/references/design-context.md +23 -0
- package/skills/yad-connect-design/references/design-registry.md +3 -3
- package/skills/yad-connect-repos/SKILL.md +13 -3
- package/skills/yad-connect-repos/references/code-context.md +2 -1
- package/skills/yad-connect-repos/references/repos-registry.md +2 -1
- package/skills/yad-docs-overview/references/pipeline-model.md +2 -2
- package/skills/yad-engineer-review/SKILL.md +25 -7
- package/skills/yad-engineer-review/references/ship-and-record.md +7 -4
- package/skills/yad-epic/SKILL.md +2 -1
- package/skills/yad-epic/references/state-schema.md +7 -1
- package/skills/yad-guide/SKILL.md +192 -0
- package/skills/yad-implement/SKILL.md +14 -0
- package/skills/yad-open-pr/SKILL.md +5 -2
- package/skills/yad-pair-review/SKILL.md +19 -5
- package/skills/yad-pr-template/templates/github/pull_request_template.md +1 -0
- package/skills/yad-pr-template/templates/gitlab/merge_request_templates/Default.md +1 -0
- package/skills/yad-product-bridge/SKILL.md +32 -13
- package/skills/yad-product-bridge/references/bridge.md +6 -3
- package/skills/yad-product-bridge/templates/github/yad-gate-sync.yml +2 -2
- package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +1 -1
- package/skills/yad-report/SKILL.md +15 -0
- package/skills/yad-review-companion/SKILL.md +9 -4
- package/skills/yad-review-gate/SKILL.md +13 -9
- package/skills/yad-review-gate/references/gating.md +1 -1
- package/skills/yad-run/SKILL.md +10 -6
- package/skills/yad-run/references/run-loop.md +2 -1
- package/skills/yad-spec/SKILL.md +21 -0
- package/skills/yad-stories/SKILL.md +22 -0
- package/skills/yad-stories/references/story-schema.md +1 -0
- package/skills/yad-sync-repos/SKILL.md +2 -1
- package/skills/yad-ui/SKILL.md +7 -2
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// #352: `yad doctor` checks the machine setup local work depends on — the active Node against each repo's
|
|
2
|
+
// pinned version, Docker only where a repo asks for it, and more than one glab config file.
|
|
3
|
+
import { test } from 'node:test';
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import { execFileSync } from 'node:child_process';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
if (process.env.NODE_TEST_CONTEXT) {
|
|
11
|
+
const write = process.stdout.write;
|
|
12
|
+
for (const k of ['log', 'info']) {
|
|
13
|
+
const orig = console[k];
|
|
14
|
+
console[k] = (...a) => (process.stdout.write === write ? console.error(...a) : orig(...a));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
process.env.YAD_NO_UPDATE_NOTIFIER = '1';
|
|
18
|
+
|
|
19
|
+
const { nodePins, satisfies, nodeFix, dockerReasons, dockerState, glabConfigs } = await import('./machine.mjs');
|
|
20
|
+
const { machineChecks } = await import('./doctor.mjs');
|
|
21
|
+
|
|
22
|
+
const tmp = () => fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'yad-machine-')));
|
|
23
|
+
const put = (file, data) => { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, typeof data === 'string' ? data : JSON.stringify(data)); };
|
|
24
|
+
const done = (T) => fs.rmSync(T, { recursive: true, force: true });
|
|
25
|
+
|
|
26
|
+
test('#352: satisfies reads the version forms repos pin, and says "not known" for the rest', () => {
|
|
27
|
+
const yes = [['24.22.1', '>= 22'], ['24.22.1', '>=22.0.0 <25'], ['25.0.0', '>24'], ['0.0.3', '^0.0.3'], ['24.22.1', '24'], ['24.22.1', 'v24.22.1'], ['24.22.1', '>=22'], ['24.22.1', '^24.1.0'], ['24.22.1', '~24.22.0'],
|
|
28
|
+
['24.22.1', '22 || 24'], ['24.22.1', '>=20 <25'], ['24.22.1', '20 - 24.30'], ['24.22.1', '24.x'], ['24.22.1', '*'], ['22.8.0', '>=22.8'], ['24.22.1', '<=24']];
|
|
29
|
+
const no = [['22.8.0', '>22'], ['24.5.0', '>24.x'], ['24.1.9', '>24.1'], ['0.0.4', '^0.0.3'], ['20.19.5', '>= 22'], ['20.19.5', '24'], ['20.19.5', '>=22'], ['25.0.0', '^24.1.0'], ['24.23.0', '~24.22.0'], ['24.22.1', '<24'], ['24.22.1', '18 || 20'], ['21.0.0', '>=20 <21']];
|
|
30
|
+
for (const [v, s] of yes) assert.equal(satisfies(v, s), true, `${v} ${s}`);
|
|
31
|
+
for (const [v, s] of no) assert.equal(satisfies(v, s), false, `${v} ${s}`);
|
|
32
|
+
for (const s of ['lts/*', 'node', 'lts/iron', 'https://x', '24.0.0-rc.1']) assert.equal(satisfies('24.22.1', s), null, s);
|
|
33
|
+
assert.equal(satisfies('25.0.0-nightly', '>=22'), null, 'a pre-release Node is not judged');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('#352: nodePins reads .nvmrc, .node-version, .tool-versions, engines.node and volta.node', () => {
|
|
37
|
+
const T = tmp();
|
|
38
|
+
try {
|
|
39
|
+
put(path.join(T, '.nvmrc'), '# the team\'s Node\n24\n');
|
|
40
|
+
put(path.join(T, '.node-version'), 'v24.1.0\n');
|
|
41
|
+
put(path.join(T, '.tool-versions'), 'python 3.12.1\nnodejs 24.2.0 # pinned\n');
|
|
42
|
+
put(path.join(T, 'package.json'), { engines: { node: '>=22' }, volta: { node: '24.3.0' } });
|
|
43
|
+
assert.deepEqual(nodePins(T), [
|
|
44
|
+
{ source: '.nvmrc', want: '24' }, { source: '.node-version', want: 'v24.1.0' }, { source: '.tool-versions', want: '24.2.0' },
|
|
45
|
+
{ source: 'package.json engines.node', want: '>=22' }, { source: 'package.json volta.node', want: '24.3.0' }]);
|
|
46
|
+
fs.rmSync(path.join(T, 'package.json'));
|
|
47
|
+
put(path.join(T, 'package.json'), '{ not json');
|
|
48
|
+
assert.equal(nodePins(T).length, 3, 'a package.json that does not parse pins nothing');
|
|
49
|
+
} finally { done(T); }
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('#352: the fix names nvm\'s commands when nvm is here, plain words otherwise', () => {
|
|
53
|
+
assert.match(nodeFix('24', { env: { NVM_DIR: '/x' }, home: '/nowhere' }), /^nvm install 24 && nvm use 24 \(and `nvm alias default 24`/);
|
|
54
|
+
assert.match(nodeFix('>=22', { env: { NVM_DIR: '/x' }, home: '/nowhere' }), /a version that meets >=22/);
|
|
55
|
+
assert.match(nodeFix('24', { env: {}, home: '/nowhere' }), /^install Node 24/);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('#352: Docker is asked about only where a repo names it', () => {
|
|
59
|
+
const T = tmp();
|
|
60
|
+
try {
|
|
61
|
+
assert.deepEqual(dockerReasons(T), []);
|
|
62
|
+
put(path.join(T, 'package.json'), { scripts: {
|
|
63
|
+
test: 'node --test', scan: 'docker run --rm zricethezav/gitleaks', up: 'npm ci && docker compose up', full: '/usr/local/bin/docker build .',
|
|
64
|
+
notdocker: 'echo dockerfile', lint: 'eslint . --ignore-pattern docker', say: 'echo run docker', '\u001b]8;;x\u0007odd': 'docker ps' } });
|
|
65
|
+
assert.deepEqual(dockerReasons(T), ['package.json scripts: scan, up, full, ]8;;x odd'], 'a script name is cleaned for the terminal');
|
|
66
|
+
put(path.join(T, 'compose.yaml'), 'services: {}\n');
|
|
67
|
+
put(path.join(T, 'Dockerfile.dev'), 'FROM node\n');
|
|
68
|
+
put(path.join(T, '.pre-commit-config.yaml'), 'repos:\n - repo: local\n hooks:\n - id: x\n language: "docker_image" # the scanner\n');
|
|
69
|
+
assert.deepEqual(dockerReasons(T).sort(), ['.pre-commit-config.yaml (a docker hook)', 'Dockerfile.dev', 'compose.yaml', 'package.json scripts: scan, up, full, ]8;;x odd'].sort());
|
|
70
|
+
const runner = (answers) => (cmd, args) => ({ ok: answers[`${cmd} ${args[0]}`] ?? false });
|
|
71
|
+
assert.equal(dockerState({ runner: runner({}) }), 'missing');
|
|
72
|
+
assert.equal(dockerState({ runner: runner({ 'which docker': true }) }), 'stopped');
|
|
73
|
+
assert.equal(dockerState({ runner: runner({ 'which docker': true, 'docker info': true }) }), 'running');
|
|
74
|
+
} finally { done(T); }
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('#352: more than one glab config file is found where glab looks', () => {
|
|
78
|
+
const T = tmp();
|
|
79
|
+
try {
|
|
80
|
+
assert.deepEqual(glabConfigs({ env: {}, home: T, platform: 'darwin' }), []);
|
|
81
|
+
put(path.join(T, '.config/glab-cli/config.yml'), 'hosts: {}\n');
|
|
82
|
+
put(path.join(T, 'Library/Application Support/glab-cli/config.yml'), 'hosts: {}\n');
|
|
83
|
+
assert.equal(glabConfigs({ env: {}, home: T, platform: 'darwin' }).length, 2);
|
|
84
|
+
assert.equal(glabConfigs({ env: {}, home: T, platform: 'linux' }).length, 1, 'not the macOS folder on Linux');
|
|
85
|
+
// GLAB_CONFIG_DIR or XDG_CONFIG_HOME names the one place glab reads: no duplicate is possible.
|
|
86
|
+
put(path.join(T, 'own/config.yml'), 'hosts: {}\n');
|
|
87
|
+
assert.deepEqual(glabConfigs({ env: { GLAB_CONFIG_DIR: path.join(T, 'own') }, home: T, platform: 'darwin' }), [path.join(T, 'own/config.yml')]);
|
|
88
|
+
put(path.join(T, 'xdg/glab-cli/config.yml'), 'hosts: {}\n');
|
|
89
|
+
assert.deepEqual(glabConfigs({ env: { XDG_CONFIG_HOME: path.join(T, 'xdg') }, home: T, platform: 'darwin' }), [path.join(T, 'xdg/glab-cli/config.yml')]);
|
|
90
|
+
} finally { done(T); }
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('#352: yad doctor rows — a Node a repo does not accept, Docker stopped where a repo needs it, two glab configs', () => {
|
|
94
|
+
const T = tmp();
|
|
95
|
+
try {
|
|
96
|
+
const root = path.join(T, 'product');
|
|
97
|
+
put(path.join(root, '.sdlc/product.json'), { platform: null });
|
|
98
|
+
put(path.join(root, '.nvmrc'), '24\n');
|
|
99
|
+
put(path.join(root, 'package.json'), { engines: { node: '>=24.1' } });
|
|
100
|
+
const app = path.join(T, 'app');
|
|
101
|
+
put(path.join(app, 'package.json'), { engines: { node: '>=22' }, scripts: { scan: 'docker compose run gitleaks' } });
|
|
102
|
+
execFileSync('git', ['init', '-q'], { cwd: app });
|
|
103
|
+
put(path.join(root, '.sdlc/repos.json'), { repos: [{ name: 'app', path: '../app' }] });
|
|
104
|
+
const home = path.join(T, 'home');
|
|
105
|
+
put(path.join(home, '.config/glab-cli/config.yml'), 'hosts: {}\n');
|
|
106
|
+
put(path.join(home, 'Library/Application Support/glab-cli/config.yml'), 'hosts: {}\n');
|
|
107
|
+
const runner = (cmd, args) => ({ ok: `${cmd} ${args[0]}` === 'which docker' });
|
|
108
|
+
const rows = (nodeVersion) => { const checks = []; machineChecks(checks, root, { nodeVersion, env: { NVM_DIR: '/x' }, home, platform: 'darwin', runner }); return Object.fromEntries(checks.map((c) => [c.id, c])); };
|
|
109
|
+
const old = rows('20.19.5');
|
|
110
|
+
assert.equal(old['node-version:product'].status, 'warn');
|
|
111
|
+
assert.match(old['node-version:product'].message, /node 20\.19\.5 does not meet what the Product pins: 24 \(\.nvmrc\), >=24\.1 \(package\.json engines\.node\)/, 'both pins, one row');
|
|
112
|
+
assert.match(old['node-version:product'].hint, /nvm install 24 && nvm use 24/);
|
|
113
|
+
assert.equal(old['node-version:repo:app'].status, 'warn');
|
|
114
|
+
assert.equal(old.docker.status, 'warn');
|
|
115
|
+
assert.match(old.docker.message, /Docker is not running, and app \(package\.json scripts: scan\) asks for it/);
|
|
116
|
+
assert.equal(old['glab-config'].status, 'warn');
|
|
117
|
+
assert.match(old['glab-config'].message, /glab has 2 config files: ~\/\.config\/glab-cli\/config\.yml, ~\/Library\/Application Support\/glab-cli\/config\.yml/);
|
|
118
|
+
const now = rows('24.22.1');
|
|
119
|
+
assert.equal(now['node-version'].status, 'ok');
|
|
120
|
+
assert.match(now['node-version'].message, /meets every Node version the repos pin \(3 read\)/);
|
|
121
|
+
assert.equal(now['node-version:product'], undefined);
|
|
122
|
+
// The glab hint says what goes wrong: one file is ignored.
|
|
123
|
+
assert.match(old['glab-config'].hint, /reads only one of them and ignores the other/);
|
|
124
|
+
// A pin yad does not read is counted as skipped, never judged.
|
|
125
|
+
put(path.join(app, '.nvmrc'), 'lts/*\n');
|
|
126
|
+
assert.match(rows('24.22.1')['node-version'].message, /\(3 read, 1 not a version yad reads\)/);
|
|
127
|
+
} finally { done(T); }
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('#352: a repo that names no pin and no Docker adds no rows, and Docker is never run', () => {
|
|
131
|
+
const T = tmp();
|
|
132
|
+
try {
|
|
133
|
+
put(path.join(T, '.sdlc/product.json'), { platform: null });
|
|
134
|
+
let asked = 0;
|
|
135
|
+
const checks = [];
|
|
136
|
+
machineChecks(checks, T, { nodeVersion: '24.22.1', env: {}, home: path.join(T, 'home'), platform: 'linux', runner: () => { asked += 1; return { ok: false }; } });
|
|
137
|
+
assert.deepEqual(checks, []);
|
|
138
|
+
assert.equal(asked, 0, 'docker is not asked about');
|
|
139
|
+
} finally { done(T); }
|
|
140
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// E161: which Node line yadflow runs on. Below 18 it does not run (YAD-ENV-003); 18 and 20 are end of life —
|
|
2
|
+
// yadflow 4 still runs on them, with a warning (YAD-ENV-004), and yadflow 5 needs 22; 22 and later are ok.
|
|
3
|
+
// Also: the CI files yad installs in people's repos name no end-of-life Node.
|
|
4
|
+
import { test } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
|
|
12
|
+
if (process.env.NODE_TEST_CONTEXT) {
|
|
13
|
+
const write = process.stdout.write;
|
|
14
|
+
for (const k of ['log', 'info']) {
|
|
15
|
+
const orig = console[k];
|
|
16
|
+
console[k] = (...a) => (process.stdout.write === write ? console.error(...a) : orig(...a));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
process.env.YAD_NO_UPDATE_NOTIFIER = '1';
|
|
20
|
+
|
|
21
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
22
|
+
const { nodeSupport, nodeEndOfLife, cpMerge } = await import('./lib.mjs');
|
|
23
|
+
const { envChecks } = await import('./doctor.mjs');
|
|
24
|
+
const { CODES } = await import('./errors.mjs');
|
|
25
|
+
|
|
26
|
+
test('E161: nodeSupport reads the major version into three bands', () => {
|
|
27
|
+
for (const v of ['16.20.2', '17.0.0', 'v16.1.0', 'not-a-version']) assert.equal(nodeSupport(v), 'unsupported', v);
|
|
28
|
+
for (const v of ['18.20.4', '20.19.5', 'v20.0.0', '21.7.3']) assert.equal(nodeSupport(v), 'end-of-life', v);
|
|
29
|
+
for (const v of ['22.0.0', '22.22.2', '24.22.1', '25.1.0']) assert.equal(nodeSupport(v), 'ok', v);
|
|
30
|
+
assert.match(nodeEndOfLife('20.19.5'), /^Node 20\.19\.5 is end of life and gets no security fixes\. yadflow 4 still runs on it; yadflow 5 will need Node 22 or newer\./);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('E161: yad doctor\'s node row — fail below 18, warn on 18 to 21 (YAD-ENV-004), ok from 22', () => {
|
|
34
|
+
const row = (nodeVersion) => { const checks = []; envChecks(checks, { nodeVersion }); return checks.find((x) => x.id === 'node'); };
|
|
35
|
+
assert.equal(row('16.0.0').status, 'fail');
|
|
36
|
+
assert.match(row('16.0.0').message, /YAD-ENV-003/);
|
|
37
|
+
const old = row('20.19.5');
|
|
38
|
+
assert.equal(old.status, 'warn');
|
|
39
|
+
assert.match(old.message, /end of life.*YAD-ENV-004/);
|
|
40
|
+
assert.match(old.hint, /22 or newer/);
|
|
41
|
+
assert.equal(row('24.22.1').status, 'ok');
|
|
42
|
+
assert.ok(CODES['YAD-ENV-004'], 'the code is in the catalogue');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('E161: the CLI warns once on an end-of-life Node, on stderr only, and never under `hook`', () => {
|
|
46
|
+
const T = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'yad-node-')));
|
|
47
|
+
try {
|
|
48
|
+
const yad = (args, version) => spawnSync(process.execPath, [path.join(ROOT, 'bin/yad.mjs'), ...args], {
|
|
49
|
+
cwd: T, encoding: 'utf8', input: '{}',
|
|
50
|
+
env: { ...process.env, NO_COLOR: '1', YAD_PLATFORM_READ: '0', ...(version ? { YAD_TEST_NODE_VERSION: version } : {}) },
|
|
51
|
+
});
|
|
52
|
+
const old = yad(['detect', '--json'], '20.19.5');
|
|
53
|
+
assert.equal((old.stderr.match(/is end of life/g) || []).length, 1, old.stderr);
|
|
54
|
+
assert.doesNotMatch(old.stdout, /end of life/, 'stdout stays clean JSON');
|
|
55
|
+
JSON.parse(old.stdout);
|
|
56
|
+
assert.doesNotMatch(yad(['detect', '--json'], '24.22.1').stderr, /end of life/);
|
|
57
|
+
// The running Node, with no stand-in: on the CI legs for 18 and 20 it warns, on 22 and later it does not.
|
|
58
|
+
const real = yad(['detect', '--json']).stderr;
|
|
59
|
+
if (nodeSupport() === 'end-of-life') assert.match(real, /is end of life/, 'this Node is end of life');
|
|
60
|
+
else assert.doesNotMatch(real, /end of life/, 'this Node (22 or later) gets no warning');
|
|
61
|
+
assert.doesNotMatch(yad(['hook', 'agent-guard'], '20.19.5').stderr, /end of life/, 'a hook\'s stderr reaches the model');
|
|
62
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('E161: no CI file yad installs or generates names an end-of-life Node', () => {
|
|
66
|
+
const files = [
|
|
67
|
+
...['skills/yad-checks/templates', 'skills/yad-product-bridge/templates', 'skills/yad-pr-template/templates'].flatMap((d) => fs.readdirSync(path.join(ROOT, d), { recursive: true }).map((f) => path.join(d, f))),
|
|
68
|
+
'cli/docs.mjs',
|
|
69
|
+
].filter((f) => fs.statSync(path.join(ROOT, f)).isFile());
|
|
70
|
+
for (const f of files) {
|
|
71
|
+
const text = fs.readFileSync(path.join(ROOT, f), 'utf8');
|
|
72
|
+
assert.doesNotMatch(text, /node-version:\s*["']?(1[0-9]|20)["']?\s*$/m, f);
|
|
73
|
+
assert.doesNotMatch(text, /image:\s*node:(1[0-9]|20)\b/, f);
|
|
74
|
+
assert.doesNotMatch(text, /YAD_NODE_VERSION[^\n]*["'](1[0-9]|20)["']/, f);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('E161: cpMerge joins folders and never replaces a file (Node 24\'s cpSync refuses an existing folder)', () => {
|
|
79
|
+
const T = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'yad-cp-')));
|
|
80
|
+
try {
|
|
81
|
+
fs.mkdirSync(path.join(T, 'a/sub'), { recursive: true });
|
|
82
|
+
fs.writeFileSync(path.join(T, 'a/f.txt'), 'x');
|
|
83
|
+
fs.writeFileSync(path.join(T, 'a/sub/g.txt'), 'y');
|
|
84
|
+
fs.mkdirSync(path.join(T, 'b/sub'), { recursive: true });
|
|
85
|
+
fs.writeFileSync(path.join(T, 'b/keep.txt'), 'mine');
|
|
86
|
+
cpMerge(path.join(T, 'a'), path.join(T, 'b'));
|
|
87
|
+
assert.equal(fs.readFileSync(path.join(T, 'b/sub/g.txt'), 'utf8'), 'y');
|
|
88
|
+
assert.equal(fs.readFileSync(path.join(T, 'b/keep.txt'), 'utf8'), 'mine', 'the folder\'s own files are kept');
|
|
89
|
+
assert.throws(() => cpMerge(path.join(T, 'a'), path.join(T, 'b')), /EEXIST/, 'a file already there is never replaced');
|
|
90
|
+
assert.equal(fs.readFileSync(path.join(T, 'b/f.txt'), 'utf8'), 'x');
|
|
91
|
+
// A new folder keeps its source's permissions; a file keeps its mode; a link stays the link it is.
|
|
92
|
+
if (process.platform !== 'win32') {
|
|
93
|
+
fs.mkdirSync(path.join(T, 'p/private'), { recursive: true, mode: 0o700 });
|
|
94
|
+
fs.chmodSync(path.join(T, 'p/private'), 0o700);
|
|
95
|
+
fs.writeFileSync(path.join(T, 'p/run.sh'), '#!/bin/sh\n', { mode: 0o755 });
|
|
96
|
+
fs.symlinkSync('run.sh', path.join(T, 'p/link'));
|
|
97
|
+
const made = [];
|
|
98
|
+
cpMerge(path.join(T, 'p'), path.join(T, 'q'), made);
|
|
99
|
+
assert.equal(fs.statSync(path.join(T, 'q/private')).mode & 0o777, 0o700);
|
|
100
|
+
assert.equal(fs.statSync(path.join(T, 'q/run.sh')).mode & 0o777, 0o755);
|
|
101
|
+
assert.equal(fs.readlinkSync(path.join(T, 'q/link')), 'run.sh', 'a relative link stays relative');
|
|
102
|
+
assert.deepEqual(made.map((p) => path.relative(T, p)).sort(), ['q', 'q/link', 'q/private', 'q/run.sh']);
|
|
103
|
+
// A read-only folder still takes its files, and is read-only after the copy.
|
|
104
|
+
fs.mkdirSync(path.join(T, 'ro/locked'), { recursive: true });
|
|
105
|
+
fs.writeFileSync(path.join(T, 'ro/locked/f.txt'), 'z');
|
|
106
|
+
fs.chmodSync(path.join(T, 'ro/locked'), 0o555);
|
|
107
|
+
try {
|
|
108
|
+
cpMerge(path.join(T, 'ro'), path.join(T, 'rw'));
|
|
109
|
+
assert.equal(fs.readFileSync(path.join(T, 'rw/locked/f.txt'), 'utf8'), 'z');
|
|
110
|
+
assert.equal(fs.statSync(path.join(T, 'rw/locked')).mode & 0o777, 0o555);
|
|
111
|
+
} finally {
|
|
112
|
+
for (const d of ['ro/locked', 'rw/locked']) if (fs.existsSync(path.join(T, d))) fs.chmodSync(path.join(T, d), 0o755);
|
|
113
|
+
}
|
|
114
|
+
// A named pipe is refused, never read (copying one would wait forever).
|
|
115
|
+
fs.mkdirSync(path.join(T, 'r'));
|
|
116
|
+
spawnSync('mkfifo', [path.join(T, 'r/pipe')]);
|
|
117
|
+
if (fs.existsSync(path.join(T, 'r/pipe'))) assert.throws(() => cpMerge(path.join(T, 'r'), path.join(T, 's')), /not a file, a folder or a link/);
|
|
118
|
+
}
|
|
119
|
+
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('E161: the error catalogue, docs/CLI.md and the docs site list the same YAD-ENV codes', () => {
|
|
123
|
+
const env = Object.keys(CODES).filter((k) => k.startsWith('YAD-ENV-')).sort();
|
|
124
|
+
const cli = [...fs.readFileSync(path.join(ROOT, 'docs/CLI.md'), 'utf8').matchAll(/^\| `(YAD-ENV-\d+)` \|/gm)].map((m) => m[1]).sort();
|
|
125
|
+
const site = [...fs.readFileSync(path.join(ROOT, 'docs/sdlc-site/src/data/referenceData.ts'), 'utf8').matchAll(/code: '(YAD-ENV-\d+)'/g)].map((m) => m[1]).sort();
|
|
126
|
+
assert.deepEqual(cli, env);
|
|
127
|
+
assert.deepEqual(site, env);
|
|
128
|
+
});
|
|
129
|
+
|