@guardian/cdk 61.3.1 → 61.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,7 +81,7 @@ function createPackageJson(outputDirectory) {
81
81
  */
82
82
  ...(!isTest && { "@guardian/cdk": constants_1.LibraryInfo.VERSION }),
83
83
  "aws-cdk": constants_1.LibraryInfo.AWS_CDK_VERSION,
84
- "aws-cdk-lib": constants_1.LibraryInfo.AWS_CDK_VERSION,
84
+ "aws-cdk-lib": constants_1.LibraryInfo.AWS_CDK_LIB_VERSION,
85
85
  constructs: constants_1.LibraryInfo.CONSTRUCTS_VERSION,
86
86
  };
87
87
  const customDeps = {
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../src/bin/commands/new-project/utils/init.ts"],"names":[],"mappings":";;;AAAA,2BAAgG;AAChG,+BAA4B;AAC5B,qDAAsE;AAMtE,8BAA8B;AAC9B,MAAa,cAAc;IAWzB,YAAY,MAAkB;QAV9B,gBAAW,GAAG,GAAG,SAAS,cAAc,CAAC;QAWvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,cAAc;QACZ,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3C,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YACtC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YACjD,IAAA,cAAS,EAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAClC;QAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACrC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEzC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACtC,8DAA8D;QAC9D,IAAI,CA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AgB,CAAC;SACzF;KACF,CAAC;IACF,IAAA,kBAAa,EAAC,GAAG,eAAe,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, writeFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { getDevDependency, LibraryInfo } from \"../../../../constants\";\n\nexport interface InitConfig {\n outputDir: string;\n}\n\n// TODO: Add project name flag\nexport class ProjectBuilder {\n templateDir = `${__dirname}/../template`;\n config: InitConfig;\n\n static validateConfig = (config: InitConfig): void => {\n const path = config.outputDir;\n if (existsSync(path) && readdirSync(path).length > 0) {\n throw new Error(`Directory ${path} is not empty`);\n }\n };\n\n constructor(config: InitConfig) {\n this.config = config;\n }\n\n buildDirectory(): void {\n ProjectBuilder.validateConfig(this.config);\n\n if (!existsSync(this.config.outputDir)) {\n console.log(`Creating ${this.config.outputDir}`);\n mkdirSync(this.config.outputDir);\n }\n\n console.log(\"Creating package.json\");\n createPackageJson(this.config.outputDir);\n\n console.log(\"Copying template files\");\n // TODO: Replace any params in files with .template extensions\n this.copyFiles(this.templateDir, this.config.outputDir);\n\n console.log(\"Success!\");\n }\n\n copyFiles(sourcePath: string, targetPath: string): void {\n for (const file of readdirSync(sourcePath)) {\n const path = join(sourcePath, file);\n\n if (path.endsWith(\".ignore\")) {\n continue;\n } else if (lstatSync(path).isDirectory()) {\n const nestedTargetPath = join(targetPath, file);\n if (!existsSync(nestedTargetPath)) {\n mkdirSync(nestedTargetPath);\n }\n this.copyFiles(path, nestedTargetPath);\n } else if (path.endsWith(\".template\")) {\n copyFileSync(path, join(targetPath, file.replace(\".template\", \"\")));\n } else {\n copyFileSync(path, join(targetPath, file));\n }\n }\n }\n}\n\nexport const buildDirectory = (config: InitConfig): void => {\n const builder = new ProjectBuilder(config);\n builder.buildDirectory();\n};\n\nfunction createPackageJson(outputDirectory: string): void {\n const { NODE_ENV, CI } = process.env;\n const isTest = NODE_ENV?.toUpperCase() === \"TEST\" || CI?.toUpperCase() === \"TRUE\";\n\n const coreDeps: Record<string, string> = [\n \"@guardian/eslint-config-typescript\",\n \"@guardian/tsconfig\",\n \"@types/jest\",\n \"@types/node\",\n \"eslint\",\n \"jest\",\n \"prettier\",\n \"ts-jest\",\n \"ts-node\",\n \"typescript\",\n ].reduce((acc, depName) => ({ ...acc, [depName]: getDevDependency(depName)! }), {});\n\n const cdkDeps: Record<string, string> = {\n /*\n Do not add `@guardian/cdk` to the generated `package.json` file when in TEST as we'll `npm link` it instead.\n See https://docs.npmjs.com/cli/v8/commands/npm-link#caveat\n\n TODO remove this once the `new` command allows opting out of automatic dependency installation\n */\n ...(!isTest && { \"@guardian/cdk\": LibraryInfo.VERSION }),\n\n \"aws-cdk\": LibraryInfo.AWS_CDK_VERSION,\n \"aws-cdk-lib\": LibraryInfo.AWS_CDK_VERSION,\n constructs: LibraryInfo.CONSTRUCTS_VERSION,\n };\n\n const customDeps = {\n \"source-map-support\": \"^0.5.20\",\n \"@guardian/prettier\": \"5.0.0\",\n };\n\n const allDeps: Record<string, string> = { ...coreDeps, ...cdkDeps, ...customDeps };\n\n const devDependencies: Record<string, string> = Object.keys(allDeps)\n .sort()\n .reduce((acc, depName) => ({ ...acc, [depName]: allDeps[depName] }), {});\n\n const contents = {\n name: \"cdk\",\n version: \"0.0.0\",\n private: true,\n scripts: {\n build: \"tsc\",\n test: \"jest\",\n \"test-update\": \"jest -u\",\n format: 'prettier --write \"{lib,bin}/**/*.ts\"',\n lint: \"eslint lib/** bin/** --ext .ts --no-error-on-unmatched-pattern\",\n synth: \"cdk synth --path-metadata false --version-reporting false\",\n diff: \"cdk diff --path-metadata false --version-reporting false\",\n },\n devDependencies,\n\n prettier: \"@guardian/prettier\",\n\n jest: {\n testMatch: [\"<rootDir>/lib/**/*.test.ts\"],\n transform: {\n \"^.+\\\\.tsx?$\": \"ts-jest\",\n },\n setupFilesAfterEnv: [\"./jest.setup.js\"],\n },\n\n eslintConfig: {\n root: true,\n env: {\n node: true,\n jest: true,\n },\n extends: [\"@guardian/eslint-config-typescript\"],\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: \"module\",\n },\n plugins: [\"@typescript-eslint\"],\n rules: {\n \"@typescript-eslint/no-inferrable-types\": 0,\n \"import/no-namespace\": 2,\n },\n ignorePatterns: [\"**/*.js\", \"node_modules\", \"cdk.out\", \".eslintrc.js\", \"jest.config.js\"],\n },\n };\n writeFileSync(`${outputDirectory}/package.json`, JSON.stringify(contents, null, 2));\n}\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../src/bin/commands/new-project/utils/init.ts"],"names":[],"mappings":";;;AAAA,2BAAgG;AAChG,+BAA4B;AAC5B,qDAAsE;AAMtE,8BAA8B;AAC9B,MAAa,cAAc;IAWzB,YAAY,MAAkB;QAV9B,gBAAW,GAAG,GAAG,SAAS,cAAc,CAAC;QAWvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,cAAc;QACZ,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3C,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YACtC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YACjD,IAAA,cAAS,EAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAClC;QAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACrC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEzC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACtC,8DAA8D;QAC9D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,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E,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, writeFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { getDevDependency, LibraryInfo } from \"../../../../constants\";\n\nexport interface InitConfig {\n outputDir: string;\n}\n\n// TODO: Add project name flag\nexport class ProjectBuilder {\n templateDir = `${__dirname}/../template`;\n config: InitConfig;\n\n static validateConfig = (config: InitConfig): void => {\n const path = config.outputDir;\n if (existsSync(path) && readdirSync(path).length > 0) {\n throw new Error(`Directory ${path} is not empty`);\n }\n };\n\n constructor(config: InitConfig) {\n this.config = config;\n }\n\n buildDirectory(): void {\n ProjectBuilder.validateConfig(this.config);\n\n if (!existsSync(this.config.outputDir)) {\n console.log(`Creating ${this.config.outputDir}`);\n mkdirSync(this.config.outputDir);\n }\n\n console.log(\"Creating package.json\");\n createPackageJson(this.config.outputDir);\n\n console.log(\"Copying template files\");\n // TODO: Replace any params in files with .template extensions\n this.copyFiles(this.templateDir, this.config.outputDir);\n\n console.log(\"Success!\");\n }\n\n copyFiles(sourcePath: string, targetPath: string): void {\n for (const file of readdirSync(sourcePath)) {\n const path = join(sourcePath, file);\n\n if (path.endsWith(\".ignore\")) {\n continue;\n } else if (lstatSync(path).isDirectory()) {\n const nestedTargetPath = join(targetPath, file);\n if (!existsSync(nestedTargetPath)) {\n mkdirSync(nestedTargetPath);\n }\n this.copyFiles(path, nestedTargetPath);\n } else if (path.endsWith(\".template\")) {\n copyFileSync(path, join(targetPath, file.replace(\".template\", \"\")));\n } else {\n copyFileSync(path, join(targetPath, file));\n }\n }\n }\n}\n\nexport const buildDirectory = (config: InitConfig): void => {\n const builder = new ProjectBuilder(config);\n builder.buildDirectory();\n};\n\nfunction createPackageJson(outputDirectory: string): void {\n const { NODE_ENV, CI } = process.env;\n const isTest = NODE_ENV?.toUpperCase() === \"TEST\" || CI?.toUpperCase() === \"TRUE\";\n\n const coreDeps: Record<string, string> = [\n \"@guardian/eslint-config-typescript\",\n \"@guardian/tsconfig\",\n \"@types/jest\",\n \"@types/node\",\n \"eslint\",\n \"jest\",\n \"prettier\",\n \"ts-jest\",\n \"ts-node\",\n \"typescript\",\n ].reduce((acc, depName) => ({ ...acc, [depName]: getDevDependency(depName)! }), {});\n\n const cdkDeps: Record<string, string> = {\n /*\n Do not add `@guardian/cdk` to the generated `package.json` file when in TEST as we'll `npm link` it instead.\n See https://docs.npmjs.com/cli/v8/commands/npm-link#caveat\n\n TODO remove this once the `new` command allows opting out of automatic dependency installation\n */\n ...(!isTest && { \"@guardian/cdk\": LibraryInfo.VERSION }),\n\n \"aws-cdk\": LibraryInfo.AWS_CDK_VERSION,\n \"aws-cdk-lib\": LibraryInfo.AWS_CDK_LIB_VERSION,\n constructs: LibraryInfo.CONSTRUCTS_VERSION,\n };\n\n const customDeps = {\n \"source-map-support\": \"^0.5.20\",\n \"@guardian/prettier\": \"5.0.0\",\n };\n\n const allDeps: Record<string, string> = { ...coreDeps, ...cdkDeps, ...customDeps };\n\n const devDependencies: Record<string, string> = Object.keys(allDeps)\n .sort()\n .reduce((acc, depName) => ({ ...acc, [depName]: allDeps[depName] }), {});\n\n const contents = {\n name: \"cdk\",\n version: \"0.0.0\",\n private: true,\n scripts: {\n build: \"tsc\",\n test: \"jest\",\n \"test-update\": \"jest -u\",\n format: 'prettier --write \"{lib,bin}/**/*.ts\"',\n lint: \"eslint lib/** bin/** --ext .ts --no-error-on-unmatched-pattern\",\n synth: \"cdk synth --path-metadata false --version-reporting false\",\n diff: \"cdk diff --path-metadata false --version-reporting false\",\n },\n devDependencies,\n\n prettier: \"@guardian/prettier\",\n\n jest: {\n testMatch: [\"<rootDir>/lib/**/*.test.ts\"],\n transform: {\n \"^.+\\\\.tsx?$\": \"ts-jest\",\n },\n setupFilesAfterEnv: [\"./jest.setup.js\"],\n },\n\n eslintConfig: {\n root: true,\n env: {\n node: true,\n jest: true,\n },\n extends: [\"@guardian/eslint-config-typescript\"],\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: \"module\",\n },\n plugins: [\"@typescript-eslint\"],\n rules: {\n \"@typescript-eslint/no-inferrable-types\": 0,\n \"import/no-namespace\": 2,\n },\n ignorePatterns: [\"**/*.js\", \"node_modules\", \"cdk.out\", \".eslintrc.js\", \"jest.config.js\"],\n },\n };\n writeFileSync(`${outputDirectory}/package.json`, JSON.stringify(contents, null, 2));\n}\n"]}
package/lib/bin/index.js CHANGED
@@ -63,7 +63,7 @@ const parseCommandLineArguments = () => {
63
63
  choices: ["npm", "yarn"],
64
64
  demandOption: true,
65
65
  }))
