mustflow 2.23.0 → 2.24.2
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 +12 -2
- package/dist/cli/commands/adapters.js +11 -9
- package/dist/cli/commands/api.js +263 -113
- package/dist/cli/commands/check.js +11 -7
- package/dist/cli/commands/classify.js +16 -42
- package/dist/cli/commands/context.js +18 -31
- package/dist/cli/commands/contract-lint.js +12 -7
- package/dist/cli/commands/dashboard.js +65 -114
- package/dist/cli/commands/docs.js +43 -26
- package/dist/cli/commands/doctor.js +11 -7
- package/dist/cli/commands/evidence.js +642 -0
- package/dist/cli/commands/explain-verify.js +1 -59
- package/dist/cli/commands/explain.js +84 -36
- package/dist/cli/commands/handoff.js +13 -17
- package/dist/cli/commands/impact.js +14 -20
- package/dist/cli/commands/index.js +15 -9
- package/dist/cli/commands/init.js +56 -70
- package/dist/cli/commands/line-endings.js +15 -9
- package/dist/cli/commands/map.js +30 -42
- package/dist/cli/commands/next.js +300 -0
- package/dist/cli/commands/onboard.js +136 -0
- package/dist/cli/commands/run.js +47 -42
- package/dist/cli/commands/search.js +43 -69
- package/dist/cli/commands/status.js +9 -6
- package/dist/cli/commands/update.js +16 -10
- package/dist/cli/commands/upgrade.js +9 -6
- package/dist/cli/commands/verify/args.js +55 -249
- package/dist/cli/commands/verify.js +2 -1
- package/dist/cli/commands/version-sources.js +9 -6
- package/dist/cli/commands/version.js +9 -6
- package/dist/cli/commands/workspace.js +564 -0
- package/dist/cli/i18n/en.js +60 -1
- package/dist/cli/i18n/es.js +60 -1
- package/dist/cli/i18n/fr.js +60 -1
- package/dist/cli/i18n/hi.js +60 -1
- package/dist/cli/i18n/ko.js +60 -1
- package/dist/cli/i18n/zh.js +60 -1
- package/dist/cli/index.js +28 -25
- package/dist/cli/lib/agent-context.js +8 -9
- package/dist/cli/lib/command-registry.js +24 -0
- package/dist/cli/lib/dashboard-html/client-script.js +1 -1
- package/dist/cli/lib/local-index/database-path.js +5 -0
- package/dist/cli/lib/local-index/database-read.js +88 -0
- package/dist/cli/lib/local-index/effect-graph-read-model.js +112 -0
- package/dist/cli/lib/local-index/freshness.js +60 -0
- package/dist/cli/lib/local-index/index.js +12 -1866
- package/dist/cli/lib/local-index/path-surface-read-model.js +134 -0
- package/dist/cli/lib/local-index/populate.js +474 -0
- package/dist/cli/lib/local-index/schema.js +413 -0
- package/dist/cli/lib/local-index/search-read-model.js +533 -0
- package/dist/cli/lib/local-index/search-text.js +79 -0
- package/dist/cli/lib/option-parser.js +93 -0
- package/dist/cli/lib/repo-map.js +2 -2
- package/dist/cli/lib/run-plan.js +5 -22
- package/dist/core/change-verification.js +11 -5
- package/dist/core/command-effects.js +1 -3
- package/dist/core/command-intent-eligibility.js +14 -0
- package/dist/core/command-preconditions.js +8 -4
- package/dist/core/command-run-constraints.js +43 -0
- package/dist/core/public-json-contracts.js +57 -0
- package/dist/core/test-selection.js +8 -2
- package/dist/core/verification-plan.js +32 -4
- package/package.json +1 -1
- package/schemas/README.md +16 -0
- package/schemas/api-serve-response.schema.json +89 -0
- package/schemas/change-verification-report.schema.json +4 -1
- package/schemas/contract-lint-report.schema.json +1 -0
- package/schemas/evidence-report.schema.json +287 -0
- package/schemas/explain-report.schema.json +4 -0
- package/schemas/next-report.schema.json +121 -0
- package/schemas/onboard-commands-report.schema.json +100 -0
- package/schemas/workspace-command-catalog.schema.json +172 -0
- package/schemas/workspace-status.schema.json +141 -0
- package/schemas/workspace-verification-plan.schema.json +195 -0
- package/templates/default/manifest.toml +1 -1
|
@@ -1,264 +1,70 @@
|
|
|
1
1
|
import { availableParallelism } from 'node:os';
|
|
2
|
+
import { getParsedCliStringOption, hasParsedCliOption, parseCliOptions, } from '../../lib/option-parser.js';
|
|
2
3
|
export const DEFAULT_VERIFY_PARALLELISM = 1;
|
|
3
4
|
export const MAX_VERIFY_PARALLELISM = 8;
|
|
5
|
+
const VERIFY_OPTIONS = [
|
|
6
|
+
{ name: '--json', kind: 'boolean' },
|
|
7
|
+
{ name: '--plan-only', kind: 'boolean' },
|
|
8
|
+
{ name: '--changed', kind: 'boolean' },
|
|
9
|
+
{ name: '--reason', kind: 'string' },
|
|
10
|
+
{ name: '--parallel', kind: 'string' },
|
|
11
|
+
{ name: '--from-classification', kind: 'string' },
|
|
12
|
+
{ name: '--from-plan', kind: 'string' },
|
|
13
|
+
{ name: '--write-plan', kind: 'string' },
|
|
14
|
+
{ name: '--external-evidence', kind: 'string' },
|
|
15
|
+
{ name: '--repro-evidence', kind: 'string' },
|
|
16
|
+
];
|
|
17
|
+
const VERIFY_MISSING_VALUE_ERRORS = new Map([
|
|
18
|
+
['--parallel', 'missing_parallel_value'],
|
|
19
|
+
['--reason', 'missing_reason_value'],
|
|
20
|
+
['--from-plan', 'missing_from_plan_value'],
|
|
21
|
+
['--from-classification', 'missing_from_classification_value'],
|
|
22
|
+
['--write-plan', 'missing_write_plan_value'],
|
|
23
|
+
['--external-evidence', 'missing_external_evidence_value'],
|
|
24
|
+
['--repro-evidence', 'missing_repro_evidence_value'],
|
|
25
|
+
]);
|
|
4
26
|
export function parseVerifyArgs(args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let fromPlan;
|
|
8
|
-
let writePlan;
|
|
9
|
-
let reproEvidence;
|
|
10
|
-
let externalEvidence;
|
|
11
|
-
let json = false;
|
|
12
|
-
let planOnly = false;
|
|
13
|
-
let changed = false;
|
|
27
|
+
const parsed = parseCliOptions(args, VERIFY_OPTIONS);
|
|
28
|
+
const base = createParsedVerifyArgsBase(parsed);
|
|
14
29
|
let parallelism = DEFAULT_VERIFY_PARALLELISM;
|
|
15
30
|
let parallelismSpecified = false;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
changed = true;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (arg === '--parallel') {
|
|
31
|
-
const value = args[index + 1];
|
|
32
|
-
if (!value || value.startsWith('-')) {
|
|
33
|
-
return { json, planOnly, changed, reason, parallelism, error: 'missing_parallel_value' };
|
|
34
|
-
}
|
|
35
|
-
const parsedParallelism = parseVerifyParallelism(value);
|
|
36
|
-
if (parsedParallelism === null) {
|
|
37
|
-
return { json, planOnly, changed, reason, parallelism, error: 'invalid_parallel_value' };
|
|
38
|
-
}
|
|
39
|
-
parallelism = parsedParallelism;
|
|
40
|
-
parallelismSpecified = true;
|
|
41
|
-
index += 1;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (arg === '--reason') {
|
|
45
|
-
const value = args[index + 1];
|
|
46
|
-
if (!value || value.startsWith('-')) {
|
|
47
|
-
return { json, planOnly, changed, reason, error: 'missing_reason_value' };
|
|
48
|
-
}
|
|
49
|
-
reason = value;
|
|
50
|
-
index += 1;
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (arg === '--from-plan') {
|
|
54
|
-
const value = args[index + 1];
|
|
55
|
-
if (!value || value.startsWith('-')) {
|
|
56
|
-
return { json, planOnly, changed, reason, fromClassification, fromPlan, error: 'missing_from_plan_value' };
|
|
57
|
-
}
|
|
58
|
-
fromPlan = value;
|
|
59
|
-
index += 1;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (arg === '--from-classification') {
|
|
63
|
-
const value = args[index + 1];
|
|
64
|
-
if (!value || value.startsWith('-')) {
|
|
65
|
-
return {
|
|
66
|
-
json,
|
|
67
|
-
planOnly,
|
|
68
|
-
changed,
|
|
69
|
-
reason,
|
|
70
|
-
fromClassification,
|
|
71
|
-
fromPlan,
|
|
72
|
-
error: 'missing_from_classification_value',
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
fromClassification = value;
|
|
76
|
-
index += 1;
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (arg === '--write-plan') {
|
|
80
|
-
const value = args[index + 1];
|
|
81
|
-
if (!value || value.startsWith('-')) {
|
|
82
|
-
return {
|
|
83
|
-
json,
|
|
84
|
-
planOnly,
|
|
85
|
-
changed,
|
|
86
|
-
reason,
|
|
87
|
-
fromClassification,
|
|
88
|
-
fromPlan,
|
|
89
|
-
writePlan,
|
|
90
|
-
error: 'missing_write_plan_value',
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
writePlan = value;
|
|
94
|
-
index += 1;
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (arg === '--external-evidence') {
|
|
98
|
-
const value = args[index + 1];
|
|
99
|
-
if (!value || value.startsWith('-')) {
|
|
100
|
-
return {
|
|
101
|
-
json,
|
|
102
|
-
planOnly,
|
|
103
|
-
changed,
|
|
104
|
-
reason,
|
|
105
|
-
fromClassification,
|
|
106
|
-
fromPlan,
|
|
107
|
-
writePlan,
|
|
108
|
-
externalEvidence,
|
|
109
|
-
error: 'missing_external_evidence_value',
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
externalEvidence = value;
|
|
113
|
-
index += 1;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (arg === '--repro-evidence') {
|
|
117
|
-
const value = args[index + 1];
|
|
118
|
-
if (!value || value.startsWith('-')) {
|
|
119
|
-
return {
|
|
120
|
-
json,
|
|
121
|
-
planOnly,
|
|
122
|
-
changed,
|
|
123
|
-
reason,
|
|
124
|
-
fromClassification,
|
|
125
|
-
fromPlan,
|
|
126
|
-
writePlan,
|
|
127
|
-
reproEvidence,
|
|
128
|
-
externalEvidence,
|
|
129
|
-
error: 'missing_repro_evidence_value',
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
reproEvidence = value;
|
|
133
|
-
index += 1;
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
if (arg.startsWith('--reason=')) {
|
|
137
|
-
const value = arg.slice('--reason='.length);
|
|
138
|
-
if (value.length === 0) {
|
|
139
|
-
return { json, planOnly, changed, reason, error: 'missing_reason_value' };
|
|
140
|
-
}
|
|
141
|
-
reason = value;
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (arg.startsWith('--parallel=')) {
|
|
145
|
-
const value = arg.slice('--parallel='.length);
|
|
146
|
-
const parsedParallelism = parseVerifyParallelism(value);
|
|
147
|
-
if (parsedParallelism === null) {
|
|
148
|
-
return { json, planOnly, changed, reason, parallelism, error: 'invalid_parallel_value' };
|
|
149
|
-
}
|
|
150
|
-
parallelism = parsedParallelism;
|
|
151
|
-
parallelismSpecified = true;
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (arg.startsWith('--from-plan=')) {
|
|
155
|
-
const value = arg.slice('--from-plan='.length);
|
|
156
|
-
if (value.length === 0) {
|
|
157
|
-
return { json, planOnly, changed, reason, fromClassification, fromPlan, error: 'missing_from_plan_value' };
|
|
158
|
-
}
|
|
159
|
-
fromPlan = value;
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
if (arg.startsWith('--from-classification=')) {
|
|
163
|
-
const value = arg.slice('--from-classification='.length);
|
|
164
|
-
if (value.length === 0) {
|
|
165
|
-
return {
|
|
166
|
-
json,
|
|
167
|
-
planOnly,
|
|
168
|
-
changed,
|
|
169
|
-
reason,
|
|
170
|
-
fromClassification,
|
|
171
|
-
fromPlan,
|
|
172
|
-
error: 'missing_from_classification_value',
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
fromClassification = value;
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (arg.startsWith('--write-plan=')) {
|
|
179
|
-
const value = arg.slice('--write-plan='.length);
|
|
180
|
-
if (value.length === 0) {
|
|
181
|
-
return {
|
|
182
|
-
json,
|
|
183
|
-
planOnly,
|
|
184
|
-
changed,
|
|
185
|
-
reason,
|
|
186
|
-
fromClassification,
|
|
187
|
-
fromPlan,
|
|
188
|
-
writePlan,
|
|
189
|
-
error: 'missing_write_plan_value',
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
writePlan = value;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
if (arg.startsWith('--external-evidence=')) {
|
|
196
|
-
const value = arg.slice('--external-evidence='.length);
|
|
197
|
-
if (value.length === 0) {
|
|
198
|
-
return {
|
|
199
|
-
json,
|
|
200
|
-
planOnly,
|
|
201
|
-
changed,
|
|
202
|
-
reason,
|
|
203
|
-
fromClassification,
|
|
204
|
-
fromPlan,
|
|
205
|
-
writePlan,
|
|
206
|
-
externalEvidence,
|
|
207
|
-
error: 'missing_external_evidence_value',
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
externalEvidence = value;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
if (arg.startsWith('--repro-evidence=')) {
|
|
214
|
-
const value = arg.slice('--repro-evidence='.length);
|
|
215
|
-
if (value.length === 0) {
|
|
216
|
-
return {
|
|
217
|
-
json,
|
|
218
|
-
planOnly,
|
|
219
|
-
changed,
|
|
220
|
-
reason,
|
|
221
|
-
fromClassification,
|
|
222
|
-
fromPlan,
|
|
223
|
-
writePlan,
|
|
224
|
-
reproEvidence,
|
|
225
|
-
externalEvidence,
|
|
226
|
-
error: 'missing_repro_evidence_value',
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
reproEvidence = value;
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
if (arg.startsWith('-')) {
|
|
233
|
-
return { json, planOnly, changed, reason, fromClassification, fromPlan, writePlan, reproEvidence, externalEvidence, error: arg };
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
json,
|
|
237
|
-
planOnly,
|
|
238
|
-
changed,
|
|
239
|
-
reason,
|
|
240
|
-
fromClassification,
|
|
241
|
-
fromPlan,
|
|
242
|
-
writePlan,
|
|
243
|
-
reproEvidence,
|
|
244
|
-
externalEvidence,
|
|
245
|
-
error: `unexpected:${arg}`,
|
|
246
|
-
};
|
|
31
|
+
if (parsed.error) {
|
|
32
|
+
return { ...base, parallelism, parallelismSpecified, error: mapVerifyOptionParseError(parsed.error) };
|
|
33
|
+
}
|
|
34
|
+
const parallelValue = getParsedCliStringOption(parsed, '--parallel');
|
|
35
|
+
if (parallelValue !== null) {
|
|
36
|
+
const parsedParallelism = parseVerifyParallelism(parallelValue);
|
|
37
|
+
if (parsedParallelism === null) {
|
|
38
|
+
return { ...base, parallelism, parallelismSpecified, error: 'invalid_parallel_value' };
|
|
39
|
+
}
|
|
40
|
+
parallelism = parsedParallelism;
|
|
41
|
+
parallelismSpecified = true;
|
|
247
42
|
}
|
|
248
43
|
return {
|
|
249
|
-
|
|
250
|
-
planOnly,
|
|
251
|
-
changed,
|
|
252
|
-
reason,
|
|
253
|
-
fromClassification,
|
|
254
|
-
fromPlan,
|
|
255
|
-
writePlan,
|
|
256
|
-
reproEvidence,
|
|
257
|
-
externalEvidence,
|
|
44
|
+
...base,
|
|
258
45
|
parallelism,
|
|
259
46
|
parallelismSpecified,
|
|
260
47
|
};
|
|
261
48
|
}
|
|
49
|
+
function createParsedVerifyArgsBase(parsed) {
|
|
50
|
+
return {
|
|
51
|
+
json: hasParsedCliOption(parsed, '--json'),
|
|
52
|
+
planOnly: hasParsedCliOption(parsed, '--plan-only'),
|
|
53
|
+
changed: hasParsedCliOption(parsed, '--changed'),
|
|
54
|
+
reason: getParsedCliStringOption(parsed, '--reason') ?? undefined,
|
|
55
|
+
fromClassification: getParsedCliStringOption(parsed, '--from-classification') ?? undefined,
|
|
56
|
+
fromPlan: getParsedCliStringOption(parsed, '--from-plan') ?? undefined,
|
|
57
|
+
writePlan: getParsedCliStringOption(parsed, '--write-plan') ?? undefined,
|
|
58
|
+
reproEvidence: getParsedCliStringOption(parsed, '--repro-evidence') ?? undefined,
|
|
59
|
+
externalEvidence: getParsedCliStringOption(parsed, '--external-evidence') ?? undefined,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function mapVerifyOptionParseError(error) {
|
|
63
|
+
if (error.kind === 'missing_value') {
|
|
64
|
+
return VERIFY_MISSING_VALUE_ERRORS.get(error.option) ?? error.option;
|
|
65
|
+
}
|
|
66
|
+
return error.option.startsWith('-') ? error.option : `unexpected:${error.option}`;
|
|
67
|
+
}
|
|
262
68
|
function parseVerifyParallelism(value) {
|
|
263
69
|
if (!/^[1-9][0-9]*$/u.test(value)) {
|
|
264
70
|
return null;
|
|
@@ -22,6 +22,7 @@ import { createVerifyIntentReceiptPath, createVerifyRunStatePaths, resolveLatest
|
|
|
22
22
|
import { printUsageError, renderHelp } from '../lib/cli-output.js';
|
|
23
23
|
import { t } from '../lib/i18n.js';
|
|
24
24
|
import { readLocalCommandEffectGraphs, readLocalPathSurfaces, readLocalSourceAnchorVerdictRisks, } from '../lib/local-index.js';
|
|
25
|
+
import { hasCliOptionToken } from '../lib/option-parser.js';
|
|
25
26
|
import { resolveMustflowRoot } from '../lib/project-root.js';
|
|
26
27
|
export { planErrorMessageKey, readInputFromClassificationReport } from './verify/input.js';
|
|
27
28
|
const VERIFY_SCHEMA_VERSION = '1';
|
|
@@ -910,7 +911,7 @@ function renderVerifyOutput(output, lang) {
|
|
|
910
911
|
return lines.join('\n');
|
|
911
912
|
}
|
|
912
913
|
export async function runVerify(args, reporter, lang = 'en') {
|
|
913
|
-
if (args
|
|
914
|
+
if (hasCliOptionToken(args, '--help', ['-h'])) {
|
|
914
915
|
reporter.stdout(getVerifyHelp(lang));
|
|
915
916
|
return 0;
|
|
916
917
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { printUsageError, renderHelp } from '../lib/cli-output.js';
|
|
2
2
|
import { isRecord } from '../lib/command-contract.js';
|
|
3
3
|
import { t } from '../lib/i18n.js';
|
|
4
|
+
import { formatCliOptionParseError, hasCliOptionToken, hasParsedCliOption, parseCliOptions, } from '../lib/option-parser.js';
|
|
4
5
|
import { resolveMustflowRoot } from '../lib/project-root.js';
|
|
5
6
|
import { readMustflowTomlFile } from '../lib/toml.js';
|
|
6
7
|
import { detectVersionSources, releaseVersioningIsEnabled, } from '../../core/version-sources.js';
|
|
7
8
|
const VERSION_SOURCES_SCHEMA_VERSION = '1';
|
|
9
|
+
const VERSION_SOURCES_OPTIONS = [
|
|
10
|
+
{ name: '--json', kind: 'boolean' },
|
|
11
|
+
];
|
|
8
12
|
export function getVersionSourcesHelp(lang = 'en') {
|
|
9
13
|
return renderHelp({
|
|
10
14
|
usage: 'mf version-sources [options]',
|
|
@@ -58,18 +62,17 @@ function renderVersionSources(output, lang) {
|
|
|
58
62
|
return lines.join('\n');
|
|
59
63
|
}
|
|
60
64
|
export function runVersionSources(args, reporter, lang = 'en') {
|
|
61
|
-
if (args
|
|
65
|
+
if (hasCliOptionToken(args, '--help', ['-h'])) {
|
|
62
66
|
reporter.stdout(getVersionSourcesHelp(lang));
|
|
63
67
|
return 0;
|
|
64
68
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
printUsageError(reporter, t(lang, 'cli.error.unknownOption', { option: unsupported[0] }), 'mf version-sources --help', getVersionSourcesHelp(lang), lang);
|
|
69
|
+
const options = parseCliOptions(args, VERSION_SOURCES_OPTIONS);
|
|
70
|
+
if (options.error) {
|
|
71
|
+
printUsageError(reporter, formatCliOptionParseError(options.error, lang), 'mf version-sources --help', getVersionSourcesHelp(lang), lang);
|
|
69
72
|
return 1;
|
|
70
73
|
}
|
|
71
74
|
const output = getVersionSourcesOutput(resolveMustflowRoot());
|
|
72
|
-
if (
|
|
75
|
+
if (hasParsedCliOption(options, '--json')) {
|
|
73
76
|
reporter.stdout(JSON.stringify(output, null, 2));
|
|
74
77
|
return 0;
|
|
75
78
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { printUsageError, renderCliError, renderHelp } from '../lib/cli-output.js';
|
|
2
2
|
import { t } from '../lib/i18n.js';
|
|
3
3
|
import { checkNpmLatestVersion } from '../lib/npm-version-check.js';
|
|
4
|
+
import { formatCliOptionParseError, hasCliOptionToken, hasParsedCliOption, parseCliOptions, } from '../lib/option-parser.js';
|
|
4
5
|
import { readPackageMetadata } from '../lib/package-info.js';
|
|
6
|
+
const VERSION_OPTIONS = [
|
|
7
|
+
{ name: '--check', kind: 'boolean' },
|
|
8
|
+
];
|
|
5
9
|
export function getVersionHelp(lang = 'en') {
|
|
6
10
|
return renderHelp({
|
|
7
11
|
usage: 'mf version [options]',
|
|
@@ -30,18 +34,17 @@ function renderVersionCheck(check, lang) {
|
|
|
30
34
|
return lines.join('\n');
|
|
31
35
|
}
|
|
32
36
|
export async function runVersion(args, reporter, lang = 'en') {
|
|
33
|
-
if (args
|
|
37
|
+
if (hasCliOptionToken(args, '--help', ['-h'])) {
|
|
34
38
|
reporter.stdout(getVersionHelp(lang));
|
|
35
39
|
return 0;
|
|
36
40
|
}
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
printUsageError(reporter, t(lang, 'cli.error.unknownOption', { option: unsupported[0] }), 'mf version --help', getVersionHelp(lang), lang);
|
|
41
|
+
const options = parseCliOptions(args, VERSION_OPTIONS);
|
|
42
|
+
if (options.error) {
|
|
43
|
+
printUsageError(reporter, formatCliOptionParseError(options.error, lang), 'mf version --help', getVersionHelp(lang), lang);
|
|
41
44
|
return 1;
|
|
42
45
|
}
|
|
43
46
|
const metadata = readPackageMetadata();
|
|
44
|
-
if (!
|
|
47
|
+
if (!hasParsedCliOption(options, '--check')) {
|
|
45
48
|
reporter.stdout(metadata.version);
|
|
46
49
|
return 0;
|
|
47
50
|
}
|