@wolsok/nx-aws-cdk-v2 2.6.0 → 3.0.2

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +204 -52
  3. package/executors.json +4 -4
  4. package/generators.json +3 -2
  5. package/migrations.json +5 -0
  6. package/package.json +37 -8
  7. package/src/executors/bootstrap/bootstrap.js +14 -13
  8. package/src/executors/bootstrap/bootstrap.js.map +1 -1
  9. package/src/executors/bootstrap/schema.d.ts +3 -0
  10. package/src/executors/bootstrap/schema.json +16 -2
  11. package/src/executors/deploy/deploy.js +16 -18
  12. package/src/executors/deploy/deploy.js.map +1 -1
  13. package/src/executors/deploy/schema.d.ts +5 -0
  14. package/src/executors/deploy/schema.json +16 -3
  15. package/src/executors/destroy/destroy.js +14 -13
  16. package/src/executors/destroy/destroy.js.map +1 -1
  17. package/src/executors/destroy/schema.d.ts +5 -0
  18. package/src/executors/destroy/schema.json +15 -2
  19. package/src/executors/synth/schema.d.ts +5 -0
  20. package/src/executors/synth/schema.json +16 -3
  21. package/src/executors/synth/synth.js +13 -13
  22. package/src/executors/synth/synth.js.map +1 -1
  23. package/src/generators/application/application.js +85 -67
  24. package/src/generators/application/application.js.map +1 -1
  25. package/src/generators/application/files/cdk.json__template__ +2 -2
  26. package/src/generators/application/files/src/main.ts__template__ +1 -1
  27. package/src/generators/application/files/src/stacks/app-stack.ts__template__ +4 -3
  28. package/src/generators/application/jest-files/src/main.test.ts__template__ +7 -7
  29. package/src/generators/application/schema.d.ts +6 -0
  30. package/src/generators/application/schema.json +10 -8
  31. package/src/generators/init/init.js +30 -24
  32. package/src/generators/init/init.js.map +1 -1
  33. package/src/generators/init/schema.d.ts +2 -0
  34. package/src/generators/init/schema.json +6 -4
  35. package/src/index.d.ts +20 -0
  36. package/src/index.js +31 -0
  37. package/src/index.js.map +1 -1
  38. package/src/interfaces/parsed-executor.interface.js.map +1 -1
  39. package/src/utils/cdk-shared.d.ts +25 -2
  40. package/src/utils/cdk-shared.js +26 -3
  41. package/src/utils/cdk-shared.js.map +1 -1
  42. package/src/utils/executor.util.js +20 -13
  43. package/src/utils/executor.util.js.map +1 -1
  44. package/src/utils/testing.js.map +1 -1
@@ -1,32 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = runExecutor;
4
- const tslib_1 = require("tslib");
5
4
  const executor_util_1 = require("../../utils/executor.util");
6
- function runExecutor(options, context) {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- const normalizedOptions = normalizeOptions(options, context);
9
- const result = yield runDestroy(normalizedOptions, context);
10
- return {
11
- success: result,
12
- };
13
- });
5
+ async function runExecutor(options, context) {
6
+ const normalizedOptions = normalizeOptions(options, context);
7
+ const result = await runDestroy(normalizedOptions, context);
8
+ return {
9
+ success: result,
10
+ };
14
11
  }
15
12
  function runDestroy(options, context) {
16
13
  const command = (0, executor_util_1.createCommand)('destroy', options);
17
14
  return (0, executor_util_1.runCommandProcess)(command, context.root);
18
15
  }
19
16
  function normalizeOptions(options, context) {
20
- var _a;
21
17
  const parsedArgs = (0, executor_util_1.parseArgs)(options);
22
18
  let stacks;
23
19
  if (Object.prototype.hasOwnProperty.call(options, 'stacks')) {
24
20
  stacks = options.stacks;
25
21
  }
22
+ const { sourceRoot, root } =
26
23
  // eslint-disable-next-line no-unsafe-optional-chaining
27
- const { sourceRoot, root } = (_a = context === null || context === void 0 ? void 0 : context.projectsConfigurations) === null || _a === void 0 ? void 0 : _a.projects[context.projectName];
28
- return Object.assign(Object.assign({}, options), { parseArgs: parsedArgs, stacks,
24
+ context?.projectsConfigurations?.projects[context.projectName];
25
+ return {
26
+ ...options,
27
+ parseArgs: parsedArgs,
28
+ stacks,
29
29
  sourceRoot,
30
- root });
30
+ root,
31
+ };
31
32
  }
