wp-typia 0.22.4 → 0.22.6
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 +7 -0
- package/dist-bunli/.bunli/commands.gen.js +2097 -1366
- package/dist-bunli/{cli-2mt6bvcj.js → cli-0q0tz4dq.js} +4 -4
- package/dist-bunli/{cli-hb9vpsev.js → cli-2rqf6t0b.js} +1 -1
- package/dist-bunli/{cli-6bhfzq5e.js → cli-52ke0ptp.js} +2 -2
- package/dist-bunli/{cli-qr2ek735.js → cli-5kn2p7ee.js} +942 -477
- package/dist-bunli/{cli-6ymn63t4.js → cli-6a65qfb1.js} +475 -249
- package/dist-bunli/{cli-add-6s6kzf7x.js → cli-add-5vmxpgmn.js} +94 -184
- package/dist-bunli/{cli-doctor-70zd5m3b.js → cli-doctor-ngzs8kkc.js} +15 -18
- package/dist-bunli/{cli-gsj6vyn5.js → cli-f44sphgv.js} +183 -81
- package/dist-bunli/cli-fys8vm2t.js +20 -0
- package/dist-bunli/{cli-btbpt84c.js → cli-hhp1d348.js} +1 -1
- package/dist-bunli/{cli-init-kjjyky1y.js → cli-init-df1wg71p.js} +421 -401
- package/dist-bunli/{cli-scaffold-f57ccf5v.js → cli-scaffold-btx3wfsn.js} +8 -7
- package/dist-bunli/cli.js +10 -7
- package/dist-bunli/{command-list-wsaa4t2p.js → command-list-bqr2tp8w.js} +16 -12
- package/dist-bunli/{migrations-vw502qf9.js → migrations-bnrjw4k1.js} +7 -6
- package/dist-bunli/node-cli.js +318 -189
- package/dist-bunli/{workspace-project-7826tewa.js → workspace-project-csnnggz6.js} +2 -2
- package/package.json +2 -2
package/dist-bunli/node-cli.js
CHANGED
|
@@ -3,7 +3,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
3
3
|
// package.json
|
|
4
4
|
var package_default = {
|
|
5
5
|
name: "wp-typia",
|
|
6
|
-
version: "0.22.
|
|
6
|
+
version: "0.22.6",
|
|
7
7
|
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
8
8
|
packageManager: "bun@1.3.11",
|
|
9
9
|
type: "module",
|
|
@@ -73,7 +73,7 @@ var package_default = {
|
|
|
73
73
|
"@bunli/tui": "0.6.0",
|
|
74
74
|
"@bunli/utils": "0.6.0",
|
|
75
75
|
"@wp-typia/api-client": "^0.4.5",
|
|
76
|
-
"@wp-typia/project-tools": "0.22.
|
|
76
|
+
"@wp-typia/project-tools": "0.22.6",
|
|
77
77
|
"better-result": "^2.7.0",
|
|
78
78
|
react: "^19.2.5",
|
|
79
79
|
"react-dom": "^19.2.5",
|
|
@@ -97,15 +97,18 @@ var package_default = {
|
|
|
97
97
|
|
|
98
98
|
// src/node-cli.ts
|
|
99
99
|
import {
|
|
100
|
-
CLI_DIAGNOSTIC_CODES as
|
|
100
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES8,
|
|
101
101
|
createCliCommandError as createCliCommandError3,
|
|
102
|
-
createCliDiagnosticCodeError as createCliDiagnosticCodeError6,
|
|
103
102
|
formatCliDiagnosticError,
|
|
104
103
|
serializeCliDiagnosticError as serializeCliDiagnosticError2
|
|
105
104
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
106
105
|
|
|
107
106
|
// src/command-option-metadata.ts
|
|
108
107
|
import { z } from "zod";
|
|
108
|
+
import {
|
|
109
|
+
CLI_DIAGNOSTIC_CODES,
|
|
110
|
+
createCliDiagnosticCodeError
|
|
111
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
109
112
|
var CREATE_OPTION_METADATA = {
|
|
110
113
|
"alternate-render-targets": {
|
|
111
114
|
description: "Comma-separated alternate render targets for dynamic block scaffolds (email,mjml,plain-text).",
|
|
@@ -336,7 +339,7 @@ var SYNC_OPTION_METADATA = {
|
|
|
336
339
|
};
|
|
337
340
|
var DOCTOR_OPTION_METADATA = {
|
|
338
341
|
format: {
|
|
339
|
-
description: "Use `json` for machine-readable doctor check output or `
|
|
342
|
+
description: "Use `json` for machine-readable doctor check output or `text` for human-readable output.",
|
|
340
343
|
type: "string"
|
|
341
344
|
}
|
|
342
345
|
};
|
|
@@ -353,7 +356,7 @@ var GLOBAL_OPTION_METADATA = {
|
|
|
353
356
|
type: "string"
|
|
354
357
|
},
|
|
355
358
|
format: {
|
|
356
|
-
description: "Output format for supported commands (`json` or `
|
|
359
|
+
description: "Output format for supported commands (`json` or `text`).",
|
|
357
360
|
type: "string"
|
|
358
361
|
},
|
|
359
362
|
id: {
|
|
@@ -419,6 +422,12 @@ function buildArgvWalkerRoutingMetadata(...metadataMaps) {
|
|
|
419
422
|
};
|
|
420
423
|
}
|
|
421
424
|
var COMMAND_ROUTING_METADATA = buildArgvWalkerRoutingMetadata(ALL_COMMAND_OPTION_METADATA);
|
|
425
|
+
function createMissingOptionValueError(optionLabel) {
|
|
426
|
+
return createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, `\`${optionLabel}\` requires a value.`);
|
|
427
|
+
}
|
|
428
|
+
function createUnknownOptionError(optionLabel) {
|
|
429
|
+
return createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Unknown option \`${optionLabel}\`.`);
|
|
430
|
+
}
|
|
422
431
|
function extractKnownOptionValuesFromArgv(argv, options) {
|
|
423
432
|
const flags = {};
|
|
424
433
|
const nextArgv = [];
|
|
@@ -444,7 +453,7 @@ function extractKnownOptionValuesFromArgv(argv, options) {
|
|
|
444
453
|
}
|
|
445
454
|
const next = argv[index + 1];
|
|
446
455
|
if (!next || next.startsWith("-")) {
|
|
447
|
-
throw
|
|
456
|
+
throw createMissingOptionValueError(arg);
|
|
448
457
|
}
|
|
449
458
|
flags[shortFlag.name] = next;
|
|
450
459
|
index += 1;
|
|
@@ -469,14 +478,14 @@ function extractKnownOptionValuesFromArgv(argv, options) {
|
|
|
469
478
|
}
|
|
470
479
|
if (inlineValue !== undefined) {
|
|
471
480
|
if (!inlineValue) {
|
|
472
|
-
throw
|
|
481
|
+
throw createMissingOptionValueError(`--${rawName}`);
|
|
473
482
|
}
|
|
474
483
|
flags[rawName] = inlineValue;
|
|
475
484
|
continue;
|
|
476
485
|
}
|
|
477
486
|
const next = argv[index + 1];
|
|
478
487
|
if (!next || next.startsWith("-")) {
|
|
479
|
-
throw
|
|
488
|
+
throw createMissingOptionValueError(`--${rawName}`);
|
|
480
489
|
}
|
|
481
490
|
flags[rawName] = next;
|
|
482
491
|
index += 1;
|
|
@@ -508,7 +517,7 @@ function parseCommandArgvWithMetadata(argv, options) {
|
|
|
508
517
|
if (arg.length === 2 && arg.startsWith("-")) {
|
|
509
518
|
const shortFlag = options.parser.shortFlagMap.get(arg.slice(1));
|
|
510
519
|
if (!shortFlag) {
|
|
511
|
-
throw
|
|
520
|
+
throw createUnknownOptionError(arg);
|
|
512
521
|
}
|
|
513
522
|
if (shortFlag.type === "boolean") {
|
|
514
523
|
flags[shortFlag.name] = true;
|
|
@@ -516,7 +525,7 @@ function parseCommandArgvWithMetadata(argv, options) {
|
|
|
516
525
|
}
|
|
517
526
|
const next = argv[index + 1];
|
|
518
527
|
if (!next || next.startsWith("-")) {
|
|
519
|
-
throw
|
|
528
|
+
throw createMissingOptionValueError(arg);
|
|
520
529
|
}
|
|
521
530
|
flags[shortFlag.name] = next;
|
|
522
531
|
index += 1;
|
|
@@ -532,25 +541,25 @@ function parseCommandArgvWithMetadata(argv, options) {
|
|
|
532
541
|
continue;
|
|
533
542
|
}
|
|
534
543
|
if (!options.parser.stringOptionNames.has(rawName)) {
|
|
535
|
-
throw
|
|
544
|
+
throw createUnknownOptionError(`--${rawName}`);
|
|
536
545
|
}
|
|
537
546
|
if (inlineValue !== undefined) {
|
|
538
547
|
if (!inlineValue) {
|
|
539
|
-
throw
|
|
548
|
+
throw createMissingOptionValueError(`--${rawName}`);
|
|
540
549
|
}
|
|
541
550
|
flags[rawName] = inlineValue;
|
|
542
551
|
continue;
|
|
543
552
|
}
|
|
544
553
|
const next = argv[index + 1];
|
|
545
554
|
if (!next || next.startsWith("-")) {
|
|
546
|
-
throw
|
|
555
|
+
throw createMissingOptionValueError(`--${rawName}`);
|
|
547
556
|
}
|
|
548
557
|
flags[rawName] = next;
|
|
549
558
|
index += 1;
|
|
550
559
|
continue;
|
|
551
560
|
}
|
|
552
561
|
if (arg.startsWith("-")) {
|
|
553
|
-
throw
|
|
562
|
+
throw createUnknownOptionError(arg);
|
|
554
563
|
}
|
|
555
564
|
positionals.push(arg);
|
|
556
565
|
}
|
|
@@ -584,12 +593,6 @@ import {
|
|
|
584
593
|
serializeCliDiagnosticError
|
|
585
594
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
586
595
|
|
|
587
|
-
// src/cli-output-format.ts
|
|
588
|
-
import {
|
|
589
|
-
CLI_DIAGNOSTIC_CODES,
|
|
590
|
-
createCliCommandError
|
|
591
|
-
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
592
|
-
|
|
593
596
|
// bin/argv-walker.js
|
|
594
597
|
function normalizeOptionSet(values) {
|
|
595
598
|
return values instanceof Set ? values : new Set(values);
|
|
@@ -635,26 +638,66 @@ function findFirstPositional(argv, metadata) {
|
|
|
635
638
|
return firstPositionalIndex === -1 ? undefined : argv[firstPositionalIndex];
|
|
636
639
|
}
|
|
637
640
|
|
|
641
|
+
// src/cli-command-resolution.ts
|
|
642
|
+
function resolveEntrypointCliCommand(argv) {
|
|
643
|
+
return findFirstPositional(argv, COMMAND_ROUTING_METADATA) ?? "wp-typia";
|
|
644
|
+
}
|
|
645
|
+
|
|
638
646
|
// src/cli-output-format.ts
|
|
639
|
-
|
|
647
|
+
import {
|
|
648
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES2,
|
|
649
|
+
createCliCommandError
|
|
650
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
651
|
+
var PUBLIC_CLI_OUTPUT_FORMATS = ["json", "text"];
|
|
652
|
+
var LEGACY_CLI_OUTPUT_FORMAT_ALIASES = ["toon"];
|
|
653
|
+
var SUPPORTED_CLI_OUTPUT_FORMATS = [
|
|
654
|
+
...PUBLIC_CLI_OUTPUT_FORMATS,
|
|
655
|
+
...LEGACY_CLI_OUTPUT_FORMAT_ALIASES
|
|
656
|
+
];
|
|
657
|
+
var SUPPORTED_CLI_OUTPUT_FORMAT_VALUES = SUPPORTED_CLI_OUTPUT_FORMATS;
|
|
640
658
|
function formatSupportedCliOutputFormats() {
|
|
641
|
-
return
|
|
659
|
+
return PUBLIC_CLI_OUTPUT_FORMATS.join(", ");
|
|
642
660
|
}
|
|
643
661
|
function isSupportedCliOutputFormat(value) {
|
|
644
|
-
return
|
|
662
|
+
return typeof value === "string" && SUPPORTED_CLI_OUTPUT_FORMAT_VALUES.includes(value);
|
|
663
|
+
}
|
|
664
|
+
function normalizeCliOutputFormatArgv(argv) {
|
|
665
|
+
let normalized;
|
|
666
|
+
for (let index = 0;index < argv.length; index += 1) {
|
|
667
|
+
const arg = argv[index];
|
|
668
|
+
if (!arg) {
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
if (arg === "--") {
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
if (arg === "--format") {
|
|
675
|
+
const next = argv[index + 1];
|
|
676
|
+
if (next === "text") {
|
|
677
|
+
normalized ??= [...argv];
|
|
678
|
+
normalized[index + 1] = "toon";
|
|
679
|
+
}
|
|
680
|
+
if (next && !next.startsWith("-")) {
|
|
681
|
+
index += 1;
|
|
682
|
+
}
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
if (arg === "--format=text") {
|
|
686
|
+
normalized ??= [...argv];
|
|
687
|
+
normalized[index] = "--format=toon";
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return normalized ?? argv;
|
|
645
691
|
}
|
|
646
692
|
function formatInvalidCliOutputFormatMessage(value) {
|
|
647
693
|
return `Invalid --format value "${value}". Supported values: ${formatSupportedCliOutputFormats()}.`;
|
|
648
694
|
}
|
|
649
|
-
function resolveEntrypointCliCommand(argv) {
|
|
650
|
-
return findFirstPositional(argv, COMMAND_ROUTING_METADATA) ?? "wp-typia";
|
|
651
|
-
}
|
|
652
695
|
function assertSupportedCliOutputFormat(value, argv) {
|
|
653
696
|
if (isSupportedCliOutputFormat(value)) {
|
|
654
697
|
return;
|
|
655
698
|
}
|
|
656
699
|
throw createCliCommandError({
|
|
657
|
-
code:
|
|
700
|
+
code: CLI_DIAGNOSTIC_CODES2.INVALID_ARGUMENT,
|
|
658
701
|
command: resolveEntrypointCliCommand(argv),
|
|
659
702
|
detailLines: [formatInvalidCliOutputFormatMessage(value)]
|
|
660
703
|
});
|
|
@@ -713,30 +756,17 @@ import {
|
|
|
713
756
|
|
|
714
757
|
// src/add-kind-registry.ts
|
|
715
758
|
import {
|
|
716
|
-
CLI_DIAGNOSTIC_CODES as
|
|
717
|
-
createCliDiagnosticCodeError as
|
|
759
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES4,
|
|
760
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError3
|
|
718
761
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
719
762
|
|
|
720
763
|
// src/add-kind-ids.ts
|
|
721
|
-
|
|
722
|
-
"admin-view",
|
|
723
|
-
"block",
|
|
724
|
-
"variation",
|
|
725
|
-
"style",
|
|
726
|
-
"transform",
|
|
727
|
-
"pattern",
|
|
728
|
-
"binding-source",
|
|
729
|
-
"rest-resource",
|
|
730
|
-
"ability",
|
|
731
|
-
"ai-feature",
|
|
732
|
-
"hooked-block",
|
|
733
|
-
"editor-plugin"
|
|
734
|
-
];
|
|
764
|
+
import { ADD_KIND_IDS } from "@wp-typia/project-tools/cli-add-kind-ids";
|
|
735
765
|
|
|
736
766
|
// src/cli-string-flags.ts
|
|
737
767
|
import {
|
|
738
|
-
CLI_DIAGNOSTIC_CODES as
|
|
739
|
-
createCliDiagnosticCodeError
|
|
768
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES3,
|
|
769
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError2
|
|
740
770
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
741
771
|
function readOptionalCliStringFlagValue(flags, name, mode) {
|
|
742
772
|
const value = flags[name];
|
|
@@ -744,12 +774,12 @@ function readOptionalCliStringFlagValue(flags, name, mode) {
|
|
|
744
774
|
return;
|
|
745
775
|
}
|
|
746
776
|
if (typeof value !== "string") {
|
|
747
|
-
throw
|
|
777
|
+
throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.MISSING_ARGUMENT, `\`--${name}\` requires a value.`);
|
|
748
778
|
}
|
|
749
779
|
const trimmed = value.trim();
|
|
750
780
|
if (trimmed.length === 0) {
|
|
751
781
|
if (mode === "strict") {
|
|
752
|
-
throw
|
|
782
|
+
throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.MISSING_ARGUMENT, `\`--${name}\` requires a value.`);
|
|
753
783
|
}
|
|
754
784
|
return;
|
|
755
785
|
}
|
|
@@ -764,7 +794,7 @@ function readOptionalStrictStringFlag(flags, name) {
|
|
|
764
794
|
function requireStrictStringFlag(flags, name, message) {
|
|
765
795
|
const value = readOptionalStrictStringFlag(flags, name);
|
|
766
796
|
if (!value) {
|
|
767
|
-
throw
|
|
797
|
+
throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.MISSING_ARGUMENT, message);
|
|
768
798
|
}
|
|
769
799
|
return value;
|
|
770
800
|
}
|
|
@@ -772,7 +802,7 @@ function readOptionalPairedStrictStringFlags(flags, leftName, rightName, message
|
|
|
772
802
|
const leftValue = readOptionalStrictStringFlag(flags, leftName);
|
|
773
803
|
const rightValue = readOptionalStrictStringFlag(flags, rightName);
|
|
774
804
|
if (Boolean(leftValue) !== Boolean(rightValue)) {
|
|
775
|
-
throw
|
|
805
|
+
throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.MISSING_ARGUMENT, message);
|
|
776
806
|
}
|
|
777
807
|
return [leftValue, rightValue];
|
|
778
808
|
}
|
|
@@ -853,7 +883,7 @@ var NAME_NAMESPACE_VISIBLE_FIELDS = [
|
|
|
853
883
|
];
|
|
854
884
|
function requireAddKindName(context, message) {
|
|
855
885
|
if (!context.name) {
|
|
856
|
-
throw
|
|
886
|
+
throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.MISSING_ARGUMENT, message);
|
|
857
887
|
}
|
|
858
888
|
return context.name;
|
|
859
889
|
}
|
|
@@ -880,9 +910,9 @@ function assertAddBlockTemplateId(context, templateId) {
|
|
|
880
910
|
return templateId;
|
|
881
911
|
}
|
|
882
912
|
if (templateId === "query-loop") {
|
|
883
|
-
throw
|
|
913
|
+
throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.INVALID_ARGUMENT, "`wp-typia add block --template query-loop` is not supported. Query Loop is a create-time `core/query` variation scaffold, so use `wp-typia create <project-dir> --template query-loop` instead.");
|
|
884
914
|
}
|
|
885
|
-
throw
|
|
915
|
+
throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.UNKNOWN_TEMPLATE, `Unknown add-block template "${templateId}". Expected one of: ${formatAddBlockTemplateIds(context.addRuntime)}. Run \`wp-typia templates list\` to inspect available templates.`);
|
|
886
916
|
}
|
|
887
917
|
var ADD_KIND_REGISTRY = {
|
|
888
918
|
"admin-view": defineAddKindRegistryEntry({
|
|
@@ -1063,7 +1093,9 @@ var ADD_KIND_REGISTRY = {
|
|
|
1063
1093
|
getValues: (result) => ({
|
|
1064
1094
|
abilitySlug: result.abilitySlug
|
|
1065
1095
|
}),
|
|
1066
|
-
|
|
1096
|
+
getWarnings: (result) => result.warnings,
|
|
1097
|
+
missingNameMessage: "`wp-typia add ability` requires <name>. Usage: wp-typia add ability <name>.",
|
|
1098
|
+
warnLine: context.warnLine
|
|
1067
1099
|
});
|
|
1068
1100
|
},
|
|
1069
1101
|
sortOrder: 90,
|
|
@@ -1407,14 +1439,87 @@ import os from "node:os";
|
|
|
1407
1439
|
import path from "node:path";
|
|
1408
1440
|
import { isPlainObject as isRecord } from "@wp-typia/api-client/runtime-primitives";
|
|
1409
1441
|
import {
|
|
1410
|
-
CLI_DIAGNOSTIC_CODES as
|
|
1411
|
-
createCliDiagnosticCodeError as
|
|
1442
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES5,
|
|
1443
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError4
|
|
1412
1444
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
1445
|
+
import { z as z2 } from "zod";
|
|
1413
1446
|
var WP_TYPIA_CONFIG_SOURCES = [
|
|
1414
1447
|
"~/.config/wp-typia/config.json",
|
|
1415
1448
|
".wp-typiarc",
|
|
1416
1449
|
".wp-typiarc.json"
|
|
1417
1450
|
];
|
|
1451
|
+
var wpTypiaSchemaSourceSchema = z2.object({
|
|
1452
|
+
namespace: z2.string(),
|
|
1453
|
+
path: z2.string()
|
|
1454
|
+
}).strict();
|
|
1455
|
+
var createConfigSchema = z2.object({
|
|
1456
|
+
"alternate-render-targets": z2.string().optional(),
|
|
1457
|
+
"inner-blocks-preset": z2.string().optional(),
|
|
1458
|
+
"data-storage": z2.string().optional(),
|
|
1459
|
+
"dry-run": z2.boolean().optional(),
|
|
1460
|
+
"external-layer-id": z2.string().optional(),
|
|
1461
|
+
"external-layer-source": z2.string().optional(),
|
|
1462
|
+
namespace: z2.string().optional(),
|
|
1463
|
+
"no-install": z2.boolean().optional(),
|
|
1464
|
+
"package-manager": z2.string().optional(),
|
|
1465
|
+
"persistence-policy": z2.string().optional(),
|
|
1466
|
+
"php-prefix": z2.string().optional(),
|
|
1467
|
+
"query-post-type": z2.string().optional(),
|
|
1468
|
+
template: z2.string().optional(),
|
|
1469
|
+
"text-domain": z2.string().optional(),
|
|
1470
|
+
variant: z2.string().optional(),
|
|
1471
|
+
"with-migration-ui": z2.boolean().optional(),
|
|
1472
|
+
"with-test-preset": z2.boolean().optional(),
|
|
1473
|
+
"with-wp-env": z2.boolean().optional(),
|
|
1474
|
+
yes: z2.boolean().optional()
|
|
1475
|
+
}).strict();
|
|
1476
|
+
var addBlockConfigSchema = z2.object({
|
|
1477
|
+
"alternate-render-targets": z2.string().optional(),
|
|
1478
|
+
"data-storage": z2.string().optional(),
|
|
1479
|
+
"external-layer-id": z2.string().optional(),
|
|
1480
|
+
"external-layer-source": z2.string().optional(),
|
|
1481
|
+
"inner-blocks-preset": z2.string().optional(),
|
|
1482
|
+
"persistence-policy": z2.string().optional(),
|
|
1483
|
+
template: z2.string().optional()
|
|
1484
|
+
}).strict();
|
|
1485
|
+
var addConfigSchema = z2.object({
|
|
1486
|
+
block: addBlockConfigSchema.optional()
|
|
1487
|
+
}).strict();
|
|
1488
|
+
var mcpConfigSchema = z2.object({
|
|
1489
|
+
schemaSources: z2.array(wpTypiaSchemaSourceSchema).optional()
|
|
1490
|
+
}).strict();
|
|
1491
|
+
var wpTypiaUserConfigSchema = z2.object({
|
|
1492
|
+
add: addConfigSchema.optional(),
|
|
1493
|
+
create: createConfigSchema.optional(),
|
|
1494
|
+
mcp: mcpConfigSchema.optional()
|
|
1495
|
+
}).strict();
|
|
1496
|
+
function formatIssuePath(issuePath) {
|
|
1497
|
+
if (issuePath.length === 0) {
|
|
1498
|
+
return "config";
|
|
1499
|
+
}
|
|
1500
|
+
return issuePath.map((segment) => typeof segment === "number" ? `[${segment}]` : `.${String(segment)}`).join("").replace(/^\./u, "");
|
|
1501
|
+
}
|
|
1502
|
+
function formatConfigValidationIssue(issue) {
|
|
1503
|
+
const pathLabel = formatIssuePath(issue.path);
|
|
1504
|
+
if (issue.code === "unrecognized_keys") {
|
|
1505
|
+
const keys = issue.keys.map((key) => `"${String(key)}"`).join(", ");
|
|
1506
|
+
const label = issue.keys.length === 1 ? "unknown key" : "unknown keys";
|
|
1507
|
+
return `${pathLabel}: ${label} ${keys}. Unknown keys are errors in wp-typia config.`;
|
|
1508
|
+
}
|
|
1509
|
+
return `${pathLabel}: ${issue.message}`;
|
|
1510
|
+
}
|
|
1511
|
+
function validateWpTypiaUserConfig(value, source) {
|
|
1512
|
+
const result = wpTypiaUserConfigSchema.safeParse(value);
|
|
1513
|
+
if (result.success) {
|
|
1514
|
+
return result.data;
|
|
1515
|
+
}
|
|
1516
|
+
const issueLines = result.error.issues.map(formatConfigValidationIssue);
|
|
1517
|
+
throw createCliDiagnosticCodeError4(CLI_DIAGNOSTIC_CODES5.INVALID_ARGUMENT, [
|
|
1518
|
+
`Invalid wp-typia config at ${source}.`,
|
|
1519
|
+
...issueLines.map((line) => `- ${line}`)
|
|
1520
|
+
].join(`
|
|
1521
|
+
`));
|
|
1522
|
+
}
|
|
1418
1523
|
function deepMerge(base, incoming) {
|
|
1419
1524
|
const merged = { ...base };
|
|
1420
1525
|
for (const [key, value] of Object.entries(incoming)) {
|
|
@@ -1436,18 +1541,21 @@ async function readJsonFile(filePath) {
|
|
|
1436
1541
|
source = await fs.readFile(filePath, "utf8");
|
|
1437
1542
|
} catch (error) {
|
|
1438
1543
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
1439
|
-
return
|
|
1544
|
+
return;
|
|
1440
1545
|
}
|
|
1441
1546
|
throw error;
|
|
1442
1547
|
}
|
|
1443
1548
|
try {
|
|
1444
|
-
|
|
1445
|
-
return isRecord(parsed) ? parsed : null;
|
|
1549
|
+
return JSON.parse(source);
|
|
1446
1550
|
} catch (error) {
|
|
1447
1551
|
const message = error instanceof Error ? error.message : String(error);
|
|
1448
|
-
throw
|
|
1552
|
+
throw createCliDiagnosticCodeError4(CLI_DIAGNOSTIC_CODES5.INVALID_ARGUMENT, `Unable to parse ${filePath}: ${message}`, error instanceof Error ? { cause: error } : undefined);
|
|
1449
1553
|
}
|
|
1450
1554
|
}
|
|
1555
|
+
async function readWpTypiaConfigFile(filePath) {
|
|
1556
|
+
const parsed = await readJsonFile(filePath);
|
|
1557
|
+
return parsed === undefined ? null : validateWpTypiaUserConfig(parsed, filePath);
|
|
1558
|
+
}
|
|
1451
1559
|
function resolveConfigPath(cwd, source) {
|
|
1452
1560
|
if (source.startsWith("~/")) {
|
|
1453
1561
|
return path.join(os.homedir(), source.slice(2));
|
|
@@ -1458,21 +1566,23 @@ function mergeWpTypiaUserConfig(base, incoming) {
|
|
|
1458
1566
|
return deepMerge(base, incoming);
|
|
1459
1567
|
}
|
|
1460
1568
|
async function loadWpTypiaUserConfigFromSource(cwd, source) {
|
|
1461
|
-
const config = await
|
|
1569
|
+
const config = await readWpTypiaConfigFile(resolveConfigPath(cwd, source));
|
|
1462
1570
|
return config ?? {};
|
|
1463
1571
|
}
|
|
1464
1572
|
async function loadWpTypiaUserConfig(cwd) {
|
|
1465
1573
|
let merged = {};
|
|
1466
1574
|
for (const source of WP_TYPIA_CONFIG_SOURCES) {
|
|
1467
1575
|
const configPath = resolveConfigPath(cwd, source);
|
|
1468
|
-
const config = await
|
|
1576
|
+
const config = await readWpTypiaConfigFile(configPath);
|
|
1469
1577
|
if (config) {
|
|
1470
1578
|
merged = deepMerge(merged, config);
|
|
1471
1579
|
}
|
|
1472
1580
|
}
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1581
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
1582
|
+
const packageJson = await readJsonFile(packageJsonPath);
|
|
1583
|
+
if (isRecord(packageJson) && "wp-typia" in packageJson) {
|
|
1584
|
+
const packageConfig = validateWpTypiaUserConfig(packageJson["wp-typia"], `${packageJsonPath}#wp-typia`);
|
|
1585
|
+
merged = deepMerge(merged, packageConfig);
|
|
1476
1586
|
}
|
|
1477
1587
|
return merged;
|
|
1478
1588
|
}
|
|
@@ -1498,8 +1608,8 @@ function extractWpTypiaConfigOverride(argv) {
|
|
|
1498
1608
|
|
|
1499
1609
|
// src/runtime-bridge.ts
|
|
1500
1610
|
import {
|
|
1501
|
-
CLI_DIAGNOSTIC_CODES as
|
|
1502
|
-
createCliDiagnosticCodeError as
|
|
1611
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES7,
|
|
1612
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError6
|
|
1503
1613
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
1504
1614
|
|
|
1505
1615
|
// src/runtime-bridge-add-dry-run.ts
|
|
@@ -1953,8 +2063,8 @@ import { spawnSync } from "node:child_process";
|
|
|
1953
2063
|
import fs3 from "node:fs";
|
|
1954
2064
|
import path3 from "node:path";
|
|
1955
2065
|
import {
|
|
1956
|
-
CLI_DIAGNOSTIC_CODES as
|
|
1957
|
-
createCliDiagnosticCodeError as
|
|
2066
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES6,
|
|
2067
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError5
|
|
1958
2068
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
1959
2069
|
import {
|
|
1960
2070
|
formatInstallCommand,
|
|
@@ -1975,10 +2085,10 @@ function resolveSyncExecutionTarget(subcommand) {
|
|
|
1975
2085
|
if (subcommand === "ai") {
|
|
1976
2086
|
return "ai";
|
|
1977
2087
|
}
|
|
1978
|
-
throw
|
|
2088
|
+
throw createCliDiagnosticCodeError5(CLI_DIAGNOSTIC_CODES6.INVALID_COMMAND, `Unknown sync subcommand "${subcommand}". Expected one of: "ai".`);
|
|
1979
2089
|
}
|
|
1980
2090
|
function getSyncRootError(cwd) {
|
|
1981
|
-
return
|
|
2091
|
+
return createCliDiagnosticCodeError5(CLI_DIAGNOSTIC_CODES6.OUTSIDE_PROJECT_ROOT, `No generated wp-typia project root was found at ${cwd}. Run \`wp-typia sync\` from a scaffolded project or official workspace root that already contains generated sync scripts. If you expected this directory to work, cd into the scaffold root first or rerun the scaffold before syncing.`);
|
|
1982
2092
|
}
|
|
1983
2093
|
function resolveSyncProjectContext(cwd) {
|
|
1984
2094
|
const packageJsonPath = path3.join(cwd, "package.json");
|
|
@@ -2044,7 +2154,7 @@ function assertSyncDependenciesInstalled(project, target) {
|
|
|
2044
2154
|
if (markerDir) {
|
|
2045
2155
|
return;
|
|
2046
2156
|
}
|
|
2047
|
-
throw
|
|
2157
|
+
throw createCliDiagnosticCodeError5(CLI_DIAGNOSTIC_CODES6.DEPENDENCIES_NOT_INSTALLED, `Project dependencies have not been installed yet. Run \`${formatInstallCommand(project.packageManager)}\` from the project root before \`wp-typia sync\`. The generated sync scripts rely on local tools such as \`tsx\`.`);
|
|
2048
2158
|
}
|
|
2049
2159
|
function getPackageManagerRunInvocation(packageManager, scriptName, extraArgs) {
|
|
2050
2160
|
switch (packageManager) {
|
|
@@ -2082,7 +2192,7 @@ function buildSyncPlannedCommands(project, extraArgs, target) {
|
|
|
2082
2192
|
if (target === "ai") {
|
|
2083
2193
|
const syncAiCommand2 = createSyncPlannedCommand(project, "sync-ai", extraArgs);
|
|
2084
2194
|
if (!syncAiCommand2) {
|
|
2085
|
-
throw
|
|
2195
|
+
throw createCliDiagnosticCodeError5(CLI_DIAGNOSTIC_CODES6.CONFIGURATION_MISSING, `Expected ${project.packageJsonPath} to define a \`sync-ai\` script for \`wp-typia sync ai\`.`);
|
|
2086
2196
|
}
|
|
2087
2197
|
return [syncAiCommand2];
|
|
2088
2198
|
}
|
|
@@ -2091,7 +2201,7 @@ function buildSyncPlannedCommands(project, extraArgs, target) {
|
|
|
2091
2201
|
}
|
|
2092
2202
|
const syncTypesCommand = createSyncPlannedCommand(project, "sync-types", extraArgs);
|
|
2093
2203
|
if (!syncTypesCommand) {
|
|
2094
|
-
throw
|
|
2204
|
+
throw createCliDiagnosticCodeError5(CLI_DIAGNOSTIC_CODES6.CONFIGURATION_MISSING, `Expected ${project.packageJsonPath} to define either a \`sync\` or \`sync-types\` script.`);
|
|
2095
2205
|
}
|
|
2096
2206
|
const plannedCommands = [syncTypesCommand];
|
|
2097
2207
|
const syncRestCommand = createSyncPlannedCommand(project, "sync-rest", extraArgs);
|
|
@@ -2371,13 +2481,13 @@ async function executeAddCommand({
|
|
|
2371
2481
|
if (emitOutput) {
|
|
2372
2482
|
printLine(addRuntime.formatAddHelpText());
|
|
2373
2483
|
}
|
|
2374
|
-
throw
|
|
2484
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.MISSING_ARGUMENT, `\`wp-typia add\` requires <kind>. Usage: wp-typia add ${formatAddKindUsagePlaceholder()} ...`);
|
|
2375
2485
|
}
|
|
2376
2486
|
if (!isAddKindId(kind)) {
|
|
2377
|
-
throw
|
|
2487
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.INVALID_COMMAND, `Unknown add kind "${kind}". Expected one of: ${formatAddKindList()}.`);
|
|
2378
2488
|
}
|
|
2379
2489
|
if (dryRun && !supportsAddKindDryRun(kind)) {
|
|
2380
|
-
throw
|
|
2490
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.INVALID_ARGUMENT, `\`wp-typia add ${kind}\` does not support \`--dry-run\` yet.`);
|
|
2381
2491
|
}
|
|
2382
2492
|
const executionContext = {
|
|
2383
2493
|
addRuntime,
|
|
@@ -2429,16 +2539,16 @@ async function executeTemplatesCommand({ flags }, printLine = console.log) {
|
|
|
2429
2539
|
}
|
|
2430
2540
|
if (subcommand === "inspect") {
|
|
2431
2541
|
if (!flags.id) {
|
|
2432
|
-
throw
|
|
2542
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.MISSING_ARGUMENT, "`wp-typia templates inspect` requires <template-id>.");
|
|
2433
2543
|
}
|
|
2434
2544
|
const template = getTemplateById(flags.id);
|
|
2435
2545
|
if (!template) {
|
|
2436
|
-
throw
|
|
2546
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.INVALID_ARGUMENT, `Unknown template "${flags.id}".`);
|
|
2437
2547
|
}
|
|
2438
2548
|
printBlock([formatTemplateDetails(template)], printLine);
|
|
2439
2549
|
return;
|
|
2440
2550
|
}
|
|
2441
|
-
throw
|
|
2551
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.INVALID_COMMAND, `Unknown templates subcommand "${subcommand}". Expected list or inspect.`);
|
|
2442
2552
|
}
|
|
2443
2553
|
async function executeInitCommand({ apply, cwd, packageManager, projectDir }, options = {}) {
|
|
2444
2554
|
try {
|
|
@@ -2682,6 +2792,60 @@ var SHORT_OPTION_NAMES_WITH_VALUES = new Set([...SHARED_OPTION_PARSER.shortFlagM
|
|
|
2682
2792
|
function isReservedTopLevelCommandName(value) {
|
|
2683
2793
|
return WP_TYPIA_RESERVED_TOP_LEVEL_COMMAND_NAMES.includes(value);
|
|
2684
2794
|
}
|
|
2795
|
+
function getLongOptionName(arg) {
|
|
2796
|
+
return arg.slice(2).split("=", 1)[0] ?? "";
|
|
2797
|
+
}
|
|
2798
|
+
function hasUnknownOptionBefore(argv, endIndex) {
|
|
2799
|
+
for (let index = 0;index < endIndex; index += 1) {
|
|
2800
|
+
const arg = argv[index];
|
|
2801
|
+
if (arg === "--") {
|
|
2802
|
+
return false;
|
|
2803
|
+
}
|
|
2804
|
+
if (!arg.startsWith("-") || arg === "-") {
|
|
2805
|
+
continue;
|
|
2806
|
+
}
|
|
2807
|
+
if (arg.startsWith("--")) {
|
|
2808
|
+
const optionName = getLongOptionName(arg);
|
|
2809
|
+
if (!SHARED_OPTION_PARSER.booleanOptionNames.has(optionName) && !SHARED_OPTION_PARSER.stringOptionNames.has(optionName)) {
|
|
2810
|
+
return true;
|
|
2811
|
+
}
|
|
2812
|
+
if (!arg.includes("=") && SHARED_OPTION_PARSER.stringOptionNames.has(optionName) && argv[index + 1] && !argv[index + 1].startsWith("-")) {
|
|
2813
|
+
index += 1;
|
|
2814
|
+
}
|
|
2815
|
+
continue;
|
|
2816
|
+
}
|
|
2817
|
+
if (arg.length === 2) {
|
|
2818
|
+
const option = SHARED_OPTION_PARSER.shortFlagMap.get(arg.slice(1));
|
|
2819
|
+
if (!option) {
|
|
2820
|
+
return true;
|
|
2821
|
+
}
|
|
2822
|
+
if (option.type === "string" && argv[index + 1] && !argv[index + 1].startsWith("-")) {
|
|
2823
|
+
index += 1;
|
|
2824
|
+
}
|
|
2825
|
+
continue;
|
|
2826
|
+
}
|
|
2827
|
+
return true;
|
|
2828
|
+
}
|
|
2829
|
+
return false;
|
|
2830
|
+
}
|
|
2831
|
+
function resolveCanonicalCommandContext(argv) {
|
|
2832
|
+
const positionalIndexes = collectPositionalIndexes(argv, COMMAND_ROUTING_METADATA);
|
|
2833
|
+
const firstPositionalIndex = positionalIndexes[0] ?? -1;
|
|
2834
|
+
if (firstPositionalIndex === -1) {
|
|
2835
|
+
return "wp-typia";
|
|
2836
|
+
}
|
|
2837
|
+
const firstPositional = argv[firstPositionalIndex];
|
|
2838
|
+
if (!firstPositional) {
|
|
2839
|
+
return "wp-typia";
|
|
2840
|
+
}
|
|
2841
|
+
if (hasUnknownOptionBefore(argv, firstPositionalIndex)) {
|
|
2842
|
+
return "wp-typia";
|
|
2843
|
+
}
|
|
2844
|
+
if (isReservedTopLevelCommandName(firstPositional)) {
|
|
2845
|
+
return firstPositional;
|
|
2846
|
+
}
|
|
2847
|
+
return positionalIndexes.length === 1 ? "create" : firstPositional;
|
|
2848
|
+
}
|
|
2685
2849
|
function assertStringOptionValues(argv) {
|
|
2686
2850
|
const firstPositionalIndex = findFirstPositionalIndex(argv, COMMAND_ROUTING_METADATA);
|
|
2687
2851
|
if (firstPositionalIndex === -1) {
|
|
@@ -2701,7 +2865,7 @@ function assertStringOptionValues(argv) {
|
|
|
2701
2865
|
if (SHORT_OPTION_NAMES_WITH_VALUES.has(arg.slice(1))) {
|
|
2702
2866
|
const next2 = argv[index + 1];
|
|
2703
2867
|
if (!next2 || next2.startsWith("-")) {
|
|
2704
|
-
throw
|
|
2868
|
+
throw createMissingOptionValueError(arg);
|
|
2705
2869
|
}
|
|
2706
2870
|
index += 1;
|
|
2707
2871
|
}
|
|
@@ -2716,13 +2880,13 @@ function assertStringOptionValues(argv) {
|
|
|
2716
2880
|
}
|
|
2717
2881
|
if (arg.includes("=")) {
|
|
2718
2882
|
if (!inlineValue) {
|
|
2719
|
-
throw
|
|
2883
|
+
throw createMissingOptionValueError(`--${rawName}`);
|
|
2720
2884
|
}
|
|
2721
2885
|
continue;
|
|
2722
2886
|
}
|
|
2723
2887
|
const next = argv[index + 1];
|
|
2724
2888
|
if (!next || next.startsWith("-")) {
|
|
2725
|
-
throw
|
|
2889
|
+
throw createMissingOptionValueError(`--${rawName}`);
|
|
2726
2890
|
}
|
|
2727
2891
|
index += 1;
|
|
2728
2892
|
}
|
|
@@ -2789,9 +2953,9 @@ var NODE_FALLBACK_RUNTIME_SUMMARY_LINES = [
|
|
|
2789
2953
|
`Install Bun 1.3.11+ or use \`bunx wp-typia ...\` for the full Bunli/OpenTUI runtime and Bun-only command surfaces such as \`skills\`, \`completions\`, and \`mcp\`. ${STANDALONE_GUIDANCE_LINE}`,
|
|
2790
2954
|
"Output markers: WP_TYPIA_ASCII=1 forces ASCII markers, WP_TYPIA_ASCII=0 opts back into Unicode markers, and non-empty NO_COLOR requests ASCII markers when WP_TYPIA_ASCII is unset."
|
|
2791
2955
|
];
|
|
2792
|
-
|
|
2956
|
+
var printLine = (line) => {
|
|
2793
2957
|
console.log(line);
|
|
2794
|
-
}
|
|
2958
|
+
};
|
|
2795
2959
|
function printBlock2(lines) {
|
|
2796
2960
|
for (const line of lines) {
|
|
2797
2961
|
printLine(line);
|
|
@@ -2809,24 +2973,17 @@ function hasFlagBeforeTerminator(argv, flag) {
|
|
|
2809
2973
|
return false;
|
|
2810
2974
|
}
|
|
2811
2975
|
function parseGlobalFlags(argv) {
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
flags:
|
|
2820
|
-
|
|
2821
|
-
id: typeof flags.id === "string" ? flags.id : undefined
|
|
2822
|
-
}
|
|
2823
|
-
};
|
|
2824
|
-
} catch (error) {
|
|
2825
|
-
if (error instanceof Error && /\`--format\` requires a value\.|\`--id\` requires a value\./.test(error.message)) {
|
|
2826
|
-
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.MISSING_ARGUMENT, error.message);
|
|
2976
|
+
const { argv: nextArgv, flags } = extractKnownOptionValuesFromArgv(argv, {
|
|
2977
|
+
optionNames: ["format", "id"],
|
|
2978
|
+
parser: NODE_FALLBACK_OPTION_PARSER
|
|
2979
|
+
});
|
|
2980
|
+
return {
|
|
2981
|
+
argv: nextArgv,
|
|
2982
|
+
flags: {
|
|
2983
|
+
format: typeof flags.format === "string" ? flags.format : undefined,
|
|
2984
|
+
id: typeof flags.id === "string" ? flags.id : undefined
|
|
2827
2985
|
}
|
|
2828
|
-
|
|
2829
|
-
}
|
|
2986
|
+
};
|
|
2830
2987
|
}
|
|
2831
2988
|
async function applyNodeFallbackConfigDefaults(command, subcommand, flags, configOverridePath, cwd) {
|
|
2832
2989
|
let config = await loadWpTypiaUserConfig(cwd);
|
|
@@ -2878,91 +3035,58 @@ function renderGeneralHelp() {
|
|
|
2878
3035
|
`- ${WP_TYPIA_POSITIONAL_ALIAS_USAGE}`
|
|
2879
3036
|
]);
|
|
2880
3037
|
}
|
|
2881
|
-
function
|
|
2882
|
-
printBlock2([
|
|
2883
|
-
"wp-typia templates <list|inspect>",
|
|
2884
|
-
"",
|
|
2885
|
-
...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
|
|
2886
|
-
"",
|
|
2887
|
-
"Supported flags:",
|
|
2888
|
-
...formatNodeFallbackOptionHelp(TEMPLATES_OPTION_METADATA)
|
|
2889
|
-
]);
|
|
2890
|
-
}
|
|
2891
|
-
function renderCreateHelp() {
|
|
2892
|
-
printBlock2([
|
|
2893
|
-
`Usage: ${WP_TYPIA_CANONICAL_CREATE_USAGE}`,
|
|
2894
|
-
"",
|
|
2895
|
-
...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
|
|
2896
|
-
"",
|
|
2897
|
-
"Supported flags:",
|
|
2898
|
-
...formatNodeFallbackOptionHelp(CREATE_OPTION_METADATA)
|
|
2899
|
-
]);
|
|
2900
|
-
}
|
|
2901
|
-
function renderInitHelp() {
|
|
2902
|
-
printBlock2([
|
|
2903
|
-
"Usage: wp-typia init [project-dir]",
|
|
2904
|
-
"",
|
|
2905
|
-
...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
|
|
2906
|
-
"",
|
|
2907
|
-
"Preview-by-default retrofit planner for existing WordPress block or plugin projects. Re-run with --apply to write package.json updates and helper scripts.",
|
|
2908
|
-
"",
|
|
2909
|
-
"Supported flags:",
|
|
2910
|
-
...formatNodeFallbackOptionHelp(INIT_OPTION_METADATA)
|
|
2911
|
-
]);
|
|
2912
|
-
}
|
|
2913
|
-
function renderAddHelp() {
|
|
2914
|
-
printBlock2([
|
|
2915
|
-
"Usage: wp-typia add <kind> <name>",
|
|
2916
|
-
"",
|
|
2917
|
-
...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
|
|
2918
|
-
"",
|
|
2919
|
-
`Supported kinds: ${formatAddKindList()}`,
|
|
2920
|
-
"",
|
|
2921
|
-
"Supported flags:",
|
|
2922
|
-
...formatNodeFallbackOptionHelp(ADD_OPTION_METADATA)
|
|
2923
|
-
]);
|
|
2924
|
-
}
|
|
2925
|
-
function renderMigrateHelp() {
|
|
2926
|
-
printBlock2([
|
|
2927
|
-
`Usage: ${WP_TYPIA_CANONICAL_MIGRATE_USAGE}`,
|
|
2928
|
-
"",
|
|
2929
|
-
...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
|
|
2930
|
-
"",
|
|
2931
|
-
"Supported flags:",
|
|
2932
|
-
...formatNodeFallbackOptionHelp(MIGRATE_OPTION_METADATA)
|
|
2933
|
-
]);
|
|
2934
|
-
}
|
|
2935
|
-
function renderSyncHelp() {
|
|
2936
|
-
printBlock2([
|
|
2937
|
-
"Usage: wp-typia sync [ai]",
|
|
2938
|
-
"",
|
|
2939
|
-
...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
|
|
2940
|
-
"",
|
|
2941
|
-
"Supported flags:",
|
|
2942
|
-
...formatNodeFallbackOptionHelp(SYNC_OPTION_METADATA)
|
|
2943
|
-
]);
|
|
2944
|
-
}
|
|
2945
|
-
function renderDoctorHelp() {
|
|
3038
|
+
function renderNodeFallbackCommandHelp(config) {
|
|
2946
3039
|
printBlock2([
|
|
2947
|
-
|
|
3040
|
+
config.heading,
|
|
2948
3041
|
"",
|
|
2949
3042
|
...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
|
|
2950
3043
|
"",
|
|
2951
|
-
|
|
2952
|
-
"",
|
|
3044
|
+
...config.bodyLines ? [...config.bodyLines, ""] : [],
|
|
2953
3045
|
"Supported flags:",
|
|
2954
|
-
...formatNodeFallbackOptionHelp(
|
|
3046
|
+
...formatNodeFallbackOptionHelp(config.optionMetadata)
|
|
2955
3047
|
]);
|
|
2956
3048
|
}
|
|
2957
|
-
var
|
|
2958
|
-
add:
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
3049
|
+
var NODE_FALLBACK_COMMAND_HELP_CONFIG = {
|
|
3050
|
+
add: {
|
|
3051
|
+
bodyLines: [`Supported kinds: ${formatAddKindList()}`],
|
|
3052
|
+
heading: "Usage: wp-typia add <kind> <name>",
|
|
3053
|
+
optionMetadata: ADD_OPTION_METADATA
|
|
3054
|
+
},
|
|
3055
|
+
create: {
|
|
3056
|
+
heading: `Usage: ${WP_TYPIA_CANONICAL_CREATE_USAGE}`,
|
|
3057
|
+
optionMetadata: CREATE_OPTION_METADATA
|
|
3058
|
+
},
|
|
3059
|
+
doctor: {
|
|
3060
|
+
bodyLines: [
|
|
3061
|
+
"Runs read-only environment readiness checks. Official wp-typia workspace roots also get inventory, source-tree drift, iframe/API v3 compatibility, and shared convention checks."
|
|
3062
|
+
],
|
|
3063
|
+
heading: "Usage: wp-typia doctor [--format json]",
|
|
3064
|
+
optionMetadata: DOCTOR_OPTION_METADATA
|
|
3065
|
+
},
|
|
3066
|
+
init: {
|
|
3067
|
+
bodyLines: [
|
|
3068
|
+
"Preview-by-default retrofit planner for existing WordPress block or plugin projects. Re-run with --apply to write package.json updates and helper scripts."
|
|
3069
|
+
],
|
|
3070
|
+
heading: "Usage: wp-typia init [project-dir]",
|
|
3071
|
+
optionMetadata: INIT_OPTION_METADATA
|
|
3072
|
+
},
|
|
3073
|
+
migrate: {
|
|
3074
|
+
heading: `Usage: ${WP_TYPIA_CANONICAL_MIGRATE_USAGE}`,
|
|
3075
|
+
optionMetadata: MIGRATE_OPTION_METADATA
|
|
3076
|
+
},
|
|
3077
|
+
sync: {
|
|
3078
|
+
heading: "Usage: wp-typia sync [ai]",
|
|
3079
|
+
optionMetadata: SYNC_OPTION_METADATA
|
|
3080
|
+
},
|
|
3081
|
+
templates: {
|
|
3082
|
+
heading: "wp-typia templates <list|inspect>",
|
|
3083
|
+
optionMetadata: TEMPLATES_OPTION_METADATA
|
|
3084
|
+
}
|
|
2965
3085
|
};
|
|
3086
|
+
var NODE_FALLBACK_HELP_RENDERERS = Object.fromEntries(Object.entries(NODE_FALLBACK_COMMAND_HELP_CONFIG).map(([command, config]) => [
|
|
3087
|
+
command,
|
|
3088
|
+
() => renderNodeFallbackCommandHelp(config)
|
|
3089
|
+
]));
|
|
2966
3090
|
function renderVersion(options = {}) {
|
|
2967
3091
|
if (options.format === "json") {
|
|
2968
3092
|
printLine(JSON.stringify({
|
|
@@ -2987,7 +3111,7 @@ function renderTemplatesJson(flags, subcommand) {
|
|
|
2987
3111
|
const templateId = flags.id;
|
|
2988
3112
|
if (!templateId) {
|
|
2989
3113
|
throw createCliCommandError3({
|
|
2990
|
-
code:
|
|
3114
|
+
code: CLI_DIAGNOSTIC_CODES8.MISSING_ARGUMENT,
|
|
2991
3115
|
command: "templates",
|
|
2992
3116
|
detailLines: ["`wp-typia templates inspect` requires <template-id>."]
|
|
2993
3117
|
});
|
|
@@ -2995,7 +3119,7 @@ function renderTemplatesJson(flags, subcommand) {
|
|
|
2995
3119
|
const template = getTemplateById(templateId);
|
|
2996
3120
|
if (!template) {
|
|
2997
3121
|
throw createCliCommandError3({
|
|
2998
|
-
code:
|
|
3122
|
+
code: CLI_DIAGNOSTIC_CODES8.INVALID_ARGUMENT,
|
|
2999
3123
|
command: "templates",
|
|
3000
3124
|
detailLines: [`Unknown template "${templateId}".`]
|
|
3001
3125
|
});
|
|
@@ -3006,7 +3130,7 @@ function renderTemplatesJson(flags, subcommand) {
|
|
|
3006
3130
|
}
|
|
3007
3131
|
function renderUnsupportedCommand(command) {
|
|
3008
3132
|
throw createCliCommandError3({
|
|
3009
|
-
code:
|
|
3133
|
+
code: CLI_DIAGNOSTIC_CODES8.UNSUPPORTED_COMMAND,
|
|
3010
3134
|
command,
|
|
3011
3135
|
detailLines: [
|
|
3012
3136
|
[
|
|
@@ -3032,7 +3156,7 @@ async function renderDoctorJson() {
|
|
|
3032
3156
|
}, null, 2));
|
|
3033
3157
|
if (checks.some((check) => check.status === "fail")) {
|
|
3034
3158
|
throw createCliCommandError4({
|
|
3035
|
-
code:
|
|
3159
|
+
code: CLI_DIAGNOSTIC_CODES8.DOCTOR_CHECK_FAILED,
|
|
3036
3160
|
command: "doctor",
|
|
3037
3161
|
detailLines: getDoctorFailureDetailLines(checks),
|
|
3038
3162
|
summary: "One or more doctor checks failed."
|
|
@@ -3049,7 +3173,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
|
|
|
3049
3173
|
const { formatAddHelpText } = await import("@wp-typia/project-tools/cli-add");
|
|
3050
3174
|
printLine(formatAddHelpText());
|
|
3051
3175
|
throw createCliCommandError3({
|
|
3052
|
-
code:
|
|
3176
|
+
code: CLI_DIAGNOSTIC_CODES8.MISSING_ARGUMENT,
|
|
3053
3177
|
command: "add",
|
|
3054
3178
|
detailLines: [
|
|
3055
3179
|
`\`wp-typia add\` requires <kind>. Usage: wp-typia add ${formatAddKindUsagePlaceholder()} ...`
|
|
@@ -3097,7 +3221,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
|
|
|
3097
3221
|
const projectDir = positionals[1];
|
|
3098
3222
|
if (!projectDir) {
|
|
3099
3223
|
throw createCliCommandError3({
|
|
3100
|
-
code:
|
|
3224
|
+
code: CLI_DIAGNOSTIC_CODES8.MISSING_ARGUMENT,
|
|
3101
3225
|
command: "create",
|
|
3102
3226
|
detailLines: [
|
|
3103
3227
|
"`wp-typia create` requires <project-dir>.",
|
|
@@ -3208,7 +3332,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
|
|
|
3208
3332
|
const resolvedSubcommand = templateId ? "inspect" : subcommand ?? "list";
|
|
3209
3333
|
if (resolvedSubcommand !== "list" && resolvedSubcommand !== "inspect") {
|
|
3210
3334
|
throw createCliCommandError3({
|
|
3211
|
-
code:
|
|
3335
|
+
code: CLI_DIAGNOSTIC_CODES8.INVALID_COMMAND,
|
|
3212
3336
|
command: "templates",
|
|
3213
3337
|
detailLines: [
|
|
3214
3338
|
`Unknown templates subcommand "${resolvedSubcommand}". Expected list or inspect.`
|
|
@@ -3234,7 +3358,8 @@ async function runNodeCli(argv = process.argv.slice(2)) {
|
|
|
3234
3358
|
const normalizedArgv = normalizeWpTypiaArgv(argv);
|
|
3235
3359
|
const { argv: argvWithoutConfigOverride, configOverridePath } = extractWpTypiaConfigOverride(normalizedArgv);
|
|
3236
3360
|
validateCliOutputFormatArgv(argvWithoutConfigOverride);
|
|
3237
|
-
const
|
|
3361
|
+
const outputFormatArgv = normalizeCliOutputFormatArgv(argvWithoutConfigOverride);
|
|
3362
|
+
const { argv: cliArgv, flags } = parseGlobalFlags(outputFormatArgv);
|
|
3238
3363
|
const { flags: commandFlags, positionals } = parseArgv(cliArgv);
|
|
3239
3364
|
const rawMergedFlags = {
|
|
3240
3365
|
...commandFlags,
|
|
@@ -3291,9 +3416,13 @@ async function runNodeCliEntrypoint(argv = process.argv.slice(2)) {
|
|
|
3291
3416
|
await runNodeCli(argv);
|
|
3292
3417
|
} catch (error) {
|
|
3293
3418
|
if (prefersStructuredErrorOutput) {
|
|
3419
|
+
const diagnostic = createCliCommandError3({
|
|
3420
|
+
command: resolveCanonicalCommandContext(argv),
|
|
3421
|
+
error
|
|
3422
|
+
});
|
|
3294
3423
|
process.stderr.write(`${JSON.stringify({
|
|
3295
3424
|
ok: false,
|
|
3296
|
-
error: serializeCliDiagnosticError2(
|
|
3425
|
+
error: serializeCliDiagnosticError2(diagnostic)
|
|
3297
3426
|
}, null, 2)}
|
|
3298
3427
|
`);
|
|
3299
3428
|
process.exitCode = 1;
|
|
@@ -3310,4 +3439,4 @@ export {
|
|
|
3310
3439
|
hasFlagBeforeTerminator
|
|
3311
3440
|
};
|
|
3312
3441
|
|
|
3313
|
-
//# debugId=
|
|
3442
|
+
//# debugId=C0474E5751A0C9C164756E2164756E21
|