66
- .version(`${constants_1.LibraryInfo.VERSION} (using aws-cdk-lib ${constants_1.LibraryInfo.AWS_CDK_VERSION}, constructs ${constants_1.LibraryInfo.CONSTRUCTS_VERSION})`)
66
+ .version(`${constants_1.LibraryInfo.VERSION} (using aws-cdk ${constants_1.LibraryInfo.AWS_CDK_VERSION}, aws-cdk-lib ${constants_1.LibraryInfo.AWS_CDK_LIB_VERSION}, constructs ${constants_1.LibraryInfo.CONSTRUCTS_VERSION})`)
67
67
  .demandCommand(1, "") // just print help
68
68
  .help()
69
69
  .alias("h", "help").argv);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":";;;;;;AAEA,kDAA0B;AAC1B,4CAA2C;AAE3C,uEAAuE;AACvE,oEAAuE;AACvE,gEAAkE;AAElE,wDAAuD;AAEvD,MAAM,QAAQ,GAAG;IACf,aAAa,EAAE,iBAAiB;IAChC,gBAAgB,EAAE,mBAAmB;IACrC,GAAG,EAAE,KAAK;CACX,CAAC;AAEF,MAAM,yBAAyB,GAAG,GAAG,EAAE;IACrC;;;;;OAKG;IACH,OAAO,OAAO,CAAC,OAAO,CACpB,eAAK;SACF,KAAK,CAAC,mBAAmB,CAAC;SAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa,EAAE,mDAAmD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AAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;YAEjD,OAAO,IAAA,2BAAa,EAAC;gBACnB,IAAI;gBACJ,GAAG;gBACH,KAAK;gBACL,oBAAoB;gBACpB,MAAM;gBACN,OAAO;gBACP,cAAc,EAAE,cAAgC;aACjD,CAAC,CAAC;SACJ;QACD;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC;KACxD;AACH,CAAC,CAAC;KACD,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE;IACxB,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE;QACvC,OAAO,CAAC,QAAQ,GAAG,eAAe,CAAC;KACpC;SAAM,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE;QAC9C,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC9B;SAAM;QACL,MAAM,uBAAuB,GAAG,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,uBAAW,CAAC,OAAO,EAAE,EAAE,GAAG,eAAe,EAAE,CAAC;QAC1G,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC,CAAC;KACtD;AACH,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport yargs from \"yargs\";\nimport { LibraryInfo } from \"../constants\";\nimport type { CliCommandResponse } from \"../types/cli\";\nimport { awsCredentialProviderChain } from \"./aws-credential-provider\";\nimport { accountReadinessCommand } from \"./commands/account-readiness\";\nimport { awsCdkVersionCommand } from \"./commands/aws-cdk-version\";\nimport type { PackageManager } from \"./commands/new-project\";\nimport { newCdkProject } from \"./commands/new-project\";\n\nconst Commands = {\n AwsCdkVersion: \"aws-cdk-version\",\n AccountReadiness: \"account-readiness\",\n New: \"new\",\n};\n\nconst parseCommandLineArguments = () => {\n /*\n The type of `yargs.argv` is `T | Promise<T>`.\n To avoid creating custom type guards, use `Promise.resolve` which takes `T | PromiseLike<T>` and returns `Promise<T>`.\n That is, use `Promise.resolve` to provide a single type.\n See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7b2f0d45985538a40df96244481bfc6cd309c250/types/yargs/index.d.ts#L74\n */\n return Promise.resolve(\n yargs\n .usage(\"$0 COMMAND [args]\")\n .command(Commands.AwsCdkVersion, \"Print the version of AWS CDK libraries being used\")\n .command(Commands.AccountReadiness, \"Perform checks on an AWS account to see if it is GuCDK ready\", (yargs) =>\n yargs\n .option(\"profile\", { type: \"string\", description: \"AWS profile\" })\n .option(\"region\", { type: \"string\", description: \"AWS region\", default: \"eu-west-1\" }),\n )\n .command(\n Commands.New,\n \"Creates a new CDK project within a `cdk` directory at the root of the repository\",\n (yargs) =>\n yargs\n .option(\"init\", {\n type: \"boolean\",\n description: \"Create the cdk directory before building the app and stack files (defaults to true)\",\n default: true,\n })\n .option(\"app\", {\n type: \"string\",\n description: \"The name of your application e.g. Amigo\",\n demandOption: true,\n })\n .option(\"stack\", {\n type: \"string\",\n description:\n \"The Guardian stack being used (as defined in your riff-raff.yaml). This will be applied as a tag to all of your resources.\",\n demandOption: true,\n })\n .option(\"yaml-template-location\", {\n type: \"string\",\n description: \"Path to the YAML CloudFormation template\",\n })\n .option(\"stage\", {\n description:\n \"The stage(s) for your stack. Can be specified multiple times, e.g. --stage CODE --stage PROD\",\n type: \"array\",\n demandOption: true,\n })\n .option(\"region\", {\n description:\n \"The region(s) for your stack. Can be specified multiple times, e.g. --region eu-west-1 --region us-east-1\",\n type: \"array\",\n default: [\"eu-west-1\"],\n })\n .option(\"package-manager\", {\n description:\n \"The Node package manager to use. Match this to the repository (package-lock.json = npm, yarn.lock = yarn). If the repository has neither file, and there is no strong convention in your team, we recommend npm.\",\n choices: [\"npm\", \"yarn\"],\n demandOption: true,\n }),\n )\n .version(\n `${LibraryInfo.VERSION} (using aws-cdk-lib ${LibraryInfo.AWS_CDK_VERSION}, constructs ${LibraryInfo.CONSTRUCTS_VERSION})`,\n )\n .demandCommand(1, \"\") // just print help\n .help()\n .alias(\"h\", \"help\").argv,\n );\n};\n\nparseCommandLineArguments()\n .then((argv): CliCommandResponse => {\n const command = argv._[0];\n switch (command) {\n case Commands.AwsCdkVersion: {\n return awsCdkVersionCommand();\n }\n case Commands.AccountReadiness: {\n // TODO remove casting as yargs should be able to infer the type of the options\n const profile = argv.profile as string;\n const region = argv.region as string;\n return accountReadinessCommand({ credentialProvider: awsCredentialProviderChain(profile), region: region });\n }\n case Commands.New: {\n // TODO remove casting as yargs should be able to infer the type of the options\n const init = argv.init as boolean;\n const app = argv.app as string;\n const stack = argv.stack as string;\n const yamlTemplateLocation = argv[\"yaml-template-location\"] as string | undefined;\n const stage = argv.stage as string[];\n const regions = argv.region as string[];\n const packageManager = argv[\"package-manager\"] as string;\n\n const stages = stage.map((_) => _.toUpperCase());\n\n return newCdkProject({\n init,\n app,\n stack,\n yamlTemplateLocation,\n stages,\n regions,\n packageManager: packageManager as PackageManager,\n });\n }\n default:\n throw new Error(`Unknown command: ${command ?? \"\"}`);\n }\n })\n .then((commandResponse) => {\n if (typeof commandResponse === \"number\") {\n process.exitCode = commandResponse;\n } else if (typeof commandResponse === \"string\") {\n console.log(commandResponse);\n } else {\n const responseWithVersionInfo = { \"@guardian/cdk\": { version: LibraryInfo.VERSION }, ...commandResponse };\n console.log(JSON.stringify(responseWithVersionInfo));\n }\n })\n .catch((err) => {\n console.error(err);\n process.exitCode = 1;\n });\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":";;;;;;AAEA,kDAA0B;AAC1B,4CAA2C;AAE3C,uEAAuE;AACvE,oEAAuE;AACv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AC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport yargs from \"yargs\";\nimport { LibraryInfo } from \"../constants\";\nimport type { CliCommandResponse } from \"../types/cli\";\nimport { awsCredentialProviderChain } from \"./aws-credential-provider\";\nimport { accountReadinessCommand } from \"./commands/account-readiness\";\nimport { awsCdkVersionCommand } from \"./commands/aws-cdk-version\";\nimport type { PackageManager } from \"./commands/new-project\";\nimport { newCdkProject } from \"./commands/new-project\";\n\nconst Commands = {\n AwsCdkVersion: \"aws-cdk-version\",\n AccountReadiness: \"account-readiness\",\n New: \"new\",\n};\n\nconst parseCommandLineArguments = () => {\n /*\n The type of `yargs.argv` is `T | Promise<T>`.\n To avoid creating custom type guards, use `Promise.resolve` which takes `T | PromiseLike<T>` and returns `Promise<T>`.\n That is, use `Promise.resolve` to provide a single type.\n See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7b2f0d45985538a40df96244481bfc6cd309c250/types/yargs/index.d.ts#L74\n */\n return Promise.resolve(\n yargs\n .usage(\"$0 COMMAND [args]\")\n .command(Commands.AwsCdkVersion, \"Print the version of AWS CDK libraries being used\")\n .command(Commands.AccountReadiness, \"Perform checks on an AWS account to see if it is GuCDK ready\", (yargs) =>\n yargs\n .option(\"profile\", { type: \"string\", description: \"AWS profile\" })\n .option(\"region\", { type: \"string\", description: \"AWS region\", default: \"eu-west-1\" }),\n )\n .command(\n Commands.New,\n \"Creates a new CDK project within a `cdk` directory at the root of the repository\",\n (yargs) =>\n yargs\n .option(\"init\", {\n type: \"boolean\",\n description: \"Create the cdk directory before building the app and stack files (defaults to true)\",\n default: true,\n })\n .option(\"app\", {\n type: \"string\",\n description: \"The name of your application e.g. Amigo\",\n demandOption: true,\n })\n .option(\"stack\", {\n type: \"string\",\n description:\n \"The Guardian stack being used (as defined in your riff-raff.yaml). This will be applied as a tag to all of your resources.\",\n demandOption: true,\n })\n .option(\"yaml-template-location\", {\n type: \"string\",\n description: \"Path to the YAML CloudFormation template\",\n })\n .option(\"stage\", {\n description:\n \"The stage(s) for your stack. Can be specified multiple times, e.g. --stage CODE --stage PROD\",\n type: \"array\",\n demandOption: true,\n })\n .option(\"region\", {\n description:\n \"The region(s) for your stack. Can be specified multiple times, e.g. --region eu-west-1 --region us-east-1\",\n type: \"array\",\n default: [\"eu-west-1\"],\n })\n .option(\"package-manager\", {\n description:\n \"The Node package manager to use. Match this to the repository (package-lock.json = npm, yarn.lock = yarn). If the repository has neither file, and there is no strong convention in your team, we recommend npm.\",\n choices: [\"npm\", \"yarn\"],\n demandOption: true,\n }),\n )\n .version(\n `${LibraryInfo.VERSION} (using aws-cdk ${LibraryInfo.AWS_CDK_VERSION}, aws-cdk-lib ${LibraryInfo.AWS_CDK_LIB_VERSION}, constructs ${LibraryInfo.CONSTRUCTS_VERSION})`,\n )\n .demandCommand(1, \"\") // just print help\n .help()\n .alias(\"h\", \"help\").argv,\n );\n};\n\nparseCommandLineArguments()\n .then((argv): CliCommandResponse => {\n const command = argv._[0];\n switch (command) {\n case Commands.AwsCdkVersion: {\n return awsCdkVersionCommand();\n }\n case Commands.AccountReadiness: {\n // TODO remove casting as yargs should be able to infer the type of the options\n const profile = argv.profile as string;\n const region = argv.region as string;\n return accountReadinessCommand({ credentialProvider: awsCredentialProviderChain(profile), region: region });\n }\n case Commands.New: {\n // TODO remove casting as yargs should be able to infer the type of the options\n const init = argv.init as boolean;\n const app = argv.app as string;\n const stack = argv.stack as string;\n const yamlTemplateLocation = argv[\"yaml-template-location\"] as string | undefined;\n const stage = argv.stage as string[];\n const regions = argv.region as string[];\n const packageManager = argv[\"package-manager\"] as string;\n\n const stages = stage.map((_) => _.toUpperCase());\n\n return newCdkProject({\n init,\n app,\n stack,\n yamlTemplateLocation,\n stages,\n regions,\n packageManager: packageManager as PackageManager,\n });\n }\n default:\n throw new Error(`Unknown command: ${command ?? \"\"}`);\n }\n })\n .then((commandResponse) => {\n if (typeof commandResponse === \"number\") {\n process.exitCode = commandResponse;\n } else if (typeof commandResponse === \"string\") {\n console.log(commandResponse);\n } else {\n const responseWithVersionInfo = { \"@guardian/cdk\": { version: LibraryInfo.VERSION }, ...commandResponse };\n console.log(JSON.stringify(responseWithVersionInfo));\n }\n })\n .catch((err) => {\n console.error(err);\n process.exitCode = 1;\n });\n"]}
