@wp-typia/project-tools 0.16.11 → 0.16.13

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 (119) hide show
  1. package/README.md +9 -3
  2. package/dist/runtime/block-generator-service-core.d.ts +8 -0
  3. package/dist/runtime/block-generator-service-core.js +274 -0
  4. package/dist/runtime/block-generator-service-spec.d.ts +104 -0
  5. package/dist/runtime/block-generator-service-spec.js +139 -0
  6. package/dist/runtime/block-generator-service.d.ts +2 -110
  7. package/dist/runtime/block-generator-service.js +2 -389
  8. package/dist/runtime/built-in-block-artifact-documents.d.ts +3 -0
  9. package/dist/runtime/built-in-block-artifact-documents.js +2 -0
  10. package/dist/runtime/built-in-block-artifact-types.d.ts +51 -0
  11. package/dist/runtime/built-in-block-artifact-types.js +304 -0
  12. package/dist/runtime/built-in-block-artifacts.js +4 -803
  13. package/dist/runtime/built-in-block-attribute-emitters.d.ts +71 -0
  14. package/dist/runtime/built-in-block-attribute-emitters.js +176 -0
  15. package/dist/runtime/built-in-block-attribute-specs.d.ts +38 -0
  16. package/dist/runtime/built-in-block-attribute-specs.js +358 -0
  17. package/dist/runtime/built-in-block-code-templates/basic.d.ts +4 -0
  18. package/dist/runtime/built-in-block-code-templates/basic.js +249 -0
  19. package/dist/runtime/built-in-block-code-templates/compound-child.d.ts +4 -0
  20. package/dist/runtime/built-in-block-code-templates/compound-child.js +138 -0
  21. package/dist/runtime/built-in-block-code-templates/compound-parent.d.ts +6 -0
  22. package/dist/runtime/built-in-block-code-templates/compound-parent.js +227 -0
  23. package/dist/runtime/built-in-block-code-templates/compound-persistence.d.ts +4 -0
  24. package/dist/runtime/built-in-block-code-templates/compound-persistence.js +478 -0
  25. package/dist/runtime/built-in-block-code-templates/compound.d.ts +3 -0
  26. package/dist/runtime/built-in-block-code-templates/compound.js +3 -0
  27. package/dist/runtime/built-in-block-code-templates/interactivity.d.ts +5 -0
  28. package/dist/runtime/built-in-block-code-templates/interactivity.js +547 -0
  29. package/dist/runtime/built-in-block-code-templates/persistence.d.ts +5 -0
  30. package/dist/runtime/built-in-block-code-templates/persistence.js +550 -0
  31. package/dist/runtime/built-in-block-code-templates/shared.d.ts +16 -0
  32. package/dist/runtime/built-in-block-code-templates/shared.js +53 -0
  33. package/dist/runtime/built-in-block-code-templates.d.ts +5 -32
  34. package/dist/runtime/built-in-block-code-templates.js +5 -2230
  35. package/dist/runtime/cli-add-block-config.d.ts +6 -0
  36. package/dist/runtime/cli-add-block-config.js +143 -0
  37. package/dist/runtime/cli-add-block-legacy-validator.d.ts +4 -0
  38. package/dist/runtime/cli-add-block-legacy-validator.js +168 -0
  39. package/dist/runtime/cli-add-block.js +3 -301
  40. package/dist/runtime/cli-add-workspace-assets.d.ts +38 -0
  41. package/dist/runtime/cli-add-workspace-assets.js +399 -0
  42. package/dist/runtime/cli-add-workspace.d.ts +2 -38
  43. package/dist/runtime/cli-add-workspace.js +5 -396
  44. package/dist/runtime/cli-diagnostics.js +76 -4
  45. package/dist/runtime/cli-doctor-environment.d.ts +12 -0
  46. package/dist/runtime/cli-doctor-environment.js +123 -0
  47. package/dist/runtime/cli-doctor-workspace.d.ts +18 -0
  48. package/dist/runtime/cli-doctor-workspace.js +308 -0
  49. package/dist/runtime/cli-doctor.d.ts +4 -2
  50. package/dist/runtime/cli-doctor.js +10 -405
  51. package/dist/runtime/cli-help.js +1 -1
  52. package/dist/runtime/cli-scaffold.d.ts +8 -1
  53. package/dist/runtime/cli-scaffold.js +47 -4
  54. package/dist/runtime/migration-command-surface.d.ts +67 -0
  55. package/dist/runtime/migration-command-surface.js +189 -0
  56. package/dist/runtime/migration-diff-rename.d.ts +13 -0
  57. package/dist/runtime/migration-diff-rename.js +192 -0
  58. package/dist/runtime/migration-diff-transform.d.ts +14 -0
  59. package/dist/runtime/migration-diff-transform.js +105 -0
  60. package/dist/runtime/migration-diff.js +12 -297
  61. package/dist/runtime/migration-generated-artifacts.d.ts +3 -0
  62. package/dist/runtime/migration-generated-artifacts.js +41 -0
  63. package/dist/runtime/migration-maintenance-fixtures.d.ts +23 -0
  64. package/dist/runtime/migration-maintenance-fixtures.js +126 -0
  65. package/dist/runtime/migration-maintenance-verify.d.ts +26 -0
  66. package/dist/runtime/migration-maintenance-verify.js +262 -0
  67. package/dist/runtime/migration-maintenance.d.ts +2 -0
  68. package/dist/runtime/migration-maintenance.js +2 -0
  69. package/dist/runtime/migration-planning.d.ts +23 -0
  70. package/dist/runtime/migration-planning.js +131 -0
  71. package/dist/runtime/migration-project-config-source.d.ts +6 -0
  72. package/dist/runtime/migration-project-config-source.js +424 -0
  73. package/dist/runtime/migration-project-layout-discovery.d.ts +61 -0
  74. package/dist/runtime/migration-project-layout-discovery.js +337 -0
  75. package/dist/runtime/migration-project-layout-paths.d.ts +135 -0
  76. package/dist/runtime/migration-project-layout-paths.js +288 -0
  77. package/dist/runtime/migration-project-layout.d.ts +3 -0
  78. package/dist/runtime/migration-project-layout.js +2 -0
  79. package/dist/runtime/migration-project-workspace.d.ts +47 -0
  80. package/dist/runtime/migration-project-workspace.js +212 -0
  81. package/dist/runtime/migration-project.d.ts +4 -94
  82. package/dist/runtime/migration-project.js +3 -1101
  83. package/dist/runtime/migration-render-diff-rule.d.ts +5 -0
  84. package/dist/runtime/migration-render-diff-rule.js +120 -0
  85. package/dist/runtime/migration-render-execution.d.ts +3 -0
  86. package/dist/runtime/migration-render-execution.js +428 -0
  87. package/dist/runtime/migration-render-generated.d.ts +27 -0
  88. package/dist/runtime/migration-render-generated.js +230 -0
  89. package/dist/runtime/migration-render-support.d.ts +3 -0
  90. package/dist/runtime/migration-render-support.js +16 -0
  91. package/dist/runtime/migration-render.d.ts +3 -33
  92. package/dist/runtime/migration-render.js +3 -789
  93. package/dist/runtime/migrations.d.ts +24 -121
  94. package/dist/runtime/migrations.js +12 -700
  95. package/dist/runtime/scaffold-apply-utils.d.ts +9 -0
  96. package/dist/runtime/scaffold-apply-utils.js +27 -4
  97. package/dist/runtime/scaffold-bootstrap.d.ts +45 -0
  98. package/dist/runtime/scaffold-bootstrap.js +185 -0
  99. package/dist/runtime/scaffold-onboarding.d.ts +12 -0
  100. package/dist/runtime/scaffold-onboarding.js +42 -5
  101. package/dist/runtime/scaffold-package-manager-files.d.ts +35 -0
  102. package/dist/runtime/scaffold-package-manager-files.js +79 -0
  103. package/dist/runtime/scaffold.d.ts +1 -12
  104. package/dist/runtime/scaffold.js +11 -394
  105. package/dist/runtime/template-source-contracts.d.ts +81 -0
  106. package/dist/runtime/template-source-contracts.js +1 -0
  107. package/dist/runtime/template-source-external.d.ts +21 -0
  108. package/dist/runtime/template-source-external.js +184 -0
  109. package/dist/runtime/template-source-locators.d.ts +4 -0
  110. package/dist/runtime/template-source-locators.js +72 -0
  111. package/dist/runtime/template-source-normalization.d.ts +7 -0
  112. package/dist/runtime/template-source-normalization.js +53 -0
  113. package/dist/runtime/template-source-remote.d.ts +23 -0
  114. package/dist/runtime/template-source-remote.js +336 -0
  115. package/dist/runtime/template-source-seeds.d.ts +12 -0
  116. package/dist/runtime/template-source-seeds.js +243 -0
  117. package/dist/runtime/template-source.d.ts +4 -86
  118. package/dist/runtime/template-source.js +9 -828
  119. package/package.json +4 -4
