@izkac/forgekit 0.3.11 → 0.3.13
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/bin/forge.mjs +107 -107
- package/bin/forgekit.mjs +83 -83
- package/bin/review.mjs +81 -81
- package/package.json +1 -1
- package/scripts/prepack.mjs +78 -78
- package/scripts/run-tests.mjs +50 -50
- package/src/adr.mjs +236 -236
- package/src/adr.test.mjs +170 -170
- package/src/change.mjs +327 -234
- package/src/change.test.mjs +145 -83
- package/src/cleanup-sessions.mjs +84 -84
- package/src/config.mjs +103 -103
- package/src/defer.mjs +75 -75
- package/src/doctor.mjs +350 -341
- package/src/doctor.test.mjs +114 -114
- package/src/init.mjs +680 -621
- package/src/install.mjs +815 -815
- package/src/install.test.mjs +180 -180
- package/src/integrity-check.mjs +60 -60
- package/src/integrity.mjs +682 -682
- package/src/integrity.test.mjs +566 -566
- package/src/lib.mjs +143 -143
- package/src/models.defaults.json +41 -41
- package/src/new-session.mjs +99 -99
- package/src/openspec-overlays/README.md +19 -19
- package/src/openspec-overlays/openspec-apply-change-footer.md +14 -14
- package/src/openspec-overlays/opsx-apply-completion-step.md +1 -1
- package/src/openspec-overlays/opsx-apply-implement-step.md +11 -11
- package/src/paths.mjs +92 -92
- package/src/plan-engine.mjs +321 -278
- package/src/plan-engine.test.mjs +447 -283
- package/src/preferences.defaults.json +78 -78
- package/src/preferences.mjs +438 -438
- package/src/preferences.test.mjs +174 -174
- package/src/record-evidence.mjs +204 -204
- package/src/resolve-model.mjs +312 -312
- package/src/resolve-model.test.mjs +194 -194
- package/src/review/cli.test.mjs +117 -117
- package/src/review/export.mjs +172 -172
- package/src/review/export.test.mjs +197 -197
- package/src/review/fixtures/valid-review.json +42 -42
- package/src/review/lib.mjs +894 -894
- package/src/review/lib.test.mjs +266 -266
- package/src/review/schema.json +196 -196
- package/src/review/signals.test.mjs +62 -62
- package/src/score-cli.mjs +68 -68
- package/src/score.mjs +568 -566
- package/src/score.test.mjs +366 -340
- package/src/session-reminder.mjs +207 -207
- package/src/session-status.mjs +70 -70
- package/src/set-models.mjs +186 -186
- package/src/set-phase.mjs +205 -205
- package/src/set-prefs.mjs +294 -294
- package/src/specs-sync.mjs +234 -0
- package/src/specs-sync.test.mjs +114 -0
- package/src/spine.mjs +93 -93
- package/src/triage-prompt.mjs +175 -175
- package/src/triage-prompt.test.mjs +50 -50
- package/src/vendor-openspec-overlays.mjs +176 -176
- package/src/vendor-openspec-overlays.test.mjs +62 -62
- package/vendor/skills/archive-to-adr/SKILL.md +149 -149
- package/vendor/skills/forge/SKILL.md +136 -136
- package/vendor/skills/forge/docs/forge.md +650 -647
- package/vendor/skills/forge/phases/brainstorm.md +23 -23
- package/vendor/skills/forge/phases/finish.md +90 -87
- package/vendor/skills/forge/phases/implement.md +77 -77
- package/vendor/skills/forge/phases/plan-openspec.md +60 -60
- package/vendor/skills/forge/phases/plan-specs.md +163 -117
- package/vendor/skills/forge/phases/review.md +25 -25
- package/vendor/skills/forge/phases/verify.md +124 -124
- package/vendor/skills/forge/references/forge-layout.md +85 -85
- package/vendor/skills/forge/references/pace.md +115 -115
- package/vendor/skills/forge/references/plan-routing.md +52 -51
- package/vendor/skills/forge/references/runtime-integrity.md +232 -225
- package/vendor/skills/forge/references/substantial-work.md +37 -37
- package/vendor/skills/forge/references/test-evidence.md +30 -30
- package/vendor/skills/forge/references/test-strategy.md +68 -68
- package/vendor/skills/forge/skills/subagent-driven-development/SKILL.md +87 -87
- package/vendor/skills/forge/subagents/final-reviewer-prompt.md +56 -56
- package/vendor/skills/forge/subagents/implementer-prompt.md +38 -38
- package/vendor/skills/git-resolve-adr-conflict/SKILL.md +132 -132
- package/vendor/skills/thorough-code-review/SKILL.md +290 -290
- package/vendor/skills/thorough-code-review/examples.md +133 -133
- package/vendor/skills/thorough-code-review/reference/accepted-risks.md +26 -26
- package/vendor/skills/thorough-code-review/reference/lenses.md +96 -96
- package/vendor/skills/thorough-code-review/reference/phase1-scout.md +62 -62
- package/vendor/skills/thorough-code-review/reference/phase2-skeptic.md +105 -105
- package/vendor/skills/thorough-code-review/reference/report-schema.json +222 -222
- package/vendor/skills/thorough-code-review/reference/report-template.md +115 -115
- package/vendor/skills/thorough-code-review/reference/severity-rubric.md +49 -49
- package/vendor/skills/thorough-code-review/reference/signals-preflight.md +55 -55
- package/vendor/templates/adr/README.md +7 -7
- package/vendor/templates/adr/decisions.md +141 -141
- package/vendor/templates/adr/hooks/check-pending-adrs.mjs +74 -74
- package/vendor/templates/adr/hooks/check-pending-adrs.sh +3 -3
- package/vendor/templates/adr/hooks/openspec-archive-agent-message.mjs +52 -52
- package/vendor/templates/adr/hooks/openspec-archive-agent-message.sh +3 -3
- package/vendor/templates/project/claude/commands/forge-apply.md +75 -75
- package/vendor/templates/project/claude/commands/forge-brainstorm.md +7 -7
- package/vendor/templates/project/claude/commands/forge-build.md +17 -17
- package/vendor/templates/project/claude/commands/forge-plan.md +12 -12
- package/vendor/templates/project/claude/commands/forge-skip.md +14 -14
- package/vendor/templates/project/claude/commands/forge-status.md +16 -16
- package/vendor/templates/project/claude/commands/forge.md +16 -16
- package/vendor/templates/project/claude/hooks/forge-prompt-hook.mjs +73 -73
- package/vendor/templates/project/claude/hooks/forge-session-start.mjs +19 -19
- package/vendor/templates/project/claude/hooks/forge-triage-hook.mjs +77 -77
- package/vendor/templates/project/cursor/commands/forge-apply.md +75 -75
- package/vendor/templates/project/cursor/commands/forge-brainstorm.md +10 -10
- package/vendor/templates/project/cursor/commands/forge-build.md +17 -17
- package/vendor/templates/project/cursor/commands/forge-plan.md +15 -15
- package/vendor/templates/project/cursor/commands/forge-skip.md +14 -14
- package/vendor/templates/project/cursor/commands/forge-status.md +16 -16
- package/vendor/templates/project/cursor/commands/forge.md +16 -16
- package/vendor/templates/project/cursor/hooks/forge-session-start.mjs +30 -30
- package/vendor/templates/project/cursor/hooks/forge-session-start.sh +3 -3
package/src/review/export.mjs
CHANGED
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Export and validate thorough code review JSON sidecars for CI.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* review export [--file <json>] [--out <dir>] [--fail-on critical]
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import { pathToFileURL } from 'node:url';
|
|
12
|
-
import {
|
|
13
|
-
REVIEWS_DIR,
|
|
14
|
-
findLatestReviewJson,
|
|
15
|
-
formatSummary,
|
|
16
|
-
countOpenAtOrAbove,
|
|
17
|
-
renderMarkdown,
|
|
18
|
-
validateReport,
|
|
19
|
-
} from './lib.mjs';
|
|
20
|
-
|
|
21
|
-
const FAIL_ON_LEVELS = new Set(['critical', 'important', 'minor']);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @param {string[]} argv
|
|
25
|
-
*/
|
|
26
|
-
export function parseArgs(argv) {
|
|
27
|
-
const opts = {
|
|
28
|
-
file: null,
|
|
29
|
-
out: null,
|
|
30
|
-
failOn: null,
|
|
31
|
-
failOnCritical: false,
|
|
32
|
-
renderMd: false,
|
|
33
|
-
reviewsDir: REVIEWS_DIR,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
37
|
-
const arg = argv[i];
|
|
38
|
-
if (arg === '--file') {
|
|
39
|
-
opts.file = argv[++i];
|
|
40
|
-
} else if (arg === '--out') {
|
|
41
|
-
opts.out = argv[++i];
|
|
42
|
-
} else if (arg === '--render-md') {
|
|
43
|
-
opts.renderMd = true;
|
|
44
|
-
} else if (arg === '--fail-on') {
|
|
45
|
-
const level = argv[++i];
|
|
46
|
-
if (!FAIL_ON_LEVELS.has(level)) {
|
|
47
|
-
throw new Error(`unsupported --fail-on value: ${level} (expected critical|important|minor)`);
|
|
48
|
-
}
|
|
49
|
-
opts.failOn = level;
|
|
50
|
-
opts.failOnCritical = level === 'critical';
|
|
51
|
-
} else if (arg === '--reviews-dir') {
|
|
52
|
-
opts.reviewsDir = argv[++i];
|
|
53
|
-
} else if (arg === '--help' || arg === '-h') {
|
|
54
|
-
opts.help = true;
|
|
55
|
-
} else {
|
|
56
|
-
throw new Error(`unknown argument: ${arg}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return opts;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @param {ReturnType<typeof parseArgs>} opts
|
|
65
|
-
* @param {string} [cwd]
|
|
66
|
-
* @returns {{ exitCode: number; message: string }}
|
|
67
|
-
*/
|
|
68
|
-
export function runExport(opts, cwd = process.cwd()) {
|
|
69
|
-
const reviewsDir = path.resolve(cwd, opts.reviewsDir ?? REVIEWS_DIR);
|
|
70
|
-
const jsonPath = opts.file
|
|
71
|
-
? path.isAbsolute(opts.file)
|
|
72
|
-
? opts.file
|
|
73
|
-
: path.resolve(cwd, opts.file)
|
|
74
|
-
: findLatestReviewJson(reviewsDir);
|
|
75
|
-
|
|
76
|
-
if (!jsonPath) {
|
|
77
|
-
return { exitCode: 1, message: `no review JSON found in ${reviewsDir}` };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!fs.existsSync(jsonPath)) {
|
|
81
|
-
return { exitCode: 1, message: `file not found: ${jsonPath}` };
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
let parsed;
|
|
85
|
-
try {
|
|
86
|
-
parsed = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
|
|
87
|
-
} catch (err) {
|
|
88
|
-
return { exitCode: 1, message: `invalid JSON: ${/** @type {Error} */ (err).message}` };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const validation = validateReport(parsed);
|
|
92
|
-
if (!validation.ok) {
|
|
93
|
-
return {
|
|
94
|
-
exitCode: 1,
|
|
95
|
-
message: `validation failed for ${jsonPath}:\n${validation.errors.map((e) => ` - ${e}`).join('\n')}`,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const report = validation.report;
|
|
100
|
-
const lines = [`OK ${jsonPath}`, formatSummary(report)];
|
|
101
|
-
|
|
102
|
-
if (opts.renderMd) {
|
|
103
|
-
const mdPath = jsonPath.replace(/\.json$/, '.md');
|
|
104
|
-
fs.writeFileSync(mdPath, `${renderMarkdown(report)}\n`, 'utf8');
|
|
105
|
-
lines.push(`rendered: ${mdPath}`);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (opts.out) {
|
|
109
|
-
const outDir = path.resolve(cwd, opts.out);
|
|
110
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
111
|
-
const base = path.basename(jsonPath);
|
|
112
|
-
const mdBase = base.replace(/\.json$/, '.md');
|
|
113
|
-
const jsonDest = path.join(outDir, base);
|
|
114
|
-
const mdSrc = path.join(path.dirname(jsonPath), mdBase);
|
|
115
|
-
fs.copyFileSync(jsonPath, jsonDest);
|
|
116
|
-
if (fs.existsSync(mdSrc)) {
|
|
117
|
-
fs.copyFileSync(mdSrc, path.join(outDir, mdBase));
|
|
118
|
-
lines.push(`copied: ${jsonDest}, ${path.join(outDir, mdBase)}`);
|
|
119
|
-
} else {
|
|
120
|
-
lines.push(`copied: ${jsonDest} (no paired .md at ${mdSrc})`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const failLevel = opts.failOn ?? (opts.failOnCritical ? 'critical' : null);
|
|
125
|
-
if (failLevel) {
|
|
126
|
-
const openCount = countOpenAtOrAbove(report, failLevel);
|
|
127
|
-
if (openCount > 0) {
|
|
128
|
-
lines.push(`FAIL: ${openCount} open ${failLevel}+ finding(s)`);
|
|
129
|
-
return { exitCode: 1, message: lines.join('\n') };
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return { exitCode: 0, message: lines.join('\n') };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function printHelp() {
|
|
137
|
-
console.log(`Usage: review export [options]
|
|
138
|
-
|
|
139
|
-
Options:
|
|
140
|
-
--file <path> Review JSON (default: latest *-review.json in .reviews/)
|
|
141
|
-
--out <dir> Copy JSON (+ paired .md if present) to directory
|
|
142
|
-
--render-md (Re)generate the paired Markdown from the JSON first
|
|
143
|
-
--fail-on <level> Exit 1 if any open finding at/above level remains
|
|
144
|
-
(critical | important | minor)
|
|
145
|
-
--reviews-dir <dir> Reviews directory (default: .reviews)
|
|
146
|
-
-h, --help Show this help
|
|
147
|
-
`);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function main() {
|
|
151
|
-
try {
|
|
152
|
-
const opts = parseArgs(process.argv.slice(2));
|
|
153
|
-
if (opts.help) {
|
|
154
|
-
printHelp();
|
|
155
|
-
process.exit(0);
|
|
156
|
-
}
|
|
157
|
-
const result = runExport(opts);
|
|
158
|
-
console.log(result.message);
|
|
159
|
-
process.exit(result.exitCode);
|
|
160
|
-
} catch (err) {
|
|
161
|
-
console.error(/** @type {Error} */ (err).message);
|
|
162
|
-
process.exit(1);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const isMain =
|
|
167
|
-
process.argv[1] &&
|
|
168
|
-
import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href;
|
|
169
|
-
|
|
170
|
-
if (isMain) {
|
|
171
|
-
main();
|
|
172
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Export and validate thorough code review JSON sidecars for CI.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* review export [--file <json>] [--out <dir>] [--fail-on critical]
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
12
|
+
import {
|
|
13
|
+
REVIEWS_DIR,
|
|
14
|
+
findLatestReviewJson,
|
|
15
|
+
formatSummary,
|
|
16
|
+
countOpenAtOrAbove,
|
|
17
|
+
renderMarkdown,
|
|
18
|
+
validateReport,
|
|
19
|
+
} from './lib.mjs';
|
|
20
|
+
|
|
21
|
+
const FAIL_ON_LEVELS = new Set(['critical', 'important', 'minor']);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string[]} argv
|
|
25
|
+
*/
|
|
26
|
+
export function parseArgs(argv) {
|
|
27
|
+
const opts = {
|
|
28
|
+
file: null,
|
|
29
|
+
out: null,
|
|
30
|
+
failOn: null,
|
|
31
|
+
failOnCritical: false,
|
|
32
|
+
renderMd: false,
|
|
33
|
+
reviewsDir: REVIEWS_DIR,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
37
|
+
const arg = argv[i];
|
|
38
|
+
if (arg === '--file') {
|
|
39
|
+
opts.file = argv[++i];
|
|
40
|
+
} else if (arg === '--out') {
|
|
41
|
+
opts.out = argv[++i];
|
|
42
|
+
} else if (arg === '--render-md') {
|
|
43
|
+
opts.renderMd = true;
|
|
44
|
+
} else if (arg === '--fail-on') {
|
|
45
|
+
const level = argv[++i];
|
|
46
|
+
if (!FAIL_ON_LEVELS.has(level)) {
|
|
47
|
+
throw new Error(`unsupported --fail-on value: ${level} (expected critical|important|minor)`);
|
|
48
|
+
}
|
|
49
|
+
opts.failOn = level;
|
|
50
|
+
opts.failOnCritical = level === 'critical';
|
|
51
|
+
} else if (arg === '--reviews-dir') {
|
|
52
|
+
opts.reviewsDir = argv[++i];
|
|
53
|
+
} else if (arg === '--help' || arg === '-h') {
|
|
54
|
+
opts.help = true;
|
|
55
|
+
} else {
|
|
56
|
+
throw new Error(`unknown argument: ${arg}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return opts;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {ReturnType<typeof parseArgs>} opts
|
|
65
|
+
* @param {string} [cwd]
|
|
66
|
+
* @returns {{ exitCode: number; message: string }}
|
|
67
|
+
*/
|
|
68
|
+
export function runExport(opts, cwd = process.cwd()) {
|
|
69
|
+
const reviewsDir = path.resolve(cwd, opts.reviewsDir ?? REVIEWS_DIR);
|
|
70
|
+
const jsonPath = opts.file
|
|
71
|
+
? path.isAbsolute(opts.file)
|
|
72
|
+
? opts.file
|
|
73
|
+
: path.resolve(cwd, opts.file)
|
|
74
|
+
: findLatestReviewJson(reviewsDir);
|
|
75
|
+
|
|
76
|
+
if (!jsonPath) {
|
|
77
|
+
return { exitCode: 1, message: `no review JSON found in ${reviewsDir}` };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!fs.existsSync(jsonPath)) {
|
|
81
|
+
return { exitCode: 1, message: `file not found: ${jsonPath}` };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let parsed;
|
|
85
|
+
try {
|
|
86
|
+
parsed = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
|
|
87
|
+
} catch (err) {
|
|
88
|
+
return { exitCode: 1, message: `invalid JSON: ${/** @type {Error} */ (err).message}` };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const validation = validateReport(parsed);
|
|
92
|
+
if (!validation.ok) {
|
|
93
|
+
return {
|
|
94
|
+
exitCode: 1,
|
|
95
|
+
message: `validation failed for ${jsonPath}:\n${validation.errors.map((e) => ` - ${e}`).join('\n')}`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const report = validation.report;
|
|
100
|
+
const lines = [`OK ${jsonPath}`, formatSummary(report)];
|
|
101
|
+
|
|
102
|
+
if (opts.renderMd) {
|
|
103
|
+
const mdPath = jsonPath.replace(/\.json$/, '.md');
|
|
104
|
+
fs.writeFileSync(mdPath, `${renderMarkdown(report)}\n`, 'utf8');
|
|
105
|
+
lines.push(`rendered: ${mdPath}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (opts.out) {
|
|
109
|
+
const outDir = path.resolve(cwd, opts.out);
|
|
110
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
111
|
+
const base = path.basename(jsonPath);
|
|
112
|
+
const mdBase = base.replace(/\.json$/, '.md');
|
|
113
|
+
const jsonDest = path.join(outDir, base);
|
|
114
|
+
const mdSrc = path.join(path.dirname(jsonPath), mdBase);
|
|
115
|
+
fs.copyFileSync(jsonPath, jsonDest);
|
|
116
|
+
if (fs.existsSync(mdSrc)) {
|
|
117
|
+
fs.copyFileSync(mdSrc, path.join(outDir, mdBase));
|
|
118
|
+
lines.push(`copied: ${jsonDest}, ${path.join(outDir, mdBase)}`);
|
|
119
|
+
} else {
|
|
120
|
+
lines.push(`copied: ${jsonDest} (no paired .md at ${mdSrc})`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const failLevel = opts.failOn ?? (opts.failOnCritical ? 'critical' : null);
|
|
125
|
+
if (failLevel) {
|
|
126
|
+
const openCount = countOpenAtOrAbove(report, failLevel);
|
|
127
|
+
if (openCount > 0) {
|
|
128
|
+
lines.push(`FAIL: ${openCount} open ${failLevel}+ finding(s)`);
|
|
129
|
+
return { exitCode: 1, message: lines.join('\n') };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return { exitCode: 0, message: lines.join('\n') };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function printHelp() {
|
|
137
|
+
console.log(`Usage: review export [options]
|
|
138
|
+
|
|
139
|
+
Options:
|
|
140
|
+
--file <path> Review JSON (default: latest *-review.json in .reviews/)
|
|
141
|
+
--out <dir> Copy JSON (+ paired .md if present) to directory
|
|
142
|
+
--render-md (Re)generate the paired Markdown from the JSON first
|
|
143
|
+
--fail-on <level> Exit 1 if any open finding at/above level remains
|
|
144
|
+
(critical | important | minor)
|
|
145
|
+
--reviews-dir <dir> Reviews directory (default: .reviews)
|
|
146
|
+
-h, --help Show this help
|
|
147
|
+
`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function main() {
|
|
151
|
+
try {
|
|
152
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
153
|
+
if (opts.help) {
|
|
154
|
+
printHelp();
|
|
155
|
+
process.exit(0);
|
|
156
|
+
}
|
|
157
|
+
const result = runExport(opts);
|
|
158
|
+
console.log(result.message);
|
|
159
|
+
process.exit(result.exitCode);
|
|
160
|
+
} catch (err) {
|
|
161
|
+
console.error(/** @type {Error} */ (err).message);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const isMain =
|
|
167
|
+
process.argv[1] &&
|
|
168
|
+
import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href;
|
|
169
|
+
|
|
170
|
+
if (isMain) {
|
|
171
|
+
main();
|
|
172
|
+
}
|