wp-typia 0.20.5 → 0.22.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/README.md +5 -0
- package/bin/argv-walker.d.ts +19 -0
- package/bin/argv-walker.js +53 -0
- package/bin/routing-metadata.generated.d.ts +3 -1
- package/bin/routing-metadata.generated.js +57 -37
- package/bin/runtime-routing.d.ts +34 -0
- package/bin/runtime-routing.js +124 -0
- package/bin/wp-typia.js +97 -90
- package/dist-bunli/.bunli/commands.gen.js +5705 -1385
- package/dist-bunli/{cli-j1tyw390.js → cli-1w5vkye4.js} +989 -266
- package/dist-bunli/{cli-tesygdnr.js → cli-39er8888.js} +29 -2
- package/dist-bunli/{cli-add-6byyahb8.js → cli-add-kjhghdqq.js} +2488 -479
- package/dist-bunli/{cli-diagnostics-zecc6w1f.js → cli-diagnostics-5dvztm7q.js} +8 -2
- package/dist-bunli/{cli-doctor-2bc4sq7v.js → cli-doctor-p3jxvn0k.js} +493 -20
- package/dist-bunli/{cli-2rev5hqm.js → cli-e623rs7g.js} +1 -1
- package/dist-bunli/cli-init-djhwr245.js +844 -0
- package/dist-bunli/{cli-3w3qxq9w.js → cli-j180bk07.js} +260 -25
- package/dist-bunli/{cli-xnh2s5kz.js → cli-ktp869eh.js} +350 -41
- package/dist-bunli/{cli-xxzpb58s.js → cli-p95wr1q8.js} +72 -4
- package/dist-bunli/{cli-scaffold-19gyvxxt.js → cli-scaffold-376yw891.js} +6 -5
- package/dist-bunli/cli.js +31 -117
- package/dist-bunli/{command-list-pztcgga5.js → command-list-jt1a1w7r.js} +587 -320
- package/dist-bunli/{migrations-1p6mbkyw.js → migrations-nwas5bwt.js} +2 -2
- package/dist-bunli/node-cli.js +1063 -556
- package/package.json +5 -3
- package/dist-bunli/cli-init-gdyp9enw.js +0 -341
|
@@ -3,13 +3,15 @@ import {
|
|
|
3
3
|
exports_external
|
|
4
4
|
} from "./cli-hv2yedw2.js";
|
|
5
5
|
import {
|
|
6
|
+
CLI_DIAGNOSTIC_CODES,
|
|
6
7
|
createCliCommandError,
|
|
8
|
+
createCliDiagnosticCodeError,
|
|
7
9
|
serializeCliDiagnosticError
|
|
8
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-p95wr1q8.js";
|
|
9
11
|
// package.json
|
|
10
12
|
var package_default = {
|
|
11
13
|
name: "wp-typia",
|
|
12
|
-
version: "0.
|
|
14
|
+
version: "0.22.0",
|
|
13
15
|
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
14
16
|
packageManager: "bun@1.3.11",
|
|
15
17
|
type: "module",
|
|
@@ -23,7 +25,9 @@ var package_default = {
|
|
|
23
25
|
"package.json"
|
|
24
26
|
],
|
|
25
27
|
scripts: {
|
|
26
|
-
generate: "
|
|
28
|
+
"generate:routing": "node scripts/generate-routing-metadata.mjs",
|
|
29
|
+
"validate:routing": "node scripts/generate-routing-metadata.mjs --check",
|
|
30
|
+
generate: "node scripts/generate-routing-metadata.mjs && bun scripts/generate-bunli-metadata.ts",
|
|
27
31
|
build: "bun run generate && bun scripts/build-bunli-runtime.ts",
|
|
28
32
|
"build:standalone": "bun scripts/build-standalone-runtime.ts --targets native --outdir ./dist-standalone",
|
|
29
33
|
"build:standalone:release": "bun scripts/build-standalone-runtime.ts --targets darwin-arm64,darwin-x64,linux-arm64,linux-x64,windows-x64 --outdir ./.cache/standalone/raw",
|
|
@@ -77,7 +81,7 @@ var package_default = {
|
|
|
77
81
|
"@bunli/tui": "0.6.0",
|
|
78
82
|
"@bunli/utils": "0.6.0",
|
|
79
83
|
"@wp-typia/api-client": "^0.4.5",
|
|
80
|
-
"@wp-typia/project-tools": "0.
|
|
84
|
+
"@wp-typia/project-tools": "0.22.0",
|
|
81
85
|
"better-result": "^2.7.0",
|
|
82
86
|
react: "^19.2.5",
|
|
83
87
|
"react-dom": "^19.2.5",
|
|
@@ -196,8 +200,12 @@ var ADD_OPTION_METADATA = {
|
|
|
196
200
|
description: "Anchor block name for hooked-block workflows.",
|
|
197
201
|
type: "string"
|
|
198
202
|
},
|
|
203
|
+
attribute: {
|
|
204
|
+
description: "Target block attribute for end-to-end binding-source workflows.",
|
|
205
|
+
type: "string"
|
|
206
|
+
},
|
|
199
207
|
block: {
|
|
200
|
-
description: "Target block slug for variation workflows.",
|
|
208
|
+
description: "Target block slug for variation, style, and end-to-end binding-source workflows.",
|
|
201
209
|
type: "string"
|
|
202
210
|
},
|
|
203
211
|
"data-storage": {
|
|
@@ -217,6 +225,10 @@ var ADD_OPTION_METADATA = {
|
|
|
217
225
|
description: "Local path, GitHub locator, or npm package that exposes wp-typia.layers.json for built-in block templates.",
|
|
218
226
|
type: "string"
|
|
219
227
|
},
|
|
228
|
+
from: {
|
|
229
|
+
description: "Source full block name (namespace/block) for transform workflows.",
|
|
230
|
+
type: "string"
|
|
231
|
+
},
|
|
220
232
|
"inner-blocks-preset": {
|
|
221
233
|
description: "Compound-only InnerBlocks preset (freeform, ordered, horizontal, locked-structure).",
|
|
222
234
|
type: "string"
|
|
@@ -238,11 +250,31 @@ var ADD_OPTION_METADATA = {
|
|
|
238
250
|
type: "string"
|
|
239
251
|
},
|
|
240
252
|
slot: {
|
|
241
|
-
description: "Document editor shell slot for editor-plugin workflows.",
|
|
253
|
+
description: "Document editor shell slot for editor-plugin workflows (sidebar or document-setting-panel).",
|
|
254
|
+
type: "string"
|
|
255
|
+
},
|
|
256
|
+
source: {
|
|
257
|
+
description: "Optional data source locator for admin-view workflows, such as rest-resource:products or core-data:postType/post.",
|
|
242
258
|
type: "string"
|
|
243
259
|
},
|
|
244
260
|
template: {
|
|
245
|
-
description: "
|
|
261
|
+
description: "Optional built-in block family for the new block; interactive flows let you choose it when omitted and non-interactive runs default to basic.",
|
|
262
|
+
type: "string"
|
|
263
|
+
},
|
|
264
|
+
to: {
|
|
265
|
+
description: "Target workspace block slug or full block name for transform workflows.",
|
|
266
|
+
type: "string"
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
var INIT_OPTION_METADATA = {
|
|
270
|
+
apply: {
|
|
271
|
+
argumentKind: "flag",
|
|
272
|
+
description: "Write the planned package.json updates and retrofit helper files instead of previewing only.",
|
|
273
|
+
type: "boolean"
|
|
274
|
+
},
|
|
275
|
+
"package-manager": {
|
|
276
|
+
description: "Package manager to use for emitted scripts and next steps.",
|
|
277
|
+
short: "p",
|
|
246
278
|
type: "string"
|
|
247
279
|
}
|
|
248
280
|
};
|
|
@@ -294,6 +326,12 @@ var SYNC_OPTION_METADATA = {
|
|
|
294
326
|
type: "boolean"
|
|
295
327
|
}
|
|
296
328
|
};
|
|
329
|
+
var DOCTOR_OPTION_METADATA = {
|
|
330
|
+
format: {
|
|
331
|
+
description: "Use `json` for machine-readable doctor check output.",
|
|
332
|
+
type: "string"
|
|
333
|
+
}
|
|
334
|
+
};
|
|
297
335
|
var TEMPLATES_OPTION_METADATA = {
|
|
298
336
|
id: {
|
|
299
337
|
description: "Template id for `templates inspect`.",
|
|
@@ -319,6 +357,30 @@ var GLOBAL_OPTION_METADATA = {
|
|
|
319
357
|
type: "string"
|
|
320
358
|
}
|
|
321
359
|
};
|
|
360
|
+
var COMMAND_OPTION_METADATA_BY_GROUP = {
|
|
361
|
+
add: ADD_OPTION_METADATA,
|
|
362
|
+
create: CREATE_OPTION_METADATA,
|
|
363
|
+
doctor: DOCTOR_OPTION_METADATA,
|
|
364
|
+
global: GLOBAL_OPTION_METADATA,
|
|
365
|
+
init: INIT_OPTION_METADATA,
|
|
366
|
+
migrate: MIGRATE_OPTION_METADATA,
|
|
367
|
+
sync: SYNC_OPTION_METADATA,
|
|
368
|
+
templates: TEMPLATES_OPTION_METADATA
|
|
369
|
+
};
|
|
370
|
+
var COMMAND_OPTION_GROUP_NAMES = Object.keys(COMMAND_OPTION_METADATA_BY_GROUP);
|
|
371
|
+
function collectCommandOptionMetadata(...groupNames) {
|
|
372
|
+
const metadata = {};
|
|
373
|
+
for (const groupName of groupNames) {
|
|
374
|
+
for (const [optionName, option] of Object.entries(COMMAND_OPTION_METADATA_BY_GROUP[groupName])) {
|
|
375
|
+
metadata[optionName] = {
|
|
376
|
+
...metadata[optionName] ?? {},
|
|
377
|
+
...option
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return metadata;
|
|
382
|
+
}
|
|
383
|
+
var ALL_COMMAND_OPTION_METADATA = collectCommandOptionMetadata(...COMMAND_OPTION_GROUP_NAMES);
|
|
322
384
|
function buildCommandOptions(metadata) {
|
|
323
385
|
return Object.fromEntries(Object.entries(metadata).map(([name, option]) => [
|
|
324
386
|
name,
|
|
@@ -334,13 +396,99 @@ function collectOptionNamesByType(metadata, type) {
|
|
|
334
396
|
return Object.entries(metadata).filter(([, option]) => option.type === type).map(([name]) => name);
|
|
335
397
|
}
|
|
336
398
|
function buildCommandOptionParser(...metadataMaps) {
|
|
337
|
-
const metadata =
|
|
399
|
+
const metadata = {};
|
|
400
|
+
for (const metadataMap of metadataMaps) {
|
|
401
|
+
for (const [optionName, option] of Object.entries(metadataMap)) {
|
|
402
|
+
metadata[optionName] = {
|
|
403
|
+
...metadata[optionName] ?? {},
|
|
404
|
+
...option
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
338
408
|
return {
|
|
339
409
|
booleanOptionNames: new Set(collectOptionNamesByType(metadata, "boolean")),
|
|
340
410
|
shortFlagMap: new Map(Object.entries(metadata).flatMap(([name, option]) => option.short ? [[option.short, { name, type: option.type }]] : [])),
|
|
341
411
|
stringOptionNames: new Set(collectOptionNamesByType(metadata, "string"))
|
|
342
412
|
};
|
|
343
413
|
}
|
|
414
|
+
function buildArgvWalkerRoutingMetadata(...metadataMaps) {
|
|
415
|
+
const parser = buildCommandOptionParser(...metadataMaps);
|
|
416
|
+
return {
|
|
417
|
+
longValueOptions: Array.from(parser.stringOptionNames).map((optionName) => `--${optionName}`).sort((left, right) => left.localeCompare(right)),
|
|
418
|
+
shortValueOptions: Array.from(parser.shortFlagMap.entries()).filter(([, option]) => option.type === "string").map(([short]) => `-${short}`).sort((left, right) => left.localeCompare(right))
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
var COMMAND_ROUTING_METADATA = buildArgvWalkerRoutingMetadata(ALL_COMMAND_OPTION_METADATA);
|
|
422
|
+
function extractKnownOptionValuesFromArgv(argv, options) {
|
|
423
|
+
const flags = {};
|
|
424
|
+
const nextArgv = [];
|
|
425
|
+
const optionNames = new Set(options.optionNames);
|
|
426
|
+
for (let index = 0;index < argv.length; index += 1) {
|
|
427
|
+
const arg = argv[index];
|
|
428
|
+
if (!arg) {
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (arg === "--") {
|
|
432
|
+
nextArgv.push(...argv.slice(index));
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
if (arg.length === 2 && arg.startsWith("-")) {
|
|
436
|
+
const shortFlag = options.parser.shortFlagMap.get(arg.slice(1));
|
|
437
|
+
if (!shortFlag || !optionNames.has(shortFlag.name)) {
|
|
438
|
+
nextArgv.push(arg);
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (shortFlag.type === "boolean") {
|
|
442
|
+
flags[shortFlag.name] = true;
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
const next = argv[index + 1];
|
|
446
|
+
if (!next || next.startsWith("-")) {
|
|
447
|
+
throw new Error(`\`${arg}\` requires a value.`);
|
|
448
|
+
}
|
|
449
|
+
flags[shortFlag.name] = next;
|
|
450
|
+
index += 1;
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (arg.startsWith("--")) {
|
|
454
|
+
const option = arg.slice(2);
|
|
455
|
+
const separatorIndex = option.indexOf("=");
|
|
456
|
+
const rawName = separatorIndex === -1 ? option : option.slice(0, separatorIndex);
|
|
457
|
+
const inlineValue = separatorIndex === -1 ? undefined : option.slice(separatorIndex + 1);
|
|
458
|
+
if (!optionNames.has(rawName)) {
|
|
459
|
+
nextArgv.push(arg);
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
if (options.parser.booleanOptionNames.has(rawName)) {
|
|
463
|
+
flags[rawName] = true;
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (!options.parser.stringOptionNames.has(rawName)) {
|
|
467
|
+
nextArgv.push(arg);
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (inlineValue !== undefined) {
|
|
471
|
+
if (!inlineValue) {
|
|
472
|
+
throw new Error(`\`--${rawName}\` requires a value.`);
|
|
473
|
+
}
|
|
474
|
+
flags[rawName] = inlineValue;
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
const next = argv[index + 1];
|
|
478
|
+
if (!next || next.startsWith("-")) {
|
|
479
|
+
throw new Error(`\`--${rawName}\` requires a value.`);
|
|
480
|
+
}
|
|
481
|
+
flags[rawName] = next;
|
|
482
|
+
index += 1;
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
nextArgv.push(arg);
|
|
486
|
+
}
|
|
487
|
+
return {
|
|
488
|
+
argv: nextArgv,
|
|
489
|
+
flags
|
|
490
|
+
};
|
|
491
|
+
}
|
|
344
492
|
function resolveCommandOptionValues(metadata, options) {
|
|
345
493
|
const resolved = {};
|
|
346
494
|
const optionNames = options.optionNames ?? Object.keys(metadata);
|
|
@@ -360,47 +508,54 @@ function resolveCommandOptionValues(metadata, options) {
|
|
|
360
508
|
return resolved;
|
|
361
509
|
}
|
|
362
510
|
|
|
363
|
-
//
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
};
|
|
372
|
-
var CLI_STRING_OPTION_NAMES = new Set(Object.entries(ALL_OPTION_METADATA).flatMap(([name, option]) => option.type === "string" ? [
|
|
373
|
-
`--${name}`,
|
|
374
|
-
..."short" in option && option.short ? [`-${option.short}`] : []
|
|
375
|
-
] : []));
|
|
376
|
-
function resolveEntrypointCliCommand(argv) {
|
|
511
|
+
// bin/argv-walker.js
|
|
512
|
+
function normalizeOptionSet(values) {
|
|
513
|
+
return values instanceof Set ? values : new Set(values);
|
|
514
|
+
}
|
|
515
|
+
function collectPositionalIndexes(argv, metadata) {
|
|
516
|
+
const longValueOptionSet = normalizeOptionSet(metadata.longValueOptions);
|
|
517
|
+
const shortValueOptionSet = normalizeOptionSet(metadata.shortValueOptions);
|
|
518
|
+
const positionalIndexes = [];
|
|
377
519
|
for (let index = 0;index < argv.length; index += 1) {
|
|
378
520
|
const arg = argv[index];
|
|
379
|
-
if (!arg) {
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
521
|
if (arg === "--") {
|
|
522
|
+
for (let restIndex = index + 1;restIndex < argv.length; restIndex += 1) {
|
|
523
|
+
positionalIndexes.push(restIndex);
|
|
524
|
+
}
|
|
383
525
|
break;
|
|
384
526
|
}
|
|
385
|
-
if (
|
|
386
|
-
|
|
387
|
-
if (next && !next.startsWith("-")) {
|
|
388
|
-
index += 1;
|
|
389
|
-
}
|
|
527
|
+
if (!arg.startsWith("-") || arg === "-") {
|
|
528
|
+
positionalIndexes.push(index);
|
|
390
529
|
continue;
|
|
391
530
|
}
|
|
392
531
|
if (arg.startsWith("--")) {
|
|
393
|
-
|
|
394
|
-
if (inlineName && CLI_STRING_OPTION_NAMES.has(inlineName)) {
|
|
532
|
+
if (arg.includes("=")) {
|
|
395
533
|
continue;
|
|
396
534
|
}
|
|
397
|
-
|
|
398
|
-
|
|
535
|
+
const next = argv[index + 1];
|
|
536
|
+
if (longValueOptionSet.has(arg) && next && !next.startsWith("-")) {
|
|
537
|
+
index += 1;
|
|
538
|
+
}
|
|
399
539
|
continue;
|
|
400
540
|
}
|
|
401
|
-
|
|
541
|
+
if (arg.length === 2 && shortValueOptionSet.has(arg) && argv[index + 1] && !argv[index + 1].startsWith("-")) {
|
|
542
|
+
index += 1;
|
|
543
|
+
}
|
|
402
544
|
}
|
|
403
|
-
return
|
|
545
|
+
return positionalIndexes;
|
|
546
|
+
}
|
|
547
|
+
function findFirstPositionalIndex(argv, metadata) {
|
|
548
|
+
const positionalIndexes = collectPositionalIndexes(argv, metadata);
|
|
549
|
+
return positionalIndexes[0] ?? -1;
|
|
550
|
+
}
|
|
551
|
+
function findFirstPositional(argv, metadata) {
|
|
552
|
+
const firstPositionalIndex = findFirstPositionalIndex(argv, metadata);
|
|
553
|
+
return firstPositionalIndex === -1 ? undefined : argv[firstPositionalIndex];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// src/cli-diagnostic-output.ts
|
|
557
|
+
function resolveEntrypointCliCommand(argv) {
|
|
558
|
+
return findFirstPositional(argv, COMMAND_ROUTING_METADATA) ?? "wp-typia";
|
|
404
559
|
}
|
|
405
560
|
function prefersStructuredCliArgv(argv) {
|
|
406
561
|
for (let index = 0;index < argv.length; index += 1) {
|
|
@@ -451,6 +606,154 @@ function writeStructuredCliDiagnosticError(argv, error) {
|
|
|
451
606
|
return true;
|
|
452
607
|
}
|
|
453
608
|
|
|
609
|
+
// src/command-registry.ts
|
|
610
|
+
var WP_TYPIA_CANONICAL_CREATE_USAGE = "wp-typia create <project-dir>";
|
|
611
|
+
var WP_TYPIA_COMMAND_REGISTRY = [
|
|
612
|
+
{
|
|
613
|
+
commandTree: true,
|
|
614
|
+
description: "Scaffold a new wp-typia project.",
|
|
615
|
+
interactiveRuntime: true,
|
|
616
|
+
name: "create",
|
|
617
|
+
nodeFallback: true,
|
|
618
|
+
optionGroups: ["create"],
|
|
619
|
+
requiresBunRuntime: false
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
commandTree: true,
|
|
623
|
+
description: "Preview or apply the minimum retrofit plan for an existing project.",
|
|
624
|
+
name: "init",
|
|
625
|
+
nodeFallback: true,
|
|
626
|
+
optionGroups: ["init"],
|
|
627
|
+
requiresBunRuntime: false
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
commandTree: true,
|
|
631
|
+
description: "Run the common generated-project sync workflow.",
|
|
632
|
+
name: "sync",
|
|
633
|
+
nodeFallback: true,
|
|
634
|
+
optionGroups: ["sync"],
|
|
635
|
+
requiresBunRuntime: false,
|
|
636
|
+
subcommands: ["ai"]
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
commandTree: true,
|
|
640
|
+
description: "Extend an official wp-typia workspace.",
|
|
641
|
+
interactiveRuntime: true,
|
|
642
|
+
name: "add",
|
|
643
|
+
nodeFallback: true,
|
|
644
|
+
optionGroups: ["add"],
|
|
645
|
+
requiresBunRuntime: false,
|
|
646
|
+
subcommands: [
|
|
647
|
+
"block",
|
|
648
|
+
"variation",
|
|
649
|
+
"style",
|
|
650
|
+
"transform",
|
|
651
|
+
"pattern",
|
|
652
|
+
"binding-source",
|
|
653
|
+
"rest-resource",
|
|
654
|
+
"editor-plugin",
|
|
655
|
+
"hooked-block"
|
|
656
|
+
]
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
commandTree: true,
|
|
660
|
+
description: "Run migration workflows.",
|
|
661
|
+
interactiveRuntime: true,
|
|
662
|
+
name: "migrate",
|
|
663
|
+
nodeFallback: true,
|
|
664
|
+
optionGroups: ["migrate"],
|
|
665
|
+
requiresBunRuntime: false,
|
|
666
|
+
subcommands: [
|
|
667
|
+
"init",
|
|
668
|
+
"snapshot",
|
|
669
|
+
"diff",
|
|
670
|
+
"scaffold",
|
|
671
|
+
"plan",
|
|
672
|
+
"wizard",
|
|
673
|
+
"verify",
|
|
674
|
+
"doctor",
|
|
675
|
+
"fixtures",
|
|
676
|
+
"fuzz"
|
|
677
|
+
]
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
commandTree: true,
|
|
681
|
+
description: "Inspect scaffold templates.",
|
|
682
|
+
name: "templates",
|
|
683
|
+
nodeFallback: true,
|
|
684
|
+
optionGroups: ["templates"],
|
|
685
|
+
requiresBunRuntime: false,
|
|
686
|
+
subcommands: ["list", "inspect"]
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
commandTree: true,
|
|
690
|
+
description: "Run repository and project diagnostics.",
|
|
691
|
+
name: "doctor",
|
|
692
|
+
nodeFallback: true,
|
|
693
|
+
optionGroups: ["doctor"],
|
|
694
|
+
requiresBunRuntime: false
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
commandTree: true,
|
|
698
|
+
description: "Inspect or sync schema-driven MCP metadata.",
|
|
699
|
+
name: "mcp",
|
|
700
|
+
nodeFallback: false,
|
|
701
|
+
optionGroups: [],
|
|
702
|
+
requiresBunRuntime: true,
|
|
703
|
+
subcommands: ["list", "sync"]
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
commandTree: false,
|
|
707
|
+
name: "help",
|
|
708
|
+
nodeFallback: true,
|
|
709
|
+
optionGroups: [],
|
|
710
|
+
requiresBunRuntime: false
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
commandTree: false,
|
|
714
|
+
name: "version",
|
|
715
|
+
nodeFallback: true,
|
|
716
|
+
optionGroups: [],
|
|
717
|
+
requiresBunRuntime: false
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
commandTree: false,
|
|
721
|
+
name: "skills",
|
|
722
|
+
nodeFallback: false,
|
|
723
|
+
optionGroups: [],
|
|
724
|
+
requiresBunRuntime: true
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
commandTree: false,
|
|
728
|
+
name: "completions",
|
|
729
|
+
nodeFallback: false,
|
|
730
|
+
optionGroups: [],
|
|
731
|
+
requiresBunRuntime: true
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
commandTree: false,
|
|
735
|
+
name: "complete",
|
|
736
|
+
nodeFallback: false,
|
|
737
|
+
optionGroups: [],
|
|
738
|
+
requiresBunRuntime: true
|
|
739
|
+
}
|
|
740
|
+
];
|
|
741
|
+
var WP_TYPIA_RESERVED_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.map((command) => command.name);
|
|
742
|
+
var WP_TYPIA_NODE_FALLBACK_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.filter((command) => command.nodeFallback).map((command) => command.name);
|
|
743
|
+
var WP_TYPIA_INTERACTIVE_RUNTIME_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.filter((command) => ("interactiveRuntime" in command) && command.interactiveRuntime).map((command) => command.name);
|
|
744
|
+
var WP_TYPIA_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.filter((command) => command.commandTree).map((command) => command.name);
|
|
745
|
+
var WP_TYPIA_BUN_REQUIRED_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.filter((command) => command.requiresBunRuntime).map((command) => command.name);
|
|
746
|
+
var WP_TYPIA_FUTURE_COMMAND_TREE = WP_TYPIA_COMMAND_REGISTRY.filter((command) => command.commandTree).map((command) => ({
|
|
747
|
+
description: command.description,
|
|
748
|
+
name: command.name,
|
|
749
|
+
subcommands: "subcommands" in command ? command.subcommands : undefined
|
|
750
|
+
}));
|
|
751
|
+
var commandOptionGroupNamesByTopLevelCommand = {};
|
|
752
|
+
for (const command of WP_TYPIA_COMMAND_REGISTRY) {
|
|
753
|
+
commandOptionGroupNamesByTopLevelCommand[command.name] = command.optionGroups;
|
|
754
|
+
}
|
|
755
|
+
var WP_TYPIA_COMMAND_OPTION_GROUP_NAMES_BY_TOP_LEVEL_COMMAND = commandOptionGroupNamesByTopLevelCommand;
|
|
756
|
+
|
|
454
757
|
// src/config.ts
|
|
455
758
|
import fs from "fs/promises";
|
|
456
759
|
import os from "os";
|
|
@@ -477,16 +780,22 @@ function deepMerge(base, incoming) {
|
|
|
477
780
|
return merged;
|
|
478
781
|
}
|
|
479
782
|
async function readJsonFile(filePath) {
|
|
783
|
+
let source;
|
|
480
784
|
try {
|
|
481
|
-
|
|
482
|
-
const parsed = JSON.parse(source);
|
|
483
|
-
return isRecord(parsed) ? parsed : null;
|
|
785
|
+
source = await fs.readFile(filePath, "utf8");
|
|
484
786
|
} catch (error) {
|
|
485
787
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
486
788
|
return null;
|
|
487
789
|
}
|
|
488
790
|
throw error;
|
|
489
791
|
}
|
|
792
|
+
try {
|
|
793
|
+
const parsed = JSON.parse(source);
|
|
794
|
+
return isRecord(parsed) ? parsed : null;
|
|
795
|
+
} catch (error) {
|
|
796
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
797
|
+
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Unable to parse ${filePath}: ${message}`, error instanceof Error ? { cause: error } : undefined);
|
|
798
|
+
}
|
|
490
799
|
}
|
|
491
800
|
function resolveConfigPath(cwd, source) {
|
|
492
801
|
if (source.startsWith("~/")) {
|
|
@@ -530,6 +839,6 @@ function getMcpSchemaSources(config) {
|
|
|
530
839
|
function createPlugin(input) {
|
|
531
840
|
return input;
|
|
532
841
|
}
|
|
533
|
-
export { createPlugin, package_default, CREATE_OPTION_METADATA, ADD_OPTION_METADATA, MIGRATE_OPTION_METADATA, SYNC_OPTION_METADATA, TEMPLATES_OPTION_METADATA, GLOBAL_OPTION_METADATA, buildCommandOptions, collectOptionNamesByType, buildCommandOptionParser, resolveCommandOptionValues, prefersStructuredCliOutput, emitCliDiagnosticFailure, writeStructuredCliDiagnosticError, WP_TYPIA_CONFIG_SOURCES, mergeWpTypiaUserConfig, loadWpTypiaUserConfigFromSource, loadWpTypiaUserConfig, getCreateDefaults, getAddBlockDefaults, getMcpSchemaSources };
|
|
842
|
+
export { createPlugin, package_default, CREATE_OPTION_METADATA, ADD_OPTION_METADATA, INIT_OPTION_METADATA, MIGRATE_OPTION_METADATA, SYNC_OPTION_METADATA, DOCTOR_OPTION_METADATA, TEMPLATES_OPTION_METADATA, GLOBAL_OPTION_METADATA, COMMAND_OPTION_METADATA_BY_GROUP, ALL_COMMAND_OPTION_METADATA, buildCommandOptions, collectOptionNamesByType, buildCommandOptionParser, COMMAND_ROUTING_METADATA, extractKnownOptionValuesFromArgv, resolveCommandOptionValues, collectPositionalIndexes, findFirstPositionalIndex, prefersStructuredCliOutput, emitCliDiagnosticFailure, writeStructuredCliDiagnosticError, WP_TYPIA_CANONICAL_CREATE_USAGE, WP_TYPIA_RESERVED_TOP_LEVEL_COMMAND_NAMES, WP_TYPIA_TOP_LEVEL_COMMAND_NAMES, WP_TYPIA_COMMAND_OPTION_GROUP_NAMES_BY_TOP_LEVEL_COMMAND, WP_TYPIA_CONFIG_SOURCES, mergeWpTypiaUserConfig, loadWpTypiaUserConfigFromSource, loadWpTypiaUserConfig, getCreateDefaults, getAddBlockDefaults, getMcpSchemaSources };
|
|
534
843
|
|
|
535
|
-
//# debugId=
|
|
844
|
+
//# debugId=A6461030E7B0624164756E2164756E21
|
|
@@ -15,6 +15,60 @@ var CLI_DIAGNOSTIC_CODES = {
|
|
|
15
15
|
UNKNOWN_TEMPLATE: "unknown-template",
|
|
16
16
|
UNSUPPORTED_COMMAND: "unsupported-command"
|
|
17
17
|
};
|
|
18
|
+
var CLI_DIAGNOSTIC_CODE_METADATA = {
|
|
19
|
+
[CLI_DIAGNOSTIC_CODES.COMMAND_EXECUTION]: {
|
|
20
|
+
cause: "The command failed after argument parsing and preflight checks completed.",
|
|
21
|
+
recovery: "Read the detail lines for the underlying tool failure, rerun with the same command once corrected, and report the full JSON envelope if the recovery is unclear."
|
|
22
|
+
},
|
|
23
|
+
[CLI_DIAGNOSTIC_CODES.CONFIGURATION_MISSING]: {
|
|
24
|
+
cause: "A command needs configuration that is not present in the current project.",
|
|
25
|
+
recovery: "Add the missing wp-typia config section or rerun the scaffold/init flow that creates the expected configuration."
|
|
26
|
+
},
|
|
27
|
+
[CLI_DIAGNOSTIC_CODES.DEPENDENCIES_NOT_INSTALLED]: {
|
|
28
|
+
cause: "Generated project or workspace dependencies are missing from the local install.",
|
|
29
|
+
recovery: "Run the package-manager install command from the reported project root, then rerun the wp-typia command."
|
|
30
|
+
},
|
|
31
|
+
[CLI_DIAGNOSTIC_CODES.DOCTOR_CHECK_FAILED]: {
|
|
32
|
+
cause: "One or more doctor checks reported a failing environment or workspace row.",
|
|
33
|
+
recovery: "Inspect the failed check labels and details, fix the reported drift or missing prerequisite, then rerun `wp-typia doctor`."
|
|
34
|
+
},
|
|
35
|
+
[CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT]: {
|
|
36
|
+
cause: "An argument was present but did not match the supported value, shape, or project state.",
|
|
37
|
+
recovery: "Correct the argument value using command help or the detail lines, then rerun the command."
|
|
38
|
+
},
|
|
39
|
+
[CLI_DIAGNOSTIC_CODES.INVALID_COMMAND]: {
|
|
40
|
+
cause: "The command or subcommand is not part of the supported wp-typia command tree.",
|
|
41
|
+
recovery: "Run `wp-typia --help` or the relevant command help and switch to a supported command/subcommand."
|
|
42
|
+
},
|
|
43
|
+
[CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT]: {
|
|
44
|
+
cause: "A required positional argument or flag value was omitted.",
|
|
45
|
+
recovery: "Provide the missing argument or flag value shown in the detail lines, then rerun the command."
|
|
46
|
+
},
|
|
47
|
+
[CLI_DIAGNOSTIC_CODES.MISSING_BUILD_ARTIFACT]: {
|
|
48
|
+
cause: "The published or standalone CLI layout is missing bundled build artifacts.",
|
|
49
|
+
recovery: "Reinstall the package or standalone binary, or rebuild the workspace before invoking the command again."
|
|
50
|
+
},
|
|
51
|
+
[CLI_DIAGNOSTIC_CODES.OUTSIDE_PROJECT_ROOT]: {
|
|
52
|
+
cause: "The command was run outside a generated wp-typia project or official workspace root.",
|
|
53
|
+
recovery: "Change into the scaffolded project/workspace root, or rerun the scaffold/init workflow that creates the expected root files."
|
|
54
|
+
},
|
|
55
|
+
[CLI_DIAGNOSTIC_CODES.TEMPLATE_SOURCE_TIMEOUT]: {
|
|
56
|
+
cause: "External template resolution did not complete within the allowed time.",
|
|
57
|
+
recovery: "Retry with a reachable template source, use a local path, or cache the template package before rerunning."
|
|
58
|
+
},
|
|
59
|
+
[CLI_DIAGNOSTIC_CODES.TEMPLATE_SOURCE_TOO_LARGE]: {
|
|
60
|
+
cause: "External template content exceeded the safety size limit.",
|
|
61
|
+
recovery: "Reduce the template package size or point wp-typia at a smaller official template layer."
|
|
62
|
+
},
|
|
63
|
+
[CLI_DIAGNOSTIC_CODES.UNKNOWN_TEMPLATE]: {
|
|
64
|
+
cause: "The requested scaffold template or add-block template id is not registered.",
|
|
65
|
+
recovery: "Run `wp-typia templates list` and rerun with one of the listed template ids."
|
|
66
|
+
},
|
|
67
|
+
[CLI_DIAGNOSTIC_CODES.UNSUPPORTED_COMMAND]: {
|
|
68
|
+
cause: "The requested command exists conceptually but is not supported by the current runtime surface.",
|
|
69
|
+
recovery: "Install Bun 1.3.11+ or use the standalone wp-typia binary when the detail lines say the Bun-powered runtime is required."
|
|
70
|
+
}
|
|
71
|
+
};
|
|
18
72
|
var DEFAULT_CLI_FAILURE_SUMMARIES = {
|
|
19
73
|
add: "Unable to complete the requested add workflow.",
|
|
20
74
|
create: "Unable to complete the requested create workflow.",
|
|
@@ -148,6 +202,14 @@ function readCliDiagnosticCode(error) {
|
|
|
148
202
|
}
|
|
149
203
|
return null;
|
|
150
204
|
}
|
|
205
|
+
function getCliDiagnosticCodeMetadata(code) {
|
|
206
|
+
return CLI_DIAGNOSTIC_CODE_METADATA[code];
|
|
207
|
+
}
|
|
208
|
+
function createCliDiagnosticCodeError(code, message, options) {
|
|
209
|
+
const error = new Error(message, options);
|
|
210
|
+
error.code = code;
|
|
211
|
+
return error;
|
|
212
|
+
}
|
|
151
213
|
function inferCliDiagnosticCode(options) {
|
|
152
214
|
const inheritedCode = readCliDiagnosticCode(options.error);
|
|
153
215
|
if (inheritedCode) {
|
|
@@ -253,7 +315,8 @@ function serializeCliDiagnosticError(error) {
|
|
|
253
315
|
};
|
|
254
316
|
}
|
|
255
317
|
function formatDoctorCheckLine(check) {
|
|
256
|
-
|
|
318
|
+
const statusLabel = check.status === "pass" ? "PASS" : check.status === "warn" ? "WARN" : "FAIL";
|
|
319
|
+
return formatWrappedPrefixedLine(`${statusLabel} ${check.label}: `, check.detail, resolveCliWrapColumns(process.stdout.columns)).join(`
|
|
257
320
|
`);
|
|
258
321
|
}
|
|
259
322
|
function getFailingDoctorChecks(checks) {
|
|
@@ -261,13 +324,18 @@ function getFailingDoctorChecks(checks) {
|
|
|
261
324
|
}
|
|
262
325
|
function formatDoctorSummaryLine(checks) {
|
|
263
326
|
const failedChecks = getFailingDoctorChecks(checks);
|
|
264
|
-
|
|
327
|
+
const warningCount = checks.filter((check) => check.status === "warn").length;
|
|
328
|
+
const summaryStatus = failedChecks.length > 0 ? "FAIL" : warningCount > 0 ? "WARN" : "PASS";
|
|
329
|
+
return formatWrappedPrefixedLine(`${summaryStatus} wp-typia doctor summary: `, [
|
|
330
|
+
`${checks.length - failedChecks.length - warningCount}/${checks.length} checks passed`,
|
|
331
|
+
warningCount > 0 ? `${warningCount} warning(s)` : null
|
|
332
|
+
].filter((detail) => detail !== null).join(", "), resolveCliWrapColumns(process.stdout.columns)).join(`
|
|
265
333
|
`);
|
|
266
334
|
}
|
|
267
335
|
function getDoctorFailureDetailLines(checks) {
|
|
268
336
|
return getFailingDoctorChecks(checks).map((check) => `${check.label}: ${check.detail}`);
|
|
269
337
|
}
|
|
270
338
|
|
|
271
|
-
export { CLI_DIAGNOSTIC_CODES, CliDiagnosticError, isCliDiagnosticError, createCliCommandError, formatCliDiagnosticError, serializeCliDiagnosticError, formatDoctorCheckLine, getFailingDoctorChecks, formatDoctorSummaryLine, getDoctorFailureDetailLines };
|
|
339
|
+
export { CLI_DIAGNOSTIC_CODES, CLI_DIAGNOSTIC_CODE_METADATA, CliDiagnosticError, isCliDiagnosticError, getCliDiagnosticCodeMetadata, createCliDiagnosticCodeError, createCliCommandError, formatCliDiagnosticError, serializeCliDiagnosticError, formatDoctorCheckLine, getFailingDoctorChecks, formatDoctorSummaryLine, getDoctorFailureDetailLines };
|
|
272
340
|
|
|
273
|
-
//# debugId=
|
|
341
|
+
//# debugId=723BDE410F54191064756E2164756E21
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
resolvePackageManagerId,
|
|
20
20
|
resolveTemplateId,
|
|
21
21
|
scaffoldProject
|
|
22
|
-
} from "./cli-
|
|
23
|
-
import"./cli-
|
|
24
|
-
import"./cli-
|
|
22
|
+
} from "./cli-1w5vkye4.js";
|
|
23
|
+
import"./cli-39er8888.js";
|
|
24
|
+
import"./cli-e623rs7g.js";
|
|
25
25
|
import"./cli-gcbre1zs.js";
|
|
26
26
|
import"./cli-bq2v559b.js";
|
|
27
27
|
import {
|
|
@@ -33,10 +33,11 @@ import {
|
|
|
33
33
|
OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE,
|
|
34
34
|
isBuiltInTemplateId
|
|
35
35
|
} from "./cli-tke8twkn.js";
|
|
36
|
-
import"./cli-
|
|
36
|
+
import"./cli-j180bk07.js";
|
|
37
37
|
import {
|
|
38
38
|
createManagedTempRoot
|
|
39
39
|
} from "./cli-t73q5aqz.js";
|
|
40
|
+
import"./cli-p95wr1q8.js";
|
|
40
41
|
import"./cli-pd5pqgre.js";
|
|
41
42
|
import"./cli-xnn9xjcy.js";
|
|
42
43
|
|
|
@@ -555,4 +556,4 @@ export {
|
|
|
555
556
|
getNextSteps
|
|
556
557
|
};
|
|
557
558
|
|
|
558
|
-
//# debugId=
|
|
559
|
+
//# debugId=F96DC2979B837E5864756E2164756E21
|