@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.
Files changed (115) hide show
  1. package/LICENSE-THIRD-PARTY +114 -244
  2. package/generators.json +1 -7
  3. package/package.json +1 -1
  4. package/src/cloudscape-website/app/README.md +84 -48
  5. package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +157 -218
  6. package/src/cloudscape-website/app/files/app/README.md.template +44 -0
  7. package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +40 -43
  8. package/src/cloudscape-website/app/files/app/src/layouts/App/navitems.ts.template +3 -3
  9. package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +4 -6
  10. package/src/cloudscape-website/app/files/app/src/main.tsx.template +7 -10
  11. package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +0 -2
  12. package/src/cloudscape-website/app/files/common/constructs/src/app/static-websites/__websiteNameKebabCase__.ts.template +13 -0
  13. package/src/cloudscape-website/app/files/common/constructs/src/{__websiteNameKebabCase__ → core}/static-website.ts.template +74 -144
  14. package/src/cloudscape-website/app/generator.js +74 -64
  15. package/src/cloudscape-website/app/generator.js.map +1 -1
  16. package/src/cloudscape-website/app/schema.d.ts +3 -4
  17. package/src/cloudscape-website/app/schema.json +1 -24
  18. package/src/cloudscape-website/cognito-auth/README.md +53 -32
  19. package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +161 -125
  20. package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +53 -39
  21. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/core/user-identity.ts.template +168 -0
  22. package/src/cloudscape-website/cognito-auth/generator.js +129 -46
  23. package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
  24. package/src/cloudscape-website/cognito-auth/schema.d.ts +1 -0
  25. package/src/cloudscape-website/cognito-auth/schema.json +7 -1
  26. package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +15 -17
  27. package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +7 -10
  28. package/src/cloudscape-website/runtime-config/files/app/hooks/useRuntimeConfig.tsx.template +13 -0
  29. package/src/cloudscape-website/runtime-config/generator.js +3 -1
  30. package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
  31. package/src/infra/app/README.md +71 -46
  32. package/src/infra/app/__snapshots__/generator.spec.ts.snap +114 -252
  33. package/src/infra/app/files/app/README.md.template +76 -0
  34. package/src/infra/app/files/app/src/main.ts.template +18 -0
  35. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +1282 -0
  36. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +6839 -0
  37. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +2807 -0
  38. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +2585 -0
  39. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +2236 -0
  40. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +885 -0
  41. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +2205 -0
  42. package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +63 -0
  43. package/src/infra/app/generator.js +17 -3
  44. package/src/infra/app/generator.js.map +1 -1
  45. package/src/infra/app/schema.d.ts +10 -1
  46. package/src/infra/app/schema.json +16 -8
  47. package/src/trpc/backend/README.md +102 -80
  48. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +37 -17
  49. package/src/trpc/backend/files/backend/README.md.template +33 -0
  50. package/src/trpc/backend/files/common/constructs/src/app/trpc-apis/__apiNameKebabCase__.ts.template +18 -0
  51. package/src/trpc/backend/files/common/constructs/src/{__apiNameKebabCase__/index.ts.template → core/trpc-api.ts.template} +12 -16
  52. package/src/trpc/backend/files/schema/README.md.template +33 -0
  53. package/src/trpc/backend/generator.js +29 -43
  54. package/src/trpc/backend/generator.js.map +1 -1
  55. package/src/trpc/backend/schema.d.ts +3 -1
  56. package/src/trpc/backend/schema.json +8 -13
  57. package/src/trpc/react/README.md +46 -66
  58. package/src/trpc/react/__snapshots__/generator.spec.ts.snap +104 -65
  59. package/src/trpc/react/files/src/components/TrpcClients/IsolatedTrpcProvider.tsx.template +75 -0
  60. package/src/trpc/react/files/src/components/TrpcClients/TrpcApis.tsx.template +1 -0
  61. package/src/trpc/react/files/src/components/TrpcClients/TrpcClientProviders.tsx.template +10 -0
  62. package/src/trpc/react/files/src/components/TrpcClients/index.tsx.template +5 -0
  63. package/src/trpc/react/files/src/hooks/useSigV4.tsx.template +38 -0
  64. package/src/trpc/react/files/src/hooks/use__apiNameClassName__.tsx.template +3 -0
  65. package/src/trpc/react/generator.js +123 -24
  66. package/src/trpc/react/generator.js.map +1 -1
  67. package/src/trpc/react/schema.json +2 -2
  68. package/src/ts/cjs-to-esm/generator.js.map +1 -1
  69. package/src/ts/lib/eslint.d.ts +1 -1
  70. package/src/ts/lib/eslint.js +59 -11
  71. package/src/ts/lib/eslint.js.map +1 -1
  72. package/src/ts/lib/files/README.md.template +33 -0
  73. package/src/ts/lib/generator.js +11 -4
  74. package/src/ts/lib/generator.js.map +1 -1
  75. package/src/ts/lib/schema.d.ts +1 -3
  76. package/src/ts/lib/schema.json +2 -15
  77. package/src/ts/lib/ts-project-utils.js.map +1 -1
  78. package/src/ts/lib/vitest.js +14 -0
  79. package/src/ts/lib/vitest.js.map +1 -1
  80. package/src/utils/ast.d.ts +13 -0
  81. package/src/utils/ast.js +102 -0
  82. package/src/utils/ast.js.map +1 -0
  83. package/src/utils/files/common/constructs/src/app/index.ts.template +0 -0
  84. package/src/utils/files/common/constructs/src/{runtime-config → core}/runtime-config.ts.template +3 -5
  85. package/src/utils/files/common/constructs/src/index.ts.template +2 -1
  86. package/src/utils/files/common/readme/README.md.template +33 -0
  87. package/src/utils/files/common/types/src/runtime-config.ts.template +1 -13
  88. package/src/utils/format.js.map +1 -1
  89. package/src/utils/names.d.ts +2 -0
  90. package/src/utils/names.js +27 -0
  91. package/src/utils/names.js.map +1 -0
  92. package/src/utils/npm-scope.js.map +1 -1
  93. package/src/utils/paths.js.map +1 -1
  94. package/src/utils/shared-constructs.js +37 -4
  95. package/src/utils/shared-constructs.js.map +1 -1
  96. package/src/utils/versions.d.ts +15 -9
  97. package/src/utils/versions.js +14 -8
  98. package/src/utils/versions.js.map +1 -1
  99. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +0 -317
  100. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +0 -4
  101. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +0 -301
  102. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +0 -4
  103. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +0 -66
  104. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +0 -70
  105. package/src/gitlab/generator.d.ts +0 -8
  106. package/src/gitlab/generator.js +0 -16
  107. package/src/gitlab/generator.js.map +0 -1
  108. package/src/gitlab/schema.d.ts +0 -9
  109. package/src/gitlab/schema.json +0 -52
  110. package/src/infra/app/files/src/main.ts.template +0 -37
  111. package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +0 -34
  112. package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +0 -5
  113. /package/src/infra/app/files/{cdk.json → app/cdk.json} +0 -0
  114. /package/src/infra/app/files/{src → app/src}/stacks/application-stack.ts.template +0 -0
  115. /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 fullyQualifiedName = `${npmScopePrefix}${schema.name}`;
