@wp-typia/project-tools 0.23.0 → 0.24.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 (228) hide show
  1. package/dist/runtime/ai-feature-artifacts.js +4 -1
  2. package/dist/runtime/block-generator-service-spec.js +2 -1
  3. package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
  4. package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
  5. package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
  6. package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
  7. package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
  8. package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
  9. package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
  10. package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
  11. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
  12. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
  13. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
  14. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
  15. package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
  16. package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
  17. package/dist/runtime/cli-add-block-json.js +5 -1
  18. package/dist/runtime/cli-add-collision.js +8 -0
  19. package/dist/runtime/cli-add-help.js +14 -10
  20. package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
  21. package/dist/runtime/cli-add-kind-ids.js +1 -0
  22. package/dist/runtime/cli-add-types.d.ts +45 -6
  23. package/dist/runtime/cli-add-types.js +2 -0
  24. package/dist/runtime/cli-add-validation.d.ts +7 -0
  25. package/dist/runtime/cli-add-validation.js +9 -0
  26. package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
  27. package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
  28. package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
  29. package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
  30. package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
  31. package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
  32. package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -2
  33. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
  34. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
  35. package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
  36. package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
  37. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
  38. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
  39. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
  40. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
  41. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
  42. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
  43. package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
  44. package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
  45. package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
  46. package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
  47. package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
  48. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
  49. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
  50. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
  51. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
  52. package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
  53. package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
  54. package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
  55. package/dist/runtime/cli-add-workspace-assets.js +6 -950
  56. package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
  57. package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
  58. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
  59. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
  60. package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
  61. package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
  62. package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
  63. package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
  64. package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
  65. package/dist/runtime/cli-add-workspace-block-style.js +148 -0
  66. package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
  67. package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
  68. package/dist/runtime/cli-add-workspace-contract.js +1 -1
  69. package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
  70. package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
  71. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
  72. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
  73. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
  74. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
  75. package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
  76. package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
  77. package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
  78. package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
  79. package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
  80. package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
  81. package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
  82. package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
  83. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
  84. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
  85. package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
  86. package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
  87. package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
  88. package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
  89. package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
  90. package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
  91. package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
  92. package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
  93. package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
  94. package/dist/runtime/cli-add-workspace-pattern.js +99 -0
  95. package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
  96. package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
  97. package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
  98. package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
  99. package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
  100. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
  101. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
  102. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
  103. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
  104. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
  105. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
  106. package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
  107. package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
  108. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
  109. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
  110. package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
  111. package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
  112. package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
  113. package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
  114. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
  115. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
  116. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
  117. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
  118. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
  119. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
  120. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
  121. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
  122. package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
  123. package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
  124. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
  125. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
  126. package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
  127. package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
  128. package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
  129. package/dist/runtime/cli-add-workspace-rest.js +33 -788
  130. package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
  131. package/dist/runtime/cli-add-workspace-variation.js +162 -0
  132. package/dist/runtime/cli-add-workspace.d.ts +42 -107
  133. package/dist/runtime/cli-add-workspace.js +42 -674
  134. package/dist/runtime/cli-add.d.ts +3 -3
  135. package/dist/runtime/cli-add.js +2 -2
  136. package/dist/runtime/cli-core.d.ts +3 -2
  137. package/dist/runtime/cli-core.js +2 -2
  138. package/dist/runtime/cli-diagnostics.d.ts +3 -1
  139. package/dist/runtime/cli-diagnostics.js +17 -5
  140. package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
  141. package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
  142. package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
  143. package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
  144. package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
  145. package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
  146. package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
  147. package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
  148. package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
  149. package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
  150. package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
  151. package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
  152. package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
  153. package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
  154. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
  155. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
  156. package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
  157. package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
  158. package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
  159. package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
  160. package/dist/runtime/cli-doctor-workspace-features.js +14 -487
  161. package/dist/runtime/cli-doctor.d.ts +54 -3
  162. package/dist/runtime/cli-doctor.js +92 -10
  163. package/dist/runtime/cli-help.js +12 -7
  164. package/dist/runtime/cli-init-package-json.js +4 -2
  165. package/dist/runtime/cli-prompt.d.ts +16 -2
  166. package/dist/runtime/cli-prompt.js +29 -12
  167. package/dist/runtime/cli-scaffold.d.ts +2 -1
  168. package/dist/runtime/cli-scaffold.js +19 -10
  169. package/dist/runtime/external-template-guards.js +4 -6
  170. package/dist/runtime/index.d.ts +6 -3
  171. package/dist/runtime/index.js +4 -2
  172. package/dist/runtime/json-utils.d.ts +62 -4
  173. package/dist/runtime/json-utils.js +78 -4
  174. package/dist/runtime/local-dev-presets.js +6 -2
  175. package/dist/runtime/migration-ui-capability.js +4 -1
  176. package/dist/runtime/migration-utils.js +4 -1
  177. package/dist/runtime/package-managers.js +6 -1
  178. package/dist/runtime/package-versions.d.ts +1 -0
  179. package/dist/runtime/package-versions.js +16 -3
  180. package/dist/runtime/pattern-catalog.d.ts +122 -0
  181. package/dist/runtime/pattern-catalog.js +471 -0
  182. package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
  183. package/dist/runtime/post-meta-binding-fields.js +135 -0
  184. package/dist/runtime/scaffold-bootstrap.js +7 -2
  185. package/dist/runtime/scaffold-package-manager-files.js +5 -1
  186. package/dist/runtime/scaffold-repository-reference.js +4 -2
  187. package/dist/runtime/scaffold-template-variables.js +2 -1
  188. package/dist/runtime/scaffold.d.ts +18 -1
  189. package/dist/runtime/scaffold.js +55 -2
  190. package/dist/runtime/temp-roots.js +4 -1
  191. package/dist/runtime/template-layers.js +4 -1
  192. package/dist/runtime/template-registry.js +9 -3
  193. package/dist/runtime/template-source-contracts.d.ts +2 -0
  194. package/dist/runtime/template-source-normalization.js +2 -1
  195. package/dist/runtime/template-source-remote.js +18 -5
  196. package/dist/runtime/template-source-seeds.js +10 -3
  197. package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
  198. package/dist/runtime/typia-llm-json-schema.js +33 -0
  199. package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
  200. package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
  201. package/dist/runtime/typia-llm-projection.d.ts +25 -0
  202. package/dist/runtime/typia-llm-projection.js +58 -0
  203. package/dist/runtime/typia-llm-render.d.ts +21 -0
  204. package/dist/runtime/typia-llm-render.js +252 -0
  205. package/dist/runtime/typia-llm-sync.d.ts +10 -0
  206. package/dist/runtime/typia-llm-sync.js +63 -0
  207. package/dist/runtime/typia-llm-types.d.ts +197 -0
  208. package/dist/runtime/typia-llm-types.js +1 -0
  209. package/dist/runtime/typia-llm.d.ts +9 -255
  210. package/dist/runtime/typia-llm.js +5 -634
  211. package/dist/runtime/workspace-inventory-mutations.js +15 -1
  212. package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
  213. package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
  214. package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
  215. package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
  216. package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
  217. package/dist/runtime/workspace-inventory-parser.js +3 -581
  218. package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
  219. package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
  220. package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
  221. package/dist/runtime/workspace-inventory-templates.js +10 -1
  222. package/dist/runtime/workspace-inventory-types.d.ts +10 -1
  223. package/dist/runtime/workspace-project.js +4 -6
  224. package/package.json +8 -3
  225. package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
  226. package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
  227. package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
  228. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
