@wolsok/nx-aws-cdk-v2 2.0.0-beta

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 (50) hide show
  1. package/README.md +97 -0
  2. package/executors.json +20 -0
  3. package/generators.json +19 -0
  4. package/package.json +25 -0
  5. package/src/executors/bootstrap/bootstrap.d.ts +12 -0
  6. package/src/executors/bootstrap/bootstrap.js +32 -0
  7. package/src/executors/bootstrap/bootstrap.js.map +1 -0
  8. package/src/executors/bootstrap/schema.d.ts +3 -0
  9. package/src/executors/bootstrap/schema.json +8 -0
  10. package/src/executors/deploy/deploy.d.ts +11 -0
  11. package/src/executors/deploy/deploy.js +34 -0
  12. package/src/executors/deploy/deploy.js.map +1 -0
  13. package/src/executors/deploy/schema.d.ts +3 -0
  14. package/src/executors/deploy/schema.json +13 -0
  15. package/src/executors/destroy/destroy.d.ts +12 -0
  16. package/src/executors/destroy/destroy.js +32 -0
  17. package/src/executors/destroy/destroy.js.map +1 -0
  18. package/src/executors/destroy/schema.d.ts +3 -0
  19. package/src/executors/destroy/schema.json +13 -0
  20. package/src/generators/application/application.d.ts +5 -0
  21. package/src/generators/application/application.js +110 -0
  22. package/src/generators/application/application.js.map +1 -0
  23. package/src/generators/application/files/cdk.json__template__ +36 -0
  24. package/src/generators/application/files/src/main.ts__template__ +5 -0
  25. package/src/generators/application/files/src/stacks/app-stack.ts__template__ +9 -0
  26. package/src/generators/application/files/tsconfig.app.json__template__ +9 -0
  27. package/src/generators/application/files/tsconfig.json__template__ +15 -0
  28. package/src/generators/application/jest-files/src/main.test.ts__template__ +13 -0
  29. package/src/generators/application/schema.d.ts +11 -0
  30. package/src/generators/application/schema.json +58 -0
  31. package/src/generators/init/init.d.ts +5 -0
  32. package/src/generators/init/init.js +40 -0
  33. package/src/generators/init/init.js.map +1 -0
  34. package/src/generators/init/schema.d.ts +4 -0
  35. package/src/generators/init/schema.json +23 -0
  36. package/src/index.d.ts +0 -0
  37. package/src/index.js +1 -0
  38. package/src/index.js.map +1 -0
  39. package/src/interfaces/parsed-executor.interface.d.ts +7 -0
  40. package/src/interfaces/parsed-executor.interface.js +3 -0
  41. package/src/interfaces/parsed-executor.interface.js.map +1 -0
  42. package/src/utils/cdk-shared.d.ts +3 -0
  43. package/src/utils/cdk-shared.js +7 -0
  44. package/src/utils/cdk-shared.js.map +1 -0
  45. package/src/utils/executor.util.d.ts +9 -0
  46. package/src/utils/executor.util.js +88 -0
  47. package/src/utils/executor.util.js.map +1 -0
  48. package/src/utils/testing.d.ts +2 -0
  49. package/src/utils/testing.js +28 -0
  50. package/src/utils/testing.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ [![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
2
+ [![@wolsok/nx-aws-cdk-v2](https://img.shields.io/badge/%40adrian--goe-nx--aws--cdk-green)](https://github.com/WolfSoko/nx-aws-cdk-v2/tree/main/packages/aws-cdk-v2)
3
+ [![Typescript](https://badgen.net/badge/icon/typescript?icon=typescript&label)](https://www.typescriptlang.org/)
4
+ [![LICENSE](https://img.shields.io/npm/l/@wolsok/nx-aws-cdk-v2.svg)](https://www.npmjs.com/package/@wolsok/nx-aws-cdk-v2)
5
+ [![npm version](https://img.shields.io/npm/v/@wolsok/nx-aws-cdk-v2.svg)](https://www.npmjs.com/package/@wolsok/nx-aws-cdk-v2)
6
+ [![Downloads](https://img.shields.io/npm/dm/@wolsok/nx-aws-cdk-v2.svg)](https://www.npmjs.com/package/@wolsok/nx-aws-cdk-v2)
7
+
8
+ <hr>
9
+
10
+ # @wolsok/nx-aws-cdk-v2
11
+
12
+ An Nx plugin for developing [aws-cdk](https://docs.aws.amazon.com/cdk/latest/guide/home.html)
13
+
14
+ ## Table of Contents
15
+
16
+ - [Install](#install)
17
+ - [Usage](#usage)
18
+ - [Generate Application](#generate-application)
19
+ - [Targets](#targets)
20
+ - [Maintainers](#maintainers)
21
+ - [Contributing](#contributing)
22
+ - [License](#license)
23
+
24
+ ## Install
25
+
26
+ ```shell
27
+ # npm
28
+ npm install --save-dev @wolsok/nx-aws-cdk-v2
29
+
30
+ # yarn
31
+ yarn add --dev @wolsok/nx-aws-cdk-v2
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ### Generate Application
37
+
38
+ Create AWS CDK v2 Application
39
+
40
+ More details on AWS CDK v2 can be found on https://docs.aws.amazon.com/cdk/v2/guide/home.html
41
+
42
+ ```shell
43
+ nx generate @wolsok/nx-aws-cdk-v2:application myApp
44
+ ```
45
+
46
+ you can customize it further by passing these options:
47
+
48
+ ```
49
+ nx generate @wolsok/nx-aws-cdk-v2:application [name] [options,...]
50
+
51
+ Options:
52
+ --name
53
+ --tags Add tags to the project (used for linting)
54
+ --directory A directory where the project is placed
55
+ --skipFormat Skip formatting files
56
+ --unitTestRunner Adds the specified unit test runner (default: jest)
57
+ --linter The tool to use for running lint checks. (default: eslint)
58
+ --setParserOptionsProject Whether or not to configure the ESLint "parserOptions.project" option. We do not do this by default for lint performance reasons.
59
+ --dryRun Runs through and reports activity without writing to disk.
60
+ --skip-nx-cache Skip the use of Nx cache.
61
+ --help Show available options for project target.
62
+ ```
63
+
64
+ ### Targets
65
+
66
+ Generated applications expose several functions to the CLI that allow users to deploy, destroy and bootstrap.
67
+
68
+ ```shell
69
+ nx deploy myApp
70
+ nx destroy myApp
71
+ nx bootstrap myApp --profile=profile
72
+ #see how to use aws environments https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html#bootstrapping-howto-cli
73
+ nx bootstrap myApp aws://123456789012/us-east-1
74
+ ```
75
+
76
+ ## Maintainers
77
+
78
+ [@WolfSoko](https://github.com/WolfSoko)
79
+
80
+ ## Contributing
81
+
82
+ See [the contributing file](../../CONTRIBUTING.md)!
83
+
84
+ PRs accepted.
85
+
86
+ If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
87
+
88
+ ## License
89
+
90
+ This project is MIT licensed 2022 Wolfram Sokollek
91
+
92
+ ## Special thanks
93
+
94
+ This Project is based on [@tienne](https://github.com/tienne)'s
95
+ [nx-plugins](https://github.com/codebrewlab/nx-plugins).
96
+
97
+ Also thanks to [@therk](https://github.com/therk) for his work on migrating to cdk v2.
package/executors.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "executors": {
4
+ "deploy": {
5
+ "implementation": "./src/executors/deploy/deploy",
6
+ "schema": "./src/executors/deploy/schema.json",
7
+ "description": "build executor"
8
+ },
9
+ "destroy": {
10
+ "implementation": "./src/executors/destroy/destroy",
11
+ "schema": "./src/executors/destroy/schema.json",
12
+ "description": "destroy executor"
13
+ },
14
+ "bootstrap": {
15
+ "implementation": "./src/executors/bootstrap/bootstrap",
16
+ "schema": "./src/executors/bootstrap/schema.json",
17
+ "description": "bootstrap executor"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "name": "aws-cdk-v2",
4
+ "version": "0.0.1",
5
+ "generators": {
6
+ "init": {
7
+ "factory": "./src/generators/init/init",
8
+ "schema": "./src/generators/init/schema.json",
9
+ "description": "init generator",
10
+ "aliases": ["ng-add"],
11
+ "hidden": true
12
+ },
13
+ "application": {
14
+ "factory": "./src/generators/application/application",
15
+ "schema": "./src/generators/application/schema.json",
16
+ "description": "create aws-cdk application"
17
+ }
18
+ }
19
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@wolsok/nx-aws-cdk-v2",
3
+ "version": "2.0.0-beta",
4
+ "main": "./src/index.js",
5
+ "generators": "./generators.json",
6
+ "executors": "./executors.json",
7
+ "keywords": [
8
+ "nx",
9
+ "aws-cdk",
10
+ "monorepo",
11
+ "aws cdk",
12
+ "Node"
13
+ ],
14
+ "ng-update": {
15
+ "requirements": {},
16
+ "migrations": "./migrations.json"
17
+ },
18
+ "author": "Wolfram Sokollek",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git@github.com:WolfSoko/nx-aws-cdk-v2"
22
+ },
23
+ "license": "MIT",
24
+ "type": "commonjs"
25
+ }
@@ -0,0 +1,12 @@
1
+ import { BootstrapExecutorSchema } from './schema';
2
+ import { ParsedExecutorInterface } from '../../interfaces/parsed-executor.interface';
3
+ import { ExecutorContext } from '@nx/devkit';
4
+ export interface ParsedBootstrapExecutorOption extends ParsedExecutorInterface {
5
+ profile?: string;
6
+ app?: string;
7
+ sourceRoot: string;
8
+ root: string;
9
+ }
10
+ export default function runExecutor(options: BootstrapExecutorSchema, context: ExecutorContext): Promise<{
11
+ success: boolean;
12
+ }>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = runExecutor;
4
+ const tslib_1 = require("tslib");
5
+ 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 runBootstrap(normalizedOptions, context);
10
+ return {
11
+ success: result,
12
+ };
13
+ });
14
+ }
15
+ function runBootstrap(options, context) {
16
+ const command = (0, executor_util_1.createCommand)('bootstrap', options);
17
+ return (0, executor_util_1.runCommandProcess)(command, context.root);
18
+ }
19
+ function normalizeOptions(options, context) {
20
+ var _a;
21
+ const parsedArgs = (0, executor_util_1.parseArgs)(options);
22
+ let profile;
23
+ if (Object.prototype.hasOwnProperty.call(options, 'profile')) {
24
+ profile = `--profile ${options.profile}`;
25
+ }
26
+ // eslint-disable-next-line no-unsafe-optional-chaining
27
+ const { sourceRoot, root } = (_a = context === null || context === void 0 ? void 0 : context.workspace) === null || _a === void 0 ? void 0 : _a.projects[context.projectName];
28
+ return Object.assign(Object.assign({}, options), { parseArgs: parsedArgs, profile,
29
+ sourceRoot,
30
+ root });
31
+ }
32
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../../../../../packages/aws-cdk-v2/src/executors/bootstrap/bootstrap.ts"],"names":[],"mappings":";;AAYA,8BAOC;;AAlBD,6DAAwF;AAWxF,SAA8B,WAAW,CAAC,OAAgC,EAAE,OAAwB;;QAClG,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAE9D,OAAO;YACL,OAAO,EAAE,MAAM;SAChB,CAAC;IACJ,CAAC;CAAA;AAED,SAAS,YAAY,CAAC,OAAsC,EAAE,OAAwB;IACpF,MAAM,OAAO,GAAG,IAAA,6BAAa,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAgC,EAAE,OAAwB;;IAClF,MAAM,UAAU,GAAG,IAAA,yBAAS,EAAC,OAAO,CAAC,CAAC;IACtC,IAAI,OAAO,CAAC;IAEZ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;QAC7D,OAAO,GAAG,aAAa,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3C,CAAC;IAED,uDAAuD;IACvD,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/E,uCACK,OAAO,KACV,SAAS,EAAE,UAAU,EACrB,OAAO;QACP,UAAU;QACV,IAAI,IACJ;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export interface BootstrapExecutorSchema {
2
+ profile?: string;
3
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "title": "Bootstrap executor",
4
+ "description": "",
5
+ "type": "object",
6
+ "properties": {},
7
+ "required": []
8
+ }
@@ -0,0 +1,11 @@
1
+ import { DeployExecutorSchema } from './schema';
2
+ import { ParsedExecutorInterface } from '../../interfaces/parsed-executor.interface';
3
+ import { ExecutorContext } from '@nx/devkit';
4
+ export interface ParsedDeployExecutorOption extends ParsedExecutorInterface {
5
+ stacks?: string[];
6
+ sourceRoot: string;
7
+ root: string;
8
+ }
9
+ export default function runExecutor(options: DeployExecutorSchema, context: ExecutorContext): Promise<{
10
+ success: boolean;
11
+ }>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = runExecutor;
4
+ const tslib_1 = require("tslib");
5
+ 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 runDeploy(normalizedOptions, context);
10
+ return {
11
+ success: result,
12
+ };
13
+ });
14
+ }
15
+ function runDeploy(options, context) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ const command = (0, executor_util_1.createCommand)('deploy', options);
18
+ return (0, executor_util_1.runCommandProcess)(command, context.root);
19
+ });
20
+ }
21
+ function normalizeOptions(options, context) {
22
+ var _a;
23
+ const parsedArgs = (0, executor_util_1.parseArgs)(options);
24
+ let stacks;
25
+ if (Object.prototype.hasOwnProperty.call(options, 'stacks')) {
26
+ stacks = options.stacks;
27
+ }
28
+ // eslint-disable-next-line no-unsafe-optional-chaining
29
+ const { sourceRoot, root } = (_a = context === null || context === void 0 ? void 0 : context.workspace) === null || _a === void 0 ? void 0 : _a.projects[context.projectName];
30
+ return Object.assign(Object.assign({}, options), { parseArgs: parsedArgs, stacks,
31
+ sourceRoot,
32
+ root });
33
+ }
34
+ //# sourceMappingURL=deploy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../../../../packages/aws-cdk-v2/src/executors/deploy/deploy.ts"],"names":[],"mappings":";;AAWA,8BAOC;;AAjBD,6DAAwF;AAUxF,SAA8B,WAAW,CAAC,OAA6B,EAAE,OAAwB;;QAC/F,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAE3D,OAAO;YACL,OAAO,EAAE,MAAM;SAChB,CAAC;IACJ,CAAC;CAAA;AAED,SAAe,SAAS,CAAC,OAAmC,EAAE,OAAwB;;QACpF,MAAM,OAAO,GAAG,IAAA,6BAAa,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjD,OAAO,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;CAAA;AAED,SAAS,gBAAgB,CAAC,OAA6B,EAAE,OAAwB;;IAC/E,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,SAAS,0CAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/E,uCACK,OAAO,KACV,SAAS,EAAE,UAAU,EACrB,MAAM;QACN,UAAU;QACV,IAAI,IACJ;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export interface DeployExecutorSchema {
2
+ stacks?: string;
3
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "title": "deploy executor",
4
+ "description": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "stacks": {
8
+ "type": "string",
9
+ "description": "use deploy named STACKS"
10
+ }
11
+ },
12
+ "required": []
13
+ }
@@ -0,0 +1,12 @@
1
+ import { DestroyExecutorSchema } from './schema';
2
+ import { ParsedExecutorInterface } from '../../interfaces/parsed-executor.interface';
3
+ import { ExecutorContext } from '@nx/devkit';
4
+ export interface ParsedDestroyExecutorOption extends ParsedExecutorInterface {
5
+ stacks?: string[];
6
+ app?: string;
7
+ sourceRoot: string;
8
+ root: string;
9
+ }
10
+ export default function runExecutor(options: DestroyExecutorSchema, context: ExecutorContext): Promise<{
11
+ success: boolean;
12
+ }>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = runExecutor;
4
+ const tslib_1 = require("tslib");
5
+ 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
+ });
14
+ }
15
+ function runDestroy(options, context) {
16
+ const command = (0, executor_util_1.createCommand)('destroy', options);
17
+ return (0, executor_util_1.runCommandProcess)(command, context.root);
18
+ }
19
+ function normalizeOptions(options, context) {
20
+ var _a;
21
+ const parsedArgs = (0, executor_util_1.parseArgs)(options);
22
+ let stacks;
23
+ if (Object.prototype.hasOwnProperty.call(options, 'stacks')) {
24
+ stacks = options.stacks;
25
+ }
26
+ // eslint-disable-next-line no-unsafe-optional-chaining
27
+ const { sourceRoot, root } = (_a = context === null || context === void 0 ? void 0 : context.workspace) === null || _a === void 0 ? void 0 : _a.projects[context.projectName];
28
+ return Object.assign(Object.assign({}, options), { parseArgs: parsedArgs, stacks,
29
+ sourceRoot,
30
+ root });
31
+ }
32
+ //# sourceMappingURL=destroy.js.map
@@ -0,0 +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,SAAS,0CAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/E,uCACK,OAAO,KACV,SAAS,EAAE,UAAU,EACrB,MAAM;QACN,UAAU;QACV,IAAI,IACJ;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export interface DestroyExecutorSchema {
2
+ stacks?: string;
3
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "title": "Destroy executor",
4
+ "description": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "stacks": {
8
+ "type": "string",
9
+ "description": "use destroy named STACKS"
10
+ }
11
+ },
12
+ "required": []
13
+ }
@@ -0,0 +1,5 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { ApplicationSchema } from './schema';
3
+ export declare function applicationGenerator(host: Tree, options: ApplicationSchema): Promise<GeneratorCallback>;
4
+ export default applicationGenerator;
5
+ export declare const applicationSchematic: (generatorOptions: ApplicationSchema) => (tree: any, context: any) => Promise<any>;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applicationSchematic = void 0;
4
+ exports.applicationGenerator = applicationGenerator;
5
+ const tslib_1 = require("tslib");
6
+ const path = require("path");
7
+ const devkit_1 = require("@nx/devkit");
8
+ const jest_1 = require("@nx/jest");
9
+ const linter_1 = require("@nx/linter");
10
+ const init_1 = require("../init/init");
11
+ function normalizeOptions(host, options) {
12
+ var _a, _b;
13
+ const name = (0, devkit_1.names)(options.name).fileName;
14
+ const projectDirectory = options.directory ? `${(0, devkit_1.names)(options.directory).fileName}/${name}` : name;
15
+ const projectName = projectDirectory.replace(new RegExp('/', 'g'), '-');
16
+ const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectDirectory}`;
17
+ const parsedTags = options.tags ? options.tags.split(',').map((s) => s.trim()) : [];
18
+ return Object.assign(Object.assign({}, options), { projectName,
19
+ projectRoot,
20
+ projectDirectory,
21
+ parsedTags, linter: (_a = options.linter) !== null && _a !== void 0 ? _a : linter_1.Linter.EsLint, unitTestRunner: (_b = options.unitTestRunner) !== null && _b !== void 0 ? _b : 'jest' });
22
+ }
23
+ function addFiles(host, options) {
24
+ const templateOptions = Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.projectName)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot), template: '' });
25
+ (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
26
+ }
27
+ function addJestFiles(host, options) {
28
+ const templateOptions = Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.projectName)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot), template: '' });
29
+ (0, devkit_1.generateFiles)(host, path.join(__dirname, 'jest-files'), options.projectRoot, templateOptions);
30
+ }
31
+ function addLintingToApplication(tree, options) {
32
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
33
+ return yield (0, linter_1.lintProjectGenerator)(tree, {
34
+ linter: options.linter,
35
+ project: options.projectName,
36
+ tsConfigPaths: [(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.*?.json')],
37
+ eslintFilePatterns: [`${options.projectRoot}/**/*.ts`],
38
+ skipFormat: true,
39
+ setParserOptionsProject: options.setParserOptionsProject,
40
+ });
41
+ });
42
+ }
43
+ function updateLintConfig(tree, options) {
44
+ (0, devkit_1.updateJson)(tree, `${options.projectRoot}/.eslintrc.json`, (json) => {
45
+ json.plugins = (json === null || json === void 0 ? void 0 : json.plugins) || [];
46
+ const plugins = json.plugins;
47
+ const hasCdkPlugin = plugins.findIndex((row) => row === 'cdk') >= 0;
48
+ if (!hasCdkPlugin) {
49
+ plugins.push('cdk');
50
+ }
51
+ return json;
52
+ });
53
+ }
54
+ function applicationGenerator(host, options) {
55
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
56
+ const tasks = [];
57
+ const normalizedOptions = normalizeOptions(host, options);
58
+ const initTask = yield (0, init_1.initGenerator)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
59
+ tasks.push(initTask);
60
+ const project = {
61
+ root: normalizedOptions.projectRoot,
62
+ projectType: 'application',
63
+ sourceRoot: `${normalizedOptions.projectRoot}/src`,
64
+ targets: {
65
+ deploy: {
66
+ executor: '@wolsok/nx-aws-cdk-v2:deploy',
67
+ options: {},
68
+ },
69
+ destroy: {
70
+ executor: '@wolsok/nx-aws-cdk-v2:destroy',
71
+ options: {},
72
+ },
73
+ bootstrap: {
74
+ executor: '@wolsok/nx-aws-cdk-v2:bootstrap',
75
+ options: {},
76
+ },
77
+ },
78
+ tags: normalizedOptions.parsedTags,
79
+ };
80
+ (0, devkit_1.addProjectConfiguration)(host, normalizedOptions.projectName, project);
81
+ const workspace = (0, devkit_1.readWorkspaceConfiguration)(host);
82
+ (0, devkit_1.updateWorkspaceConfiguration)(host, workspace);
83
+ addFiles(host, normalizedOptions);
84
+ if (normalizedOptions.linter !== linter_1.Linter.None) {
85
+ const lintTask = yield addLintingToApplication(host, normalizedOptions);
86
+ tasks.push(lintTask);
87
+ updateLintConfig(host, normalizedOptions);
88
+ }
89
+ if (normalizedOptions.unitTestRunner === 'jest') {
90
+ const jestTask = yield (0, jest_1.jestProjectGenerator)(host, {
91
+ project: normalizedOptions.projectName,
92
+ setupFile: 'none',
93
+ skipSerializers: true,
94
+ supportTsx: false,
95
+ babelJest: false,
96
+ testEnvironment: 'node',
97
+ skipFormat: true,
98
+ });
99
+ tasks.push(jestTask);
100
+ addJestFiles(host, normalizedOptions);
101
+ }
102
+ if (!options.skipFormat) {
103
+ yield (0, devkit_1.formatFiles)(host);
104
+ }
105
+ return (0, devkit_1.runTasksInSerial)(...tasks);
106
+ });
107
+ }
108
+ exports.default = applicationGenerator;
109
+ exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
110
+ //# sourceMappingURL=application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../../../packages/aws-cdk-v2/src/generators/application/application.ts"],"names":[],"mappings":";;;AA6FA,oDA6DC;;AA1JD,6BAA6B;AAC7B,uCAgBoB;AACpB,mCAAgD;AAChD,uCAA0D;AAG1D,uCAA6C;AAS7C,SAAS,gBAAgB,CAAC,IAAU,EA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AC,IAAI,EAAE,CAAC;YAC7C,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;YACxE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,iBAAiB,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;YAChD,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAoB,EAAC,IAAI,EAAE;gBAChD,OAAO,EAAE,iBAAiB,CAAC,WAAW;gBACtC,SAAS,EAAE,MAAM;gBACjB,eAAe,EAAE,IAAI;gBACrB,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,KAAK;gBAChB,eAAe,EAAE,MAAM;gBACvB,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;YACH,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;AACD,kBAAe,oBAAoB,CAAC;AACvB,QAAA,oBAAoB,GAAG,IAAA,2BAAkB,EAAC,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ {
2
+ "app": "npx ts-node src/main.ts",
3
+ "output": "<%= offsetFromRoot %>dist/apps/<%= projectName %>",
4
+ "requireApproval": "never",
5
+ "watch": {
6
+ "include": [
7
+ "**"
8
+ ],
9
+ "exclude": [
10
+ "README.md",
11
+ "cdk*.json",
12
+ "**/*.d.ts",
13
+ "**/*.js",
14
+ "tsconfig.json",
15
+ "package*.json",
16
+ "yarn.lock",
17
+ "node_modules",
18
+ "test"
19
+ ]
20
+ },
21
+ "context": {
22
+ "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
23
+ "@aws-cdk/core:stackRelativeExports": true,
24
+ "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
25
+ "@aws-cdk/aws-lambda:recognizeVersionProps": true,
26
+ "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
27
+ "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
28
+ "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
29
+ "@aws-cdk/core:checkSecretUsage": true,
30
+ "@aws-cdk/aws-iam:minimizePolicies": true,
31
+ "@aws-cdk/core:target-partitions": [
32
+ "aws",
33
+ "aws-cn"
34
+ ]
35
+ }
36
+ }
@@ -0,0 +1,5 @@
1
+ import { App } from 'aws-cdk-lib';
2
+ import { AppStack } from './stacks/app-stack';
3
+
4
+ const app = new App();
5
+ new AppStack(app, '<%= projectName %>');
@@ -0,0 +1,9 @@
1
+ import { Stack, App, StackProps } from 'aws-cdk-lib';
2
+
3
+ export class AppStack extends Stack {
4
+ constructor(scope: App, id: string, props?: StackProps) {
5
+ super(scope, id, props);
6
+
7
+ // defines your stack here
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "<%= offsetFromRoot %>dist/out-tsc",
5
+ "types": ["node"]
6
+ },
7
+ "exclude": ["**/*.spec.ts", "**/*.test.ts"],
8
+ "include": ["**/*.ts"]
9
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "<%= offsetFromRoot %>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "outDir": "<%= offsetFromRoot %>dist/out-tsc",
6
+ "types": ["node", "jest"]
7
+ },
8
+ "include": [],
9
+ "files": [],
10
+ "references": [
11
+ {
12
+ "path": "./tsconfig.app.json"
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,13 @@
1
+ import { Stack, App } from 'aws-cdk-lib';
2
+ import { Template } from 'aws-cdk-lib/assertions';
3
+ import { AppStack } from './stacks/app-stack';
4
+
5
+ test('Empty Stack', () => {
6
+ const app = new App();
7
+ // WHEN
8
+ const stack = new AppStack(app, '<%= projectName %>TestStack');
9
+ // THEN
10
+ Template.fromStack(stack as Stack).templateMatches({
11
+ Resources: {}
12
+ });
13
+ });
@@ -0,0 +1,11 @@
1
+ import { Linter } from '@nx/linter';
2
+
3
+ export interface ApplicationSchema {
4
+ name: string;
5
+ tags?: string;
6
+ directory?: string;
7
+ skipFormat?: boolean;
8
+ linter?: Linter;
9
+ unitTestRunner?: 'jest' | 'none';
10
+ setParserOptionsProject?: boolean;
11
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "id": "AwsCdk",
4
+ "title": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What name would you like to use?"
15
+ },
16
+ "tags": {
17
+ "type": "string",
18
+ "description": "Add tags to the project (used for linting)",
19
+ "alias": "t"
20
+ },
21
+ "directory": {
22
+ "type": "string",
23
+ "description": "A directory where the project is placed",
24
+ "alias": "d"
25
+ },
26
+ "skipFormat": {
27
+ "description": "Skip formatting files",
28
+ "type": "boolean",
29
+ "default": false
30
+ },
31
+ "unitTestRunner": {
32
+ "description": "Adds the specified unit test runner",
33
+ "type": "string",
34
+ "enum": [
35
+ "jest",
36
+ "none"
37
+ ],
38
+ "default": "jest"
39
+ },
40
+ "linter": {
41
+ "description": "The tool to use for running lint checks.",
42
+ "type": "string",
43
+ "enum": [
44
+ "eslint",
45
+ "tslint"
46
+ ],
47
+ "default": "eslint"
48
+ },
49
+ "setParserOptionsProject": {
50
+ "type": "boolean",
51
+ "description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
52
+ "default": false
53
+ }
54
+ },
55
+ "required": [
56
+ "name"
57
+ ]
58
+ }
@@ -0,0 +1,5 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { InitGeneratorSchema } from './schema';
3
+ export declare function initGenerator(host: Tree, options: InitGeneratorSchema): Promise<() => Promise<void>>;
4
+ export default initGenerator;
5
+ export declare const initSchematic: (generatorOptions: InitGeneratorSchema) => (tree: any, context: any) => Promise<any>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initSchematic = void 0;
4
+ exports.initGenerator = initGenerator;
5
+ const tslib_1 = require("tslib");
6
+ const devkit_1 = require("@nx/devkit");
7
+ const jest_1 = require("@nx/jest");
8
+ const cdk_shared_1 = require("../../utils/cdk-shared");
9
+ function normalizeOptions(schema) {
10
+ var _a;
11
+ return Object.assign(Object.assign({}, schema), { unitTestRunner: (_a = schema.unitTestRunner) !== null && _a !== void 0 ? _a : 'jest' });
12
+ }
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
+ 'eslint-plugin-cdk': cdk_shared_1.CDK_ESLINT_VERSION,
26
+ });
27
+ if (!schema.skipFormat) {
28
+ yield (0, devkit_1.formatFiles)(host);
29
+ }
30
+ return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ if (jestInstall) {
32
+ yield jestInstall();
33
+ }
34
+ yield installTask();
35
+ });
36
+ });
37
+ }
38
+ exports.default = initGenerator;
39
+ exports.initSchematic = (0, devkit_1.convertNxGenerator)(initGenerator);
40
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/aws-cdk-v2/src/generators/init/init.ts"],"names":[],"mappings":";;;AAaA,sCA8BC;;AA3CD,uCAAoH;AACpH,mCAA6C;AAG7C,uDAAiG;AAEjG,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;YACE,mBAAmB,EAAE,+BAAkB;SACxC,CACF,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"}
@@ -0,0 +1,4 @@
1
+ export interface InitGeneratorSchema {
2
+ unitTestRunner?: 'jest' | 'none';
3
+ skipFormat?: boolean;
4
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "id": "AwsCdkInit",
4
+ "title": "Add AWS CDK Schematics",
5
+ "type": "object",
6
+ "properties": {
7
+ "unitTestRunner": {
8
+ "description": "Adds the specified unit test runner",
9
+ "type": "string",
10
+ "enum": [
11
+ "jest",
12
+ "none"
13
+ ],
14
+ "default": "jest"
15
+ },
16
+ "skipFormat": {
17
+ "description": "Skip formatting files",
18
+ "type": "boolean",
19
+ "default": false
20
+ }
21
+ },
22
+ "required": []
23
+ }
package/src/index.d.ts ADDED
File without changes
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/aws-cdk-v2/src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface ParsedExecutorInterface {
2
+ parseArgs?: Record<string, string | string[]>;
3
+ stacks?: string[];
4
+ sourceRoot: string;
5
+ root: string;
6
+ env?: Record<string, string>;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=parsed-executor.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsed-executor.interface.js","sourceRoot":"","sources":["../../../../../packages/aws-cdk-v2/src/interfaces/parsed-executor.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare const CDK_VERSION = "^2.77.0";
2
+ export declare const CDK_ESLINT_VERSION = "^1.8.0";
3
+ export declare const CDK_CONSTRUCTS_VERSION = "^10.2.10";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDK_CONSTRUCTS_VERSION = exports.CDK_ESLINT_VERSION = exports.CDK_VERSION = void 0;
4
+ exports.CDK_VERSION = '^2.77.0';
5
+ exports.CDK_ESLINT_VERSION = '^1.8.0';
6
+ exports.CDK_CONSTRUCTS_VERSION = '^10.2.10';
7
+ //# sourceMappingURL=cdk-shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdk-shared.js","sourceRoot":"","sources":["../../../../../packages/aws-cdk-v2/src/utils/cdk-shared.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,SAAS,CAAC;AACxB,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AAC9B,QAAA,sBAAsB,GAAG,UAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { DeployExecutorSchema } from '../executors/deploy/schema';
2
+ import { ParsedExecutorInterface } from '../interfaces/parsed-executor.interface';
3
+ import { BootstrapExecutorSchema } from '../executors/bootstrap/schema';
4
+ export declare const executorPropKeys: string[];
5
+ export declare const LARGE_BUFFER: number;
6
+ export declare function generateCommandString(command: string, appPath: string): string;
7
+ export declare function parseArgs(options: DeployExecutorSchema | BootstrapExecutorSchema): Record<string, string | string[]>;
8
+ export declare function createCommand(command: string, options: ParsedExecutorInterface): string;
9
+ export declare function runCommandProcess(command: string, cwd: string): Promise<boolean>;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.LARGE_BUFFER = exports.executorPropKeys = void 0;
5
+ exports.generateCommandString = generateCommandString;
6
+ exports.parseArgs = parseArgs;
7
+ exports.createCommand = createCommand;
8
+ exports.runCommandProcess = runCommandProcess;
9
+ const child_process_1 = require("child_process");
10
+ const devkit_1 = require("@nx/devkit");
11
+ exports.executorPropKeys = ['stacks'];
12
+ exports.LARGE_BUFFER = 1024 * 1000000;
13
+ const NX_WORKSPACE_ROOT = (_a = process.env.NX_WORKSPACE_ROOT) !== null && _a !== void 0 ? _a : '';
14
+ if (!NX_WORKSPACE_ROOT) {
15
+ throw new Error('CDK not Found');
16
+ }
17
+ function generateCommandString(command, appPath) {
18
+ const packageManager = (0, devkit_1.detectPackageManager)();
19
+ const packageManagerExecutor = packageManager === 'npm' ? 'npx' : packageManager;
20
+ const projectPath = `${NX_WORKSPACE_ROOT}/${appPath}`;
21
+ const generatePath = `"${packageManagerExecutor} ts-node --require tsconfig-paths/register --project ${projectPath}/tsconfig.app.json ${projectPath}/src/main.ts"`;
22
+ return `node --require ts-node/register ${NX_WORKSPACE_ROOT}/node_modules/aws-cdk/bin/cdk.js -a ${generatePath} ${command}`;
23
+ }
24
+ function parseArgs(options) {
25
+ const keys = Object.keys(options);
26
+ return keys
27
+ .filter((prop) => exports.executorPropKeys.indexOf(prop) < 0)
28
+ .reduce((acc, key) => ((acc[key] = options[key]), acc), {});
29
+ }
30
+ function createCommand(command, options) {
31
+ console.log('OptionsParsedExecutorInterface', JSON.stringify(options));
32
+ const nodeCommandWithRelativePath = generateCommandString(command, options.root);
33
+ console.log('nodeCommandWithRelativePath', nodeCommandWithRelativePath);
34
+ const commands = [nodeCommandWithRelativePath];
35
+ if (typeof options.stacks === 'string') {
36
+ commands.push(options.stacks);
37
+ }
38
+ for (const arg in options.parseArgs) {
39
+ const parsedArg = options.parseArgs[arg];
40
+ if (Array.isArray(parsedArg)) {
41
+ parsedArg.forEach((value) => {
42
+ commands.push(`--${arg} ${value}`);
43
+ });
44
+ }
45
+ else {
46
+ commands.push(`--${arg} ${parsedArg}`);
47
+ }
48
+ }
49
+ return commands.join(' ');
50
+ }
51
+ function runCommandProcess(command, cwd) {
52
+ return new Promise((resolve) => {
53
+ devkit_1.logger.debug(`Executing command: ${command}`);
54
+ const childProcess = (0, child_process_1.exec)(command, {
55
+ maxBuffer: exports.LARGE_BUFFER,
56
+ env: process.env,
57
+ cwd: cwd,
58
+ });
59
+ // Ensure the child process is killed when the parent exits
60
+ const processExitListener = () => childProcess.kill();
61
+ process.on('exit', processExitListener);
62
+ process.on('SIGTERM', processExitListener);
63
+ process.stdin.on('data', (data) => {
64
+ childProcess.stdin.write(data);
65
+ childProcess.stdin.end();
66
+ });
67
+ childProcess.stdout.on('data', (data) => {
68
+ process.stdout.write(data);
69
+ });
70
+ childProcess.stderr.on('data', (err) => {
71
+ process.stderr.write(err);
72
+ });
73
+ childProcess.on('close', (code) => {
74
+ if (code === 0) {
75
+ resolve(true);
76
+ }
77
+ else {
78
+ resolve(false);
79
+ }
80
+ process.removeListener('exit', processExitListener);
81
+ if (process.stdin.isTTY) {
82
+ process.stdin.end();
83
+ }
84
+ process.stdin.removeListener('data', processExitListener);
85
+ });
86
+ });
87
+ }
88
+ //# sourceMappingURL=executor.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.util.js","sourceRoot":"","sources":["../../../../../packages/aws-cdk-v2/src/utils/executor.util.ts"],"names":[],"mappings":";;;;AAeA,sDAMC;AAED,8BAKC;AAED,sCAuBC;AAED,8CA2CC;AAlGD,iDAAqC;AAIrC,uCAA0D;AAG7C,QAAA,gBAAgB,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,QAAA,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC;AAE3C,MAAM,iBAAiB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,iBAAiB,mCAAI,EAAE,CAAC;AAC9D,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACvB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,qBAAqB,CAAC,OAAe,EAAE,OAAe;IACpE,MAAM,cAAc,GAAG,IAAA,6BAAoB,GAAE,CAAC;IAC9C,MAAM,sBAAsB,GAAG,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC;IACjF,MAAM,WAAW,GAAG,GAAG,iBAAiB,IAAI,OAAO,EAAE,CAAC;IACtD,MAAM,YAAY,GAAG,IAAI,sBAAsB,wDAAwD,WAAW,sBAAsB,WAAW,eAAe,CAAC;IACnK,OAAO,mCAAmC,iBAAiB,uCAAuC,YAAY,IAAI,O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K,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAChC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YAED,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;YAEpD,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACtB,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ export declare function mockExecutorContext(executorName: string, workspaceVersion?: number): ExecutorContext;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockExecutorContext = mockExecutorContext;
4
+ function mockExecutorContext(executorName, workspaceVersion = 2) {
5
+ return {
6
+ projectName: 'proj',
7
+ root: '/root',
8
+ cwd: '/root',
9
+ workspace: {
10
+ version: workspaceVersion,
11
+ projects: {
12
+ proj: {
13
+ root: 'apps/proj',
14
+ targets: {
15
+ test: {
16
+ executor: `@wolsok/nx-aws-cdk-v2:${executorName}`,
17
+ },
18
+ },
19
+ },
20
+ },
21
+ },
22
+ target: {
23
+ executor: `@wolsok/nx-aws-cdk-v2:${executorName}`,
24
+ },
25
+ isVerbose: true,
26
+ };
27
+ }
28
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../../../../../packages/aws-cdk-v2/src/utils/testing.ts"],"names":[],"mappings":";;AAEA,kDAuBC;AAvBD,SAAgB,mBAAmB,CAAC,YAAoB,EAAE,gBAAgB,GAAG,CAAC;IAC5E,OAAO;QACL,WAAW,EAAE,MAAM;QACnB,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,OAAO;QACZ,SAAS,EAAE;YACT,OAAO,EAAE,gBAAgB;YACzB,QAAQ,EAAE;gBACR,IAAI,EAAE;oBACJ,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE;wBACP,IAAI,EAAE;4BACJ,QAAQ,EAAE,yBAAyB,YAAY,EAAE;yBAClD;qBACF;iBACF;aACF;SACF;QACD,MAAM,EAAE;YACN,QAAQ,EAAE,yBAAyB,YAAY,EAAE;SAClD;QACD,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC"}