@aws/nx-plugin 0.1.6 → 0.2.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.
Files changed (126) hide show
  1. package/LICENSE-THIRD-PARTY +1554 -3241
  2. package/generators.json +1 -13
  3. package/package.json +14 -14
  4. package/src/cloudscape-website/app/README.md +84 -48
  5. package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +168 -233
  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 +79 -144
  14. package/src/cloudscape-website/app/generator.js +90 -74
  15. package/src/cloudscape-website/app/generator.js.map +1 -1
  16. package/src/cloudscape-website/app/schema.d.ts +3 -5
  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 +162 -124
  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 +130 -47
  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 +20 -15
  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 +4 -2
  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 +184 -305
  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 +36 -7
  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 +42 -19
  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 +30 -44
  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 +124 -25
  66. package/src/trpc/react/generator.js.map +1 -1
  67. package/src/trpc/react/schema.json +2 -2
  68. package/src/ts/lib/__snapshots__/generator.spec.ts.snap +47 -93
  69. package/src/ts/lib/eslint.d.ts +1 -2
  70. package/src/ts/lib/eslint.js +62 -21
  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 +44 -5
  74. package/src/ts/lib/generator.js.map +1 -1
  75. package/src/ts/lib/schema.d.ts +1 -4
  76. package/src/ts/lib/schema.json +2 -21
  77. package/src/ts/lib/ts-project-utils.js +3 -18
  78. package/src/ts/lib/ts-project-utils.js.map +1 -1
  79. package/src/ts/lib/vitest.js +12 -0
  80. package/src/ts/lib/vitest.js.map +1 -1
  81. package/src/utils/ast.d.ts +13 -0
  82. package/src/utils/ast.js +102 -0
  83. package/src/utils/ast.js.map +1 -0
  84. package/src/utils/files/common/constructs/src/app/index.ts.template +0 -0
  85. package/src/utils/files/common/constructs/src/{runtime-config → core}/runtime-config.ts.template +3 -5
  86. package/src/utils/files/common/constructs/src/index.ts.template +2 -1
  87. package/src/utils/files/common/readme/README.md.template +33 -0
  88. package/src/utils/files/common/types/src/runtime-config.ts.template +2 -13
  89. package/src/utils/format.d.ts +1 -1
  90. package/src/utils/format.js +2 -2
  91. package/src/utils/format.js.map +1 -1
  92. package/src/utils/names.d.ts +2 -0
  93. package/src/utils/names.js +27 -0
  94. package/src/utils/names.js.map +1 -0
  95. package/src/utils/npm-scope.js.map +1 -1
  96. package/src/utils/paths.js.map +1 -1
  97. package/src/utils/shared-constructs.js +37 -4
  98. package/src/utils/shared-constructs.js.map +1 -1
  99. package/src/utils/test.d.ts +2 -0
  100. package/src/utils/test.js +19 -0
  101. package/src/utils/test.js.map +1 -0
  102. package/src/utils/versions.d.ts +15 -9
  103. package/src/utils/versions.js +14 -8
  104. package/src/utils/versions.js.map +1 -1
  105. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +0 -317
  106. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +0 -4
  107. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +0 -301
  108. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +0 -4
  109. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +0 -66
  110. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +0 -70
  111. package/src/gitlab/generator.d.ts +0 -8
  112. package/src/gitlab/generator.js +0 -16
  113. package/src/gitlab/generator.js.map +0 -1
  114. package/src/gitlab/schema.d.ts +0 -9
  115. package/src/gitlab/schema.json +0 -52
  116. package/src/infra/app/files/src/main.ts.template +0 -37
  117. package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +0 -34
  118. package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +0 -5
  119. package/src/ts/cjs-to-esm/generator.d.ts +0 -12
  120. package/src/ts/cjs-to-esm/generator.js +0 -189
  121. package/src/ts/cjs-to-esm/generator.js.map +0 -1
  122. package/src/ts/cjs-to-esm/schema.d.ts +0 -9
  123. package/src/ts/cjs-to-esm/schema.json +0 -28
  124. /package/src/infra/app/files/{cdk.json → app/cdk.json} +0 -0
  125. /package/src/infra/app/files/{src → app/src}/stacks/application-stack.ts.template +0 -0
  126. /package/src/utils/files/common/constructs/src/{runtime-config → core}/index.ts.template +0 -0
@@ -10,8 +10,11 @@ const devkit_1 = require("@nx/devkit");
10
10
  const typescript_1 = require("typescript");
11
11
  const tsquery_1 = require("@phenomnomnominal/tsquery");
