@boyingliu01/xp-gate 0.39.1 → 0.39.3
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/adapters/gate-10.sh +0 -0
- package/adapters/gate-12-file-hygiene.sh +0 -0
- package/adapters/gate-13-compiler-strictness.sh +0 -0
- package/adapters/gate-3.sh +12 -5
- package/adapters/gate-4.sh +0 -0
- package/adapters/gate-6-layers.sh +0 -0
- package/adapters/gate-7.sh +0 -0
- package/adapters/gate-8.sh +0 -0
- package/gate-12-file-hygiene.sh +0 -0
- package/gate-13-compiler-strictness.sh +0 -0
- package/gate-3.sh +12 -5
- package/gate-6-layers.sh +0 -0
- package/gate-registry.sh +0 -0
- package/hooks/gate-12-file-hygiene.sh +0 -0
- package/hooks/gate-13-compiler-strictness.sh +0 -0
- package/hooks/gate-3.sh +12 -5
- package/hooks/gate-6-layers.sh +0 -0
- package/hooks/gate-driver.sh +0 -0
- package/hooks/gate-registry.sh +0 -0
- package/package.json +1 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/reinstall-xp-gate/.architecture-skip +8 -0
- package/plugins/dsh/skills/reinstall-xp-gate/.github/workflows/test.yml +106 -0
- package/plugins/dsh/skills/reinstall-xp-gate/CHANGELOG.md +379 -0
- package/plugins/dsh/skills/reinstall-xp-gate/LICENSE +21 -0
- package/plugins/dsh/skills/reinstall-xp-gate/QUALITY-OVERVIEW.md +173 -0
- package/plugins/dsh/skills/reinstall-xp-gate/README.md +167 -0
- package/plugins/dsh/skills/reinstall-xp-gate/SKILL.md +271 -0
- package/plugins/dsh/skills/reinstall-xp-gate/TODO.md +253 -0
- package/plugins/dsh/skills/reinstall-xp-gate/VERSION +1 -0
- package/plugins/dsh/skills/reinstall-xp-gate/package.json +28 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/audit.mjs +193 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/coverage.mjs +140 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/hp-gate.mjs +175 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/install.mjs +64 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/agent-paths.mjs +67 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/agents.mjs +247 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/backups.mjs +96 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/baseline.mjs +101 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/ccn.mjs +124 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/delphi.mjs +61 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/fs-tree.mjs +108 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/gatecheck.mjs +290 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/json-file.mjs +37 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/mutations.mjs +154 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/platform.mjs +92 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/probes.mjs +128 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/proc.mjs +33 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/report.mjs +29 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/residue.mjs +188 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/selfsync.mjs +75 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/skills.mjs +121 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/spawn.mjs +181 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/testreport.mjs +26 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/tools.mjs +238 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/util.mjs +33 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/verdict.mjs +45 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/version.mjs +29 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/lib/xp-cli.mjs +66 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/mutation.mjs +132 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/preflight.mjs +75 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/reinstall.mjs +305 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/setup-wsl.sh +633 -0
- package/plugins/dsh/skills/reinstall-xp-gate/scripts/verify.mjs +239 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/agents.test.mjs +168 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/baseline.test.mjs +104 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/ccn.test.mjs +87 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/cleanup.test.mjs +128 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/coverage.test.mjs +69 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/delphi.test.mjs +78 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/fixtures.mjs +61 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/gatecheck-audit.test.mjs +157 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/gatecheck.test.mjs +57 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/mutation-anchors.test.mjs +49 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/proc-contract.test.mjs +58 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/proc.test.mjs +255 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/report.test.mjs +66 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/residue.test.mjs +278 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/selfsync.test.mjs +70 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/skills.test.mjs +171 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/testreport.test.mjs +40 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/timeout-budgets.test.mjs +38 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/tools-leaf.test.mjs +323 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/tools-probe.test.mjs +350 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/tools.test.mjs +131 -0
- package/plugins/dsh/skills/reinstall-xp-gate/tests/util.test.mjs +154 -0
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { HOME } from './proc.mjs';
|
|
4
|
+
import { copyTree, isDir, isFile, pruneBackups, sameTree, stamp } from './util.mjs';
|
|
5
|
+
import { cmpVersion } from './version.mjs';
|
|
6
|
+
|
|
7
|
+
const SKILL_NAME = 'reinstall-xp-gate';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The tree `install.mjs` copies from.
|
|
11
|
+
*
|
|
12
|
+
* MEASURED on the 2.0.1 release: this returned the canonical copy whenever it
|
|
13
|
+
* existed, so a checkout at 2.0.1 kept distributing the 2.0.0 it had installed
|
|
14
|
+
* earlier and reported "已写入 0 个副本". The newer tree has to win, or a
|
|
15
|
+
* release never reaches the machines it was built on.
|
|
16
|
+
*/
|
|
17
|
+
export function defaultSource(selfDir) {
|
|
18
|
+
const canonical = path.join(HOME, '.local', 'share', 'xp-gate', 'skills', SKILL_NAME);
|
|
19
|
+
return newerSkillDir(selfDir, canonical);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The skill tree with the higher VERSION, ignoring a dir that is not one. */
|
|
23
|
+
export function newerSkillDir(a, b) {
|
|
24
|
+
const av = skillVersion(a);
|
|
25
|
+
const bv = skillVersion(b);
|
|
26
|
+
if (av === null) return bv === null ? a : b;
|
|
27
|
+
if (bv === null) return a;
|
|
28
|
+
return cmpVersion(av, bv) < 0 ? b : a;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The VERSION of a skill tree, or null when the dir is not one. */
|
|
32
|
+
function skillVersion(dir) {
|
|
33
|
+
if (!isDir(dir) || !isFile(path.join(dir, 'SKILL.md'))) return null;
|
|
34
|
+
const versionFile = path.join(dir, 'VERSION');
|
|
35
|
+
if (!isFile(versionFile)) return '';
|
|
36
|
+
return fs.readFileSync(versionFile, 'utf8').trim();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function backupDirFor(agent) {
|
|
40
|
+
const label = String(agent).replace(/[^a-z0-9]+/gi, '-').replace(/^-+|-+$/g, '') || 'agent';
|
|
41
|
+
return path.join(HOME, '.local', 'share', 'xp-gate', 'skills', '.backups', `${label}-${stamp()}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** What would have to happen to bring one agent root up to date. */
|
|
45
|
+
function stateFor(source, dest) {
|
|
46
|
+
if (!isDir(dest)) return 'new';
|
|
47
|
+
return sameTree(source, dest) ? 'ok' : 'update';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function syncOne(source, root, dryRun) {
|
|
51
|
+
const dest = path.join(root.dir, SKILL_NAME);
|
|
52
|
+
if (path.resolve(dest) === path.resolve(source)) {
|
|
53
|
+
return { agent: root.agent, dir: root.dir, dest, state: 'source' };
|
|
54
|
+
}
|
|
55
|
+
const state = stateFor(source, dest);
|
|
56
|
+
if (state !== 'ok' && !dryRun) {
|
|
57
|
+
if (state === 'update') {
|
|
58
|
+
const backup = backupDirFor(root.agent);
|
|
59
|
+
copyTree(dest, backup);
|
|
60
|
+
// Bound the set this very line just grew: without this the directory keeps
|
|
61
|
+
// one copy of the skill per install, forever.
|
|
62
|
+
pruneBackups(path.dirname(backup));
|
|
63
|
+
}
|
|
64
|
+
copyTree(source, dest);
|
|
65
|
+
}
|
|
66
|
+
return { agent: root.agent, dir: root.dir, dest, state };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 把本 skill 复制到每个 agent 的 skills 根。副本彼此独立、可单独运行。
|
|
71
|
+
* 只覆盖内容不同的副本,并在覆盖前备份。
|
|
72
|
+
*/
|
|
73
|
+
export function syncSelf({ source, roots, dryRun = false }) {
|
|
74
|
+
return roots.map((root) => syncOne(source, root, dryRun));
|
|
75
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { HOME } from './proc.mjs';
|
|
5
|
+
import { copyTree, isDir, isFile, listFiles, pruneBackups, sameTree } from './util.mjs';
|
|
6
|
+
|
|
7
|
+
function safeReaddir(dir) {
|
|
8
|
+
try {
|
|
9
|
+
return fs.readdirSync(dir, { withFileTypes: true });
|
|
10
|
+
} catch {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Names of the skills the installed package ships (`<pkg>/skills/<name>/SKILL.md`). */
|
|
16
|
+
export function bundledSkills(pkgDir) {
|
|
17
|
+
if (!pkgDir) return [];
|
|
18
|
+
return safeReaddir(path.join(pkgDir, 'skills'))
|
|
19
|
+
.filter((e) => e.isDirectory() && isFile(path.join(pkgDir, 'skills', e.name, 'SKILL.md')))
|
|
20
|
+
.map((e) => e.name)
|
|
21
|
+
.sort();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* How a deployed copy compares to the bundled skill.
|
|
26
|
+
*
|
|
27
|
+
* `ok` identical tree
|
|
28
|
+
* `drift` a shipped file differs or is missing -- the copy is damaged
|
|
29
|
+
* `extra` every shipped file matches, but the copy has files the package does
|
|
30
|
+
* not ship
|
|
31
|
+
* `missing` nothing deployed
|
|
32
|
+
*
|
|
33
|
+
* MEASURED: ~/xp-gate/skills/sprint-flow carries its own `__tests__/`, which the
|
|
34
|
+
* npm package does not include. All 26 shipped files matched byte for byte, yet
|
|
35
|
+
* a whole-tree hash called it `drift` and `verify` reported FAIL -- the
|
|
36
|
+
* distribution was correct and the verdict was wrong. `extra` keeps that visible
|
|
37
|
+
* without claiming the copy is damaged: a stray file can still shadow real
|
|
38
|
+
* content, so it is not `ok` either.
|
|
39
|
+
*/
|
|
40
|
+
function copyState(src, dest) {
|
|
41
|
+
if (!isDir(dest)) return { state: 'missing', extra: [] };
|
|
42
|
+
if (sameTree(src, dest)) return { state: 'ok', extra: [] };
|
|
43
|
+
const shipped = listFiles(src);
|
|
44
|
+
const local = listFiles(dest);
|
|
45
|
+
const localSet = new Set(local);
|
|
46
|
+
// A shipped file that is absent locally makes this 'drift' immediately.
|
|
47
|
+
const intact = shipped.every((rel) => localSet.has(rel) && contentHash(src, rel) === contentHash(dest, rel));
|
|
48
|
+
if (!intact) return { state: 'drift', extra: [] };
|
|
49
|
+
const shippedSet = new Set(shipped);
|
|
50
|
+
const extra = local.filter((rel) => !shippedSet.has(rel));
|
|
51
|
+
// Name the extras: "there are extra files" without saying which is not
|
|
52
|
+
// actionable, and the whole point of keeping `extra` visible is to let the
|
|
53
|
+
// reader decide whether they belong.
|
|
54
|
+
return { state: extra.length ? 'extra' : 'drift', extra };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Hash of one file inside a tree, or '' when it cannot be read. */
|
|
58
|
+
function contentHash(root, rel) {
|
|
59
|
+
try {
|
|
60
|
+
return crypto.createHash('sha256').update(fs.readFileSync(path.join(root, rel))).digest('hex');
|
|
61
|
+
} catch {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 每个 agent 根 × 每个发布包 skill 的状态:ok / drift / missing。
|
|
68
|
+
* 只读,不改盘;state 的基准是当前安装的发布包。
|
|
69
|
+
*/
|
|
70
|
+
export function planSkillCopies(pkgDir, roots) {
|
|
71
|
+
const names = bundledSkills(pkgDir);
|
|
72
|
+
const rows = [];
|
|
73
|
+
for (const root of roots) {
|
|
74
|
+
for (const name of names) {
|
|
75
|
+
const src = path.join(pkgDir, 'skills', name);
|
|
76
|
+
const dest = path.join(root.dir, name);
|
|
77
|
+
const { state, extra } = copyState(src, dest);
|
|
78
|
+
rows.push({ agent: root.agent, root: root.dir, name, src, dest, state, extra });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { names, rows };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function summarizeRows(rows) {
|
|
85
|
+
const byAgent = new Map();
|
|
86
|
+
for (const row of rows) {
|
|
87
|
+
const entry = byAgent.get(row.agent) || { total: 0, ok: 0, drift: 0, missing: 0, extra: 0 };
|
|
88
|
+
entry.total += 1;
|
|
89
|
+
entry[row.state] += 1;
|
|
90
|
+
byAgent.set(row.agent, entry);
|
|
91
|
+
}
|
|
92
|
+
return byAgent;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function safeLabel(name) {
|
|
96
|
+
return String(name).replace(/[^a-z0-9]+/gi, '-').replace(/^-+|-+$/g, '') || 'agent';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 补齐缺失、覆盖漂移。漂移副本先备份,用户改动不会被静默丢掉。
|
|
101
|
+
* @returns {Array} 实际处理的 row(含 applied / backup)
|
|
102
|
+
*/
|
|
103
|
+
export function applySkillCopies(rows, { backupRoot, dryRun = false } = {}) {
|
|
104
|
+
return rows.filter((row) => row.state !== 'ok').map((row) => applyOne(row, { backupRoot, dryRun }));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function applyOne(row, { backupRoot, dryRun }) {
|
|
108
|
+
if (dryRun) return row;
|
|
109
|
+
if (row.state === 'drift' && isDir(row.dest) && backupRoot) {
|
|
110
|
+
row.backup = path.join(backupRoot, safeLabel(row.agent), row.name);
|
|
111
|
+
copyTree(row.dest, row.backup);
|
|
112
|
+
pruneBackups(backupRoot);
|
|
113
|
+
}
|
|
114
|
+
copyTree(row.src, row.dest);
|
|
115
|
+
row.applied = true;
|
|
116
|
+
return row;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function skillsBackupRoot() {
|
|
120
|
+
return path.join(HOME, '.local', 'share', 'xp-gate', 'skills', '.backups');
|
|
121
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { isFile, stripNul } from './util.mjs';
|
|
4
|
+
import {
|
|
5
|
+
comspecOf,
|
|
6
|
+
isWindowsShim,
|
|
7
|
+
WIN_WHERE,
|
|
8
|
+
WIN_REG,
|
|
9
|
+
parseWhichOutput,
|
|
10
|
+
parseRegPathLine,
|
|
11
|
+
expandRegistryPath,
|
|
12
|
+
} from './platform.mjs';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Starting child processes, and asking them what they are.
|
|
16
|
+
*
|
|
17
|
+
* Split out of `proc.mjs` (Gate 4: 20 exports, maximum 10). Nothing here knows
|
|
18
|
+
* about xp-gate or npm layout; it is the layer that runs a program and reads
|
|
19
|
+
* its output, which is what the `run` family and the version probing need.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Budgets for the three kinds of child process this module starts.
|
|
24
|
+
*
|
|
25
|
+
* Named by INTENT, deliberately not by duration. A count of the literals used to
|
|
26
|
+
* show 30s four times, but those four were unrelated decisions -- a node syntax
|
|
27
|
+
* check and `npm root -g` happen to need the same number today while having
|
|
28
|
+
* nothing to do with each other. Grouping them under one `TIMEOUT_30S` would
|
|
29
|
+
* couple two changes that should stay independent.
|
|
30
|
+
*/
|
|
31
|
+
/** which / where / registry queries: a slow one means the tool is unusable. */
|
|
32
|
+
export const PROBE_TIMEOUT_MS = 10000;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* xp-gate mutations that rewrite the global install: uninstall --purge,
|
|
36
|
+
* `npm uninstall -g`, `update-hooks`, `doctor`. They shell out to the same CLI
|
|
37
|
+
* and are all slow for the same reason, so they share one budget.
|
|
38
|
+
*/
|
|
39
|
+
export const XP_GATE_SLOW_OP_TIMEOUT_MS = 300000;
|
|
40
|
+
|
|
41
|
+
let cachedPath = null;
|
|
42
|
+
|
|
43
|
+
/** Registry keys holding PATH, in append order. */
|
|
44
|
+
const REGISTRY_PATH_KEYS = [
|
|
45
|
+
'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment',
|
|
46
|
+
'HKCU\\Environment',
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Windows GUI 进程和 Git Bash 的 PATH 经常是陈旧的;工具已安装但看不见。
|
|
51
|
+
* 合并注册表 Machine/User PATH,探测工具时用这份。
|
|
52
|
+
*
|
|
53
|
+
* 从 Git Bash 启动时 node 往往不在 Windows PATH 上;npm 生成的 .cmd shim
|
|
54
|
+
* 内部用 `node` 兜底,缺了它就会报 "'node' is not recognized"。所以 node 所在
|
|
55
|
+
* 目录必须排在第一位。
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* The node directory leads ONLY where that is the fix it was written for.
|
|
59
|
+
*
|
|
60
|
+
* Prepending it unconditionally looks necessary on Windows (npm .cmd shims call
|
|
61
|
+
* bare `node`), but it silently reorders resolution everywhere: on Linux
|
|
62
|
+
* `process.execPath` is `/usr/bin/node`, so `/usr/bin` jumped to the front of
|
|
63
|
+
* `PATH`. Measured: a tool installed in an earlier `PATH` entry (jq 1.8.2 in
|
|
64
|
+
* `~/.local/bin`) kept resolving to the stale `/usr/bin/jq` (1.6), so the tool
|
|
65
|
+
* report said "outdated" while the shell said current -- and `upgradeTool`
|
|
66
|
+
* would have re-run a no-op upgrade forever. The `which`-based probe reported
|
|
67
|
+
* the same wrong binary, so this was not a display bug.
|
|
68
|
+
*
|
|
69
|
+
* On POSIX `sh` already resolves bare names from `PATH`, and node is reachable
|
|
70
|
+
* by construction, so the leading entry is pure harm there.
|
|
71
|
+
*/
|
|
72
|
+
function pathPrefixes() {
|
|
73
|
+
if (process.platform !== 'win32') return [];
|
|
74
|
+
return [path.dirname(process.execPath)];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function effectivePath() {
|
|
78
|
+
if (cachedPath) return cachedPath;
|
|
79
|
+
const parts = [...pathPrefixes(), ...(process.env.PATH || '').split(path.delimiter)];
|
|
80
|
+
if (process.platform === 'win32') {
|
|
81
|
+
for (const key of REGISTRY_PATH_KEYS) parts.push(...expandRegistryPath(readRegPath(key)));
|
|
82
|
+
}
|
|
83
|
+
cachedPath = [...new Set(parts.filter(Boolean))].join(path.delimiter);
|
|
84
|
+
return cachedPath;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function envWithPath() {
|
|
88
|
+
return { ...process.env, PATH: effectivePath() };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Shared spawn options. `run` and `runNpm` used to inline the same nine-field
|
|
93
|
+
* object, so adding a field (or fixing maxBuffer) had to be done twice and one
|
|
94
|
+
* copy was always the copy that got forgotten.
|
|
95
|
+
*/
|
|
96
|
+
function spawnOpts(opts, defaultTimeout) {
|
|
97
|
+
return {
|
|
98
|
+
cwd: opts.cwd,
|
|
99
|
+
timeout: opts.timeout ?? defaultTimeout,
|
|
100
|
+
stdio: opts.stdio,
|
|
101
|
+
encoding: opts.stdio ? undefined : 'utf8',
|
|
102
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
103
|
+
env: opts.env ?? envWithPath(),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function run(cmd, args, opts = {}) {
|
|
108
|
+
return spawnSync(cmd, args, spawnOpts(opts, 120000));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Windows 上直接 spawn .cmd/.bat 会 EINVAL;经 Git Bash 的 shell 执行 .cmd 又因
|
|
113
|
+
* 反斜杠转义失败(现象:工具明明在,probe 拿不到任何输出)。固定走 cmd.exe。
|
|
114
|
+
*/
|
|
115
|
+
export function probe(cmdPath, args, opts = {}) {
|
|
116
|
+
if (!isWindowsShim(cmdPath)) return run(cmdPath, args, opts);
|
|
117
|
+
const env = opts.env ?? envWithPath();
|
|
118
|
+
const line = `"${cmdPath}" ${args.map((a) => `"${a}"`).join(' ')}`;
|
|
119
|
+
return spawnSync(comspecOf(env), ['/d', '/s', '/c', `"${line}"`], {
|
|
120
|
+
windowsVerbatimArguments: true,
|
|
121
|
+
timeout: opts.timeout ?? 15000,
|
|
122
|
+
encoding: 'utf8',
|
|
123
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
124
|
+
env,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function which(tool) {
|
|
129
|
+
if (process.platform === 'win32') {
|
|
130
|
+
const r = run(WIN_WHERE, [tool], { timeout: PROBE_TIMEOUT_MS });
|
|
131
|
+
if (r.status !== 0) return '';
|
|
132
|
+
return parseWhichOutput(r.stdout);
|
|
133
|
+
}
|
|
134
|
+
const r = run('which', [tool], { timeout: PROBE_TIMEOUT_MS });
|
|
135
|
+
return r.status === 0 ? String(r.stdout).trim() : '';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** First non-empty line a tool prints for a version flag. */
|
|
139
|
+
function versionLine(resolved) {
|
|
140
|
+
for (const flag of ['--version', '-v', '-V', 'version']) {
|
|
141
|
+
const r = probe(resolved, [flag]);
|
|
142
|
+
const first = stripNul(`${r.stdout || ''}${r.stderr || ''}`)
|
|
143
|
+
.split(/\r?\n/)
|
|
144
|
+
.map((s) => s.trim())
|
|
145
|
+
.find(Boolean);
|
|
146
|
+
if (first) return first;
|
|
147
|
+
}
|
|
148
|
+
return '';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function toolVersion(tool) {
|
|
152
|
+
const resolved = which(tool);
|
|
153
|
+
if (!resolved) return { path: '', version: '' };
|
|
154
|
+
return { path: resolved, version: versionLine(resolved) };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** `npm-cli.js` next to node, or ''. */
|
|
158
|
+
export function npmCli() {
|
|
159
|
+
const nodeDir = path.dirname(process.execPath);
|
|
160
|
+
const candidates = [
|
|
161
|
+
path.join(nodeDir, 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
162
|
+
path.resolve(nodeDir, '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
163
|
+
];
|
|
164
|
+
return candidates.find(isFile) || '';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function runNpm(args, opts = {}) {
|
|
168
|
+
const cli = npmCli();
|
|
169
|
+
if (!cli) {
|
|
170
|
+
return { status: 127, stdout: '', stderr: 'npm-cli.js not found next to node' };
|
|
171
|
+
}
|
|
172
|
+
return spawnSync(process.execPath, [cli, ...args], spawnOpts(opts, 180000));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** The raw `Path` value of one registry environment key, or ''. */
|
|
176
|
+
function readRegPath(key) {
|
|
177
|
+
if (!isFile(WIN_REG)) return '';
|
|
178
|
+
const r = spawnSync(WIN_REG, ['query', key, '/v', 'Path'], { encoding: 'utf8', timeout: PROBE_TIMEOUT_MS });
|
|
179
|
+
if (r.status !== 0) return '';
|
|
180
|
+
return parseRegPathLine(r.stdout);
|
|
181
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the failure count out of Node's test-runner output.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS IS A SEPARATE MODULE
|
|
5
|
+
* -----------------------------
|
|
6
|
+
* Node picks its reporter by whether stdout is a TTY:
|
|
7
|
+
*
|
|
8
|
+
* local terminal ℹ tests 92 / ℹ pass 92 / ℹ fail 0 (spec)
|
|
9
|
+
* CI (piped) # tests 92 / # pass 92 / # fail 0 (TAP)
|
|
10
|
+
*
|
|
11
|
+
* A regex matching only the spec spelling made every CI run of the mutation
|
|
12
|
+
* gate report "the runner failed", because it was looking for the wrong
|
|
13
|
+
* spelling of a line that was right there. The same mistake would make a
|
|
14
|
+
* genuinely broken run look merely unreadable, or vice versa, so the parse is
|
|
15
|
+
* isolated here and tested against both formats instead of being buried in the
|
|
16
|
+
* runner.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} output combined stdout+stderr of a `node --test` run
|
|
21
|
+
* @returns {number} failing test count, or -1 when no count could be read
|
|
22
|
+
*/
|
|
23
|
+
export function parseFailCount(output) {
|
|
24
|
+
const match = String(output).match(/(?:\u2139 fail|# fail) (\d+)/);
|
|
25
|
+
return match ? Number(match[1]) : -1;
|
|
26
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { runNpm, toolVersion, which, run } from './proc.mjs';
|
|
2
|
+
import { semverOf, cmpVersion } from './version.mjs';
|
|
3
|
+
import {
|
|
4
|
+
PACKAGE_INSTALL_TIMEOUT_MS,
|
|
5
|
+
npmLatest,
|
|
6
|
+
pythonBin,
|
|
7
|
+
pipShowVersion,
|
|
8
|
+
pipLatest,
|
|
9
|
+
pypiLatest,
|
|
10
|
+
githubLatest,
|
|
11
|
+
} from './probes.mjs';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Classifying the gate tools: what is installed, what is newest, what to do.
|
|
15
|
+
*
|
|
16
|
+
* Gate 4 flagged this module for owning 18 exports against a maximum of 10. The
|
|
17
|
+
* count came from three jobs living together -- parsing versions, asking each
|
|
18
|
+
* package manager for one, and combining the answers into a report. The first
|
|
19
|
+
* two moved to `version.mjs` and `probes.mjs`; this file keeps the orchestration
|
|
20
|
+
* and the report rows, which is what `verify` and `reinstall` actually want.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
export const TOOLS = [
|
|
24
|
+
{ name: 'jscpd', kind: 'npm', pkg: 'jscpd' },
|
|
25
|
+
{ name: 'lizard', kind: 'pip', pkg: 'lizard' },
|
|
26
|
+
{ name: 'checkov', kind: 'pip', pkg: 'checkov' },
|
|
27
|
+
{ name: 'hadolint', kind: 'binary', repo: 'hadolint/hadolint' },
|
|
28
|
+
{ name: 'gitleaks', kind: 'binary', repo: 'gitleaks/gitleaks' },
|
|
29
|
+
{ name: 'semgrep', kind: 'pip', pkg: 'semgrep' },
|
|
30
|
+
{ name: 'npx', kind: 'node' },
|
|
31
|
+
{ name: 'jq', kind: 'binary', repo: 'jqlang/jq' },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Fill the version/path of a pip-managed tool from whichever source answers.
|
|
36
|
+
*
|
|
37
|
+
* `deps` carries the same lookups `detect` received. Without threading them
|
|
38
|
+
* through, injecting `toolVersion` at the top still let this function call the
|
|
39
|
+
* real one -- each test then paid a live `which python` round trip, which is
|
|
40
|
+
* how a supposedly isolated unit test took 5-7 s.
|
|
41
|
+
*/
|
|
42
|
+
export function pipProbe(spec, row, deps = {}) {
|
|
43
|
+
const d = resolveDeps(deps);
|
|
44
|
+
const shown = d.pipShowVersion(spec.pkg, d.pythonBin);
|
|
45
|
+
const probe = d.toolVersion(spec.name);
|
|
46
|
+
if (!shown && !probe.path) return;
|
|
47
|
+
row.present = true;
|
|
48
|
+
row.version = pipVersion(shown, probe.version);
|
|
49
|
+
row.path = pipPath(shown, probe.path, spec.pkg);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* pip's own metadata wins over the version banner when both answered: the banner
|
|
54
|
+
* is a tool-specific string, the metadata is the installed distribution version.
|
|
55
|
+
* A binary's version is kept raw because it may be unparseable by design.
|
|
56
|
+
*/
|
|
57
|
+
function pipVersion(shown, probed) {
|
|
58
|
+
if (shown) return semverOf(shown);
|
|
59
|
+
return semverOf(probed) || probed;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A venv install is not on PATH, so the path has to say how to reach it. */
|
|
63
|
+
function pipPath(shown, probedPath, pkg) {
|
|
64
|
+
if (!shown) return probedPath;
|
|
65
|
+
return probedPath || `python -m pip show ${pkg}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Every external effect the probe layer can reach, resolved once.
|
|
70
|
+
*
|
|
71
|
+
* Spreading `deps.x || realX` through each function made every signature carry
|
|
72
|
+
* its own fallback chain, which pushed six of them past the CCN 5 ceiling
|
|
73
|
+
* (measured: pipLatest 9, pipProbe 9, latestFor 8, pipShowVersion 7, detect 7,
|
|
74
|
+
* upgraders 6). Filling the gaps in one place keeps each probe a straight-line
|
|
75
|
+
* read of `deps` and restores the complexity budget.
|
|
76
|
+
*
|
|
77
|
+
* The table is data rather than a chain of `||` so adding a seam costs a row,
|
|
78
|
+
* not a branch: written as a chain this function alone measured CCN 15.
|
|
79
|
+
*
|
|
80
|
+
* Production passes nothing, so every field is the real implementation and
|
|
81
|
+
* behaviour is unchanged; tests pass only the fields they want to fake.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
const DEFAULT_DEPS = {
|
|
85
|
+
toolVersion,
|
|
86
|
+
pipProbe,
|
|
87
|
+
pipShowVersion,
|
|
88
|
+
pythonBin,
|
|
89
|
+
run,
|
|
90
|
+
runNpm,
|
|
91
|
+
npmLatest,
|
|
92
|
+
pipLatest,
|
|
93
|
+
githubLatest,
|
|
94
|
+
pypiLatest,
|
|
95
|
+
fetchImpl: fetch,
|
|
96
|
+
lookup: latestFor,
|
|
97
|
+
log: (msg) => console.log(msg),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
function resolveDeps(deps = {}) {
|
|
101
|
+
const resolved = { ...DEFAULT_DEPS };
|
|
102
|
+
for (const [key, value] of Object.entries(deps)) {
|
|
103
|
+
if (value !== undefined) resolved[key] = value;
|
|
104
|
+
}
|
|
105
|
+
return resolved;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Probe one tool spec into a report row.
|
|
110
|
+
*
|
|
111
|
+
* `deps` exists so the probe can be exercised without real tools on PATH:
|
|
112
|
+
* `toolVersion` shells out via `proc.mjs`, whose bindings are fixed at module
|
|
113
|
+
* load and cannot be swapped by a test. Injecting the lookups keeps the
|
|
114
|
+
* production default identical while making every branch reachable.
|
|
115
|
+
*/
|
|
116
|
+
export function detect(spec, deps = {}) {
|
|
117
|
+
const d = resolveDeps(deps);
|
|
118
|
+
const row = { ...spec, path: '', present: false, version: '', latest: '', status: 'ok' };
|
|
119
|
+
if (spec.kind === 'pip') {
|
|
120
|
+
d.pipProbe(spec, row, deps);
|
|
121
|
+
return row;
|
|
122
|
+
}
|
|
123
|
+
const probe = d.toolVersion(spec.name);
|
|
124
|
+
row.present = Boolean(probe.path);
|
|
125
|
+
row.path = probe.path;
|
|
126
|
+
row.version = spec.kind === 'binary' ? probe.version : semverOf(probe.version) || probe.version;
|
|
127
|
+
return row;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Best known release for a tool, or '' when the lookup is unavailable.
|
|
132
|
+
*
|
|
133
|
+
* Every branch reaches the network or spawns a package manager, so the three
|
|
134
|
+
* sources are injectable. Without that seam none of them is testable, which is
|
|
135
|
+
* how this function reached 25% function coverage while carrying the decision
|
|
136
|
+
* that turns a tool row into 'outdated'.
|
|
137
|
+
*/
|
|
138
|
+
export async function latestFor(row, deps = {}) {
|
|
139
|
+
const d = resolveDeps(deps);
|
|
140
|
+
const source = { npm: d.npmLatest, pip: d.pipLatest, binary: d.githubLatest }[row.kind];
|
|
141
|
+
if (!source) return '';
|
|
142
|
+
const raw = row.kind === 'npm' ? source(row.pkg) : await source(row.kind === 'pip' ? row.pkg : row.repo);
|
|
143
|
+
return semverOf(raw);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Classify one row. `node` (npx) has no independent version to compare, so it
|
|
148
|
+
* is 'ok' whenever it resolves -- calling it 'unverified' every run would add a
|
|
149
|
+
* permanent WARN that trains the operator to ignore the column.
|
|
150
|
+
*/
|
|
151
|
+
export async function classify(row, lookup = latestFor) {
|
|
152
|
+
if (!row.present) {
|
|
153
|
+
row.status = 'missing';
|
|
154
|
+
return row;
|
|
155
|
+
}
|
|
156
|
+
row.latest = await lookup(row);
|
|
157
|
+
row.status = statusOf(row);
|
|
158
|
+
return row;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The verdict for one probed row.
|
|
163
|
+
*
|
|
164
|
+
* Split out and exported because it is the whole decision and it has three
|
|
165
|
+
* outcomes that are easy to collapse: a tool that is absent ('missing'), one
|
|
166
|
+
* whose latest version could not be fetched ('unverified'), and one that is
|
|
167
|
+
* genuinely behind ('outdated'). Reporting the middle case as 'ok' would say a
|
|
168
|
+
* tool is current when nothing was compared -- the same silent pass this
|
|
169
|
+
* project exists to avoid. `node` is the documented exception: it has no
|
|
170
|
+
* independent version to compare against, so a permanent 'unverified' would be
|
|
171
|
+
* noise rather than information.
|
|
172
|
+
*/
|
|
173
|
+
export function statusOf(row) {
|
|
174
|
+
if (row.latest) return cmpVersion(row.version, row.latest) < 0 ? 'outdated' : 'ok';
|
|
175
|
+
return row.kind === 'node' ? 'ok' : 'unverified';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** 8 个门禁 CLI 的存在性 + 版本 + 可达最新。 */
|
|
179
|
+
export async function toolReport(deps = {}) {
|
|
180
|
+
const d = resolveDeps(deps);
|
|
181
|
+
const rows = TOOLS.map((spec) => detect(spec, d));
|
|
182
|
+
// Not `rows.map(classify)`: map passes (value, index, array), so the index
|
|
183
|
+
// lands in the `lookup` parameter and every call dies with "lookup is not a
|
|
184
|
+
// function". The default only applies when the argument is undefined.
|
|
185
|
+
await Promise.all(rows.map((row) => classify(row, d.lookup)));
|
|
186
|
+
return rows;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** `install -g <pkg>@latest` through npm; the exit code is the verdict. */
|
|
190
|
+
function upgradeNpm(row, d) {
|
|
191
|
+
const r = d.runNpm(['install', '-g', `${row.pkg}@latest`], { stdio: 'inherit', timeout: PACKAGE_INSTALL_TIMEOUT_MS });
|
|
192
|
+
return r.status ?? 1;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** `pip install -U <pkg>`; without an interpreter there is nothing to run. */
|
|
196
|
+
function upgradePip(row, d) {
|
|
197
|
+
const py = d.pythonBin();
|
|
198
|
+
if (!py) return 1;
|
|
199
|
+
const r = d.run(py, ['-m', 'pip', 'install', '-U', row.pkg], { stdio: 'inherit', timeout: PACKAGE_INSTALL_TIMEOUT_MS });
|
|
200
|
+
return r.status ?? 1;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* 二进制工具没有统一的包管理器入口,只提示,不擅自下载覆盖用户的 PATH。
|
|
205
|
+
*/
|
|
206
|
+
function upgradeBinary(row, d) {
|
|
207
|
+
d.log(` ${row.name}: 二进制工具,请从 ${row.repo || '官方 release'} 手动升级到 ${row.latest || '最新版'}`);
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 各 kind 的升级方式。表驱动而不是 if-链:原来是三分支嵌套,
|
|
213
|
+
* 加一种 kind 就要再嵌一层,而现在只需要加一行。
|
|
214
|
+
*
|
|
215
|
+
* 每条分支都通过 `deps` 注入以便测试:它们真的会执行全局安装,
|
|
216
|
+
* 在测试里跑一次就会改动开发机的工具链。
|
|
217
|
+
*/
|
|
218
|
+
const UPGRADERS = { npm: upgradeNpm, pip: upgradePip, binary: upgradeBinary };
|
|
219
|
+
|
|
220
|
+
export function upgradeTool(row, deps = {}) {
|
|
221
|
+
const upgrade = UPGRADERS[row.kind];
|
|
222
|
+
return upgrade ? upgrade(row, resolveDeps(deps)) : 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Implementation moved to `version.mjs` and `probes.mjs`; re-exported so the
|
|
226
|
+
// existing import sites keep working and `tools.mjs` stays the one place to ask
|
|
227
|
+
// about gate tools.
|
|
228
|
+
export { semverOf, cmpVersion } from './version.mjs';
|
|
229
|
+
export {
|
|
230
|
+
PACKAGE_INSTALL_TIMEOUT_MS,
|
|
231
|
+
npmLatest,
|
|
232
|
+
pythonBin,
|
|
233
|
+
pipShowVersion,
|
|
234
|
+
pipLatest,
|
|
235
|
+
fetchJsonVersion,
|
|
236
|
+
pypiLatest,
|
|
237
|
+
githubLatest,
|
|
238
|
+
} from './probes.mjs';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem and value helpers -- the module every script in this repo imports.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS IS A RE-EXPORT AND NOT THE IMPLEMENTATION
|
|
5
|
+
* --------------------------------------------------
|
|
6
|
+
* Gate 4 flagged it for owning 13 exports against a maximum of 10. As with
|
|
7
|
+
* `proc.mjs`, that count was a symptom: tree walking and small JSON/formatting
|
|
8
|
+
* helpers are different jobs that happened to live together.
|
|
9
|
+
*
|
|
10
|
+
* The importers are left alone on purpose. From their side this is one
|
|
11
|
+
* "helpers" API, and rewriting a dozen import sites to lower a lint number is
|
|
12
|
+
* churn. Implementations live in `fs-tree.mjs`, `json-file.mjs` and
|
|
13
|
+
* `backups.mjs`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
isFile,
|
|
18
|
+
isDir,
|
|
19
|
+
listFiles,
|
|
20
|
+
hashTree,
|
|
21
|
+
sameTree,
|
|
22
|
+
rmrf,
|
|
23
|
+
copyTree,
|
|
24
|
+
} from './fs-tree.mjs';
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
readJson,
|
|
28
|
+
writeJson,
|
|
29
|
+
stamp,
|
|
30
|
+
stripNul,
|
|
31
|
+
} from './json-file.mjs';
|
|
32
|
+
|
|
33
|
+
export { BACKUP_KEEP, pruneBackups } from './backups.mjs';
|