@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,4 @@
|
|
|
1
|
+
import type { MigrationDiff, MigrationRiskSummary } from "./migration-types.js";
|
|
2
|
+
export declare function createEmptyMigrationRiskSummary(): MigrationRiskSummary;
|
|
3
|
+
export declare function formatMigrationRiskSummary(summary: MigrationRiskSummary): string;
|
|
4
|
+
export declare function createMigrationRiskSummary(diff: MigrationDiff): MigrationRiskSummary;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function createRiskBucket(items) {
|
|
2
|
+
return {
|
|
3
|
+
count: items.length,
|
|
4
|
+
items,
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function formatDiffOutcome(item) {
|
|
8
|
+
return `${item.path}: ${item.kind}${item.detail ? ` (${item.detail})` : ""}`;
|
|
9
|
+
}
|
|
10
|
+
function formatRenameCandidate(candidate) {
|
|
11
|
+
return `${candidate.currentPath} <- ${candidate.legacyPath} (${candidate.autoApply ? "auto" : "review"}, ${candidate.reason})`;
|
|
12
|
+
}
|
|
13
|
+
function formatTransformSuggestion(suggestion) {
|
|
14
|
+
return `${suggestion.currentPath}${suggestion.legacyPath ? ` <- ${suggestion.legacyPath}` : ""} (${suggestion.reason})`;
|
|
15
|
+
}
|
|
16
|
+
function unique(items) {
|
|
17
|
+
return [...new Set(items)];
|
|
18
|
+
}
|
|
19
|
+
export function createEmptyMigrationRiskSummary() {
|
|
20
|
+
return {
|
|
21
|
+
additive: createRiskBucket([]),
|
|
22
|
+
rename: createRiskBucket([]),
|
|
23
|
+
semanticTransform: createRiskBucket([]),
|
|
24
|
+
unionBreaking: createRiskBucket([]),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function formatMigrationRiskSummary(summary) {
|
|
28
|
+
return `additive=${summary.additive.count}, rename=${summary.rename.count}, semanticTransform=${summary.semanticTransform.count}, unionBreaking=${summary.unionBreaking.count}`;
|
|
29
|
+
}
|
|
30
|
+
export function createMigrationRiskSummary(diff) {
|
|
31
|
+
const additiveKinds = new Set([
|
|
32
|
+
"add-default",
|
|
33
|
+
"add-optional",
|
|
34
|
+
"drop",
|
|
35
|
+
"hydrate",
|
|
36
|
+
"union-branch-addition",
|
|
37
|
+
]);
|
|
38
|
+
const additiveItems = unique(diff.summary.autoItems
|
|
39
|
+
.filter((item) => additiveKinds.has(item.kind))
|
|
40
|
+
.map(formatDiffOutcome));
|
|
41
|
+
const renameItems = unique(diff.summary.renameCandidates.map(formatRenameCandidate));
|
|
42
|
+
const semanticTransformItems = unique(diff.summary.transformSuggestions.map(formatTransformSuggestion));
|
|
43
|
+
const unionBreakingItems = unique(diff.summary.manualItems
|
|
44
|
+
.filter((item) => item.kind.startsWith("union-"))
|
|
45
|
+
.map(formatDiffOutcome));
|
|
46
|
+
return {
|
|
47
|
+
additive: createRiskBucket(additiveItems),
|
|
48
|
+
rename: createRiskBucket(renameItems),
|
|
49
|
+
semanticTransform: createRiskBucket(semanticTransformItems),
|
|
50
|
+
unionBreaking: createRiskBucket(unionBreakingItems),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
2
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
export type ManifestTsKind = "string" | "number" | "boolean" | "array" | "object" | "union";
|
|
6
|
+
export interface ManifestConstraints {
|
|
7
|
+
exclusiveMaximum?: number | null;
|
|
8
|
+
exclusiveMinimum?: number | null;
|
|
9
|
+
format?: string | null;
|
|
10
|
+
maxLength?: number | null;
|
|
11
|
+
maxItems?: number | null;
|
|
12
|
+
maximum?: number | null;
|
|
13
|
+
minLength?: number | null;
|
|
14
|
+
minItems?: number | null;
|
|
15
|
+
minimum?: number | null;
|
|
16
|
+
multipleOf?: number | null;
|
|
17
|
+
pattern?: string | null;
|
|
18
|
+
typeTag?: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface ManifestUnionMetadata {
|
|
21
|
+
discriminator: string;
|
|
22
|
+
branches: Record<string, ManifestAttribute>;
|
|
23
|
+
}
|
|
24
|
+
export interface ManifestTsMetadata {
|
|
25
|
+
items?: ManifestAttribute | null;
|
|
26
|
+
kind: ManifestTsKind;
|
|
27
|
+
properties?: Record<string, ManifestAttribute> | null;
|
|
28
|
+
required?: boolean;
|
|
29
|
+
union?: ManifestUnionMetadata | null;
|
|
30
|
+
}
|
|
31
|
+
export interface ManifestTypiaMetadata {
|
|
32
|
+
constraints: ManifestConstraints;
|
|
33
|
+
defaultValue?: JsonValue | null;
|
|
34
|
+
hasDefault?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ManifestWpMetadata {
|
|
37
|
+
defaultValue?: JsonValue | null;
|
|
38
|
+
enum?: JsonValue[] | null;
|
|
39
|
+
hasDefault?: boolean;
|
|
40
|
+
selector?: string | null;
|
|
41
|
+
source?: "html" | "text" | "rich-text" | null;
|
|
42
|
+
type?: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface ManifestAttribute {
|
|
45
|
+
ts: ManifestTsMetadata;
|
|
46
|
+
typia: ManifestTypiaMetadata;
|
|
47
|
+
wp: ManifestWpMetadata;
|
|
48
|
+
}
|
|
49
|
+
export interface ManifestDocument {
|
|
50
|
+
attributes?: Record<string, ManifestAttribute>;
|
|
51
|
+
manifestVersion?: number | null;
|
|
52
|
+
sourceType?: string | null;
|
|
53
|
+
}
|
|
54
|
+
export interface ManifestSummaryAttribute {
|
|
55
|
+
constraints: ManifestAttribute["typia"]["constraints"];
|
|
56
|
+
defaultValue: ManifestAttribute["typia"]["defaultValue"] | null;
|
|
57
|
+
enum: ManifestAttribute["wp"]["enum"] | null;
|
|
58
|
+
hasDefault: boolean;
|
|
59
|
+
kind: ManifestAttribute["ts"]["kind"] | null;
|
|
60
|
+
required: boolean;
|
|
61
|
+
union: ManifestAttribute["ts"]["union"] | null;
|
|
62
|
+
}
|
|
63
|
+
export interface ManifestSummary {
|
|
64
|
+
attributes: Record<string, ManifestSummaryAttribute>;
|
|
65
|
+
manifestVersion: number | null;
|
|
66
|
+
sourceType: string | null;
|
|
67
|
+
}
|
|
68
|
+
export interface UnionBranchSummary {
|
|
69
|
+
branches: string[];
|
|
70
|
+
discriminator: string | null;
|
|
71
|
+
field: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Declares the migration-lineage labels and block targets used by a project migration workspace.
|
|
75
|
+
*
|
|
76
|
+
* These labels describe schema lineage such as `v1`, `v2`, and `v3`; they do
|
|
77
|
+
* not represent package, plugin, or release versions.
|
|
78
|
+
*/
|
|
79
|
+
export interface MigrationConfig {
|
|
80
|
+
/** Optional single-block name used by legacy-root retrofit layouts. */
|
|
81
|
+
blockName?: string;
|
|
82
|
+
/** Optional explicit block target list for multi-block migration workspaces. */
|
|
83
|
+
blocks?: MigrationBlockConfig[];
|
|
84
|
+
/** Current migration-lineage label for newly generated snapshots and rules. */
|
|
85
|
+
currentMigrationVersion: string;
|
|
86
|
+
/** Relative directory that stores versioned migration snapshots. */
|
|
87
|
+
snapshotDir: string;
|
|
88
|
+
/** Ordered migration-lineage labels configured for this workspace, including the current label. */
|
|
89
|
+
supportedMigrationVersions: string[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Declares one migration-capable block target inside a project workspace.
|
|
93
|
+
*/
|
|
94
|
+
export interface MigrationBlockConfig {
|
|
95
|
+
/** Relative path to the target block.json metadata file. */
|
|
96
|
+
blockJsonFile: string;
|
|
97
|
+
/** Registered block name for this migration target. */
|
|
98
|
+
blockName: string;
|
|
99
|
+
/** Stable block key used for generated file naming and registry entries. */
|
|
100
|
+
key: string;
|
|
101
|
+
/** Relative path to the generated manifest snapshot input for the block. */
|
|
102
|
+
manifestFile: string;
|
|
103
|
+
/** Relative path to the saved-markup source file used for snapshot capture. */
|
|
104
|
+
saveFile: string;
|
|
105
|
+
/** Relative path to the canonical types source for the block. */
|
|
106
|
+
typesFile: string;
|
|
107
|
+
}
|
|
108
|
+
export interface ResolvedMigrationBlockTarget extends MigrationBlockConfig {
|
|
109
|
+
currentBlockJson: Record<string, unknown>;
|
|
110
|
+
currentManifest: ManifestDocument;
|
|
111
|
+
layout: "legacy" | "multi";
|
|
112
|
+
}
|
|
113
|
+
export interface MigrationProjectPaths {
|
|
114
|
+
configFile: string;
|
|
115
|
+
fixturesDir: string;
|
|
116
|
+
generatedDir: string;
|
|
117
|
+
rulesDir: string;
|
|
118
|
+
snapshotDir: string;
|
|
119
|
+
}
|
|
120
|
+
export interface MigrationProjectState {
|
|
121
|
+
blocks: ResolvedMigrationBlockTarget[];
|
|
122
|
+
config: MigrationConfig;
|
|
123
|
+
currentBlockJson: Record<string, unknown>;
|
|
124
|
+
currentManifest: ManifestDocument;
|
|
125
|
+
paths: MigrationProjectPaths;
|
|
126
|
+
projectDir: string;
|
|
127
|
+
}
|
|
128
|
+
export interface MigrationEntry {
|
|
129
|
+
block: MigrationBlockConfig;
|
|
130
|
+
blockJsonImport: string;
|
|
131
|
+
fixtureImport: string;
|
|
132
|
+
fromVersion: string;
|
|
133
|
+
generatedDir: string;
|
|
134
|
+
manifestImport: string;
|
|
135
|
+
ruleImport: string;
|
|
136
|
+
rulePath: string;
|
|
137
|
+
saveImport: string;
|
|
138
|
+
toVersion: string;
|
|
139
|
+
validatorImport: string;
|
|
140
|
+
}
|
|
141
|
+
export interface RuleMetadata {
|
|
142
|
+
renameMap: Array<{
|
|
143
|
+
currentPath: string;
|
|
144
|
+
legacyPath: string;
|
|
145
|
+
}>;
|
|
146
|
+
transforms: string[];
|
|
147
|
+
unresolved: string[];
|
|
148
|
+
}
|
|
149
|
+
export interface FlattenedAttributeDescriptor {
|
|
150
|
+
attribute: ManifestAttribute;
|
|
151
|
+
currentPath: string;
|
|
152
|
+
rootPath: string;
|
|
153
|
+
sourcePath: string;
|
|
154
|
+
unionBranch: string | null;
|
|
155
|
+
unionDiscriminator: string | null;
|
|
156
|
+
unionRoot: string | null;
|
|
157
|
+
}
|
|
158
|
+
export interface DiffOutcome {
|
|
159
|
+
detail?: string;
|
|
160
|
+
kind: string;
|
|
161
|
+
path: string;
|
|
162
|
+
status: "auto" | "manual";
|
|
163
|
+
}
|
|
164
|
+
export interface RenameCandidate {
|
|
165
|
+
autoApply: boolean;
|
|
166
|
+
currentPath: string;
|
|
167
|
+
legacyPath: string;
|
|
168
|
+
reason: string;
|
|
169
|
+
score: number;
|
|
170
|
+
}
|
|
171
|
+
export interface TransformSuggestion {
|
|
172
|
+
attribute: ManifestAttribute | null;
|
|
173
|
+
bodyLines: string[];
|
|
174
|
+
currentPath: string;
|
|
175
|
+
legacyPath: string | null;
|
|
176
|
+
reason: string;
|
|
177
|
+
}
|
|
178
|
+
export interface MigrationDiffSummary {
|
|
179
|
+
auto: number;
|
|
180
|
+
autoItems: DiffOutcome[];
|
|
181
|
+
manual: number;
|
|
182
|
+
manualItems: DiffOutcome[];
|
|
183
|
+
renameCandidates: RenameCandidate[];
|
|
184
|
+
transformSuggestions: TransformSuggestion[];
|
|
185
|
+
}
|
|
186
|
+
export interface MigrationDiff {
|
|
187
|
+
currentTypeName: string | null | undefined;
|
|
188
|
+
fromVersion: string;
|
|
189
|
+
summary: MigrationDiffSummary;
|
|
190
|
+
toVersion: string;
|
|
191
|
+
}
|
|
192
|
+
export interface MigrationRiskBucket {
|
|
193
|
+
count: number;
|
|
194
|
+
items: string[];
|
|
195
|
+
}
|
|
196
|
+
export interface MigrationRiskSummary {
|
|
197
|
+
additive: MigrationRiskBucket;
|
|
198
|
+
rename: MigrationRiskBucket;
|
|
199
|
+
semanticTransform: MigrationRiskBucket;
|
|
200
|
+
unionBreaking: MigrationRiskBucket;
|
|
201
|
+
}
|
|
202
|
+
export interface MigrationFuzzMapping {
|
|
203
|
+
currentPath: string;
|
|
204
|
+
legacyPath: string;
|
|
205
|
+
}
|
|
206
|
+
export interface MigrationFuzzPlan {
|
|
207
|
+
blockedPaths: string[];
|
|
208
|
+
compatibleMappings: MigrationFuzzMapping[];
|
|
209
|
+
}
|
|
210
|
+
export interface GeneratedMigrationEntry {
|
|
211
|
+
diff: MigrationDiff;
|
|
212
|
+
entry: MigrationEntry;
|
|
213
|
+
fuzzPlan: MigrationFuzzPlan;
|
|
214
|
+
riskSummary: MigrationRiskSummary;
|
|
215
|
+
}
|
|
216
|
+
export interface MigrationRuleFileInput {
|
|
217
|
+
block: MigrationBlockConfig;
|
|
218
|
+
currentAttributes: Record<string, ManifestAttribute>;
|
|
219
|
+
currentTypeName: string | null | undefined;
|
|
220
|
+
diff: MigrationDiff;
|
|
221
|
+
fromVersion: string;
|
|
222
|
+
projectDir: string;
|
|
223
|
+
rulePath: string;
|
|
224
|
+
targetVersion: string;
|
|
225
|
+
}
|
|
226
|
+
export interface MigrationFixtureCase {
|
|
227
|
+
input: JsonObject;
|
|
228
|
+
name: string;
|
|
229
|
+
}
|
|
230
|
+
export interface MigrationFixtureDocument {
|
|
231
|
+
cases: MigrationFixtureCase[];
|
|
232
|
+
fromVersion: string;
|
|
233
|
+
toVersion: string;
|
|
234
|
+
}
|
|
235
|
+
export interface ParsedMigrationArgs {
|
|
236
|
+
command?: string;
|
|
237
|
+
flags: {
|
|
238
|
+
all: boolean;
|
|
239
|
+
currentMigrationVersion?: string;
|
|
240
|
+
force: boolean;
|
|
241
|
+
fromMigrationVersion?: string;
|
|
242
|
+
iterations?: string;
|
|
243
|
+
migrationVersion?: string;
|
|
244
|
+
seed?: string;
|
|
245
|
+
toMigrationVersion?: string;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
export type RenderLine = (line: string) => void;
|
|
249
|
+
export type JsonObject = Record<string, JsonValue>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PackageManagerId } from "./package-managers.js";
|
|
2
|
+
import type { ScaffoldTemplateVariables } from "./scaffold.js";
|
|
3
|
+
interface ApplyMigrationUiCapabilityOptions {
|
|
4
|
+
packageManager: PackageManagerId;
|
|
5
|
+
projectDir: string;
|
|
6
|
+
templateId: string;
|
|
7
|
+
variables: ScaffoldTemplateVariables;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Layer the migration dashboard capability onto a freshly scaffolded project.
|
|
11
|
+
*
|
|
12
|
+
* This copies the shared migration UI files, wires template-specific editor
|
|
13
|
+
* hooks, and injects pinned migration scripts that shell out to the matching
|
|
14
|
+
* `wp-typia` CLI version.
|
|
15
|
+
*/
|
|
16
|
+
export declare function applyMigrationUiCapability({ packageManager, projectDir, templateId, variables, }: ApplyMigrationUiCapabilityOptions): Promise<void>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { promises as fsp } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getPackageVersions } from "./package-versions.js";
|
|
4
|
+
import { formatPackageExecCommand } from "./package-managers.js";
|
|
5
|
+
import { seedProjectMigrations } from "./migrations.js";
|
|
6
|
+
import { copyInterpolatedDirectory } from "./template-render.js";
|
|
7
|
+
import { SHARED_MIGRATION_UI_TEMPLATE_ROOT, } from "./template-registry.js";
|
|
8
|
+
const INITIAL_MIGRATION_VERSION = "v1";
|
|
9
|
+
async function mutatePackageJson(projectDir, mutate) {
|
|
10
|
+
const packageJsonPath = path.join(projectDir, "package.json");
|
|
11
|
+
const packageJson = JSON.parse(await fsp.readFile(packageJsonPath, "utf8"));
|
|
12
|
+
mutate(packageJson);
|
|
13
|
+
await fsp.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, "\t")}\n`, "utf8");
|
|
14
|
+
}
|
|
15
|
+
async function patchFile(filePath, transform) {
|
|
16
|
+
const source = await fsp.readFile(filePath, "utf8");
|
|
17
|
+
const nextSource = transform(source);
|
|
18
|
+
if (nextSource === source) {
|
|
19
|
+
throw new Error(`Unable to apply migration UI patch for ${filePath}`);
|
|
20
|
+
}
|
|
21
|
+
await fsp.writeFile(filePath, nextSource, "utf8");
|
|
22
|
+
}
|
|
23
|
+
function injectAfter(source, needle, insertion) {
|
|
24
|
+
if (source.includes(insertion)) {
|
|
25
|
+
return source;
|
|
26
|
+
}
|
|
27
|
+
if (!source.includes(needle)) {
|
|
28
|
+
return source;
|
|
29
|
+
}
|
|
30
|
+
return source.replace(needle, `${needle}\n${insertion}`);
|
|
31
|
+
}
|
|
32
|
+
function injectBefore(source, needle, insertion) {
|
|
33
|
+
if (source.includes(insertion)) {
|
|
34
|
+
return source;
|
|
35
|
+
}
|
|
36
|
+
if (!source.includes(needle)) {
|
|
37
|
+
return source;
|
|
38
|
+
}
|
|
39
|
+
return source.replace(needle, `${insertion}\n${needle}`);
|
|
40
|
+
}
|
|
41
|
+
function buildMigrationBlocks(templateId, variables) {
|
|
42
|
+
if (templateId === "compound") {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
blockJsonFile: `src/blocks/${variables.slugKebabCase}/block.json`,
|
|
46
|
+
blockName: `${variables.namespace}/${variables.slugKebabCase}`,
|
|
47
|
+
key: variables.slugKebabCase,
|
|
48
|
+
manifestFile: `src/blocks/${variables.slugKebabCase}/typia.manifest.json`,
|
|
49
|
+
saveFile: `src/blocks/${variables.slugKebabCase}/save.tsx`,
|
|
50
|
+
typesFile: `src/blocks/${variables.slugKebabCase}/types.ts`,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
blockJsonFile: `src/blocks/${variables.slugKebabCase}-item/block.json`,
|
|
54
|
+
blockName: `${variables.namespace}/${variables.slugKebabCase}-item`,
|
|
55
|
+
key: `${variables.slugKebabCase}-item`,
|
|
56
|
+
manifestFile: `src/blocks/${variables.slugKebabCase}-item/typia.manifest.json`,
|
|
57
|
+
saveFile: `src/blocks/${variables.slugKebabCase}-item/save.tsx`,
|
|
58
|
+
typesFile: `src/blocks/${variables.slugKebabCase}-item/types.ts`,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
blockJsonFile: "src/block.json",
|
|
65
|
+
blockName: `${variables.namespace}/${variables.slugKebabCase}`,
|
|
66
|
+
key: variables.slugKebabCase,
|
|
67
|
+
manifestFile: "src/typia.manifest.json",
|
|
68
|
+
saveFile: "src/save.tsx",
|
|
69
|
+
typesFile: "src/types.ts",
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
async function applySingleBlockPatches(projectDir, variables) {
|
|
74
|
+
const editPath = path.join(projectDir, "src", "edit.tsx");
|
|
75
|
+
const indexPath = path.join(projectDir, "src", "index.tsx");
|
|
76
|
+
const deprecatedImport = `import { deprecated } from './migrations/generated/${variables.slugKebabCase}/deprecated';`;
|
|
77
|
+
const deprecatedLine = ` deprecated: deprecated as NonNullable<BlockConfiguration<${variables.pascalCase}Attributes>['deprecated']>,`;
|
|
78
|
+
const dashboardImport = `import { MigrationDashboard } from './admin/migration-dashboard';`;
|
|
79
|
+
const migrationPanel = `\n <PanelBody title={__('Migration Manager', '${variables.textDomain}')}>\n <MigrationDashboard />\n </PanelBody>\n </InspectorControls>`;
|
|
80
|
+
await patchFile(indexPath, (source) => {
|
|
81
|
+
let nextSource = injectAfter(source, "import metadata from './block.json';", deprecatedImport);
|
|
82
|
+
nextSource = injectBefore(nextSource, " edit: Edit,", deprecatedLine);
|
|
83
|
+
return nextSource;
|
|
84
|
+
});
|
|
85
|
+
await patchFile(editPath, (source) => {
|
|
86
|
+
let nextSource = injectAfter(source, "import { useTypiaValidation } from './hooks';", dashboardImport);
|
|
87
|
+
nextSource = nextSource.replace("</InspectorControls>", migrationPanel);
|
|
88
|
+
return nextSource;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async function applyCompoundPatches(projectDir, variables) {
|
|
92
|
+
const parentEditPath = path.join(projectDir, "src", "blocks", variables.slugKebabCase, "edit.tsx");
|
|
93
|
+
const parentIndexPath = path.join(projectDir, "src", "blocks", variables.slugKebabCase, "index.tsx");
|
|
94
|
+
const childIndexPath = path.join(projectDir, "src", "blocks", `${variables.slugKebabCase}-item`, "index.tsx");
|
|
95
|
+
const addChildScriptPath = path.join(projectDir, "scripts", "add-compound-child.ts");
|
|
96
|
+
await patchFile(parentIndexPath, (source) => {
|
|
97
|
+
let nextSource = injectAfter(source, "import metadata from './block.json';", `import { deprecated } from '../../migrations/generated/${variables.slugKebabCase}/deprecated';`);
|
|
98
|
+
nextSource = injectBefore(nextSource, "\tedit: Edit,", `\tdeprecated: deprecated as NonNullable<BlockConfiguration< ${variables.pascalCase}Attributes >['deprecated']>,`);
|
|
99
|
+
return nextSource;
|
|
100
|
+
});
|
|
101
|
+
await patchFile(childIndexPath, (source) => {
|
|
102
|
+
let nextSource = injectAfter(source, "import metadata from './block.json';", `import { deprecated } from '../../migrations/generated/${variables.slugKebabCase}-item/deprecated';`);
|
|
103
|
+
nextSource = injectBefore(nextSource, "\tedit: Edit,", `\tdeprecated: deprecated as NonNullable<BlockConfiguration< ${variables.pascalCase}ItemAttributes >['deprecated']>,`);
|
|
104
|
+
return nextSource;
|
|
105
|
+
});
|
|
106
|
+
await patchFile(parentEditPath, (source) => {
|
|
107
|
+
let nextSource = injectAfter(source, "import { useTypiaValidation } from './hooks';", `import { MigrationDashboard } from '../../admin/migration-dashboard';`);
|
|
108
|
+
nextSource = nextSource.replace("</InspectorControls>", `\n\t\t\t\t<PanelBody title={ __( 'Migration Manager', '${variables.textDomain}' ) }>\n\t\t\t\t\t<MigrationDashboard />\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>`);
|
|
109
|
+
return nextSource;
|
|
110
|
+
});
|
|
111
|
+
await patchFile(addChildScriptPath, (source) => {
|
|
112
|
+
let nextSource = injectAfter(source, "const PROJECT_ROOT = process.cwd();", "const MIGRATION_CONFIG_FILE = path.join( PROJECT_ROOT, 'src', 'migrations', 'config.ts' );");
|
|
113
|
+
nextSource = nextSource.replace("import metadata from './block.json';\nimport '${ PARENT_STYLE_IMPORT }';", "import metadata from './block.json';\nimport { deprecated } from '../../migrations/generated/${ childFolderSlug }/deprecated';\nimport '${ PARENT_STYLE_IMPORT }';");
|
|
114
|
+
nextSource = nextSource.replace("\tedit: Edit,\n\tsave: Save,", "\tdeprecated: deprecated as NonNullable<BlockConfiguration< ${ childTypeName } >['deprecated']>,\n\tedit: Edit,\n\tsave: Save,");
|
|
115
|
+
nextSource = injectAfter(nextSource, "function insertBeforeMarker( filePath: string, marker: string, insertionLines: string[] ) {", "");
|
|
116
|
+
if (!nextSource.includes("function appendMigrationBlockConfig")) {
|
|
117
|
+
const appendMigrationHelper = [
|
|
118
|
+
"function appendMigrationBlockConfig( filePath: string, childBlockName: string, childFolderSlug: string ) {",
|
|
119
|
+
"\tif ( ! fs.existsSync( filePath ) ) {",
|
|
120
|
+
"\t\treturn;",
|
|
121
|
+
"\t}",
|
|
122
|
+
"",
|
|
123
|
+
"\tconst source = fs.readFileSync( filePath, 'utf8' );",
|
|
124
|
+
"\tconst blockEntry = [",
|
|
125
|
+
"\t\t`\\t\\t{`,",
|
|
126
|
+
"\t\t`\\t\\t\\tkey: '${ childFolderSlug }',`,",
|
|
127
|
+
"\t\t`\\t\\t\\tblockName: '${ childBlockName }',`,",
|
|
128
|
+
"\t\t`\\t\\t\\tblockJsonFile: 'src/blocks/${ childFolderSlug }/block.json',`,",
|
|
129
|
+
"\t\t`\\t\\t\\tmanifestFile: 'src/blocks/${ childFolderSlug }/typia.manifest.json',`,",
|
|
130
|
+
"\t\t`\\t\\t\\tsaveFile: 'src/blocks/${ childFolderSlug }/save.tsx',`,",
|
|
131
|
+
"\t\t`\\t\\t\\ttypesFile: 'src/blocks/${ childFolderSlug }/types.ts',`,",
|
|
132
|
+
"\t\t`\\t\\t},`,",
|
|
133
|
+
"\t].join( '\\n' );",
|
|
134
|
+
"\tif ( source.includes( `key: '${ childFolderSlug }'` ) ) {",
|
|
135
|
+
"\t\treturn;",
|
|
136
|
+
"\t}",
|
|
137
|
+
"\tconst nextSource = source.replace( /\\tblocks:\\s*\\[([\\s\\S]*?)\\n\\t\\],/m, ( match ) => {",
|
|
138
|
+
"\t\treturn match.replace( /\\n\\t\\],$/, `\\n${ blockEntry }\\n\\t],` );",
|
|
139
|
+
"\t} );",
|
|
140
|
+
"\tfs.writeFileSync( filePath, nextSource, 'utf8' );",
|
|
141
|
+
"}",
|
|
142
|
+
"",
|
|
143
|
+
"function renderBlockJson(",
|
|
144
|
+
].join("\n");
|
|
145
|
+
nextSource = nextSource.replace("function renderBlockJson(", appendMigrationHelper);
|
|
146
|
+
}
|
|
147
|
+
nextSource = nextSource.replace("console.log( `✅ Added compound child block ${ childBlockName }` );", "appendMigrationBlockConfig( MIGRATION_CONFIG_FILE, childBlockName, childFolderSlug );\n\n\tconsole.log( `✅ Added compound child block ${ childBlockName }` );");
|
|
148
|
+
return nextSource;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Layer the migration dashboard capability onto a freshly scaffolded project.
|
|
153
|
+
*
|
|
154
|
+
* This copies the shared migration UI files, wires template-specific editor
|
|
155
|
+
* hooks, and injects pinned migration scripts that shell out to the matching
|
|
156
|
+
* `wp-typia` CLI version.
|
|
157
|
+
*/
|
|
158
|
+
export async function applyMigrationUiCapability({ packageManager, projectDir, templateId, variables, }) {
|
|
159
|
+
const commonTemplateDir = path.join(SHARED_MIGRATION_UI_TEMPLATE_ROOT, "common");
|
|
160
|
+
await copyInterpolatedDirectory(commonTemplateDir, projectDir, variables);
|
|
161
|
+
await mutatePackageJson(projectDir, (packageJson) => {
|
|
162
|
+
const wpTypiaPackageVersion = getPackageVersions().wpTypiaPackageVersion;
|
|
163
|
+
const canonicalCliSpecifier = wpTypiaPackageVersion === "^0.0.0"
|
|
164
|
+
? "wp-typia"
|
|
165
|
+
: `wp-typia@${wpTypiaPackageVersion.replace(/^[~^]/u, "")}`;
|
|
166
|
+
const migrationCli = (args) => formatPackageExecCommand(packageManager, canonicalCliSpecifier, `migrate ${args}`);
|
|
167
|
+
packageJson.dependencies = {
|
|
168
|
+
...(packageJson.dependencies ?? {}),
|
|
169
|
+
"@wordpress/api-fetch": "^7.42.0",
|
|
170
|
+
};
|
|
171
|
+
packageJson.scripts = {
|
|
172
|
+
...(packageJson.scripts ?? {}),
|
|
173
|
+
"migration:init": migrationCli(`init --current-migration-version ${INITIAL_MIGRATION_VERSION}`),
|
|
174
|
+
"migration:snapshot": migrationCli("snapshot"),
|
|
175
|
+
"migration:diff": migrationCli("diff"),
|
|
176
|
+
"migration:scaffold": migrationCli("scaffold"),
|
|
177
|
+
"migration:doctor": migrationCli("doctor --all"),
|
|
178
|
+
"migration:fixtures": migrationCli("fixtures --all"),
|
|
179
|
+
"migration:verify": migrationCli("verify --all"),
|
|
180
|
+
"migration:fuzz": migrationCli("fuzz --all"),
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
if (templateId === "compound") {
|
|
184
|
+
await applyCompoundPatches(projectDir, variables);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
await applySingleBlockPatches(projectDir, variables);
|
|
188
|
+
}
|
|
189
|
+
await seedProjectMigrations(projectDir, INITIAL_MIGRATION_VERSION, buildMigrationBlocks(templateId, variables));
|
|
190
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { JsonValue, ManifestAttribute, JsonObject } from "./migration-types.js";
|
|
2
|
+
export { cloneJsonValue } from "./json-utils.js";
|
|
3
|
+
export declare function getValueAtPath(input: Record<string, unknown>, pathLabel: string): unknown;
|
|
4
|
+
export declare function setValueAtPath(input: Record<string, unknown>, pathLabel: string, value: unknown): void;
|
|
5
|
+
export declare function deleteValueAtPath(input: Record<string, unknown>, pathLabel: string): void;
|
|
6
|
+
export declare function createFixtureScalarValue(pathLabel: string): JsonValue;
|
|
7
|
+
export declare function createTransformFixtureValue(attribute: ManifestAttribute | null | undefined, pathLabel: string): JsonValue;
|
|
8
|
+
export declare function readJson<T = unknown>(filePath: string): T;
|
|
9
|
+
export declare function renderPhpValue(value: unknown, indentLevel: number): string;
|
|
10
|
+
export declare function copyFile(sourcePath: string, targetPath: string): void;
|
|
11
|
+
export declare function sanitizeSaveSnapshotSource(source: string): string;
|
|
12
|
+
export declare function sanitizeSnapshotBlockJson(blockJson: JsonObject): JsonObject;
|
|
13
|
+
export declare function runProjectScriptIfPresent(projectDir: string, scriptName: string): void;
|
|
14
|
+
export declare function detectPackageManagerId(projectDir: string): "bun" | "npm" | "pnpm" | "yarn";
|
|
15
|
+
export declare function getLocalTsxBinary(projectDir: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Returns whether isInteractiveTerminal() is running with both stdin and stdout
|
|
18
|
+
* attached to a TTY so CLI and migration flows can safely prompt the user.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isInteractiveTerminal(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the `current` sentinel to the current migration version label.
|
|
23
|
+
*
|
|
24
|
+
* @param currentMigrationVersion Current migration version label for the workspace.
|
|
25
|
+
* @param value Requested target value, which may be `current`.
|
|
26
|
+
* @returns The concrete migration version label that should be used.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveTargetMigrationVersion(currentMigrationVersion: string, value: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether a value matches the canonical `vN` migration label format.
|
|
31
|
+
*
|
|
32
|
+
* @param value Candidate migration version label.
|
|
33
|
+
* @returns `true` when the value is a valid `vN` label with `N >= 1`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isMigrationVersionLabel(value: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Returns whether a value looks like a legacy semver-based migration label.
|
|
38
|
+
*
|
|
39
|
+
* @param value Candidate migration version label.
|
|
40
|
+
* @returns `true` when the value matches the legacy `x.y.z` semver pattern.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isLegacySemverMigrationVersion(value: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Throws when a migration version label does not match the canonical `vN` format.
|
|
45
|
+
*
|
|
46
|
+
* @param value Candidate migration version label.
|
|
47
|
+
* @param label Human-readable label used in the thrown error message.
|
|
48
|
+
* @returns Nothing.
|
|
49
|
+
* @throws Error When the provided value is not a valid `vN` migration label.
|
|
50
|
+
*/
|
|
51
|
+
export declare function assertMigrationVersionLabel(value: string, label: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Compares two migration version labels by their numeric suffix.
|
|
54
|
+
*
|
|
55
|
+
* @param left Left migration version label.
|
|
56
|
+
* @param right Right migration version label.
|
|
57
|
+
* @returns A negative number when `left < right`, zero when equal, and a positive number when `left > right`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function compareMigrationVersionLabels(left: string, right: string): number;
|
|
60
|
+
/**
|
|
61
|
+
* Formats the reset guidance shown when a legacy semver migration workspace is detected.
|
|
62
|
+
*
|
|
63
|
+
* @param reason Optional leading reason that explains what legacy pattern was found.
|
|
64
|
+
* @returns A user-facing guidance string that explains how to reset to `v1` labels.
|
|
65
|
+
*/
|
|
66
|
+
export declare function formatLegacyMigrationWorkspaceResetGuidance(reason?: string): string;
|
|
67
|
+
export declare function escapeForCode(value: unknown): string;
|
|
68
|
+
export declare function renderObjectKey(key: string): string;
|
|
69
|
+
export declare function isNumber(value: unknown): value is number;
|