@@ -0,0 +1,337 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { CONFIG_FILE, ROOT_BLOCK_JSON, ROOT_MANIFEST, ROOT_SAVE_FILE, ROOT_TYPES_FILE, SRC_BLOCK_JSON, SRC_MANIFEST, SUPPORTED_PROJECT_FILES, } from "./migration-constants.js";
4
+ import { readJson, } from "./migration-utils.js";
5
+ import { normalizeRelativePath, parseMigrationConfig, } from "./migration-project-config-source.js";
6
+ const DEFAULT_BLOCK_KEY = "default";
7
+ const SINGLE_BLOCK_LAYOUT_NOT_FOUND = "No supported single-block migration layout was found.";
8
+ const SINGLE_BLOCK_LAYOUT_CANDIDATES = [
9
+ {
10
+ blockJsonFile: SRC_BLOCK_JSON,
11
+ manifestFile: SRC_MANIFEST,
12
+ },
13
+ {
14
+ blockJsonFile: ROOT_BLOCK_JSON,
15
+ manifestFile: ROOT_MANIFEST,
16
+ },
17
+ ];
18
+ const LEGACY_ROOT_SINGLE_BLOCK_LAYOUT = SINGLE_BLOCK_LAYOUT_CANDIDATES[1];
19
+ function readSingleBlockTarget(projectDir, { blockJsonFile, manifestFile, }) {
20
+ const requiredFiles = [blockJsonFile, ROOT_SAVE_FILE, ROOT_TYPES_FILE];
21
+ if (requiredFiles.some((relativePath) => !fs.existsSync(path.join(projectDir, relativePath)))) {
22
+ return null;
23
+ }
24
+ const blockName = readJson(path.join(projectDir, blockJsonFile))?.name;
25
+ if (typeof blockName !== "string" || blockName.length === 0) {
26
+ throw new Error(`Unable to resolve block name from ${normalizeRelativePath(blockJsonFile)}`);
27
+ }
28
+ return {
29
+ blockJsonFile: normalizeRelativePath(blockJsonFile),
30
+ blockName,
31
+ key: DEFAULT_BLOCK_KEY,
32
+ manifestFile: normalizeRelativePath(manifestFile),
33
+ saveFile: ROOT_SAVE_FILE,
34
+ typesFile: ROOT_TYPES_FILE,
35
+ };
36
+ }
37
+ function collectSingleBlockCandidates(projectDir) {
38
+ return SINGLE_BLOCK_LAYOUT_CANDIDATES.filter(({ blockJsonFile }) => hasSingleBlockLayoutFiles(projectDir, blockJsonFile));
39
+ }
40
+ function hasSingleBlockLayoutFiles(projectDir, blockJsonFile) {
41
+ return [blockJsonFile, ROOT_SAVE_FILE, ROOT_TYPES_FILE].every((relativePath) => fs.existsSync(path.join(projectDir, relativePath)));
42
+ }
43
+ function orderSingleBlockCandidates(projectDir, candidates) {
44
+ const candidatesWithManifest = candidates.filter(({ manifestFile }) => fs.existsSync(path.join(projectDir, manifestFile)));
45
+ return [
46
+ ...candidatesWithManifest,
47
+ ...candidates.filter((candidate) => !candidatesWithManifest.includes(candidate)),
48
+ ];
49
+ }
50
+ /**
51
+ * Synthesizes the implicit legacy migration block target for single-block projects.
52
+ *
53
+ * @param projectDir Project directory that may contain a legacy root migration layout.
54
+ * @param blockName Optional configured block name used to prefer a matching legacy root target.
55
+ * @returns The discovered single-block migration target keyed as `default`.
56
+ */
57
+ export function createImplicitLegacyBlock(projectDir, blockName) {
58
+ if (blockName) {
59
+ try {
60
+ const rootTarget = readSingleBlockTarget(projectDir, LEGACY_ROOT_SINGLE_BLOCK_LAYOUT);
61
+ const srcTarget = readSingleBlockTarget(projectDir, SINGLE_BLOCK_LAYOUT_CANDIDATES[0]);
62
+ const hasSrcManifest = fs.existsSync(path.join(projectDir, SRC_MANIFEST));
63
+ if (rootTarget?.blockName === blockName &&
64
+ (!srcTarget || srcTarget.blockName !== blockName || !hasSrcManifest)) {
65
+ return {
66
+ ...rootTarget,
67
+ key: DEFAULT_BLOCK_KEY,
68
+ };
69
+ }
70
+ }
71
+ catch {
72
+ // Fall back to the shared discovery flow so malformed legacy roots do not block valid layouts.
73
+ }
74
+ }
75
+ const discovered = discoverSingleBlockTarget(projectDir, blockName);
76
+ return {
77
+ ...discovered,
78
+ key: DEFAULT_BLOCK_KEY,
79
+ };
80
+ }
81
+ function createMalformedMultiBlockTargetError(directory, reason) {
82
+ return new Error("Unable to auto-detect a supported migration retrofit layout. " +
83
+ `Detected ${path.join("src", "blocks", directory, "block.json")} but ${reason}. ` +
84
+ "Create `src/migrations/config.ts` manually if your project uses a custom layout.");
85
+ }
86
+ function getRequiredProjectFiles(projectDir, blocks) {
87
+ if (Array.isArray(blocks) && blocks.length > 0) {
88
+ return [
89
+ "package.json",
90
+ ...blocks.flatMap((block) => [block.blockJsonFile, block.saveFile, block.typesFile]),
91
+ ];
92
+ }
93
+ const configPath = path.join(projectDir, CONFIG_FILE);
94
+ if (fs.existsSync(configPath)) {
95
+ const config = parseMigrationConfig(fs.readFileSync(configPath, "utf8"));
96
+ const configuredBlocks = config.blocks ?? [createImplicitLegacyBlock(projectDir, config.blockName)];
97
+ return [
98
+ "package.json",
99
+ ...configuredBlocks.flatMap((block) => [block.blockJsonFile, block.saveFile, block.typesFile]),
100
+ ];
101
+ }
102
+ const discoveredLayout = discoverMigrationLayout(projectDir);
103
+ if (discoveredLayout?.mode === "multi") {
104
+ return [
105
+ "package.json",
106
+ ...discoveredLayout.blocks.flatMap((block) => [block.blockJsonFile, block.saveFile, block.typesFile]),
107
+ ];
108
+ }
109
+ if (discoveredLayout?.mode === "single") {
110
+ return [
111
+ "package.json",
112
+ discoveredLayout.block.blockJsonFile,
113
+ discoveredLayout.block.saveFile,
114
+ discoveredLayout.block.typesFile,
115
+ ];
116
+ }
117
+ return SUPPORTED_PROJECT_FILES;
118
+ }
119
+ /**
120
+ * Verifies that a project directory contains the files required for migration tooling.
121
+ *
122
+ * @param projectDir Project directory to validate.
123
+ * @param blocks Optional block targets to validate directly instead of auto-discovering them.
124
+ * @returns Nothing.
125
+ * @throws Error When any required project file is missing.
126
+ */
127
+ export function ensureAdvancedMigrationProject(projectDir, blocks) {
128
+ const missing = getRequiredProjectFiles(projectDir, blocks).filter((relativePath) => !fs.existsSync(path.join(projectDir, relativePath)));
129
+ if (missing.length > 0) {
130
+ throw new Error(`This directory is not a supported migration-capable project. Missing: ${missing.join(", ")}`);
131
+ }
132
+ }
133
+ function createBlockTarget(projectDir, { blockJsonFile, key, manifestFile, saveFile, typesFile, }) {
134
+ const requiredFiles = [blockJsonFile, saveFile, typesFile];
135
+ if (requiredFiles.some((relativePath) => !fs.existsSync(path.join(projectDir, relativePath)))) {
136
+ return null;
137
+ }
138
+ const blockName = readJson(path.join(projectDir, blockJsonFile))?.name;
139
+ if (typeof blockName !== "string" || blockName.length === 0) {
140
+ return null;
141
+ }
142
+ return {
143
+ blockJsonFile: normalizeRelativePath(blockJsonFile),
144
+ blockName,
145
+ key,
146
+ manifestFile: normalizeRelativePath(manifestFile),
147
+ saveFile: normalizeRelativePath(saveFile),
148
+ typesFile: normalizeRelativePath(typesFile),
149
+ };
150
+ }
151
+ function discoverSingleBlockTarget(projectDir, preferredBlockName) {
152
+ const candidates = collectSingleBlockCandidates(projectDir);
153
+ if (candidates.length === 0) {
154
+ throw new Error(SINGLE_BLOCK_LAYOUT_NOT_FOUND);
155
+ }
156
+ const readCandidate = (candidate) => readSingleBlockTarget(projectDir, candidate);
157
+ const orderedCandidates = orderSingleBlockCandidates(projectDir, candidates);
158
+ if (preferredBlockName) {
159
+ const validTargets = [];
160
+ let firstReadError = null;
161
+ for (const candidate of orderedCandidates) {
162
+ try {
163
+ const target = readCandidate(candidate);
164
+ if (!target) {
165
+ continue;
166
+ }
167
+ if (target.blockName === preferredBlockName) {
168
+ return target;
169
+ }
170
+ validTargets.push(target);
171
+ }
172
+ catch (error) {
173
+ if (!firstReadError && error instanceof Error) {
174
+ firstReadError = error;
175
+ }
176
+ }
177
+ }
178
+ if (validTargets.length > 0) {
179
+ throw new Error(`Configured migration blockName ${preferredBlockName} does not match the detected single-block layout(s): ${validTargets
180
+ .map((target) => target.blockName)
181
+ .join(", ")}.`);
182
+ }
183
+ if (firstReadError) {
184
+ throw firstReadError;
185
+ }
186
+ }
187
+ let firstReadError;
188
+ let sawReadError = false;
189
+ for (const candidate of orderedCandidates) {
190
+ try {
191
+ const target = readCandidate(candidate);
192
+ if (target) {
193
+ return target;
194
+ }
195
+ }
196
+ catch (error) {
197
+ if (!sawReadError) {
198
+ firstReadError = error;
199
+ sawReadError = true;
200
+ }
201
+ }
202
+ }
203
+ if (sawReadError) {
204
+ throw firstReadError;
205
+ }
206
+ throw new Error(SINGLE_BLOCK_LAYOUT_NOT_FOUND);
207
+ }
208
+ function discoverMigrationLayout(projectDir) {
209
+ const blocksRoot = path.join(projectDir, "src", "blocks");
210
+ let firstMultiBlockError = null;
211
+ if (fs.existsSync(blocksRoot) && fs.statSync(blocksRoot).isDirectory()) {
212
+ const blockDirectories = fs
213
+ .readdirSync(blocksRoot, { withFileTypes: true })
214
+ .filter((entry) => entry.isDirectory())
215
+ .map((entry) => entry.name);
216
+ const candidateDirectories = blockDirectories.filter((directory) => fs.existsSync(path.join(blocksRoot, directory, "block.json")));
217
+ if (candidateDirectories.length > 0) {
218
+ const blocks = candidateDirectories.flatMap((directory) => {
219
+ const saveFile = path.join("src", "blocks", directory, "save.tsx");
220
+ const typesFile = path.join("src", "blocks", directory, "types.ts");
221
+ const missingFiles = [saveFile, typesFile].filter((relativePath) => !fs.existsSync(path.join(projectDir, relativePath)));
222
+ if (missingFiles.length > 0) {
223
+ firstMultiBlockError ?? (firstMultiBlockError = createMalformedMultiBlockTargetError(directory, `the block target is missing ${missingFiles.join(", ")}`));
224
+ return [];
225
+ }
226
+ let block = null;
227
+ try {
228
+ block = createBlockTarget(projectDir, {
229
+ blockJsonFile: path.join("src", "blocks", directory, "block.json"),
230
+ key: directory,
231
+ manifestFile: path.join("src", "blocks", directory, "typia.manifest.json"),
232
+ saveFile,
233
+ typesFile,
234
+ });
235
+ }
236
+ catch (error) {
237
+ firstMultiBlockError ?? (firstMultiBlockError = error instanceof Error
238
+ ? createMalformedMultiBlockTargetError(directory, `could not be parsed (${error.message})`)
239
+ : createMalformedMultiBlockTargetError(directory, "could not be parsed"));
240
+ return [];
241
+ }
242
+ if (!block) {
243
+ firstMultiBlockError ?? (firstMultiBlockError = createMalformedMultiBlockTargetError(directory, "it does not expose a valid block name"));
244
+ return [];
245
+ }
246
+ return [block];
247
+ });
248
+ if (blocks.length > 0) {
249
+ return {
250
+ blocks: blocks.sort((left, right) => left.key.localeCompare(right.key)),
251
+ mode: "multi",
252
+ };
253
+ }
254
+ }
255
+ }
256
+ try {
257
+ return {
258
+ block: discoverSingleBlockTarget(projectDir),
259
+ mode: "single",
260
+ };
261
+ }
262
+ catch (error) {
263
+ if (error instanceof Error && error.message === SINGLE_BLOCK_LAYOUT_NOT_FOUND) {
264
+ if (firstMultiBlockError) {
265
+ throw firstMultiBlockError;
266
+ }
267
+ return null;
268
+ }
269
+ throw error;
270
+ }
271
+ }
272
+ /**
273
+ * Detects the supported migration retrofit layout for `migrate init`.
274
+ *
275
+ * Multi-block targets under `src/blocks/<slug>` take precedence over
276
+ * single-block layouts.
277
+ * Returns the detected layout on success and throws an actionable error when no
278
+ * supported first-party layout can be inferred.
279
+ *
280
+ * @param projectDir Project directory to inspect.
281
+ * @returns The discovered migration layout.
282
+ * @throws Error When no supported layout can be inferred.
283
+ */
284
+ export function discoverMigrationInitLayout(projectDir) {
285
+ const discoveredLayout = discoverMigrationLayout(projectDir);
286
+ if (discoveredLayout) {
287
+ return discoveredLayout;
288
+ }
289
+ throw new Error("Unable to auto-detect a supported migration retrofit layout. " +
290
+ "Expected either `src/blocks/*/block.json` with matching `types.ts` and `save.tsx`, " +
291
+ "or a single-block layout using `src/block.json` (or legacy root `block.json`) with `src/types.ts` and `src/save.tsx`. " +
292
+ "Create `src/migrations/config.ts` manually if your project uses a custom layout.");
293
+ }
294
+ /**
295
+ * Resolves the configured migration block targets and their current artifacts.
296
+ *
297
+ * @param projectDir Project directory containing the migration workspace.
298
+ * @param config Parsed migration configuration.
299
+ * @returns The resolved block targets, including current block.json and manifest documents.
300
+ */
301
+ export function resolveMigrationBlocks(projectDir, config) {
302
+ if (Array.isArray(config.blocks)) {
303
+ if (config.blocks.length === 0) {
304
+ return [];
305
+ }
306
+ return config.blocks.map((block) => {
307
+ const blockJsonPath = path.join(projectDir, block.blockJsonFile);
308
+ const manifestPath = path.join(projectDir, block.manifestFile);
309
+ return {
310
+ ...block,
311
+ currentBlockJson: readJson(blockJsonPath),
312
+ currentManifest: readJson(manifestPath),
313
+ layout: "multi",
314
+ };
315
+ });
316
+ }
317
+ return [createImplicitLegacyBlock(projectDir, config.blockName)].map((block) => {
318
+ const blockJsonPath = path.join(projectDir, block.blockJsonFile);
319
+ const manifestPath = path.join(projectDir, block.manifestFile);
320
+ return {
321
+ ...block,
322
+ currentBlockJson: readJson(blockJsonPath),
323
+ currentManifest: readJson(manifestPath),
324
+ layout: "legacy",
325
+ };
326
+ });
327
+ }
328
+ /**
329
+ * Returns the discovered block name for a supported single-block project.
330
+ *
331
+ * Uses `discoverSingleBlockTarget(projectDir)` internally and throws when the
332
+ * project directory does not resolve to a supported single-block migration
333
+ * layout.
334
+ */
335
+ export function readProjectBlockName(projectDir) {
336
+ return discoverSingleBlockTarget(projectDir).blockName;
337
+ }
@@ -0,0 +1,135 @@
1
+ import type { MigrationBlockConfig, MigrationEntry, MigrationProjectPaths, MigrationProjectState, ResolvedMigrationBlockTarget, RuleMetadata } from "./migration-types.js";
2
+ /**
3
+ * Resolves the canonical migration workspace paths for a project directory.
4
+ *
5
+ * @param projectDir Project directory containing the migration workspace.
6
+ * @returns Absolute filesystem paths for config, generated, fixture, rule, and snapshot roots.
7
+ */
8
+ export declare function getProjectPaths(projectDir: string): MigrationProjectPaths;
9
+ /**
10
+ * Resolves the snapshot root for a block target and migration version.
11
+ *
12
+ * @param projectDir Project directory containing the migration workspace.
13
+ * @param block Block target or resolved block target.
14
+ * @param version Migration version label.
15
+ * @returns The absolute snapshot root directory for the requested block/version pair.
16
+ */
17
+ export declare function getSnapshotRoot(projectDir: string, block: MigrationBlockConfig | ResolvedMigrationBlockTarget, version: string): string;
18
+ /**
19
+ * Resolves the snapshot `block.json` path for a block target and migration version.
20
+ *
21
+ * @param projectDir Project directory containing the migration workspace.
22
+ * @param block Block target or resolved block target.
23
+ * @param version Migration version label.
24
+ * @returns The absolute snapshot `block.json` path.
25
+ */
26
+ export declare function getSnapshotBlockJsonPath(projectDir: string, block: MigrationBlockConfig | ResolvedMigrationBlockTarget, version: string): string;
27
+ /**
28
+ * Resolves the snapshot manifest path for a block target and migration version.
29
+ *
30
+ * @param projectDir Project directory containing the migration workspace.
31
+ * @param block Block target or resolved block target.
32
+ * @param version Migration version label.
33
+ * @returns The absolute snapshot manifest path.
34
+ */
35
+ export declare function getSnapshotManifestPath(projectDir: string, block: MigrationBlockConfig | ResolvedMigrationBlockTarget, version: string): string;
36
+ /**
37
+ * Lists the snapshot versions currently present for a specific block target.
38
+ *
39
+ * Returns the sorted subset of supported migration versions that have a manifest on disk
40
+ * for the provided block, or an empty array when none exist.
41
+ */
42
+ export declare function getAvailableSnapshotVersionsForBlock(projectDir: string, supportedMigrationVersions: string[], block: MigrationBlockConfig | ResolvedMigrationBlockTarget): string[];
43
+ /**
44
+ * Formats the standard missing-snapshot guidance for a block target.
45
+ *
46
+ * Returns a user-facing message that either lists the available snapshot
47
+ * versions or explains that no snapshots exist yet for the block.
48
+ */
49
+ export declare function createMissingBlockSnapshotMessage(blockName: string, fromVersion: string, availableSnapshotVersions: string[]): string;
50
+ /**
51
+ * Resolves the snapshot save source path for a block target and migration version.
52
+ *
53
+ * @param projectDir Project directory containing the migration workspace.
54
+ * @param block Block target or resolved block target.
55
+ * @param version Migration version label.
56
+ * @returns The absolute snapshot `save.tsx` path.
57
+ */
58
+ export declare function getSnapshotSavePath(projectDir: string, block: MigrationBlockConfig | ResolvedMigrationBlockTarget, version: string): string;
59
+ /**
60
+ * Resolves the generated directory used for a block's migration output.
61
+ *
62
+ * @param paths Resolved migration project paths.
63
+ * @param block Block target or resolved block target.
64
+ * @returns The absolute generated directory for the block.
65
+ */
66
+ export declare function getGeneratedDirForBlock(paths: MigrationProjectPaths, block: MigrationBlockConfig | ResolvedMigrationBlockTarget): string;
67
+ /**
68
+ * Resolves the migration rule file path for a block version edge.
69
+ *
70
+ * @param paths Resolved migration project paths.
71
+ * @param block Block target or resolved block target.
72
+ * @param fromVersion Source migration version.
73
+ * @param toVersion Destination migration version.
74
+ * @returns The absolute migration rule file path.
75
+ */
76
+ export declare function getRuleFilePath(paths: MigrationProjectPaths, block: MigrationBlockConfig | ResolvedMigrationBlockTarget, fromVersion: string, toVersion: string): string;
77
+ /**
78
+ * Resolves the migration fixture path for a block version edge.
79
+ *
80
+ * @param paths Resolved migration project paths.
81
+ * @param block Block target or resolved block target.
82
+ * @param fromVersion Source migration version.
83
+ * @param toVersion Destination migration version.
84
+ * @returns The absolute migration fixture file path.
85
+ */
86
+ export declare function getFixtureFilePath(paths: MigrationProjectPaths, block: MigrationBlockConfig | ResolvedMigrationBlockTarget, fromVersion: string, toVersion: string): string;
87
+ /**
88
+ * Resolves the validators import path for generated migration artifacts.
89
+ *
90
+ * @param projectDir Project directory containing the migration workspace.
91
+ * @param block Block target or resolved block target.
92
+ * @param fromDir Directory that will import the validators module.
93
+ * @returns A relative module import path without a file extension.
94
+ */
95
+ export declare function getValidatorsImportPath(projectDir: string, block: MigrationBlockConfig | ResolvedMigrationBlockTarget, fromDir: string): string;
96
+ /**
97
+ * Ensures the migration fixture, generated, rule, and snapshot directories exist.
98
+ *
99
+ * @param projectDir Project directory containing the migration workspace.
100
+ * @param blocks Optional block targets whose scoped rule/fixture directories should be created.
101
+ * @returns Nothing.
102
+ */
103
+ export declare function ensureMigrationDirectories(projectDir: string, blocks?: MigrationBlockConfig[]): void;
104
+ /**
105
+ * Discovers the generated migration registry entries for a loaded project state.
106
+ *
107
+ * @param state Loaded migration project state.
108
+ * @returns Sorted migration registry entries for every available block/version edge.
109
+ */
110
+ export declare function discoverMigrationEntries(state: MigrationProjectState): MigrationEntry[];
111
+ /**
112
+ * Verifies that a migration rule file exists and no TODO markers remain in it.
113
+ *
114
+ * @param projectDir Project directory containing the migration workspace.
115
+ * @param block Block target or resolved block target.
116
+ * @param fromMigrationVersion Source migration version.
117
+ * @param toMigrationVersion Destination migration version.
118
+ * @returns Nothing.
119
+ * @throws Error When the rule file is missing or still contains TODO markers.
120
+ */
121
+ export declare function assertRuleHasNoTodos(projectDir: string, block: MigrationBlockConfig | ResolvedMigrationBlockTarget, fromMigrationVersion: string, toMigrationVersion: string): void;
122
+ /**
123
+ * Reads lightweight metadata from a migration rule source file.
124
+ *
125
+ * @param rulePath Absolute path to the migration rule source file.
126
+ * @returns Parsed unresolved paths, rename mappings, and transform keys.
127
+ */
128
+ export declare function readRuleMetadata(rulePath: string): RuleMetadata;
129
+ /**
130
+ * Normalizes a migration block config against the current working directory.
131
+ *
132
+ * @param block Migration block config with project-relative file paths.
133
+ * @returns A normalized migration block config with ensured relative paths.
134
+ */
135
+ export declare function createMigrationBlockConfig(block: MigrationBlockConfig): MigrationBlockConfig;