12
12
  const generator_1 = require("../../cloudscape-website/runtime-config/generator");
13
+ const shared_constructs_1 = require("../../utils/shared-constructs");
13
14
  const npm_scope_1 = require("../../utils/npm-scope");
14
15
  const versions_1 = require("../../utils/versions");
16
+ const ast_1 = require("../../utils/ast");
17
+ const names_1 = require("../../utils/names");
15
18
  const format_1 = require("../../utils/format");
16
19
  function reactGenerator(tree, options) {
17
20
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -20,45 +23,141 @@ function reactGenerator(tree, options) {
20
23
  const backendProjectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.backendProjectName);
21
24
  /* eslint-disable @typescript-eslint/no-explicit-any */
22
25
  const apiName = (_a = backendProjectConfig.metadata) === null || _a === void 0 ? void 0 : _a.apiName;
23
- (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), frontendProjectConfig.root, Object.assign(Object.assign({ apiName }, options), { backendProjectAlias: (0, npm_scope_1.toScopeAlias)(options.backendProjectName) }));
26
+ const apiNameClassName = (0, names_1.toClassName)(apiName);
27
+ const backendProjectAlias = (0, npm_scope_1.toScopeAlias)(options.backendProjectName);
28
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), frontendProjectConfig.root, Object.assign(Object.assign({ apiName, apiNameClassName: (0, names_1.toClassName)(apiName) }, options), { backendProjectAlias: (0, npm_scope_1.toScopeAlias)(options.backendProjectName) }), {
29
+ overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
30
+ });
31
+ if (options.auth !== 'IAM') {
32
+ tree.delete(`${frontendProjectConfig.root}/src/hooks/useSigV4.tsx`);
33
+ }
24
34
  yield (0, generator_1.runtimeConfigGenerator)(tree, {
25
35
  project: options.frontendProjectName,
26
36
  });
37
+ // Update runtime-config.ts with ApiUrl type and trpcApis property
38
+ const runtimeConfigPath = (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.TYPE_DEFINITIONS_DIR, 'src', 'runtime-config.ts');
39
+ const runtimeConfigContent = tree.read(runtimeConfigPath).toString();
40
+ const sourceFile = (0, tsquery_1.ast)(runtimeConfigContent);
41
+ // Check if ApiUrl type exists
42
+ const existingApiUrl = tsquery_1.tsquery.query(sourceFile, 'TypeAliasDeclaration[name.text="ApiUrl"]');
43
+ // Check if trpcApis property exists in IRuntimeConfig
44
+ const existingTrpcApis = tsquery_1.tsquery.query(sourceFile, 'InterfaceDeclaration[name.text="IRuntimeConfig"] PropertySignature[name.text="trpcApis"]');
45
+ let updatedContent = sourceFile;
46
+ // Add ApiUrl type if it doesn't exist
47
+ if (existingApiUrl.length === 0) {
48
+ const apiUrlType = typescript_1.factory.createTypeAliasDeclaration([typescript_1.factory.createModifier(typescript_1.SyntaxKind.ExportKeyword)], typescript_1.factory.createIdentifier('ApiUrl'), undefined, typescript_1.factory.createKeywordTypeNode(typescript_1.SyntaxKind.StringKeyword));
49
+ updatedContent = tsquery_1.tsquery.map(updatedContent, 'SourceFile', (node) => {
50
+ return typescript_1.factory.updateSourceFile(node, [apiUrlType, ...node.statements]);
51
+ });
52
+ }
53
+ // Add empty trpcApis to IRuntimeConfig if it doesn't exist
54
+ if (existingTrpcApis.length === 0) {
55
+ updatedContent = tsquery_1.tsquery.map(updatedContent, 'InterfaceDeclaration[name.text="IRuntimeConfig"]', (node) => {
56
+ const trpcApisProperty = typescript_1.factory.createPropertySignature(undefined, typescript_1.factory.createIdentifier('trpcApis'), undefined, typescript_1.factory.createTypeLiteralNode([]));
57
+ return typescript_1.factory.updateInterfaceDeclaration(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, [...node.members, trpcApisProperty]);
58
+ });
59
+ }
60
+ // Check if apiNameClassName property exists in trpcApis
61
+ const existingApiNameProperty = tsquery_1.tsquery.query(updatedContent, `InterfaceDeclaration[name.text="IRuntimeConfig"] PropertySignature[name.text="trpcApis"] TypeLiteral PropertySignature[name.text="${apiNameClassName}"]`);
62
+ // Add apiNameClassName property to trpcApis if it doesn't exist
63
+ if (existingApiNameProperty.length === 0) {
64
+ updatedContent = tsquery_1.tsquery.map(updatedContent, 'InterfaceDeclaration[name.text="IRuntimeConfig"] PropertySignature[name.text="trpcApis"] TypeLiteral', (node) => {
65
+ return typescript_1.factory.createTypeLiteralNode([
66
+ ...node.members,
67
+ typescript_1.factory.createPropertySignature(undefined, typescript_1.factory.createIdentifier(apiNameClassName), undefined, typescript_1.factory.createTypeReferenceNode('ApiUrl', undefined)),
68
+ ]);
69
+ });
70
+ }
71
+ // Only write if changes were made
72
+ if (updatedContent !== sourceFile) {
73
+ tree.write(runtimeConfigPath, updatedContent.getFullText());
74
+ }
75
+ // update main.tsx
27
76
  const mainTsxPath = (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'main.tsx');
