@wp-typia/project-tools 0.15.4 → 0.16.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/dist/runtime/cli-help.js +1 -1
- package/dist/runtime/cli-scaffold.d.ts +2 -1
- package/dist/runtime/cli-scaffold.js +23 -2
- package/dist/runtime/scaffold-onboarding.d.ts +2 -1
- package/dist/runtime/scaffold-onboarding.js +37 -8
- package/dist/runtime/scaffold.js +26 -15
- package/package.json +2 -2
- package/templates/_shared/base/package.json.mustache +4 -3
- package/templates/_shared/base/scripts/sync-project.ts.mustache +103 -0
- package/templates/_shared/compound/core/package.json.mustache +4 -3
- package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +42 -28
- package/templates/_shared/compound/core/scripts/sync-project.ts.mustache +103 -0
- package/templates/_shared/compound/persistence/package.json.mustache +4 -3
- package/templates/_shared/compound/persistence/scripts/sync-project.ts.mustache +103 -0
- package/templates/_shared/compound/persistence/scripts/sync-rest-contracts.ts.mustache +28 -0
- package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/interactivity.ts.mustache +8 -0
- package/templates/_shared/compound/persistence-auth/{{slugKebabCase}}.php.mustache +5 -5
- package/templates/_shared/compound/persistence-public/{{slugKebabCase}}.php.mustache +5 -5
- package/templates/_shared/persistence/auth/{{slugKebabCase}}.php.mustache +5 -5
- package/templates/_shared/persistence/core/package.json.mustache +4 -3
- package/templates/_shared/persistence/core/scripts/sync-project.ts.mustache +103 -0
- package/templates/_shared/persistence/core/scripts/sync-rest-contracts.ts.mustache +28 -0
- package/templates/_shared/persistence/core/src/interactivity.ts.mustache +5 -0
- package/templates/_shared/persistence/core/{{slugKebabCase}}.php.mustache +5 -5
- package/templates/_shared/persistence/public/{{slugKebabCase}}.php.mustache +5 -5
- package/templates/_shared/workspace/persistence-auth/server.php.mustache +7 -5
- package/templates/_shared/workspace/persistence-public/server.php.mustache +7 -5
- package/templates/compound/src/blocks/{{slugKebabCase}}/types.ts.mustache +5 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}/validators.ts.mustache +10 -3
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/types.ts.mustache +5 -0
- package/templates/compound/src/blocks/{{slugKebabCase}}-item/validators.ts.mustache +10 -3
- package/templates/interactivity/package.json.mustache +4 -3
- package/templates/interactivity/src/edit.tsx.mustache +1 -1
- package/templates/interactivity/src/save.tsx.mustache +1 -1
- package/templates/persistence/src/edit.tsx.mustache +2 -2
|
@@ -87,7 +87,7 @@ function {{phpPrefix}}_with_counter_lock( $post_id, $resource_key, $callback ) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function {{phpPrefix}}_maybe_install_storage() {
|
|
90
|
-
if ( 'custom-table' !==
|
|
90
|
+
if ( 'custom-table' !== {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -118,7 +118,7 @@ function {{phpPrefix}}_maybe_install_storage() {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
function {{phpPrefix}}_ensure_storage_installed() {
|
|
121
|
-
if ( 'custom-table' ===
|
|
121
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE && '1.0.0' !== get_option( '{{phpPrefix}}_storage_version', '' ) ) {
|
|
122
122
|
{{phpPrefix}}_maybe_install_storage();
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -130,7 +130,7 @@ function {{phpPrefix}}_get_rest_build_dir() {
|
|
|
130
130
|
function {{phpPrefix}}_get_counter( $post_id, $resource_key ) {
|
|
131
131
|
global $wpdb;
|
|
132
132
|
|
|
133
|
-
if ( 'custom-table' ===
|
|
133
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
134
134
|
$table_name = {{phpPrefix}}_get_counter_table_name();
|
|
135
135
|
$count = $wpdb->get_var(
|
|
136
136
|
$wpdb->prepare(
|
|
@@ -152,7 +152,7 @@ function {{phpPrefix}}_get_counter( $post_id, $resource_key ) {
|
|
|
152
152
|
function {{phpPrefix}}_increment_counter( $post_id, $resource_key, $delta ) {
|
|
153
153
|
global $wpdb;
|
|
154
154
|
|
|
155
|
-
if ( 'custom-table' ===
|
|
155
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
156
156
|
$table_name = {{phpPrefix}}_get_counter_table_name();
|
|
157
157
|
$delta_value = (int) $delta;
|
|
158
158
|
$initial_count = max( 0, $delta_value );
|
|
@@ -196,7 +196,7 @@ function {{phpPrefix}}_build_state_response( $post_id, $resource_key, $count ) {
|
|
|
196
196
|
'postId' => (int) $post_id,
|
|
197
197
|
'resourceKey' => (string) $resource_key,
|
|
198
198
|
'count' => (int) $count,
|
|
199
|
-
'storage' =>
|
|
199
|
+
'storage' => {{phpPrefixUpper}}_DATA_STORAGE_MODE,
|
|
200
200
|
);
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -7,6 +7,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
|
7
7
|
require_once __DIR__ . '/inc/rest-shared.php';
|
|
8
8
|
require_once __DIR__ . '/inc/rest-auth.php';
|
|
9
9
|
|
|
10
|
+
define( '{{phpPrefixUpper}}_DATA_STORAGE_MODE', '{{dataStorageMode}}' );
|
|
11
|
+
|
|
10
12
|
function {{phpPrefix}}_get_rest_build_dir() {
|
|
11
13
|
return dirname( __DIR__, 3 ) . '/build/blocks/{{slugKebabCase}}';
|
|
12
14
|
}
|
|
@@ -50,7 +52,7 @@ function {{phpPrefix}}_with_counter_lock( $post_id, $resource_key, $callback ) {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
function {{phpPrefix}}_maybe_install_storage() {
|
|
53
|
-
if ( 'custom-table' !==
|
|
55
|
+
if ( 'custom-table' !== {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -81,7 +83,7 @@ function {{phpPrefix}}_maybe_install_storage() {
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
function {{phpPrefix}}_ensure_storage_installed() {
|
|
84
|
-
if ( 'custom-table' ===
|
|
86
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE && '1.0.0' !== get_option( '{{phpPrefix}}_storage_version', '' ) ) {
|
|
85
87
|
{{phpPrefix}}_maybe_install_storage();
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -89,7 +91,7 @@ function {{phpPrefix}}_ensure_storage_installed() {
|
|
|
89
91
|
function {{phpPrefix}}_get_counter( $post_id, $resource_key ) {
|
|
90
92
|
global $wpdb;
|
|
91
93
|
|
|
92
|
-
if ( 'custom-table' ===
|
|
94
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
93
95
|
$table_name = {{phpPrefix}}_get_counter_table_name();
|
|
94
96
|
$count = $wpdb->get_var(
|
|
95
97
|
$wpdb->prepare(
|
|
@@ -110,7 +112,7 @@ function {{phpPrefix}}_get_counter( $post_id, $resource_key ) {
|
|
|
110
112
|
function {{phpPrefix}}_increment_counter( $post_id, $resource_key, $delta ) {
|
|
111
113
|
global $wpdb;
|
|
112
114
|
|
|
113
|
-
if ( 'custom-table' ===
|
|
115
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
114
116
|
$table_name = {{phpPrefix}}_get_counter_table_name();
|
|
115
117
|
$delta_value = (int) $delta;
|
|
116
118
|
$initial_count = max( 0, $delta_value );
|
|
@@ -154,7 +156,7 @@ function {{phpPrefix}}_build_state_response( $post_id, $resource_key, $count ) {
|
|
|
154
156
|
'postId' => (int) $post_id,
|
|
155
157
|
'resourceKey' => (string) $resource_key,
|
|
156
158
|
'count' => (int) $count,
|
|
157
|
-
'storage' =>
|
|
159
|
+
'storage' => {{phpPrefixUpper}}_DATA_STORAGE_MODE,
|
|
158
160
|
);
|
|
159
161
|
}
|
|
160
162
|
|
|
@@ -7,6 +7,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
|
7
7
|
require_once __DIR__ . '/inc/rest-shared.php';
|
|
8
8
|
require_once __DIR__ . '/inc/rest-public.php';
|
|
9
9
|
|
|
10
|
+
define( '{{phpPrefixUpper}}_DATA_STORAGE_MODE', '{{dataStorageMode}}' );
|
|
11
|
+
|
|
10
12
|
function {{phpPrefix}}_get_rest_build_dir() {
|
|
11
13
|
return dirname( __DIR__, 3 ) . '/build/blocks/{{slugKebabCase}}';
|
|
12
14
|
}
|
|
@@ -50,7 +52,7 @@ function {{phpPrefix}}_with_counter_lock( $post_id, $resource_key, $callback ) {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
function {{phpPrefix}}_maybe_install_storage() {
|
|
53
|
-
if ( 'custom-table' !==
|
|
55
|
+
if ( 'custom-table' !== {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -81,7 +83,7 @@ function {{phpPrefix}}_maybe_install_storage() {
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
function {{phpPrefix}}_ensure_storage_installed() {
|
|
84
|
-
if ( 'custom-table' ===
|
|
86
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE && '1.0.0' !== get_option( '{{phpPrefix}}_storage_version', '' ) ) {
|
|
85
87
|
{{phpPrefix}}_maybe_install_storage();
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -89,7 +91,7 @@ function {{phpPrefix}}_ensure_storage_installed() {
|
|
|
89
91
|
function {{phpPrefix}}_get_counter( $post_id, $resource_key ) {
|
|
90
92
|
global $wpdb;
|
|
91
93
|
|
|
92
|
-
if ( 'custom-table' ===
|
|
94
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
93
95
|
$table_name = {{phpPrefix}}_get_counter_table_name();
|
|
94
96
|
$count = $wpdb->get_var(
|
|
95
97
|
$wpdb->prepare(
|
|
@@ -110,7 +112,7 @@ function {{phpPrefix}}_get_counter( $post_id, $resource_key ) {
|
|
|
110
112
|
function {{phpPrefix}}_increment_counter( $post_id, $resource_key, $delta ) {
|
|
111
113
|
global $wpdb;
|
|
112
114
|
|
|
113
|
-
if ( 'custom-table' ===
|
|
115
|
+
if ( 'custom-table' === {{phpPrefixUpper}}_DATA_STORAGE_MODE ) {
|
|
114
116
|
$table_name = {{phpPrefix}}_get_counter_table_name();
|
|
115
117
|
$delta_value = (int) $delta;
|
|
116
118
|
$initial_count = max( 0, $delta_value );
|
|
@@ -154,7 +156,7 @@ function {{phpPrefix}}_build_state_response( $post_id, $resource_key, $count ) {
|
|
|
154
156
|
'postId' => (int) $post_id,
|
|
155
157
|
'resourceKey' => (string) $resource_key,
|
|
156
158
|
'count' => (int) $count,
|
|
157
|
-
'storage' =>
|
|
159
|
+
'storage' => {{phpPrefixUpper}}_DATA_STORAGE_MODE,
|
|
158
160
|
);
|
|
159
161
|
}
|
|
160
162
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { ValidationResult } from '@wp-typia/block-runtime/validation';
|
|
1
2
|
import { tags } from 'typia';
|
|
2
3
|
|
|
4
|
+
export type { ValidationResult } from '@wp-typia/block-runtime/validation';
|
|
5
|
+
|
|
3
6
|
export interface {{pascalCase}}Attributes {
|
|
4
7
|
heading: string &
|
|
5
8
|
tags.MinLength< 1 > &
|
|
@@ -11,3 +14,5 @@ export interface {{pascalCase}}Attributes {
|
|
|
11
14
|
tags.Default< 'Add and reorder internal items inside this compound block.' >;
|
|
12
15
|
showDividers?: boolean & tags.Default< true >;
|
|
13
16
|
}
|
|
17
|
+
|
|
18
|
+
export type {{pascalCase}}ValidationResult = ValidationResult< {{pascalCase}}Attributes >;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import typia from 'typia';
|
|
2
2
|
import currentManifest from './typia.manifest.json';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
{{pascalCase}}Attributes,
|
|
5
|
+
{{pascalCase}}ValidationResult,
|
|
6
|
+
} from './types';
|
|
4
7
|
import { createTemplateValidatorToolkit } from '../../validator-toolkit';
|
|
5
8
|
|
|
6
9
|
const scaffoldValidators = createTemplateValidatorToolkit< {{pascalCase}}Attributes >( {
|
|
@@ -18,11 +21,15 @@ const scaffoldValidators = createTemplateValidatorToolkit< {{pascalCase}}Attribu
|
|
|
18
21
|
} );
|
|
19
22
|
|
|
20
23
|
export const validate{{pascalCase}}Attributes =
|
|
21
|
-
scaffoldValidators.validateAttributes
|
|
24
|
+
scaffoldValidators.validateAttributes as (
|
|
25
|
+
attributes: unknown
|
|
26
|
+
) => {{pascalCase}}ValidationResult;
|
|
22
27
|
|
|
23
28
|
export const validators = scaffoldValidators.validators;
|
|
24
29
|
|
|
25
30
|
export const sanitize{{pascalCase}}Attributes =
|
|
26
|
-
scaffoldValidators.sanitizeAttributes
|
|
31
|
+
scaffoldValidators.sanitizeAttributes as (
|
|
32
|
+
attributes: Partial< {{pascalCase}}Attributes >
|
|
33
|
+
) => {{pascalCase}}Attributes;
|
|
27
34
|
|
|
28
35
|
export const createAttributeUpdater = scaffoldValidators.createAttributeUpdater;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { ValidationResult } from '@wp-typia/block-runtime/validation';
|
|
1
2
|
import { tags } from 'typia';
|
|
2
3
|
|
|
4
|
+
export type { ValidationResult } from '@wp-typia/block-runtime/validation';
|
|
5
|
+
|
|
3
6
|
export interface {{pascalCase}}ItemAttributes {
|
|
4
7
|
title: string &
|
|
5
8
|
tags.MinLength< 1 > &
|
|
@@ -10,3 +13,5 @@ export interface {{pascalCase}}ItemAttributes {
|
|
|
10
13
|
tags.MaxLength< 280 > &
|
|
11
14
|
tags.Default< 'Add supporting details for this internal item.' >;
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
export type {{pascalCase}}ItemValidationResult = ValidationResult< {{pascalCase}}ItemAttributes >;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import typia from 'typia';
|
|
2
2
|
import currentManifest from './typia.manifest.json';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
{{pascalCase}}ItemAttributes,
|
|
5
|
+
{{pascalCase}}ItemValidationResult,
|
|
6
|
+
} from './types';
|
|
4
7
|
import { createTemplateValidatorToolkit } from '../../validator-toolkit';
|
|
5
8
|
|
|
6
9
|
const scaffoldValidators = createTemplateValidatorToolkit< {{pascalCase}}ItemAttributes >( {
|
|
@@ -18,11 +21,15 @@ const scaffoldValidators = createTemplateValidatorToolkit< {{pascalCase}}ItemAtt
|
|
|
18
21
|
} );
|
|
19
22
|
|
|
20
23
|
export const validate{{pascalCase}}ItemAttributes =
|
|
21
|
-
scaffoldValidators.validateAttributes
|
|
24
|
+
scaffoldValidators.validateAttributes as (
|
|
25
|
+
attributes: unknown
|
|
26
|
+
) => {{pascalCase}}ItemValidationResult;
|
|
22
27
|
|
|
23
28
|
export const validators = scaffoldValidators.validators;
|
|
24
29
|
|
|
25
30
|
export const sanitize{{pascalCase}}ItemAttributes =
|
|
26
|
-
scaffoldValidators.sanitizeAttributes
|
|
31
|
+
scaffoldValidators.sanitizeAttributes as (
|
|
32
|
+
attributes: Partial< {{pascalCase}}ItemAttributes >
|
|
33
|
+
) => {{pascalCase}}ItemAttributes;
|
|
27
34
|
|
|
28
35
|
export const createAttributeUpdater = scaffoldValidators.createAttributeUpdater;
|
|
@@ -7,15 +7,16 @@
|
|
|
7
7
|
"license": "GPL-2.0-or-later",
|
|
8
8
|
"main": "build/index.js",
|
|
9
9
|
"scripts": {
|
|
10
|
+
"sync": "tsx scripts/sync-project.ts",
|
|
10
11
|
"sync-types": "tsx scripts/sync-types-to-block-json.ts",
|
|
11
|
-
"build": "bun run sync
|
|
12
|
-
"start": "bun run sync
|
|
12
|
+
"build": "bun run sync --check && wp-scripts build --experimental-modules",
|
|
13
|
+
"start": "bun run sync && wp-scripts start --experimental-modules",
|
|
13
14
|
"dev": "bun run start",
|
|
14
15
|
"lint:js": "wp-scripts lint-js",
|
|
15
16
|
"lint:css": "wp-scripts lint-style",
|
|
16
17
|
"lint": "bun run lint:js && bun run lint:css",
|
|
17
18
|
"format": "wp-scripts format",
|
|
18
|
-
"typecheck": "bun run sync
|
|
19
|
+
"typecheck": "bun run sync --check && tsc --noEmit"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@wp-typia/block-runtime": "{{blockRuntimePackageVersion}}",
|
|
@@ -258,7 +258,7 @@ export default function Edit({ attributes, setAttributes, isSelected }: {
|
|
|
258
258
|
{animation !== 'none' && (
|
|
259
259
|
<div
|
|
260
260
|
className={`{{cssClassName}}__animation ${attributes.isAnimating ? 'is-active' : ''}`}
|
|
261
|
-
data-wp-class
|
|
261
|
+
data-wp-class--is-active="state.isAnimating"
|
|
262
262
|
>
|
|
263
263
|
{animation}
|
|
264
264
|
</div>
|
|
@@ -70,7 +70,7 @@ export default function Save({ attributes }: { attributes: {{pascalCase}}Attribu
|
|
|
70
70
|
<div
|
|
71
71
|
className={`{{cssClassName}}__animation ${attributes.animation}`}
|
|
72
72
|
aria-hidden="true"
|
|
73
|
-
data-wp-class
|
|
73
|
+
data-wp-class--is-active="state.isAnimating"
|
|
74
74
|
/>
|
|
75
75
|
|
|
76
76
|
{attributes.maxClicks > 0 && (
|
|
@@ -66,7 +66,7 @@ export default function Edit( {
|
|
|
66
66
|
validateEditorUpdate
|
|
67
67
|
);
|
|
68
68
|
const alignmentValue = editorFields.getStringValue(
|
|
69
|
-
attributes
|
|
69
|
+
attributes,
|
|
70
70
|
'alignment',
|
|
71
71
|
'left'
|
|
72
72
|
);
|
|
@@ -91,7 +91,7 @@ export default function Edit( {
|
|
|
91
91
|
</BlockControls>
|
|
92
92
|
<InspectorControls>
|
|
93
93
|
<InspectorFromManifest
|
|
94
|
-
attributes={ attributes
|
|
94
|
+
attributes={ attributes }
|
|
95
95
|
fieldLookup={ editorFields }
|
|
96
96
|
onChange={ updateField }
|
|
97
97
|
paths={ [ 'alignment', 'isVisible', 'showCount', 'buttonLabel' ] }
|