From 5dff808a919d4ead350b56aadf60336ea6eda668 Mon Sep 17 00:00:00 2001 From: Madeline Kusters Date: Wed, 1 Sep 2021 07:23:20 -0700 Subject: [PATCH 1/5] chore(resolve-version): export the alphaVersion --- scripts/resolve-version-lib.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/resolve-version-lib.js b/scripts/resolve-version-lib.js index ec1f7b1b83822..69019b80616b8 100755 --- a/scripts/resolve-version-lib.js +++ b/scripts/resolve-version-lib.js @@ -68,6 +68,7 @@ function resolveVersion(rootdir) { return { version: currentVersion, + alphaVersion: require(versionFilePath).alphaVersion, versionFile, changelogFile, alphaChangelogFile, From 667496b0d3a2d17cf7dfa2223a5a2dcb4300465d Mon Sep 17 00:00:00 2001 From: Madeline Kusters Date: Wed, 1 Sep 2021 07:48:03 -0700 Subject: [PATCH 2/5] update and add unit tests --- scripts/script-tests/resolve-version.test.js | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/scripts/script-tests/resolve-version.test.js b/scripts/script-tests/resolve-version.test.js index 693e29234f023..1cabbb2acd795 100644 --- a/scripts/script-tests/resolve-version.test.js +++ b/scripts/script-tests/resolve-version.test.js @@ -17,6 +17,24 @@ happy({ marker: '0.0.0', prerelease: undefined, version: '2.1.0', + alphaVersion: undefined, + versionFile: 'version.v2.json' + } +}); + +happy({ + name: 'stable release with alpha modules', + inputs: { + 'release.json': { majorVersion: 2, releaseType: 'stable' }, + 'version.v2.json': { version: '2.1.0', alphaVersion: '2.1.0-alpha' }, + }, + expected: { + changelogFile: 'CHANGELOG.v2.md', + alphaChangelogFile: 'CHANGELOG.v2.alpha.md', + marker: '0.0.0', + prerelease: undefined, + version: '2.1.0', + alphaVersion: '2.1.0-alpha', versionFile: 'version.v2.json' } }); @@ -33,6 +51,7 @@ happy({ marker: '0.0.0', prerelease: 'alpha', version: '2.1.0-alpha.0', + alphaVersion: undefined, versionFile: 'version.v2.json' } }); @@ -49,6 +68,24 @@ happy({ marker: '0.0.0', prerelease: 'rc', version: '2.1.0-rc.0', + alphaVersion: undefined, + versionFile: 'version.v2.json' + } +}); + +happy({ + name: 'rc release with alpha modules', + inputs: { + 'release.json': { majorVersion: 2, releaseType: 'rc' }, + 'version.v2.json': { version: '2.0.0-rc.0', alphaVersion: '2.0.0-alpha.0' }, + }, + expected: { + changelogFile: 'CHANGELOG.v2.md', + alphaChangelogFile: 'CHANGELOG.v2.alpha.md', + marker: '0.0.0', + prerelease: 'rc', + version: '2.0.0-rc.0', + alphaVersion: '2.0.0-alpha.0', versionFile: 'version.v2.json' } }); @@ -65,6 +102,7 @@ happy({ marker: '0.0.0', prerelease: undefined, version: '1.72.0', + alphaVersion: undefined, versionFile: 'version.v1.json' } }); @@ -81,6 +119,7 @@ happy({ marker: '0.0.0', prerelease: undefined, version: '2.0.0-rc.0', + alphaVersion: undefined, versionFile: 'version.v2.json' } }); From 4890ff734e12094c40d49ac12551f9afa9d1c06c Mon Sep 17 00:00:00 2001 From: Madeline Kusters Date: Wed, 1 Sep 2021 08:32:49 -0700 Subject: [PATCH 3/5] refactor: only perform require(versionFilePath) once --- scripts/resolve-version-lib.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/resolve-version-lib.js b/scripts/resolve-version-lib.js index 69019b80616b8..188e733572a1c 100755 --- a/scripts/resolve-version-lib.js +++ b/scripts/resolve-version-lib.js @@ -36,8 +36,8 @@ function resolveVersion(rootdir) { // // validate that current version matches the requirements // - - const currentVersion = require(versionFilePath).version; + const versions = require(versionFilePath); + const currentVersion = versions.version; if (!currentVersion.startsWith(`${majorVersion}.`)) { throw new Error(`current version "${currentVersion}" does not use the expected major version ${majorVersion}`); } @@ -68,7 +68,7 @@ function resolveVersion(rootdir) { return { version: currentVersion, - alphaVersion: require(versionFilePath).alphaVersion, + alphaVersion: versions.alphaVersion, versionFile, changelogFile, alphaChangelogFile, From 3478447832440738c9c1b352f7f24d134cc14ef8 Mon Sep 17 00:00:00 2001 From: Madeline Kusters <80541297+madeline-k@users.noreply.github.com> Date: Wed, 1 Sep 2021 09:44:55 -0700 Subject: [PATCH 4/5] Update resolve-version-lib.js spacing --- scripts/resolve-version-lib.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/resolve-version-lib.js b/scripts/resolve-version-lib.js index 188e733572a1c..ba0381f300e5a 100755 --- a/scripts/resolve-version-lib.js +++ b/scripts/resolve-version-lib.js @@ -36,6 +36,7 @@ function resolveVersion(rootdir) { // // validate that current version matches the requirements // + const versions = require(versionFilePath); const currentVersion = versions.version; if (!currentVersion.startsWith(`${majorVersion}.`)) { From 96a76909c49f35cfd7437d3f9c35decfa9514a27 Mon Sep 17 00:00:00 2001 From: Madeline Kusters <80541297+madeline-k@users.noreply.github.com> Date: Wed, 1 Sep 2021 09:46:15 -0700 Subject: [PATCH 5/5] Update resolve-version-lib.js spacing --- scripts/resolve-version-lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/resolve-version-lib.js b/scripts/resolve-version-lib.js index ba0381f300e5a..5885d96b6afd9 100755 --- a/scripts/resolve-version-lib.js +++ b/scripts/resolve-version-lib.js @@ -36,7 +36,7 @@ function resolveVersion(rootdir) { // // validate that current version matches the requirements // - + const versions = require(versionFilePath); const currentVersion = versions.version; if (!currentVersion.startsWith(`${majorVersion}.`)) {