wp-typia 0.23.1 → 0.24.1

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.
@@ -4,6 +4,7 @@ var ADD_KIND_IDS = [
4
4
  "admin-view",
5
5
  "block",
6
6
  "integration-env",
7
+ "core-variation",
7
8
  "variation",
8
9
  "style",
9
10
  "transform",
@@ -20,4 +21,4 @@ var ADD_KIND_IDS = [
20
21
 
21
22
  export { ADD_KIND_IDS };
22
23
 
23
- //# debugId=C480D575E839E69A64756E2164756E21
24
+ //# debugId=39A9377B00AF01BA64756E2164756E21
@@ -1,15 +1,17 @@
1
1
  // @bun
2
2
  import {
3
+ assertPostMetaBindingPath,
3
4
  hasAdminViewManualSettingsRouteParameters,
4
5
  hasExecutablePattern,
5
6
  hasUncommentedPattern,
6
7
  isAdminViewManualSettingsRestResource,
8
+ loadPostMetaBindingFieldsSync,
7
9
  maskTypeScriptCommentsAndLiterals
8
- } from "./cli-j8et6jvr.js";
10
+ } from "./cli-z48frc8t.js";
9
11
  import {
10
12
  getBuiltInTemplateLayerDirs,
11
13
  isOmittableBuiltInTemplateLayerDir
12
- } from "./cli-nvs5atj1.js";
14
+ } from "./cli-gaq29kzp.js";
13
15
  import {
14
16
  isBuiltInTemplateId,
15
17
  listTemplates
@@ -24,14 +26,17 @@ import {
24
26
  REST_RESOURCE_NAMESPACE_PATTERN,
25
27
  assertValidPostMetaPostType,
26
28
  escapeRegex,
29
+ formatPatternCatalogDiagnostics,
27
30
  isGeneratedRestResourceRoutePatternCompatible,
28
31
  pathExists,
29
32
  readWorkspaceInventoryAsync,
30
- resolveEditorPluginSlotAlias
31
- } from "./cli-k5q5v8g6.js";
33
+ resolveEditorPluginSlotAlias,
34
+ resolvePatternCatalogContentFile,
35
+ validatePatternCatalog
36
+ } from "./cli-h2v72j8q.js";
32
37
  import"./cli-cvxvcw7c.js";
33
38
  import"./cli-t73q5aqz.js";
34
- import"./cli-43mx1vfb.js";
39
+ import"./cli-bajwv85z.js";
35
40
  import {
36
41
  CLI_DIAGNOSTIC_CODES,
37
42
  createCliCommandError,
@@ -282,6 +287,55 @@ function checkWorkspaceBindingTarget(projectDir, workspace, registeredBlockSlugs
282
287
  }
283
288
  return createDoctorCheck(`Binding target ${bindingSource.slug}`, issues.length === 0 ? "pass" : "fail", issues.length === 0 ? `${bindingSource.block}.${bindingSource.attribute} is declared and supported` : issues.join("; "));
284
289
  }
