diff --git a/scripts/extension-version.js b/scripts/extension-version.js index 76084ef1b7..dfac1e39ee 100644 --- a/scripts/extension-version.js +++ b/scripts/extension-version.js @@ -1,10 +1,13 @@ function nextExtensionVersion({ prismaVersion, extensionVersion }) { + const isBeta = prismaVersion.includes('beta') const derivedExtensionVersion = getDerivedExtensionVersion( stripPreReleaseText(prismaVersion), + isBeta, ) const derivedExistingExtensionVersion = getDerivedExtensionVersion( extensionVersion, + isBeta, ) if (derivedExtensionVersion === derivedExistingExtensionVersion) { @@ -18,13 +21,22 @@ function stripPreReleaseText(version) { return version.replace('-alpha', '').replace('-beta', '').replace('-dev', '') } -function getDerivedExtensionVersion(version) { +function getDerivedExtensionVersion(version, isBeta = false) { const tokens = version.split('.') + + // Because https://github.com/prisma/vscode/issues/121#issuecomment-623327393 + if (isBeta && tokens.length === 4) { + tokens[2] = 1 + } + if (isBeta && tokens.length === 3) { + tokens[1] = 1 + } + if (tokens.length === 4) { return tokens.slice(1).join('.') } if (tokens.length === 3) { - return version + return tokens.join('.') } throw new Error( `Version ${version} must have 3 or 4 tokens separated by "." character`, diff --git a/scripts/extension-version.test.js b/scripts/extension-version.test.js index 7fe76dd402..1f823e561b 100644 --- a/scripts/extension-version.test.js +++ b/scripts/extension-version.test.js @@ -9,7 +9,7 @@ describe('next extension version', () => { prismaVersion: '2.0.0-beta.3', extensionVersion: '0.0.35', }), - ).to.eq('0.0.3') + ).to.eq('0.1.3') }) it('it should work with stable channel and extension only push', () => { @@ -18,7 +18,7 @@ describe('next extension version', () => { prismaVersion: '2.0.0-beta.3', extensionVersion: '0.0.3', }), - ).to.eq('0.0.3.1') + ).to.eq('0.1.3.1') }) it('it should work with stable channel and new prisma version', () => { @@ -27,7 +27,7 @@ describe('next extension version', () => { prismaVersion: '2.0.0-beta.4', extensionVersion: '0.0.3', }), - ).to.eq('0.0.4') + ).to.eq('0.1.4') }) it('it should work with stable channel and new prisma version after an extension only publish', () => { @@ -36,7 +36,7 @@ describe('next extension version', () => { prismaVersion: '2.0.0-beta.4', extensionVersion: '0.0.3.1', }), - ).to.eq('0.0.4') + ).to.eq('0.1.4') }) it('it should work with unstable channel and current version to new version schema', () => {