From 38f3b8992f58d26947bd8c7b5ec64b973ccc8586 Mon Sep 17 00:00:00 2001 From: Momo Kornher Date: Tue, 7 Nov 2023 11:46:03 +0000 Subject: [PATCH 1/3] chore(aws-cdk-lib): remove superfluous script (#27871) This checks was introduced when aws-cdk-lib was still a "virtual" package and created by combing different sources. Since this is not the case anymore, we can remove this script. Fixes failing build. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk-lib/package.json | 3 - .../scripts/verify-stripped-exp.ts | 157 ------------------ 2 files changed, 160 deletions(-) delete mode 100644 packages/aws-cdk-lib/scripts/verify-stripped-exp.ts diff --git a/packages/aws-cdk-lib/package.json b/packages/aws-cdk-lib/package.json index 98c623336f622..964417798a9b4 100644 --- a/packages/aws-cdk-lib/package.json +++ b/packages/aws-cdk-lib/package.json @@ -47,9 +47,6 @@ "cdk-package": { "pre": [ "/bin/bash ./scripts/minify-sources.sh" - ], - "post": [ - "ts-node ./scripts/verify-stripped-exp.ts" ] }, "pkglint": { diff --git a/packages/aws-cdk-lib/scripts/verify-stripped-exp.ts b/packages/aws-cdk-lib/scripts/verify-stripped-exp.ts deleted file mode 100644 index cba39a6b07bfd..0000000000000 --- a/packages/aws-cdk-lib/scripts/verify-stripped-exp.ts +++ /dev/null @@ -1,157 +0,0 @@ -// +------------------------------------------------------------------------------------------------ -// | this script is executed post packaging to verify that experimental modules in aws-cdk-lib includes **only** L1 autogenerated files. -// | The purpose is to avoid publishing L2 of experimental modules with aws-cdk-lib -// | -import { spawnSync } from 'child_process'; -import * as console from 'console'; -import * as os from 'os'; -import * as path from 'path'; -import * as fs from 'fs-extra'; - -async function main(tempDir: string) { - console.log('🧐 Verifying all experimental modules includes only L1s files...'); - const cwd = process.cwd(); - const awsCdkModulesRepoPath = path.join(findWorkspacePath(), 'packages', '@aws-cdk'); - // eslint-disable-next-line @typescript-eslint/no-require-imports - const version = require('./../package.json').version; - const tarFullPath = path.join(cwd, 'dist', 'js', `aws-cdk-lib@${version}.jsii.tgz`); - - const invalidCfnModules = new Map>(); - const invalidModules = new Array(); - - // install the tarball in a temp directory - console.log(`installing aws-cdk-lib from dist/js into ${tempDir}`); - exec('npm', ['install', '--prefix', tempDir, tarFullPath]); - const installedAwsCdkLibPath = path.join(tempDir, 'node_modules', 'aws-cdk-lib', 'lib'); - - for (const module of fs.readdirSync(awsCdkModulesRepoPath)) { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const pkgJson = require(path.join(awsCdkModulesRepoPath, module, 'package.json')); - if (pkgJson.stability !== 'experimental') { - continue; - } - if (pkgJson['cdk-build']?.cloudformation) { - // if a cfn module, verify only the allowed files exists - const files = await listAllFiles(path.join(installedAwsCdkLibPath, module)); - const invalidFiles = new Array(); - files.forEach(file => { - if (!isAllowedFile(file)) { - invalidFiles.push(file); - } - }); - if (invalidFiles.length > 0) { - invalidCfnModules.set(module, invalidFiles); - } - } else { - // not a cfn module, verify it was entirely removed - if (fs.existsSync(path.join(installedAwsCdkLibPath, module))) { - invalidModules.push(module); - } - } - } - - if (invalidCfnModules.size > 0 || invalidModules.length > 0) { - if (invalidCfnModules.size > 0 ) { - console.log('cfn module with invalid files:'); - for (let [module, files] of invalidCfnModules.entries()) { - console.log(`${module}:`); - files.forEach(file => console.log(`\t ${file}`)); - } - } - console.log('---------------------------------------------'); - if (invalidModules.length > 0) { - console.log('non-cfn experimental modules:'); - invalidModules.forEach(m => console.log(`\t ${m}`)); - } - throw new Error('Verification Error'); - } -} - -const tempDir = fs.mkdtempSync(os.tmpdir()); - -main(tempDir).then( - () => { - fs.removeSync(tempDir); - console.log('✅ All experimental modules includes only L1s files!'); - process.exit(0); - }, - (err) => { - process.stderr.write(`${err}\n`); - process.stderr.write(`❌ Verification failed, Some experimental modules includes non L1 files, see details above. Inspect working directory: '${tempDir}'`); - process.exit(1); - }, -); - -/** - * Spawn sync with error handling - */ -function exec(cmd: string, args: string[]) { - const proc = spawnSync(cmd, args); - - if (proc.error) { - throw proc.error; - } - - if (proc.status !== 0) { - if (proc.stdout || proc.stderr) { - throw new Error(`${cmd} exited with status ${proc.status}; stdout: ${proc.stdout?.toString().trim()}\n\n\nstderr: ${proc.stderr?.toString().trim()}`); - } - throw new Error(`${cmd} exited with status ${proc.status}`); - } - - return proc; -} - -const GENERATED_SUFFIX_REGEX = new RegExp(/generated\.(js|d\.ts)$/); -const ALLOWED_FILES = ['.jsiirc.json', 'index.ts', 'index.js', 'index.d.ts']; - -/** - * Recursively collect all files in dir - */ -async function listAllFiles(dir: string) { - const ret = new Array(); - - async function recurse(part: string) { - const files = await fs.readdir(part); - for (const file of files) { - const fullPath = path.join(part, file); - if ((await fs.stat(fullPath)).isDirectory()) { - await recurse(fullPath); - } else { - ret.push(file); - } - } - } - await recurse(dir); - return ret; -} - -/** - * Find the workspace root path. Walk up the directory tree until you find lerna.json - */ -function findWorkspacePath() { - - return _findRootPath(process.cwd()); - - function _findRootPath(part: string): string { - if (part === path.resolve(part, '..')) { - throw new Error('couldn\'t find a \'lerna.json\' file when walking up the directory tree, are you in a aws-cdk project?'); - } - - if (fs.existsSync(path.resolve(part, 'lerna.json'))) { - return part; - } - return _findRootPath(path.resolve(part, '..')); - } -} - -/** - * @param file - * @returns true if the file allowed in an L1 only modules, otherwise false - */ -function isAllowedFile(file: string) { - if (GENERATED_SUFFIX_REGEX.test(file)) { - return true; - } - return ALLOWED_FILES.includes(file); -} \ No newline at end of file From 782bac4a12ae8ed22bfb9038a87c22c01cb3ecfe Mon Sep 17 00:00:00 2001 From: Ana Carolina Lima Hamud Date: Tue, 7 Nov 2023 15:11:34 -0300 Subject: [PATCH 2/3] chore: fix broken link in README.md (#27877) The link for nodejs.org is broken. From: https://nodejs.org/en/about/releases ![image](https://github.com/aws/aws-cdk/assets/20182640/e450ef7d-cf2a-43fa-9708-fe94a6d631ab) To: https://nodejs.org/en/about/previous-releases ![image](https://github.com/aws/aws-cdk/assets/20182640/3f8a47ef-6fe1-4586-bdde-f9a0fe2a28ad) Please let me know if the [download](https://nodejs.org/en/download) page is a better fit for this... ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65ee406e54ad6..bfd2b0ffae78c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ infrastructure definition and share it without worrying about boilerplate logic. The CDK is available in the following languages: * JavaScript, TypeScript ([Node.js ≥ 14.15.0](https://nodejs.org/download/release/latest-v14.x/)) - * We recommend using a version in [Active LTS](https://nodejs.org/en/about/releases/) + * We recommend using a version in [Active LTS](https://nodejs.org/en/about/previous-releases) * Python ([Python ≥ 3.6](https://www.python.org/downloads/)) * Java ([Java ≥ 8](https://www.oracle.com/technetwork/java/javase/downloads/index.html) and [Maven ≥ 3.5.4](https://maven.apache.org/download.cgi)) * .NET ([.NET ≥ 6.0](https://dotnet.microsoft.com/download)) From 4bd3b057103d03c6844901c7c18601d62fa66a24 Mon Sep 17 00:00:00 2001 From: Parker Scanlon <69879391+scanlonp@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:13:19 -0800 Subject: [PATCH 3/3] chore: fix second broken link in README (#27879) Following up on https://github.com/aws/aws-cdk/pull/27877, we had a broken link in two places. This fixes the second. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bfd2b0ffae78c..d69b0f6571705 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ For a detailed walkthrough, see the [tutorial](https://docs.aws.amazon.com/cdk/l ### At a glance -Install or update the [AWS CDK CLI] from npm (requires [Node.js ≥ 14.15.0](https://nodejs.org/download/release/latest-v14.x/)). We recommend using a version in [Active LTS](https://nodejs.org/en/about/releases/) +Install or update the [AWS CDK CLI] from npm (requires [Node.js ≥ 14.15.0](https://nodejs.org/download/release/latest-v14.x/)). We recommend using a version in [Active LTS](https://nodejs.org/en/about/previous-releases) ```sh npm i -g aws-cdk