28
- if (!tree.exists(mainTsxPath)) {
29
- throw new Error(`Could not find main.tsx in ${frontendProjectConfig.sourceRoot}`);
77
+ (0, ast_1.singleImport)(tree, mainTsxPath, 'TrpcClientProviders', './components/TrpcClients');
78
+ // Check if TrpcClientProviders already exists
79
+ const mainTsxSource = tree.read(mainTsxPath).toString();
80
+ const mainTsxAst = (0, tsquery_1.ast)(mainTsxSource);
81
+ const hasProvider = tsquery_1.tsquery.query(mainTsxAst, 'JsxOpeningElement[tagName.name="TrpcClientProviders"]').length > 0;
82
+ if (!hasProvider) {
83
+ (0, ast_1.replace)(tree, mainTsxPath, 'JsxSelfClosingElement[tagName.name="App"]', (node) => (0, ast_1.createJsxElementFromIdentifier)('TrpcClientProviders', [node]));
30
84
  }
31
- const mainTsxContents = tree.read(mainTsxPath).toString();
32
- const trpcProviderImport = typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier('TRPCClientProvider'), undefined), typescript_1.factory.createStringLiteral('./components/TRPCClientProvider'));
33
- const updatedImports = tsquery_1.tsquery
34
- .map((0, tsquery_1.ast)(mainTsxContents), 'SourceFile', (node) => {
35
- return Object.assign(Object.assign({}, node), { statements: [trpcProviderImport, ...node.statements] });
36
- })
37
- .getFullText();
38
- let locatedNode = false;
39
- const mainTsxUpdatedContents = tsquery_1.tsquery
40
- .map((0, tsquery_1.ast)(updatedImports), 'JsxSelfClosingElement', (node) => {
41
- if (node.tagName.getText() !== 'App') {
85
+ // update TrpcApis.tsx
86
+ const trpcApisPath = (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'components/TrpcClients/TrpcApis.tsx');
87
+ // Add imports if they don't exist
88
+ (0, ast_1.destructuredImport)(tree, trpcApisPath, ['createIsolatedTrpcClientProvider'], './IsolatedTrpcProvider');
89
+ (0, ast_1.destructuredImport)(tree, trpcApisPath, [
90
+ `AppRouter as ${apiNameClassName}AppRouter`,
91
+ `Context as ${apiNameClassName}Context`,
92
+ ], backendProjectAlias);
93
+ // Update the export object only if API doesn't exist
94
+ (0, ast_1.replace)(tree, trpcApisPath, 'ExportAssignment > ObjectLiteralExpression', (node) => {
95
+ const existingProperties = node.properties;
96
+ if (existingProperties.find((p) => { var _a; return ((_a = p.name) === null || _a === void 0 ? void 0 : _a.getText()) === apiNameClassName; })) {
42
97
  return node;
43
98
  }
44
- else {
45
- locatedNode = true;
46
- }
47
- return typescript_1.factory.createJsxElement(typescript_1.factory.createJsxOpeningElement(typescript_1.factory.createIdentifier('TRPCClientProvider'), undefined, typescript_1.factory.createJsxAttributes([])), [node], typescript_1.factory.createJsxClosingElement(typescript_1.factory.createIdentifier('TRPCClientProvider')));
48
- })
49
- .getFullText();
50
- if (!locatedNode) {
51
- throw new Error('Could not locate App component in main.tsx');
99
+ const newProperty = typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier(apiNameClassName), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('createIsolatedTrpcClientProvider'), [
100
+ typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier(`${apiNameClassName}AppRouter`)),
101
+ typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier(`${apiNameClassName}Context`)),
102
+ ], []));
103
+ return typescript_1.factory.createObjectLiteralExpression([...existingProperties, newProperty], true);
104
+ });
105
+ // update TrpcClientProviders.tsx
106
+ const trpcClientProvidersPath = (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'components/TrpcClients/TrpcClientProviders.tsx');
107
+ // Add imports
108
+ (0, ast_1.destructuredImport)(tree, trpcClientProvidersPath, ['useRuntimeConfig'], '../../hooks/useRuntimeConfig');
109
+ (0, ast_1.singleImport)(tree, trpcClientProvidersPath, 'TrpcApis', './TrpcApis');
110
+ // Check if useContext hook exists and add if it doesn't add it
111
+ const providersSource = tree.read(trpcClientProvidersPath).toString();
112
+ const providersAst = (0, tsquery_1.ast)(providersSource);
113
+ const hasRuntimeConfig = tsquery_1.tsquery.query(providersAst, 'VariableDeclaration[name.name="runtimeConfig"] CallExpression[expression.name="useRuntimeConfig"]').length > 0;
114
+ if (!hasRuntimeConfig) {
115
+ (0, ast_1.replace)(tree, trpcClientProvidersPath, 'ArrowFunction > Block', (node) => {
116
+ const existingStatements = [...node.statements];
117
+ const runtimeContextVar = typescript_1.factory.createVariableStatement(undefined, typescript_1.factory.createVariableDeclarationList([
118
+ typescript_1.factory.createVariableDeclaration('runtimeConfig', undefined, undefined, typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('useRuntimeConfig'), undefined, [])),
119
+ ], typescript_1.NodeFlags.Const));
120
+ // Insert the runtimeContext declaration before the return statement
121
+ existingStatements.splice(existingStatements.length - 1, 0, runtimeContextVar);
122
+ return typescript_1.factory.createBlock(existingStatements, true);
123
+ });
52
124
  }