@@ -10,10 +10,15 @@ export declare const LibraryInfo: {
10
10
  */
11
11
  VERSION: string;
12
12
  /**
13
- * The version of the `aws-cdk-lib` library used by `@guardian/cdk`.
13
+ * The version of the `aws-cdk` library used by `@guardian/cdk`.
14
14
  * You need to match this version exactly.
15
15
  */
16
16
  AWS_CDK_VERSION: string;
17
+ /**
18
+ * The version of the `aws-cdk-lib` library used by `@guardian/cdk`.
19
+ * You need to match this version exactly.
20
+ */
21
+ AWS_CDK_LIB_VERSION: string;
17
22
  /**
18
23
  * The version of the `constructs` library used by `@guardian/cdk`.
19
24
  * You need to match this version exactly.
@@ -1 +1 @@
1
- {"version":3,"file":"library-info.d.ts","sourceRoot":"","sources":["../../src/constants/library-info.ts"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGrE;AAED,eAAO,MAAM,WAAW;IACtB;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;CAEJ,CAAC"}
1
+ {"version":3,"file":"library-info.d.ts","sourceRoot":"","sources":["../../src/constants/library-info.ts"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGrE;AAED,eAAO,MAAM,WAAW;IACtB;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;CAEJ,CAAC"}
@@ -27,11 +27,16 @@ exports.LibraryInfo = {
27
27
  * The current version of `@guardian/cdk`.
28
28
  */
29
29
  VERSION: version,
30
+ /**
31
+ * The version of the `aws-cdk` library used by `@guardian/cdk`.
32
+ * You need to match this version exactly.
33
+ */
34
+ AWS_CDK_VERSION: valueOrUnknown(getDevDependency("aws-cdk")),
30
35
  /**
31
36
  * The version of the `aws-cdk-lib` library used by `@guardian/cdk`.
32
37
  * You need to match this version exactly.
33
38
  */
34
- AWS_CDK_VERSION: valueOrUnknown(getDevDependency("aws-cdk-lib")),
39
+ AWS_CDK_LIB_VERSION: valueOrUnknown(getDevDependency("aws-cdk-lib")),
35
40
  /**
36
41
  * The version of the `constructs` library used by `@guardian/cdk`.
37
42
  * You need to match this version exactly.
@@ -1 +1 @@
1
- {"version":3,"file":"library-info.js","sourceRoot":"","sources":["../../src/constants/library-info.ts"],"names":[],"mappings":";;;;;;AACA,8DAAoC;AAEpC,MAAM,cAAc,GAAG,CAAC,KAAyB,EAAE,EAAE,CAAC,KAAK,IAAI,SAAS,CAAC;AAEzE,MAAM,WAAW,GAAwC,qBAAS,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,IAAI,EAAE,CAAC;AAE/G,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAEpD,SAAgB,gBAAgB,CAAC,WAAmB;IAClD,MAAM,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,WAAW,CAAC;IAC7C,OAAO,eAAe,CAAC,WAAW,CAAC,CAAC;AACtC,CAAC;AAHD,4CAGC;AAED,SAAgB,aAAa,CAAC,WAAmB;IAC/C,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,WAAW,CAAC;IAC1C,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC;AAHD,sCAGC;AAEY,QAAA,WAAW,GAAG;IACzB;;OAEG;IACH,IAAI,EAAE,eAAe;IAErB;;OAEG;IACH,OAAO,EAAE,OAAO;IAEhB;;;OAGG;IACH,eAAe,EAAE,cAAc,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAEhE;;;OAGG;IACH,kBAAkB,EAAE,cAAc,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACnE,CAAC","sourcesContent":["import type { NormalizedPackageJson, PackageJson } from \"read-pkg-up\";\nimport readPkgUp from \"read-pkg-up\";\n\nconst valueOrUnknown = (value: string | undefined) => value ?? \"unknown\";\n\nconst packageJson: PackageJson | NormalizedPackageJson = readPkgUp.sync({ cwd: __dirname })?.packageJson ?? {};\n\nconst version = valueOrUnknown(packageJson.version);\n\nexport function getDevDependency(packageName: string): string | undefined {\n const { devDependencies = {} } = packageJson;\n return devDependencies[packageName];\n}\n\nexport function getDependency(packageName: string): string | undefined {\n const { dependencies = {} } = packageJson;\n return dependencies[packageName];\n}\n\nexport const LibraryInfo = {\n /**\n * The name of this package\n */\n NAME: \"@guardian/cdk\",\n\n /**\n * The current version of `@guardian/cdk`.\n */\n VERSION: version,\n\n /**\n * The version of the `aws-cdk-lib` library used by `@guardian/cdk`.\n * You need to match this version exactly.\n */\n AWS_CDK_VERSION: valueOrUnknown(getDevDependency(\"aws-cdk-lib\")),\n\n /**\n * The version of the `constructs` library used by `@guardian/cdk`.\n * You need to match this version exactly.\n */\n CONSTRUCTS_VERSION: valueOrUnknown(getDevDependency(\"constructs\")),\n};\n"]}
1
+ {"version":3,"file":"library-info.js","sourceRoot":"","sources":["../../src/constants/library-info.ts"],"names":[],"mappings":";;;;;;AACA,8DAAoC;AAEpC,MAAM,cAAc,GAAG,CAAC,KAAyB,EAAE,EAAE,CAAC,KAAK,IAAI,SAAS,CAAC;AAEzE,MAAM,WAAW,GAAwC,qBAAS,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,IAAI,EAAE,CAAC;AAE/G,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAEpD,SAAgB,gBAAgB,CAAC,WAAmB;IAClD,MAAM,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,WAAW,CAAC;IAC7C,OAAO,eAAe,CAAC,WAAW,CAAC,CAAC;AACtC,CAAC;AAHD,4CAGC;AAED,SAAgB,aAAa,CAAC,WAAmB;IAC/C,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,WAAW,CAAC;IAC1C,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC;AAHD,sCAGC;AAEY,QAAA,WAAW,GAAG;IACzB;;OAEG;IACH,IAAI,EAAE,eAAe;IAErB;;OAEG;IACH,OAAO,EAAE,OAAO;IAEhB;;;OAGG;IACH,eAAe,EAAE,cAAc,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAE5D;;;OAGG;IACH,mBAAmB,EAAE,cAAc,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAEpE;;;OAGG;IACH,kBAAkB,EAAE,cAAc,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACnE,CAAC","sourcesContent":["import type { NormalizedPackageJson, PackageJson } from \"read-pkg-up\";\nimport readPkgUp from \"read-pkg-up\";\n\nconst valueOrUnknown = (value: string | undefined) => value ?? \"unknown\";\n\nconst packageJson: PackageJson | NormalizedPackageJson = readPkgUp.sync({ cwd: __dirname })?.packageJson ?? {};\n\nconst version = valueOrUnknown(packageJson.version);\n\nexport function getDevDependency(packageName: string): string | undefined {\n const { devDependencies = {} } = packageJson;\n return devDependencies[packageName];\n}\n\nexport function getDependency(packageName: string): string | undefined {\n const { dependencies = {} } = packageJson;\n return dependencies[packageName];\n}\n\nexport const LibraryInfo = {\n /**\n * The name of this package\n */\n NAME: \"@guardian/cdk\",\n\n /**\n * The current version of `@guardian/cdk`.\n */\n VERSION: version,\n\n /**\n * The version of the `aws-cdk` library used by `@guardian/cdk`.\n * You need to match this version exactly.\n */\n AWS_CDK_VERSION: valueOrUnknown(getDevDependency(\"aws-cdk\")),\n\n /**\n * The version of the `aws-cdk-lib` library used by `@guardian/cdk`.\n * You need to match this version exactly.\n */\n AWS_CDK_LIB_VERSION: valueOrUnknown(getDevDependency(\"aws-cdk-lib\")),\n\n /**\n * The version of the `constructs` library used by `@guardian/cdk`.\n * You need to match this version exactly.\n */\n CONSTRUCTS_VERSION: valueOrUnknown(getDevDependency(\"constructs\")),\n};\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@guardian/cdk",
3
3
  "description": "Generic Guardian flavoured AWS CDK components",
4
- "version": "61.3.1",
4
+ "version": "61.3.3",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "files": [
@@ -38,27 +38,27 @@
38
38
  "@types/lodash.camelcase": "^4.3.9",
39
39
  "@types/lodash.kebabcase": "^4.1.9",
40
40
  "@types/lodash.upperfirst": "^4.3.9",
41
- "@types/node": "22.13.4",
41
+ "@types/node": "22.14.0",
42
42
  "@types/yargs": "^17.0.33",
43
- "aws-cdk": "2.178.1",
44
- "aws-cdk-lib": "2.178.1",
43
+ "aws-cdk": "2.1007.0",
44
+ "aws-cdk-lib": "2.189.0",
45
45
  "constructs": "10.4.2",
46
46
  "eslint": "^8.57.1",
47
47
  "eslint-plugin-custom-rules": "file:tools/eslint",
48
48
  "gh-pages": "^6.3.0",
49
49
  "jest": "^29.7.0",
50
- "prettier": "^3.5.2",
50
+ "prettier": "^3.5.3",
51
51
  "serve": "^14.2.4",
52
- "ts-jest": "^29.2.6",
52
+ "ts-jest": "^29.3.1",
53
53
  "ts-node": "^10.9.2",
54
- "typedoc": "^0.27.7",
54
+ "typedoc": "^0.28.2",
55
55
  "typescript": "5.1.6"
56
56
  },
57
57
  "dependencies": {
58
58
  "@oclif/core": "3.26.6",
59
59
  "aws-sdk": "^2.1692.0",
60
60
  "chalk": "^4.1.2",
61
- "codemaker": "^1.108.0",
61
+ "codemaker": "^1.111.0",
62
62
  "git-url-parse": "^16.0.1",
63
63
  "js-yaml": "^4.1.0",
64
64
  "lodash.camelcase": "^4.3.0",
@@ -68,8 +68,8 @@
68
68
  "yargs": "^17.7.2"
69
69
  },
70
70
  "peerDependencies": {
71
- "aws-cdk": "2.178.1",
72
- "aws-cdk-lib": "2.178.1",
71
+ "aws-cdk": "2.1007.0",
72
+ "aws-cdk-lib": "2.189.0",
73
73
  "constructs": "10.4.2"
74
74
  }
75
75
  }