@@ -0,0 +1,111 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { parseScaffoldBlockMetadata } from "@wp-typia/block-runtime/blocks";
4
+ import { checkExistingFiles, createDoctorCheck, WORKSPACE_GENERATED_BLOCK_ARTIFACTS, } from "./cli-doctor-workspace-shared.js";
5
+ import { HOOKED_BLOCK_ANCHOR_PATTERN, HOOKED_BLOCK_POSITION_SET, } from "./hooked-blocks.js";
6
+ import { readJsonFileSync } from "./json-utils.js";
7
+ const WORKSPACE_COLLECTION_IMPORT_LINE = "import '../../collection';";
8
+ const WORKSPACE_COLLECTION_IMPORT_PATTERN = /^\s*import\s+["']\.\.\/\.\.\/collection["']\s*;?\s*$/m;
9
+ function getWorkspaceBlockRequiredFiles(block) {
10
+ const blockDir = path.join("src", "blocks", block.slug);
11
+ return Array.from(new Set([
12
+ block.typesFile,
13
+ block.apiTypesFile,
14
+ block.openApiFile,
15
+ path.join(blockDir, "index.tsx"),
16
+ ...WORKSPACE_GENERATED_BLOCK_ARTIFACTS.map((fileName) => path.join(blockDir, fileName)),
17
+ ].filter((filePath) => typeof filePath === "string")));
18
+ }
19
+ function checkWorkspaceBlockMetadata(projectDir, workspace, block) {
20
+ const blockJsonRelativePath = path.join("src", "blocks", block.slug, "block.json");
21
+ const blockJsonPath = path.join(projectDir, blockJsonRelativePath);
22
+ if (!fs.existsSync(blockJsonPath)) {
23
+ return createDoctorCheck(`Block metadata ${block.slug}`, "fail", `Missing ${blockJsonRelativePath}`);
24
+ }
25
+ let blockJson;
26
+ try {
27
+ blockJson = parseScaffoldBlockMetadata(readJsonFileSync(blockJsonPath, {
28
+ context: "workspace block metadata",
29
+ }));
30
+ }
31
+ catch (error) {
32
+ return createDoctorCheck(`Block metadata ${block.slug}`, "fail", error instanceof Error ? error.message : String(error));
33
+ }
34
+ const expectedName = `${workspace.workspace.namespace}/${block.slug}`;
35
+ const issues = [];
36
+ if (blockJson.name !== expectedName) {
37
+ issues.push(`block.json name must equal "${expectedName}"`);
38
+ }
39
+ if (blockJson.textdomain !== workspace.workspace.textDomain) {
40
+ issues.push(`block.json textdomain must equal "${workspace.workspace.textDomain}"`);
41
+ }
42
+ return createDoctorCheck(`Block metadata ${block.slug}`, issues.length === 0 ? "pass" : "fail", issues.length === 0
43
+ ? `block.json matches ${expectedName} and ${workspace.workspace.textDomain}`
44
+ : issues.join("; "));
45
+ }
46
+ function checkWorkspaceBlockHooks(projectDir, blockSlug) {
47
+ const blockJsonRelativePath = path.join("src", "blocks", blockSlug, "block.json");
48
+ const blockJsonPath = path.join(projectDir, blockJsonRelativePath);
49
+ if (!fs.existsSync(blockJsonPath)) {
50
+ return createDoctorCheck(`Block hooks ${blockSlug}`, "fail", `Missing ${blockJsonRelativePath}`);
51
+ }
52
+ let blockJson;
53
+ try {
54
+ blockJson = parseScaffoldBlockMetadata(readJsonFileSync(blockJsonPath, {
55
+ context: "workspace block metadata",
56
+ }));
57
+ }
58
+ catch (error) {
59
+ return createDoctorCheck(`Block hooks ${blockSlug}`, "fail", error instanceof Error ? error.message : String(error));
60
+ }
61
+ const blockHooks = blockJson.blockHooks;
62
+ if (blockHooks === undefined) {
63
+ return createDoctorCheck(`Block hooks ${blockSlug}`, "pass", "No blockHooks metadata configured");
64
+ }
65
+ if (!blockHooks || typeof blockHooks !== "object" || Array.isArray(blockHooks)) {
66
+ return createDoctorCheck(`Block hooks ${blockSlug}`, "fail", `${blockJsonRelativePath} must define blockHooks as an object when present.`);
67
+ }
68
+ const blockName = typeof blockJson.name === "string" && blockJson.name.trim().length > 0
69
+ ? blockJson.name.trim()
70
+ : null;
71
+ const invalidEntries = Object.entries(blockHooks).filter(([anchor, position]) => (blockName !== null && anchor.trim() === blockName) ||
72
+ anchor.trim().length === 0 ||
73
+ anchor !== anchor.trim() ||
74
+ !HOOKED_BLOCK_ANCHOR_PATTERN.test(anchor) ||
75
+ typeof position !== "string" ||
76
+ !HOOKED_BLOCK_POSITION_SET.has(position));
77
+ return createDoctorCheck(`Block hooks ${blockSlug}`, invalidEntries.length === 0 ? "pass" : "fail", invalidEntries.length === 0
78
+ ? `blockHooks metadata is valid${Object.keys(blockHooks).length > 0
79
+ ? ` (${Object.keys(blockHooks).join(", ")})`
80
+ : ""}`
81
+ : `Invalid blockHooks entries: ${invalidEntries
82
+ .map(([anchor, position]) => `${anchor || "<empty>"} => ${String(position)}`)
83
+ .join(", ")}`);
84
+ }
85
+ function checkWorkspaceBlockCollectionImport(projectDir, blockSlug) {
86
+ const entryRelativePath = path.join("src", "blocks", blockSlug, "index.tsx");
87
+ const entryPath = path.join(projectDir, entryRelativePath);
88
+ if (!fs.existsSync(entryPath)) {
89
+ return createDoctorCheck(`Block collection ${blockSlug}`, "fail", `Missing ${entryRelativePath}`);
90
+ }
91
+ const source = fs.readFileSync(entryPath, "utf8");
92
+ const hasCollectionImport = WORKSPACE_COLLECTION_IMPORT_PATTERN.test(source);
93
+ return createDoctorCheck(`Block collection ${blockSlug}`, hasCollectionImport ? "pass" : "fail", hasCollectionImport
94
+ ? "Shared block collection import is present"
95
+ : `Missing a shared collection import like ${WORKSPACE_COLLECTION_IMPORT_LINE}`);
96
+ }
97
+ /**
98
+ * Collect base file, metadata, hook, and collection-import checks for one block.
99
+ *
100
+ * @param workspace Resolved workspace metadata and filesystem paths.
101
+ * @param block Inventory row describing the generated block.
102
+ * @returns Ordered block core doctor checks.
103
+ */
104
+ export function getWorkspaceBlockCoreDoctorChecks(workspace, block) {
105
+ return [
106
+ checkExistingFiles(workspace.projectDir, `Block ${block.slug}`, getWorkspaceBlockRequiredFiles(block)),
107
+ checkWorkspaceBlockMetadata(workspace.projectDir, workspace, block),
108
+ checkWorkspaceBlockHooks(workspace.projectDir, block.slug),
109
+ checkWorkspaceBlockCollectionImport(workspace.projectDir, block.slug),
110
+ ];
111
+ }
@@ -1,371 +1,6 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { parseScaffoldBlockMetadata } from "@wp-typia/block-runtime/blocks";
4
- import { checkExistingFiles, createDoctorCheck, resolveWorkspaceBootstrapPath, WORKSPACE_FULL_BLOCK_NAME_PATTERN, WORKSPACE_GENERATED_BLOCK_ARTIFACTS, } from "./cli-doctor-workspace-shared.js";
5
- import { HOOKED_BLOCK_ANCHOR_PATTERN, HOOKED_BLOCK_POSITION_SET, } from "./hooked-blocks.js";
6
- import { hasExecutablePattern, hasUncommentedPattern, maskTypeScriptCommentsAndLiterals, } from "./ts-source-masking.js";
7
- const WORKSPACE_COLLECTION_IMPORT_LINE = "import '../../collection';";
8
- const WORKSPACE_COLLECTION_IMPORT_PATTERN = /^\s*import\s+["']\.\.\/\.\.\/collection["']\s*;?\s*$/m;
9
- const WORKSPACE_VARIATIONS_IMPORT_PATTERN = /^\s*import\s*\{\s*registerWorkspaceVariations\s*\}\s*from\s*["']\.\/variations["']\s*;?\s*$/mu;
10
- const WORKSPACE_VARIATIONS_CALL_PATTERN = /registerWorkspaceVariations\s*\(\s*\)\s*;?/u;
11
- const WORKSPACE_BLOCK_STYLES_IMPORT_PATTERN = /^\s*import\s*\{\s*registerWorkspaceBlockStyles\s*\}\s*from\s*["']\.\/styles["']\s*;?\s*$/mu;
12
- const WORKSPACE_BLOCK_STYLES_CALL_PATTERN = /registerWorkspaceBlockStyles\s*\(\s*\)\s*;?/u;
13
- const WORKSPACE_BLOCK_TRANSFORMS_IMPORT_PATTERN = /^\s*import\s*\{\s*applyWorkspaceBlockTransforms\s*\}\s*from\s*["']\.\/transforms["']\s*;?\s*$/mu;
14
- const WORKSPACE_BLOCK_TRANSFORMS_CALL_PATTERN = /applyWorkspaceBlockTransforms\s*\(\s*registration\s*\.\s*settings\s*\)\s*;?/u;
15
- const WORKSPACE_BLOCK_IFRAME_COMPATIBILITY_DOC_URL = "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/block-migration-for-iframe-editor-compatibility/";
16
- const WORKSPACE_BLOCK_IFRAME_DIAGNOSTIC_CODES = {
17
- API_VERSION: "wp-typia.workspace.block.iframe.api-version",
18
- BLOCK_PROPS: "wp-typia.workspace.block.iframe.block-props",
19
- EDITOR_GLOBALS: "wp-typia.workspace.block.iframe.editor-globals",
20
- EDITOR_STYLES: "wp-typia.workspace.block.iframe.editor-styles",
21
- };
22
- const WORKSPACE_BLOCK_EDITOR_SOURCE_FILE_PATTERN = /\.[cm]?[jt]sx?$/u;
23
- const WORKSPACE_BLOCK_EDITOR_SOURCE_BASENAMES = new Set([
24
- "edit",
25
- "editor",
26
- "index",
27
- "save",
28
- ]);
29
- const WORKSPACE_BLOCK_EDITOR_SOURCE_DIRECTORIES = new Set([
30
- "components",
31
- "controls",
32
- "editor",
33
- "inspector",
34
- ]);
35
- const WORKSPACE_BLOCK_LOCAL_STYLE_FILES = [
36
- "editor.css",
37
- "editor.scss",
38
- "index.css",
39
- "style.css",
40
- "style.scss",
41
- ];
42
- const WORKSPACE_BLOCK_IFRAME_GLOBAL_DOM_PATTERN = /\b(?:document|window)\b|\b(?:parent|top)\b(?!\s*:)/gu;
43
- const WORKSPACE_BLOCK_PROPS_PATTERN = /\buse(?:Block|InnerBlocks)Props(?:\.save)?\s*\(/u;
44
- function normalizePathSeparators(relativePath) {
45
- return relativePath.split(path.sep).join("/");
46
- }
47
- function hasRegisteredBlockAsset(value) {
48
- if (typeof value === "string") {
49
- return value.trim().length > 0;
50
- }
51
- if (Array.isArray(value)) {
52
- return value.some((entry) => hasRegisteredBlockAsset(entry));
53
- }
54
- return false;
55
- }
56
- function readWorkspaceBlockIframeMetadata(projectDir, blockSlug) {
57
- const blockJsonRelativePath = path.join("src", "blocks", blockSlug, "block.json");
58
- const blockJsonPath = path.join(projectDir, blockJsonRelativePath);
59
- if (!fs.existsSync(blockJsonPath)) {
60
- return {
61
- blockJsonRelativePath,
62
- error: `Missing ${blockJsonRelativePath}`,
63
- };
64
- }
65
- try {
66
- const document = parseScaffoldBlockMetadata(JSON.parse(fs.readFileSync(blockJsonPath, "utf8")));
67
- return {
68
- blockJsonRelativePath,
69
- document,
70
- };
71
- }
72
- catch (error) {
73
- return {
74
- blockJsonRelativePath,
75
- error: error instanceof Error ? error.message : String(error),
76
- };
77
- }
78
- }
79
- function isWorkspaceBlockEditorSource(relativePath) {
80
- if (!WORKSPACE_BLOCK_EDITOR_SOURCE_FILE_PATTERN.test(relativePath)) {
81
- return false;
82
- }
83
- const normalizedRelativePath = normalizePathSeparators(relativePath);
84
- const normalizedDirName = path.posix.dirname(normalizedRelativePath);
85
- const normalizedBaseName = path.posix.basename(normalizedRelativePath, path.posix.extname(normalizedRelativePath));
86
- if (WORKSPACE_BLOCK_EDITOR_SOURCE_BASENAMES.has(normalizedBaseName)) {
87
- return true;
88
- }
89
- const pathSegments = normalizedDirName.split("/");
90
- return pathSegments.some((segment) => WORKSPACE_BLOCK_EDITOR_SOURCE_DIRECTORIES.has(segment));
91
- }
92
- function isWorkspaceBlockSaveSource(relativePath) {
93
- const normalizedBaseName = path.basename(relativePath, path.extname(relativePath));
94
- return normalizedBaseName === "save";
95
- }
96
- function collectWorkspaceBlockEditorSources(projectDir, blockSlug) {
97
- const blockDir = path.join(projectDir, "src", "blocks", blockSlug);
98
- if (!fs.existsSync(blockDir)) {
99
- return [];
100
- }
101
- const collected = [];
102
- const queue = [blockDir];
103
- while (queue.length > 0) {
104
- const currentDir = queue.pop();
105
- if (!currentDir) {
106
- continue;
107
- }
108
- for (const entry of fs.readdirSync(currentDir, { withFileTypes: true })) {
109
- const absolutePath = path.join(currentDir, entry.name);
110
- if (entry.isDirectory()) {
111
- queue.push(absolutePath);
112
- continue;
113
- }
114
- if (!entry.isFile()) {
115
- continue;
116
- }
117
- const relativePath = path.relative(projectDir, absolutePath);
118
- if (!isWorkspaceBlockEditorSource(relativePath)) {
119
- continue;
120
- }
121
- collected.push({
122
- relativePath: normalizePathSeparators(relativePath),
123
- source: fs.readFileSync(absolutePath, "utf8"),
124
- });
125
- }
126
- }
127
- return collected.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
128
- }
129
- function getSourceLineNumber(source, index) {
130
- let line = 1;
131
- for (let cursor = 0; cursor < index; cursor += 1) {
132
- if (source[cursor] === "\n") {
133
- line += 1;
134
- }
135
- }
136
- return line;
137
- }
138
- function isGlobalDomAccessCandidate(source, index, identifier) {
139
- const lineStart = source.lastIndexOf("\n", index - 1) + 1;
140
- const lineEndCandidate = source.indexOf("\n", index);
141
- const lineEnd = lineEndCandidate === -1 ? source.length : lineEndCandidate;
142
- const lineSource = source.slice(lineStart, lineEnd);
143
- const trimmedLine = lineSource.trimStart();
144
- if (trimmedLine.startsWith("import ")) {
145
- return false;
146
- }
147
- if (trimmedLine.startsWith("const ") || trimmedLine.startsWith("let ") || trimmedLine.startsWith("var ")) {
148
- return false;
149
- }
150
- if (trimmedLine.startsWith("function ") || trimmedLine.startsWith("class ")) {
151
- return false;
152
- }
153
- const precedingCharacter = index > 0 ? source[index - 1] : "";
154
- if (precedingCharacter === "." || precedingCharacter === "'" || precedingCharacter === '"') {
155
- return false;
156
- }
157
- return (identifier === "document" ||
158
- identifier === "window" ||
159
- identifier === "parent" ||
160
- identifier === "top");
161
- }
162
- function findWorkspaceBlockGlobalDomAccesses(editorSources) {
163
- return editorSources.flatMap(({ relativePath, source }) => {
164
- const maskedSource = maskTypeScriptCommentsAndLiterals(source);
165
- const matches = maskedSource.matchAll(WORKSPACE_BLOCK_IFRAME_GLOBAL_DOM_PATTERN);
166
- const findings = [];
167
- for (const match of matches) {
168
- const identifier = match[0];
169
- const matchIndex = match.index ?? -1;
170
- if (matchIndex < 0) {
171
- continue;
172
- }
173
- if (!isGlobalDomAccessCandidate(source, matchIndex, identifier)) {
174
- continue;
175
- }
176
- findings.push(`${relativePath}:${getSourceLineNumber(source, matchIndex)}`);
177
- }
178
- return findings;
179
- });
180
- }
181
- function getWorkspaceBlockRequiredFiles(block) {
182
- const blockDir = path.join("src", "blocks", block.slug);
183
- return Array.from(new Set([
184
- block.typesFile,
185
- block.apiTypesFile,
186
- block.openApiFile,
187
- path.join(blockDir, "index.tsx"),
188
- ...WORKSPACE_GENERATED_BLOCK_ARTIFACTS.map((fileName) => path.join(blockDir, fileName)),
189
- ].filter((filePath) => typeof filePath === "string")));
190
- }
191
- function checkWorkspaceBlockMetadata(projectDir, workspace, block) {
192
- const blockJsonRelativePath = path.join("src", "blocks", block.slug, "block.json");
193
- const blockJsonPath = path.join(projectDir, blockJsonRelativePath);
194
- if (!fs.existsSync(blockJsonPath)) {
195
- return createDoctorCheck(`Block metadata ${block.slug}`, "fail", `Missing ${blockJsonRelativePath}`);
196
- }
197
- let blockJson;
198
- try {
199
- blockJson = parseScaffoldBlockMetadata(JSON.parse(fs.readFileSync(blockJsonPath, "utf8")));
200
- }
201
- catch (error) {
202
- return createDoctorCheck(`Block metadata ${block.slug}`, "fail", error instanceof Error ? error.message : String(error));
203
- }
204
- const expectedName = `${workspace.workspace.namespace}/${block.slug}`;
205
- const issues = [];
206
- if (blockJson.name !== expectedName) {
207
- issues.push(`block.json name must equal "${expectedName}"`);
208
- }
209
- if (blockJson.textdomain !== workspace.workspace.textDomain) {
210
- issues.push(`block.json textdomain must equal "${workspace.workspace.textDomain}"`);
211
- }
212
- return createDoctorCheck(`Block metadata ${block.slug}`, issues.length === 0 ? "pass" : "fail", issues.length === 0
213
- ? `block.json matches ${expectedName} and ${workspace.workspace.textDomain}`
214
- : issues.join("; "));
215
- }
216
- function checkWorkspaceBlockHooks(projectDir, blockSlug) {
217
- const blockJsonRelativePath = path.join("src", "blocks", blockSlug, "block.json");
218
- const blockJsonPath = path.join(projectDir, blockJsonRelativePath);
219
- if (!fs.existsSync(blockJsonPath)) {
220
- return createDoctorCheck(`Block hooks ${blockSlug}`, "fail", `Missing ${blockJsonRelativePath}`);
221
- }
222
- let blockJson;
223
- try {
224
- blockJson = parseScaffoldBlockMetadata(JSON.parse(fs.readFileSync(blockJsonPath, "utf8")));
225
- }
226
- catch (error) {
227
- return createDoctorCheck(`Block hooks ${blockSlug}`, "fail", error instanceof Error ? error.message : String(error));
228
- }
229
- const blockHooks = blockJson.blockHooks;
230
- if (blockHooks === undefined) {
231
- return createDoctorCheck(`Block hooks ${blockSlug}`, "pass", "No blockHooks metadata configured");
232
- }
233
- if (!blockHooks || typeof blockHooks !== "object" || Array.isArray(blockHooks)) {
234
- return createDoctorCheck(`Block hooks ${blockSlug}`, "fail", `${blockJsonRelativePath} must define blockHooks as an object when present.`);
235
- }
236
- const blockName = typeof blockJson.name === "string" && blockJson.name.trim().length > 0
237
- ? blockJson.name.trim()
238
- : null;
239
- const invalidEntries = Object.entries(blockHooks).filter(([anchor, position]) => (blockName !== null && anchor.trim() === blockName) ||
240
- anchor.trim().length === 0 ||
241
- anchor !== anchor.trim() ||
242
- !HOOKED_BLOCK_ANCHOR_PATTERN.test(anchor) ||
243
- typeof position !== "string" ||
244
- !HOOKED_BLOCK_POSITION_SET.has(position));
245
- return createDoctorCheck(`Block hooks ${blockSlug}`, invalidEntries.length === 0 ? "pass" : "fail", invalidEntries.length === 0
246
- ? `blockHooks metadata is valid${Object.keys(blockHooks).length > 0 ? ` (${Object.keys(blockHooks).join(", ")})` : ""}`
247
- : `Invalid blockHooks entries: ${invalidEntries
248
- .map(([anchor, position]) => `${anchor || "<empty>"} => ${String(position)}`)
249
- .join(", ")}`);
250
- }
251
- function checkWorkspaceBlockCollectionImport(projectDir, blockSlug) {
252
- const entryRelativePath = path.join("src", "blocks", blockSlug, "index.tsx");
253
- const entryPath = path.join(projectDir, entryRelativePath);
254
- if (!fs.existsSync(entryPath)) {
255
- return createDoctorCheck(`Block collection ${blockSlug}`, "fail", `Missing ${entryRelativePath}`);
256
- }
257
- const source = fs.readFileSync(entryPath, "utf8");
258
- const hasCollectionImport = WORKSPACE_COLLECTION_IMPORT_PATTERN.test(source);
259
- return createDoctorCheck(`Block collection ${blockSlug}`, hasCollectionImport ? "pass" : "fail", hasCollectionImport
260
- ? "Shared block collection import is present"
261
- : `Missing a shared collection import like ${WORKSPACE_COLLECTION_IMPORT_LINE}`);
262
- }
263
- function checkWorkspaceBlockIframeCompatibility(projectDir, blockSlug) {
264
- const metadataResult = readWorkspaceBlockIframeMetadata(projectDir, blockSlug);
265
- if (!metadataResult.document) {
266
- return [
267
- createDoctorCheck(`Block iframe/API v3 ${blockSlug}`, "warn", metadataResult.error ?? `Unable to inspect ${metadataResult.blockJsonRelativePath}`, WORKSPACE_BLOCK_IFRAME_DIAGNOSTIC_CODES.API_VERSION),
268
- ];
269
- }
270
- const blockJson = metadataResult.document;
271
- const apiVersion = typeof blockJson.apiVersion === "number" && Number.isFinite(blockJson.apiVersion)
272
- ? blockJson.apiVersion
273
- : null;
274
- const blockDir = path.join(projectDir, "src", "blocks", blockSlug);
275
- const localStyleFiles = WORKSPACE_BLOCK_LOCAL_STYLE_FILES.filter((fileName) => fs.existsSync(path.join(blockDir, fileName))).map((fileName) => normalizePathSeparators(path.join("src", "blocks", blockSlug, fileName)));
276
- const hasRegisteredEditorStyles = hasRegisteredBlockAsset(blockJson.style) ||
277
- hasRegisteredBlockAsset(blockJson.editorStyle);
278
- const editorSources = collectWorkspaceBlockEditorSources(projectDir, blockSlug);
279
- const editorWrapperSources = editorSources.filter((source) => !isWorkspaceBlockSaveSource(source.relativePath));
280
- const globalDomAccesses = findWorkspaceBlockGlobalDomAccesses(editorSources);
281
- const hasBlockPropsUsage = editorSources.some(({ source }) => hasExecutablePattern(source, WORKSPACE_BLOCK_PROPS_PATTERN));
282
- const hasEditorBlockPropsUsage = editorWrapperSources.some(({ source }) => hasExecutablePattern(source, WORKSPACE_BLOCK_PROPS_PATTERN));
283
- const blockWrapperStatus = editorWrapperSources.length === 0 || hasEditorBlockPropsUsage ? "pass" : "warn";
284
- const blockWrapperDetail = editorSources.length === 0
285
- ? "No editor-facing block source files found; general file checks will report missing entrypoints"
286
- : editorWrapperSources.length === 0
287
- ? "No editor wrapper source files found; general file checks will report missing entrypoints"
288
- : hasEditorBlockPropsUsage
289
- ? "Editor-facing sources use block wrapper props"
290
- : hasBlockPropsUsage
291
- ? "Only save-facing useBlockProps.save() usage was detected. Confirm the editor wrapper also receives useBlockProps() or useInnerBlocksProps() before relying on iframe editor rendering."
292
- : "No useBlockProps(), useBlockProps.save(), or useInnerBlocksProps() usage was detected in editor-facing sources. Confirm the block wrapper receives WordPress block editor props before relying on iframe editor rendering.";
293
- return [
294
- createDoctorCheck(`Block iframe API version ${blockSlug}`, apiVersion !== null && apiVersion >= 3 ? "pass" : "warn", apiVersion !== null && apiVersion >= 3
295
- ? "block.json declares apiVersion 3 for iframe editor readiness"
296
- : `Set ${metadataResult.blockJsonRelativePath} apiVersion to 3 after testing the block in iframe-enabled Post Editor and Site Editor contexts. WordPress recommends API v3 for iframe editor compatibility. See ${WORKSPACE_BLOCK_IFRAME_COMPATIBILITY_DOC_URL}`, WORKSPACE_BLOCK_IFRAME_DIAGNOSTIC_CODES.API_VERSION),
297
- createDoctorCheck(`Block iframe styles ${blockSlug}`, localStyleFiles.length === 0 || hasRegisteredEditorStyles ? "pass" : "warn", localStyleFiles.length === 0
298
- ? "No local block stylesheet source files found to register"
299
- : hasRegisteredEditorStyles
300
- ? "block.json registers block styles for iframe editor loading"
301
- : `Found stylesheet source files (${localStyleFiles.join(", ")}) but block.json does not declare style or editorStyle. Register block content styles so iframe editors do not depend on parent admin styles.`, WORKSPACE_BLOCK_IFRAME_DIAGNOSTIC_CODES.EDITOR_STYLES),
302
- createDoctorCheck(`Block iframe globals ${blockSlug}`, globalDomAccesses.length === 0 ? "pass" : "warn", globalDomAccesses.length === 0
303
- ? "No direct window/document/parent DOM access detected in editor-facing block sources"
304
- : `Direct global DOM access detected at ${globalDomAccesses.join(", ")}. Prefer element.ownerDocument/defaultView via refs or useRefEffect for iframe editor content.`, WORKSPACE_BLOCK_IFRAME_DIAGNOSTIC_CODES.EDITOR_GLOBALS),
305
- createDoctorCheck(`Block iframe wrapper ${blockSlug}`, blockWrapperStatus, blockWrapperDetail, WORKSPACE_BLOCK_IFRAME_DIAGNOSTIC_CODES.BLOCK_PROPS),
306
- ];
307
- }
308
- function checkWorkspacePatternBootstrap(projectDir, packageName) {
309
- const bootstrapPath = resolveWorkspaceBootstrapPath(projectDir, packageName);
310
- if (!fs.existsSync(bootstrapPath)) {
311
- return createDoctorCheck("Pattern bootstrap", "fail", `Missing ${path.basename(bootstrapPath)}`);
312
- }
313
- const source = fs.readFileSync(bootstrapPath, "utf8");
314
- const hasCategoryAnchor = source.includes("register_block_pattern_category");
315
- const hasPatternGlob = source.includes("/src/patterns/*.php");
316
- return createDoctorCheck("Pattern bootstrap", hasCategoryAnchor && hasPatternGlob ? "pass" : "fail", hasCategoryAnchor && hasPatternGlob
317
- ? "Pattern category and loader hooks are present"
318
- : "Missing pattern category registration or src/patterns loader hook");
319
- }
320
- function checkVariationEntrypoint(projectDir, blockSlug) {
321
- const entryPath = path.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
322
- if (!fs.existsSync(entryPath)) {
323
- return createDoctorCheck(`Variation entrypoint ${blockSlug}`, "fail", `Missing ${path.relative(projectDir, entryPath)}`);
324
- }
325
- const source = fs.readFileSync(entryPath, "utf8");
326
- const hasImport = hasUncommentedPattern(source, WORKSPACE_VARIATIONS_IMPORT_PATTERN);
327
- const hasCall = hasExecutablePattern(source, WORKSPACE_VARIATIONS_CALL_PATTERN);
328
- return createDoctorCheck(`Variation entrypoint ${blockSlug}`, hasImport && hasCall ? "pass" : "fail", hasImport && hasCall
329
- ? "Variations registration hook is present"
330
- : "Missing ./variations import or registerWorkspaceVariations() call");
331
- }
332
- function checkBlockStyleEntrypoint(projectDir, blockSlug) {
333
- const entryPath = path.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
334
- if (!fs.existsSync(entryPath)) {
335
- return createDoctorCheck(`Block style entrypoint ${blockSlug}`, "fail", `Missing ${path.relative(projectDir, entryPath)}`);
336
- }
337
- const source = fs.readFileSync(entryPath, "utf8");
338
- const hasImport = hasUncommentedPattern(source, WORKSPACE_BLOCK_STYLES_IMPORT_PATTERN);
339
- const hasCall = hasExecutablePattern(source, WORKSPACE_BLOCK_STYLES_CALL_PATTERN);
340
- return createDoctorCheck(`Block style entrypoint ${blockSlug}`, hasImport && hasCall ? "pass" : "fail", hasImport && hasCall
341
- ? "Block style registration hook is present"
342
- : "Missing ./styles import or registerWorkspaceBlockStyles() call");
343
- }
344
- function checkBlockTransformEntrypoint(projectDir, blockSlug) {
345
- const entryPath = path.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
346
- if (!fs.existsSync(entryPath)) {
347
- return createDoctorCheck(`Block transform entrypoint ${blockSlug}`, "fail", `Missing ${path.relative(projectDir, entryPath)}`);
348
- }
349
- const source = fs.readFileSync(entryPath, "utf8");
350
- const hasImport = hasUncommentedPattern(source, WORKSPACE_BLOCK_TRANSFORMS_IMPORT_PATTERN);
351
- const hasCall = hasExecutablePattern(source, WORKSPACE_BLOCK_TRANSFORMS_CALL_PATTERN);
352
- return createDoctorCheck(`Block transform entrypoint ${blockSlug}`, hasImport && hasCall ? "pass" : "fail", hasImport && hasCall
353
- ? "Block transform registration hook is present"
354
- : "Missing ./transforms import or applyWorkspaceBlockTransforms(registration.settings) call");
355
- }
356
- function checkBlockTransformConfig(workspace, transform) {
357
- const expectedTo = `${workspace.workspace.namespace}/${transform.block}`;
358
- const issues = [];
359
- if (!WORKSPACE_FULL_BLOCK_NAME_PATTERN.test(transform.from)) {
360
- issues.push("from must use full namespace/block format");
361
- }
362
- if (transform.to !== expectedTo) {
363
- issues.push(`to must equal "${expectedTo}" for workspace block "${transform.block}"`);
364
- }
365
- return createDoctorCheck(`Block transform config ${transform.block}/${transform.slug}`, issues.length === 0 ? "pass" : "fail", issues.length === 0
366
- ? `${transform.from} transforms into ${transform.to}`
367
- : issues.join("; "));
368
- }
1
+ import { getWorkspaceBlockAddonDoctorChecks, } from "./cli-doctor-workspace-block-addons.js";
2
+ import { getWorkspaceBlockIframeCompatibilityChecks, } from "./cli-doctor-workspace-block-iframe.js";
3
+ import { getWorkspaceBlockCoreDoctorChecks, } from "./cli-doctor-workspace-block-metadata.js";
369
4
  /**
370
5
  * Collect block-, variation-, transform-, and pattern-related workspace doctor checks.
371
6
  *
@@ -376,63 +11,10 @@ function checkBlockTransformConfig(workspace, transform) {
376
11
  export function getWorkspaceBlockDoctorChecks(workspace, inventory) {
377
12
  const checks = [];
378
13
  for (const block of inventory.blocks) {
379
- checks.push(checkExistingFiles(workspace.projectDir, `Block ${block.slug}`, getWorkspaceBlockRequiredFiles(block)));
380
- checks.push(checkWorkspaceBlockMetadata(workspace.projectDir, workspace, block));
381
- checks.push(checkWorkspaceBlockHooks(workspace.projectDir, block.slug));
382
- checks.push(checkWorkspaceBlockCollectionImport(workspace.projectDir, block.slug));
383
- checks.push(...checkWorkspaceBlockIframeCompatibility(workspace.projectDir, block.slug));
14
+ checks.push(...getWorkspaceBlockCoreDoctorChecks(workspace, block));
15
+ checks.push(...getWorkspaceBlockIframeCompatibilityChecks(workspace.projectDir, block.slug));
384
16
  }
385
17
  const registeredBlockSlugs = new Set(inventory.blocks.map((block) => block.slug));
386
- const variationTargetBlocks = new Set();
387
- for (const variation of inventory.variations) {
388
- if (!registeredBlockSlugs.has(variation.block)) {
389
- checks.push(createDoctorCheck(`Variation ${variation.block}/${variation.slug}`, "fail", `Variation references unknown block "${variation.block}"`));
390
- continue;
391
- }
392
- variationTargetBlocks.add(variation.block);
393
- checks.push(checkExistingFiles(workspace.projectDir, `Variation ${variation.block}/${variation.slug}`, [variation.file]));
394
- }
395
- for (const blockSlug of variationTargetBlocks) {
396
- checks.push(checkVariationEntrypoint(workspace.projectDir, blockSlug));
397
- }
398
- const blockStyleTargetBlocks = new Set();
399
- for (const blockStyle of inventory.blockStyles) {
400
- if (!registeredBlockSlugs.has(blockStyle.block)) {
401
- checks.push(createDoctorCheck(`Block style ${blockStyle.block}/${blockStyle.slug}`, "fail", `Block style references unknown block "${blockStyle.block}"`));
402
- continue;
403
- }
404
- blockStyleTargetBlocks.add(blockStyle.block);
405
- checks.push(checkExistingFiles(workspace.projectDir, `Block style ${blockStyle.block}/${blockStyle.slug}`, [blockStyle.file]));
406
- }
407
- for (const blockSlug of blockStyleTargetBlocks) {
408
- checks.push(checkExistingFiles(workspace.projectDir, `Block style registry ${blockSlug}`, [
409
- path.join("src", "blocks", blockSlug, "styles", "index.ts"),
410
- ]));
411
- checks.push(checkBlockStyleEntrypoint(workspace.projectDir, blockSlug));
412
- }
413
- const blockTransformTargetBlocks = new Set();
414
- for (const blockTransform of inventory.blockTransforms) {
415
- if (!registeredBlockSlugs.has(blockTransform.block)) {
416
- checks.push(createDoctorCheck(`Block transform ${blockTransform.block}/${blockTransform.slug}`, "fail", `Block transform references unknown block "${blockTransform.block}"`));
417
- continue;
418
- }
419
- blockTransformTargetBlocks.add(blockTransform.block);
420
- checks.push(checkBlockTransformConfig(workspace, blockTransform));
421
- checks.push(checkExistingFiles(workspace.projectDir, `Block transform ${blockTransform.block}/${blockTransform.slug}`, [blockTransform.file]));
422
- }
423
- for (const blockSlug of blockTransformTargetBlocks) {
424
- checks.push(checkExistingFiles(workspace.projectDir, `Block transform registry ${blockSlug}`, [
425
- path.join("src", "blocks", blockSlug, "transforms", "index.ts"),
426
- ]));
427
- checks.push(checkBlockTransformEntrypoint(workspace.projectDir, blockSlug));
428
- }
429
- const shouldCheckPatternBootstrap = inventory.patterns.length > 0 ||
430
- fs.existsSync(path.join(workspace.projectDir, "src", "patterns"));
431
- if (shouldCheckPatternBootstrap) {
432
- checks.push(checkWorkspacePatternBootstrap(workspace.projectDir, workspace.packageName));
433
- }
434
- for (const pattern of inventory.patterns) {
435
- checks.push(checkExistingFiles(workspace.projectDir, `Pattern ${pattern.slug}`, [pattern.file]));
436
- }
18
+ checks.push(...getWorkspaceBlockAddonDoctorChecks(workspace, inventory, registeredBlockSlugs));
437
19
  return checks;
438
20
  }
@@ -0,0 +1,11 @@
1
+ import type { DoctorCheck } from "./cli-doctor.js";
2
+ import type { WorkspaceInventory } from "./workspace-inventory.js";
3
+ import type { WorkspaceProject } from "./workspace-project.js";
4
+ /**
5
+ * Collect ability workspace doctor checks while preserving existing row order.
6
+ *
7
+ * @param workspace Resolved workspace metadata and filesystem paths.
8
+ * @param abilities Ability entries parsed from the workspace inventory.
9
+ * @returns Ordered ability doctor checks.
10
+ */
11
+ export declare function getWorkspaceAbilityDoctorChecks(workspace: WorkspaceProject, abilities: WorkspaceInventory["abilities"]): DoctorCheck[];