@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,394 @@
|
|
|
1
|
+
/* eslint-disable no-alert */
|
|
2
|
+
import { useState } from '@wordpress/element';
|
|
3
|
+
import { Button, Card, CardBody, Notice, Spinner } from '@wordpress/components';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
type BatchMigrationResult,
|
|
8
|
+
type BlockScanResult,
|
|
9
|
+
batchMigrateScanResults,
|
|
10
|
+
generateMigrationReport,
|
|
11
|
+
scanSiteForMigrations,
|
|
12
|
+
} from '../migration-detector';
|
|
13
|
+
|
|
14
|
+
interface MigrationStats {
|
|
15
|
+
needsMigration: number;
|
|
16
|
+
riskTotals: {
|
|
17
|
+
additive: number;
|
|
18
|
+
rename: number;
|
|
19
|
+
semanticTransform: number;
|
|
20
|
+
unionBreaking: number;
|
|
21
|
+
};
|
|
22
|
+
total: number;
|
|
23
|
+
unknown: number;
|
|
24
|
+
versions: Record< string, number >;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const TEXT_DOMAIN = '{{textDomain}}';
|
|
28
|
+
|
|
29
|
+
function formatUnionStatus( status: BlockScanResult[ 'preview' ][ 'unionBranches' ][ number ][ 'status' ] ) {
|
|
30
|
+
switch ( status ) {
|
|
31
|
+
case 'auto':
|
|
32
|
+
return __( 'auto', TEXT_DOMAIN );
|
|
33
|
+
case 'current':
|
|
34
|
+
return __( 'current', TEXT_DOMAIN );
|
|
35
|
+
case 'manual':
|
|
36
|
+
return __( 'manual', TEXT_DOMAIN );
|
|
37
|
+
default:
|
|
38
|
+
return __( 'unknown', TEXT_DOMAIN );
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function formatRiskSummaryLine(
|
|
43
|
+
result: BlockScanResult[ 'analysis' ]
|
|
44
|
+
): string {
|
|
45
|
+
return `${ __( 'additive', TEXT_DOMAIN ) } ${ result.riskSummary.additive.count }, ${ __( 'rename', TEXT_DOMAIN ) } ${ result.riskSummary.rename.count }, ${ __( 'transform', TEXT_DOMAIN ) } ${ result.riskSummary.semanticTransform.count }, ${ __( 'union breaking', TEXT_DOMAIN ) } ${ result.riskSummary.unionBreaking.count }`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function collectStats( results: BlockScanResult[] ): MigrationStats {
|
|
49
|
+
return results.reduce< MigrationStats >(
|
|
50
|
+
( accumulator, result ) => {
|
|
51
|
+
accumulator.total += 1;
|
|
52
|
+
if ( result.analysis.needsMigration ) {
|
|
53
|
+
accumulator.needsMigration += 1;
|
|
54
|
+
}
|
|
55
|
+
if ( result.analysis.currentMigrationVersion === 'unknown' ) {
|
|
56
|
+
accumulator.unknown += 1;
|
|
57
|
+
}
|
|
58
|
+
accumulator.versions[ result.analysis.currentMigrationVersion ] =
|
|
59
|
+
( accumulator.versions[ result.analysis.currentMigrationVersion ] ??
|
|
60
|
+
0 ) + 1;
|
|
61
|
+
accumulator.riskTotals.additive +=
|
|
62
|
+
result.analysis.riskSummary.additive.count;
|
|
63
|
+
accumulator.riskTotals.rename +=
|
|
64
|
+
result.analysis.riskSummary.rename.count;
|
|
65
|
+
accumulator.riskTotals.semanticTransform +=
|
|
66
|
+
result.analysis.riskSummary.semanticTransform.count;
|
|
67
|
+
accumulator.riskTotals.unionBreaking +=
|
|
68
|
+
result.analysis.riskSummary.unionBreaking.count;
|
|
69
|
+
return accumulator;
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
needsMigration: 0,
|
|
73
|
+
riskTotals: {
|
|
74
|
+
additive: 0,
|
|
75
|
+
rename: 0,
|
|
76
|
+
semanticTransform: 0,
|
|
77
|
+
unionBreaking: 0,
|
|
78
|
+
},
|
|
79
|
+
total: 0,
|
|
80
|
+
unknown: 0,
|
|
81
|
+
versions: {},
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function downloadFile( contents: string, fileName: string, type: string ) {
|
|
87
|
+
const blob = new Blob( [ contents ], { type } );
|
|
88
|
+
const url = URL.createObjectURL( blob );
|
|
89
|
+
const link = document.createElement( 'a' );
|
|
90
|
+
link.href = url;
|
|
91
|
+
link.download = fileName;
|
|
92
|
+
link.click();
|
|
93
|
+
URL.revokeObjectURL( url );
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function formatUnionSummary( result: BlockScanResult[ 'preview' ] ): string {
|
|
97
|
+
if ( result.unionBranches.length === 0 ) {
|
|
98
|
+
return __( 'No union branch changes', TEXT_DOMAIN );
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return result.unionBranches
|
|
102
|
+
.map(
|
|
103
|
+
( branch ) =>
|
|
104
|
+
`${ branch.field }: ${ branch.legacyBranch ?? __( 'unknown', TEXT_DOMAIN ) } → ${
|
|
105
|
+
branch.nextBranch ?? __( 'unknown', TEXT_DOMAIN )
|
|
106
|
+
} (${ formatUnionStatus( branch.status ) })`
|
|
107
|
+
)
|
|
108
|
+
.join( ', ' );
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function renderJsonPreview( value: unknown ) {
|
|
112
|
+
return (
|
|
113
|
+
<pre
|
|
114
|
+
style={ {
|
|
115
|
+
background: '#f6f7f7',
|
|
116
|
+
borderRadius: '4px',
|
|
117
|
+
margin: '8px 0 0',
|
|
118
|
+
overflowX: 'auto',
|
|
119
|
+
padding: '8px',
|
|
120
|
+
} }
|
|
121
|
+
>
|
|
122
|
+
{ JSON.stringify( value, null, 2 ) }
|
|
123
|
+
</pre>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function MigrationDashboard() {
|
|
128
|
+
const [ results, setResults ] = useState< BlockScanResult[] >( [] );
|
|
129
|
+
const [ dryRunResult, setDryRunResult ] =
|
|
130
|
+
useState< BatchMigrationResult | null >( null );
|
|
131
|
+
const [ executionResult, setExecutionResult ] =
|
|
132
|
+
useState< BatchMigrationResult | null >( null );
|
|
133
|
+
const [ isScanning, setIsScanning ] = useState( false );
|
|
134
|
+
const [ isMigrating, setIsMigrating ] = useState( false );
|
|
135
|
+
const [ error, setError ] = useState< string | null >( null );
|
|
136
|
+
|
|
137
|
+
const stats = collectStats( results );
|
|
138
|
+
|
|
139
|
+
const runScan = async () => {
|
|
140
|
+
setIsScanning( true );
|
|
141
|
+
setError( null );
|
|
142
|
+
setDryRunResult( null );
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
setResults( await scanSiteForMigrations() );
|
|
146
|
+
} catch ( scanError ) {
|
|
147
|
+
setError(
|
|
148
|
+
scanError instanceof Error
|
|
149
|
+
? scanError.message
|
|
150
|
+
: String( scanError )
|
|
151
|
+
);
|
|
152
|
+
} finally {
|
|
153
|
+
setIsScanning( false );
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const runDryRun = async () => {
|
|
158
|
+
setError( null );
|
|
159
|
+
setExecutionResult( null );
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
setDryRunResult(
|
|
163
|
+
await batchMigrateScanResults( results, { dryRun: true } )
|
|
164
|
+
);
|
|
165
|
+
} catch ( batchError ) {
|
|
166
|
+
setError(
|
|
167
|
+
batchError instanceof Error
|
|
168
|
+
? batchError.message
|
|
169
|
+
: String( batchError )
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const runBatchMigration = async () => {
|
|
175
|
+
if (
|
|
176
|
+
! window.confirm(
|
|
177
|
+
__(
|
|
178
|
+
'Migrate all detected legacy blocks now?',
|
|
179
|
+
'{{textDomain}}'
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
setIsMigrating( true );
|
|
187
|
+
setError( null );
|
|
188
|
+
|
|
189
|
+
try {
|
|
190
|
+
setExecutionResult(
|
|
191
|
+
await batchMigrateScanResults( results, { dryRun: false } )
|
|
192
|
+
);
|
|
193
|
+
await runScan();
|
|
194
|
+
} catch ( batchError ) {
|
|
195
|
+
setError(
|
|
196
|
+
batchError instanceof Error
|
|
197
|
+
? batchError.message
|
|
198
|
+
: String( batchError )
|
|
199
|
+
);
|
|
200
|
+
} finally {
|
|
201
|
+
setIsMigrating( false );
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const downloadReport = () => {
|
|
206
|
+
downloadFile(
|
|
207
|
+
generateMigrationReport( results ),
|
|
208
|
+
'typia-migration-report.md',
|
|
209
|
+
'text/markdown'
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const downloadJson = () => {
|
|
214
|
+
downloadFile(
|
|
215
|
+
JSON.stringify(
|
|
216
|
+
{
|
|
217
|
+
executionResult,
|
|
218
|
+
dryRunResult,
|
|
219
|
+
results,
|
|
220
|
+
},
|
|
221
|
+
null,
|
|
222
|
+
2
|
|
223
|
+
),
|
|
224
|
+
'typia-migration-report.json',
|
|
225
|
+
'application/json'
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
<div className="wp-typia-migration-dashboard">
|
|
231
|
+
<Card>
|
|
232
|
+
<CardBody>
|
|
233
|
+
<div style={ { display: 'grid', gap: '12px' } }>
|
|
234
|
+
<div>
|
|
235
|
+
<strong>
|
|
236
|
+
{ __( 'Migration Manager', '{{textDomain}}' ) }
|
|
237
|
+
</strong>
|
|
238
|
+
<p style={ { margin: '4px 0 0' } }>
|
|
239
|
+
{ __(
|
|
240
|
+
'Scan posts for legacy attributes, preview field-level changes, and batch migrate to the current Typia contract.',
|
|
241
|
+
'{{textDomain}}'
|
|
242
|
+
) }
|
|
243
|
+
</p>
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
<div
|
|
247
|
+
style={ {
|
|
248
|
+
display: 'flex',
|
|
249
|
+
gap: '8px',
|
|
250
|
+
flexWrap: 'wrap',
|
|
251
|
+
} }
|
|
252
|
+
>
|
|
253
|
+
<Button
|
|
254
|
+
variant="secondary"
|
|
255
|
+
onClick={ runScan }
|
|
256
|
+
disabled={ isScanning }
|
|
257
|
+
>
|
|
258
|
+
{ isScanning
|
|
259
|
+
? __( 'Scanning…', '{{textDomain}}' )
|
|
260
|
+
: __( 'Scan site', '{{textDomain}}' ) }
|
|
261
|
+
</Button>
|
|
262
|
+
<Button
|
|
263
|
+
variant="secondary"
|
|
264
|
+
onClick={ runDryRun }
|
|
265
|
+
disabled={
|
|
266
|
+
results.length === 0 || isScanning || isMigrating
|
|
267
|
+
}
|
|
268
|
+
>
|
|
269
|
+
{ __( 'Preview dry run', '{{textDomain}}' ) }
|
|
270
|
+
</Button>
|
|
271
|
+
<Button
|
|
272
|
+
variant="primary"
|
|
273
|
+
onClick={ runBatchMigration }
|
|
274
|
+
disabled={
|
|
275
|
+
results.length === 0 || isScanning || isMigrating
|
|
276
|
+
}
|
|
277
|
+
>
|
|
278
|
+
{ isMigrating
|
|
279
|
+
? __( 'Migrating…', '{{textDomain}}' )
|
|
280
|
+
: __( 'Run migration', '{{textDomain}}' ) }
|
|
281
|
+
</Button>
|
|
282
|
+
<Button
|
|
283
|
+
variant="tertiary"
|
|
284
|
+
onClick={ downloadReport }
|
|
285
|
+
disabled={ results.length === 0 }
|
|
286
|
+
>
|
|
287
|
+
{ __( 'Export Markdown', '{{textDomain}}' ) }
|
|
288
|
+
</Button>
|
|
289
|
+
<Button
|
|
290
|
+
variant="tertiary"
|
|
291
|
+
onClick={ downloadJson }
|
|
292
|
+
disabled={
|
|
293
|
+
results.length === 0 &&
|
|
294
|
+
dryRunResult === null &&
|
|
295
|
+
executionResult === null
|
|
296
|
+
}
|
|
297
|
+
>
|
|
298
|
+
{ __( 'Export JSON', TEXT_DOMAIN ) }
|
|
299
|
+
</Button>
|
|
300
|
+
</div>
|
|
301
|
+
|
|
302
|
+
{ isScanning && <Spinner /> }
|
|
303
|
+
|
|
304
|
+
{ error && (
|
|
305
|
+
<Notice status="error" isDismissible={ false }>
|
|
306
|
+
{ error }
|
|
307
|
+
</Notice>
|
|
308
|
+
) }
|
|
309
|
+
|
|
310
|
+
<Notice status="info" isDismissible={ false }>
|
|
311
|
+
{ __( 'Detected blocks needing attention:', '{{textDomain}}' ) }{' '}
|
|
312
|
+
<strong>{ stats.total }</strong>
|
|
313
|
+
<br />
|
|
314
|
+
{ __( 'Needs migration:', '{{textDomain}}' ) }{' '}
|
|
315
|
+
<strong>{ stats.needsMigration }</strong>
|
|
316
|
+
<br />
|
|
317
|
+
{ __( 'Unknown version matches:', '{{textDomain}}' ) }{' '}
|
|
318
|
+
<strong>{ stats.unknown }</strong>
|
|
319
|
+
</Notice>
|
|
320
|
+
|
|
321
|
+
{ executionResult && (
|
|
322
|
+
<Notice
|
|
323
|
+
status={ executionResult.failed > 0 ? 'warning' : 'success' }
|
|
324
|
+
isDismissible={ false }
|
|
325
|
+
>
|
|
326
|
+
{ __( 'Migration summary', TEXT_DOMAIN ) }: { executionResult.successful }{' '}
|
|
327
|
+
{ __( 'post(s) migrated,', TEXT_DOMAIN ) } { executionResult.failed }{' '}
|
|
328
|
+
{ __( 'post(s) blocked.', TEXT_DOMAIN ) }
|
|
329
|
+
</Notice>
|
|
330
|
+
) }
|
|
331
|
+
|
|
332
|
+
{ ! executionResult && dryRunResult && (
|
|
333
|
+
<Notice
|
|
334
|
+
status={ dryRunResult.failed > 0 ? 'warning' : 'success' }
|
|
335
|
+
isDismissible={ false }
|
|
336
|
+
>
|
|
337
|
+
{ __( 'Dry run summary', TEXT_DOMAIN ) }: { dryRunResult.successful }{' '}
|
|
338
|
+
{ __( 'post(s) ready,', TEXT_DOMAIN ) } { dryRunResult.failed }{' '}
|
|
339
|
+
{ __( 'post(s) blocked.', TEXT_DOMAIN ) }
|
|
340
|
+
</Notice>
|
|
341
|
+
) }
|
|
342
|
+
|
|
343
|
+
{ results.map( ( result ) => (
|
|
344
|
+
<Card key={ `${ result.postId }:${ result.blockPath.join( '.' ) }` }>
|
|
345
|
+
<CardBody>
|
|
346
|
+
<div
|
|
347
|
+
style={ {
|
|
348
|
+
display: 'grid',
|
|
349
|
+
gap: '8px',
|
|
350
|
+
} }
|
|
351
|
+
>
|
|
352
|
+
<div>
|
|
353
|
+
<strong>{ result.postTitle }</strong> ({ result.blockName })
|
|
354
|
+
<div style={ { fontSize: '12px', opacity: 0.8 } }>
|
|
355
|
+
{ __( 'Migration version', '{{textDomain}}' ) }: { result.analysis.currentMigrationVersion } → { result.analysis.targetMigrationVersion }
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
358
|
+
<div style={ { fontSize: '12px' } }>
|
|
359
|
+
{ __( 'Risk summary', '{{textDomain}}' ) }: { formatRiskSummaryLine( result.analysis ) }
|
|
360
|
+
</div>
|
|
361
|
+
<div style={ { fontSize: '12px' } }>
|
|
362
|
+
{ __( 'Changed fields', '{{textDomain}}' ) }: { result.preview.changedFields.join( ', ' ) || __( 'none', '{{textDomain}}' ) }
|
|
363
|
+
</div>
|
|
364
|
+
<div style={ { fontSize: '12px' } }>
|
|
365
|
+
{ __( 'Union branches', '{{textDomain}}' ) }: { formatUnionSummary( result.preview ) }
|
|
366
|
+
</div>
|
|
367
|
+
{ result.preview.unresolved.length > 0 && (
|
|
368
|
+
<Notice status="warning" isDismissible={ false }>
|
|
369
|
+
{ result.preview.unresolved.join( ', ' ) }
|
|
370
|
+
</Notice>
|
|
371
|
+
) }
|
|
372
|
+
{ result.preview.validationErrors.length > 0 && (
|
|
373
|
+
<Notice status="error" isDismissible={ false }>
|
|
374
|
+
{ result.preview.validationErrors.join( ', ' ) }
|
|
375
|
+
</Notice>
|
|
376
|
+
) }
|
|
377
|
+
<div>
|
|
378
|
+
<strong>{ __( 'Before', '{{textDomain}}' ) }</strong>
|
|
379
|
+
{ renderJsonPreview( result.preview.before ) }
|
|
380
|
+
</div>
|
|
381
|
+
<div>
|
|
382
|
+
<strong>{ __( 'After', '{{textDomain}}' ) }</strong>
|
|
383
|
+
{ renderJsonPreview( result.preview.after ) }
|
|
384
|
+
</div>
|
|
385
|
+
</div>
|
|
386
|
+
</CardBody>
|
|
387
|
+
</Card>
|
|
388
|
+
) ) }
|
|
389
|
+
</div>
|
|
390
|
+
</CardBody>
|
|
391
|
+
</Card>
|
|
392
|
+
</div>
|
|
393
|
+
);
|
|
394
|
+
}
|