@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
|
@@ -7,12 +7,13 @@ const tslib_1 = require("tslib");
|
|
|
7
7
|
* SPDX-License-Identifier: Apache-2.0
|
|
8
8
|
*/
|
|
9
9
|
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
10
11
|
const generator_1 = require("../runtime-config/generator");
|
|
11
12
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
12
13
|
const typescript_1 = require("typescript");
|
|
13
|
-
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
14
14
|
const versions_1 = require("../../utils/versions");
|
|
15
15
|
const format_1 = require("../../utils/format");
|
|
16
|
+
const ast_1 = require("../../utils/ast");
|
|
16
17
|
function cognitoAuthGenerator(tree, options) {
|
|
17
18
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
const srcRoot = (0, devkit_1.readProjectConfiguration)(tree, options.project).sourceRoot;
|
|
@@ -23,63 +24,145 @@ function cognitoAuthGenerator(tree, options) {
|
|
|
23
24
|
project: options.project,
|
|
24
25
|
});
|
|
25
26
|
yield (0, shared_constructs_1.sharedConstructsGenerator)(tree);
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
// Add ICognitoProps interface and update IRuntimeConfig
|
|
28
|
+
const runtimeConfigPath = (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.TYPE_DEFINITIONS_DIR, 'src', 'runtime-config.ts');
|
|
29
|
+
const runtimeConfigContent = tree.read(runtimeConfigPath).toString();
|
|
30
|
+
const sourceFile = (0, tsquery_1.ast)(runtimeConfigContent);
|
|
31
|
+
// Check if ICognitoProps interface exists
|
|
32
|
+
const existingCognitoProps = tsquery_1.tsquery.query(sourceFile, 'InterfaceDeclaration[name.text="ICognitoProps"]');
|
|
33
|
+
// Check if cognitoProps property exists in IRuntimeConfig
|
|
34
|
+
const existingCognitoPropsInConfig = tsquery_1.tsquery.query(sourceFile, 'InterfaceDeclaration[name.text="IRuntimeConfig"] PropertySignature[name.text="cognitoProps"]');
|
|
35
|
+
let updatedContent = sourceFile;
|
|
36
|
+
// Add ICognitoProps interface if it doesn't exist
|
|
37
|
+
if (existingCognitoProps.length === 0) {
|
|
38
|
+
const cognitoPropsInterface = typescript_1.factory.createInterfaceDeclaration([typescript_1.factory.createModifier(typescript_1.SyntaxKind.ExportKeyword)], typescript_1.factory.createIdentifier('ICognitoProps'), undefined, undefined, [
|
|
39
|
+
typescript_1.factory.createPropertySignature(undefined, typescript_1.factory.createIdentifier('region'), undefined, typescript_1.factory.createKeywordTypeNode(typescript_1.SyntaxKind.StringKeyword)),
|
|
40
|
+
typescript_1.factory.createPropertySignature(undefined, typescript_1.factory.createIdentifier('identityPoolId'), undefined, typescript_1.factory.createKeywordTypeNode(typescript_1.SyntaxKind.StringKeyword)),
|
|
41
|
+
typescript_1.factory.createPropertySignature(undefined, typescript_1.factory.createIdentifier('userPoolId'), undefined, typescript_1.factory.createKeywordTypeNode(typescript_1.SyntaxKind.StringKeyword)),
|
|
42
|
+
typescript_1.factory.createPropertySignature(undefined, typescript_1.factory.createIdentifier('userPoolWebClientId'), undefined, typescript_1.factory.createKeywordTypeNode(typescript_1.SyntaxKind.StringKeyword)),
|
|
43
|
+
]);
|
|
44
|
+
updatedContent = tsquery_1.tsquery.map(updatedContent, 'SourceFile', (node) => {
|
|
45
|
+
return typescript_1.factory.updateSourceFile(node, [
|
|
46
|
+
cognitoPropsInterface,
|
|
47
|
+
...node.statements,
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Add cognitoProps to IRuntimeConfig if it doesn't exist
|
|
52
|
+
if (existingCognitoPropsInConfig.length === 0) {
|
|
53
|
+
updatedContent = tsquery_1.tsquery.map(updatedContent, 'InterfaceDeclaration[name.text="IRuntimeConfig"]', (node) => {
|
|
54
|
+
return typescript_1.factory.updateInterfaceDeclaration(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, [
|
|
55
|
+
...node.members,
|
|
56
|
+
typescript_1.factory.createPropertySignature(undefined, typescript_1.factory.createIdentifier('cognitoProps'), undefined, typescript_1.factory.createTypeReferenceNode('ICognitoProps', undefined)),
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Only write if changes were made
|
|
61
|
+
if (updatedContent !== sourceFile) {
|
|
62
|
+
tree.write(runtimeConfigPath, updatedContent.getFullText());
|
|
63
|
+
}
|
|
64
|
+
const identityPath = (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core', 'user-identity.ts');
|
|
65
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'app'), srcRoot, options, {
|
|
66
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
67
|
+
});
|
|
28
68
|
if (!tree.exists(identityPath)) {
|
|
29
69
|
(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), {
|
|
30
70
|
allowSignup: options.allowSignup,
|
|
71
|
+
cognitoDomain: options.cognitoDomain,
|
|
72
|
+
}, {
|
|
73
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
31
74
|
});
|
|
32
75
|
(0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)([
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'@aws/pdk',
|
|
76
|
+
'oidc-client-ts',
|
|
77
|
+
'react-oidc-context',
|
|
36
78
|
'@aws-cdk/aws-cognito-identitypool-alpha',
|
|
37
79
|
]), {});
|
|
38
|
-
|
|
39
|
-
const sharedConstructsIndexContents = tree
|
|
40
|
-
.read(sharedConstructsIndexTsPath)
|
|
41
|
-
.toString();
|
|
42
|
-
const identityExportDeclaration = typescript_1.factory.createExportDeclaration(undefined, undefined, undefined, typescript_1.factory.createStringLiteral('./identity/index.js', true));
|
|
43
|
-
const updatedIndex = tsquery_1.tsquery
|
|
44
|
-
.map((0, tsquery_1.ast)(sharedConstructsIndexContents), 'SourceFile', (node) => {
|
|
45
|
-
return Object.assign(Object.assign({}, node), { statements: [identityExportDeclaration, ...node.statements] });
|
|
46
|
-
})
|
|
47
|
-
.getFullText();
|
|
48
|
-
if (sharedConstructsIndexContents !== updatedIndex) {
|
|
49
|
-
tree.write(sharedConstructsIndexTsPath, updatedIndex);
|
|
50
|
-
}
|
|
80
|
+
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core', 'index.ts'), './user-identity.js');
|
|
51
81
|
}
|
|
52
82
|
const mainTsxPath = (0, devkit_1.joinPathFragments)(srcRoot, 'main.tsx');
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
(0, ast_1.singleImport)(tree, mainTsxPath, 'CognitoAuth', './components/CognitoAuth');
|
|
84
|
+
(0, ast_1.replace)(tree, mainTsxPath, 'JsxElement[openingElement.tagName.name="RuntimeConfigProvider"]', (node) => (0, ast_1.createJsxElement)(node.openingElement, [(0, ast_1.createJsxElementFromIdentifier)('CognitoAuth', node.children)], node.closingElement));
|
|
85
|
+
// Update App Layout
|
|
86
|
+
const appLayoutTsxPath = (0, devkit_1.joinPathFragments)(srcRoot, 'layouts', 'App', 'index.tsx');
|
|
87
|
+
if (tree.exists(appLayoutTsxPath)) {
|
|
88
|
+
const contents = tree.read(appLayoutTsxPath).toString();
|
|
89
|
+
let updatedContents = (0, ast_1.destructuredImport)(tree, appLayoutTsxPath, ['useAuth'], 'react-oidc-context');
|
|
90
|
+
updatedContents = tsquery_1.tsquery
|
|
91
|
+
.map((0, tsquery_1.ast)(updatedContents), 'VariableDeclaration', (node) => {
|
|
92
|
+
// Only process if this is the App component
|
|
93
|
+
if (node.name.getText() !== 'App') {
|
|
94
|
+
return node;
|
|
95
|
+
}
|
|
96
|
+
const arrowFunction = node.initializer;
|
|
97
|
+
const functionBody = arrowFunction.body;
|
|
98
|
+
// Create our new declaration
|
|
99
|
+
const authDeclaration = typescript_1.factory.createVariableStatement(undefined, typescript_1.factory.createVariableDeclarationList([
|
|
100
|
+
typescript_1.factory.createVariableDeclaration(typescript_1.factory.createObjectBindingPattern([
|
|
101
|
+
typescript_1.factory.createBindingElement(undefined, undefined, typescript_1.factory.createIdentifier('user'), undefined),
|
|
102
|
+
typescript_1.factory.createBindingElement(undefined, undefined, typescript_1.factory.createIdentifier('removeUser'), undefined),
|
|
103
|
+
typescript_1.factory.createBindingElement(undefined, undefined, typescript_1.factory.createIdentifier('signoutRedirect'), undefined),
|
|
104
|
+
typescript_1.factory.createBindingElement(undefined, undefined, typescript_1.factory.createIdentifier('clearStaleState'), undefined),
|
|
105
|
+
]), undefined, undefined, typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('useAuth'), undefined, [])),
|
|
106
|
+
], typescript_1.NodeFlags.Const));
|
|
107
|
+
// Add as first statement
|
|
108
|
+
const newStatements = [authDeclaration, ...functionBody.statements];
|
|
109
|
+
// Create new arrow function with updated body
|
|
110
|
+
const newArrowFunction = typescript_1.factory.updateArrowFunction(arrowFunction, arrowFunction.modifiers, arrowFunction.typeParameters, arrowFunction.parameters, arrowFunction.type, arrowFunction.equalsGreaterThanToken, typescript_1.factory.createBlock(newStatements, true));
|
|
111
|
+
// Update the variable declaration
|
|
112
|
+
return typescript_1.factory.updateVariableDeclaration(node, node.name, node.exclamationToken, node.type, newArrowFunction);
|
|
113
|
+
})
|
|
114
|
+
.getFullText();
|
|
115
|
+
// TODO: update utils if they exist by appending to the array
|
|
116
|
+
updatedContents = tsquery_1.tsquery
|
|
117
|
+
.map((0, tsquery_1.ast)(updatedContents), 'JsxSelfClosingElement[tagName.text="TopNavigation"]', (node) => {
|
|
118
|
+
// Create the utilities attribute
|
|
119
|
+
const utilitiesAttribute = typescript_1.factory.createJsxAttribute(typescript_1.factory.createIdentifier('utilities'), typescript_1.factory.createJsxExpression(undefined, typescript_1.factory.createArrayLiteralExpression([
|
|
120
|
+
typescript_1.factory.createObjectLiteralExpression([
|
|
121
|
+
typescript_1.factory.createPropertyAssignment('type', typescript_1.factory.createStringLiteral('menu-dropdown')),
|
|
122
|
+
typescript_1.factory.createPropertyAssignment('text', typescript_1.factory.createTemplateExpression(typescript_1.factory.createTemplateHead(''), [
|
|
123
|
+
typescript_1.factory.createTemplateSpan(typescript_1.factory.createElementAccessChain(typescript_1.factory.createPropertyAccessChain(typescript_1.factory.createIdentifier('user'), typescript_1.factory.createToken(typescript_1.SyntaxKind.QuestionDotToken), typescript_1.factory.createIdentifier('profile')), typescript_1.factory.createToken(typescript_1.SyntaxKind.QuestionDotToken), typescript_1.factory.createStringLiteral('cognito:username')), typescript_1.factory.createTemplateTail('')),
|
|
124
|
+
])),
|
|
125
|
+
typescript_1.factory.createPropertyAssignment('iconName', typescript_1.factory.createStringLiteral('user-profile-active')),
|
|
126
|
+
typescript_1.factory.createPropertyAssignment('onItemClick', typescript_1.factory.createArrowFunction(undefined, undefined, [
|
|
127
|
+
typescript_1.factory.createParameterDeclaration(undefined, undefined, typescript_1.factory.createIdentifier('e'), undefined, undefined, undefined),
|
|
128
|
+
], undefined, typescript_1.factory.createToken(typescript_1.SyntaxKind.EqualsGreaterThanToken), typescript_1.factory.createBlock([
|
|
129
|
+
typescript_1.factory.createIfStatement(typescript_1.factory.createBinaryExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('e'), typescript_1.factory.createIdentifier('detail')), typescript_1.factory.createIdentifier('id')), typescript_1.factory.createToken(typescript_1.SyntaxKind.EqualsEqualsEqualsToken), typescript_1.factory.createStringLiteral('signout')), typescript_1.factory.createBlock([
|
|
130
|
+
typescript_1.factory.createExpressionStatement(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('removeUser'), undefined, [])),
|
|
131
|
+
typescript_1.factory.createExpressionStatement(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('signoutRedirect'), undefined, [
|
|
132
|
+
typescript_1.factory.createObjectLiteralExpression([
|
|
133
|
+
typescript_1.factory.createPropertyAssignment('post_logout_redirect_uri', typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('window'), typescript_1.factory.createIdentifier('location')), typescript_1.factory.createIdentifier('origin'))),
|
|
134
|
+
typescript_1.factory.createPropertyAssignment('extraQueryParams', typescript_1.factory.createObjectLiteralExpression([
|
|
135
|
+
typescript_1.factory.createPropertyAssignment('redirect_uri', typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('window'), typescript_1.factory.createIdentifier('location')), typescript_1.factory.createIdentifier('origin'))),
|
|
136
|
+
typescript_1.factory.createPropertyAssignment('response_type', typescript_1.factory.createStringLiteral('code')),
|
|
137
|
+
])),
|
|
138
|
+
]),
|
|
139
|
+
])),
|
|
140
|
+
typescript_1.factory.createExpressionStatement(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('clearStaleState'), undefined, [])),
|
|
141
|
+
], true)),
|
|
142
|
+
], true))),
|
|
143
|
+
typescript_1.factory.createPropertyAssignment('items', typescript_1.factory.createArrayLiteralExpression([
|
|
144
|
+
typescript_1.factory.createObjectLiteralExpression([
|
|
145
|
+
typescript_1.factory.createPropertyAssignment('id', typescript_1.factory.createStringLiteral('signout')),
|
|
146
|
+
typescript_1.factory.createPropertyAssignment('text', typescript_1.factory.createStringLiteral('Sign out')),
|
|
147
|
+
]),
|
|
148
|
+
])),
|
|
149
|
+
]),
|
|
150
|
+
], true)));
|
|
151
|
+
// Add the utilities attribute to existing attributes
|
|
152
|
+
return typescript_1.factory.createJsxSelfClosingElement(node.tagName, node.typeArguments, typescript_1.factory.createJsxAttributes([
|
|
153
|
+
...node.attributes.properties,
|
|
154
|
+
utilitiesAttribute,
|
|
155
|
+
]));
|
|
156
|
+
})
|
|
157
|
+
.getFullText();
|
|
158
|
+
if (contents !== updatedContents) {
|
|
159
|
+
tree.write(appLayoutTsxPath, updatedContents);
|
|
71
160
|
}
|
|
72
|
-
return typescript_1.factory.createJsxElement(node.openingElement, [
|
|
73
|
-
typescript_1.factory.createJsxElement(typescript_1.factory.createJsxOpeningElement(typescript_1.factory.createIdentifier('CognitoAuth'), undefined, typescript_1.factory.createJsxAttributes([])), node.children, typescript_1.factory.createJsxClosingElement(typescript_1.factory.createIdentifier('CognitoAuth'))),
|
|
74
|
-
], node.closingElement);
|
|
75
|
-
})
|
|
76
|
-
.getFullText();
|
|
77
|
-
if (!locatedTargetNode) {
|
|
78
|
-
throw new Error('Could not locate the RuntimeConfigProvider element in main.tsx');
|
|
79
161
|
}
|
|
80
|
-
|
|
81
|
-
|
|
162
|
+
else {
|
|
163
|
+
console.info(`Skipping update to ${appLayoutTsxPath} as it does not exist.`);
|
|
82
164
|
}
|
|
165
|
+
// End update App Layout
|
|
83
166
|
yield (0, format_1.formatFilesInSubtree)(tree, srcRoot);
|
|
84
167
|
return () => {
|
|
85
168
|
(0, devkit_1.installPackagesTask)(tree);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/cognito-auth/generator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/cognito-auth/generator.ts"],"names":[],"mappings":";;AA4CA,oDAudC;;AAngBD;;;GAGG;AACH,uCAQoB;AACpB,qEAKuC;AAEvC,2DAAqE;AACrE,uDAAyD;AACzD,2CAWoB;AACpB,mDAAoD;AACpD,+CAA0D;AAC1D,yCAOyB;AACzB,SAAsB,oBAAoB,CACxC,IAAU,EACV,OAAmC;;QAEnC,MAAM,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;QAC3E,IACE,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC,E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M,CAAC;YACN,OAAO,CAAC,IAAI,CACV,sBAAsB,gBAAgB,wBAAwB,CAC/D,CAAC;QACJ,CAAC;QACD,wBAAwB;QACxB,MAAM,IAAA,6BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AACD,kBAAe,oBAAoB,CAAC"}
|
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
"x-prompt": "the root directory for your Cloudscape application",
|
|
25
25
|
"x-dropdown": "projects"
|
|
26
26
|
},
|
|
27
|
+
"cognitoDomain": {
|
|
28
|
+
"description": "The cognito domain prefix to use",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"x-priority": "important",
|
|
31
|
+
"x-prompt": "the cognito domain prefix to use i.e: https://{{cognitoDomain}}-123456789.auth.ap-southeast-2.amazoncognito.com"
|
|
32
|
+
},
|
|
27
33
|
"allowSignup": {
|
|
28
34
|
"description": "Whether to allow self-signup",
|
|
29
35
|
"type": "boolean",
|
|
@@ -32,5 +38,5 @@
|
|
|
32
38
|
"x-priority": "important"
|
|
33
39
|
}
|
|
34
40
|
},
|
|
35
|
-
"required": ["project"]
|
|
41
|
+
"required": ["project", "cognitoDomain"]
|
|
36
42
|
}
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
3
|
exports[`runtime-config generator > should generate runtime config files > runtime-config-component.tsx 1`] = `
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
import ErrorMessage from '@aws-northstar/ui/components/CognitoAuth/components/ErrorMessage';
|
|
7
|
-
import { Spinner } from '@cloudscape-design/components';
|
|
8
|
-
import React, { createContext, useEffect, useState } from 'react';
|
|
4
|
+
"import { Alert, Spinner } from '@cloudscape-design/components';
|
|
5
|
+
import React, { createContext, PropsWithChildren, useEffect, useState } from 'react';
|
|
9
6
|
import type { IRuntimeConfig } from ':proj/common-types';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* Context for storing the runtimeConfig.
|
|
13
10
|
*/
|
|
14
|
-
export const RuntimeConfigContext = createContext<IRuntimeConfig | undefined>(
|
|
15
|
-
undefined
|
|
16
|
-
);
|
|
11
|
+
export const RuntimeConfigContext = createContext<IRuntimeConfig | undefined>(undefined);
|
|
17
12
|
|
|
18
13
|
/**
|
|
19
14
|
* Sets up the runtimeConfig.
|
|
20
15
|
*
|
|
21
16
|
* This assumes a runtime-config.json file is present at '/'.
|
|
22
17
|
*/
|
|
23
|
-
const RuntimeConfigProvider: React.FC<
|
|
18
|
+
const RuntimeConfigProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|
24
19
|
const [runtimeConfig, setRuntimeConfig] = useState<
|
|
25
20
|
IRuntimeConfig | undefined
|
|
26
21
|
>();
|
|
@@ -40,7 +35,9 @@ const RuntimeConfigProvider: React.FC<any> = ({ children }) => {
|
|
|
40
35
|
}, [setRuntimeConfig]);
|
|
41
36
|
|
|
42
37
|
return error ? (
|
|
43
|
-
<
|
|
38
|
+
<Alert type="error" header="Validation error">
|
|
39
|
+
{error}
|
|
40
|
+
</Alert>
|
|
44
41
|
) : runtimeConfig ? (
|
|
45
42
|
<RuntimeConfigContext.Provider value={runtimeConfig}>
|
|
46
43
|
{children}
|
|
@@ -54,18 +51,21 @@ export default RuntimeConfigProvider;
|
|
|
54
51
|
"
|
|
55
52
|
`;
|
|
56
53
|
|
|
57
|
-
exports[`runtime-config generator > should generate shared constructs > common/constructs-index.ts 1`] = `
|
|
54
|
+
exports[`runtime-config generator > should generate shared constructs > common/constructs-index.ts 1`] = `
|
|
55
|
+
"export * from './runtime-config.js';
|
|
56
|
+
"
|
|
57
|
+
`;
|
|
58
58
|
|
|
59
59
|
exports[`runtime-config generator > should generate shared constructs > runtime-config.ts 1`] = `
|
|
60
|
-
"
|
|
61
|
-
SPDX-License-Identifier: Apache-2.0 */
|
|
62
|
-
import type { IRuntimeConfig } from ':proj/common-types';
|
|
60
|
+
"import type { IRuntimeConfig } from ':proj/common-types';
|
|
63
61
|
import { Stack } from 'aws-cdk-lib';
|
|
64
62
|
import { Construct } from 'constructs';
|
|
65
63
|
|
|
66
64
|
const RuntimeConfigKey = '__RuntimeConfig__';
|
|
67
65
|
|
|
68
66
|
export class RuntimeConfig extends Construct {
|
|
67
|
+
private readonly _runtimeConfig: Partial<IRuntimeConfig> = {};
|
|
68
|
+
|
|
69
69
|
static ensure(scope: Construct): RuntimeConfig {
|
|
70
70
|
const stack = Stack.of(scope);
|
|
71
71
|
return (
|
|
@@ -80,13 +80,11 @@ export class RuntimeConfig extends Construct {
|
|
|
80
80
|
| undefined;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
private readonly _runtimeConfig: IRuntimeConfig = {};
|
|
84
|
-
|
|
85
83
|
constructor(scope: Construct, id: string) {
|
|
86
84
|
super(scope, id);
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
get config(): IRuntimeConfig {
|
|
87
|
+
get config(): Partial<IRuntimeConfig> {
|
|
90
88
|
return this._runtimeConfig;
|
|
91
89
|
}
|
|
92
90
|
}
|
package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import ErrorMessage from '@aws-northstar/ui/components/CognitoAuth/components/ErrorMessage';
|
|
4
|
-
import { Spinner } from '@cloudscape-design/components';
|
|
5
|
-
import React, { createContext, useEffect, useState } from 'react';
|
|
1
|
+
import { Alert, Spinner } from '@cloudscape-design/components';
|
|
2
|
+
import React, { createContext, PropsWithChildren, useEffect, useState } from 'react';
|
|
6
3
|
import type { IRuntimeConfig } from '<%= scopeAlias %>common-types';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Context for storing the runtimeConfig.
|
|
10
7
|
*/
|
|
11
|
-
export const RuntimeConfigContext = createContext<IRuntimeConfig | undefined>(
|
|
12
|
-
undefined
|
|
13
|
-
);
|
|
8
|
+
export const RuntimeConfigContext = createContext<IRuntimeConfig | undefined>(undefined);
|
|
14
9
|
|
|
15
10
|
/**
|
|
16
11
|
* Sets up the runtimeConfig.
|
|
17
12
|
*
|
|
18
13
|
* This assumes a runtime-config.json file is present at '/'.
|
|
19
14
|
*/
|
|
20
|
-
const RuntimeConfigProvider: React.FC<
|
|
15
|
+
const RuntimeConfigProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|
21
16
|
const [runtimeConfig, setRuntimeConfig] = useState<
|
|
22
17
|
IRuntimeConfig | undefined
|
|
23
18
|
>();
|
|
@@ -37,7 +32,9 @@ const RuntimeConfigProvider: React.FC<any> = ({ children }) => {
|
|
|
37
32
|
}, [setRuntimeConfig]);
|
|
38
33
|
|
|
39
34
|
return error ? (
|
|
40
|
-
<
|
|
35
|
+
<Alert type="error" header="Validation error">
|
|
36
|
+
{error}
|
|
37
|
+
</Alert>
|
|
41
38
|
) : runtimeConfig ? (
|
|
42
39
|
<RuntimeConfigContext.Provider value={runtimeConfig}>
|
|
43
40
|
{children}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { RuntimeConfigContext } from '../components/RuntimeConfig';
|
|
3
|
+
import { IRuntimeConfig } from '<%= scopeAlias %>common-types';
|
|
4
|
+
|
|
5
|
+
export const useRuntimeConfig = (): IRuntimeConfig => {
|
|
6
|
+
const runtimeConfig = useContext(RuntimeConfigContext);
|
|
7
|
+
|
|
8
|
+
if (!runtimeConfig) {
|
|
9
|
+
throw new Error("useRuntimeConfig must be used within a RuntimeConfigProvider");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return runtimeConfig;
|
|
13
|
+
}
|
|
@@ -29,7 +29,9 @@ function runtimeConfigGenerator(tree, options) {
|
|
|
29
29
|
}
|
|
30
30
|
yield (0, shared_constructs_1.sharedConstructsGenerator)(tree);
|
|
31
31
|
const npmScopePrefix = (0, npm_scope_1.getNpmScopePrefix)(tree);
|
|
32
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'app'), srcRoot, Object.assign(Object.assign({}, options), { npmScopePrefix, scopeAlias: (0, npm_scope_1.toScopeAlias)(npmScopePrefix) })
|
|
32
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'app'), srcRoot, Object.assign(Object.assign({}, options), { npmScopePrefix, scopeAlias: (0, npm_scope_1.toScopeAlias)(npmScopePrefix) }), {
|
|
33
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
34
|
+
});
|
|
33
35
|
const runtimeContextImport = typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier('RuntimeConfigProvider'), undefined), typescript_1.factory.createStringLiteral('./components/RuntimeConfig', true));
|
|
34
36
|
const updatedImports = tsquery_1.tsquery
|
|
35
37
|
.map(mainTsxAst, 'SourceFile', (node) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/runtime-config/generator.ts"],"names":[],"mappings":";;AAiBA,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/cloudscape-website/runtime-config/generator.ts"],"names":[],"mappings":";;AAiBA,wDAyFC;;AA1GD;;;GAGG;AACH,uCAMoB;AAEpB,uDAAyD;AACzD,2CAA6D;AAC7D,qEAA0E;AAC1E,qDAAwE;AACxE,+CAA0D;AAC1D,SAAsB,sBAAsB,CAC1C,IAAU,EACV,OAAqC;;QAErC,MAAM,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;QAC3E,MAAM,WAAW,GAAG,IAAA,0BAAiB,EAAC,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