Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(resolve-version): export the alphaVersion #16321

Merged
merged 5 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion scripts/resolve-version-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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}`);
}
Expand Down Expand Up @@ -68,6 +69,7 @@ function resolveVersion(rootdir) {

return {
version: currentVersion,
alphaVersion: versions.alphaVersion,
versionFile,
changelogFile,
alphaChangelogFile,
Expand Down
39 changes: 39 additions & 0 deletions scripts/script-tests/resolve-version.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
});
Expand All @@ -33,6 +51,7 @@ happy({
marker: '0.0.0',
prerelease: 'alpha',
version: '2.1.0-alpha.0',
alphaVersion: undefined,
versionFile: 'version.v2.json'
}
});
Expand All @@ -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'
}
});
Expand All @@ -65,6 +102,7 @@ happy({
marker: '0.0.0',
prerelease: undefined,
version: '1.72.0',
alphaVersion: undefined,
versionFile: 'version.v1.json'
}
});
Expand All @@ -81,6 +119,7 @@ happy({
marker: '0.0.0',
prerelease: undefined,
version: '2.0.0-rc.0',
alphaVersion: undefined,
versionFile: 'version.v2.json'
}
});
Expand Down