32
33
  //# sourceMappingURL=destroy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../../../../packages/aws-cdk-v2/src/executors/destroy/destroy.ts"],"names":[],"mappings":";;AAYA,8BAOC;;AAlBD,6DAAwF;AAWxF,SAA8B,WAAW,CAAC,OAA8B,EAAE,OAAwB;;QAChG,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAE5D,OAAO;YACL,OAAO,EAAE,MAAM;SAChB,CAAC;IACJ,CAAC;CAAA;AAED,SAAS,UAAU,CAAC,OAAoC,EAAE,OAAwB;IAChF,MAAM,OAAO,GAAG,IAAA,6BAAa,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClD,OAAO,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,gBAAgB,CAAC,OAA8B,EAAE,OAAwB;;IAChF,MAAM,UAAU,GAAG,IAAA,yBAAS,EAAC,OAAO,CAAC,CAAC;IACtC,IAAI,MAAM,CAAC;IAEX,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC5D,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,uDAAuD;IACvD,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,sBAAsB,0CAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE5F,uCACK,OAAO,KACV,SAAS,EAAE,UAAU,EACrB,MAAM;QACN,UAAU;QACV,IAAI,IACJ;AACJ,CAAC"}
1
+ {"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../../../../../libs/public/nx-aws-cdk-v2/src/executors/destroy/destroy.ts"],"names":[],"mappings":";;AAgBA,8BAUC;AAzBD,6DAImC;AAWpB,KAAK,UAAU,WAAW,CACvC,OAA8B,EAC9B,OAAwB;IAExB,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5D,OAAO;QACL,OAAO,EAAE,MAAM;KAChB,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,OAAoC,EACpC,OAAwB;IAExB,MAAM,OAAO,GAAG,IAAA,6BAAa,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClD,OAAO,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,gBAAgB,CACvB,OAA8B,EAC9B,OAAwB;IAExB,MAAM,UAAU,GAAG,IAAA,yBAAS,EAAC,OAAO,CAAC,CAAC;IACtC,IAAI,MAAM,CAAC;IAEX,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC5D,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE;IACxB,uDAAuD;IACvD,OAAO,EAAE,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAEjE,OAAO;QACL,GAAG,OAAO;QACV,SAAS,EAAE,UAAU;QACrB,MAAM;QACN,UAAU;QACV,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -1,3 +1,8 @@
1
1
  export interface DestroyExecutorSchema {
2
+ /** Stacks to destroy. Defaults to every stack in the app. */
2
3
  stacks?: string;
4
+ /** AWS profile to use. */
5
+ profile?: string;
6
+ /** Additional CDK context values as `KEY=VALUE` pairs. */
7
+ context?: string | string[];
3
8
  }
@@ -1,13 +1,26 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "title": "Destroy executor",
4
- "description": "",
4
+ "description": "Destroy the deployed CDK stacks of this project.",
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "stacks": {
8
8
  "type": "string",
9
- "description": "use destroy named STACKS"
9
+ "description": "Stacks to destroy. Accepts stack names or glob patterns, space separated. Defaults to every stack in the app."
10
+ },
11
+ "profile": {
12
+ "type": "string",
13
+ "description": "Name of the AWS profile (from ~/.aws/credentials or ~/.aws/config) to use."
14
+ },
15
+ "context": {
16
+ "oneOf": [
17
+ { "type": "string" },
18
+ { "type": "array", "items": { "type": "string" } }
19
+ ],
20
+ "description": "Additional CDK context values as KEY=VALUE pairs. Pass the option multiple times for multiple values.",
21
+ "alias": "c"
10
22
  }
11
23
  },
24
+ "additionalProperties": true,
12
25
  "required": []
13
26
  }
@@ -1,3 +1,8 @@
1
1
  export interface SynthExecutorSchema {
2
+ /** Stacks to synthesize. Defaults to every stack in the app. */
2
3
  stacks?: string;
4
+ /** AWS profile to use. */
5
+ profile?: string;
6
+ /** Additional CDK context values as `KEY=VALUE` pairs. */
7
+ context?: string | string[];
3
8
  }
