@wp-typia/project-tools 0.11.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.
- package/README.md +32 -0
- package/dist/runtime/cli-add.d.ts +38 -0
- package/dist/runtime/cli-add.js +561 -0
- package/dist/runtime/cli-core.d.ts +25 -0
- package/dist/runtime/cli-core.js +25 -0
- package/dist/runtime/cli-doctor.d.ts +34 -0
- package/dist/runtime/cli-doctor.js +131 -0
- package/dist/runtime/cli-help.d.ts +9 -0
- package/dist/runtime/cli-help.js +37 -0
- package/dist/runtime/cli-prompt.d.ts +21 -0
- package/dist/runtime/cli-prompt.js +53 -0
- package/dist/runtime/cli-scaffold.d.ts +79 -0
- package/dist/runtime/cli-scaffold.js +206 -0
- package/dist/runtime/cli-templates.d.ts +30 -0
- package/dist/runtime/cli-templates.js +61 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/json-utils.d.ts +10 -0
- package/dist/runtime/json-utils.js +12 -0
- package/dist/runtime/local-dev-presets.d.ts +26 -0
- package/dist/runtime/local-dev-presets.js +132 -0
- package/dist/runtime/metadata-analysis.d.ts +11 -0
- package/dist/runtime/metadata-analysis.js +285 -0
- package/dist/runtime/metadata-model.d.ts +84 -0
- package/dist/runtime/metadata-model.js +59 -0
- package/dist/runtime/metadata-parser.d.ts +53 -0
- package/dist/runtime/metadata-parser.js +794 -0
- package/dist/runtime/metadata-php-render.d.ts +29 -0
- package/dist/runtime/metadata-php-render.js +549 -0
- package/dist/runtime/metadata-projection.d.ts +7 -0
- package/dist/runtime/metadata-projection.js +233 -0
- package/dist/runtime/migration-constants.d.ts +15 -0
- package/dist/runtime/migration-constants.js +16 -0
- package/dist/runtime/migration-diff.d.ts +2 -0
- package/dist/runtime/migration-diff.js +537 -0
- package/dist/runtime/migration-fixtures.d.ts +8 -0
- package/dist/runtime/migration-fixtures.js +94 -0
- package/dist/runtime/migration-fuzz-plan.d.ts +2 -0
- package/dist/runtime/migration-fuzz-plan.js +50 -0
- package/dist/runtime/migration-manifest.d.ts +19 -0
- package/dist/runtime/migration-manifest.js +129 -0
- package/dist/runtime/migration-project.d.ts +94 -0
- package/dist/runtime/migration-project.js +1101 -0
- package/dist/runtime/migration-render.d.ts +11 -0
- package/dist/runtime/migration-render.js +741 -0
- package/dist/runtime/migration-risk.d.ts +4 -0
- package/dist/runtime/migration-risk.js +52 -0
- package/dist/runtime/migration-types.d.ts +249 -0
- package/dist/runtime/migration-types.js +1 -0
- package/dist/runtime/migration-ui-capability.d.ts +17 -0
- package/dist/runtime/migration-ui-capability.js +190 -0
- package/dist/runtime/migration-utils.d.ts +69 -0
- package/dist/runtime/migration-utils.js +246 -0
- package/dist/runtime/migrations.d.ts +249 -0
- package/dist/runtime/migrations.js +1061 -0
- package/dist/runtime/object-utils.d.ts +12 -0
- package/dist/runtime/object-utils.js +14 -0
- package/dist/runtime/package-managers.d.ts +28 -0
- package/dist/runtime/package-managers.js +156 -0
- package/dist/runtime/package-versions.d.ts +10 -0
- package/dist/runtime/package-versions.js +68 -0
- package/dist/runtime/scaffold-onboarding.d.ts +32 -0
- package/dist/runtime/scaffold-onboarding.js +99 -0
- package/dist/runtime/scaffold.d.ts +146 -0
- package/dist/runtime/scaffold.js +612 -0
- package/dist/runtime/schema-core.d.ts +267 -0
- package/dist/runtime/schema-core.js +597 -0
- package/dist/runtime/starter-manifests.d.ts +25 -0
- package/dist/runtime/starter-manifests.js +383 -0
- package/dist/runtime/string-case.d.ts +36 -0
- package/dist/runtime/string-case.js +69 -0
- package/dist/runtime/template-builtins.d.ts +38 -0
- package/dist/runtime/template-builtins.js +72 -0
- package/dist/runtime/template-defaults.d.ts +75 -0
- package/dist/runtime/template-defaults.js +65 -0
- package/dist/runtime/template-registry.d.ts +36 -0
- package/dist/runtime/template-registry.js +94 -0
- package/dist/runtime/template-render.d.ts +24 -0
- package/dist/runtime/template-render.js +113 -0
- package/dist/runtime/template-source.d.ts +71 -0
- package/dist/runtime/template-source.js +821 -0
- package/dist/runtime/typia-tags.d.ts +1 -0
- package/dist/runtime/typia-tags.js +1 -0
- package/package.json +79 -0
- package/templates/_shared/base/languages/.gitkeep +1 -0
- package/templates/_shared/base/package.json.mustache +41 -0
- package/templates/_shared/base/scripts/sync-types-to-block-json.ts.mustache +118 -0
- package/templates/_shared/base/src/hooks.ts.mustache +19 -0
- package/templates/_shared/base/src/validator-toolkit.ts.mustache +31 -0
- package/templates/_shared/base/tsconfig.json.mustache +21 -0
- package/templates/_shared/base/webpack.config.js.mustache +99 -0
- package/templates/_shared/base/{{slugKebabCase}}.php.mustache +53 -0
- package/templates/_shared/compound/core/package.json.mustache +45 -0
- package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +559 -0
- package/templates/_shared/compound/core/scripts/block-config.ts.mustache +13 -0
- package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +53 -0
- package/templates/_shared/compound/core/webpack.config.js.mustache +141 -0
- package/templates/_shared/compound/core/{{slugKebabCase}}.php.mustache +51 -0
- package/templates/_shared/compound/persistence/package.json.mustache +50 -0
- package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +59 -0
- package/templates/_shared/compound/persistence/scripts/sync-rest-contracts.ts.mustache +101 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/api-types.ts.mustache +21 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/api-validators.ts.mustache +32 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/api.ts.mustache +68 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/block.json.mustache +52 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/data.ts.mustache +192 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +123 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +11 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/interactivity.ts.mustache +132 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/render.php.mustache +158 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/save.tsx.mustache +3 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/types.ts.mustache +56 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/validators.ts.mustache +32 -0
- package/templates/_shared/compound/persistence-auth/{{slugKebabCase}}.php.mustache +294 -0
- package/templates/_shared/compound/persistence-public/{{slugKebabCase}}.php.mustache +312 -0
- package/templates/_shared/migration-ui/common/src/admin/migration-dashboard.tsx +394 -0
- package/templates/_shared/migration-ui/common/src/migration-detector.ts +9 -0
- package/templates/_shared/migration-ui/common/src/migrations/helpers.ts +490 -0
- package/templates/_shared/migration-ui/common/src/migrations/index.ts +886 -0
- package/templates/_shared/persistence/auth/{{slugKebabCase}}.php.mustache +290 -0
- package/templates/_shared/persistence/core/package.json.mustache +46 -0
- package/templates/_shared/persistence/core/scripts/sync-rest-contracts.ts.mustache +113 -0
- package/templates/_shared/persistence/core/scripts/sync-types-to-block-json.ts.mustache +125 -0
- package/templates/_shared/persistence/core/src/api-types.ts.mustache +21 -0
- package/templates/_shared/persistence/core/src/api-validators.ts.mustache +32 -0
- package/templates/_shared/persistence/core/src/api.ts.mustache +68 -0
- package/templates/_shared/persistence/core/src/data.ts.mustache +192 -0
- package/templates/_shared/persistence/core/src/index.tsx.mustache +25 -0
- package/templates/_shared/persistence/core/src/interactivity.ts.mustache +134 -0
- package/templates/_shared/persistence/core/src/save.tsx.mustache +5 -0
- package/templates/_shared/persistence/core/src/validators.ts.mustache +32 -0
- package/templates/_shared/persistence/core/{{slugKebabCase}}.php.mustache +336 -0
- package/templates/_shared/persistence/public/{{slugKebabCase}}.php.mustache +308 -0
- package/templates/_shared/presets/test-preset/.wp-env.test.json.mustache +16 -0
- package/templates/_shared/presets/test-preset/playwright.config.ts.mustache +22 -0
- package/templates/_shared/presets/test-preset/scripts/wait-for-wp-env.mjs.mustache +102 -0
- package/templates/_shared/presets/test-preset/scripts/wp-env-utils.cjs.mustache +32 -0
- package/templates/_shared/presets/test-preset/tests/e2e/smoke.spec.ts.mustache +34 -0
- package/templates/_shared/presets/wp-env/.wp-env.json.mustache +16 -0
- package/templates/_shared/rest-helpers/auth/inc/rest-auth.php.mustache +37 -0
- package/templates/_shared/rest-helpers/public/inc/rest-public.php.mustache +314 -0
- package/templates/_shared/rest-helpers/shared/inc/rest-shared.php.mustache +58 -0
- package/templates/_shared/workspace/persistence-auth/inc/rest-auth.php.mustache +36 -0
- package/templates/_shared/workspace/persistence-auth/inc/rest-shared.php.mustache +55 -0
- package/templates/_shared/workspace/persistence-auth/server.php.mustache +237 -0
- package/templates/_shared/workspace/persistence-public/inc/rest-public.php.mustache +273 -0
- package/templates/_shared/workspace/persistence-public/inc/rest-shared.php.mustache +55 -0
- package/templates/_shared/workspace/persistence-public/server.php.mustache +252 -0
- package/templates/basic/src/block.json.mustache +51 -0
- package/templates/basic/src/edit.tsx.mustache +128 -0
- package/templates/basic/src/editor.scss.mustache +8 -0
- package/templates/basic/src/hooks.ts.mustache +18 -0
- package/templates/basic/src/index.tsx.mustache +45 -0
- package/templates/basic/src/save.tsx.mustache +30 -0
- package/templates/basic/src/style.scss.mustache +40 -0
- package/templates/basic/src/types.ts.mustache +56 -0
- package/templates/basic/src/validators.ts.mustache +26 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/block.json.mustache +37 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/children.ts.mustache +25 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +93 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +11 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/index.tsx.mustache +25 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/save.tsx.mustache +32 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/style.scss.mustache +31 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/types.ts.mustache +13 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/validators.ts.mustache +17 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/block.json.mustache +35 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/edit.tsx.mustache +50 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/hooks.ts.mustache +11 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/index.tsx.mustache +25 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/save.tsx.mustache +24 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/types.ts.mustache +12 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/validators.ts.mustache +17 -0
- package/templates/interactivity/package.json.mustache +42 -0
- package/templates/interactivity/src/block.json.mustache +73 -0
- package/templates/interactivity/src/edit.tsx.mustache +270 -0
- package/templates/interactivity/src/index.tsx.mustache +32 -0
- package/templates/interactivity/src/interactivity.ts.mustache +152 -0
- package/templates/interactivity/src/save.tsx.mustache +101 -0
- package/templates/interactivity/src/style.scss.mustache +60 -0
- package/templates/interactivity/src/types.ts.mustache +32 -0
- package/templates/interactivity/src/validators.ts.mustache +36 -0
- package/templates/persistence/src/block.json.mustache +52 -0
- package/templates/persistence/src/edit.tsx.mustache +165 -0
- package/templates/persistence/src/render.php.mustache +126 -0
- package/templates/persistence/src/style.scss.mustache +46 -0
- package/templates/persistence/src/types.ts.mustache +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wp-typia/project-tools",
|
|
3
|
+
"version": "0.11.1",
|
|
4
|
+
"description": "Project orchestration and programmatic tooling for wp-typia",
|
|
5
|
+
"packageManager": "bun@1.3.11",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/runtime/index.js",
|
|
8
|
+
"types": "dist/runtime/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/runtime/index.d.ts",
|
|
12
|
+
"import": "./dist/runtime/index.js",
|
|
13
|
+
"default": "./dist/runtime/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./schema-core": {
|
|
16
|
+
"types": "./dist/runtime/schema-core.d.ts",
|
|
17
|
+
"import": "./dist/runtime/schema-core.js",
|
|
18
|
+
"default": "./dist/runtime/schema-core.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/",
|
|
24
|
+
"templates/",
|
|
25
|
+
"README.md",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "bun run --filter @wp-typia/block-runtime build && rm -rf dist && tsc -p tsconfig.runtime.json",
|
|
30
|
+
"test": "bun run --filter @wp-typia/block-runtime build && bun run build && bun test tests/*.test.ts",
|
|
31
|
+
"test:coverage": "bun run --filter @wp-typia/block-runtime build && bun run build && bun test tests/*.test.ts --coverage --coverage-reporter=lcov --coverage-dir=coverage",
|
|
32
|
+
"clean": "rm -rf dist",
|
|
33
|
+
"prepack": "bun run build"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"wordpress",
|
|
37
|
+
"gutenberg",
|
|
38
|
+
"typia",
|
|
39
|
+
"scaffold",
|
|
40
|
+
"migrate",
|
|
41
|
+
"templates",
|
|
42
|
+
"tooling"
|
|
43
|
+
],
|
|
44
|
+
"author": "imjlk",
|
|
45
|
+
"license": "GPL-2.0-or-later",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/imjlk/wp-typia.git",
|
|
49
|
+
"directory": "packages/wp-typia-project-tools"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/imjlk/wp-typia/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/imjlk/wp-typia/tree/main/packages/wp-typia-project-tools#readme",
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=20.0.0",
|
|
60
|
+
"npm": ">=10.0.0",
|
|
61
|
+
"bun": ">=1.3.11"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@wp-typia/api-client": "^0.4.0",
|
|
65
|
+
"@wp-typia/block-runtime": "^0.3.0",
|
|
66
|
+
"@wp-typia/rest": "^0.3.1",
|
|
67
|
+
"@wp-typia/block-types": "^0.2.0",
|
|
68
|
+
"mustache": "^4.2.0",
|
|
69
|
+
"npm-package-arg": "^13.0.0",
|
|
70
|
+
"semver": "^7.7.3",
|
|
71
|
+
"tar": "^7.4.3",
|
|
72
|
+
"typescript": "^5.9.2"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"react": "^19.2.0",
|
|
76
|
+
"react-devtools-core": "^7.0.1",
|
|
77
|
+
"ws": "^8.18.0"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{slug}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"packageManager": "bun@1.3.10",
|
|
5
|
+
"description": "{{description}}",
|
|
6
|
+
"author": "{{author}}",
|
|
7
|
+
"license": "GPL-2.0-or-later",
|
|
8
|
+
"main": "build/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"sync-types": "tsx scripts/sync-types-to-block-json.ts",
|
|
11
|
+
"build": "bun run sync-types --check && wp-scripts build --experimental-modules",
|
|
12
|
+
"start": "bun run sync-types && wp-scripts start --experimental-modules",
|
|
13
|
+
"dev": "bun run start",
|
|
14
|
+
"lint:js": "wp-scripts lint-js",
|
|
15
|
+
"lint:css": "wp-scripts lint-style",
|
|
16
|
+
"lint": "bun run lint:js && bun run lint:css",
|
|
17
|
+
"format": "wp-scripts format",
|
|
18
|
+
"typecheck": "bun run sync-types --check && tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@wp-typia/block-runtime": "{{blockRuntimePackageVersion}}",
|
|
22
|
+
"@wp-typia/block-types": "{{blockTypesPackageVersion}}",
|
|
23
|
+
"ajv": "^8.18.0",
|
|
24
|
+
"@types/wordpress__block-editor": "^11.5.17",
|
|
25
|
+
"@types/wordpress__blocks": "^12.5.18",
|
|
26
|
+
"@wordpress/browserslist-config": "^6.42.0",
|
|
27
|
+
"@wordpress/scripts": "^30.22.0",
|
|
28
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
29
|
+
"@typia/unplugin": "^12.0.1",
|
|
30
|
+
"tsx": "^4.20.5",
|
|
31
|
+
"typescript": "^5.9.2",
|
|
32
|
+
"typia": "^12.0.1"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@wordpress/block-editor": "^15.2.0",
|
|
36
|
+
"@wordpress/blocks": "^15.2.0",
|
|
37
|
+
"@wordpress/components": "^30.2.0",
|
|
38
|
+
"@wordpress/element": "^6.29.0",
|
|
39
|
+
"@wordpress/i18n": "^6.2.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { runSyncBlockMetadata } from "@wp-typia/block-runtime/metadata-core";
|
|
2
|
+
|
|
3
|
+
type SyncTypesReportMode = "human" | "json";
|
|
4
|
+
|
|
5
|
+
interface SyncTypesCliOptions {
|
|
6
|
+
check: boolean;
|
|
7
|
+
failOnLossy: boolean;
|
|
8
|
+
report: SyncTypesReportMode;
|
|
9
|
+
strict: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function parseCliOptions(argv: string[]): SyncTypesCliOptions {
|
|
13
|
+
const options: SyncTypesCliOptions = {
|
|
14
|
+
check: false,
|
|
15
|
+
failOnLossy: false,
|
|
16
|
+
report: "human",
|
|
17
|
+
strict: false,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
21
|
+
const argument = argv[index];
|
|
22
|
+
|
|
23
|
+
if (argument === "--strict") {
|
|
24
|
+
options.strict = true;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (argument === "--fail-on-lossy") {
|
|
29
|
+
options.failOnLossy = true;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (argument === "--check") {
|
|
34
|
+
options.check = true;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (argument === "--report") {
|
|
39
|
+
const reportMode = argv[index + 1];
|
|
40
|
+
if (reportMode !== "json") {
|
|
41
|
+
throw new Error('The `--report` flag currently supports only `json`.');
|
|
42
|
+
}
|
|
43
|
+
options.report = reportMode;
|
|
44
|
+
index += 1;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
throw new Error(`Unknown sync-types flag: ${argument}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return options;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function printHumanReport(
|
|
55
|
+
options: SyncTypesCliOptions,
|
|
56
|
+
report: Awaited<ReturnType<typeof runSyncBlockMetadata>>,
|
|
57
|
+
) {
|
|
58
|
+
if (report.failure) {
|
|
59
|
+
console.error("❌ Type sync failed:", report.failure.message);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
console.log(
|
|
64
|
+
options.check
|
|
65
|
+
? "✅ block.json, typia.manifest.json, and typia-validator.php are already up to date with the TypeScript types!"
|
|
66
|
+
: "✅ block.json, typia.manifest.json, and typia-validator.php were generated from TypeScript types!",
|
|
67
|
+
);
|
|
68
|
+
console.log("📝 Generated attributes:", report.attributeNames);
|
|
69
|
+
|
|
70
|
+
if (report.lossyProjectionWarnings.length > 0) {
|
|
71
|
+
console.warn("⚠️ Some Typia constraints were preserved only in typia.manifest.json:");
|
|
72
|
+
for (const warning of report.lossyProjectionWarnings) {
|
|
73
|
+
console.warn(` - ${warning}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (report.phpGenerationWarnings.length > 0) {
|
|
78
|
+
console.warn("⚠️ Some Typia constraints are not yet enforced by typia-validator.php:");
|
|
79
|
+
for (const warning of report.phpGenerationWarnings) {
|
|
80
|
+
console.warn(` - ${warning}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (report.status === "error") {
|
|
85
|
+
console.error(
|
|
86
|
+
"❌ Type sync completed with warnings treated as errors because of the selected flags.",
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function main() {
|
|
92
|
+
const options = parseCliOptions(process.argv.slice(2));
|
|
93
|
+
const report = await runSyncBlockMetadata({
|
|
94
|
+
blockJsonFile: "src/block.json",
|
|
95
|
+
manifestFile: "src/typia.manifest.json",
|
|
96
|
+
sourceTypeName: "{{pascalCase}}Attributes",
|
|
97
|
+
typesFile: "src/types.ts",
|
|
98
|
+
}, {
|
|
99
|
+
check: options.check,
|
|
100
|
+
failOnLossy: options.failOnLossy,
|
|
101
|
+
strict: options.strict,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (options.report === "json") {
|
|
105
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
106
|
+
} else {
|
|
107
|
+
printHumanReport(options, report);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (report.status === "error") {
|
|
111
|
+
process.exitCode = 1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main().catch((error) => {
|
|
116
|
+
console.error("❌ Type sync failed:", error);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useMemo } from '@wordpress/element';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createUseTypiaValidationHook,
|
|
5
|
+
formatValidationError,
|
|
6
|
+
formatValidationErrors,
|
|
7
|
+
} from '@wp-typia/block-runtime/validation';
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
formatValidationError,
|
|
11
|
+
formatValidationErrors,
|
|
12
|
+
type TypiaValidationError,
|
|
13
|
+
type ValidationResult,
|
|
14
|
+
type ValidationState,
|
|
15
|
+
} from '@wp-typia/block-runtime/validation';
|
|
16
|
+
|
|
17
|
+
export const useTypiaValidation = createUseTypiaValidationHook( {
|
|
18
|
+
useMemo,
|
|
19
|
+
} );
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import typia from 'typia';
|
|
2
|
+
|
|
3
|
+
import type { ManifestDefaultsDocument } from '@wp-typia/block-runtime/defaults';
|
|
4
|
+
import {
|
|
5
|
+
createScaffoldValidatorToolkit,
|
|
6
|
+
type ScaffoldValidatorToolkitOptions,
|
|
7
|
+
} from '@wp-typia/block-runtime/validation';
|
|
8
|
+
|
|
9
|
+
interface TemplateValidatorToolkitOptions< T extends object > {
|
|
10
|
+
finalize?: ScaffoldValidatorToolkitOptions< T >['finalize'];
|
|
11
|
+
manifest: unknown;
|
|
12
|
+
onValidationError?: ScaffoldValidatorToolkitOptions< T >['onValidationError'];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createTemplateValidatorToolkit< T extends object >( {
|
|
16
|
+
finalize,
|
|
17
|
+
manifest,
|
|
18
|
+
onValidationError,
|
|
19
|
+
}: TemplateValidatorToolkitOptions< T > ) {
|
|
20
|
+
return createScaffoldValidatorToolkit< T >( {
|
|
21
|
+
manifest: manifest as ManifestDefaultsDocument,
|
|
22
|
+
validate: typia.createValidate< T >(),
|
|
23
|
+
assert: typia.createAssert< T >(),
|
|
24
|
+
is: typia.createIs< T >(),
|
|
25
|
+
random: typia.createRandom< T >() as ( ...args: unknown[] ) => T,
|
|
26
|
+
clone: typia.misc.createClone< T >() as ( value: T ) => T,
|
|
27
|
+
prune: typia.misc.createPrune< T >(),
|
|
28
|
+
finalize,
|
|
29
|
+
onValidationError,
|
|
30
|
+
} );
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"jsx": "react-jsx",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"baseUrl": ".",
|
|
17
|
+
"types": ["wordpress__block-editor", "wordpress__blocks"]
|
|
18
|
+
},
|
|
19
|
+
"include": ["src/**/*"],
|
|
20
|
+
"exclude": ["node_modules", "build"]
|
|
21
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const defaultConfig = require("@wordpress/scripts/config/webpack.config");
|
|
4
|
+
|
|
5
|
+
const STATIC_ARTIFACT_FILENAMES = new Set([
|
|
6
|
+
"render.php",
|
|
7
|
+
"typia.manifest.json",
|
|
8
|
+
"typia-validator.php",
|
|
9
|
+
"typia-migration-registry.php",
|
|
10
|
+
]);
|
|
11
|
+
const ROOT_GENERATED_ARTIFACT_FILENAMES = new Set([
|
|
12
|
+
...STATIC_ARTIFACT_FILENAMES,
|
|
13
|
+
"typia.schema.json",
|
|
14
|
+
"typia.openapi.json",
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
function isGeneratedArtifact(filename) {
|
|
18
|
+
return (
|
|
19
|
+
STATIC_ARTIFACT_FILENAMES.has(filename) ||
|
|
20
|
+
filename.endsWith(".openapi.json") ||
|
|
21
|
+
filename.endsWith(".schema.json")
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getArtifactEntries() {
|
|
26
|
+
const entries = [];
|
|
27
|
+
|
|
28
|
+
for (const filename of ROOT_GENERATED_ARTIFACT_FILENAMES) {
|
|
29
|
+
const rootArtifactPath = path.resolve(process.cwd(), filename);
|
|
30
|
+
if (fs.existsSync(rootArtifactPath)) {
|
|
31
|
+
entries.push({
|
|
32
|
+
inputPath: rootArtifactPath,
|
|
33
|
+
outputPath: filename,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const srcDir = path.resolve(process.cwd(), "src");
|
|
39
|
+
if (!fs.existsSync(srcDir)) {
|
|
40
|
+
return entries;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const inputPath of findArtifactFiles(srcDir)) {
|
|
44
|
+
entries.push({
|
|
45
|
+
inputPath,
|
|
46
|
+
outputPath: path.relative(srcDir, inputPath),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return entries;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function findArtifactFiles(directory) {
|
|
54
|
+
const artifactFiles = [];
|
|
55
|
+
|
|
56
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
57
|
+
const entryPath = path.join(directory, entry.name);
|
|
58
|
+
|
|
59
|
+
if (entry.isDirectory()) {
|
|
60
|
+
artifactFiles.push(...findArtifactFiles(entryPath));
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (entry.isFile() && isGeneratedArtifact(entry.name)) {
|
|
64
|
+
artifactFiles.push(entryPath);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return artifactFiles;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function resolveOptionalEntry(name, candidates) {
|
|
72
|
+
for (const candidate of candidates) {
|
|
73
|
+
const entryPath = path.resolve(process.cwd(), candidate);
|
|
74
|
+
if (fs.existsSync(entryPath)) {
|
|
75
|
+
return [name, entryPath];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = async () => {
|
|
83
|
+
const { createTypiaWebpackConfig } = await import("@wp-typia/block-runtime/blocks");
|
|
84
|
+
const optionalModuleEntries = Object.fromEntries(
|
|
85
|
+
[
|
|
86
|
+
resolveOptionalEntry("interactivity", ["src/interactivity.ts", "src/interactivity.js"]),
|
|
87
|
+
resolveOptionalEntry("view", ["src/view.ts", "src/view.js"]),
|
|
88
|
+
].filter(Boolean),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return createTypiaWebpackConfig({
|
|
92
|
+
defaultConfig,
|
|
93
|
+
fs,
|
|
94
|
+
path,
|
|
95
|
+
getArtifactEntries,
|
|
96
|
+
getOptionalModuleEntries: () => optionalModuleEntries,
|
|
97
|
+
importTypiaWebpackPlugin: () => import("@typia/unplugin/webpack"),
|
|
98
|
+
});
|
|
99
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: {{title}}
|
|
4
|
+
* Description: {{description}}
|
|
5
|
+
* Version: 0.1.0
|
|
6
|
+
* Requires at least: 6.7
|
|
7
|
+
* Tested up to: 6.9
|
|
8
|
+
* Requires PHP: 8.0
|
|
9
|
+
* Author: {{author}}
|
|
10
|
+
* License: GPL-2.0-or-later
|
|
11
|
+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
12
|
+
* Text Domain: {{textDomain}}
|
|
13
|
+
* Domain Path: /languages
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
17
|
+
exit;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function {{phpPrefix}}_load_textdomain() {
|
|
21
|
+
load_plugin_textdomain(
|
|
22
|
+
'{{textDomain}}',
|
|
23
|
+
false,
|
|
24
|
+
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function {{phpPrefix}}_get_build_dir() {
|
|
29
|
+
$candidates = array(
|
|
30
|
+
__DIR__ . '/build',
|
|
31
|
+
__DIR__ . '/build/{{slugKebabCase}}',
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
foreach ( $candidates as $candidate ) {
|
|
35
|
+
if ( file_exists( $candidate . '/block.json' ) ) {
|
|
36
|
+
return $candidate;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function {{phpPrefix}}_register_block() {
|
|
44
|
+
$build_dir = {{phpPrefix}}_get_build_dir();
|
|
45
|
+
if ( ! $build_dir ) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
register_block_type( $build_dir );
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
add_action( 'init', '{{phpPrefix}}_load_textdomain' );
|
|
53
|
+
add_action( 'init', '{{phpPrefix}}_register_block' );
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{slug}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"packageManager": "bun@1.3.10",
|
|
5
|
+
"description": "{{description}}",
|
|
6
|
+
"author": "{{author}}",
|
|
7
|
+
"license": "GPL-2.0-or-later",
|
|
8
|
+
"main": "build/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"add-child": "tsx scripts/add-compound-child.ts",
|
|
11
|
+
"sync-types": "tsx scripts/sync-types-to-block-json.ts",
|
|
12
|
+
"build": "bun run sync-types --check && wp-scripts build --experimental-modules",
|
|
13
|
+
"start": "bun run sync-types && wp-scripts start --experimental-modules",
|
|
14
|
+
"dev": "bun run start",
|
|
15
|
+
"typecheck": "bun run sync-types --check && tsc --noEmit",
|
|
16
|
+
"lint:js": "wp-scripts lint-js",
|
|
17
|
+
"lint:css": "wp-scripts lint-style",
|
|
18
|
+
"lint": "bun run lint:js && bun run lint:css",
|
|
19
|
+
"format": "wp-scripts format"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@wp-typia/block-runtime": "{{blockRuntimePackageVersion}}",
|
|
23
|
+
"@wp-typia/block-types": "{{blockTypesPackageVersion}}",
|
|
24
|
+
"@typia/unplugin": "^12.0.1",
|
|
25
|
+
"@wordpress/browserslist-config": "^6.42.0",
|
|
26
|
+
"@wordpress/scripts": "^30.22.0",
|
|
27
|
+
"@types/react": "^19.2.2",
|
|
28
|
+
"@types/react-dom": "^19.2.2",
|
|
29
|
+
"@types/wordpress__block-editor": "^11.5.17",
|
|
30
|
+
"@types/wordpress__blocks": "^12.5.18",
|
|
31
|
+
"ajv": "^8.18.0",
|
|
32
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
33
|
+
"prettier": "2.8.8",
|
|
34
|
+
"tsx": "^4.20.5",
|
|
35
|
+
"typescript": "^5.9.2",
|
|
36
|
+
"typia": "^12.0.1"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@wordpress/block-editor": "^15.2.0",
|
|
40
|
+
"@wordpress/blocks": "^15.2.0",
|
|
41
|
+
"@wordpress/components": "^30.2.0",
|
|
42
|
+
"@wordpress/element": "^6.29.0",
|
|
43
|
+
"@wordpress/i18n": "^6.2.0"
|
|
44
|
+
}
|
|
45
|
+
}
|