-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: record CLI version in manifest package (#184)
Record the current CLI version in the manifest package when we release the manifest. This by itself will not trigger a new release of the `cloud-assembly-schema` package, so the version only gets recorded (and published!) when there is a new version of `cloud-assembly-schema` to publish anyway, and the version will only be displayed back to the user if there is an incompatibility of the major version number. That means we won't necessarily show the *lowest* possible CLI version number when the user needs to upgrade, but we'll show a valid CLI version number that will definitely support the given manifest. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Signed-off-by: github-actions <[email protected]> Co-authored-by: github-actions <[email protected]>
- Loading branch information
Showing
7 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { promises as fs } from 'fs'; | ||
|
||
/** | ||
* Copy the version from the CLI into the `@aws-cdk/cloud-assembly-schema` package at release time. | ||
*/ | ||
async function main() { | ||
const cliVersion = JSON.parse(await fs.readFile(`${__dirname}/../packages/aws-cdk/package.json`, 'utf8')).version; | ||
|
||
const cliVersionFile = `${__dirname}/../packages/@aws-cdk/cloud-assembly-schema/cli-version.json`; | ||
|
||
// We write an empty string if we're in "development mode" to show that we don't really have a version. | ||
// It's not a missing field so that the `import` statement of that JSON file in TypeScript | ||
// always knows the version field is there, and its value is a string. | ||
const advertisedVersion = cliVersion !== '0.0.0' ? cliVersion : ''; | ||
|
||
await fs.writeFile(cliVersionFile, JSON.stringify({ version: advertisedVersion }), 'utf8'); | ||
} | ||
|
||
main().catch(e => { | ||
// this is effectively a mini-cli | ||
// eslint-disable-next-line no-console | ||
console.error(e); | ||
process.exitCode = 1; | ||
}); |