Skip to content

Commit

Permalink
chore: stripping stability banners for Cfn constructs on alpha modules (
Browse files Browse the repository at this point in the history
#17327)

Alpha modules don't have Cfn constructs, so it doesn't make sense to have a stability banner for them on the README.

Fixes #17038.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
otaviomacedo authored Nov 4, 2021
1 parent a91cc05 commit bc00427
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit bc00427

Please sign in to comment.