@wp-typia/project-tools 0.16.8 → 0.16.10
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 +14 -4
- package/dist/runtime/block-generator-service.d.ts +5 -1
- package/dist/runtime/block-generator-service.js +7 -3
- package/dist/runtime/built-in-block-artifacts.js +388 -572
- package/dist/runtime/built-in-block-code-artifacts.js +96 -46
- package/dist/runtime/built-in-block-code-templates.d.ts +36 -0
- package/dist/runtime/built-in-block-code-templates.js +2234 -0
- package/dist/runtime/cli-add-block.d.ts +2 -1
- package/dist/runtime/cli-add-block.js +163 -25
- package/dist/runtime/cli-add-shared.d.ts +7 -0
- package/dist/runtime/cli-add-shared.js +4 -6
- package/dist/runtime/cli-add-workspace.js +56 -17
- package/dist/runtime/cli-core.d.ts +4 -0
- package/dist/runtime/cli-core.js +3 -0
- package/dist/runtime/cli-diagnostics.d.ts +58 -0
- package/dist/runtime/cli-diagnostics.js +101 -0
- package/dist/runtime/cli-doctor.d.ts +2 -1
- package/dist/runtime/cli-doctor.js +16 -5
- package/dist/runtime/cli-help.js +4 -4
- package/dist/runtime/cli-scaffold.d.ts +5 -1
- package/dist/runtime/cli-scaffold.js +138 -111
- package/dist/runtime/external-layer-selection.d.ts +14 -0
- package/dist/runtime/external-layer-selection.js +35 -0
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/migration-render.d.ts +23 -1
- package/dist/runtime/migration-render.js +58 -10
- package/dist/runtime/migration-ui-capability.js +17 -8
- package/dist/runtime/migration-utils.d.ts +7 -6
- package/dist/runtime/migration-utils.js +76 -73
- package/dist/runtime/migrations.js +2 -2
- package/dist/runtime/object-utils.d.ts +8 -1
- package/dist/runtime/object-utils.js +21 -1
- package/dist/runtime/scaffold-apply-utils.d.ts +14 -2
- package/dist/runtime/scaffold-apply-utils.js +19 -6
- package/dist/runtime/scaffold-repository-reference.d.ts +22 -0
- package/dist/runtime/scaffold-repository-reference.js +119 -0
- package/dist/runtime/scaffold.d.ts +5 -1
- package/dist/runtime/scaffold.js +15 -37
- package/dist/runtime/template-layers.d.ts +6 -0
- package/dist/runtime/template-layers.js +20 -7
- package/dist/runtime/template-render.d.ts +13 -2
- package/dist/runtime/template-render.js +102 -71
- package/dist/runtime/template-source.d.ts +6 -5
- package/dist/runtime/template-source.js +284 -217
- package/package.json +8 -3
- package/templates/_shared/base/src/validator-toolkit.ts.mustache +2 -2
- package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +61 -16
- package/templates/_shared/migration-ui/common/src/migrations/helpers.ts +19 -47
- package/templates/_shared/migration-ui/common/src/migrations/index.ts +40 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-typia/project-tools",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.10",
|
|
4
4
|
"description": "Project orchestration and programmatic tooling for wp-typia",
|
|
5
5
|
"packageManager": "bun@1.3.11",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"import": "./dist/runtime/cli-add.js",
|
|
18
18
|
"default": "./dist/runtime/cli-add.js"
|
|
19
19
|
},
|
|
20
|
+
"./cli-diagnostics": {
|
|
21
|
+
"types": "./dist/runtime/cli-diagnostics.d.ts",
|
|
22
|
+
"import": "./dist/runtime/cli-diagnostics.js",
|
|
23
|
+
"default": "./dist/runtime/cli-diagnostics.js"
|
|
24
|
+
},
|
|
20
25
|
"./cli-doctor": {
|
|
21
26
|
"types": "./dist/runtime/cli-doctor.d.ts",
|
|
22
27
|
"import": "./dist/runtime/cli-doctor.js",
|
|
@@ -115,9 +120,9 @@
|
|
|
115
120
|
},
|
|
116
121
|
"dependencies": {
|
|
117
122
|
"@wp-typia/api-client": "^0.4.4",
|
|
118
|
-
"@wp-typia/block-runtime": "^0.4.
|
|
123
|
+
"@wp-typia/block-runtime": "^0.4.8",
|
|
119
124
|
"@wp-typia/rest": "^0.3.7",
|
|
120
|
-
"@wp-typia/block-types": "^0.2.
|
|
125
|
+
"@wp-typia/block-types": "^0.2.3",
|
|
121
126
|
"mustache": "^4.2.0",
|
|
122
127
|
"npm-package-arg": "^13.0.0",
|
|
123
128
|
"semver": "^7.7.3",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ManifestDefaultsDocument } from '@wp-typia/block-runtime/defaults';
|
|
2
1
|
import {
|
|
3
2
|
createScaffoldValidatorToolkit,
|
|
4
3
|
type ScaffoldValidatorToolkitOptions,
|
|
5
4
|
} from '@wp-typia/block-runtime/validation';
|
|
5
|
+
import { parseManifestDefaultsDocument } from '@wp-typia/block-runtime/defaults';
|
|
6
6
|
|
|
7
7
|
interface TemplateValidatorFunctions< T extends object > {
|
|
8
8
|
assert: ScaffoldValidatorToolkitOptions< T >['assert'];
|
|
@@ -32,7 +32,7 @@ export function createTemplateValidatorToolkit< T extends object >( {
|
|
|
32
32
|
validate,
|
|
33
33
|
}: TemplateValidatorToolkitOptions< T > ) {
|
|
34
34
|
return createScaffoldValidatorToolkit< T >( {
|
|
35
|
-
manifest: manifest
|
|
35
|
+
manifest: parseManifestDefaultsDocument( manifest ),
|
|
36
36
|
validate,
|
|
37
37
|
assert,
|
|
38
38
|
is,
|
|
@@ -410,12 +410,42 @@ export const useTypiaValidation = createUseTypiaValidationHook( {
|
|
|
410
410
|
`;
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
function renderBlockMetadataFile(): string {
|
|
414
|
+
return `import rawMetadata from './block.json';
|
|
415
|
+
import { defineScaffoldBlockMetadata } from '@wp-typia/block-runtime/blocks';
|
|
416
|
+
|
|
417
|
+
const metadata = defineScaffoldBlockMetadata( rawMetadata );
|
|
418
|
+
|
|
419
|
+
export default metadata;
|
|
420
|
+
`;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function renderManifestDocumentFile(): string {
|
|
424
|
+
return `import rawCurrentManifest from './typia.manifest.json';
|
|
425
|
+
import { defineManifestDocument } from '@wp-typia/block-runtime/editor';
|
|
426
|
+
|
|
427
|
+
const currentManifest = defineManifestDocument( rawCurrentManifest );
|
|
428
|
+
|
|
429
|
+
export default currentManifest;
|
|
430
|
+
`;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function renderManifestDefaultsDocumentFile(): string {
|
|
434
|
+
return `import rawCurrentManifest from './typia.manifest.json';
|
|
435
|
+
import { defineManifestDefaultsDocument } from '@wp-typia/block-runtime/defaults';
|
|
436
|
+
|
|
437
|
+
const currentManifest = defineManifestDefaultsDocument( rawCurrentManifest );
|
|
438
|
+
|
|
439
|
+
export default currentManifest;
|
|
440
|
+
`;
|
|
441
|
+
}
|
|
442
|
+
|
|
413
443
|
function renderValidatorsFile(
|
|
414
444
|
childTypeName: string,
|
|
415
445
|
childInterfaceName: string
|
|
416
446
|
): string {
|
|
417
447
|
return `import typia from 'typia';
|
|
418
|
-
import currentManifest from './
|
|
448
|
+
import currentManifest from './manifest-defaults-document';
|
|
419
449
|
import type {
|
|
420
450
|
\t${ childTypeName },
|
|
421
451
|
\t${ childInterfaceName }ValidationResult,
|
|
@@ -460,7 +490,7 @@ function renderEditFile(
|
|
|
460
490
|
): string {
|
|
461
491
|
const childCssClassName = buildBlockCssClassName( PARENT_BLOCK_NAMESPACE, childFolderSlug );
|
|
462
492
|
|
|
463
|
-
return `import type { BlockEditProps } from '@
|
|
493
|
+
return `import type { BlockEditProps } from '@wp-typia/block-types/blocks/registration';
|
|
464
494
|
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
465
495
|
import { Notice } from '@wordpress/components';
|
|
466
496
|
import { __ } from '@wordpress/i18n';
|
|
@@ -546,31 +576,31 @@ export default function Save( {
|
|
|
546
576
|
}
|
|
547
577
|
|
|
548
578
|
function renderIndexFile( childTypeName: string, childFolderSlug: string ): string {
|
|
549
|
-
|
|
550
|
-
|
|
579
|
+
return `import {
|
|
580
|
+
\tregisterScaffoldBlockType,
|
|
581
|
+
\ttype BlockConfiguration,
|
|
582
|
+
} from '@wp-typia/block-types/blocks/registration';
|
|
551
583
|
import {
|
|
552
584
|
\tbuildScaffoldBlockRegistration,
|
|
553
|
-
\
|
|
585
|
+
\tparseScaffoldBlockMetadata,
|
|
554
586
|
} from '@wp-typia/block-runtime/blocks';
|
|
555
587
|
|
|
556
588
|
import Edit from './edit';
|
|
557
589
|
import Save from './save';
|
|
558
|
-
import metadata from './block
|
|
590
|
+
import metadata from './block-metadata';
|
|
559
591
|
import '${ PARENT_STYLE_IMPORT }';
|
|
560
592
|
|
|
561
593
|
import type { ${ childTypeName } } from './types';
|
|
562
594
|
|
|
563
|
-
const registration = buildScaffoldBlockRegistration
|
|
564
|
-
\
|
|
565
|
-
|
|
566
|
-
\tedit: Edit,
|
|
567
|
-
\tsave: Save,
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
registerBlockType< ${ childTypeName } >(
|
|
571
|
-
\tregistration.name,
|
|
572
|
-
\tregistration.settings
|
|
595
|
+
const registration = buildScaffoldBlockRegistration(
|
|
596
|
+
\tparseScaffoldBlockMetadata<BlockConfiguration< ${ childTypeName } >>( metadata ),
|
|
597
|
+
\t{
|
|
598
|
+
\t\tedit: Edit,
|
|
599
|
+
\t\tsave: Save,
|
|
600
|
+
\t}
|
|
573
601
|
);
|
|
602
|
+
|
|
603
|
+
registerScaffoldBlockType( registration.name, registration.settings );
|
|
574
604
|
`;
|
|
575
605
|
}
|
|
576
606
|
|
|
@@ -625,6 +655,21 @@ function main() {
|
|
|
625
655
|
renderStarterManifestFile( childTypeName, childTitle ),
|
|
626
656
|
'utf8'
|
|
627
657
|
);
|
|
658
|
+
fs.writeFileSync(
|
|
659
|
+
path.join( childDir, 'block-metadata.ts' ),
|
|
660
|
+
renderBlockMetadataFile(),
|
|
661
|
+
'utf8'
|
|
662
|
+
);
|
|
663
|
+
fs.writeFileSync(
|
|
664
|
+
path.join( childDir, 'manifest-document.ts' ),
|
|
665
|
+
renderManifestDocumentFile(),
|
|
666
|
+
'utf8'
|
|
667
|
+
);
|
|
668
|
+
fs.writeFileSync(
|
|
669
|
+
path.join( childDir, 'manifest-defaults-document.ts' ),
|
|
670
|
+
renderManifestDefaultsDocumentFile(),
|
|
671
|
+
'utf8'
|
|
672
|
+
);
|
|
628
673
|
fs.writeFileSync( path.join( childDir, 'hooks.ts' ), renderHooksFile(), 'utf8' );
|
|
629
674
|
fs.writeFileSync(
|
|
630
675
|
path.join( childDir, 'validators.ts' ),
|
|
@@ -1,42 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface ManifestAttribute {
|
|
7
|
-
typia: {
|
|
8
|
-
constraints: {
|
|
9
|
-
format: string | null;
|
|
10
|
-
maxLength: number | null;
|
|
11
|
-
maximum: number | null;
|
|
12
|
-
minLength: number | null;
|
|
13
|
-
minimum: number | null;
|
|
14
|
-
pattern: string | null;
|
|
15
|
-
typeTag: string | null;
|
|
16
|
-
};
|
|
17
|
-
defaultValue: unknown;
|
|
18
|
-
hasDefault: boolean;
|
|
19
|
-
};
|
|
20
|
-
ts: {
|
|
21
|
-
items: ManifestAttribute | null;
|
|
22
|
-
kind: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'union';
|
|
23
|
-
properties: Record< string, ManifestAttribute > | null;
|
|
24
|
-
required: boolean;
|
|
25
|
-
union: ManifestUnion | null;
|
|
26
|
-
};
|
|
27
|
-
wp: {
|
|
28
|
-
defaultValue: unknown;
|
|
29
|
-
enum: Array< string | number | boolean > | null;
|
|
30
|
-
hasDefault: boolean;
|
|
31
|
-
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
32
|
-
};
|
|
33
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
ManifestAttribute,
|
|
3
|
+
ManifestDocument,
|
|
4
|
+
} from '@wp-typia/block-runtime/migration-types';
|
|
34
5
|
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
6
|
+
export type {
|
|
7
|
+
ManifestAttribute,
|
|
8
|
+
ManifestDocument,
|
|
9
|
+
} from '@wp-typia/block-runtime/migration-types';
|
|
40
10
|
|
|
41
11
|
export interface MigrationRiskBucket {
|
|
42
12
|
count: number;
|
|
@@ -282,7 +252,7 @@ export function manifestMatchesDocument(
|
|
|
282
252
|
manifest: ManifestDocument,
|
|
283
253
|
attributes: Record< string, unknown >
|
|
284
254
|
): boolean {
|
|
285
|
-
for ( const [ key, attribute ] of Object.entries( manifest.attributes ) ) {
|
|
255
|
+
for ( const [ key, attribute ] of Object.entries( manifest.attributes ?? {} ) ) {
|
|
286
256
|
const value = attributes[ key ];
|
|
287
257
|
if (
|
|
288
258
|
( value === undefined || value === null ) &&
|
|
@@ -304,20 +274,22 @@ export function summarizeVersionDelta(
|
|
|
304
274
|
legacyManifest: ManifestDocument,
|
|
305
275
|
currentManifest: ManifestDocument
|
|
306
276
|
): { added: string[]; removed: string[]; changed: string[] } {
|
|
307
|
-
const
|
|
308
|
-
|
|
277
|
+
const currentAttributes = currentManifest.attributes ?? {};
|
|
278
|
+
const legacyAttributes = legacyManifest.attributes ?? {};
|
|
279
|
+
const added = Object.keys( currentAttributes ).filter(
|
|
280
|
+
( key ) => ! ( key in legacyAttributes )
|
|
309
281
|
);
|
|
310
|
-
const removed = Object.keys(
|
|
311
|
-
( key ) => ! ( key in
|
|
282
|
+
const removed = Object.keys( legacyAttributes ).filter(
|
|
283
|
+
( key ) => ! ( key in currentAttributes )
|
|
312
284
|
);
|
|
313
|
-
const changed = Object.keys(
|
|
285
|
+
const changed = Object.keys( currentAttributes ).filter(
|
|
314
286
|
( key ) => {
|
|
315
|
-
if ( ! ( key in
|
|
287
|
+
if ( ! ( key in legacyAttributes ) ) {
|
|
316
288
|
return false;
|
|
317
289
|
}
|
|
318
290
|
return (
|
|
319
|
-
JSON.stringify(
|
|
320
|
-
JSON.stringify(
|
|
291
|
+
JSON.stringify( currentAttributes[ key ] ) !==
|
|
292
|
+
JSON.stringify( legacyAttributes[ key ] )
|
|
321
293
|
);
|
|
322
294
|
}
|
|
323
295
|
);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import apiFetch from '@wordpress/api-fetch';
|
|
2
|
-
import { parse, serialize
|
|
2
|
+
import { parse, serialize } from '@wordpress/blocks';
|
|
3
|
+
import type { BlockInstance } from '@wp-typia/block-types/blocks/registration';
|
|
4
|
+
import { parseManifestDocument } from '@wp-typia/block-runtime/editor';
|
|
3
5
|
import typia from 'typia';
|
|
4
6
|
|
|
5
7
|
import migrationBlocks from './generated';
|
|
@@ -148,6 +150,36 @@ interface MigrationResolution {
|
|
|
148
150
|
preview: MigrationPreview;
|
|
149
151
|
}
|
|
150
152
|
|
|
153
|
+
const manifestDocumentCache = new WeakMap< object, ManifestDocument >();
|
|
154
|
+
|
|
155
|
+
function parseCachedManifestDocument( manifest: unknown ): ManifestDocument {
|
|
156
|
+
if ( typeof manifest !== 'object' || manifest === null ) {
|
|
157
|
+
return parseManifestDocument< ManifestDocument >( manifest );
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const cached = manifestDocumentCache.get( manifest );
|
|
161
|
+
if ( cached ) {
|
|
162
|
+
return cached;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const parsed = parseManifestDocument< ManifestDocument >( manifest );
|
|
166
|
+
manifestDocumentCache.set( manifest, parsed );
|
|
167
|
+
return parsed;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function getCurrentManifestDocument(
|
|
171
|
+
target: MigrationTargetRuntime
|
|
172
|
+
): ManifestDocument {
|
|
173
|
+
return parseCachedManifestDocument( target.registry.currentManifest );
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getLegacyManifestDocument(
|
|
177
|
+
target: MigrationTargetRuntime,
|
|
178
|
+
entry: MigrationTargetRuntime[ 'registry' ][ 'entries' ][ number ]
|
|
179
|
+
): ManifestDocument {
|
|
180
|
+
return parseCachedManifestDocument( entry.manifest );
|
|
181
|
+
}
|
|
182
|
+
|
|
151
183
|
const EMPTY_RISK_SUMMARY: MigrationRiskSummary = {
|
|
152
184
|
additive: {
|
|
153
185
|
count: 0,
|
|
@@ -633,8 +665,7 @@ function resolveMigrationState(
|
|
|
633
665
|
preview: createPreview( {
|
|
634
666
|
after: attributes,
|
|
635
667
|
before: attributes,
|
|
636
|
-
currentManifest:
|
|
637
|
-
target.registry.currentManifest as ManifestDocument,
|
|
668
|
+
currentManifest: getCurrentManifestDocument( target ),
|
|
638
669
|
legacyManifest: null,
|
|
639
670
|
status: 'current',
|
|
640
671
|
unresolved: [],
|
|
@@ -646,7 +677,7 @@ function resolveMigrationState(
|
|
|
646
677
|
for ( const entry of target.registry.entries ) {
|
|
647
678
|
if (
|
|
648
679
|
manifestMatchesDocument(
|
|
649
|
-
entry
|
|
680
|
+
getLegacyManifestDocument( target, entry ),
|
|
650
681
|
attributes
|
|
651
682
|
)
|
|
652
683
|
) {
|
|
@@ -669,16 +700,15 @@ function resolveMigrationState(
|
|
|
669
700
|
? ( migrated as Record< string, unknown > )
|
|
670
701
|
: null,
|
|
671
702
|
before: attributes,
|
|
672
|
-
currentManifest:
|
|
673
|
-
|
|
674
|
-
legacyManifest: entry.manifest as ManifestDocument,
|
|
703
|
+
currentManifest: getCurrentManifestDocument( target ),
|
|
704
|
+
legacyManifest: getLegacyManifestDocument( target, entry ),
|
|
675
705
|
status,
|
|
676
706
|
unresolved,
|
|
677
707
|
validationErrors,
|
|
678
708
|
} );
|
|
679
709
|
const delta = summarizeVersionDelta(
|
|
680
|
-
entry
|
|
681
|
-
target
|
|
710
|
+
getLegacyManifestDocument( target, entry ),
|
|
711
|
+
getCurrentManifestDocument( target )
|
|
682
712
|
);
|
|
683
713
|
|
|
684
714
|
return {
|
|
@@ -727,8 +757,7 @@ function resolveMigrationState(
|
|
|
727
757
|
preview: createPreview( {
|
|
728
758
|
after: null,
|
|
729
759
|
before: attributes,
|
|
730
|
-
currentManifest:
|
|
731
|
-
target.registry.currentManifest as ManifestDocument,
|
|
760
|
+
currentManifest: getCurrentManifestDocument( target ),
|
|
732
761
|
legacyManifest: null,
|
|
733
762
|
status: 'unknown',
|
|
734
763
|
unresolved: [
|