wp-typia 0.20.4 → 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.
@@ -54,7 +54,7 @@ import {
54
54
  } from "./cli-sj5mtyzj.js";
55
55
  import {
56
56
  readWorkspaceInventory
57
- } from "./cli-3w3qxq9w.js";
57
+ } from "./cli-hx88xwr4.js";
58
58
  import {
59
59
  getInvalidWorkspaceProjectReason,
60
60
  tryResolveWorkspaceProject
@@ -12,8 +12,63 @@ var CLI_DIAGNOSTIC_CODES = {
12
12
  OUTSIDE_PROJECT_ROOT: "outside-project-root",
13
13
  TEMPLATE_SOURCE_TIMEOUT: "template-source-timeout",
14
14
  TEMPLATE_SOURCE_TOO_LARGE: "template-source-too-large",
15
+ UNKNOWN_TEMPLATE: "unknown-template",
15
16
  UNSUPPORTED_COMMAND: "unsupported-command"
16
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
+ };
17
72
  var DEFAULT_CLI_FAILURE_SUMMARIES = {
18
73
  add: "Unable to complete the requested add workflow.",
19
74
  create: "Unable to complete the requested create workflow.",
@@ -147,6 +202,14 @@ function readCliDiagnosticCode(error) {
147
202
  }
148
203
  return null;
149
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
+ }
150
213
  function inferCliDiagnosticCode(options) {
151
214
  const inheritedCode = readCliDiagnosticCode(options.error);
152
215
  if (inheritedCode) {
@@ -181,7 +244,10 @@ function inferCliDiagnosticCode(options) {
181
244
  if (/requires <|requires --|requires a value/u.test(haystack)) {
182
245
  return CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT;
183
246
  }
184
- if (/Unknown .*subcommand|Unknown add kind|Unknown template|removed in favor|does not support|The Bun-free fallback runtime does not support|The positional alias only accepts/u.test(haystack)) {
247
+ if (/Unknown (?:add-block )?template\s+(?:"|\\")/u.test(haystack)) {
248
+ return CLI_DIAGNOSTIC_CODES.UNKNOWN_TEMPLATE;
249
+ }
250
+ 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)) {
185
251
  return haystack.includes("does not support") || haystack.includes("The Bun-free fallback runtime does not support") ? CLI_DIAGNOSTIC_CODES.UNSUPPORTED_COMMAND : CLI_DIAGNOSTIC_CODES.INVALID_COMMAND;
186
252
  }
187
253
  if (/Invalid |must start with|cannot hook|cannot nest|cannot use|cannot be|already defines|already exists|Expected one of/u.test(haystack)) {
@@ -249,7 +315,8 @@ function serializeCliDiagnosticError(error) {
249
315
  };
250
316
  }
251
317
  function formatDoctorCheckLine(check) {
252
- return formatWrappedPrefixedLine(`${check.status === "pass" ? "PASS" : "FAIL"} ${check.label}: `, check.detail, resolveCliWrapColumns(process.stdout.columns)).join(`
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(`
253
320
  `);
254
321
  }
255
322
  function getFailingDoctorChecks(checks) {
@@ -257,13 +324,18 @@ function getFailingDoctorChecks(checks) {
257
324
  }
258
325
  function formatDoctorSummaryLine(checks) {
259
326
  const failedChecks = getFailingDoctorChecks(checks);
260
- return formatWrappedPrefixedLine(`${failedChecks.length === 0 ? "PASS" : "FAIL"} wp-typia doctor summary: `, `${checks.length - failedChecks.length}/${checks.length} checks passed`, resolveCliWrapColumns(process.stdout.columns)).join(`
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(`
261
333
  `);
262
334
  }
263
335
  function getDoctorFailureDetailLines(checks) {
264
336
  return getFailingDoctorChecks(checks).map((check) => `${check.label}: ${check.detail}`);
265
337
  }
266
338
 
267
- 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 };
268
340
 
269
- //# debugId=62F5F6BDF80B85D964756E2164756E21
341
+ //# debugId=723BDE410F54191064756E2164756E21