@@ -1,13 +1,26 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/schema",
3
- "title": "synth executor",
4
- "description": "",
3
+ "title": "Synth executor",
4
+ "description": "Synthesize the CDK app of this project into a CloudFormation template.",
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "stacks": {
8
8
  "type": "string",
9
- "description": "use synth named STACKS"
9
+ "description": "Stacks to synthesize. Accepts stack names or glob patterns, space separated. Defaults to every stack in the app."
10
+ },
11
+ "profile": {
12
+ "type": "string",
13
+ "description": "Name of the AWS profile (from ~/.aws/credentials or ~/.aws/config) to use."
14
+ },
15
+ "context": {
16
+ "oneOf": [
17
+ { "type": "string" },
18
+ { "type": "array", "items": { "type": "string" } }
19
+ ],
20
+ "description": "Additional CDK context values as KEY=VALUE pairs. Pass the option multiple times for multiple values.",
21
+ "alias": "c"
10
22
  }
11
23
  },
24
+ "additionalProperties": true,
12
25
  "required": []
13
26
  }
@@ -1,31 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = runExecutor;
4
- const tslib_1 = require("tslib");
5
4
  const executor_util_1 = require("../../utils/executor.util");
6
- function runExecutor(options, context) {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- const normalizedOptions = normalizeOptions(options, context);
9
- const result = yield runSynth(normalizedOptions, context);
10
- return {
11
- success: result,
12
- };
13
- });
5
+ async function runExecutor(options, context) {
6
+ const normalizedOptions = normalizeOptions(options, context);
7
+ const result = await runSynth(normalizedOptions, context);
8
+ return {
9
+ success: result,
10
+ };
14
11
  }
15
12
  function runSynth(options, context) {
16
13
  const command = (0, executor_util_1.createCommand)('synth', options);
17
14
  return (0, executor_util_1.runCommandProcess)(command, context.root);
18
15
  }
19
16
  function normalizeOptions(options, context) {
20
- var _a, _b;
21
17
  const parsedArgs = (0, executor_util_1.parseArgs)(options);
22
18
  let stacks;
23
19
  if (Object.prototype.hasOwnProperty.call(options, 'stacks')) {
24
20
  stacks = options.stacks;
25
21
  }
26
- const { sourceRoot, root } = (_b = (_a = context === null || context === void 0 ? void 0 : context.projectsConfigurations) === null || _a === void 0 ? void 0 : _a.projects[context.projectName]) !== null && _b !== void 0 ? _b : {};
27
- return Object.assign(Object.assign({}, options), { parseArgs: parsedArgs, stacks,
22
+ const { sourceRoot, root } = context?.projectsConfigurations?.projects[context.projectName] ?? {};
23
+ return {
24
+ ...options,
25
+ parseArgs: parsedArgs,
26
+ stacks,
28
27
  sourceRoot,
29
- root });
28
+ root,
29
+ };
30
30
  }
31
31
  //# sourceMappingURL=synth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"synth.js","sourceRoot":"","sources":["../../../../../../packages/aws-cdk-v2/src/executors/synth/synth.ts"],"names":[],"mappings":";;AAYA,8BAOC;;AAhBD,6DAAwF;AASxF,SAA8B,WAAW,CAAC,OAA4B,EAA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AC;IAC7D,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE1D,OAAO;QACL,OAAO,EAAE,MAAM;KAChB,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CACf,OAAkC,EAClC,OAAwB;IAExB,MAAM,OAAO,GAAG,IAAA,6BAAa,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChD,OAAO,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,gBAAgB,CACvB,OAA4B,EAC5B,OAAwB;IAExB,MAAM,UAAU,GAAG,IAAA,yBAAS,EAAC,OAAO,CAAC,CAAC;IACtC,IAAI,MAAM,CAAC;IAEX,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC5D,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GACxB,OAAO,EAAE,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAEvE,OAAO;QACL,GAAG,OAAO;QACV,SAAS,EAAE,UAAU;QACrB,MAAM;QACN,UAAU;QACV,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -8,87 +8,105 @@ const devkit_1 = require("@nx/devkit");
8
8
  const jest_1 = require("@nx/jest");
9
9
  const init_1 = require("../init/init");
