@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.
- package/dist/runtime/ai-feature-artifacts.js +4 -1
- package/dist/runtime/block-generator-service-spec.js +2 -1
- package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
- package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
- package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
- package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
- package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
- package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
- package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
- package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
- package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
- package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
- package/dist/runtime/cli-add-block-json.js +5 -1
- package/dist/runtime/cli-add-collision.js +8 -0
- package/dist/runtime/cli-add-help.js +14 -10
- package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
- package/dist/runtime/cli-add-kind-ids.js +1 -0
- package/dist/runtime/cli-add-types.d.ts +45 -6
- package/dist/runtime/cli-add-types.js +2 -0
- package/dist/runtime/cli-add-validation.d.ts +7 -0
- package/dist/runtime/cli-add-validation.js +9 -0
- package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
- package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
- package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
- package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
- package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -2
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
- package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
- package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
- package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
- package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
- package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
- package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
- package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
- package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
- package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
- package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
- package/dist/runtime/cli-add-workspace-assets.js +6 -950
- package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
- package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
- package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
- package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
- package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
- package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-block-style.js +148 -0
- package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
- package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
- package/dist/runtime/cli-add-workspace-contract.js +1 -1
- package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
- package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
- package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
- package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
- package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
- package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
- package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
- package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
- package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
- package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
- package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
- package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
- package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
- package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
- package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
- package/dist/runtime/cli-add-workspace-pattern.js +99 -0
- package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
- package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
- package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
- package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
- package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
- package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
- package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
- package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
- package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
- package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
- package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
- package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
- package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
- package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
- package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
- package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
- package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
- package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
- package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
- package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
- package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
- package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
- package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
- package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
- package/dist/runtime/cli-add-workspace-rest.js +33 -788
- package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-variation.js +162 -0
- package/dist/runtime/cli-add-workspace.d.ts +42 -107
- package/dist/runtime/cli-add-workspace.js +42 -674
- package/dist/runtime/cli-add.d.ts +3 -3
- package/dist/runtime/cli-add.js +2 -2
- package/dist/runtime/cli-core.d.ts +3 -2
- package/dist/runtime/cli-core.js +2 -2
- package/dist/runtime/cli-diagnostics.d.ts +3 -1
- package/dist/runtime/cli-diagnostics.js +17 -5
- package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
- package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
- package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
- package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
- package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
- package/dist/runtime/cli-doctor-workspace-features.js +14 -487
- package/dist/runtime/cli-doctor.d.ts +54 -3
- package/dist/runtime/cli-doctor.js +92 -10
- package/dist/runtime/cli-help.js +12 -7
- package/dist/runtime/cli-init-package-json.js +4 -2
- package/dist/runtime/cli-prompt.d.ts +16 -2
- package/dist/runtime/cli-prompt.js +29 -12
- package/dist/runtime/cli-scaffold.d.ts +2 -1
- package/dist/runtime/cli-scaffold.js +19 -10
- package/dist/runtime/external-template-guards.js +4 -6
- package/dist/runtime/index.d.ts +6 -3
- package/dist/runtime/index.js +4 -2
- package/dist/runtime/json-utils.d.ts +62 -4
- package/dist/runtime/json-utils.js +78 -4
- package/dist/runtime/local-dev-presets.js +6 -2
- package/dist/runtime/migration-ui-capability.js +4 -1
- package/dist/runtime/migration-utils.js +4 -1
- package/dist/runtime/package-managers.js +6 -1
- package/dist/runtime/package-versions.d.ts +1 -0
- package/dist/runtime/package-versions.js +16 -3
- package/dist/runtime/pattern-catalog.d.ts +122 -0
- package/dist/runtime/pattern-catalog.js +471 -0
- package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
- package/dist/runtime/post-meta-binding-fields.js +135 -0
- package/dist/runtime/scaffold-bootstrap.js +7 -2
- package/dist/runtime/scaffold-package-manager-files.js +5 -1
- package/dist/runtime/scaffold-repository-reference.js +4 -2
- package/dist/runtime/scaffold-template-variables.js +2 -1
- package/dist/runtime/scaffold.d.ts +18 -1
- package/dist/runtime/scaffold.js +55 -2
- package/dist/runtime/temp-roots.js +4 -1
- package/dist/runtime/template-layers.js +4 -1
- package/dist/runtime/template-registry.js +9 -3
- package/dist/runtime/template-source-contracts.d.ts +2 -0
- package/dist/runtime/template-source-normalization.js +2 -1
- package/dist/runtime/template-source-remote.js +18 -5
- package/dist/runtime/template-source-seeds.js +10 -3
- package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
- package/dist/runtime/typia-llm-json-schema.js +33 -0
- package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
- package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
- package/dist/runtime/typia-llm-projection.d.ts +25 -0
- package/dist/runtime/typia-llm-projection.js +58 -0
- package/dist/runtime/typia-llm-render.d.ts +21 -0
- package/dist/runtime/typia-llm-render.js +252 -0
- package/dist/runtime/typia-llm-sync.d.ts +10 -0
- package/dist/runtime/typia-llm-sync.js +63 -0
- package/dist/runtime/typia-llm-types.d.ts +197 -0
- package/dist/runtime/typia-llm-types.js +1 -0
- package/dist/runtime/typia-llm.d.ts +9 -255
- package/dist/runtime/typia-llm.js +5 -634
- package/dist/runtime/workspace-inventory-mutations.js +15 -1
- package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
- package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
- package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
- package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
- package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
- package/dist/runtime/workspace-inventory-parser.js +3 -581
- package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
- package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
- package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
- package/dist/runtime/workspace-inventory-templates.js +10 -1
- package/dist/runtime/workspace-inventory-types.d.ts +10 -1
- package/dist/runtime/workspace-project.js +4 -6
- package/package.json +8 -3
- package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
- package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
- package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
- package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
|
@@ -1,7 +1,81 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { promises as fsp } from "node:fs";
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* runtime
|
|
4
|
+
* JSON helpers shared by project-tools runtime modules.
|
|
5
|
+
*
|
|
6
|
+
* File-backed runtime JSON readers should use `safeJsonParse`,
|
|
7
|
+
* `readJsonFileSync`, or `readJsonFile` so malformed JSON reports the file path
|
|
8
|
+
* and operation context. Raw `JSON.parse` remains intentional for trusted
|
|
9
|
+
* in-memory clones, subprocess output, test fixtures, generated workspace
|
|
10
|
+
* script templates that embed their own path-aware parse handling,
|
|
11
|
+
* package-version manifest cache probes with colocated path-aware wrappers,
|
|
12
|
+
* and cache/discovery probes that immediately catch malformed documents to
|
|
13
|
+
* continue with fallback behavior.
|
|
14
|
+
*
|
|
15
|
+
* This module keeps `cloneJsonValue` local instead of re-exporting the
|
|
16
|
+
* block-runtime helper so Bunli CLI bundles that only need project-tools JSON
|
|
17
|
+
* readers do not need to resolve the block-runtime subpath at runtime.
|
|
18
|
+
*
|
|
5
19
|
* @module
|
|
6
20
|
*/
|
|
7
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Create a deep clone of a JSON-serializable value.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Values that are not JSON-serializable, such as functions, `undefined`,
|
|
26
|
+
* `BigInt`, class instances, and `Date` objects, are not preserved faithfully.
|
|
27
|
+
*
|
|
28
|
+
* @param value JSON-compatible data to clone.
|
|
29
|
+
* @returns A deep-cloned copy created with `JSON.parse(JSON.stringify(...))`.
|
|
30
|
+
*/
|
|
31
|
+
export function cloneJsonValue(value) {
|
|
32
|
+
return JSON.parse(JSON.stringify(value));
|
|
33
|
+
}
|
|
34
|
+
function formatJsonParseTarget({ context, filePath }) {
|
|
35
|
+
const operation = context?.trim() || "JSON";
|
|
36
|
+
return filePath ? `${operation} at ${filePath}` : operation;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parse JSON and include operation/file context when decoding fails.
|
|
40
|
+
*
|
|
41
|
+
* @param source Raw JSON source text.
|
|
42
|
+
* @param options Optional file path and human-readable operation context.
|
|
43
|
+
* @returns Parsed JSON value cast to the caller-specified type.
|
|
44
|
+
* @throws {Error} When the source is malformed JSON.
|
|
45
|
+
*/
|
|
46
|
+
export function safeJsonParse(source, options = {}) {
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(source);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Failed to parse ${formatJsonParseTarget(options)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Read and parse a JSON file synchronously with path-aware parse errors.
|
|
56
|
+
*
|
|
57
|
+
* @param filePath JSON file path to read.
|
|
58
|
+
* @param options Optional parse context. `filePath` is always set from the
|
|
59
|
+
* reader argument.
|
|
60
|
+
* @returns Parsed JSON value cast to the caller-specified type.
|
|
61
|
+
*/
|
|
62
|
+
export function readJsonFileSync(filePath, options = {}) {
|
|
63
|
+
return safeJsonParse(fs.readFileSync(filePath, "utf8"), {
|
|
64
|
+
...options,
|
|
65
|
+
filePath,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Read and parse a JSON file asynchronously with path-aware parse errors.
|
|
70
|
+
*
|
|
71
|
+
* @param filePath JSON file path to read.
|
|
72
|
+
* @param options Optional parse context. `filePath` is always set from the
|
|
73
|
+
* reader argument.
|
|
74
|
+
* @returns Parsed JSON value cast to the caller-specified type.
|
|
75
|
+
*/
|
|
76
|
+
export async function readJsonFile(filePath, options = {}) {
|
|
77
|
+
return safeJsonParse(await fsp.readFile(filePath, "utf8"), {
|
|
78
|
+
...options,
|
|
79
|
+
filePath,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -8,6 +8,8 @@ import fs from "node:fs";
|
|
|
8
8
|
import { promises as fsp } from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { formatRunScript, } from "./package-managers.js";
|
|
11
|
+
import { DEFAULT_WORDPRESS_ENV_VERSION } from "./package-versions.js";
|
|
12
|
+
import { readJsonFile } from "./json-utils.js";
|
|
11
13
|
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, SHARED_TEST_PRESET_TEMPLATE_ROOT, SHARED_WP_ENV_PRESET_TEMPLATE_ROOT, } from "./template-registry.js";
|
|
12
14
|
import { copyInterpolatedDirectory } from "./template-render.js";
|
|
13
15
|
function templateHasPersistenceSync(templateId, compoundPersistenceEnabled) {
|
|
@@ -54,7 +56,9 @@ function getDevScript(packageManager, compoundPersistenceEnabled, templateId) {
|
|
|
54
56
|
}
|
|
55
57
|
async function mutatePackageJson(projectDir, mutate) {
|
|
56
58
|
const packageJsonPath = path.join(projectDir, "package.json");
|
|
57
|
-
const packageJson =
|
|
59
|
+
const packageJson = await readJsonFile(packageJsonPath, {
|
|
60
|
+
context: "local dev package manifest",
|
|
61
|
+
});
|
|
58
62
|
mutate(packageJson);
|
|
59
63
|
await fsp.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, "\t")}\n`, "utf8");
|
|
60
64
|
}
|
|
@@ -103,7 +107,7 @@ export async function applyGeneratedProjectDxPackageJson({ compoundPersistenceEn
|
|
|
103
107
|
: {}),
|
|
104
108
|
};
|
|
105
109
|
if (withWpEnv || withTestPreset) {
|
|
106
|
-
packageJson.devDependencies["@wordpress/env"] =
|
|
110
|
+
packageJson.devDependencies["@wordpress/env"] = DEFAULT_WORDPRESS_ENV_VERSION;
|
|
107
111
|
}
|
|
108
112
|
if (withTestPreset) {
|
|
109
113
|
packageJson.devDependencies["@playwright/test"] = "^1.54.2";
|
|
@@ -2,6 +2,7 @@ import { promises as fsp } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { getPackageVersions } from "./package-versions.js";
|
|
4
4
|
import { formatPackageExecCommand } from "./package-managers.js";
|
|
5
|
+
import { readJsonFile } from "./json-utils.js";
|
|
5
6
|
import { seedProjectMigrations } from "./migrations.js";
|
|
6
7
|
import { copyInterpolatedDirectory } from "./template-render.js";
|
|
7
8
|
import { SHARED_MIGRATION_UI_TEMPLATE_ROOT, } from "./template-registry.js";
|
|
@@ -10,7 +11,9 @@ const BLOCK_METADATA_IMPORT_LINE = "import metadata from './block-metadata';";
|
|
|
10
11
|
const LEGACY_BLOCK_JSON_IMPORT_LINE = "import metadata from './block.json';";
|
|
11
12
|
async function mutatePackageJson(projectDir, mutate) {
|
|
12
13
|
const packageJsonPath = path.join(projectDir, "package.json");
|
|
13
|
-
const packageJson =
|
|
14
|
+
const packageJson = await readJsonFile(packageJsonPath, {
|
|
15
|
+
context: "migration UI package manifest",
|
|
16
|
+
});
|
|
14
17
|
mutate(packageJson);
|
|
15
18
|
await fsp.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, "\t")}\n`, "utf8");
|
|
16
19
|
}
|
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { execSync } from 'node:child_process';
|
|
4
4
|
import { formatRunScript, inferPackageManagerId, parsePackageManagerField, } from './package-managers.js';
|
|
5
5
|
import { isPlainObject } from './object-utils.js';
|
|
6
|
+
import { readJsonFileSync } from './json-utils.js';
|
|
6
7
|
export { cloneJsonValue } from './json-utils.js';
|
|
7
8
|
const MIGRATION_VERSION_LABEL_PATTERN = /^v([1-9]\d*)$/;
|
|
8
9
|
const LEGACY_SEMVER_MIGRATION_VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
|
|
@@ -66,7 +67,9 @@ export function createTransformFixtureValue(attribute, pathLabel) {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
export function readJson(filePath) {
|
|
69
|
-
return
|
|
70
|
+
return readJsonFileSync(filePath, {
|
|
71
|
+
context: 'migration JSON file',
|
|
72
|
+
});
|
|
70
73
|
}
|
|
71
74
|
export function renderPhpValue(value, indentLevel) {
|
|
72
75
|
const indent = '\t'.repeat(indentLevel);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { readJsonFileSync } from "./json-utils.js";
|
|
3
4
|
const PACKAGE_MANAGER_DATA = [
|
|
4
5
|
{
|
|
5
6
|
id: "bun",
|
|
@@ -73,12 +74,16 @@ function readPackageManagerField(projectDir) {
|
|
|
73
74
|
if (!fs.existsSync(packageJsonPath)) {
|
|
74
75
|
return undefined;
|
|
75
76
|
}
|
|
76
|
-
const manifest =
|
|
77
|
+
const manifest = readJsonFileSync(packageJsonPath, {
|
|
78
|
+
context: "package manager manifest",
|
|
79
|
+
});
|
|
77
80
|
return typeof manifest.packageManager === "string"
|
|
78
81
|
? manifest.packageManager
|
|
79
82
|
: undefined;
|
|
80
83
|
}
|
|
81
84
|
catch {
|
|
85
|
+
// Package manager inference intentionally falls back to lockfile signals
|
|
86
|
+
// when package.json is absent or malformed.
|
|
82
87
|
return undefined;
|
|
83
88
|
}
|
|
84
89
|
}
|
|
@@ -23,6 +23,7 @@ export declare const DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION = "^0.9.0";
|
|
|
23
23
|
export declare const DEFAULT_WORDPRESS_CORE_DATA_VERSION = "^7.44.0";
|
|
24
24
|
export declare const DEFAULT_WORDPRESS_DATA_VERSION = "^9.28.0";
|
|
25
25
|
export declare const DEFAULT_WORDPRESS_DATAVIEWS_VERSION = "^14.1.0";
|
|
26
|
+
export declare const DEFAULT_WORDPRESS_ENV_VERSION = "^11.2.0";
|
|
26
27
|
export declare const DEFAULT_WP_TYPIA_DATAVIEWS_VERSION = "^0.1.1";
|
|
27
28
|
/**
|
|
28
29
|
* Resolve a managed package version range from linked workspace packages first,
|
|
@@ -20,6 +20,7 @@ export const DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION = '^0.9.0';
|
|
|
20
20
|
export const DEFAULT_WORDPRESS_CORE_DATA_VERSION = '^7.44.0';
|
|
21
21
|
export const DEFAULT_WORDPRESS_DATA_VERSION = '^9.28.0';
|
|
22
22
|
export const DEFAULT_WORDPRESS_DATAVIEWS_VERSION = '^14.1.0';
|
|
23
|
+
export const DEFAULT_WORDPRESS_ENV_VERSION = '^11.2.0';
|
|
23
24
|
export const DEFAULT_WP_TYPIA_DATAVIEWS_VERSION = '^0.1.1';
|
|
24
25
|
let cachedPackageVersions = null;
|
|
25
26
|
function normalizeVersionRange(value) {
|
|
@@ -92,7 +93,12 @@ function readPackageManifest(location) {
|
|
|
92
93
|
if (!location.packageJsonPath || location.source === null) {
|
|
93
94
|
return null;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
+
try {
|
|
97
|
+
return JSON.parse(location.source);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
throw new Error(`Failed to parse package version manifest at ${location.packageJsonPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
101
|
+
}
|
|
96
102
|
}
|
|
97
103
|
function tryReadPackageManifest(location) {
|
|
98
104
|
if (!location) {
|
|
@@ -170,6 +176,7 @@ export function getPackageVersions() {
|
|
|
170
176
|
const createManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, 'package.json'));
|
|
171
177
|
const monorepoManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, '..', '..', 'package.json'));
|
|
172
178
|
const blockRuntimeManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, '..', 'wp-typia-block-runtime', 'package.json'));
|
|
179
|
+
const blockTypesManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, '..', 'wp-typia-block-types', 'package.json'));
|
|
173
180
|
const wpTypiaManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, '..', 'wp-typia', 'package.json'));
|
|
174
181
|
const installedProjectToolsManifestLocation = resolveInstalledPackageManifestLocation('@wp-typia/project-tools');
|
|
175
182
|
const installedApiClientManifestLocation = resolveInstalledPackageManifestLocation('@wp-typia/api-client');
|
|
@@ -185,6 +192,7 @@ export function getPackageVersions() {
|
|
|
185
192
|
createManifestLocation,
|
|
186
193
|
monorepoManifestLocation,
|
|
187
194
|
blockRuntimeManifestLocation,
|
|
195
|
+
blockTypesManifestLocation,
|
|
188
196
|
wpTypiaManifestLocation,
|
|
189
197
|
installedProjectToolsManifestLocation,
|
|
190
198
|
installedApiClientManifestLocation,
|
|
@@ -207,18 +215,23 @@ export function getPackageVersions() {
|
|
|
207
215
|
const blockRuntimeManifest = readPackageManifest(blockRuntimeManifestLocation) ??
|
|
208
216
|
readPackageManifest(installedBlockRuntimeManifestLocation) ??
|
|
209
217
|
{};
|
|
218
|
+
const blockTypesManifest = readPackageManifest(blockTypesManifestLocation) ??
|
|
219
|
+
readPackageManifest(installedBlockTypesManifestLocation) ??
|
|
220
|
+
{};
|
|
210
221
|
const wpTypiaManifest = readPackageManifest(wpTypiaManifestLocation) ??
|
|
211
222
|
readPackageManifest(installedWpTypiaManifestLocation) ??
|
|
212
223
|
{};
|
|
213
224
|
const blockRuntimeDependencyVersion = normalizeVersionRange(createManifest.dependencies?.['@wp-typia/block-runtime']);
|
|
225
|
+
const blockTypesDependencyVersion = normalizeVersionRange(createManifest.dependencies?.['@wp-typia/block-types']);
|
|
214
226
|
const versions = {
|
|
215
227
|
apiClientPackageVersion: normalizeVersionRange(createManifest.dependencies?.['@wp-typia/api-client'] ??
|
|
216
228
|
readPackageManifest(installedApiClientManifestLocation)?.version),
|
|
217
229
|
blockRuntimePackageVersion: blockRuntimeDependencyVersion !== DEFAULT_VERSION_RANGE
|
|
218
230
|
? blockRuntimeDependencyVersion
|
|
219
231
|
: normalizeVersionRange(blockRuntimeManifest.version),
|
|
220
|
-
blockTypesPackageVersion:
|
|
221
|
-
|
|
232
|
+
blockTypesPackageVersion: blockTypesDependencyVersion !== DEFAULT_VERSION_RANGE
|
|
233
|
+
? blockTypesDependencyVersion
|
|
234
|
+
: normalizeVersionRange(blockTypesManifest.version),
|
|
222
235
|
projectToolsPackageVersion: normalizeVersionRange(createManifest.version),
|
|
223
236
|
restPackageVersion: normalizeVersionRange(createManifest.dependencies?.['@wp-typia/rest'] ??
|
|
224
237
|
readPackageManifest(installedRestManifestLocation)?.version),
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { type ParsedBlockPatternBlock } from "@wp-typia/block-runtime/metadata-core";
|
|
2
|
+
export declare const PATTERN_CATALOG_SCOPE_IDS: readonly ["full", "section"];
|
|
3
|
+
export type PatternCatalogScope = (typeof PATTERN_CATALOG_SCOPE_IDS)[number];
|
|
4
|
+
export type PatternCatalogEntry = {
|
|
5
|
+
contentFile?: string;
|
|
6
|
+
file?: string;
|
|
7
|
+
scope?: string;
|
|
8
|
+
sectionRole?: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
tags?: readonly string[];
|
|
11
|
+
thumbnailUrl?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
};
|
|
14
|
+
export type PatternCatalogDiagnosticSeverity = "error" | "warning";
|
|
15
|
+
export type PatternCatalogDiagnosticCode = "duplicate-pattern-slug" | "invalid-pattern-content-file" | "invalid-pattern-scope" | "invalid-pattern-section-role" | "invalid-pattern-section-role-convention" | "invalid-pattern-section-role-marker" | "invalid-pattern-slug" | "invalid-pattern-tag" | "invalid-pattern-thumbnail-url" | "mismatched-pattern-section-role" | "missing-pattern-content-file" | "missing-pattern-section-role" | "missing-pattern-section-role-marker" | "duplicate-pattern-section-role-marker" | "unknown-pattern-section-role-marker";
|
|
16
|
+
export type PatternCatalogDiagnostic = {
|
|
17
|
+
code: PatternCatalogDiagnosticCode;
|
|
18
|
+
message: string;
|
|
19
|
+
patternSlug?: string;
|
|
20
|
+
severity: PatternCatalogDiagnosticSeverity;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Convention used to discover section role markers in serialized pattern
|
|
24
|
+
* content. Defaults target `core/group` wrappers with a `section` base class,
|
|
25
|
+
* `section--{role}` role class tokens, and `metadata.sectionRole` attributes.
|
|
26
|
+
*/
|
|
27
|
+
export type PatternCatalogSectionRoleConvention = {
|
|
28
|
+
/**
|
|
29
|
+
* Serialized block name used as the section wrapper. Defaults to
|
|
30
|
+
* `core/group`.
|
|
31
|
+
*/
|
|
32
|
+
wrapperBlockName?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional class that marks a wrapper block as section-like even when the
|
|
35
|
+
* role marker is missing. Defaults to `section`.
|
|
36
|
+
*/
|
|
37
|
+
baseClassName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Class token pattern where exactly one `{role}` placeholder is replaced by
|
|
40
|
+
* the section role slug. Defaults to `section--{role}`.
|
|
41
|
+
*/
|
|
42
|
+
roleClassNamePattern?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Dot-separated block attribute paths that can carry role slugs. Defaults to
|
|
45
|
+
* `metadata.sectionRole`.
|
|
46
|
+
*/
|
|
47
|
+
roleAttributePaths?: readonly string[];
|
|
48
|
+
/**
|
|
49
|
+
* Warn when a full pattern repeats the same section role marker. Defaults to
|
|
50
|
+
* `false`.
|
|
51
|
+
*/
|
|
52
|
+
requireUniqueFullPatternRoles?: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Section wrapper match extracted from a parsed WordPress block tree.
|
|
56
|
+
*/
|
|
57
|
+
export type PatternCatalogSectionRoleMatch = {
|
|
58
|
+
blockName: string;
|
|
59
|
+
blockPath: string;
|
|
60
|
+
roles: readonly string[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Options for validating typed pattern catalog entries and, when `projectDir`
|
|
64
|
+
* is provided, their serialized pattern content. Set `sectionRoleConvention` to
|
|
65
|
+
* `false` to keep file existence checks but opt out of section-role marker
|
|
66
|
+
* validation.
|
|
67
|
+
*/
|
|
68
|
+
export type PatternCatalogValidationOptions = {
|
|
69
|
+
projectDir?: string;
|
|
70
|
+
sectionRoleConvention?: PatternCatalogSectionRoleConvention | false;
|
|
71
|
+
};
|
|
72
|
+
export type PatternCatalogValidationResult = {
|
|
73
|
+
diagnostics: PatternCatalogDiagnostic[];
|
|
74
|
+
errors: PatternCatalogDiagnostic[];
|
|
75
|
+
warnings: PatternCatalogDiagnostic[];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Extract section role slugs from serialized block attributes using the
|
|
79
|
+
* configured class and metadata marker convention.
|
|
80
|
+
*
|
|
81
|
+
* @param attributes Parsed block attributes from serialized pattern content.
|
|
82
|
+
* @param convention Optional marker convention override.
|
|
83
|
+
* @returns Unique role marker values in discovery order.
|
|
84
|
+
*/
|
|
85
|
+
export declare function extractPatternSectionRolesFromAttributes(attributes: Record<string, unknown>, convention?: PatternCatalogSectionRoleConvention): string[];
|
|
86
|
+
/**
|
|
87
|
+
* Find section wrapper blocks and their role markers in parsed pattern content.
|
|
88
|
+
*
|
|
89
|
+
* @param blocks Parsed block tree returned by `validateBlockPatternContentNesting`.
|
|
90
|
+
* @param convention Optional marker convention override.
|
|
91
|
+
* @returns Section wrapper matches with serialized block paths.
|
|
92
|
+
*/
|
|
93
|
+
export declare function extractPatternSectionRoleMatches(blocks: readonly ParsedBlockPatternBlock[], convention?: PatternCatalogSectionRoleConvention): PatternCatalogSectionRoleMatch[];
|
|
94
|
+
/**
|
|
95
|
+
* Validate pattern thumbnail references with the same URL/path rules used by
|
|
96
|
+
* catalog diagnostics and `wp-typia add pattern`.
|
|
97
|
+
*
|
|
98
|
+
* @param value Candidate thumbnail URL or relative project path.
|
|
99
|
+
* @returns Whether the value is an http(s) URL or safe relative project path.
|
|
100
|
+
*/
|
|
101
|
+
export declare function isValidPatternThumbnailUrl(value: string): boolean;
|
|
102
|
+
export declare function resolvePatternCatalogContentFile(pattern: Pick<PatternCatalogEntry, "contentFile" | "file">): string | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Validate typed pattern catalog metadata declared in `scripts/block-config.ts`.
|
|
105
|
+
*
|
|
106
|
+
* The validator checks catalog shape, duplicate slugs, optional section-role
|
|
107
|
+
* rules, safe content file paths, and missing files when a workspace root is
|
|
108
|
+
* provided. With a workspace root, it also parses serialized block markup and
|
|
109
|
+
* compares section role markers against the catalog manifest.
|
|
110
|
+
*
|
|
111
|
+
* @param patterns Pattern catalog entries to validate.
|
|
112
|
+
* @param options Optional project root and section role marker convention.
|
|
113
|
+
* @returns Structured diagnostics split into errors and warnings.
|
|
114
|
+
*/
|
|
115
|
+
export declare function validatePatternCatalog(patterns: readonly PatternCatalogEntry[], options?: PatternCatalogValidationOptions): PatternCatalogValidationResult;
|
|
116
|
+
/**
|
|
117
|
+
* Render pattern catalog diagnostics for CLI, sync, and doctor output.
|
|
118
|
+
*
|
|
119
|
+
* @param diagnostics Diagnostics returned from {@link validatePatternCatalog}.
|
|
120
|
+
* @returns Human-readable lines with stable diagnostic codes.
|
|
121
|
+
*/
|
|
122
|
+
export declare function formatPatternCatalogDiagnostics(diagnostics: readonly PatternCatalogDiagnostic[]): string;
|