diff --git a/src/bin/lib/migrateToLatest.ts b/src/bin/lib/migrateToLatest.ts index 97bdb74c..b10c9da8 100644 --- a/src/bin/lib/migrateToLatest.ts +++ b/src/bin/lib/migrateToLatest.ts @@ -31,12 +31,24 @@ export interface MigrationLatest { version: string; } +function isSemverPatchDiff(version1: string, version2: string): boolean { + return version1.split('.').slice(0, 2).join('.') === version2.split('.').slice(0, 2).join('.'); +} + export function migrateToLatest(projectJson: Record, path: string): MigrationResult { let currentVersion = `v${'typeDocJsonParserVersion' in projectJson ? projectJson.typeDocJsonParserVersion : '2.0.0'}` as string; const latestVersion = `v${ProjectParser.version}`; let result: MigrationResult | undefined; while (currentVersion !== latestVersion) { + if (isSemverPatchDiff(currentVersion, latestVersion)) { + projectJson = latest(projectJson as unknown as Tags.v10_1_0.ProjectJson) as unknown as Record; + result = { status: MigrationStatus.Latest, path, name: projectJson.name as string, version: projectJson.version as string }; + currentVersion = latestVersion; + + break; + } + const migration = migrations.find((migration) => migration.from.includes(currentVersion)); if (!migration) { @@ -833,15 +845,12 @@ const migrations: Migration[] = [ dependencies: {} }; } - }, - { - from: ['v10.1.0', 'v10.1.1', 'v10.1.2'], - to: 'v10.1.3', - run(projectJson: Tags.v10_1_0.ProjectJson | Tags.v10_1_1.ProjectJson | Tags.v10_1_2.ProjectJson): Tags.v10_1_3.ProjectJson { - return { - ...projectJson, - typeDocJsonParserVersion: '10.1.3' - }; - } } ]; + +function latest(projectJson: Tags.v10_1_0.ProjectJson): ProjectParser.Json { + return { + ...projectJson, + typeDocJsonParserVersion: ProjectParser.version + }; +} diff --git a/src/bin/lib/types/Tags/v10_1_0.ts b/src/bin/lib/types/Tags/v10_1_0.ts index 1646a39b..0970d789 100644 --- a/src/bin/lib/types/Tags/v10_1_0.ts +++ b/src/bin/lib/types/Tags/v10_1_0.ts @@ -123,7 +123,7 @@ export namespace v10_1_0 { abstract: boolean; typeParameters: Misc.TypeParameterJson[]; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; @@ -240,5 +240,3 @@ export namespace v10_1_0 { value: string; } } - -export { v10_1_0 as v10_1_1, v10_1_0 as v10_1_2, v10_1_0 as v10_1_3 }; diff --git a/src/bin/lib/types/Tags/v2_0_0.ts b/src/bin/lib/types/Tags/v2_0_0.ts index bfe57268..f7eee6c8 100644 --- a/src/bin/lib/types/Tags/v2_0_0.ts +++ b/src/bin/lib/types/Tags/v2_0_0.ts @@ -111,7 +111,7 @@ export namespace v2_0_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v2_1_0.ts b/src/bin/lib/types/Tags/v2_1_0.ts index 5d9c4402..7a148b2d 100644 --- a/src/bin/lib/types/Tags/v2_1_0.ts +++ b/src/bin/lib/types/Tags/v2_1_0.ts @@ -112,7 +112,7 @@ export namespace v2_1_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v2_2_0.ts b/src/bin/lib/types/Tags/v2_2_0.ts index 1aa5c0dd..7f3adf98 100644 --- a/src/bin/lib/types/Tags/v2_2_0.ts +++ b/src/bin/lib/types/Tags/v2_2_0.ts @@ -113,7 +113,7 @@ export namespace v2_2_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v2_3_0.ts b/src/bin/lib/types/Tags/v2_3_0.ts index 257fffa9..c072b6bc 100644 --- a/src/bin/lib/types/Tags/v2_3_0.ts +++ b/src/bin/lib/types/Tags/v2_3_0.ts @@ -114,7 +114,7 @@ export namespace v2_3_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v3_0_0.ts b/src/bin/lib/types/Tags/v3_0_0.ts index b67e9c0a..1a5ba7c9 100644 --- a/src/bin/lib/types/Tags/v3_0_0.ts +++ b/src/bin/lib/types/Tags/v3_0_0.ts @@ -116,7 +116,7 @@ export namespace v3_0_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v3_1_0.ts b/src/bin/lib/types/Tags/v3_1_0.ts index 78c18e40..349d2bdc 100644 --- a/src/bin/lib/types/Tags/v3_1_0.ts +++ b/src/bin/lib/types/Tags/v3_1_0.ts @@ -116,7 +116,7 @@ export namespace v3_1_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v3_2_0.ts b/src/bin/lib/types/Tags/v3_2_0.ts index a4a14169..881c9318 100644 --- a/src/bin/lib/types/Tags/v3_2_0.ts +++ b/src/bin/lib/types/Tags/v3_2_0.ts @@ -117,7 +117,7 @@ export namespace v3_2_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v4_0_0.ts b/src/bin/lib/types/Tags/v4_0_0.ts index 91f84809..1e06881c 100644 --- a/src/bin/lib/types/Tags/v4_0_0.ts +++ b/src/bin/lib/types/Tags/v4_0_0.ts @@ -117,7 +117,7 @@ export namespace v4_0_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v5_0_0.ts b/src/bin/lib/types/Tags/v5_0_0.ts index 1afdebc2..62dd9112 100644 --- a/src/bin/lib/types/Tags/v5_0_0.ts +++ b/src/bin/lib/types/Tags/v5_0_0.ts @@ -117,7 +117,7 @@ export namespace v5_0_0 { external: boolean; abstract: boolean; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v6_0_0.ts b/src/bin/lib/types/Tags/v6_0_0.ts index 14563601..c05cb0ec 100644 --- a/src/bin/lib/types/Tags/v6_0_0.ts +++ b/src/bin/lib/types/Tags/v6_0_0.ts @@ -119,7 +119,7 @@ export namespace v6_0_0 { abstract: boolean; typeParameters: Misc.TypeParameterJson[]; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v7_0_0.ts b/src/bin/lib/types/Tags/v7_0_0.ts index 5c7bcad1..d6661d7f 100644 --- a/src/bin/lib/types/Tags/v7_0_0.ts +++ b/src/bin/lib/types/Tags/v7_0_0.ts @@ -119,7 +119,7 @@ export namespace v7_0_0 { abstract: boolean; typeParameters: Misc.TypeParameterJson[]; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v7_1_0.ts b/src/bin/lib/types/Tags/v7_1_0.ts index 74f6a875..dd717b7d 100644 --- a/src/bin/lib/types/Tags/v7_1_0.ts +++ b/src/bin/lib/types/Tags/v7_1_0.ts @@ -120,7 +120,7 @@ export namespace v7_1_0 { abstract: boolean; typeParameters: Misc.TypeParameterJson[]; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v7_2_0.ts b/src/bin/lib/types/Tags/v7_2_0.ts index 3a9b0af0..2b4bc364 100644 --- a/src/bin/lib/types/Tags/v7_2_0.ts +++ b/src/bin/lib/types/Tags/v7_2_0.ts @@ -121,7 +121,7 @@ export namespace v7_2_0 { abstract: boolean; typeParameters: Misc.TypeParameterJson[]; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v7_3_0.ts b/src/bin/lib/types/Tags/v7_3_0.ts index cc9e87a7..06c315f0 100644 --- a/src/bin/lib/types/Tags/v7_3_0.ts +++ b/src/bin/lib/types/Tags/v7_3_0.ts @@ -122,7 +122,7 @@ export namespace v7_3_0 { abstract: boolean; typeParameters: Misc.TypeParameterJson[]; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[]; diff --git a/src/bin/lib/types/Tags/v8_2_0.ts b/src/bin/lib/types/Tags/v8_2_0.ts index 7d50b1dd..c89083a7 100644 --- a/src/bin/lib/types/Tags/v8_2_0.ts +++ b/src/bin/lib/types/Tags/v8_2_0.ts @@ -122,7 +122,7 @@ export namespace v8_2_0 { abstract: boolean; typeParameters: Misc.TypeParameterJson[]; extendsType: TypeJson | null; - implementsTypes: TypeJson[]; + implementsType: TypeJson[]; construct: ClassJson.ConstructorJson; properties: ClassJson.PropertyJson[]; methods: ClassJson.MethodJson[];