Skip to content

Commit

Permalink
chore(resolve-version): export the alphaVersion (aws#16321)
Browse files Browse the repository at this point in the history
This will be used by a change in `tools/individual-pkg-gen/copy-files-removing-deps.ts` on the `v2-main` branch, so that the `transform` step can correctly set the `version` key and the version for each dependency in each alpha module's `package.json` file.

See aws#16322 for usage. 

Part of aws#15591 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
madeline-k authored and david-doyle-as24 committed Sep 7, 2021
1 parent 05aca34 commit 4eb1378
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
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

0 comments on commit 4eb1378

Please sign in to comment.