@aws/nx-plugin 0.6.0 → 0.7.1
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.
- package/LICENSE-THIRD-PARTY +1761 -134
- package/generators.json +22 -10
- package/package.json +9 -1
- package/src/api-connection/README.md +0 -0
- package/src/api-connection/generator.d.ts +20 -0
- package/src/api-connection/generator.js +101 -0
- package/src/api-connection/generator.js.map +1 -0
- package/src/api-connection/schema.d.ts +10 -0
- package/src/api-connection/schema.json +32 -0
- package/src/cloudscape-website/app/README.md +3 -3
- package/src/cloudscape-website/app/generator.js +2 -2
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/cognito-auth/README.md +4 -4
- package/src/infra/app/README.md +3 -3
- package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +5 -1
- package/src/infra/app/generator.js +1 -1
- package/src/infra/app/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.d.ts +11 -0
- package/src/open-api/ts-hooks/generator.js +17 -0
- package/src/open-api/ts-hooks/generator.js.map +1 -0
- package/src/open-api/ts-hooks/schema.d.ts +9 -0
- package/src/open-api/ts-hooks/schema.json +20 -0
- package/src/open-api/utils/codegen-data/languages.d.ts +10 -0
- package/src/open-api/utils/codegen-data/languages.js +175 -0
- package/src/open-api/utils/codegen-data/languages.js.map +1 -0
- package/src/open-api/utils/codegen-data/types.d.ts +20 -0
- package/src/open-api/utils/codegen-data/types.js +19 -0
- package/src/open-api/utils/codegen-data/types.js.map +1 -0
- package/src/open-api/utils/codegen-data.d.ts +6 -0
- package/src/open-api/utils/codegen-data.js +434 -0
- package/src/open-api/utils/codegen-data.js.map +1 -0
- package/src/open-api/utils/normalise.d.ts +6 -0
- package/src/open-api/utils/normalise.js +213 -0
- package/src/open-api/utils/normalise.js.map +1 -0
- package/src/open-api/utils/parse.d.ts +10 -0
- package/src/open-api/utils/parse.js +38 -0
- package/src/open-api/utils/parse.js.map +1 -0
- package/src/open-api/utils/refs.d.ts +23 -0
- package/src/open-api/utils/refs.js +41 -0
- package/src/open-api/utils/refs.js.map +1 -0
- package/src/open-api/utils/types.d.ts +6 -0
- package/src/open-api/utils/types.js +3 -0
- package/src/open-api/utils/types.js.map +1 -0
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +33 -0
- package/src/py/fast-api/files/app/__name__/main.py.template +3 -1
- package/src/py/fast-api/generator.js +7 -2
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/project/generator.js +1 -1
- package/src/py/project/generator.js.map +1 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +7 -3
- package/src/trpc/backend/files/backend/src/init.ts.template +2 -0
- package/src/trpc/backend/generator.js +18 -3
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.json +1 -1
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.json +1 -1
- package/src/ts/lib/generator.js +1 -2
- package/src/ts/lib/generator.js.map +1 -1
- package/src/utils/ast.d.ts +4 -0
- package/src/utils/ast.js +10 -1
- package/src/utils/ast.js.map +1 -1
- package/src/utils/files/http-api/common/constructs/src/core/http-api.ts.template +5 -3
- package/src/utils/names.d.ts +2 -0
- package/src/utils/names.js +6 -1
- package/src/utils/names.js.map +1 -1
- package/src/utils/nx.d.ts +1 -1
- package/src/utils/nx.js +3 -3
- package/src/utils/nx.js.map +1 -1
package/generators.json
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"name": "pace",
|
|
4
4
|
"version": "0.0.1",
|
|
5
5
|
"generators": {
|
|
6
|
-
"ts#
|
|
6
|
+
"ts#project": {
|
|
7
7
|
"factory": "./src/ts/lib/generator",
|
|
8
8
|
"schema": "./src/ts/lib/schema.json",
|
|
9
|
-
"description": "Generates a TypeScript
|
|
9
|
+
"description": "Generates a TypeScript project"
|
|
10
10
|
},
|
|
11
11
|
"py#project": {
|
|
12
12
|
"factory": "./src/py/project/generator",
|
|
@@ -18,36 +18,48 @@
|
|
|
18
18
|
"schema": "./src/py/fast-api/schema.json",
|
|
19
19
|
"description": "Generates a FastAPI Python project"
|
|
20
20
|
},
|
|
21
|
-
"cloudscape-website
|
|
21
|
+
"ts#cloudscape-website": {
|
|
22
22
|
"factory": "./src/cloudscape-website/app/generator",
|
|
23
23
|
"schema": "./src/cloudscape-website/app/schema.json",
|
|
24
24
|
"description": "Generates a React static website based on Cloudscape"
|
|
25
25
|
},
|
|
26
|
-
"cloudscape-website#
|
|
26
|
+
"ts#cloudscape-website#auth": {
|
|
27
27
|
"factory": "./src/cloudscape-website/cognito-auth/generator",
|
|
28
28
|
"schema": "./src/cloudscape-website/cognito-auth/schema.json",
|
|
29
|
-
"description": "Adds
|
|
29
|
+
"description": "Adds auth to an existing cloudscape website"
|
|
30
30
|
},
|
|
31
|
-
"cloudscape-website#runtime-config": {
|
|
31
|
+
"ts#cloudscape-website#runtime-config": {
|
|
32
32
|
"factory": "./src/cloudscape-website/runtime-config/generator",
|
|
33
33
|
"schema": "./src/cloudscape-website/runtime-config/schema.json",
|
|
34
34
|
"description": "Adds runtime config to an existing cloudscape website",
|
|
35
35
|
"hidden": true
|
|
36
36
|
},
|
|
37
|
-
"infra
|
|
37
|
+
"ts#infra": {
|
|
38
38
|
"factory": "./src/infra/app/generator",
|
|
39
39
|
"schema": "./src/infra/app/schema.json",
|
|
40
40
|
"description": "Generates a cdk application"
|
|
41
41
|
},
|
|
42
|
-
"trpc
|
|
42
|
+
"ts#trpc-api": {
|
|
43
43
|
"factory": "./src/trpc/backend/generator",
|
|
44
44
|
"schema": "./src/trpc/backend/schema.json",
|
|
45
45
|
"description": "creates a trpc backend"
|
|
46
46
|
},
|
|
47
|
-
"trpc#react": {
|
|
47
|
+
"ts#trpc-api#react-connection": {
|
|
48
48
|
"factory": "./src/trpc/react/generator",
|
|
49
49
|
"schema": "./src/trpc/react/schema.json",
|
|
50
|
-
"description": "provides React integration to a React website"
|
|
50
|
+
"description": "provides React integration to a React website",
|
|
51
|
+
"hidden": true
|
|
52
|
+
},
|
|
53
|
+
"api-connection": {
|
|
54
|
+
"factory": "./src/api-connection/generator",
|
|
55
|
+
"schema": "./src/api-connection/schema.json",
|
|
56
|
+
"description": "Integrates a source project with a target API project"
|
|
57
|
+
},
|
|
58
|
+
"open-api#ts-hooks": {
|
|
59
|
+
"factory": "./src/open-api/ts-hooks/generator",
|
|
60
|
+
"schema": "./src/open-api/ts-hooks/schema.json",
|
|
61
|
+
"description": "Generate typescript hooks from an OpenAPI specification",
|
|
62
|
+
"hidden": true
|
|
51
63
|
},
|
|
52
64
|
"license": {
|
|
53
65
|
"factory": "./src/license/generator",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws/nx-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"nx": "20.4.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@apidevtools/swagger-parser": "^10.1.1",
|
|
19
|
+
"@hey-api/openapi-ts": "0.64.4",
|
|
18
20
|
"@iarna/toml": "^2.2.5",
|
|
19
21
|
"@nx/devkit": "^20.4.0",
|
|
20
22
|
"@nx/eslint": "^20.4.0",
|
|
@@ -24,9 +26,15 @@
|
|
|
24
26
|
"@nxlv/python": "^20.5.1",
|
|
25
27
|
"@phenomnomnominal/tsquery": "6.1.3",
|
|
26
28
|
"fast-glob": "^3.3.3",
|
|
29
|
+
"lodash.camelcase": "^4.3.0",
|
|
30
|
+
"lodash.trim": "^4.5.1",
|
|
31
|
+
"lodash.orderby": "^4.6.0",
|
|
32
|
+
"lodash.clonedeepwith": "^4.5.0",
|
|
27
33
|
"lodash.kebabcase": "4.1.1",
|
|
28
34
|
"lodash.snakecase": "4.1.1",
|
|
35
|
+
"lodash.uniqby": "^4.7.0",
|
|
29
36
|
"minimatch": "^10.0.1",
|
|
37
|
+
"openapi-types": "^12.1.3",
|
|
30
38
|
"typescript": "~5.5.4",
|
|
31
39
|
"vite": "^5.4.0",
|
|
32
40
|
"vitest": "^1.6.0"
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { Tree } from '@nx/devkit';
|
|
6
|
+
import { ApiConnectionSchema } from './schema';
|
|
7
|
+
/**
|
|
8
|
+
* List of supported source and target project types for api connections
|
|
9
|
+
*/
|
|
10
|
+
declare const SUPPORTED_PROJECT_TYPES: readonly ["ts#trpc-api", "react"];
|
|
11
|
+
type ProjectType = (typeof SUPPORTED_PROJECT_TYPES)[number];
|
|
12
|
+
/**
|
|
13
|
+
* Generator for a connection from a project to an API project
|
|
14
|
+
*/
|
|
15
|
+
export declare const apiConnectionGenerator: (tree: Tree, options: ApiConnectionSchema) => Promise<() => void>;
|
|
16
|
+
/**
|
|
17
|
+
* Determine whether the given project is of a known project type
|
|
18
|
+
*/
|
|
19
|
+
export declare const determineProjectType: (tree: Tree, projectName: string) => ProjectType | undefined;
|
|
20
|
+
export default apiConnectionGenerator;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.determineProjectType = exports.apiConnectionGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
const generator_1 = tslib_1.__importDefault(require("../trpc/react/generator"));
|
|
11
|
+
const ast_1 = require("../utils/ast");
|
|
12
|
+
/**
|
|
13
|
+
* List of supported source and target project types for api connections
|
|
14
|
+
*/
|
|
15
|
+
const SUPPORTED_PROJECT_TYPES = ['ts#trpc-api', 'react'];
|
|
16
|
+
/**
|
|
17
|
+
* Enumerates the supported project connections
|
|
18
|
+
*/
|
|
19
|
+
const SUPPORTED_CONNECTIONS = [
|
|
20
|
+
{ source: 'react', target: 'ts#trpc-api' },
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Generators for each connection type
|
|
24
|
+
*/
|
|
25
|
+
const CONNECTION_GENERATORS = {
|
|
26
|
+
'react -> ts#trpc-api': (tree, options) => (0, generator_1.default)(tree, {
|
|
27
|
+
frontendProjectName: options.sourceProject,
|
|
28
|
+
backendProjectName: options.targetProject,
|
|
29
|
+
auth: options.auth,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Generator for a connection from a project to an API project
|
|
34
|
+
*/
|
|
35
|
+
const apiConnectionGenerator = (tree, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const sourceType = (0, exports.determineProjectType)(tree, options.sourceProject);
|
|
37
|
+
const targetType = (0, exports.determineProjectType)(tree, options.targetProject);
|
|
38
|
+
if (!sourceType || !SUPPORTED_PROJECT_TYPES.includes(sourceType)) {
|
|
39
|
+
throw new Error(`This generator does not support selected source project ${options.sourceProject}`);
|
|
40
|
+
}
|
|
41
|
+
if (!targetType || !SUPPORTED_PROJECT_TYPES.includes(targetType)) {
|
|
42
|
+
throw new Error(`This generator does not support selected target project ${options.targetProject}`);
|
|
43
|
+
}
|
|
44
|
+
const connection = SUPPORTED_CONNECTIONS.find((c) => c.source === sourceType && c.target === targetType);
|
|
45
|
+
if (!connection) {
|
|
46
|
+
throw new Error(`This generator does not support a connection from ${options.sourceProject} (${sourceType}) to ${options.targetProject} (${targetType})`);
|
|
47
|
+
}
|
|
48
|
+
return yield CONNECTION_GENERATORS[`${connection.source} -> ${connection.target}`](tree, options);
|
|
49
|
+
});
|
|
50
|
+
exports.apiConnectionGenerator = apiConnectionGenerator;
|
|
51
|
+
/**
|
|
52
|
+
* Determine whether the given project is of a known project type
|
|
53
|
+
*/
|
|
54
|
+
const determineProjectType = (tree, projectName) => {
|
|
55
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
56
|
+
// NB: if adding new checks, ensure these go from most to least specific
|
|
57
|
+
// eg. react website is more specific than typescript project
|
|
58
|
+
if (isTrpcApi(tree, projectConfiguration)) {
|
|
59
|
+
return 'ts#trpc-api';
|
|
60
|
+
}
|
|
61
|
+
if (isReact(tree, projectConfiguration)) {
|
|
62
|
+
return 'react';
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
};
|
|
66
|
+
exports.determineProjectType = determineProjectType;
|
|
67
|
+
const sourceRoot = (projectConfiguration) => {
|
|
68
|
+
var _a;
|
|
69
|
+
return (_a = projectConfiguration.sourceRoot) !== null && _a !== void 0 ? _a : (0, devkit_1.joinPathFragments)(projectConfiguration.root, 'src');
|
|
70
|
+
};
|
|
71
|
+
const isTrpcApi = (tree, projectConfiguration) => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
// If the project.json says it's a trpc api, there's no need for introspection
|
|
74
|
+
if (((_a = projectConfiguration.metadata) === null || _a === void 0 ? void 0 : _a.apiType) === 'trpc') {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
// Find the src/index.ts
|
|
78
|
+
const indexTs = tree.read((0, devkit_1.joinPathFragments)(sourceRoot(projectConfiguration), 'index.ts'), 'utf-8');
|
|
79
|
+
if (indexTs === null) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
// If the index file exports an AppRouter, it's a trpc api
|
|
83
|
+
if ((0, ast_1.hasExportDeclaration)(indexTs, 'AppRouter')) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
// If there's a src/router.ts or src/lambdas/router.ts which exports an AppRouter, it's a trpc api
|
|
87
|
+
const trpcRouter = (_b = tree.read((0, devkit_1.joinPathFragments)(sourceRoot(projectConfiguration), 'router.ts'), 'utf-8')) !== null && _b !== void 0 ? _b : tree.read((0, devkit_1.joinPathFragments)(sourceRoot(projectConfiguration), 'lambdas', 'router.ts'), 'utf-8');
|
|
88
|
+
if (trpcRouter === null) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if ((0, ast_1.hasExportDeclaration)(trpcRouter, 'AppRouter')) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
};
|
|
96
|
+
const isReact = (tree, projectConfiguration) => {
|
|
97
|
+
// if there's a main.tsx, it's a react app
|
|
98
|
+
return tree.exists((0, devkit_1.joinPathFragments)(sourceRoot(projectConfiguration), 'main.tsx'));
|
|
99
|
+
};
|
|
100
|
+
exports.default = exports.apiConnectionGenerator;
|
|
101
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/api-connection/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAKoB;AAEpB,gFAAyD;AACzD,sCAAoD;AAEpD;;GAEG;AACH,MAAM,uBAAuB,GAAG,CAAC,aAAa,EAAE,OAAO,CAAU,CAAC;AAMlE;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC5B,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE;CACpB,CAAC;AAQzB;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC5B,sBAAsB,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CACxC,IAAA,mBAAkB,EAAC,IAAI,EAAE;QACvB,mBAAmB,EAAE,OAAO,CAAC,aAAa;QAC1C,kBAAkB,EAAE,OAAO,CAAC,aAAa;QACzC,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC;CAIL,CAA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BAAiB,EACf,UAAU,CAAC,oBAAoB,CAAC,EAChC,SAAS,EACT,WAAW,CACZ,EACD,OAAO,CACR,CAAC;IAEJ,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAA,0BAAoB,EAAC,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CACd,IAAU,EACV,oBAA0C,EACjC,EAAE;IACX,0CAA0C;IAC1C,OAAO,IAAI,CAAC,MAAM,CAChB,IAAA,0BAAiB,EAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE,UAAU,CAAC,CAChE,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,8BAAsB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "APIConnection",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"sourceProject": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "The project which will call the API",
|
|
15
|
+
"x-dropdown": "projects"
|
|
16
|
+
},
|
|
17
|
+
"targetProject": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "",
|
|
20
|
+
"x-prompt": "The project containing your API",
|
|
21
|
+
"x-dropdown": "projects"
|
|
22
|
+
},
|
|
23
|
+
"auth": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "",
|
|
26
|
+
"enum": ["IAM", "None"],
|
|
27
|
+
"x-prompt": "Select your API authentication strategy",
|
|
28
|
+
"default": "IAM"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"required": ["sourceProject", "targetProject"]
|
|
32
|
+
}
|
|
@@ -21,7 +21,7 @@ Then generate your application:
|
|
|
21
21
|
|
|
22
22
|
1. Open the NX Console in VSCode
|
|
23
23
|
2. Click on "Generate"
|
|
24
|
-
3. Search for "cloudscape-website
|
|
24
|
+
3. Search for "ts#cloudscape-website"
|
|
25
25
|
4. Fill in the required parameters in the form
|
|
26
26
|
5. Click "Run"
|
|
27
27
|
|
|
@@ -30,13 +30,13 @@ Then generate your application:
|
|
|
30
30
|
Generate the application:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
nx g @aws/nx-plugin:cloudscape-website
|
|
33
|
+
nx g @aws/nx-plugin:ts#cloudscape-website my-website --directory=apps/web
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
You can also perform a dry-run to see what files would be generated without actually creating them:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
nx g @aws/nx-plugin:cloudscape-website
|
|
39
|
+
nx g @aws/nx-plugin:ts#cloudscape-website my-website --directory=apps/web --dry-run
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Both methods will create a new Cloudscape website application in `apps/web/my-website` with all the necessary configuration and infrastructure code.
|
|
@@ -41,7 +41,7 @@ function appGenerator(tree, schema) {
|
|
|
41
41
|
description: `Load runtime config from your deployed stack for dev purposes. You must set the AWS_REGION and CDK_APP_DIR env variables whilst calling i.e: AWS_REGION=ap-southeast-2 CDK_APP_DIR=./dist/packages/infra/cdk.out pnpm exec nx run ${fullyQualifiedName}:load:runtime-config`,
|
|
42
42
|
},
|
|
43
43
|
options: {
|
|
44
|
-
command: `curl https://\`aws cloudformation describe-stacks --query "Stacks[?StackName=='infra-sandbox'][].Outputs[?contains(OutputKey, '
|
|
44
|
+
command: `curl https://\`aws cloudformation describe-stacks --query "Stacks[?StackName=='infra-sandbox'][].Outputs[?contains(OutputKey, 'DistributionDomainName')].OutputValue" --output text\`/runtime-config.json > './${websiteContentPath}/public/runtime-config.json'`,
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
const buildTarget = targets['build'];
|
|
@@ -66,7 +66,7 @@ function appGenerator(tree, schema) {
|
|
|
66
66
|
outputPath: (0, devkit_1.joinPathFragments)('dist', websiteContentPath),
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
|
-
projectConfiguration.targets = (0, nx_1.
|
|
69
|
+
projectConfiguration.targets = (0, nx_1.sortObjectKeys)(targets);
|
|
70
70
|
(0, devkit_1.updateProjectConfiguration)(tree, fullyQualifiedName, projectConfiguration);
|
|
71
71
|
(0, ts_project_utils_1.configureTsProject)(tree, {
|
|
72
72
|
dir: websiteContentPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/app/generator.ts"],"names":[],"mappings":";;AA6CA,oCA8YC;;AA3bD;;;GAGG;AACH,uCAaoB;AACpB,uDAAyD;AACzD,2CAKoB;AAEpB,qCAAiD;AACjD,qEAIuC;AACvC,qDAAwE;AACxE,oEAAmE;AACnE,mDAAoD;AACpD,6CAA0D;AAC1D,6CAA6D;AAC7D,yCAIyB;AACzB,+CAA0D;AAC1D,+BAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/app/generator.ts"],"names":[],"mappings":";;AA6CA,oCA8YC;;AA3bD;;;GAGG;AACH,uCAaoB;AACpB,uDAAyD;AACzD,2CAKoB;AAEpB,qCAAiD;AACjD,qEAIuC;AACvC,qDAAwE;AACxE,oEAAmE;AACnE,mDAAoD;AACpD,6CAA0D;AAC1D,6CAA6D;AAC7D,yCAIyB;AACzB,+CAA0D;AAC1D,+BAAgC;AAChC,uCAAgD;AAChD,SAAsB,YAAY,CAAC,IAAU,EAAE,MAA0B;;;QACvE,MAAM,cAAc,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,oB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AAI,EACJ,IAAA,0BAAiB,EAAC,kBAAkB,EAAE,mBAAmB,CAAC,EAC1D,CAAC,QAAQ,EAAE,EAAE,CAAC,iCACT,QAAQ,KACX,eAAe,kCACV,QAAQ,CAAC,eAAe,KAC3B,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,IAAA,0BAAiB,EAAC,OAAO,EAAE,0BAA0B,CAAC,EACvE,GAAG,EAAE,CAAC,KAAK,CAAC,OAEd,CACH,CAAC;QACF,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,uBAAY,EAAC;YACX,+BAA+B;YAC/B,qCAAqC;YACrC,kCAAkC;YAClC,wBAAwB;SACzB,CAAC,EACF,IAAA,uBAAY,EAAC,CAAC,yBAAyB,EAAE,qBAAqB,CAAC,CAAC,CACjE,CAAC;QAEF,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;gBACxB,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CAAA;AACD,kBAAe,YAAY,CAAC"}
|
|
@@ -39,7 +39,7 @@ Then add authentication:
|
|
|
39
39
|
|
|
40
40
|
1. Open the NX Console in VSCode
|
|
41
41
|
2. Click on "Generate"
|
|
42
|
-
3. Search for "cloudscape-website#cognito-auth"
|
|
42
|
+
3. Search for "ts#cloudscape-website#cognito-auth"
|
|
43
43
|
4. Fill in the required parameters:
|
|
44
44
|
- project: Your existing Cloudscape application name
|
|
45
45
|
- allowSignup: Whether to enable self-signup (optional)
|
|
@@ -50,19 +50,19 @@ Then add authentication:
|
|
|
50
50
|
Add authentication to your existing Cloudscape application:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
|
-
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app --cognito-domain=<your-domain-prefix>
|
|
53
|
+
nx g @aws/nx-plugin:ts#cloudscape-website#cognito-auth --project=my-cloudscape-app --cognito-domain=<your-domain-prefix>
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
Enable self-signup:
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app --allowSignup=true --cognito-domain=<your-domain-prefix>
|
|
59
|
+
nx g @aws/nx-plugin:ts#cloudscape-website#cognito-auth --project=my-cloudscape-app --allowSignup=true --cognito-domain=<your-domain-prefix>
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
You can also perform a dry-run to see what files would be generated without actually creating them:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app --cognito-domain=<your-domain-prefix> --dry-run
|
|
65
|
+
nx g @aws/nx-plugin:ts#cloudscape-website#cognito-auth --project=my-cloudscape-app --cognito-domain=<your-domain-prefix> --dry-run
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
All methods will add Cognito authentication to your existing Cloudscape website application with all the necessary components and infrastructure code.
|
package/src/infra/app/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Then generate your application:
|
|
|
21
21
|
|
|
22
22
|
1. Open the NX Console in VSCode
|
|
23
23
|
2. Click on "Generate"
|
|
24
|
-
3. Search for "infra
|
|
24
|
+
3. Search for "ts#infra"
|
|
25
25
|
4. Fill in the required parameters in the form
|
|
26
26
|
5. Click "Run"
|
|
27
27
|
|
|
@@ -30,13 +30,13 @@ Then generate your application:
|
|
|
30
30
|
Generate the application:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
nx g @aws/nx-plugin:infra
|
|
33
|
+
nx g @aws/nx-plugin:ts#infra my-infra --directory=apps/infrastructure
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
You can also perform a dry-run to see what files would be generated without actually creating them:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
nx g @aws/nx-plugin:infra
|
|
39
|
+
nx g @aws/nx-plugin:ts#infra my-infra --directory=apps/infrastructure --dry-run
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Input Parameters
|
|
@@ -26,7 +26,11 @@ export const suppressRule = (
|
|
|
26
26
|
const resources = (
|
|
27
27
|
predicate ? construct.node.findAll().filter(predicate) : [construct]
|
|
28
28
|
)
|
|
29
|
-
.map((resource) =>
|
|
29
|
+
.map((resource) => {
|
|
30
|
+
if (CfnResource.isCfnResource(resource)) {
|
|
31
|
+
return resource;
|
|
32
|
+
} else return resource.node.defaultChild;
|
|
33
|
+
})
|
|
30
34
|
.filter((resource) => CfnResource.isCfnResource(resource));
|
|
31
35
|
|
|
32
36
|
resources.forEach((resource) => {
|
|
@@ -64,7 +64,7 @@ function infraGenerator(tree, schema) {
|
|
|
64
64
|
command: `cdk deploy --require-approval=never --app ${synthDirFromProject}`,
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
|
-
config.targets = (0, nx_1.
|
|
67
|
+
config.targets = (0, nx_1.sortObjectKeys)(config.targets);
|
|
68
68
|
return config;
|
|
69
69
|
});
|
|
70
70
|
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core', 'index.ts'), './cfn-guard.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/infra/app/generator.ts"],"names":[],"mappings":";;AA+BA,wCAuHC;;AAtJD;;;GAGG;AACH,uCAYoB;AAEpB,4EAAyE;AACzE,mDAAoD;AACpD,qDAAwE;AACxE,qEAIuC;AACvC,yCAAgD;AAChD,wDAAwB;AACxB,+CAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/infra/app/generator.ts"],"names":[],"mappings":";;AA+BA,wCAuHC;;AAtJD;;;G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ache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { Tree } from '@nx/devkit';
|
|
6
|
+
import { OpenApiHooksSchema } from './schema';
|
|
7
|
+
/**
|
|
8
|
+
* Generates typescript hooks from an openapi spec
|
|
9
|
+
*/
|
|
10
|
+
export declare const openApiTsHooksGenerator: (tree: Tree, options: OpenApiHooksSchema) => Promise<void>;
|
|
11
|
+
export default openApiTsHooksGenerator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openApiTsHooksGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const parse_1 = require("../utils/parse");
|
|
6
|
+
const codegen_data_1 = require("../utils/codegen-data");
|
|
7
|
+
/**
|
|
8
|
+
* Generates typescript hooks from an openapi spec
|
|
9
|
+
*/
|
|
10
|
+
const openApiTsHooksGenerator = (tree, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
const spec = yield (0, parse_1.parseOpenApiSpec)(tree, options.openApiSpecPath);
|
|
12
|
+
yield (0, codegen_data_1.buildOpenApiCodeGenData)(spec);
|
|
13
|
+
// TODO: generate files!
|
|
14
|
+
});
|
|
15
|
+
exports.openApiTsHooksGenerator = openApiTsHooksGenerator;
|
|
16
|
+
exports.default = exports.openApiTsHooksGenerator;
|
|
17
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/open-api/ts-hooks/generator.ts"],"names":[],"mappings":";;;;AAMA,0CAAkD;AAClD,wDAAgE;AAEhE;;GAEG;AACI,MAAM,uBAAuB,GAAG,CACrC,IAAU,EACV,OAA2B,EAC3B,EAAE;IACF,MAAM,IAAI,GAAG,MAAM,IAAA,wBAAgB,EAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAEnE,MAAM,IAAA,sCAAuB,EAAC,IAAI,CAAC,CAAC;IAEpC,wBAAwB;AAC1B,CAAC,CAAA,CAAC;AATW,QAAA,uBAAuB,2BASlC;AAEF,kBAAe,+BAAuB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "OpenApiTsHooks",
|
|
4
|
+
"title": "OpenAPI TypeScript Hooks",
|
|
5
|
+
"description": "Generate TypeScript hooks from an OpenAPI specification",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"openApiSpecPath": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Path to the OpenAPI specification relative to the monorepo root",
|
|
11
|
+
"x-priority": "important"
|
|
12
|
+
},
|
|
13
|
+
"outputPath": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Path to the directory in which to generate the hooks relative to the monorepo root",
|
|
16
|
+
"x-priority": "important"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["openApiSpecPath", "outputPath"]
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Model } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Return the typescript type for the given model
|
|
4
|
+
*/
|
|
5
|
+
export declare const toTypeScriptType: (property: Model) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Return the python type for a given property
|
|
8
|
+
*/
|
|
9
|
+
export declare const toPythonType: (property: Model) => string;
|
|
10
|
+
export declare const toPythonName: (namedEntity: "model" | "property" | "operation", name: string) => string;
|