forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cx-api): automatically determine new feature flag version (aws#…
…22838) With the new feature flags mechanism, you have to put the `v2` version a flag becomes available in when adding a flag. One problem: the code hasn't been released yet, so you don't know what version that will be. You can guess it's going to be the next release, but what if the review takes a long time, or a new release was juuuust started by the oncall? ---------------------- Solution: we force you to put in the magic version marker `'V2NEXT'`. We update the sorting mechanism to sort this always after all v2 versions and before any v3 versions, so it appears at the right place in the report. At release time, when the actual version number is determined and files are updated and committed back to the repository, we replace the magic marker with the actual version number and regenerate the flag report, so that the actual release version number is put in. These commits will find their way to the `main` branch when the mergeback commit is created at the end of the release pipeline. This requires inventing a new `cdk-release` protocol: scripts named `on-bump` will be called as part of creating a release, after the version has been bumped but before the new commit has been created. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
14 changed files
with
225 additions
and
39 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
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,28 @@ | ||
/** | ||
* Load the `features.ts` source file, and replace the "V2NEXT" version markers with the actual current version | ||
*/ | ||
import { promises as fs } from 'fs'; | ||
import * as path from 'path'; | ||
import { MAGIC_V2NEXT } from '../lib/private/flag-modeling'; | ||
|
||
async function main() { | ||
const featuresSourceFile = path.join(__dirname, '..', 'lib', 'features.ts'); | ||
|
||
let currentv2: string | undefined = JSON.parse(await fs.readFile(path.join(__dirname, '../../../../version.v2.json'), { encoding: 'utf-8' })).version; | ||
currentv2 = currentv2?.match(/^[0-9\.]+/)?.[0]; // Make sure to only retain the actual version number, not any '-rc.X' suffix | ||
|
||
if (!currentv2) { | ||
throw new Error('Could not determine current v2 version number'); | ||
} | ||
|
||
let source = await fs.readFile(featuresSourceFile, { encoding: 'utf-8' }); | ||
source = source.replace(new RegExp(MAGIC_V2NEXT, 'g'), currentv2); | ||
|
||
await fs.writeFile(featuresSourceFile, source, { encoding: 'utf-8' }); | ||
} | ||
|
||
main().catch(e => { | ||
// eslint-disable-next-line no-console | ||
console.error(e); | ||
process.exitCode = 1; | ||
}); |
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
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
Oops, something went wrong.