10
10
  function normalizeOptions(host, options) {
11
- var _a;
12
11
  const name = (0, devkit_1.names)(options.name).fileName;
13
- const projectDirectory = options.directory ? `${(0, devkit_1.names)(options.directory).fileName}/${name}` : name;
12
+ const projectDirectory = options.directory
13
+ ? `${(0, devkit_1.names)(options.directory).fileName}/${name}`
14
+ : name;
14
15
  const projectName = projectDirectory.replace(new RegExp('/', 'g'), '-');
15
16
  const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectDirectory}`;
16
- const parsedTags = options.tags ? options.tags.split(',').map((s) => s.trim()) : [];
17
- return Object.assign(Object.assign({}, options), { projectName,
17
+ const parsedTags = options.tags
18
+ ? options.tags.split(',').map((s) => s.trim())
19
+ : [];
20
+ return {
21
+ ...options,
22
+ projectName,
18
23
  projectRoot,
19
24
  projectDirectory,
20
- parsedTags, unitTestRunner: (_a = options.unitTestRunner) !== null && _a !== void 0 ? _a : 'jest' });
25
+ parsedTags,
26
+ unitTestRunner: options.unitTestRunner ?? 'jest',
27
+ };
21
28
  }
22
29
  function addFiles(host, options) {
23
- const templateOptions = Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.projectName)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot), template: '' });
30
+ const templateOptions = {
31
+ ...options,
32
+ ...(0, devkit_1.names)(options.projectName),
33
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
34
+ template: '',
35
+ };
24
36
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
25
37
  }
26
38
  function addJestFiles(host, options) {
27
- const templateOptions = Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.projectName)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot), template: '' });
39
+ const templateOptions = {
40
+ ...options,
41
+ ...(0, devkit_1.names)(options.projectName),
42
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
43
+ template: '',
44
+ };
28
45
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'jest-files'), options.projectRoot, templateOptions);
29
46
  }
30
- function applicationGenerator(host, options) {
31
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
32
- const tasks = [];
33
- const normalizedOptions = normalizeOptions(host, options);
34
- const initTask = yield (0, init_1.initGenerator)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
35
- tasks.push(initTask);
36
- const project = {
37
- root: normalizedOptions.projectRoot,
38
- projectType: 'application',
39
- sourceRoot: `${normalizedOptions.projectRoot}/src`,
40
- targets: {
41
- deploy: {
42
- executor: '@wolsok/nx-aws-cdk-v2:deploy',
43
- options: {},
44
- },
45
- synth: {
46
- executor: '@wolsok/nx-aws-cdk-v2:synth',
47
- options: {},
48
- },
49
- destroy: {
50
- executor: '@wolsok/nx-aws-cdk-v2:destroy',
51
- options: {},
52
- },
53
- bootstrap: {
54
- executor: '@wolsok/nx-aws-cdk-v2:bootstrap',
55
- options: {},
56
- },
47
+ async function applicationGenerator(host, options) {
48
+ const tasks = [];
49
+ const normalizedOptions = normalizeOptions(host, options);
50
+ const initTask = await (0, init_1.initGenerator)(host, {
51
+ ...options,
52
+ skipFormat: true,
53
+ });
54
+ tasks.push(initTask);
55
+ const project = {
56
+ root: normalizedOptions.projectRoot,
57
+ projectType: 'application',
58
+ sourceRoot: `${normalizedOptions.projectRoot}/src`,
59
+ targets: {
60
+ deploy: {
61
+ executor: '@wolsok/nx-aws-cdk-v2:deploy',
62
+ options: {},
63
+ },
64
+ synth: {
65
+ executor: '@wolsok/nx-aws-cdk-v2:synth',
66
+ options: {},
67
+ },
68
+ destroy: {
69
+ executor: '@wolsok/nx-aws-cdk-v2:destroy',
70
+ options: {},
57
71
  },
58
- tags: normalizedOptions.parsedTags,
72
+ bootstrap: {
73
+ executor: '@wolsok/nx-aws-cdk-v2:bootstrap',
74
+ options: {},
75
+ },
76
+ },
77
+ tags: normalizedOptions.parsedTags,
78
+ };
79
+ (0, devkit_1.addProjectConfiguration)(host, normalizedOptions.projectName, project);
80
+ const workspace = (0, devkit_1.readProjectConfiguration)(host, normalizedOptions.projectName);
81
+ (0, devkit_1.updateProjectConfiguration)(host, normalizedOptions.projectName, workspace);
82
+ addFiles(host, normalizedOptions);
83
+ if (normalizedOptions.unitTestRunner === 'jest') {
84
+ // `configurationGenerator` forwards its whole options object to `@nx/js`'s init
85
+ // generator, where `skipFormat` only guards the formatFiles call - `ensurePackage`
86
+ // for prettier still runs unless `formatter: 'none'` is set too. Since we already
87
+ // skip formatting here, also skip ensuring prettier: requiring the real prettier
88
+ // package from inside Jest's own module sandbox (i.e. when this generator runs in
89
+ // a unit test) crashes with "dynamic import callback ... without --experimental-vm-modules".
90
+ // `formatter` isn't part of JestProjectSchema's public type, so build the options
91
+ // object separately to avoid TypeScript's excess-property check on the call site.
92
+ const jestConfigOptions = {
93
+ project: normalizedOptions.projectName,
94
+ setupFile: 'none',
95
+ skipSerializers: true,
96
+ supportTsx: false,
97
+ babelJest: false,
98
+ testEnvironment: 'node',
99
+ skipFormat: true,
100
+ formatter: 'none',
59
101
  };
60
- (0, devkit_1.addProjectConfiguration)(host, normalizedOptions.projectName, project);
61
- const workspace = (0, devkit_1.readProjectConfiguration)(host, normalizedOptions.projectName);
62
- (0, devkit_1.updateProjectConfiguration)(host, normalizedOptions.projectName, workspace);
63
- addFiles(host, normalizedOptions);
64
- if (normalizedOptions.unitTestRunner === 'jest') {
65
- // `configurationGenerator` forwards its whole options object to `@nx/js`'s init
66
- // generator, where `skipFormat` only guards the formatFiles call - `ensurePackage`
67
- // for prettier still runs unless `formatter: 'none'` is set too. Since we already
68
- // skip formatting here, also skip ensuring prettier: requiring the real prettier
69
- // package from inside Jest's own module sandbox (i.e. when this generator runs in
70
- // a unit test) crashes with "dynamic import callback ... without --experimental-vm-modules".
71
- // `formatter` isn't part of JestProjectSchema's public type, so build the options
72
- // object separately to avoid TypeScript's excess-property check on the call site.
73
- const jestConfigOptions = {
74
- project: normalizedOptions.projectName,
75
- setupFile: 'none',
76
- skipSerializers: true,
77
- supportTsx: false,
78
- babelJest: false,
79
- testEnvironment: 'node',
80
- skipFormat: true,
81
- formatter: 'none',
82
- };
83
- const jestTask = yield (0, jest_1.configurationGenerator)(host, jestConfigOptions);
84
- tasks.push(jestTask);
85
- addJestFiles(host, normalizedOptions);
86
- }
87
- if (!options.skipFormat) {
88
- yield (0, devkit_1.formatFiles)(host);
89
- }
90
- return (0, devkit_1.runTasksInSerial)(...tasks);
91
- });
102
+ const jestTask = await (0, jest_1.configurationGenerator)(host, jestConfigOptions);
103
+ tasks.push(jestTask);
104
+ addJestFiles(host, normalizedOptions);
105
+ }
106
+ if (!options.skipFormat) {
107
+ await (0, devkit_1.formatFiles)(host);
108
+ }
109
+ return (0, devkit_1.runTasksInSerial)(...tasks);
92
110
  }
93
111
  exports.default = applicationGenerator;
94
112
  exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
@@ -1 +1 @@
1
- {"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../../../packages/aws-cdk-v2/src/generators/application/application.ts"],"names":[],"mappings":";;;AAkEA,oDAqEC;;AAvID,mDAA6B;AAC7B,uCAcoB;AACpB,mCAAkD;AAGlD,uCAA6C;AAS7C,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAA0B;;IAC9D,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnG,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAC9E,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CA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AAG,MAAM,IAAA,6BAAsB,EAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;YACvE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrB,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YACxB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AAED,kBAAe,oBAAoB,CAAC;AACvB,QAAA,oBAAoB,GAAG,IAAA,2BAAkB,EAAC,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../../../../libs/public/nx-aws-cdk-v2/src/generators/application/application.ts"],"names":[],"mappings":";;;AAmFA,oDA2EC;;AA9JD,mDAA6B;AAC7B,uCAcoB;AACpB,mCAAkD;AAGlD,uCAA6C;AAS7C,SAAS,gBAAgB,CACvB,IAAU,EACV,OAA0B;IAE1B,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS;QACxC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAI,IAAI,EAAE;QAChD,CAAC,CAAC,IAAI,CAAC;IACT,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAC9E,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI;QAC7B,CAAC,CAAC,OAAO,CAAC,IAA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AAM;YACjB,eAAe,EAAE,IAAI;YACrB,UAAU,EAAE,KAAK;YACjB,SAAS,EAAE,KAAK;YAChB,eAAe,EAAE,MAAM;YACvB,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,MAAM;SACT,CAAC;QACX,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAsB,EAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QACvE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrB,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACxB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,kBAAe,oBAAoB,CAAC;AACvB,QAAA,oBAAoB,GAAG,IAAA,2BAAkB,EAAC,oBAAoB,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  {
2
- "app": "npx ts-node src/main.ts",
3
- "output": "<%= offsetFromRoot %>dist/apps/<%= projectName %>",
2
+ "app": "npx ts-node --require tsconfig-paths/register --project tsconfig.app.json src/main.ts",
3
+ "output": "<%= offsetFromRoot %>dist/cdk.out/<%= projectName %>",
4
4
  "requireApproval": "never",
5
5
  "watch": {
6
6
  "include": [
@@ -2,4 +2,4 @@ import { App } from 'aws-cdk-lib';
2
2
  import { AppStack } from './stacks/app-stack';
3
3
 
4
4
  const app = new App();
5
- new AppStack(app, '<%= projectName %>');
5
+ new AppStack(app, '<%= projectName %>');
@@ -1,9 +1,10 @@
1
- import { Stack, App, StackProps } from 'aws-cdk-lib';
1
+ import { App, Stack, StackProps } from 'aws-cdk-lib';
2
2
 
3
3
  export class AppStack extends Stack {
4
4
  constructor(scope: App, id: string, props?: StackProps) {
5
5
  super(scope, id, props);
6
6
 
7
- // defines your stack here
8
- }
7
+ // Define your infrastructure here, for example:
8
+ // new Bucket(this, 'MyBucket', { versioned: true });
9
+ }
9
10
  }
@@ -1,13 +1,13 @@
1
- import { Stack, App } from 'aws-cdk-lib';
1
+ import { App } from 'aws-cdk-lib';
2
2
  import { Template } from 'aws-cdk-lib/assertions';
3
3
  import { AppStack } from './stacks/app-stack';
4
4
 
5
- test('Empty Stack', () => {
5
+ describe('<%= className %>', () => {
6
+ it('synthesizes an empty stack', () => {
6
7
  const app = new App();
7
- // WHEN
8
+
8
9
  const stack = new AppStack(app, '<%= projectName %>TestStack');
9
- // THEN
10
- Template.fromStack(stack as Stack).templateMatches({
11
- Resources: {}
12
- });
10
+
11
+ Template.fromStack(stack).templateMatches({ Resources: {} });
12
+ });
13
13
  });
@@ -1,8 +1,14 @@
1
1
  export interface ApplicationSchema {
2
+ /** The name of the application. */
2
3
  name: string;
4
+ /** Comma separated list of tags to add to the project. */
3
5
  tags?: string;
6
+ /** Directory the project is placed in, relative to the workspace's apps directory. */
4
7
  directory?: string;
8
+ /** Skip formatting the generated files with Prettier. */
5
9
  skipFormat?: boolean;
10
+ /** Unit test runner to configure for the generated application. */
6
11
  unitTestRunner?: 'jest' | 'none';
12
+ /** Whether to configure the ESLint `parserOptions.project` option. */
7
13
  setParserOptionsProject?: boolean;
8
14
  }
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/schema",
3
- "id": "AwsCdk",
4
- "title": "",
3
+ "$id": "AwsCdkApplication",
4
+ "cli": "nx",
5
+ "title": "Create an AWS CDK v2 application",
6
+ "description": "Scaffolds an AWS CDK v2 application with deploy, destroy, synth and bootstrap targets.",
5
7
  "type": "object",
6
8
  "properties": {
7
9
  "name": {
8
10
  "type": "string",
9
- "description": "",
11
+ "description": "The name of the application.",
10
12
  "$default": {
11
13
  "$source": "argv",
12
14
  "index": 0
@@ -15,28 +17,28 @@
15
17
  },
16
18
  "tags": {
17
19
  "type": "string",
18
- "description": "Add tags to the project (used for linting)",
20
+ "description": "Comma separated list of tags to add to the project (used for linting and for `nx affected` filtering).",
19
21
  "alias": "t"
20
22
  },
21
23
  "directory": {
22
24
  "type": "string",
23
- "description": "A directory where the project is placed",
25
+ "description": "The directory the project is placed in, relative to the workspace's apps directory.",
24
26
  "alias": "d"
25
27
  },
26
28
  "skipFormat": {
27
- "description": "Skip formatting files",
29
+ "description": "Skip formatting the generated files with Prettier.",
28
30
  "type": "boolean",
29
31
  "default": false
30
32
  },
31
33
  "unitTestRunner": {
32
- "description": "Adds the specified unit test runner",
34
+ "description": "The unit test runner to configure for the generated application.",
33
35
  "type": "string",
34
36
  "enum": ["jest", "none"],
35
37
  "default": "jest"
36
38
  },
37
39
  "setParserOptionsProject": {
38
40
  "type": "boolean",
39
- "description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
41
+ "description": "Whether to configure the ESLint \"parserOptions.project\" option. Off by default for lint performance reasons.",
40
42
  "default": false
41
43
  }
42
44
  },
@@ -2,36 +2,42 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initSchematic = void 0;
4
4
  exports.initGenerator = initGenerator;
5
- const tslib_1 = require("tslib");
6
5
  const devkit_1 = require("@nx/devkit");
7
6
  const jest_1 = require("@nx/jest");
8
7
  const cdk_shared_1 = require("../../utils/cdk-shared");
9
8
  function normalizeOptions(schema) {
10
- var _a;
11
- return Object.assign(Object.assign({}, schema), { unitTestRunner: (_a = schema.unitTestRunner) !== null && _a !== void 0 ? _a : 'jest' });
9
+ return {
10
+ ...schema,
11
+ unitTestRunner: schema.unitTestRunner ?? 'jest',
12
+ };
12
13
  }
13
- function initGenerator(host, options) {
14
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
- let jestInstall;
16
- const schema = normalizeOptions(options);
17
- if (schema.unitTestRunner === 'jest') {
18
- jestInstall = yield (0, jest_1.jestInitGenerator)(host, {});
19
- }
20
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {
21
- 'aws-cdk': cdk_shared_1.CDK_VERSION,
22
- 'aws-cdk-lib': cdk_shared_1.CDK_VERSION,
23
- constructs: cdk_shared_1.CDK_CONSTRUCTS_VERSION,
24
- }, {});
25
- if (!schema.skipFormat) {
26
- yield (0, devkit_1.formatFiles)(host);
27
- }
28
- return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
29
- if (jestInstall) {
30
- yield jestInstall();
31
- }
32
- yield installTask();
33
- });
14
+ async function initGenerator(host, options) {
15
+ let jestInstall;
16
+ const schema = normalizeOptions(options);
17
+ if (schema.unitTestRunner === 'jest') {
18
+ jestInstall = await (0, jest_1.jestInitGenerator)(host, {});
19
+ }
20
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {
21
+ 'aws-cdk-lib': cdk_shared_1.CDK_LIB_VERSION,
22
+ constructs: cdk_shared_1.CDK_CONSTRUCTS_VERSION,
23
+ }, {
24
+ // The CDK Toolkit and the TypeScript loaders are only ever invoked by the
25
+ // executors, so they belong in devDependencies rather than shipping with
26
+ // whatever the workspace publishes.
27
+ 'aws-cdk': cdk_shared_1.CDK_CLI_VERSION,
28
+ 'ts-node': cdk_shared_1.TS_NODE_VERSION,
29
+ 'tsconfig-paths': cdk_shared_1.TSCONFIG_PATHS_VERSION,
30
+ tsx: cdk_shared_1.TSX_VERSION,
34
31
  });
32
+ if (!schema.skipFormat) {
33
+ await (0, devkit_1.formatFiles)(host);
34
+ }
35
+ return async () => {
36
+ if (jestInstall) {
37
+ await jestInstall();
38
+ }
39
+ await installTask();
40
+ };
35
41
  }
36
42
  exports.default = initGenerator;
37
43
  exports.initSchematic = (0, devkit_1.convertNxGenerator)(initGenerator);
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/aws-cdk-v2/src/generators/init/init.ts"],"names":[],"mappings":";;;AAaA,sCA4BC;;AAzCD,uCAAoH;AACpH,mCAA6C;AAG7C,uDAA6E;AAE7E,SAAS,gBAAgB,CAAC,MAA2B;;IACnD,uCACK,MAAM,KACT,cAAc,EAAE,MAAA,MAAM,CAAC,cAAc,mCAAI,MAAM,IAC/C;AACJ,CAAC;AAED,SAAsB,aAAa,CAAC,IAAU,EAAE,OAA4B;;QAC1E,IAAI,WAA8B,CAAC;QACnC,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;YACrC,WAAW,GAAG,MAAM,IAAA,wBAAiB,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,WAAW,GAAG,IAAA,qCAA4B,EAC9C,IAAI,EACJ;YACE,SAAS,EAAE,wBAAW;YACtB,aAAa,EAAE,wBAAW;YAC1B,UAAU,EAAE,mCAAsB;SACnC,EACD,EAAE,CACH,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,OAAO,GAAS,EAAE;YAChB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,WAAW,EAAE,CAAC;YACtB,CAAC;YACD,MAAM,WAAW,EAAE,CAAC;QACtB,CAAC,CAAA,CAAC;IACJ,CAAC;CAAA;AAED,kBAAe,aAAa,CAAC;AAChB,QAAA,aAAa,GAAG,IAAA,2BAAkB,EAAC,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../../libs/public/nx-aws-cdk-v2/src/generators/init/init.ts"],"names":[],"mappings":";;;AA0BA,sCAmCC;AA7DD,uCAMoB;AACpB,mCAA6C;AAG7C,uDAOgC;AAEhC,SAAS,gBAAgB,CAAC,MAA2B;IACnD,OAAO;QACL,GAAG,MAAM;QACT,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,MAAM;KAChD,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,IAAU,EAAE,OAA4B;IAC1E,IAAI,WAA8B,CAAC;IACnC,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAEzC,IAAI,MAAM,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;QACrC,WAAW,GAAG,MAAM,IAAA,wBAAiB,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,qCAA4B,EAC9C,IAAI,EACJ;QACE,aAAa,EAAE,4BAAe;QAC9B,UAAU,EAAE,mCAAsB;KACnC,EACD;QACE,0EAA0E;QAC1E,yEAAyE;QACzE,oCAAoC;QACpC,SAAS,EAAE,4BAAe;QAC1B,SAAS,EAAE,4BAAe;QAC1B,gBAAgB,EAAE,mCAAsB;QACxC,GAAG,EAAE,wBAAW;KACjB,CACF,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,IAAI,EAAE;QAChB,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,WAAW,EAAE,CAAC;QACtB,CAAC;QACD,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,aAAa,CAAC;AAChB,QAAA,aAAa,GAAG,IAAA,2BAAkB,EAAC,aAAa,CAAC,CAAC"}
@@ -1,4 +1,6 @@
1
1
  export interface InitGeneratorSchema {
2
+ /** Unit test runner to initialise for the workspace. */
2
3
  unitTestRunner?: 'jest' | 'none';
4
+ /** Skip formatting the touched files with Prettier. */
3
5
  skipFormat?: boolean;
4
6
  }
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/schema",
3
- "id": "AwsCdkInit",
4
- "title": "Add AWS CDK Schematics",
3
+ "$id": "AwsCdkInit",
4
+ "cli": "nx",
5
+ "title": "Add the AWS CDK dependencies to the workspace",
6
+ "description": "Adds aws-cdk-lib, constructs, the CDK Toolkit CLI and the TypeScript loaders the executors need. Runs automatically as part of the application generator.",
5
7
  "type": "object",
6
8
  "properties": {
7
9
  "unitTestRunner": {
8
- "description": "Adds the specified unit test runner",
10
+ "description": "The unit test runner to initialise for the workspace.",
9
11
  "type": "string",
10
12
  "enum": ["jest", "none"],
11
13
  "default": "jest"
12
14
  },
13
15
  "skipFormat": {
14
- "description": "Skip formatting files",
16
+ "description": "Skip formatting the touched files with Prettier.",
15
17
  "type": "boolean",
16
18
  "default": false
17
19
  }