25
- const websiteContentPath = (0, devkit_1.joinPathFragments)((_a = schema.directory) !== null && _a !== void 0 ? _a : '.', schema.name);
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
- const websiteNameKebabCase = (0, lodash_kebabcase_1.default)(schema.name);
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
- (0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)(['constructs', '@aws/pdk', 'cdk-nag', 'aws-cdk-lib']), (0, versions_1.withVersions)(['@aws-sdk/client-wafv2']));
50
- const sharedConstructsIndexTsPath = (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'index.ts');
51
- const sharedConstructsIndexContents = tree
52
- .read(sharedConstructsIndexTsPath)
53
- .toString();
54
- const staticWebsiteExportDeclaration = typescript_1.factory.createExportDeclaration(undefined, undefined, undefined, typescript_1.factory.createStringLiteral(`./${websiteNameKebabCase}/index.js`));
55
- const updatedIndex = tsquery_1.tsquery
56
- .map((0, tsquery_1.ast)(sharedConstructsIndexContents), 'SourceFile', (node) => {
57
- return Object.assign(Object.assign({}, node), { statements: [staticWebsiteExportDeclaration, ...node.statements] });
58
- })
59
- .getFullText();
60
- if (sharedConstructsIndexContents !== updatedIndex) {
61
- tree.write(sharedConstructsIndexTsPath, updatedIndex);
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/app'));
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, // destination path of the files
84
- schema // config object to replace variable in file templates
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 = (_b = tree.read(viteConfigPath)) === null || _b === void 0 ? void 0 : _b.toString();
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
- if (schema.unitTestRunner === 'vitest') {
102
- viteConfigUpdatedContents = tsquery_1.tsquery
103
- .map((0, tsquery_1.ast)(viteConfigContents), 'ObjectLiteralExpression', (node) => {
104
- return typescript_1.factory.createObjectLiteralExpression([
105
- typescript_1.factory.createPropertyAssignment('define', typescript_1.factory.createObjectLiteralExpression([
106
- typescript_1.factory.createPropertyAssignment('global', typescript_1.factory.createObjectLiteralExpression()),
107
- ], true)),
108
- ...node.properties,
109
- ], true);
110
- })
111
- .getFullText();
112
- }
113
- if (schema.bundler === 'vite') {
114
- viteConfigUpdatedContents = tsquery_1.tsquery
115
- .map((0, tsquery_1.ast)(viteConfigUpdatedContents), 'ObjectLiteralExpression', (node) => {
116
- const updatedProperties = node.properties.map((prop) => {
117
- if ((0, typescript_1.isPropertyAssignment)(prop) &&
118
- prop.name.getText() === 'build') {
119
- const buildConfig = prop.initializer;
120
- return typescript_1.factory.createPropertyAssignment('build', typescript_1.factory.createObjectLiteralExpression(buildConfig.properties.map((buildProp) => {
121
- if ((0, typescript_1.isPropertyAssignment)(buildProp) &&
122
- buildProp.name.getText() === 'outDir') {
123
- return typescript_1.factory.createPropertyAssignment('outDir', typescript_1.factory.createStringLiteral((0, devkit_1.joinPathFragments)((0, paths_1.getRelativePathToRoot)(tree, fullyQualifiedName), 'dist', websiteContentPath)));
124
- }
125
- return buildProp;
126
- }), true));
127
- }
128
- return prop;
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":";;AAqCA,oCAyRC;;AA9TD;;;GAGG;AACH,uCAWoB;AACpB,uDAAyD;AACzD,2CAKoB;AAEpB,qCAAiD;AACjD,qEAIuC;AACvC,qDAAwE;AACxE,gFAAyC;AACzC,oEAAmE;AACnE,mDAAoD;AACpD,6CAA0D;AAC1D,+CAA0D;AAE1D,SAAsB,YAAY,CAAC,IAAU,EAAE,MAA0B;;;QACvE,MAAM,cAAc,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,kBAAkB,GAAG,GAAG,cAAc,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7D,MAAM,kBAAkB,GAAG,IAAA,0BAAiB,EAC1C,MAAA,MAAM,CAAC,SAAS,mCAAI,GAAG,EACvB,MAAM,CAAC,IAAI,CACZ,CAAC;QAEF,mDAAmD;QACnD,MAAM,aAAa,GAAG,MAAM,CAAC;QAE7B,MAAM,IAAA,4BAAoB,EAAC,IAAI,kCAC1B,MAAM,KACT,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,IAAI,EACf,aAAa,IACb,CAAC;QAEH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,kBAAkB,eAAe,CAAC,EAAE,CAAC;YACvD,IAAA,gCAAuB,EAAC,IAAI,EAAE,kBAAkB,EAAE;gBAChD,IAAI,EAAE,kBAAkB;gBACxB,IAAI,EAAE,kBAAkB;gBACxB,UAAU,EAAE,GAAG,kBAAkB,MAAM;gBACvC,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,EAAE;gBACR,OAAO,EAAE,EAAE;aACZ,CAAC,CAAC;QACL,CAAC;QAED,IAAA,qCAAkB,EAAC,IAAI,EAAE;Y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AAC,CAAC,CAAC;oBACH,OAAO,oBAAO,CAAC,6BAA6B,CAC1C,iBAAiB,EACjB,IAAI,CACL,CAAC;gBACJ,CAAC,CACF;qBACA,WAAW,EAAE,CAAC;YACnB,CAAC;YAED,IAAI,kBAAkB,KAAK,yBAAyB,EAAE,CAAC;gBACrD,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QAED,IAAA,mBAAU,EACR,IAAI,EACJ,IAAA,0BAAiB,EAAC,kBAAkB,EAAE,eAAe,CAAC,EACtD,CAAC,QAAQ,EAAE,EAAE,CAAC,iCACT,QAAQ,KACX,eAAe,kCACV,QAAQ,CAAC,eAAe,KAC3B,gBAAgB,EAAE,SAAS,EAC3B,MAAM,EAAE,UAAU,OAEpB,CACH,CAAC;QAEF,IAAA,mBAAU,EACR,IAAI,EACJ,IAAA,0BAAiB,EAAC,kBAAkB,EAAE,mBAAmB,CAAC,EAC1D,CAAC,QAAQ,EAAE,EAAE,CAAC,iCACT,QAAQ,KACX,eAAe,kCACV,QAAQ,CAAC,eAAe,KAC3B,GAAG,EAAE,CAAC,KAAK,CAAC,OAEd,CACH,CAAC;QAEF,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,uBAAY,EAAC;YACX,mBAAmB;YACnB,+BAA+B;YAC/B,qCAAqC;YACrC,kBAAkB;SACnB,CAAC,EACF,EAAE,CACH,CAAC;QAEF,MAAM,IAAA,6BAAoB,EAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QAErD,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;AAED,kBAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/app/generator.ts"],"names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CACV,QAAQ,CAAC,eAAe,KAC3B,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,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
- 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, 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.
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 | Type | Default | Description |
70
- |-----------|------|---------|-------------|
71
- | project* | string | - | The root directory of the Cloudscape application (required) |
72
- | allowSignup | boolean | false | Whether to allow self-signup |
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
- *Required parameter
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>/<project>/
87
+ <directory>/<websiteProject>/
83
88
  ├── src/
84
- └── components/
85
- └── CognitoAuth/
86
- └── index.tsx # Main authentication component
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/constructs/
92
- ├── src/
93
- └── identity/
94
- │ ├── index.ts # Exports for identity constructs
95
- │ ├── user-identity.ts # Main identity construct
96
- └── userpool-with-mfa.ts # User pool configuration
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 application's main.tsx
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 authentication UI with:
140
- - Sign in form
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
  }