53
- if (mainTsxContents !== mainTsxUpdatedContents) {
54
- tree.write(mainTsxPath, mainTsxUpdatedContents);
125
+ // Check if API provider already exists
126
+ const trpcProviderSource = tree.read(trpcClientProvidersPath).toString();
127
+ const trpcProviderAst = (0, tsquery_1.ast)(trpcProviderSource);
128
+ const hasTrpcProvider = tsquery_1.tsquery.query(trpcProviderAst, `JsxOpeningElement PropertyAccessExpression:has(Identifier[name="Provider"]) PropertyAccessExpression:has(Identifier[name="${apiNameClassName}"]) Identifier[name="TrpcApis"]`).length > 0;
129
+ if (!hasTrpcProvider) {
130
+ // Transform the return statement only if provider doesn't exist
131
+ (0, ast_1.replace)(tree, trpcClientProvidersPath, 'ReturnStatement', (node) => {
132
+ var _a;
133
+ const existingExpression = (0, typescript_1.isParenthesizedExpression)(node.expression)
134
+ ? (_a = node.expression) === null || _a === void 0 ? void 0 : _a.expression
135
+ : node.expression;
136
+ return typescript_1.factory.createReturnStatement(typescript_1.factory.createJsxElement(typescript_1.factory.createJsxOpeningElement(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('TrpcApis'), typescript_1.factory.createIdentifier(apiNameClassName)), typescript_1.factory.createIdentifier('Provider')), undefined, typescript_1.factory.createJsxAttributes([
137
+ typescript_1.factory.createJsxAttribute(typescript_1.factory.createIdentifier('apiUrl'), typescript_1.factory.createJsxExpression(undefined, typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('runtimeConfig'), typescript_1.factory.createIdentifier('trpcApis')), typescript_1.factory.createIdentifier(apiNameClassName)))),
138
+ ])), [
139
+ (0, typescript_1.isJsxChild)(existingExpression) ||
140
+ (0, typescript_1.isJsxElement)(existingExpression) ||
141
+ (0, typescript_1.isJsxFragment)(existingExpression) ||
142
+ (0, typescript_1.isJsxSelfClosingElement)(existingExpression) ||
143
+ (0, typescript_1.isJsxExpression)(existingExpression)
144
+ ? existingExpression
145
+ : typescript_1.factory.createJsxExpression(undefined, existingExpression),
146
+ ], typescript_1.factory.createJsxClosingElement(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('TrpcApis'), typescript_1.factory.createIdentifier(apiNameClassName)), typescript_1.factory.createIdentifier('Provider')))));
147
+ });
55
148
  }
