@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.
Files changed (48) hide show
  1. package/dist/runtime/cli-add-block.js +1 -1
  2. package/dist/runtime/cli-add-shared.d.ts +73 -5
  3. package/dist/runtime/cli-add-shared.js +58 -11
  4. package/dist/runtime/cli-add-workspace-ability.js +11 -57
  5. package/dist/runtime/cli-add-workspace-admin-view.d.ts +23 -0
  6. package/dist/runtime/cli-add-workspace-admin-view.js +872 -0
  7. package/dist/runtime/cli-add-workspace-ai-anchors.js +2 -5
  8. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +0 -4
  9. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +7 -17
  10. package/dist/runtime/cli-add-workspace-ai.js +4 -6
  11. package/dist/runtime/cli-add-workspace-assets.d.ts +13 -5
  12. package/dist/runtime/cli-add-workspace-assets.js +290 -106
  13. package/dist/runtime/cli-add-workspace-rest-anchors.js +2 -5
  14. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +0 -1
  15. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +7 -14
  16. package/dist/runtime/cli-add-workspace-rest.js +4 -6
  17. package/dist/runtime/cli-add-workspace.d.ts +58 -1
  18. package/dist/runtime/cli-add-workspace.js +588 -18
  19. package/dist/runtime/cli-add.d.ts +1 -1
  20. package/dist/runtime/cli-add.js +1 -1
  21. package/dist/runtime/cli-core.d.ts +8 -5
  22. package/dist/runtime/cli-core.js +7 -4
  23. package/dist/runtime/cli-diagnostics.d.ts +84 -1
  24. package/dist/runtime/cli-diagnostics.js +90 -3
  25. package/dist/runtime/cli-doctor-workspace.js +552 -13
  26. package/dist/runtime/cli-doctor.d.ts +4 -2
  27. package/dist/runtime/cli-doctor.js +2 -1
  28. package/dist/runtime/cli-help.js +19 -9
  29. package/dist/runtime/cli-init.d.ts +67 -3
  30. package/dist/runtime/cli-init.js +603 -64
  31. package/dist/runtime/cli-validation.js +4 -3
  32. package/dist/runtime/index.d.ts +9 -4
  33. package/dist/runtime/index.js +7 -3
  34. package/dist/runtime/package-json-types.d.ts +12 -0
  35. package/dist/runtime/package-json-types.js +1 -0
  36. package/dist/runtime/package-versions.d.ts +17 -2
  37. package/dist/runtime/package-versions.js +46 -1
  38. package/dist/runtime/php-utils.d.ts +16 -0
  39. package/dist/runtime/php-utils.js +59 -0
  40. package/dist/runtime/scaffold-answer-resolution.js +35 -10
  41. package/dist/runtime/scaffold-apply-utils.d.ts +2 -3
  42. package/dist/runtime/scaffold-apply-utils.js +3 -43
  43. package/dist/runtime/template-source-cache.d.ts +112 -0
  44. package/dist/runtime/template-source-cache.js +434 -0
  45. package/dist/runtime/template-source-seeds.js +333 -53
  46. package/dist/runtime/workspace-inventory.d.ts +43 -2
  47. package/dist/runtime/workspace-inventory.js +138 -5
  48. package/package.json +2 -2
@@ -2,12 +2,14 @@
2
2
  * One doctor check rendered by the CLI diagnostics flow.
3
3
  */
4
4
  export interface DoctorCheck {
5
+ /** Stable machine-readable diagnostic id for structured integrations. */
6
+ code?: string;
5
7
  /** Human-readable status detail rendered next to the label. */
6
8
  detail: string;
7
9
  /** Short label for the dependency, directory, or template check. */
8
10
  label: string;
9
- /** Final pass/fail status for this diagnostic row. */
10
- status: "pass" | "fail";
11
+ /** Final pass/fail/warn status for this diagnostic row. */
12
+ status: "pass" | "fail" | "warn";
11
13
  }
