@aws/nx-plugin 0.1.6 → 0.2.0
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 +114 -244
- package/generators.json +1 -7
- package/package.json +1 -1
- package/src/cloudscape-website/app/README.md +84 -48
- package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +157 -218
- package/src/cloudscape-website/app/files/app/README.md.template +44 -0
- package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +40 -43
- package/src/cloudscape-website/app/files/app/src/layouts/App/navitems.ts.template +3 -3
- package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +4 -6
- package/src/cloudscape-website/app/files/app/src/main.tsx.template +7 -10
- package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +0 -2
- package/src/cloudscape-website/app/files/common/constructs/src/app/static-websites/__websiteNameKebabCase__.ts.template +13 -0
- package/src/cloudscape-website/app/files/common/constructs/src/{__websiteNameKebabCase__ → core}/static-website.ts.template +74 -144
- package/src/cloudscape-website/app/generator.js +74 -64
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/app/schema.d.ts +3 -4
- package/src/cloudscape-website/app/schema.json +1 -24
- package/src/cloudscape-website/cognito-auth/README.md +53 -32
- package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +161 -125
- package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +53 -39
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/core/user-identity.ts.template +168 -0
- package/src/cloudscape-website/cognito-auth/generator.js +129 -46
- package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
- package/src/cloudscape-website/cognito-auth/schema.d.ts +1 -0
- package/src/cloudscape-website/cognito-auth/schema.json +7 -1
- package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +15 -17
- package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +7 -10
- package/src/cloudscape-website/runtime-config/files/app/hooks/useRuntimeConfig.tsx.template +13 -0
- package/src/cloudscape-website/runtime-config/generator.js +3 -1
- package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
- package/src/infra/app/README.md +71 -46
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +114 -252
- package/src/infra/app/files/app/README.md.template +76 -0
- package/src/infra/app/files/app/src/main.ts.template +18 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +1282 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +6839 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +2807 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +2585 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +2236 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +885 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +2205 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +63 -0
- package/src/infra/app/generator.js +17 -3
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.ts +10 -1
- package/src/infra/app/schema.json +16 -8
- package/src/trpc/backend/README.md +102 -80
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +37 -17
- package/src/trpc/backend/files/backend/README.md.template +33 -0
- package/src/trpc/backend/files/common/constructs/src/app/trpc-apis/__apiNameKebabCase__.ts.template +18 -0
- package/src/trpc/backend/files/common/constructs/src/{__apiNameKebabCase__/index.ts.template → core/trpc-api.ts.template} +12 -16
- package/src/trpc/backend/files/schema/README.md.template +33 -0
- package/src/trpc/backend/generator.js +29 -43
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +3 -1
- package/src/trpc/backend/schema.json +8 -13
- package/src/trpc/react/README.md +46 -66
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +104 -65
- package/src/trpc/react/files/src/components/TrpcClients/IsolatedTrpcProvider.tsx.template +75 -0
- package/src/trpc/react/files/src/components/TrpcClients/TrpcApis.tsx.template +1 -0
- package/src/trpc/react/files/src/components/TrpcClients/TrpcClientProviders.tsx.template +10 -0
- package/src/trpc/react/files/src/components/TrpcClients/index.tsx.template +5 -0
- package/src/trpc/react/files/src/hooks/useSigV4.tsx.template +38 -0
- package/src/trpc/react/files/src/hooks/use__apiNameClassName__.tsx.template +3 -0
- package/src/trpc/react/generator.js +123 -24
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.json +2 -2
- package/src/ts/cjs-to-esm/generator.js.map +1 -1
- package/src/ts/lib/eslint.d.ts +1 -1
- package/src/ts/lib/eslint.js +59 -11
- package/src/ts/lib/eslint.js.map +1 -1
- package/src/ts/lib/files/README.md.template +33 -0
- package/src/ts/lib/generator.js +11 -4
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.d.ts +1 -3
- package/src/ts/lib/schema.json +2 -15
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.js +14 -0
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/utils/ast.d.ts +13 -0
- package/src/utils/ast.js +102 -0
- package/src/utils/ast.js.map +1 -0
- package/src/utils/files/common/constructs/src/app/index.ts.template +0 -0
- package/src/utils/files/common/constructs/src/{runtime-config → core}/runtime-config.ts.template +3 -5
- package/src/utils/files/common/constructs/src/index.ts.template +2 -1
- package/src/utils/files/common/readme/README.md.template +33 -0
- package/src/utils/files/common/types/src/runtime-config.ts.template +1 -13
- package/src/utils/format.js.map +1 -1
- package/src/utils/names.d.ts +2 -0
- package/src/utils/names.js +27 -0
- package/src/utils/names.js.map +1 -0
- package/src/utils/npm-scope.js.map +1 -1
- package/src/utils/paths.js.map +1 -1
- package/src/utils/shared-constructs.js +37 -4
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/versions.d.ts +15 -9
- package/src/utils/versions.js +14 -8
- package/src/utils/versions.js.map +1 -1
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +0 -317
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +0 -4
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +0 -301
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +0 -4
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +0 -66
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +0 -70
- package/src/gitlab/generator.d.ts +0 -8
- package/src/gitlab/generator.js +0 -16
- package/src/gitlab/generator.js.map +0 -1
- package/src/gitlab/schema.d.ts +0 -9
- package/src/gitlab/schema.json +0 -52
- package/src/infra/app/files/src/main.ts.template +0 -37
- package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +0 -34
- package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +0 -5
- /package/src/infra/app/files/{cdk.json → app/cdk.json} +0 -0
- /package/src/infra/app/files/{src → app/src}/stacks/application-stack.ts.template +0 -0
- /package/src/utils/files/common/constructs/src/{runtime-config → core}/index.ts.template +0 -0
|
@@ -12,20 +12,23 @@ const typescript_1 = require("typescript");
|
|
|
12
12
|
const react_1 = require("@nx/react");
|
|
13
13
|
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
14
14
|
const npm_scope_1 = require("../../utils/npm-scope");
|
|
15
|
-
const lodash_kebabcase_1 = tslib_1.__importDefault(require("lodash.kebabcase"));
|
|
16
15
|
const ts_project_utils_1 = require("../../ts/lib/ts-project-utils");
|
|
17
16
|
const versions_1 = require("../../utils/versions");
|
|
18
17
|
const paths_1 = require("../../utils/paths");
|
|
19
18
|
const format_1 = require("../../utils/format");
|
|
19
|
+
const names_1 = require("../../utils/names");
|
|
20
|
+
const ast_1 = require("../../utils/ast");
|
|
20
21
|
function appGenerator(tree, schema) {
|
|
21
22
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
var _a, _b;
|
|
23
|
+
var _a, _b, _c;
|
|
23
24
|
const npmScopePrefix = (0, npm_scope_1.getNpmScopePrefix)(tree);
|
|
24
|
-
const
|
|
25
|
-
const
|
|
25
|
+
const websiteNameClassName = (0, names_1.toClassName)(schema.name);
|
|
26
|
+
const websiteNameKebabCase = (0, names_1.toKebabCase)(schema.name);
|
|
27
|
+
const fullyQualifiedName = `${npmScopePrefix}${websiteNameKebabCase}`;
|
|
28
|
+
const websiteContentPath = (0, devkit_1.joinPathFragments)((_a = schema.directory) !== null && _a !== void 0 ? _a : '.', websiteNameKebabCase);
|
|
26
29
|
// TODO: consider exposing and supporting e2e tests
|
|
27
30
|
const e2eTestRunner = 'none';
|
|
28
|
-
yield (0, react_1.applicationGenerator)(tree, Object.assign(Object.assign({}, schema), { name: fullyQualifiedName, directory: websiteContentPath, routing: false, addPlugin: true, e2eTestRunner }));
|
|
31
|
+
yield (0, react_1.applicationGenerator)(tree, Object.assign(Object.assign({}, schema), { name: fullyQualifiedName, directory: websiteContentPath, routing: false, addPlugin: (_b = schema.addPlugin) !== null && _b !== void 0 ? _b : true, e2eTestRunner, linter: 'eslint', bundler: 'vite', unitTestRunner: 'vitest' }));
|
|
29
32
|
if (!tree.exists(`${websiteContentPath}/project.json`)) {
|
|
30
33
|
(0, devkit_1.addProjectConfiguration)(tree, fullyQualifiedName, {
|
|
31
34
|
root: websiteContentPath,
|
|
@@ -33,7 +36,17 @@ function appGenerator(tree, schema) {
|
|
|
33
36
|
sourceRoot: `${websiteContentPath}/src`,
|
|
34
37
|
projectType: 'application',
|
|
35
38
|
tags: [],
|
|
36
|
-
targets: {
|
|
39
|
+
targets: {
|
|
40
|
+
'load:runtime-config': {
|
|
41
|
+
executor: 'nx:run-commands',
|
|
42
|
+
metadata: {
|
|
43
|
+
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`,
|
|
44
|
+
},
|
|
45
|
+
options: {
|
|
46
|
+
command: `cdk-app WebsiteBucket get --key runtime-config.json './${websiteContentPath}/public/runtime-config.json'`,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
37
50
|
});
|
|
38
51
|
}
|
|
39
52
|
(0, ts_project_utils_1.configureTsProject)(tree, {
|
|
@@ -41,24 +54,23 @@ function appGenerator(tree, schema) {
|
|
|
41
54
|
fullyQualifiedName,
|
|
42
55
|
});
|
|
43
56
|
yield (0, shared_constructs_1.sharedConstructsGenerator)(tree);
|
|
44
|
-
|
|
45
|
-
const constructsPath = (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', websiteNameKebabCase, 'index.ts');
|
|
46
|
-
if (!tree.exists(constructsPath)) {
|
|
57
|
+
if (!tree.exists((0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'static-websites', `${websiteNameKebabCase}.ts`))) {
|
|
47
58
|
const npmScopePrefix = (0, npm_scope_1.getNpmScopePrefix)(tree);
|
|
48
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', shared_constructs_1.SHARED_CONSTRUCTS_DIR), (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR), Object.assign(Object.assign({}, schema), { npmScopePrefix, scopeAlias: (0, npm_scope_1.toScopeAlias)(npmScopePrefix), websiteContentPath: (0, devkit_1.joinPathFragments)('dist', websiteContentPath), websiteNameKebabCase
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app'), (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app'), Object.assign(Object.assign({}, schema), { npmScopePrefix, scopeAlias: (0, npm_scope_1.toScopeAlias)(npmScopePrefix), websiteContentPath: (0, devkit_1.joinPathFragments)('dist', websiteContentPath), websiteNameKebabCase,
|
|
60
|
+
websiteNameClassName }), {
|
|
61
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
62
|
+
});
|
|
63
|
+
const shouldGenerateCoreStaticWebsiteConstruct = !tree.exists((0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core', 'static-website.ts'));
|
|
64
|
+
if (shouldGenerateCoreStaticWebsiteConstruct) {
|
|
65
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core'), (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core'), Object.assign(Object.assign({}, schema), { npmScopePrefix, scopeAlias: (0, npm_scope_1.toScopeAlias)(npmScopePrefix), websiteContentPath: (0, devkit_1.joinPathFragments)('dist', websiteContentPath), websiteNameKebabCase,
|
|
66
|
+
websiteNameClassName }), {
|
|
67
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'index.ts'), './static-websites/index.js');
|
|
71
|
+
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'static-websites', 'index.ts'), `./${websiteNameKebabCase}.js`);
|
|
72
|
+
if (shouldGenerateCoreStaticWebsiteConstruct) {
|
|
73
|
+
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core', 'index.ts'), './static-website.js');
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'project.json'), (config) => {
|
|
@@ -77,60 +89,58 @@ function appGenerator(tree, schema) {
|
|
|
77
89
|
});
|
|
78
90
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, fullyQualifiedName);
|
|
79
91
|
const libraryRoot = projectConfig.root;
|
|
80
|
-
tree.delete((0, devkit_1.joinPathFragments)(libraryRoot, 'src
|
|
92
|
+
tree.delete((0, devkit_1.joinPathFragments)(libraryRoot, 'src', 'app'));
|
|
81
93
|
(0, devkit_1.generateFiles)(tree, // the virtual file system
|
|
82
94
|
(0, devkit_1.joinPathFragments)(__dirname, './files/app'), // path to the file templates
|
|
83
|
-
libraryRoot, //
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
libraryRoot, Object.assign(Object.assign({}, schema), { fullyQualifiedName, pkgMgrCmd: (0, devkit_1.getPackageManagerCommand)().exec }), // config object to replace variable in file templates
|
|
96
|
+
{
|
|
97
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
|
|
98
|
+
});
|
|
86
99
|
if (e2eTestRunner !== 'none') {
|
|
87
100
|
const e2eFullyQualifiedName = `${fullyQualifiedName}-e2e`;
|
|
88
101
|
const e2eRoot = (0, devkit_1.readProjectConfiguration)(tree, e2eFullyQualifiedName).root;
|
|
89
102
|
(0, devkit_1.generateFiles)(tree, // the virtual file system
|
|
90
103
|
(0, devkit_1.joinPathFragments)(__dirname, `./files/e2e/${e2eTestRunner}`), // path to the file templates
|
|
91
|
-
e2eRoot, Object.assign(Object.assign({}, schema), (0, devkit_1.names)(fullyQualifiedName))
|
|
104
|
+
e2eRoot, Object.assign(Object.assign({}, schema), (0, devkit_1.names)(fullyQualifiedName)), {
|
|
105
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
106
|
+
});
|
|
92
107
|
(0, ts_project_utils_1.configureTsProject)(tree, {
|
|
93
108
|
fullyQualifiedName: e2eFullyQualifiedName,
|
|
94
109
|
dir: e2eRoot,
|
|
95
110
|
});
|
|
96
111
|
}
|
|
97
112
|
const viteConfigPath = (0, devkit_1.joinPathFragments)(libraryRoot, 'vite.config.ts');
|
|
98
|
-
const viteConfigContents = (
|
|
113
|
+
const viteConfigContents = (_c = tree.read(viteConfigPath)) === null || _c === void 0 ? void 0 : _c.toString();
|
|
99
114
|
if (viteConfigContents) {
|
|
100
115
|
let viteConfigUpdatedContents = viteConfigContents;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
typescript_1.factory.createPropertyAssignment('
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
return typescript_1.factory.createObjectLiteralExpression(updatedProperties, true);
|
|
131
|
-
})
|
|
132
|
-
.getFullText();
|
|
133
|
-
}
|
|
116
|
+
viteConfigUpdatedContents = tsquery_1.tsquery
|
|
117
|
+
.map((0, tsquery_1.ast)(viteConfigContents), 'ObjectLiteralExpression', (node) => {
|
|
118
|
+
return typescript_1.factory.createObjectLiteralExpression([
|
|
119
|
+
typescript_1.factory.createPropertyAssignment('define', typescript_1.factory.createObjectLiteralExpression([
|
|
120
|
+
typescript_1.factory.createPropertyAssignment('global', typescript_1.factory.createObjectLiteralExpression()),
|
|
121
|
+
], true)),
|
|
122
|
+
...node.properties,
|
|
123
|
+
], true);
|
|
124
|
+
})
|
|
125
|
+
.getFullText();
|
|
126
|
+
viteConfigUpdatedContents = tsquery_1.tsquery
|
|
127
|
+
.map((0, tsquery_1.ast)(viteConfigUpdatedContents), 'ObjectLiteralExpression', (node) => {
|
|
128
|
+
const updatedProperties = node.properties.map((prop) => {
|
|
129
|
+
if ((0, typescript_1.isPropertyAssignment)(prop) && prop.name.getText() === 'build') {
|
|
130
|
+
const buildConfig = prop.initializer;
|
|
131
|
+
return typescript_1.factory.createPropertyAssignment('build', typescript_1.factory.createObjectLiteralExpression(buildConfig.properties.map((buildProp) => {
|
|
132
|
+
if ((0, typescript_1.isPropertyAssignment)(buildProp) &&
|
|
133
|
+
buildProp.name.getText() === 'outDir') {
|
|
134
|
+
return typescript_1.factory.createPropertyAssignment('outDir', typescript_1.factory.createStringLiteral((0, devkit_1.joinPathFragments)((0, paths_1.getRelativePathToRoot)(tree, fullyQualifiedName), 'dist', websiteContentPath)));
|
|
135
|
+
}
|
|
136
|
+
return buildProp;
|
|
137
|
+
}), true));
|
|
138
|
+
}
|
|
139
|
+
return prop;
|
|
140
|
+
});
|
|
141
|
+
return typescript_1.factory.createObjectLiteralExpression(updatedProperties, true);
|
|
142
|
+
})
|
|
143
|
+
.getFullText();
|
|
134
144
|
if (viteConfigContents !== viteConfigUpdatedContents) {
|
|
135
145
|
tree.write(viteConfigPath, viteConfigUpdatedContents);
|
|
136
146
|
}
|
|
@@ -138,11 +148,11 @@ function appGenerator(tree, schema) {
|
|
|
138
148
|
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(websiteContentPath, 'tsconfig.json'), (tsconfig) => (Object.assign(Object.assign({}, tsconfig), { compilerOptions: Object.assign(Object.assign({}, tsconfig.compilerOptions), { moduleResolution: 'Bundler', module: 'Preserve' }) })));
|
|
139
149
|
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(websiteContentPath, 'tsconfig.app.json'), (tsconfig) => (Object.assign(Object.assign({}, tsconfig), { compilerOptions: Object.assign(Object.assign({}, tsconfig.compilerOptions), { lib: ['DOM'] }) })));
|
|
140
150
|
(0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)([
|
|
141
|
-
'@aws-northstar/ui',
|
|
142
151
|
'@cloudscape-design/components',
|
|
143
152
|
'@cloudscape-design/board-components',
|
|
153
|
+
'@cloudscape-design/global-styles',
|
|
144
154
|
'react-router-dom',
|
|
145
|
-
]),
|
|
155
|
+
]), (0, versions_1.withVersions)(['cdk-app-cli']));
|
|
146
156
|
yield (0, format_1.formatFilesInSubtree)(tree, websiteContentPath);
|
|
147
157
|
return () => {
|
|
148
158
|
if (!schema.skipInstall) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/app/generator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/app/generator.ts"],"names":[],"mappings":";;AAsCA,oCA6TC;;AAnWD;;;GAGG;AACH,uCAaoB;AACpB,uDAAyD;AACzD,2CAIoB;AAEpB,qCAAiD;AACjD,qEAIuC;AACvC,qDAAwE;AACxE,oEAAmE;AACnE,mDAAoD;AACpD,6CAA0D;AAC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;YAClC,kBAAkB;SACnB,CAAC,EACF,IAAA,uBAAY,EAAC,CAAC,aAAa,CAAC,CAAC,CAC9B,CAAC;QACF,MAAM,IAAA,6BAAoB,EAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACrD,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"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { SupportedStyles } from '@nx/react';
|
|
6
|
-
import { Linter } from '@nx/eslint';
|
|
7
6
|
|
|
8
7
|
export interface AppGeneratorSchema {
|
|
9
8
|
name: string;
|
|
@@ -11,12 +10,12 @@ export interface AppGeneratorSchema {
|
|
|
11
10
|
skipFormat?: boolean;
|
|
12
11
|
directory?: string;
|
|
13
12
|
tags?: string;
|
|
14
|
-
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
13
|
+
// unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
15
14
|
inSourceTests?: boolean;
|
|
16
15
|
// TODO: consider exposing if swc paths issue can be addressed https://github.com/swc-project/swc/discussions/8396
|
|
17
16
|
// or if alternative compiler can be used for e2e tests
|
|
18
17
|
// e2eTestRunner: 'cypress' | 'playwright' | 'none';
|
|
19
|
-
linter: Linter;
|
|
18
|
+
// linter: Linter;
|
|
20
19
|
pascalCaseFiles?: boolean;
|
|
21
20
|
classComponent?: boolean;
|
|
22
21
|
routing?: boolean;
|
|
@@ -30,7 +29,7 @@ export interface AppGeneratorSchema {
|
|
|
30
29
|
devServerPort?: number;
|
|
31
30
|
skipPackageJson?: boolean;
|
|
32
31
|
rootProject?: boolean;
|
|
33
|
-
bundler?: 'webpack' | 'vite' | 'rspack';
|
|
32
|
+
// bundler?: 'webpack' | 'vite' | 'rspack';
|
|
34
33
|
minimal?: boolean;
|
|
35
34
|
addPlugin?: boolean;
|
|
36
35
|
skipInstall?: boolean;
|
|
@@ -78,12 +78,6 @@
|
|
|
78
78
|
]
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
|
-
"linter": {
|
|
82
|
-
"description": "The tool to use for running lint checks.",
|
|
83
|
-
"type": "string",
|
|
84
|
-
"enum": ["eslint", "none"],
|
|
85
|
-
"default": "eslint"
|
|
86
|
-
},
|
|
87
81
|
"skipFormat": {
|
|
88
82
|
"description": "Skip formatting files.",
|
|
89
83
|
"type": "boolean",
|
|
@@ -96,14 +90,6 @@
|
|
|
96
90
|
"default": false,
|
|
97
91
|
"x-priority": "internal"
|
|
98
92
|
},
|
|
99
|
-
"unitTestRunner": {
|
|
100
|
-
"type": "string",
|
|
101
|
-
"enum": ["jest", "vitest", "none"],
|
|
102
|
-
"description": "Test runner to use for unit tests.",
|
|
103
|
-
"x-prompt": "Which unit test runner would you like to use?",
|
|
104
|
-
"default": "vitest",
|
|
105
|
-
"x-priority": "important"
|
|
106
|
-
},
|
|
107
93
|
"inSourceTests": {
|
|
108
94
|
"type": "boolean",
|
|
109
95
|
"default": false,
|
|
@@ -150,8 +136,7 @@
|
|
|
150
136
|
"type": "string",
|
|
151
137
|
"description": "The compiler to use.",
|
|
152
138
|
"enum": ["babel", "swc"],
|
|
153
|
-
"default": "swc"
|
|
154
|
-
"x-priority": "important"
|
|
139
|
+
"default": "swc"
|
|
155
140
|
},
|
|
156
141
|
"skipPackageJson": {
|
|
157
142
|
"description": "Do not add dependencies to `package.json`.",
|
|
@@ -165,14 +150,6 @@
|
|
|
165
150
|
"default": false,
|
|
166
151
|
"hidden": true
|
|
167
152
|
},
|
|
168
|
-
"bundler": {
|
|
169
|
-
"description": "The bundler to use.",
|
|
170
|
-
"type": "string",
|
|
171
|
-
"enum": ["vite", "webpack", "rspack"],
|
|
172
|
-
"x-prompt": "Which bundler do you want to use to build the application?",
|
|
173
|
-
"default": "vite",
|
|
174
|
-
"x-priority": "important"
|
|
175
|
-
},
|
|
176
153
|
"minimal": {
|
|
177
154
|
"description": "Generate a React app with a minimal setup, no separate test files.",
|
|
178
155
|
"type": "boolean",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Cognito Auth Generator
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
This generator adds AWS Cognito authentication to an existing Cloudscape React application. It sets up the necessary components and infrastructure for user authentication using Amazon Cognito hosted UI, including sign-in, sign-up, and password recovery flows. The generator integrates seamlessly with the Cloudscape Design System components and configures all required AWS resources through CDK.
|
|
5
6
|
|
|
6
7
|
## Prerequisites
|
|
7
8
|
|
|
@@ -12,14 +13,11 @@ Before using this generator, ensure your project meets these requirements:
|
|
|
12
13
|
3. The project must be a valid Cloudscape application
|
|
13
14
|
|
|
14
15
|
Example of required `main.tsx` structure:
|
|
16
|
+
|
|
15
17
|
```typescript
|
|
16
18
|
import { RuntimeConfigProvider } from './components/RuntimeConfig';
|
|
17
19
|
|
|
18
|
-
const App = () =>
|
|
19
|
-
<RuntimeConfigProvider>
|
|
20
|
-
{/* Your app components */}
|
|
21
|
-
</RuntimeConfigProvider>
|
|
22
|
-
);
|
|
20
|
+
const App = () => <RuntimeConfigProvider>{/* Your app components */}</RuntimeConfigProvider>;
|
|
23
21
|
```
|
|
24
22
|
|
|
25
23
|
If these prerequisites are not met, the generator will fail with an error.
|
|
@@ -31,12 +29,14 @@ You can add Cognito authentication to your Cloudscape website in two ways:
|
|
|
31
29
|
### 1. Using VSCode IDE
|
|
32
30
|
|
|
33
31
|
First, install the NX Console extension for VSCode:
|
|
32
|
+
|
|
34
33
|
1. Open VSCode
|
|
35
34
|
2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
|
|
36
35
|
3. Search for "Nx Console"
|
|
37
36
|
4. Install [Nx Console](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console)
|
|
38
37
|
|
|
39
38
|
Then add authentication:
|
|
39
|
+
|
|
40
40
|
1. Open the NX Console in VSCode
|
|
41
41
|
2. Click on "Generate"
|
|
42
42
|
3. Search for "cloudscape-website#cognito-auth"
|
|
@@ -48,62 +48,77 @@ Then add authentication:
|
|
|
48
48
|
### 2. Using CLI
|
|
49
49
|
|
|
50
50
|
Add authentication to your existing Cloudscape application:
|
|
51
|
+
|
|
51
52
|
```bash
|
|
52
|
-
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app
|
|
53
|
+
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app --cognito-domain=<your-domain-prefix>
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
Enable self-signup:
|
|
57
|
+
|
|
56
58
|
```bash
|
|
57
|
-
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app --allowSignup=true
|
|
59
|
+
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app --allowSignup=true --cognito-domain=<your-domain-prefix>
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
You can also perform a dry-run to see what files would be generated without actually creating them:
|
|
63
|
+
|
|
61
64
|
```bash
|
|
62
|
-
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app --dry-run
|
|
65
|
+
nx g @aws/nx-plugin:cloudscape-website#cognito-auth --project=my-cloudscape-app --cognito-domain=<your-domain-prefix> --dry-run
|
|
63
66
|
```
|
|
64
67
|
|
|
65
68
|
All methods will add Cognito authentication to your existing Cloudscape website application with all the necessary components and infrastructure code.
|
|
66
69
|
|
|
67
70
|
## Input Parameters
|
|
68
71
|
|
|
69
|
-
| Parameter
|
|
70
|
-
|
|
71
|
-
| project
|
|
72
|
-
|
|
|
72
|
+
| Parameter | Type | Default | Description |
|
|
73
|
+
| --------------- | ------- | ------- | ----------------------------------------------------------- |
|
|
74
|
+
| project\* | string | - | The root directory of the Cloudscape application (required) |
|
|
75
|
+
| cognitoDomain\* | string | - | domain prefix when creating the Cognito Hosted UI |
|
|
76
|
+
| allowSignup | boolean | false | Whether to allow self-signup |
|
|
73
77
|
|
|
74
|
-
|
|
78
|
+
\*Required parameter
|
|
75
79
|
|
|
76
80
|
## Expected Output
|
|
77
81
|
|
|
78
82
|
The generator adds authentication-related components and infrastructure:
|
|
79
83
|
|
|
80
84
|
### 1. React Components
|
|
85
|
+
|
|
81
86
|
```
|
|
82
|
-
<directory>/<
|
|
87
|
+
<directory>/<websiteProject>/
|
|
83
88
|
├── src/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
└── components/
|
|
90
|
+
| └── CognitoAuth/
|
|
91
|
+
| └── index.tsx # Main authentication component
|
|
92
|
+
└── layouts/
|
|
93
|
+
└── App/
|
|
94
|
+
└── index.tsx # Updates this file to add auth support
|
|
95
|
+
|
|
87
96
|
```
|
|
88
97
|
|
|
89
98
|
### 2. Infrastructure Code
|
|
99
|
+
|
|
90
100
|
```
|
|
91
|
-
common
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
common
|
|
102
|
+
└── constructs/
|
|
103
|
+
└── src/
|
|
104
|
+
└── core/
|
|
105
|
+
└── index.ts # Adds export for identity construct
|
|
106
|
+
└── user-identity.ts # Main identity construct
|
|
107
|
+
└── types/
|
|
108
|
+
└── src/
|
|
109
|
+
└── runtime-config.ts # Updates IRuntimeConfig to add cognitoProps
|
|
97
110
|
```
|
|
98
111
|
|
|
99
112
|
Additionally, it:
|
|
113
|
+
|
|
100
114
|
1. Installs required dependencies:
|
|
101
|
-
- @aws-northstar/ui
|
|
102
115
|
- aws-cdk-lib
|
|
103
116
|
- constructs
|
|
104
117
|
- @aws-cdk/aws-cognito-identitypool-alpha
|
|
118
|
+
- react-oidc-context
|
|
119
|
+
- oidc-client-ts
|
|
105
120
|
2. Updates the application's runtime configuration to include Cognito settings
|
|
106
|
-
3. Automatically integrates the authentication component into your
|
|
121
|
+
3. Automatically integrates the authentication component into your website code
|
|
107
122
|
|
|
108
123
|
## Infrastructure Architecture
|
|
109
124
|
|
|
@@ -111,36 +126,42 @@ Additionally, it:
|
|
|
111
126
|
graph TD
|
|
112
127
|
subgraph AWS Cloud
|
|
113
128
|
UP[Cognito User Pool] --> IP[Identity Pool]
|
|
129
|
+
UP --> CognitoDomain
|
|
114
130
|
UP --> Client[Web Client]
|
|
115
131
|
IP --> IAM[IAM Roles]
|
|
116
132
|
end
|
|
117
133
|
```
|
|
118
134
|
|
|
119
135
|
The infrastructure stack adds:
|
|
136
|
+
|
|
120
137
|
1. **Cognito User Pool**
|
|
138
|
+
|
|
121
139
|
- User directory management
|
|
122
140
|
- Sign-up and sign-in flows
|
|
123
141
|
- MFA configuration
|
|
124
142
|
|
|
125
143
|
2. **Cognito Identity Pool**
|
|
144
|
+
|
|
126
145
|
- Federated identities
|
|
127
146
|
- AWS credentials mapping
|
|
128
147
|
- IAM role assignment
|
|
129
148
|
|
|
130
149
|
3. **Web Client**
|
|
150
|
+
|
|
131
151
|
- User Password and SRP auth flows
|
|
132
152
|
- Token handling
|
|
133
153
|
|
|
154
|
+
4. **Cognito Domain**
|
|
155
|
+
- Domain configured using the cognitoDomain provided
|
|
156
|
+
|
|
134
157
|
## Authentication Components
|
|
135
158
|
|
|
136
159
|
The generator automatically sets up authentication in your application by:
|
|
160
|
+
|
|
137
161
|
1. Importing the CognitoAuth component in main.tsx
|
|
138
162
|
2. Wrapping your application with the CognitoAuth component inside the RuntimeConfigProvider
|
|
139
|
-
3. Configuring the
|
|
140
|
-
|
|
141
|
-
- Sign up form (if enabled)
|
|
142
|
-
- Password recovery
|
|
143
|
-
- MFA setup and verification
|
|
163
|
+
3. Configuring authenticated using the Cognito hosted UI
|
|
164
|
+
4. Updating the layout add add a singout button and display the logged in user.
|
|
144
165
|
|
|
145
166
|
No manual setup is required as the generator handles all the necessary component integration.
|
|
146
167
|
|
|
@@ -161,7 +182,7 @@ export class MyWebsiteStack extends Stack {
|
|
|
161
182
|
|
|
162
183
|
// Create the Cognito authentication resources
|
|
163
184
|
new UserIdentity(this, 'Identity');
|
|
164
|
-
|
|
185
|
+
|
|
165
186
|
// The runtime config is automatically updated with Cognito settings
|
|
166
187
|
}
|
|
167
188
|
}
|