290
+ function checkWorkspaceBindingPostMeta(projectDir, inventory, bindingSource) {
291
+ if (!bindingSource.postMeta) {
292
+ return;
293
+ }
294
+ const postMeta = inventory.postMeta.find((entry) => entry.slug === bindingSource.postMeta);
295
+ if (!postMeta) {
296
+ return createDoctorCheck(`Binding post meta ${bindingSource.slug}`, "fail", `Binding source references unknown post meta contract "${bindingSource.postMeta}".`);
297
+ }
298
+ const issues = [];
299
+ try {
300
+ const fields = loadPostMetaBindingFieldsSync(projectDir, postMeta);
301
+ if (bindingSource.metaPath) {
302
+ assertPostMetaBindingPath(fields, postMeta.slug, bindingSource.metaPath);
303
+ }
304
+ } catch (error) {
305
+ issues.push(error instanceof Error ? error.message : String(error));
306
+ }
307
+ const serverPath = path3.join(projectDir, bindingSource.serverFile);
308
+ if (fs3.existsSync(serverPath)) {
309
+ const serverSource = fs3.readFileSync(serverPath, "utf8");
310
+ if (!serverSource.includes("get_post_meta")) {
311
+ issues.push(`${bindingSource.serverFile} must read post meta values`);
312
+ }
313
+ if (!serverSource.includes(postMeta.metaKey)) {
314
+ issues.push(`${bindingSource.serverFile} must reference ${postMeta.metaKey}`);
315
+ }
316
+ if (!serverSource.includes(postMeta.schemaFile)) {
317
+ issues.push(`${bindingSource.serverFile} must reference ${postMeta.schemaFile}`);
318
+ }
319
+ } else {
320
+ issues.push(`Missing ${bindingSource.serverFile}`);
321
+ }
322
+ const editorPath = path3.join(projectDir, bindingSource.editorFile);
323
+ if (fs3.existsSync(editorPath)) {
324
+ const editorSource = fs3.readFileSync(editorPath, "utf8");
325
+ if (!editorSource.includes("POST_META_BINDING_FIELDS")) {
326
+ issues.push(`${bindingSource.editorFile} must define post meta binding fields`);
327
+ }
328
+ if (!editorSource.includes(postMeta.schemaFile)) {
329
+ issues.push(`${bindingSource.editorFile} must reference ${postMeta.schemaFile}`);
330
+ }
331
+ if (bindingSource.metaPath && !editorSource.includes(bindingSource.metaPath)) {
332
+ issues.push(`${bindingSource.editorFile} must reference default meta path "${bindingSource.metaPath}"`);
333
+ }
334
+ } else {
335
+ issues.push(`Missing ${bindingSource.editorFile}`);
336
+ }
337
+ return createDoctorCheck(`Binding post meta ${bindingSource.slug}`, issues.length === 0 ? "pass" : "fail", issues.length === 0 ? `${bindingSource.slug} reads ${postMeta.slug} via ${postMeta.schemaFile}` : issues.join("; "));
338
+ }
285
339
  function getWorkspaceBindingDoctorChecks(workspace, inventory) {
286
340
  const checks = [];
287
341
  if (inventory.bindingSources.length > 0) {
@@ -298,6 +352,10 @@ function getWorkspaceBindingDoctorChecks(workspace, inventory) {
298
352
  if (bindingTargetCheck) {
299
353
  checks.push(bindingTargetCheck);
300
354
  }
355
+ const bindingPostMetaCheck = checkWorkspaceBindingPostMeta(workspace.projectDir, inventory, bindingSource);
356
+ if (bindingPostMetaCheck) {
357
+ checks.push(bindingPostMetaCheck);
358
+ }
301
359
  }
302
360
  return checks;
303
361
  }
@@ -311,7 +369,14 @@ var WORKSPACE_BLOCK_STYLES_IMPORT_PATTERN = /^\s*import\s*\{\s*registerWorkspace
311
369
  var WORKSPACE_BLOCK_STYLES_CALL_PATTERN = /registerWorkspaceBlockStyles\s*\(\s*\)\s*;?/u;
312
370
  var WORKSPACE_BLOCK_TRANSFORMS_IMPORT_PATTERN = /^\s*import\s*\{\s*applyWorkspaceBlockTransforms\s*\}\s*from\s*["']\.\/transforms["']\s*;?\s*$/mu;
313
371
  var WORKSPACE_BLOCK_TRANSFORMS_CALL_PATTERN = /applyWorkspaceBlockTransforms\s*\(\s*registration\s*\.\s*settings\s*\)\s*;?/u;
314
- function checkWorkspacePatternBootstrap(projectDir, packageName) {
372
+ function isNestedPatternContentFile(patternFile) {
373
+ if (!patternFile) {
374
+ return false;
375
+ }
376
+ const normalizedPath = patternFile.replace(/\\/gu, "/");
377
+ return normalizedPath.startsWith("src/patterns/") && normalizedPath.slice("src/patterns/".length).includes("/");
378
+ }
379
+ function checkWorkspacePatternBootstrap(projectDir, packageName, requiresNestedPatternGlob) {
315
380
  const bootstrapPath = resolveWorkspaceBootstrapPath(projectDir, packageName);
316
381
  if (!fs4.existsSync(bootstrapPath)) {
317
382
  return createDoctorCheck("Pattern bootstrap", "fail", `Missing ${path4.basename(bootstrapPath)}`);
@@ -319,7 +384,9 @@ function checkWorkspacePatternBootstrap(projectDir, packageName) {
319
384
  const source = fs4.readFileSync(bootstrapPath, "utf8");
320
385
  const hasCategoryAnchor = source.includes("register_block_pattern_category");
321
386
  const hasPatternGlob = source.includes("/src/patterns/*.php");
322
- return createDoctorCheck("Pattern bootstrap", hasCategoryAnchor && hasPatternGlob ? "pass" : "fail", hasCategoryAnchor && hasPatternGlob ? "Pattern category and loader hooks are present" : "Missing pattern category registration or src/patterns loader hook");
387
+ const hasNestedPatternGlob = source.includes("/src/patterns/*/*.php");
388
+ const hasRequiredPatternGlobs = hasPatternGlob && (!requiresNestedPatternGlob || hasNestedPatternGlob);
389
+ return createDoctorCheck("Pattern bootstrap", hasCategoryAnchor && hasRequiredPatternGlobs ? "pass" : "fail", hasCategoryAnchor && hasRequiredPatternGlobs ? "Pattern category and loader hooks are present" : requiresNestedPatternGlob ? "Missing pattern category registration or nested src/patterns loader hook" : "Missing pattern category registration or src/patterns loader hook");
323
390
  }
324
391
  function checkVariationEntrypoint(projectDir, blockSlug) {
325
392
  const entryPath = path4.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
@@ -409,10 +476,19 @@ function getWorkspaceBlockAddonDoctorChecks(workspace, inventory, registeredBloc
409
476
  }
410
477
  const shouldCheckPatternBootstrap = inventory.patterns.length > 0 || fs4.existsSync(path4.join(workspace.projectDir, "src", "patterns"));
411
478
  if (shouldCheckPatternBootstrap) {
412
- checks.push(checkWorkspacePatternBootstrap(workspace.projectDir, workspace.packageName));
479
+ const requiresNestedPatternGlob = inventory.patterns.some((pattern) => isNestedPatternContentFile(resolvePatternCatalogContentFile(pattern)));
480
+ checks.push(checkWorkspacePatternBootstrap(workspace.projectDir, workspace.packageName, requiresNestedPatternGlob));
481
+ }
482
+ if (inventory.patterns.length > 0) {
483
+ const catalogValidation = validatePatternCatalog(inventory.patterns, {
484
+ projectDir: workspace.projectDir
485
+ });
486
+ checks.push(createDoctorCheck("Pattern catalog", catalogValidation.errors.length > 0 ? "fail" : catalogValidation.warnings.length > 0 ? "warn" : "pass", catalogValidation.diagnostics.length > 0 ? formatPatternCatalogDiagnostics(catalogValidation.diagnostics) : "Pattern catalog metadata is valid"));
413
487
  }
414
488
  for (const pattern of inventory.patterns) {
415
- checks.push(checkExistingFiles(workspace.projectDir, `Pattern ${pattern.slug}`, [pattern.file]));
489
+ checks.push(checkExistingFiles(workspace.projectDir, `Pattern ${pattern.slug}`, [
490
+ resolvePatternCatalogContentFile(pattern)
491
+ ]));
416
492
  }
417
493
  return checks;
418
494
  }
@@ -1268,6 +1344,16 @@ async function getWorkspaceDoctorChecks(cwd) {
1268
1344
 
1269
1345
  // ../wp-typia-project-tools/src/runtime/cli-doctor.ts
1270
1346
  var DEFAULT_DOCTOR_EXIT_POLICY = "strict";
1347
+ var defaultDoctorLinePrinter = (line) => {
1348
+ process.stdout.write(`${line}
1349
+ `);
1350
+ };
1351
+ function renderDefaultDoctorCheckLine(check) {
1352
+ defaultDoctorLinePrinter(formatDoctorCheckLine(check));
1353
+ }
1354
+ function renderDefaultDoctorSummaryLine(summaryLine) {
1355
+ defaultDoctorLinePrinter(summaryLine);
1356
+ }
1271
1357
  function annotateDoctorChecks(checks, scope) {
1272
1358
  return checks.map((check) => ({
1273
1359
  ...check,
@@ -1328,10 +1414,10 @@ function createDoctorRunSummary(checks, options = {}) {
1328
1414
  }
1329
1415
  async function runDoctor(cwd, options = {}) {
1330
1416
  const exitPolicy = resolveDoctorExitPolicy(options);
1331
- const renderLine = options.renderLine ?? ((check) => console.log(formatDoctorCheckLine(check)));
1417
+ const renderLine = options.renderLine ?? renderDefaultDoctorCheckLine;
1332
1418
  const renderSummaryLine = options.renderSummaryLine ?? (options.renderLine ? () => {
1333
1419
  return;
1334
- } : (summaryLine) => console.log(summaryLine));
1420
+ } : renderDefaultDoctorSummaryLine);
1335
1421
  const checks = await getDoctorChecks(cwd);
1336
1422
  for (const check of checks) {
1337
1423
  renderLine(check);
@@ -1357,4 +1443,4 @@ export {
1357
1443
  createDoctorRunSummary
1358
1444
  };
1359
1445
 
1360
- //# debugId=3074C8F7DE85281764756E2164756E21
1446
+ //# debugId=7D607F817A3CF55764756E2164756E21
@@ -47,7 +47,7 @@ import {
47
47
  } from "./cli-e4bwd81c.js";
48
48
  import {
49
49
  readWorkspaceInventory
50
- } from "./cli-k5q5v8g6.js";
50
+ } from "./cli-h2v72j8q.js";
51
51
  import {
52
52
  getInvalidWorkspaceProjectReason,
53
53
  tryResolveWorkspaceProject
@@ -11,7 +11,7 @@ import {
11
11
  } from "./cli-8hxf9qw6.js";
12
12
  import {
13
13
  pathExists
14
- } from "./cli-k5q5v8g6.js";
14
+ } from "./cli-h2v72j8q.js";
15
15
  import {
16
16
  createManagedTempRoot
17
17
  } from "./cli-t73q5aqz.js";