@wp-typia/create-workspace-template 0.15.0 → 0.17.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/README.md +8 -0
- package/README.md.mustache +5 -1
- package/package.json +1 -1
- package/package.json.mustache +1 -1
- package/scripts/block-config.ts.mustache +90 -4
- package/scripts/build-workspace.mjs.mustache +2 -0
- package/scripts/sync-rest-contracts.ts.mustache +70 -5
- package/webpack.config.js.mustache +4 -0
package/README.md
CHANGED
|
@@ -12,6 +12,14 @@ The generated project starts with an empty `src/blocks/*` workspace shell and is
|
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
wp-typia add block my-block --template basic
|
|
15
|
+
wp-typia add integration-env local-smoke --wp-env --service docker-compose
|
|
16
|
+
wp-typia add style callout-emphasis --block my-block
|
|
17
|
+
wp-typia add transform quote-to-block --from core/quote --to my-block
|
|
15
18
|
wp-typia add binding-source hero-data
|
|
19
|
+
wp-typia add binding-source hero-data --block my-block --attribute headline
|
|
20
|
+
wp-typia add contract external-retrieve-response --type ExternalRetrieveResponse
|
|
21
|
+
wp-typia add post-meta integration-state --post-type post --type IntegrationStateMeta
|
|
22
|
+
wp-typia add editor-plugin review-workflow --slot sidebar
|
|
23
|
+
wp-typia add editor-plugin seo-notes --slot document-setting-panel
|
|
16
24
|
wp-typia add hooked-block my-block --anchor core/post-content --position after
|
|
17
25
|
```
|
package/README.md.mustache
CHANGED
|
@@ -20,12 +20,16 @@ wp-typia add block counter-card --template persistence --data-storage custom-tab
|
|
|
20
20
|
wp-typia add block faq-stack --template compound --data-storage custom-table --persistence-policy public
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Variations
|
|
23
|
+
Variations, block styles, transforms, patterns, REST resources, and post meta
|
|
24
|
+
contracts can also be added after the first block exists:
|
|
24
25
|
|
|
25
26
|
```bash
|
|
26
27
|
wp-typia add variation hero-card --block counter-card
|
|
28
|
+
wp-typia add style callout-emphasis --block counter-card
|
|
29
|
+
wp-typia add transform quote-to-counter --from core/quote --to counter-card
|
|
27
30
|
wp-typia add pattern hero-layout
|
|
28
31
|
wp-typia add rest-resource snapshots --namespace {{namespace}}/v1 --methods list,read,create
|
|
32
|
+
wp-typia add post-meta integration-state --post-type post
|
|
29
33
|
```
|
|
30
34
|
|
|
31
35
|
## Development
|
package/package.json
CHANGED
package/package.json.mustache
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"@wp-typia/api-client": "{{apiClientPackageVersion}}",
|
|
30
30
|
"@wp-typia/block-runtime": "{{blockRuntimePackageVersion}}",
|
|
31
31
|
"@wp-typia/block-types": "{{blockTypesPackageVersion}}",
|
|
32
|
+
"@wp-typia/project-tools": "{{projectToolsPackageVersion}}",
|
|
32
33
|
"@wp-typia/rest": "{{restPackageVersion}}",
|
|
33
34
|
"@typia/unplugin": "^12.0.1",
|
|
34
35
|
"@types/node": "^24.5.2",
|
|
@@ -36,7 +37,6 @@
|
|
|
36
37
|
"@types/wordpress__blocks": "^12.5.18",
|
|
37
38
|
"@wordpress/browserslist-config": "^6.42.0",
|
|
38
39
|
"@wordpress/scripts": "^30.22.0",
|
|
39
|
-
"ajv": "^8.18.0",
|
|
40
40
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
41
41
|
"tsx": "^4.20.5",
|
|
42
42
|
"typescript": "^5.9.2",
|
|
@@ -15,39 +15,105 @@ export interface WorkspaceVariationConfig {
|
|
|
15
15
|
slug: string;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export interface WorkspaceBlockStyleConfig {
|
|
19
|
+
block: string;
|
|
20
|
+
file: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface WorkspaceBlockTransformConfig {
|
|
25
|
+
block: string;
|
|
26
|
+
file: string;
|
|
27
|
+
from: string;
|
|
28
|
+
slug: string;
|
|
29
|
+
to: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
18
32
|
export interface WorkspacePatternConfig {
|
|
19
33
|
file: string;
|
|
20
34
|
slug: string;
|
|
21
35
|
}
|
|
22
36
|
|
|
23
37
|
export interface WorkspaceBindingSourceConfig {
|
|
38
|
+
attribute?: string;
|
|
39
|
+
block?: string;
|
|
24
40
|
editorFile: string;
|
|
25
41
|
serverFile: string;
|
|
26
42
|
slug: string;
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
export interface
|
|
45
|
+
export interface WorkspaceContractConfig {
|
|
46
|
+
schemaFile: string;
|
|
47
|
+
slug: string;
|
|
48
|
+
sourceTypeName: string;
|
|
49
|
+
typesFile: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface WorkspaceRestResourceBaseConfig {
|
|
30
53
|
apiFile: string;
|
|
54
|
+
auth?: 'authenticated' | 'public' | 'public-write-protected';
|
|
55
|
+
bodyTypeName?: string;
|
|
31
56
|
clientFile: string;
|
|
32
|
-
|
|
33
|
-
|
|
57
|
+
controllerClass?: string;
|
|
58
|
+
controllerExtends?: string;
|
|
34
59
|
namespace: string;
|
|
35
60
|
openApiFile: string;
|
|
36
|
-
|
|
61
|
+
permissionCallback?: string;
|
|
37
62
|
restManifest?: ReturnType<
|
|
38
63
|
typeof import( '@wp-typia/block-runtime/metadata-core' ).defineEndpointManifest
|
|
39
64
|
>;
|
|
65
|
+
secretFieldName?: string;
|
|
66
|
+
secretStateFieldName?: string;
|
|
40
67
|
slug: string;
|
|
41
68
|
typesFile: string;
|
|
42
69
|
validatorsFile: string;
|
|
43
70
|
}
|
|
44
71
|
|
|
72
|
+
export interface GeneratedWorkspaceRestResourceConfig extends WorkspaceRestResourceBaseConfig {
|
|
73
|
+
dataFile: string;
|
|
74
|
+
methods: Array< 'list' | 'read' | 'create' | 'update' | 'delete' >;
|
|
75
|
+
mode?: 'generated';
|
|
76
|
+
phpFile: string;
|
|
77
|
+
routePattern?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ManualWorkspaceRestResourceConfig extends WorkspaceRestResourceBaseConfig {
|
|
81
|
+
method: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
|
|
82
|
+
methods: [];
|
|
83
|
+
mode: 'manual';
|
|
84
|
+
pathPattern: string;
|
|
85
|
+
queryTypeName: string;
|
|
86
|
+
responseTypeName: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type WorkspaceRestResourceConfig =
|
|
90
|
+
| GeneratedWorkspaceRestResourceConfig
|
|
91
|
+
| ManualWorkspaceRestResourceConfig;
|
|
92
|
+
|
|
93
|
+
export interface WorkspacePostMetaConfig {
|
|
94
|
+
metaKey: string;
|
|
95
|
+
phpFile: string;
|
|
96
|
+
postType: string;
|
|
97
|
+
schemaFile: string;
|
|
98
|
+
showInRest: boolean;
|
|
99
|
+
slug: string;
|
|
100
|
+
sourceTypeName: string;
|
|
101
|
+
typesFile: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
45
104
|
export interface WorkspaceEditorPluginConfig {
|
|
46
105
|
file: string;
|
|
47
106
|
slug: string;
|
|
48
107
|
slot: string;
|
|
49
108
|
}
|
|
50
109
|
|
|
110
|
+
export interface WorkspaceAdminViewConfig {
|
|
111
|
+
file: string;
|
|
112
|
+
phpFile: string;
|
|
113
|
+
slug: string;
|
|
114
|
+
source?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
51
117
|
export const BLOCKS: WorkspaceBlockConfig[] = [
|
|
52
118
|
// wp-typia add block entries
|
|
53
119
|
];
|
|
@@ -56,6 +122,14 @@ export const VARIATIONS: WorkspaceVariationConfig[] = [
|
|
|
56
122
|
// wp-typia add variation entries
|
|
57
123
|
];
|
|
58
124
|
|
|
125
|
+
export const BLOCK_STYLES: WorkspaceBlockStyleConfig[] = [
|
|
126
|
+
// wp-typia add style entries
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
export const BLOCK_TRANSFORMS: WorkspaceBlockTransformConfig[] = [
|
|
130
|
+
// wp-typia add transform entries
|
|
131
|
+
];
|
|
132
|
+
|
|
59
133
|
export const PATTERNS: WorkspacePatternConfig[] = [
|
|
60
134
|
// wp-typia add pattern entries
|
|
61
135
|
];
|
|
@@ -64,10 +138,22 @@ export const BINDING_SOURCES: WorkspaceBindingSourceConfig[] = [
|
|
|
64
138
|
// wp-typia add binding-source entries
|
|
65
139
|
];
|
|
66
140
|
|
|
141
|
+
export const CONTRACTS: WorkspaceContractConfig[] = [
|
|
142
|
+
// wp-typia add contract entries
|
|
143
|
+
];
|
|
144
|
+
|
|
67
145
|
export const REST_RESOURCES: WorkspaceRestResourceConfig[] = [
|
|
68
146
|
// wp-typia add rest-resource entries
|
|
69
147
|
];
|
|
70
148
|
|
|
149
|
+
export const POST_META: WorkspacePostMetaConfig[] = [
|
|
150
|
+
// wp-typia add post-meta entries
|
|
151
|
+
];
|
|
152
|
+
|
|
71
153
|
export const EDITOR_PLUGINS: WorkspaceEditorPluginConfig[] = [
|
|
72
154
|
// wp-typia add editor-plugin entries
|
|
73
155
|
];
|
|
156
|
+
|
|
157
|
+
export const ADMIN_VIEWS: WorkspaceAdminViewConfig[] = [
|
|
158
|
+
// wp-typia add admin-view entries
|
|
159
|
+
];
|
|
@@ -27,6 +27,8 @@ function hasSharedEditorEntries() {
|
|
|
27
27
|
'src/bindings/index.js',
|
|
28
28
|
'src/editor-plugins/index.ts',
|
|
29
29
|
'src/editor-plugins/index.js',
|
|
30
|
+
'src/admin-views/index.ts',
|
|
31
|
+
'src/admin-views/index.js',
|
|
30
32
|
] ) {
|
|
31
33
|
if ( fs.existsSync( path.join( process.cwd(), relativePath ) ) ) {
|
|
32
34
|
return true;
|
|
@@ -10,8 +10,12 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
BLOCKS,
|
|
13
|
+
CONTRACTS,
|
|
14
|
+
POST_META,
|
|
13
15
|
REST_RESOURCES,
|
|
14
16
|
type WorkspaceBlockConfig,
|
|
17
|
+
type WorkspaceContractConfig,
|
|
18
|
+
type WorkspacePostMetaConfig,
|
|
15
19
|
type WorkspaceRestResourceConfig,
|
|
16
20
|
} from './block-config';
|
|
17
21
|
|
|
@@ -66,6 +70,34 @@ function isWorkspaceRestResource(
|
|
|
66
70
|
);
|
|
67
71
|
}
|
|
68
72
|
|
|
73
|
+
function isWorkspaceStandaloneContract(
|
|
74
|
+
contract: WorkspaceContractConfig
|
|
75
|
+
): contract is WorkspaceContractConfig & {
|
|
76
|
+
schemaFile: string;
|
|
77
|
+
sourceTypeName: string;
|
|
78
|
+
typesFile: string;
|
|
79
|
+
} {
|
|
80
|
+
return (
|
|
81
|
+
typeof contract.schemaFile === 'string' &&
|
|
82
|
+
typeof contract.sourceTypeName === 'string' &&
|
|
83
|
+
typeof contract.typesFile === 'string'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isWorkspacePostMetaContract(
|
|
88
|
+
postMeta: WorkspacePostMetaConfig
|
|
89
|
+
): postMeta is WorkspacePostMetaConfig & {
|
|
90
|
+
schemaFile: string;
|
|
91
|
+
sourceTypeName: string;
|
|
92
|
+
typesFile: string;
|
|
93
|
+
} {
|
|
94
|
+
return (
|
|
95
|
+
typeof postMeta.schemaFile === 'string' &&
|
|
96
|
+
typeof postMeta.sourceTypeName === 'string' &&
|
|
97
|
+
typeof postMeta.typesFile === 'string'
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
69
101
|
async function assertTypeArtifactsCurrent( block: WorkspaceBlockConfig ) {
|
|
70
102
|
const report = await runSyncBlockMetadata(
|
|
71
103
|
{
|
|
@@ -97,13 +129,20 @@ async function assertTypeArtifactsCurrent( block: WorkspaceBlockConfig ) {
|
|
|
97
129
|
async function main() {
|
|
98
130
|
const options = parseCliOptions( process.argv.slice( 2 ) );
|
|
99
131
|
const restBlocks = BLOCKS.filter( isRestEnabledBlock );
|
|
132
|
+
const standaloneContracts = CONTRACTS.filter( isWorkspaceStandaloneContract );
|
|
133
|
+
const postMetaContracts = POST_META.filter( isWorkspacePostMetaContract );
|
|
100
134
|
const restResources = REST_RESOURCES.filter( isWorkspaceRestResource );
|
|
101
135
|
|
|
102
|
-
if (
|
|
136
|
+
if (
|
|
137
|
+
restBlocks.length === 0 &&
|
|
138
|
+
standaloneContracts.length === 0 &&
|
|
139
|
+
postMetaContracts.length === 0 &&
|
|
140
|
+
restResources.length === 0
|
|
141
|
+
) {
|
|
103
142
|
console.log(
|
|
104
143
|
options.check
|
|
105
|
-
? 'ℹ️ No REST-enabled workspace blocks or plugin-level REST resources are registered yet. `sync-rest --check` is already clean.'
|
|
106
|
-
: 'ℹ️ No REST-enabled workspace blocks or plugin-level REST resources are registered yet.'
|
|
144
|
+
? 'ℹ️ No REST-enabled workspace blocks, standalone contracts, post meta contracts, or plugin-level REST resources are registered yet. `sync-rest --check` is already clean.'
|
|
145
|
+
: 'ℹ️ No REST-enabled workspace blocks, standalone contracts, post meta contracts, or plugin-level REST resources are registered yet.'
|
|
107
146
|
);
|
|
108
147
|
return;
|
|
109
148
|
}
|
|
@@ -167,6 +206,32 @@ async function main() {
|
|
|
167
206
|
);
|
|
168
207
|
}
|
|
169
208
|
|
|
209
|
+
for ( const contract of standaloneContracts ) {
|
|
210
|
+
await syncTypeSchemas(
|
|
211
|
+
{
|
|
212
|
+
jsonSchemaFile: contract.schemaFile,
|
|
213
|
+
sourceTypeName: contract.sourceTypeName,
|
|
214
|
+
typesFile: contract.typesFile,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
check: options.check,
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
for ( const postMeta of postMetaContracts ) {
|
|
223
|
+
await syncTypeSchemas(
|
|
224
|
+
{
|
|
225
|
+
jsonSchemaFile: postMeta.schemaFile,
|
|
226
|
+
sourceTypeName: postMeta.sourceTypeName,
|
|
227
|
+
typesFile: postMeta.typesFile,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
check: options.check,
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
170
235
|
for ( const resource of restResources ) {
|
|
171
236
|
const contracts = resource.restManifest.contracts;
|
|
172
237
|
|
|
@@ -218,8 +283,8 @@ async function main() {
|
|
|
218
283
|
|
|
219
284
|
console.log(
|
|
220
285
|
options.check
|
|
221
|
-
? '✅ REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents are already up to date for workspace blocks and plugin-level resources!'
|
|
222
|
-
: '✅ REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents generated for workspace blocks and plugin-level resources!'
|
|
286
|
+
? '✅ REST contract schemas, standalone schemas, post meta schemas, portable API clients, and endpoint-aware OpenAPI documents are already up to date for workspace blocks, standalone contracts, post meta contracts, and plugin-level resources!'
|
|
287
|
+
: '✅ REST contract schemas, standalone schemas, post meta schemas, portable API clients, and endpoint-aware OpenAPI documents generated for workspace blocks, standalone contracts, post meta contracts, and plugin-level resources!'
|
|
223
288
|
);
|
|
224
289
|
}
|
|
225
290
|
|
|
@@ -198,6 +198,10 @@ function getSharedEditorEntries() {
|
|
|
198
198
|
'editor-plugins/index',
|
|
199
199
|
[ 'src/editor-plugins/index.ts', 'src/editor-plugins/index.js' ],
|
|
200
200
|
],
|
|
201
|
+
[
|
|
202
|
+
'admin-views/index',
|
|
203
|
+
[ 'src/admin-views/index.ts', 'src/admin-views/index.js' ],
|
|
204
|
+
],
|
|
201
205
|
] ) {
|
|
202
206
|
for ( const relativePath of candidates ) {
|
|
203
207
|
const entryPath = path.resolve( process.cwd(), relativePath );
|