From 9c945637bdf1d9bcf84db46ec10679ab7170fbb0 Mon Sep 17 00:00:00 2001 From: Madeline Kusters <80541297+madeline-k@users.noreply.github.com> Date: Thu, 2 Sep 2021 12:45:58 -0700 Subject: [PATCH] chore(individual-pkg-gen): set the alpha version in alpha module's package.json files if present (#16322) This change sets the `version` key in each alpha module's `package.json` file to the alphaVersion that was created in this PR: https://github.com/aws/aws-cdk/pull/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* --- tools/individual-pkg-gen/copy-files-removing-deps.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/individual-pkg-gen/copy-files-removing-deps.ts b/tools/individual-pkg-gen/copy-files-removing-deps.ts index e7576621492c2..6244618870712 100644 --- a/tools/individual-pkg-gen/copy-files-removing-deps.ts +++ b/tools/individual-pkg-gen/copy-files-removing-deps.ts @@ -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'); transformPackages(); @@ -98,6 +100,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}`; // disable awslint (some rules are hard-coded to @aws-cdk/core) @@ -160,7 +165,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]; @@ -180,7 +185,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/')) { devDependencies[v1DevDependency] = packageJson.devDependencies[v1DevDependency]; }