@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.
Files changed (187) hide show
  1. package/README.md +32 -0
  2. package/dist/runtime/cli-add.d.ts +38 -0
  3. package/dist/runtime/cli-add.js +561 -0
  4. package/dist/runtime/cli-core.d.ts +25 -0
  5. package/dist/runtime/cli-core.js +25 -0
  6. package/dist/runtime/cli-doctor.d.ts +34 -0
  7. package/dist/runtime/cli-doctor.js +131 -0
  8. package/dist/runtime/cli-help.d.ts +9 -0
  9. package/dist/runtime/cli-help.js +37 -0
  10. package/dist/runtime/cli-prompt.d.ts +21 -0
  11. package/dist/runtime/cli-prompt.js +53 -0
  12. package/dist/runtime/cli-scaffold.d.ts +79 -0
  13. package/dist/runtime/cli-scaffold.js +206 -0
  14. package/dist/runtime/cli-templates.d.ts +30 -0
  15. package/dist/runtime/cli-templates.js +61 -0
  16. package/dist/runtime/index.d.ts +9 -0
  17. package/dist/runtime/index.js +7 -0
  18. package/dist/runtime/json-utils.d.ts +10 -0
  19. package/dist/runtime/json-utils.js +12 -0
  20. package/dist/runtime/local-dev-presets.d.ts +26 -0
  21. package/dist/runtime/local-dev-presets.js +132 -0
  22. package/dist/runtime/metadata-analysis.d.ts +11 -0
  23. package/dist/runtime/metadata-analysis.js +285 -0
  24. package/dist/runtime/metadata-model.d.ts +84 -0
  25. package/dist/runtime/metadata-model.js +59 -0
  26. package/dist/runtime/metadata-parser.d.ts +53 -0
  27. package/dist/runtime/metadata-parser.js +794 -0
  28. package/dist/runtime/metadata-php-render.d.ts +29 -0
  29. package/dist/runtime/metadata-php-render.js +549 -0
  30. package/dist/runtime/metadata-projection.d.ts +7 -0
  31. package/dist/runtime/metadata-projection.js +233 -0
  32. package/dist/runtime/migration-constants.d.ts +15 -0
  33. package/dist/runtime/migration-constants.js +16 -0
  34. package/dist/runtime/migration-diff.d.ts +2 -0
  35. package/dist/runtime/migration-diff.js +537 -0
  36. package/dist/runtime/migration-fixtures.d.ts +8 -0
  37. package/dist/runtime/migration-fixtures.js +94 -0
  38. package/dist/runtime/migration-fuzz-plan.d.ts +2 -0
  39. package/dist/runtime/migration-fuzz-plan.js +50 -0
  40. package/dist/runtime/migration-manifest.d.ts +19 -0
  41. package/dist/runtime/migration-manifest.js +129 -0
  42. package/dist/runtime/migration-project.d.ts +94 -0
  43. package/dist/runtime/migration-project.js +1101 -0
  44. package/dist/runtime/migration-render.d.ts +11 -0
  45. package/dist/runtime/migration-render.js +741 -0
  46. package/dist/runtime/migration-risk.d.ts +4 -0
  47. package/dist/runtime/migration-risk.js +52 -0
  48. package/dist/runtime/migration-types.d.ts +249 -0
  49. package/dist/runtime/migration-types.js +1 -0
  50. package/dist/runtime/migration-ui-capability.d.ts +17 -0
  51. package/dist/runtime/migration-ui-capability.js +190 -0
  52. package/dist/runtime/migration-utils.d.ts +69 -0
  53. package/dist/runtime/migration-utils.js +246 -0
  54. package/dist/runtime/migrations.d.ts +249 -0
  55. package/dist/runtime/migrations.js +1061 -0
  56. package/dist/runtime/object-utils.d.ts +12 -0
  57. package/dist/runtime/object-utils.js +14 -0
  58. package/dist/runtime/package-managers.d.ts +28 -0
  59. package/dist/runtime/package-managers.js +156 -0
  60. package/dist/runtime/package-versions.d.ts +10 -0
  61. package/dist/runtime/package-versions.js +68 -0
  62. package/dist/runtime/scaffold-onboarding.d.ts +32 -0
  63. package/dist/runtime/scaffold-onboarding.js +99 -0
  64. package/dist/runtime/scaffold.d.ts +146 -0
  65. package/dist/runtime/scaffold.js +612 -0
  66. package/dist/runtime/schema-core.d.ts +267 -0
  67. package/dist/runtime/schema-core.js +597 -0
  68. package/dist/runtime/starter-manifests.d.ts +25 -0
  69. package/dist/runtime/starter-manifests.js +383 -0
  70. package/dist/runtime/string-case.d.ts +36 -0
  71. package/dist/runtime/string-case.js +69 -0
  72. package/dist/runtime/template-builtins.d.ts +38 -0
  73. package/dist/runtime/template-builtins.js +72 -0
  74. package/dist/runtime/template-defaults.d.ts +75 -0
  75. package/dist/runtime/template-defaults.js +65 -0
  76. package/dist/runtime/template-registry.d.ts +36 -0
  77. package/dist/runtime/template-registry.js +94 -0
  78. package/dist/runtime/template-render.d.ts +24 -0
  79. package/dist/runtime/template-render.js +113 -0
  80. package/dist/runtime/template-source.d.ts +71 -0
  81. package/dist/runtime/template-source.js +821 -0
  82. package/dist/runtime/typia-tags.d.ts +1 -0
  83. package/dist/runtime/typia-tags.js +1 -0
  84. package/package.json +79 -0
  85. package/templates/_shared/base/languages/.gitkeep +1 -0
  86. package/templates/_shared/base/package.json.mustache +41 -0
  87. package/templates/_shared/base/scripts/sync-types-to-block-json.ts.mustache +118 -0
  88. package/templates/_shared/base/src/hooks.ts.mustache +19 -0
  89. package/templates/_shared/base/src/validator-toolkit.ts.mustache +31 -0
  90. package/templates/_shared/base/tsconfig.json.mustache +21 -0
  91. package/templates/_shared/base/webpack.config.js.mustache +99 -0
  92. package/templates/_shared/base/{{slugKebabCase}}.php.mustache +53 -0
  93. package/templates/_shared/compound/core/package.json.mustache +45 -0
  94. package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +559 -0
  95. package/templates/_shared/compound/core/scripts/block-config.ts.mustache +13 -0
  96. package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +53 -0
  97. package/templates/_shared/compound/core/webpack.config.js.mustache +141 -0
  98. package/templates/_shared/compound/core/{{slugKebabCase}}.php.mustache +51 -0
  99. package/templates/_shared/compound/persistence/package.json.mustache +50 -0
  100. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +59 -0
  101. package/templates/_shared/compound/persistence/scripts/sync-rest-contracts.ts.mustache +101 -0
  102. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/api-types.ts.mustache +21 -0
  103. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/api-validators.ts.mustache +32 -0
  104. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/api.ts.mustache +68 -0
  105. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/block.json.mustache +52 -0
  106. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/data.ts.mustache +192 -0
  107. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +123 -0
  108. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +11 -0
  109. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/interactivity.ts.mustache +132 -0
  110. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/render.php.mustache +158 -0
  111. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/save.tsx.mustache +3 -0
  112. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/types.ts.mustache +56 -0
  113. package/templates/_shared/compound/persistence/src/blocks/{{slugKebabCase}}/validators.ts.mustache +32 -0
  114. package/templates/_shared/compound/persistence-auth/{{slugKebabCase}}.php.mustache +294 -0
  115. package/templates/_shared/compound/persistence-public/{{slugKebabCase}}.php.mustache +312 -0
  116. package/templates/_shared/migration-ui/common/src/admin/migration-dashboard.tsx +394 -0
  117. package/templates/_shared/migration-ui/common/src/migration-detector.ts +9 -0
  118. package/templates/_shared/migration-ui/common/src/migrations/helpers.ts +490 -0
  119. package/templates/_shared/migration-ui/common/src/migrations/index.ts +886 -0
  120. package/templates/_shared/persistence/auth/{{slugKebabCase}}.php.mustache +290 -0
  121. package/templates/_shared/persistence/core/package.json.mustache +46 -0
  122. package/templates/_shared/persistence/core/scripts/sync-rest-contracts.ts.mustache +113 -0
  123. package/templates/_shared/persistence/core/scripts/sync-types-to-block-json.ts.mustache +125 -0
  124. package/templates/_shared/persistence/core/src/api-types.ts.mustache +21 -0
  125. package/templates/_shared/persistence/core/src/api-validators.ts.mustache +32 -0
  126. package/templates/_shared/persistence/core/src/api.ts.mustache +68 -0
  127. package/templates/_shared/persistence/core/src/data.ts.mustache +192 -0
  128. package/templates/_shared/persistence/core/src/index.tsx.mustache +25 -0
  129. package/templates/_shared/persistence/core/src/interactivity.ts.mustache +134 -0
  130. package/templates/_shared/persistence/core/src/save.tsx.mustache +5 -0
  131. package/templates/_shared/persistence/core/src/validators.ts.mustache +32 -0
  132. package/templates/_shared/persistence/core/{{slugKebabCase}}.php.mustache +336 -0
  133. package/templates/_shared/persistence/public/{{slugKebabCase}}.php.mustache +308 -0
  134. package/templates/_shared/presets/test-preset/.wp-env.test.json.mustache +16 -0
  135. package/templates/_shared/presets/test-preset/playwright.config.ts.mustache +22 -0
  136. package/templates/_shared/presets/test-preset/scripts/wait-for-wp-env.mjs.mustache +102 -0
  137. package/templates/_shared/presets/test-preset/scripts/wp-env-utils.cjs.mustache +32 -0
  138. package/templates/_shared/presets/test-preset/tests/e2e/smoke.spec.ts.mustache +34 -0
  139. package/templates/_shared/presets/wp-env/.wp-env.json.mustache +16 -0
  140. package/templates/_shared/rest-helpers/auth/inc/rest-auth.php.mustache +37 -0
  141. package/templates/_shared/rest-helpers/public/inc/rest-public.php.mustache +314 -0
  142. package/templates/_shared/rest-helpers/shared/inc/rest-shared.php.mustache +58 -0
  143. package/templates/_shared/workspace/persistence-auth/inc/rest-auth.php.mustache +36 -0
  144. package/templates/_shared/workspace/persistence-auth/inc/rest-shared.php.mustache +55 -0
  145. package/templates/_shared/workspace/persistence-auth/server.php.mustache +237 -0
  146. package/templates/_shared/workspace/persistence-public/inc/rest-public.php.mustache +273 -0
  147. package/templates/_shared/workspace/persistence-public/inc/rest-shared.php.mustache +55 -0
  148. package/templates/_shared/workspace/persistence-public/server.php.mustache +252 -0
  149. package/templates/basic/src/block.json.mustache +51 -0
  150. package/templates/basic/src/edit.tsx.mustache +128 -0
  151. package/templates/basic/src/editor.scss.mustache +8 -0
  152. package/templates/basic/src/hooks.ts.mustache +18 -0
  153. package/templates/basic/src/index.tsx.mustache +45 -0
  154. package/templates/basic/src/save.tsx.mustache +30 -0
  155. package/templates/basic/src/style.scss.mustache +40 -0
  156. package/templates/basic/src/types.ts.mustache +56 -0
  157. package/templates/basic/src/validators.ts.mustache +26 -0
  158. package/templates/compound/src/blocks/{{slugKebabCase}}/block.json.mustache +37 -0
  159. package/templates/compound/src/blocks/{{slugKebabCase}}/children.ts.mustache +25 -0
  160. package/templates/compound/src/blocks/{{slugKebabCase}}/edit.tsx.mustache +93 -0
  161. package/templates/compound/src/blocks/{{slugKebabCase}}/hooks.ts.mustache +11 -0
  162. package/templates/compound/src/blocks/{{slugKebabCase}}/index.tsx.mustache +25 -0
  163. package/templates/compound/src/blocks/{{slugKebabCase}}/save.tsx.mustache +32 -0
  164. package/templates/compound/src/blocks/{{slugKebabCase}}/style.scss.mustache +31 -0
  165. package/templates/compound/src/blocks/{{slugKebabCase}}/types.ts.mustache +13 -0
  166. package/templates/compound/src/blocks/{{slugKebabCase}}/validators.ts.mustache +17 -0
  167. package/templates/compound/src/blocks/{{slugKebabCase}}-item/block.json.mustache +35 -0
  168. package/templates/compound/src/blocks/{{slugKebabCase}}-item/edit.tsx.mustache +50 -0
  169. package/templates/compound/src/blocks/{{slugKebabCase}}-item/hooks.ts.mustache +11 -0
  170. package/templates/compound/src/blocks/{{slugKebabCase}}-item/index.tsx.mustache +25 -0
  171. package/templates/compound/src/blocks/{{slugKebabCase}}-item/save.tsx.mustache +24 -0
  172. package/templates/compound/src/blocks/{{slugKebabCase}}-item/types.ts.mustache +12 -0
  173. package/templates/compound/src/blocks/{{slugKebabCase}}-item/validators.ts.mustache +17 -0
  174. package/templates/interactivity/package.json.mustache +42 -0
  175. package/templates/interactivity/src/block.json.mustache +73 -0
  176. package/templates/interactivity/src/edit.tsx.mustache +270 -0
  177. package/templates/interactivity/src/index.tsx.mustache +32 -0
  178. package/templates/interactivity/src/interactivity.ts.mustache +152 -0
  179. package/templates/interactivity/src/save.tsx.mustache +101 -0
  180. package/templates/interactivity/src/style.scss.mustache +60 -0
  181. package/templates/interactivity/src/types.ts.mustache +32 -0
  182. package/templates/interactivity/src/validators.ts.mustache +36 -0
  183. package/templates/persistence/src/block.json.mustache +52 -0
  184. package/templates/persistence/src/edit.tsx.mustache +165 -0
  185. package/templates/persistence/src/render.php.mustache +126 -0
  186. package/templates/persistence/src/style.scss.mustache +46 -0
  187. 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
+ }
@@ -0,0 +1,9 @@
1
+ export {
2
+ type BatchMigrationResult,
3
+ type BlockScanResult,
4
+ type MigrationAnalysis,
5
+ batchMigrateScanResults,
6
+ detectBlockMigration,
7
+ generateMigrationReport,
8
+ scanSiteForMigrations,
9
+ } from './migrations';