12
14
  interface RunDoctorOptions {
13
15
  renderLine?: (check: DoctorCheck) => void;
@@ -1,4 +1,4 @@
1
- import { createCliCommandError, formatDoctorCheckLine, formatDoctorSummaryLine, getDoctorFailureDetailLines, } from "./cli-diagnostics.js";
1
+ import { CLI_DIAGNOSTIC_CODES, createCliCommandError, formatDoctorCheckLine, formatDoctorSummaryLine, getDoctorFailureDetailLines, } from "./cli-diagnostics.js";
2
2
  import { getEnvironmentDoctorChecks } from "./cli-doctor-environment.js";
3
3
  import { getWorkspaceDoctorChecks } from "./cli-doctor-workspace.js";
4
4
  /**
@@ -38,6 +38,7 @@ export async function runDoctor(cwd, options = {}) {
38
38
  const failureDetailLines = getDoctorFailureDetailLines(checks);
39
39
  if (failureDetailLines.length > 0) {
40
40
  throw createCliCommandError({
41
+ code: CLI_DIAGNOSTIC_CODES.DOCTOR_CHECK_FAILED,
41
42
  command: "doctor",
42
43
  detailLines: failureDetailLines,
43
44
  summary: "One or more doctor checks failed.",
@@ -17,15 +17,18 @@ export function formatHelpText() {
17
17
  wp-typia create <project-dir> [--template persistence] [--external-layer-source <./path|github:owner/repo/path[#ref]|npm-package>] [--external-layer-id <layer-id>] [--alternate-render-targets <email,mjml,plain-text>] [--data-storage <post-meta|custom-table>] [--persistence-policy <authenticated|public>] [--namespace <value>] [--text-domain <value>] [--php-prefix <value>] [--with-migration-ui] [--with-wp-env] [--with-test-preset] [--yes] [--dry-run] [--no-install] [--package-manager <id>]
18
18
  wp-typia create <project-dir> [--template compound] [--external-layer-source <./path|github:owner/repo/path[#ref]|npm-package>] [--external-layer-id <layer-id>] [--inner-blocks-preset <freeform|ordered|horizontal|locked-structure>] [--alternate-render-targets <email,mjml,plain-text>] [--data-storage <post-meta|custom-table>] [--persistence-policy <authenticated|public>] [--namespace <value>] [--text-domain <value>] [--php-prefix <value>] [--with-migration-ui] [--with-wp-env] [--with-test-preset] [--yes] [--dry-run] [--no-install] [--package-manager <id>]
19
19
  wp-typia <project-dir> [create flags...]
20
- wp-typia init [project-dir]
21
- wp-typia add block <name> --template <basic|interactivity|persistence|compound> [--external-layer-source <./path|github:owner/repo/path[#ref]|npm-package>] [--external-layer-id <layer-id>] [--inner-blocks-preset <freeform|ordered|horizontal|locked-structure>] [--alternate-render-targets <email,mjml,plain-text>] [--data-storage <post-meta|custom-table>] [--persistence-policy <authenticated|public>]
20
+ wp-typia init [project-dir] [--apply] [--package-manager <id>]
21
+ wp-typia add admin-view <name> [--source <rest-resource:slug>]
22
+ wp-typia add block <name> [--template <basic|interactivity|persistence|compound>] [--external-layer-source <./path|github:owner/repo/path[#ref]|npm-package>] [--external-layer-id <layer-id>] [--inner-blocks-preset <freeform|ordered|horizontal|locked-structure>] [--alternate-render-targets <email,mjml,plain-text>] [--data-storage <post-meta|custom-table>] [--persistence-policy <authenticated|public>]
22
23
  wp-typia add variation <name> --block <block-slug>
24
+ wp-typia add style <name> --block <block-slug>
25
+ wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>
23
26
  wp-typia add pattern <name>
24
- wp-typia add binding-source <name>
27
+ wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>]
25
28
  wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <method[,method...]>]
26
29
  wp-typia add ability <name>
27
30
  wp-typia add ai-feature <name> [--namespace <vendor/v1>]
28
- wp-typia add editor-plugin <name> [--slot <PluginSidebar>]
31
+ wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>]
29
32
  wp-typia add hooked-block <block-slug> --anchor <anchor-block-name> --position <before|after|firstChild|lastChild>
30
33
  wp-typia migrate <init|snapshot|diff|scaffold|verify|doctor|fixtures|fuzz> [...]
31
34
  wp-typia templates list
@@ -37,22 +40,29 @@ export function formatHelpText() {
37
40
 
38
41
  Built-in templates: ${TEMPLATE_IDS.join(", ")}
39
42
  Package managers: ${PACKAGE_MANAGER_IDS.join(", ")}
43
+ Output environment:
44
+ WP_TYPIA_ASCII=1 forces ASCII status markers; WP_TYPIA_ASCII=0 opts back into Unicode markers even when NO_COLOR is set.
45
+ A non-empty NO_COLOR requests ASCII-safe markers such as [ok], [dry-run], [!], and [...] when WP_TYPIA_ASCII is not set.
40
46
  Notes:
41
47
  \`wp-typia create\` is the canonical scaffold command.
42
48
  \`wp-typia <project-dir>\` remains a backward-compatible alias to \`create\` when \`<project-dir>\` is the only positional argument.
43
- \`wp-typia init\` is a preview-only retrofit planner for existing projects. It does not write files yet.
49
+ \`wp-typia init\` previews the minimum retrofit sync surface by default; rerun with \`--apply\` to write package.json updates and generated helper scripts.
44
50
  Use \`--template workspace\` as shorthand for \`@wp-typia/create-workspace-template\`, the official empty workspace scaffold behind \`wp-typia add ...\`.
51
+ Interactive add flows let you choose a template when \`--template\` is omitted; non-interactive runs default to \`basic\`.
52
+ \`add admin-view\` scaffolds an opt-in DataViews-powered WordPress admin screen under \`src/admin-views/\`; pass \`--source rest-resource:<slug>\` to reuse a list-capable REST resource.
45
53
  \`query-loop\` is create-only. Use \`wp-typia create <project-dir> --template query-loop\`; \`wp-typia add block\` accepts only basic, interactivity, persistence, and compound families.
46
54
  \`add variation\` uses an existing workspace block from \`scripts/block-config.ts\`.
55
+ \`add style\` registers a Block Styles option for an existing generated block.
56
+ \`add transform\` adds a block-to-block transform into an existing generated block.
47
57
  \`add pattern\` scaffolds a namespaced PHP pattern shell under \`src/patterns/\`.
48
- \`add binding-source\` scaffolds shared PHP and editor registration under \`src/bindings/\`.
58
+ \`add binding-source\` scaffolds shared PHP and editor registration under \`src/bindings/\`; pass \`--block\` and \`--attribute\` together to declare a bindable generated-block attribute.
49
59
  \`add rest-resource\` scaffolds plugin-level TypeScript REST contracts under \`src/rest/\` and PHP route glue under \`inc/rest/\`.
50
60
  \`add ability\` scaffolds typed workflow abilities under \`src/abilities/\` and server registration under \`inc/abilities/\`.
51
61
  \`add ai-feature\` scaffolds server-owned AI feature endpoints under \`src/ai-features/\` and PHP route glue under \`inc/ai-features/\`.
52
- \`add editor-plugin\` scaffolds a document-level editor extension under \`src/editor-plugins/\`.
62
+ \`add editor-plugin\` scaffolds a document-level editor extension under \`src/editor-plugins/\`; legacy aliases \`PluginSidebar\` and \`PluginDocumentSettingPanel\` resolve to \`sidebar\` and \`document-setting-panel\`.
53
63
  \`add hooked-block\` patches an existing workspace block's \`block.json\` \`blockHooks\` metadata.
54
- \`wp-typia doctor\` always checks environment readiness and reports when it only ran environment-level diagnostics; official workspace roots also get inventory and source-tree drift checks.
55
- \`wp-typia init\` previews the minimum sync/doctor/migration adoption layer for supported existing layouts before a future write mode exists.
64
+ \`wp-typia doctor\` always checks environment readiness and reports when it only ran environment-level diagnostics; official workspace roots also get inventory, source-tree drift, shared convention checks, and iframe/API v3 compatibility checks.
65
+ \`wp-typia init\` previews or applies the minimum sync/doctor/migration adoption layer for supported existing layouts; pass \`--package-manager <id>\` to pin emitted scripts and next steps.
56
66
  \`wp-typia migrate doctor --all\` checks migration target alignment, snapshots, fixtures, and generated migration artifacts.
57
67
  \`migrate\` is the canonical migration command; \`migrations\` is no longer supported.`;
58
68
  }
@@ -1,6 +1,7 @@
1
1
  import { type PackageManagerId } from "./package-managers.js";
2
+ type InitCommandMode = "apply" | "preview-only";
2
3
  type InitPlanAction = "add" | "update";
3
- type InitPlanStatus = "already-initialized" | "preview";
4
+ type InitPlanStatus = "already-initialized" | "applied" | "preview";
4
5
  type InitPlanLayoutKind = "generated-project" | "multi-block" | "official-workspace" | "single-block" | "unsupported";
5
6
  interface InitDependencyChange {
6
7
  action: InitPlanAction;
@@ -20,11 +21,37 @@ interface InitPackageManagerFieldChange {
20
21
  requiredValue: string;
21
22
  }
22
23
  interface InitFilePlan {
24
+ action: InitPlanAction;
23
25
  path: string;
24
26
  purpose: string;
25
27
  }
28
+ /**
29
+ * One existing block target that `wp-typia init` can retrofit into the shared
30
+ * sync surface.
31
+ *
32
+ * Each path stays relative to the project root so generated helper scripts can
33
+ * resolve the current block metadata and TypeScript source of truth without
34
+ * guessing layout-specific locations.
35
+ */
36
+ export interface RetrofitInitBlockTarget {
37
+ attributeTypeName: string;
38
+ blockJsonFile: string;
39
+ blockName: string;
40
+ manifestFile: string;
41
+ saveFile: string;
42
+ slug: string;
43
+ typesFile: string;
44
+ }
45
+ /**
46
+ * Preview or apply result returned by `wp-typia init`.
47
+ *
48
+ * The plan describes the detected retrofit layout, package-level mutations,
49
+ * helper files, next steps, and any warnings gathered while preparing or
50
+ * applying the minimum sync surface for an existing project.
51
+ */
26
52
  export interface RetrofitInitPlan {
27
- commandMode: "preview-only";
53
+ blockTargets: RetrofitInitBlockTarget[];
54
+ commandMode: InitCommandMode;
28
55
  detectedLayout: {
29
56
  blockNames: string[];
30
57
  description: string;
@@ -45,5 +72,42 @@ export interface RetrofitInitPlan {
45
72
  status: InitPlanStatus;
46
73
  summary: string;
47
74
  }
48
- export declare function getInitPlan(projectDir: string): RetrofitInitPlan;
75
+ /**
76
+ * Inspect one project directory and return the current retrofit init plan.
77
+ *
78
+ * @param projectDir Project root or nested path that should be analyzed.
79
+ * @param options Optional package-manager override used for emitted scripts and
80
+ * follow-up guidance.
81
+ * @returns The preview-only retrofit init plan for the resolved project.
82
+ */
83
+ export declare function getInitPlan(projectDir: string, options?: {
84
+ packageManager?: string;
85
+ }): RetrofitInitPlan;
86
+ /**
87
+ * Apply the previewed retrofit init plan to disk.
88
+ *
89
+ * The command snapshots package.json and generated helper targets before
90
+ * writing, then rolls those files back automatically if any write fails.
91
+ *
92
+ * @param projectDir Project root that should receive the retrofit surface.
93
+ * @param options Optional package-manager override used for emitted scripts and
94
+ * follow-up guidance.
95
+ * @returns The applied retrofit init plan describing the persisted changes.
96
+ */
97
+ export declare function applyInitPlan(projectDir: string, options?: {
98
+ packageManager?: string;
99
+ }): Promise<RetrofitInitPlan>;
100
+ /**
101
+ * Execute `wp-typia init` in preview or apply mode.
102
+ *
103
+ * @param options Resolved command options including the target project
104
+ * directory, optional package-manager override, and whether writes should be
105
+ * applied.
106
+ * @returns The previewed or applied retrofit init plan.
107
+ */
108
+ export declare function runInitCommand(options: {
109
+ apply?: boolean;
110
+ packageManager?: string;
111
+ projectDir: string;
112
+ }): Promise<RetrofitInitPlan>;
49
113
  export {};