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: stripping stability banners for Cfn constructs on alpha modules #17327

Merged
merged 3 commits into from
Nov 4, 2021
Merged
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
22 changes: 22 additions & 0 deletions tools/@aws-cdk/individual-pkg-gen/transform-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ const lerna_project = require('@lerna/project');
// eslint-disable-next-line @typescript-eslint/no-require-imports
const ver = require('../../../scripts/resolve-version');

const CFN_STABILITY_BANNER = [
'![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)',
'',
'> All classes with the `Cfn` prefix in this module ([CFN Resources]) are always stable and safe to use.',
'>',
'> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib',
].join('\n');

const FEATURE_CFN_STABILITY_BANNER = `> **CFN Resources:** All classes with the \`Cfn\` prefix in this module ([CFN Resources]) are always
> stable and safe to use.
>
> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib`;

const FEATURE_CFN_STABILITY_LINE = /CFN Resources\s+\| !\[Stable]\(https:\/\/img\.shields\.io\/badge\/stable-success\.svg\?style=for-the-badge\)\n/gm;

/**
* @aws-cdk/ scoped packages that may be present in devDependencies and need to
* be retained (or else pkglint might declare the package unworthy).
Expand Down Expand Up @@ -109,6 +124,13 @@ function transformPackages(): void {
packageUnscopedName: `${pkg.name.substring('@aws-cdk/'.length)}`,
});
fs.outputFileSync(destination, sourceCodeOutput);
} else if (sourceFileName === 'README.md') {
// Remove the stability banner for Cfn constructs, since they don't exist in the alpha modules
let sourceCode = fs.readFileSync(source).toString();
[CFN_STABILITY_BANNER, FEATURE_CFN_STABILITY_BANNER, FEATURE_CFN_STABILITY_LINE].forEach(pattern => {
sourceCode = sourceCode.replace(pattern, '');
});
fs.outputFileSync(destination, sourceCode);
} else {
const stat = fs.statSync(source);
if (stat.isDirectory()) {
Expand Down