@wp-typia/project-tools 0.20.1 → 0.21.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/dist/runtime/cli-add-block.js +1 -1
- package/dist/runtime/cli-add-shared.d.ts +73 -5
- package/dist/runtime/cli-add-shared.js +58 -11
- package/dist/runtime/cli-add-workspace-ability.js +11 -57
- package/dist/runtime/cli-add-workspace-admin-view.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-admin-view.js +872 -0
- package/dist/runtime/cli-add-workspace-ai-anchors.js +2 -5
- package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +0 -4
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +7 -17
- package/dist/runtime/cli-add-workspace-ai.js +4 -6
- package/dist/runtime/cli-add-workspace-assets.d.ts +13 -5
- package/dist/runtime/cli-add-workspace-assets.js +290 -106
- package/dist/runtime/cli-add-workspace-rest-anchors.js +2 -5
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +0 -1
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +7 -14
- package/dist/runtime/cli-add-workspace-rest.js +4 -6
- package/dist/runtime/cli-add-workspace.d.ts +58 -1
- package/dist/runtime/cli-add-workspace.js +588 -18
- package/dist/runtime/cli-add.d.ts +1 -1
- package/dist/runtime/cli-add.js +1 -1
- package/dist/runtime/cli-core.d.ts +8 -5
- package/dist/runtime/cli-core.js +7 -4
- package/dist/runtime/cli-diagnostics.d.ts +84 -1
- package/dist/runtime/cli-diagnostics.js +90 -3
- package/dist/runtime/cli-doctor-workspace.js +552 -13
- package/dist/runtime/cli-doctor.d.ts +4 -2
- package/dist/runtime/cli-doctor.js +2 -1
- package/dist/runtime/cli-help.js +19 -9
- package/dist/runtime/cli-init.d.ts +67 -3
- package/dist/runtime/cli-init.js +603 -64
- package/dist/runtime/cli-validation.js +4 -3
- package/dist/runtime/index.d.ts +9 -4
- package/dist/runtime/index.js +7 -3
- package/dist/runtime/package-json-types.d.ts +12 -0
- package/dist/runtime/package-json-types.js +1 -0
- package/dist/runtime/package-versions.d.ts +17 -2
- package/dist/runtime/package-versions.js +46 -1
- package/dist/runtime/php-utils.d.ts +16 -0
- package/dist/runtime/php-utils.js +59 -0
- package/dist/runtime/scaffold-answer-resolution.js +35 -10
- package/dist/runtime/scaffold-apply-utils.d.ts +2 -3
- package/dist/runtime/scaffold-apply-utils.js +3 -43
- package/dist/runtime/template-source-cache.d.ts +112 -0
- package/dist/runtime/template-source-cache.js +434 -0
- package/dist/runtime/template-source-seeds.js +333 -53
- package/dist/runtime/workspace-inventory.d.ts +43 -2
- package/dist/runtime/workspace-inventory.js +138 -5
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* Import `formatAddHelpText`, `runAddBlockCommand`,
|
|
9
9
|
* `runAddVariationCommand`, `runAddPatternCommand`,
|
|
10
10
|
* `runAddBindingSourceCommand`, `runAddHookedBlockCommand`,
|
|
11
|
+
* `runAddAdminViewCommand` for DataViews-backed admin screen scaffolds,
|
|
11
12
|
* `runAddAbilityCommand` for typed workflow ability scaffolds,
|
|
12
13
|
* and `HOOKED_BLOCK_POSITION_IDS`,
|
|
13
14
|
* `getWorkspaceBlockSelectOptions`, and `seedWorkspaceMigrationProject` for
|
|
@@ -15,8 +16,10 @@
|
|
|
15
16
|
* `runAddAiFeatureCommand` for server-owned WordPress AI feature scaffolds,
|
|
16
17
|
* `runAddRestResourceCommand` for plugin-level REST resource scaffolds,
|
|
17
18
|
* `getDoctorChecks`, `runDoctor`, and `DoctorCheck` for diagnostics,
|
|
18
|
-
* `createCliCommandError
|
|
19
|
-
*
|
|
19
|
+
* `createCliCommandError`, `createCliDiagnosticCodeError`,
|
|
20
|
+
* `CLI_DIAGNOSTIC_CODES`, `CLI_DIAGNOSTIC_CODE_METADATA`,
|
|
21
|
+
* `getCliDiagnosticCodeMetadata`, and `formatCliDiagnosticError` for shared
|
|
22
|
+
* non-interactive failure rendering and explicit diagnostic-code ownership,
|
|
20
23
|
* `formatHelpText` for top-level CLI usage output, scaffold helpers such as
|
|
21
24
|
* `createReadlinePrompt`, `getNextSteps`, `getOptionalOnboarding`,
|
|
22
25
|
* `runScaffoldFlow`, and `ReadlinePrompt` for interactive project creation,
|
|
@@ -26,9 +29,9 @@
|
|
|
26
29
|
* template inspection flows.
|
|
27
30
|
*/
|
|
28
31
|
export { getDoctorChecks, runDoctor, type DoctorCheck } from "./cli-doctor.js";
|
|
29
|
-
export { createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
|
|
30
|
-
export type { CliDiagnosticMessage } from "./cli-diagnostics.js";
|
|
31
|
-
export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
|
|
32
|
+
export { createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODE_METADATA, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getCliDiagnosticCodeMetadata, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
|
|
33
|
+
export type { CliDiagnosticCode, CliDiagnosticCodeError, CliDiagnosticMessage, } from "./cli-diagnostics.js";
|
|
34
|
+
export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAdminViewCommand, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
|
|
32
35
|
export { COMPOUND_INNER_BLOCKS_PRESET_IDS, getCompoundInnerBlocksPresetDefinition, } from "./compound-inner-blocks.js";
|
|
33
36
|
export type { CompoundInnerBlocksPresetId } from "./compound-inner-blocks.js";
|
|
34
37
|
export { HOOKED_BLOCK_POSITION_IDS } from "./hooked-blocks.js";
|
package/dist/runtime/cli-core.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* Import `formatAddHelpText`, `runAddBlockCommand`,
|
|
9
9
|
* `runAddVariationCommand`, `runAddPatternCommand`,
|
|
10
10
|
* `runAddBindingSourceCommand`, `runAddHookedBlockCommand`,
|
|
11
|
+
* `runAddAdminViewCommand` for DataViews-backed admin screen scaffolds,
|
|
11
12
|
* `runAddAbilityCommand` for typed workflow ability scaffolds,
|
|
12
13
|
* and `HOOKED_BLOCK_POSITION_IDS`,
|
|
13
14
|
* `getWorkspaceBlockSelectOptions`, and `seedWorkspaceMigrationProject` for
|
|
@@ -15,8 +16,10 @@
|
|
|
15
16
|
* `runAddAiFeatureCommand` for server-owned WordPress AI feature scaffolds,
|
|
16
17
|
* `runAddRestResourceCommand` for plugin-level REST resource scaffolds,
|
|
17
18
|
* `getDoctorChecks`, `runDoctor`, and `DoctorCheck` for diagnostics,
|
|
18
|
-
* `createCliCommandError
|
|
19
|
-
*
|
|
19
|
+
* `createCliCommandError`, `createCliDiagnosticCodeError`,
|
|
20
|
+
* `CLI_DIAGNOSTIC_CODES`, `CLI_DIAGNOSTIC_CODE_METADATA`,
|
|
21
|
+
* `getCliDiagnosticCodeMetadata`, and `formatCliDiagnosticError` for shared
|
|
22
|
+
* non-interactive failure rendering and explicit diagnostic-code ownership,
|
|
20
23
|
* `formatHelpText` for top-level CLI usage output, scaffold helpers such as
|
|
21
24
|
* `createReadlinePrompt`, `getNextSteps`, `getOptionalOnboarding`,
|
|
22
25
|
* `runScaffoldFlow`, and `ReadlinePrompt` for interactive project creation,
|
|
@@ -26,8 +29,8 @@
|
|
|
26
29
|
* template inspection flows.
|
|
27
30
|
*/
|
|
28
31
|
export { getDoctorChecks, runDoctor } from "./cli-doctor.js";
|
|
29
|
-
export { createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
|
|
30
|
-
export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
|
|
32
|
+
export { createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODE_METADATA, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getCliDiagnosticCodeMetadata, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
|
|
33
|
+
export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAdminViewCommand, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
|
|
31
34
|
export { COMPOUND_INNER_BLOCKS_PRESET_IDS, getCompoundInnerBlocksPresetDefinition, } from "./compound-inner-blocks.js";
|
|
32
35
|
export { HOOKED_BLOCK_POSITION_IDS } from "./hooked-blocks.js";
|
|
33
36
|
export { formatHelpText } from "./cli-help.js";
|
|
@@ -19,13 +19,84 @@ export declare const CLI_DIAGNOSTIC_CODES: {
|
|
|
19
19
|
readonly OUTSIDE_PROJECT_ROOT: "outside-project-root";
|
|
20
20
|
readonly TEMPLATE_SOURCE_TIMEOUT: "template-source-timeout";
|
|
21
21
|
readonly TEMPLATE_SOURCE_TOO_LARGE: "template-source-too-large";
|
|
22
|
+
readonly UNKNOWN_TEMPLATE: "unknown-template";
|
|
22
23
|
readonly UNSUPPORTED_COMMAND: "unsupported-command";
|
|
23
24
|
};
|
|
24
25
|
export type CliDiagnosticCode = (typeof CLI_DIAGNOSTIC_CODES)[keyof typeof CLI_DIAGNOSTIC_CODES];
|
|
26
|
+
/**
|
|
27
|
+
* Human-readable guidance attached to one stable CLI diagnostic code.
|
|
28
|
+
*/
|
|
29
|
+
export interface CliDiagnosticCodeMetadata {
|
|
30
|
+
/** Why this diagnostic code is emitted. */
|
|
31
|
+
cause: string;
|
|
32
|
+
/** The recommended recovery path for users and automation. */
|
|
33
|
+
recovery: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Stable cause and recovery metadata for every supported CLI diagnostic code.
|
|
37
|
+
*/
|
|
38
|
+
export declare const CLI_DIAGNOSTIC_CODE_METADATA: {
|
|
39
|
+
"command-execution": {
|
|
40
|
+
cause: string;
|
|
41
|
+
recovery: string;
|
|
42
|
+
};
|
|
43
|
+
"configuration-missing": {
|
|
44
|
+
cause: string;
|
|
45
|
+
recovery: string;
|
|
46
|
+
};
|
|
47
|
+
"dependencies-not-installed": {
|
|
48
|
+
cause: string;
|
|
49
|
+
recovery: string;
|
|
50
|
+
};
|
|
51
|
+
"doctor-check-failed": {
|
|
52
|
+
cause: string;
|
|
53
|
+
recovery: string;
|
|
54
|
+
};
|
|
55
|
+
"invalid-argument": {
|
|
56
|
+
cause: string;
|
|
57
|
+
recovery: string;
|
|
58
|
+
};
|
|
59
|
+
"invalid-command": {
|
|
60
|
+
cause: string;
|
|
61
|
+
recovery: string;
|
|
62
|
+
};
|
|
63
|
+
"missing-argument": {
|
|
64
|
+
cause: string;
|
|
65
|
+
recovery: string;
|
|
66
|
+
};
|
|
67
|
+
"missing-build-artifact": {
|
|
68
|
+
cause: string;
|
|
69
|
+
recovery: string;
|
|
70
|
+
};
|
|
71
|
+
"outside-project-root": {
|
|
72
|
+
cause: string;
|
|
73
|
+
recovery: string;
|
|
74
|
+
};
|
|
75
|
+
"template-source-timeout": {
|
|
76
|
+
cause: string;
|
|
77
|
+
recovery: string;
|
|
78
|
+
};
|
|
79
|
+
"template-source-too-large": {
|
|
80
|
+
cause: string;
|
|
81
|
+
recovery: string;
|
|
82
|
+
};
|
|
83
|
+
"unknown-template": {
|
|
84
|
+
cause: string;
|
|
85
|
+
recovery: string;
|
|
86
|
+
};
|
|
87
|
+
"unsupported-command": {
|
|
88
|
+
cause: string;
|
|
89
|
+
recovery: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export type CliDiagnosticCodeError<TCode extends CliDiagnosticCode = CliDiagnosticCode> = Error & {
|
|
93
|
+
code: TCode;
|
|
94
|
+
};
|
|
25
95
|
type DoctorCheckLike = {
|
|
96
|
+
code?: string;
|
|
26
97
|
detail: string;
|
|
27
98
|
label: string;
|
|
28
|
-
status: "pass" | "fail";
|
|
99
|
+
status: "pass" | "fail" | "warn";
|
|
29
100
|
};
|
|
30
101
|
/**
|
|
31
102
|
* Structured CLI failure carrying a stable summary/detail layout.
|
|
@@ -41,6 +112,18 @@ export declare class CliDiagnosticError extends Error {
|
|
|
41
112
|
* Narrow an unknown error to the shared CLI diagnostic error shape.
|
|
42
113
|
*/
|
|
43
114
|
export declare function isCliDiagnosticError(error: unknown): error is CliDiagnosticError;
|
|
115
|
+
/**
|
|
116
|
+
* Look up cause and recovery guidance for a stable CLI diagnostic code.
|
|
117
|
+
*/
|
|
118
|
+
export declare function getCliDiagnosticCodeMetadata(code: CliDiagnosticCode): CliDiagnosticCodeMetadata;
|
|
119
|
+
/**
|
|
120
|
+
* Tag a user-facing CLI throw site with a stable diagnostic code.
|
|
121
|
+
*
|
|
122
|
+
* Prefer this helper, or `createCliCommandError({ code })`, for new known CLI
|
|
123
|
+
* failures. `inferCliDiagnosticCode()` remains only a compatibility fallback
|
|
124
|
+
* for legacy or untyped errors.
|
|
125
|
+
*/
|
|
126
|
+
export declare function createCliDiagnosticCodeError<TCode extends CliDiagnosticCode>(code: TCode, message: string, options?: ErrorOptions): CliDiagnosticCodeError<TCode>;
|
|
44
127
|
/**
|
|
45
128
|
* Build a shared diagnostic error for one CLI command failure.
|
|
46
129
|
*/
|
|
@@ -10,8 +10,66 @@ export const CLI_DIAGNOSTIC_CODES = {
|
|
|
10
10
|
OUTSIDE_PROJECT_ROOT: "outside-project-root",
|
|
11
11
|
TEMPLATE_SOURCE_TIMEOUT: "template-source-timeout",
|
|
12
12
|
TEMPLATE_SOURCE_TOO_LARGE: "template-source-too-large",
|
|
13
|
+
UNKNOWN_TEMPLATE: "unknown-template",
|
|
13
14
|
UNSUPPORTED_COMMAND: "unsupported-command",
|
|
14
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Stable cause and recovery metadata for every supported CLI diagnostic code.
|
|
18
|
+
*/
|
|
19
|
+
export const CLI_DIAGNOSTIC_CODE_METADATA = {
|
|
20
|
+
[CLI_DIAGNOSTIC_CODES.COMMAND_EXECUTION]: {
|
|
21
|
+
cause: "The command failed after argument parsing and preflight checks completed.",
|
|
22
|
+
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.",
|
|
23
|
+
},
|
|
24
|
+
[CLI_DIAGNOSTIC_CODES.CONFIGURATION_MISSING]: {
|
|
25
|
+
cause: "A command needs configuration that is not present in the current project.",
|
|
26
|
+
recovery: "Add the missing wp-typia config section or rerun the scaffold/init flow that creates the expected configuration.",
|
|
27
|
+
},
|
|
28
|
+
[CLI_DIAGNOSTIC_CODES.DEPENDENCIES_NOT_INSTALLED]: {
|
|
29
|
+
cause: "Generated project or workspace dependencies are missing from the local install.",
|
|
30
|
+
recovery: "Run the package-manager install command from the reported project root, then rerun the wp-typia command.",
|
|
31
|
+
},
|
|
32
|
+
[CLI_DIAGNOSTIC_CODES.DOCTOR_CHECK_FAILED]: {
|
|
33
|
+
cause: "One or more doctor checks reported a failing environment or workspace row.",
|
|
34
|
+
recovery: "Inspect the failed check labels and details, fix the reported drift or missing prerequisite, then rerun `wp-typia doctor`.",
|
|
35
|
+
},
|
|
36
|
+
[CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT]: {
|
|
37
|
+
cause: "An argument was present but did not match the supported value, shape, or project state.",
|
|
38
|
+
recovery: "Correct the argument value using command help or the detail lines, then rerun the command.",
|
|
39
|
+
},
|
|
40
|
+
[CLI_DIAGNOSTIC_CODES.INVALID_COMMAND]: {
|
|
41
|
+
cause: "The command or subcommand is not part of the supported wp-typia command tree.",
|
|
42
|
+
recovery: "Run `wp-typia --help` or the relevant command help and switch to a supported command/subcommand.",
|
|
43
|
+
},
|
|
44
|
+
[CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT]: {
|
|
45
|
+
cause: "A required positional argument or flag value was omitted.",
|
|
46
|
+
recovery: "Provide the missing argument or flag value shown in the detail lines, then rerun the command.",
|
|
47
|
+
},
|
|
48
|
+
[CLI_DIAGNOSTIC_CODES.MISSING_BUILD_ARTIFACT]: {
|
|
49
|
+
cause: "The published or standalone CLI layout is missing bundled build artifacts.",
|
|
50
|
+
recovery: "Reinstall the package or standalone binary, or rebuild the workspace before invoking the command again.",
|
|
51
|
+
},
|
|
52
|
+
[CLI_DIAGNOSTIC_CODES.OUTSIDE_PROJECT_ROOT]: {
|
|
53
|
+
cause: "The command was run outside a generated wp-typia project or official workspace root.",
|
|
54
|
+
recovery: "Change into the scaffolded project/workspace root, or rerun the scaffold/init workflow that creates the expected root files.",
|
|
55
|
+
},
|
|
56
|
+
[CLI_DIAGNOSTIC_CODES.TEMPLATE_SOURCE_TIMEOUT]: {
|
|
57
|
+
cause: "External template resolution did not complete within the allowed time.",
|
|
58
|
+
recovery: "Retry with a reachable template source, use a local path, or cache the template package before rerunning.",
|
|
59
|
+
},
|
|
60
|
+
[CLI_DIAGNOSTIC_CODES.TEMPLATE_SOURCE_TOO_LARGE]: {
|
|
61
|
+
cause: "External template content exceeded the safety size limit.",
|
|
62
|
+
recovery: "Reduce the template package size or point wp-typia at a smaller official template layer.",
|
|
63
|
+
},
|
|
64
|
+
[CLI_DIAGNOSTIC_CODES.UNKNOWN_TEMPLATE]: {
|
|
65
|
+
cause: "The requested scaffold template or add-block template id is not registered.",
|
|
66
|
+
recovery: "Run `wp-typia templates list` and rerun with one of the listed template ids.",
|
|
67
|
+
},
|
|
68
|
+
[CLI_DIAGNOSTIC_CODES.UNSUPPORTED_COMMAND]: {
|
|
69
|
+
cause: "The requested command exists conceptually but is not supported by the current runtime surface.",
|
|
70
|
+
recovery: "Install Bun 1.3.11+ or use the standalone wp-typia binary when the detail lines say the Bun-powered runtime is required.",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
15
73
|
const DEFAULT_CLI_FAILURE_SUMMARIES = {
|
|
16
74
|
add: "Unable to complete the requested add workflow.",
|
|
17
75
|
create: "Unable to complete the requested create workflow.",
|
|
@@ -150,6 +208,24 @@ function readCliDiagnosticCode(error) {
|
|
|
150
208
|
}
|
|
151
209
|
return null;
|
|
152
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Look up cause and recovery guidance for a stable CLI diagnostic code.
|
|
213
|
+
*/
|
|
214
|
+
export function getCliDiagnosticCodeMetadata(code) {
|
|
215
|
+
return CLI_DIAGNOSTIC_CODE_METADATA[code];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Tag a user-facing CLI throw site with a stable diagnostic code.
|
|
219
|
+
*
|
|
220
|
+
* Prefer this helper, or `createCliCommandError({ code })`, for new known CLI
|
|
221
|
+
* failures. `inferCliDiagnosticCode()` remains only a compatibility fallback
|
|
222
|
+
* for legacy or untyped errors.
|
|
223
|
+
*/
|
|
224
|
+
export function createCliDiagnosticCodeError(code, message, options) {
|
|
225
|
+
const error = new Error(message, options);
|
|
226
|
+
error.code = code;
|
|
227
|
+
return error;
|
|
228
|
+
}
|
|
153
229
|
function inferCliDiagnosticCode(options) {
|
|
154
230
|
const inheritedCode = readCliDiagnosticCode(options.error);
|
|
155
231
|
if (inheritedCode) {
|
|
@@ -183,7 +259,10 @@ function inferCliDiagnosticCode(options) {
|
|
|
183
259
|
if (/requires <|requires --|requires a value/u.test(haystack)) {
|
|
184
260
|
return CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT;
|
|
185
261
|
}
|
|
186
|
-
if (/Unknown
|
|
262
|
+
if (/Unknown (?:add-block )?template\s+(?:"|\\")/u.test(haystack)) {
|
|
263
|
+
return CLI_DIAGNOSTIC_CODES.UNKNOWN_TEMPLATE;
|
|
264
|
+
}
|
|
265
|
+
if (/Unknown .*subcommand|Unknown add kind|removed in favor|does not support|The Bun-free fallback runtime does not support|The positional alias only accepts/u.test(haystack)) {
|
|
187
266
|
return haystack.includes("does not support") ||
|
|
188
267
|
haystack.includes("The Bun-free fallback runtime does not support")
|
|
189
268
|
? CLI_DIAGNOSTIC_CODES.UNSUPPORTED_COMMAND
|
|
@@ -265,7 +344,8 @@ export function serializeCliDiagnosticError(error) {
|
|
|
265
344
|
* Format one human-readable doctor check row.
|
|
266
345
|
*/
|
|
267
346
|
export function formatDoctorCheckLine(check) {
|
|
268
|
-
|
|
347
|
+
const statusLabel = check.status === "pass" ? "PASS" : check.status === "warn" ? "WARN" : "FAIL";
|
|
348
|
+
return formatWrappedPrefixedLine(`${statusLabel} ${check.label}: `, check.detail, resolveCliWrapColumns(process.stdout.columns)).join("\n");
|
|
269
349
|
}
|
|
270
350
|
/**
|
|
271
351
|
* Return the failing doctor checks from one doctor run.
|
|
@@ -278,7 +358,14 @@ export function getFailingDoctorChecks(checks) {
|
|
|
278
358
|
*/
|
|
279
359
|
export function formatDoctorSummaryLine(checks) {
|
|
280
360
|
const failedChecks = getFailingDoctorChecks(checks);
|
|
281
|
-
|
|
361
|
+
const warningCount = checks.filter((check) => check.status === "warn").length;
|
|
362
|
+
const summaryStatus = failedChecks.length > 0 ? "FAIL" : warningCount > 0 ? "WARN" : "PASS";
|
|
363
|
+
return formatWrappedPrefixedLine(`${summaryStatus} wp-typia doctor summary: `, [
|
|
364
|
+
`${checks.length - failedChecks.length - warningCount}/${checks.length} checks passed`,
|
|
365
|
+
warningCount > 0 ? `${warningCount} warning(s)` : null,
|
|
366
|
+
]
|
|
367
|
+
.filter((detail) => detail !== null)
|
|
368
|
+
.join(", "), resolveCliWrapColumns(process.stdout.columns)).join("\n");
|
|
282
369
|
}
|
|
283
370
|
/**
|
|
284
371
|
* Build detail lines for doctor failures so the non-interactive formatter can
|