56
149
  (0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)([
150
+ '@aws-sdk/client-cognito-identity',
151
+ '@aws-sdk/credential-provider-cognito-identity',
57
152
  '@trpc/client',
58
153
  '@trpc/react-query',
59
154
  '@tanstack/react-query',
155
+ 'aws4fetch',
156
+ ...(options.auth === 'IAM'
157
+ ? ['oidc-client-ts', 'react-oidc-context']
158
+ : []),
60
159
  ]), {});
61
- yield (0, format_1.formatFilesInSubtree)(tree, frontendProjectConfig.root);
160
+ yield (0, format_1.formatFilesInSubtree)(tree);
62
161
  return () => {
63
162
  (0, devkit_1.installPackagesTask)(tree);
64
163
  };
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/react/generator.ts"],"names":[],"mappings":";;AAyBA,wCA+GC;;AAxID;;;GAGG;AACH,uCAOoB;AAEpB,2CAKoB;AACpB,uDAAyD;AACzD,iFAA2F;AAC3F,qDAAqD;AACrD,mDAAoD;AACpD,+CAA0D;AAE1D,SAAsB,cAAc,CAClC,IAAU,EACV,OAA6B;;;QAE7B,MAAM,qBAAqB,GAAG,IAAA,iCAAwB,EACpD,IAAI,EACJ,OAAO,CAAC,mBAAmB,CAC5B,CAAC;QACF,MAAM,oBAAoB,GAAG,IAAA,iCAAwB,EACnD,IAAI,EACJ,OAAO,CAAC,kBAAkB,CAC3B,CAAC;QACF,uDAAuD;QACvD,MAAM,OAAO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ACJ,CAAC,CACF,CAAC;QACJ,CAAC;QACD,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,uBAAY,EAAC;YACX,kCAAkC;YAClC,+CAA+C;YAC/C,cAAc;YACd,mBAAmB;YACnB,uBAAuB;YACvB,WAAW;YACX,GAAI,CAAC,OAAO,CAAC,IAAI,KAAK,KAAK;gBACzB,CAAC,CAAC,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;gBAC1C,CAAC,CAAC,EAAE,CAAS;SAChB,CAAC,EACF,EAAE,CACH,CAAC;QACF,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AACD,kBAAe,cAAc,CAAC"}
@@ -23,10 +23,10 @@
23
23
  "auth": {
24
24
  "type": "string",
25
25
  "description": "",
26
+ "enum": ["IAM", "NONE"],
26
27
  "x-prompt": "Select your API authentication strategy",
27
- "x-dropdown": ["IAM", "None"],
28
28
  "default": "IAM"
29
29
  }
30
30
  },
31
- "required": ["frontendProjectName", "backendProjectName", "auth"]
31
+ "required": ["frontendProjectName", "backendProjectName"]
32
32
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  exports[`ts lib generator > should generate library with custom directory > custom-dir-index.ts 1`] = `
4
4
  "export function hello() {
5
- return "Hello!";
5
+ return "Hello!";
6
6
  }
7
7
  "
8
8
  `;
@@ -17,23 +17,11 @@ exports[`ts lib generator > should generate library with custom directory > cust
17
17
  "targets": {
18
18
  "build": {
19
19
  "dependsOn": [
20
- "compile",
21
20
  "lint",
21
+ "compile",
22
22
  "test"
23
23
  ]
24
24
  },
25
- "lint": {
26
- "executor": "@nx/eslint:lint"
27
- },
28
- "test": {
29
- "executor": "@nx/vite:test",
30
- "outputs": [
31
- "{options.reportsDirectory}"
32
- ],
33
- "options": {
34
- "reportsDirectory": "../../coverage/libs/test-lib"
35
- }
36
- },
37
25
  "compile": {
38
26
  "executor": "@nx/js:tsc",
39
27
  "outputs": [
@@ -42,11 +30,23 @@ exports[`ts lib generator > should generate library with custom directory > cust
42
30
  "options": {
43
31
  "outputPath": "dist/libs/test-lib",
44
32
  "main": "libs/test-lib/src/index.ts",
45
- "tsConfig": "libs/test-lib/tsconfig.lib.json",
33
+ "tsConfig": "libs/test-lib/tsconfig.json",
46
34
  "assets": [
47
35
  "libs/test-lib/*.md"
48
36
  ]
49
37
  }
38
+ },
39
+ "lint": {
40
+ "executor": "@nx/eslint:lint"
41
+ },
42
+ "test": {
43
+ "executor": "@nx/vite:test",
44
+ "outputs": [
45
+ "{options.reportsDirectory}"
46
+ ],
47
+ "options": {
48
+ "reportsDirectory": "../../coverage/libs/test-lib"
49
+ }
50
50
  }
