Skip to content

Commit

Permalink
chore(individual-pkg-gen): set the alpha version in alpha module's pa…
Browse files Browse the repository at this point in the history
…ckage.json files if present (#16965)

This change was already approved and merged in: #16322. It somehow got removed from the `v2-main` branch since originally being merged. This PR is just a cherry-pick of the original commit. 

---

This change sets the `version` key in each alpha module's `package.json` file to the alphaVersion that was created in this PR: #16043

And, also sets the version of each dependency on another alpha module to the same version.

Depends on: #16321

Part of: #15591

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
madeline-k authored Oct 14, 2021
1 parent d5b5336 commit d5c4f9a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/@aws-cdk/individual-pkg-gen/transform-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as awsCdkMigration from 'aws-cdk-migration';
import * as fs from 'fs-extra';
// eslint-disable-next-line @typescript-eslint/no-require-imports
const lerna_project = require('@lerna/project');
// eslint-disable-next-line @typescript-eslint/no-require-imports
const ver = require('../../../scripts/resolve-version');

/**
* @aws-cdk/ scoped packages that may be present in devDependencies and need to
Expand Down Expand Up @@ -128,6 +130,9 @@ function transformPackageJson(pkg: any, source: string, destination: string, alp
const pkgUnscopedName = `${pkg.name.substring('@aws-cdk/'.length)}`;

packageJson.name += '-alpha';
if (ver.alphaVersion) {
packageJson.version = ver.alphaVersion;
}
packageJson.repository.directory = `packages/individual-packages/${pkgUnscopedName}`;

// All individual packages are public by default on v1, and private by default on v2.
Expand Down Expand Up @@ -201,7 +206,7 @@ function transformPackageJsonDependencies(packageJson: any, pkg: any, alphaPacka
break;
default:
if (alphaPackages[dependency]) {
alphaDependencies[alphaPackages[dependency]] = pkg.version;
alphaDependencies[alphaPackages[dependency]] = packageJson.version;
} else if (v1BundledDependencies.indexOf(dependency) !== -1) {
// ...other than third-party dependencies, which are in bundledDependencies
bundledDependencies[dependency] = packageJson.dependencies[dependency];
Expand All @@ -221,7 +226,7 @@ function transformPackageJsonDependencies(packageJson: any, pkg: any, alphaPacka
break;
default:
if (alphaPackages[v1DevDependency]) {
alphaDevDependencies[alphaPackages[v1DevDependency]] = pkg.version;
alphaDevDependencies[alphaPackages[v1DevDependency]] = packageJson.version;
} else if (!v1DevDependency.startsWith('@aws-cdk/') || isRequiredTool(v1DevDependency)) {
devDependencies[v1DevDependency] = packageJson.devDependencies[v1DevDependency];
}
Expand Down

0 comments on commit d5c4f9a

Please sign in to comment.