Skip to content

Commit

Permalink
chore: fix packages transform for stability stripping (#17388)
Browse files Browse the repository at this point in the history
In #17327, we stripped away the stability banner for `Cfn` resources from README's of alpha modules, since these modules don't actually contain L1 resources. 

Problem is that this stripping causes a bunch of `pkglint` violations on the `v2-main` branch, for example:

```console
@aws-cdk/aws-iot-alpha: In package package.json
--
972 | @aws-cdk/aws-iot-alpha: - [package-info/maturity] Missing stability banner for experimental in README.md file (fixable)
973 | @aws-cdk/aws-iot-alpha: Error: Some package.json files had errors
974 | @aws-cdk/aws-iot-alpha:     at main (/codebuild/output/src115445882/src/github.com/aws/aws-cdk/tools/@aws-cdk/pkglint/bin/pkglint.js:30:15)
975 | @aws-cdk/aws-iot-alpha:     at Object.<anonym
```

This PR fixes the transform and makes the necessary changes so that `pkglint` will be happy. 
Note that this was not detected during merge of #17327 into master since on master, these packages are transformed into private packages, and hence are not validated. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
iliapolo authored Nov 7, 2021
1 parent d869f51 commit d231b9e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tools/@aws-cdk/individual-pkg-gen/transform-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ 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 = [
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');
].join('\n')}\n\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`;
> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib\n\n<!-- -->\n\n`;

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

Expand Down Expand Up @@ -168,6 +168,16 @@ function transformPackageJson(pkg: any, source: string, destination: string, alp
}
}

// disable the 'cloudformation' directive since alpha modules don't contain L1 resources.
const cdkBuild = packageJson['cdk-build'];
if (cdkBuild) {
delete cdkBuild.cloudformation;
packageJson['cdk-build'] = cdkBuild;
}

// disable `cfn2ts` script since alpha modules don't contain L1 resources.
delete packageJson.scripts.cfn2ts;

// disable awslint (some rules are hard-coded to @aws-cdk/core)
packageJson.awslint = {
exclude: ['*:*'],
Expand Down

0 comments on commit d231b9e

Please sign in to comment.