51
51
  }
52
52
  }
@@ -56,7 +56,6 @@ exports[`ts lib generator > should generate library with custom directory > cust
56
56
  exports[`ts lib generator > should generate library with custom directory > custom-dir-tsconfig.json 1`] = `
57
57
  "{
58
58
  "extends": "../../tsconfig.base.json",
59
- "compilerOptions": {},
60
59
  "files": [],
61
60
  "include": [],
62
61
  "references": [
@@ -66,14 +65,22 @@ exports[`ts lib generator > should generate library with custom directory > cust
66
65
  {
67
66
  "path": "./tsconfig.spec.json"
68
67
  }
69
- ]
68
+ ],
69
+ "compilerOptions": {}
70
70
  }
71
71
  "
72
72
  `;
73
73
 
74
- exports[`ts lib generator > should generate library with custom scope > scoped-project.json 1`] = `
74
+ exports[`ts lib generator > should generate library with default options > index.ts 1`] = `
75
+ "export function hello() {
76
+ return "Hello!";
77
+ }
78
+ "
79
+ `;
80
+
81
+ exports[`ts lib generator > should generate library with default options > project.json 1`] = `
75
82
  "{
76
- "name": "@custom/test-lib",
83
+ "name": "@proj/test-lib",
77
84
  "$schema": "../node_modules/nx/schemas/project-schema.json",
78
85
  "sourceRoot": "test-lib/src",
79
86
  "projectType": "library",
@@ -81,23 +88,11 @@ exports[`ts lib generator > should generate library with custom scope > scoped-p
81
88
  "targets": {
82
89
  "build": {
83
90
  "dependsOn": [
84
- "compile",
85
91
  "lint",
92
+ "compile",
86
93
  "test"
87
94
  ]
88
95
  },
89
- "lint": {
90
- "executor": "@nx/eslint:lint"
91
- },
92
- "test": {
93
- "executor": "@nx/vite:test",
94
- "outputs": [
95
- "{options.reportsDirectory}"
96
- ],
97
- "options": {
98
- "reportsDirectory": "../coverage/test-lib"
99
- }
100
- },
101
96
  "compile": {
102
97
  "executor": "@nx/js:tsc",
103
98
  "outputs": [
@@ -106,38 +101,11 @@ exports[`ts lib generator > should generate library with custom scope > scoped-p
106
101
  "options": {
107
102
  "outputPath": "dist/test-lib",
108
103
  "main": "test-lib/src/index.ts",
109
- "tsConfig": "test-lib/tsconfig.lib.json",
104
+ "tsConfig": "test-lib/tsconfig.json",
110
105
  "assets": [
111
106
  "test-lib/*.md"
112
107
  ]
113
108
  }
114
- }
115
- }
116
- }
117
- "
118
- `;
119
-
120
- exports[`ts lib generator > should generate library with default options > index.ts 1`] = `
121
- "export function hello() {
122
- return "Hello!";
123
- }
124
- "
125
- `;
126
-
127
- exports[`ts lib generator > should generate library with default options > project.json 1`] = `
128
- "{
129
- "name": "@proj/test-lib",
130
- "$schema": "../node_modules/nx/schemas/project-schema.json",
131
- "sourceRoot": "test-lib/src",
132
- "projectType": "library",
133
- "tags": [],
134
- "targets": {
135
- "build": {
136
- "dependsOn": [
137
- "compile",
138
- "lint",
139
- "test"
140
- ]
141
109
  },
142
110
  "lint": {
143
111
  "executor": "@nx/eslint:lint"
@@ -150,20 +118,6 @@ exports[`ts lib generator > should generate library with default options > proje
150
118
  "options": {
151
119
  "reportsDirectory": "../coverage/test-lib"
152
120
  }
153
- },
154
- "compile": {
155
- "executor": "@nx/js:tsc",
156
- "outputs": [
157
- "{options.outputPath}"
158
- ],
159
- "options": {
160
- "outputPath": "dist/test-lib",
161
- "main": "test-lib/src/index.ts",
162
- "tsConfig": "test-lib/tsconfig.lib.json",
163
- "assets": [
164
- "test-lib/*.md"
165
- ]
166
- }
167
121
  }
168
122
  }
169
123
  }
@@ -173,7 +127,6 @@ exports[`ts lib generator > should generate library with default options > proje
173
127
  exports[`ts lib generator > should generate library with default options > tsconfig.json 1`] = `
174
128
  "{
175
129
  "extends": "../tsconfig.base.json",
176
- "compilerOptions": {},
177
130
  "files": [],
178
131
  "include": [],
179
132
  "references": [
@@ -183,14 +136,15 @@ exports[`ts lib generator > should generate library with default options > tscon
183
136
  {
184
137
  "path": "./tsconfig.spec.json"
185
138
  }
186
- ]
139
+ ],
140
+ "compilerOptions": {}
187
141
  }
