Skip to content

Commit

Permalink
chore(individual-pkg-gen): fix bug in setting alpha package visibility (
Browse files Browse the repository at this point in the history
aws#16787)

The logic to remove the "private" marker for the alpha module `package.json`s
was backported to `master` without any change or an appropriate qualifier. This
leads to the alpha packages being set to public on `master`, which is not what
we want. Rather than introduce v1- and v2-specific logic here, I opted to look
at the current package's setting, and swap it. The logic is that if we're
publishing `aws-foobar`, we don't want to publish `aws-foobar-alpha`, and vice
versa.

Also fixed a bug where alpha'ed packages were being re-alpha'ed when transform
was run multiple times in local development.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
njlynch authored and TikiTDO committed Feb 21, 2022
1 parent b64faf2 commit bc625ae
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tools/@aws-cdk/individual-pkg-gen/transform-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,15 @@ function transformPackageJson(pkg: any, source: string, destination: string, alp
packageJson.name += '-alpha';
packageJson.repository.directory = `packages/individual-packages/${pkgUnscopedName}`;

// All individual packages are private by default on v2.
// This needs to be removed for the alpha modules to be published.
// However, we should only do this for packages we intend to publish (those with a `publishConfig`)
// All individual packages are public by default on v1, and private by default on v2.
// We need to flip these around, so we don't publish alphas on v1, but *do* on v2.
// We also should only do this for packages we intend to publish (those with a `publishConfig`)
if (packageJson.publishConfig) {
packageJson.private = undefined;
packageJson.private = !packageJson.private;
packageJson.publishConfig.tag = 'latest';
if (packageJson.private) {
packageJson.ubergen = { exclude: true };
}
}

// disable awslint (some rules are hard-coded to @aws-cdk/core)
Expand Down Expand Up @@ -278,7 +281,8 @@ function packageIsAlpha(pkg: any): boolean {
}
// we're only interested in '@aws-cdk/' packages,
// and those that are JSII-enabled (so no @aws-cdk/assert)
return pkg.name.startsWith('@aws-cdk/') && !!pkg.get('jsii');
// Also, don't re-transform already alpha-ed packages
return pkg.name.startsWith('@aws-cdk/') && !!pkg.get('jsii') && !pkg.name.endsWith('-alpha');
}

function isRequiredTool(name: string) {
Expand Down

0 comments on commit bc625ae

Please sign in to comment.