188
142
  "
189
143
  `;
190
144
 
191
145
  exports[`ts lib generator > should generate library with subdirectory > subdir-index.ts 1`] = `
192
146
  "export function hello() {
193
- return "Hello!";
147
+ return "Hello!";
194
148
  }
195
149
  "
196
150
  `;
@@ -205,23 +159,11 @@ exports[`ts lib generator > should generate library with subdirectory > subdir-p
205
159
  "targets": {
206
160
  "build": {
207
161
  "dependsOn": [
208
- "compile",
209
162
  "lint",
163
+ "compile",
210
164
  "test"
211
165
  ]
212
166
  },
213
- "lint": {
214
- "executor": "@nx/eslint:lint"
215
- },
216
- "test": {
217
- "executor": "@nx/vite:test",
218
- "outputs": [
219
- "{options.reportsDirectory}"
220
- ],
221
- "options": {
222
- "reportsDirectory": "../../coverage/feature/test-lib"
223
- }
224
- },
225
167
  "compile": {
226
168
  "executor": "@nx/js:tsc",
227
169
  "outputs": [
@@ -230,11 +172,23 @@ exports[`ts lib generator > should generate library with subdirectory > subdir-p
230
172
  "options": {
231
173
  "outputPath": "dist/feature/test-lib",
232
174
  "main": "feature/test-lib/src/index.ts",
233
- "tsConfig": "feature/test-lib/tsconfig.lib.json",
175
+ "tsConfig": "feature/test-lib/tsconfig.json",
234
176
  "assets": [
235
177
  "feature/test-lib/*.md"
236
178
  ]
237
179
  }
180
+ },
181
+ "lint": {
182
+ "executor": "@nx/eslint:lint"
183
+ },
184
+ "test": {
185
+ "executor": "@nx/vite:test",
186
+ "outputs": [
187
+ "{options.reportsDirectory}"
188
+ ],
189
+ "options": {
190
+ "reportsDirectory": "../../coverage/feature/test-lib"
191
+ }
238
192
  }
239
193
  }
240
194
  }
@@ -244,7 +198,6 @@ exports[`ts lib generator > should generate library with subdirectory > subdir-p
244
198
  exports[`ts lib generator > should generate library with subdirectory > subdir-tsconfig.json 1`] = `
245
199
  "{
246
200
  "extends": "../../tsconfig.base.json",
247
- "compilerOptions": {},
248
201
  "files": [],
249
202
  "include": [],
250
203
  "references": [
@@ -254,7 +207,8 @@ exports[`ts lib generator > should generate library with subdirectory > subdir-t
254
207
  {
255
208
  "path": "./tsconfig.spec.json"
256
209
  }
257
- ]
210
+ ],
211
+ "compilerOptions": {}
258
212
  }
259
213
  "
260
214
  `;
@@ -3,5 +3,4 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { Tree } from '@nx/devkit';
6
- import { ConfigureProjectOptions } from './types';
7
- export declare const configureEslint: (tree: Tree, options: ConfigureProjectOptions) => void;
6
+ export declare const configureEslint: (tree: Tree) => Promise<void>;
@@ -1,33 +1,74 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configureEslint = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  /**
5
6
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
7
  * SPDX-License-Identifier: Apache-2.0
7
8
  */
8
9
  const devkit_1 = require("@nx/devkit");
9
- const configureEslint = (tree, options) => {
10
- var _a;
10
+ const versions_1 = require("../../utils/versions");
11
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
12
+ const typescript_1 = require("typescript");
13
+ const ast_1 = require("../../utils/ast");
14
+ const configureEslint = (tree) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
15
+ var _a, _b, _c;
11
16
  // Configure the lint task
12
- const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.fullyQualifiedName);
13
- if (!projectConfiguration.targets.lint) {
14
- projectConfiguration.targets.lint = {
15
- executor: '@nx/eslint:lint',
16
- options: {
17
- fix: true,
18
- },
19
- };
20
- (0, devkit_1.updateProjectConfiguration)(tree, options.fullyQualifiedName, projectConfiguration);
17
+ let nxJson = (0, devkit_1.readNxJson)(tree);
18
+ if (!((_a = nxJson.plugins) === null || _a === void 0 ? void 0 : _a.filter((e) => typeof e !== 'string').some((e) => e.plugin === '@nx/eslint/plugin'))) {
19
+ (0, devkit_1.updateNxJson)(tree, Object.assign(Object.assign({}, nxJson), { plugins: [
20
+ ...((_b = nxJson.plugins) !== null && _b !== void 0 ? _b : []),
21
+ {
22
+ plugin: '@nx/eslint/plugin',
23
+ options: {
24
+ targetName: 'lint',
25
+ },
26
+ },
27
+ ] }));
21
28
  }
22
- const nxJson = (0, devkit_1.readNxJson)(tree);
23
- (0, devkit_1.updateNxJson)(tree, Object.assign(Object.assign({}, nxJson), { targetDefaults: Object.assign(Object.assign({}, ((_a = nxJson.targetDefaults) !== null && _a !== void 0 ? _a : {})), { lint: {
24
- cache: true,
25
- inputs: [
26
- 'default',
27
- '{workspaceRoot}/eslint.config.js',
28
- '{projectRoot}/eslint.config.js',
29
- ],
30
- } }) }));
31
- };
29
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, (0, versions_1.withVersions)(['prettier', 'eslint-plugin-prettier']));
30
+ // Update or create eslint.config.mjs
31
+ const eslintConfigPath = 'eslint.config.mjs';
32
+ if (tree.exists(eslintConfigPath)) {
33
+ const eslintConfigContent = tree.read(eslintConfigPath).toString();
34
+ const sourceFile = (0, tsquery_1.ast)(eslintConfigContent);
35
+ // Check if import exists
36
+ const existingImport = tsquery_1.tsquery.query(sourceFile, 'VariableDeclaration[name.text="eslintPluginPrettierRecommended"]');
37
+ let updatedContent = sourceFile;
38
+ // Add import if it doesn't exist
39
+ if (existingImport.length === 0) {
40
+ updatedContent = (0, tsquery_1.ast)((0, ast_1.singleImport)(tree, eslintConfigPath, 'eslintPluginPrettierRecommended', 'eslint-plugin-prettier/recommended'));
41
+ }
42
+ // Check if eslintPluginPrettierRecommended exists in exports array
43
+ const existingPlugin = tsquery_1.tsquery.query(updatedContent, 'ExportAssignment > ArrayLiteralExpression Identifier[name="eslintPluginPrettierRecommended"]');
44
+ // Add eslintPluginPrettierRecommended to array if it doesn't exist
45
+ if (existingPlugin.length === 0) {
46
+ updatedContent = tsquery_1.tsquery.map(updatedContent, 'ExportAssignment > ArrayLiteralExpression', (node) => {
47
+ return typescript_1.factory.createArrayLiteralExpression([
48
+ typescript_1.factory.createIdentifier('eslintPluginPrettierRecommended'),
49
+ ...node.elements,
50
+ ], true);
51
+ });
52
+ }
53
+ // Only write if changes were made
54
+ if (updatedContent !== sourceFile) {
55
+ tree.write(eslintConfigPath, updatedContent.getFullText());
56
+ }
57
+ nxJson = (0, devkit_1.readNxJson)(tree);
58
+ (0, devkit_1.updateNxJson)(tree, Object.assign(Object.assign({}, nxJson), { targetDefaults: Object.assign(Object.assign({}, ((_c = nxJson.targetDefaults) !== null && _c !== void 0 ? _c : {})), { lint: {
59
+ cache: true,
60
+ configurations: {
61
+ fix: {
62
+ fix: true,
63
+ },
64
+ },
65
+ inputs: [
66
+ 'default',
67
+ '{workspaceRoot}/eslint.config.mjs',
68
+ '{projectRoot}/eslint.config.mjs',
69
+ ],
70
+ } }) }));
71
+ }
72
+ });
32
73
  exports.configureEslint = configureEslint;
33
74
  //# sourceMappingURL=eslint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/eslint.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAMoB;AAGb,MAAM,eAAe,GAAG,CAC7B,IAAU,EACV,OAAgC,EAChC,EAAE;;IACF,0BAA0B;IAC1B,MAAM,oBAAoB,GAAG,IAAA,iCAAwB,EACnD,IAAI,EACJ,OAAO,CAAC,kBAAkB,CAC3B,CAAC;IACF,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,EAAE,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