@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.
- package/LICENSE-THIRD-PARTY +1554 -3241
- package/generators.json +1 -13
- package/package.json +14 -14
- package/src/cloudscape-website/app/README.md +84 -48
- package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +168 -233
- 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 +79 -144
- package/src/cloudscape-website/app/generator.js +90 -74
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/app/schema.d.ts +3 -5
- 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 +162 -124
- 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 +130 -47
- 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 +20 -15
- 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 +4 -2
- 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 +184 -305
- 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 +36 -7
- 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 +42 -19
- 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 +30 -44
- 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 +124 -25
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.json +2 -2
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +47 -93
- package/src/ts/lib/eslint.d.ts +1 -2
- package/src/ts/lib/eslint.js +62 -21
- 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 +44 -5
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.d.ts +1 -4
- package/src/ts/lib/schema.json +2 -21
- package/src/ts/lib/ts-project-utils.js +3 -18
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.js +12 -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 +2 -13
- package/src/utils/format.d.ts +1 -1
- package/src/utils/format.js +2 -2
- 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/test.d.ts +2 -0
- package/src/utils/test.js +19 -0
- package/src/utils/test.js.map +1 -0
- 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/ts/cjs-to-esm/generator.d.ts +0 -12
- package/src/ts/cjs-to-esm/generator.js +0 -189
- package/src/ts/cjs-to-esm/generator.js.map +0 -1
- package/src/ts/cjs-to-esm/schema.d.ts +0 -9
- package/src/ts/cjs-to-esm/schema.json +0 -28
- /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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# <%= fullyQualifiedName %>
|
|
2
|
+
|
|
3
|
+
This library was generated with [@aws/nx-plugin](https://github.com/awslabs/nx-plugin-for-aws/).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `<%= pkgMgrCmd %> nx build <%= fullyQualifiedName %> [--skip-nx-cache]` to build the application.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `<%= pkgMgrCmd %> nx test <%= fullyQualifiedName %>` to execute the unit tests via Vitest.
|
|
12
|
+
|
|
13
|
+
### Updating snapshots
|
|
14
|
+
|
|
15
|
+
To update snapshots, run the following command:
|
|
16
|
+
|
|
17
|
+
`<%= pkgMgrCmd %> nx test <%= fullyQualifiedName %> --configuration=update-snapshot`
|
|
18
|
+
|
|
19
|
+
## Run lint
|
|
20
|
+
|
|
21
|
+
Run `<%= pkgMgrCmd %> nx lint <%= fullyQualifiedName %>`
|
|
22
|
+
|
|
23
|
+
### Fixable issues
|
|
24
|
+
|
|
25
|
+
You can also automatiaclly fix some lint errors by running the following command:
|
|
26
|
+
|
|
27
|
+
`<%= pkgMgrCmd %> nx lint <%= fullyQualifiedName %> --configuration=fix`
|
|
28
|
+
|
|
29
|
+
## Useful links
|
|
30
|
+
|
|
31
|
+
- [Ts library reference docs](TODO)
|
|
32
|
+
- [Learn more about NX](https://nx.dev/getting-started/intro)
|
|
33
|
+
|
package/src/ts/lib/generator.js
CHANGED
|
@@ -10,14 +10,18 @@ const devkit_1 = require("@nx/devkit");
|
|
|
10
10
|
const js_1 = require("@nx/js");
|
|
11
11
|
const npm_scope_1 = require("../../utils/npm-scope");
|
|
12
12
|
const ts_project_utils_1 = require("./ts-project-utils");
|
|
13
|
+
const names_1 = require("../../utils/names");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const format_1 = require("../../utils/format");
|
|
13
16
|
/**
|
|
14
17
|
* Returns details about the TS library to be created
|
|
15
18
|
*/
|
|
16
19
|
const getTsLibDetails = (tree, schema) => {
|
|
17
20
|
var _a, _b;
|
|
18
|
-
const scope =
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
+
const scope = (0, npm_scope_1.getNpmScopePrefix)(tree);
|
|
22
|
+
const normalizedName = (0, names_1.toKebabCase)(schema.name);
|
|
23
|
+
const fullyQualifiedName = `${scope}${normalizedName}`;
|
|
24
|
+
const dir = (0, devkit_1.joinPathFragments)((_a = (0, names_1.toKebabCase)(schema.directory)) !== null && _a !== void 0 ? _a : '.', (_b = (0, names_1.toKebabCase)(schema.subDirectory)) !== null && _b !== void 0 ? _b : normalizedName);
|
|
21
25
|
return { dir, fullyQualifiedName };
|
|
22
26
|
};
|
|
23
27
|
exports.getTsLibDetails = getTsLibDetails;
|
|
@@ -26,14 +30,49 @@ exports.getTsLibDetails = getTsLibDetails;
|
|
|
26
30
|
*/
|
|
27
31
|
const tsLibGenerator = (tree, schema) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
28
32
|
const { fullyQualifiedName, dir } = (0, exports.getTsLibDetails)(tree, schema);
|
|
29
|
-
yield (0, js_1.libraryGenerator)(tree, Object.assign(Object.assign({}, schema), { name:
|
|
33
|
+
yield (0, js_1.libraryGenerator)(tree, Object.assign(Object.assign({}, schema), { name: (0, names_1.toKebabCase)(schema.name), directory: dir, skipPackageJson: true, bundler: 'tsc', linter: 'eslint', unitTestRunner: 'vitest' }));
|
|
30
34
|
// Replace with simpler sample source code
|
|
31
35
|
tree.delete((0, devkit_1.joinPathFragments)(dir, 'src'));
|
|
32
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'
|
|
36
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), (0, devkit_1.joinPathFragments)(dir), {
|
|
37
|
+
fullyQualifiedName,
|
|
38
|
+
pkgMgrCmd: (0, devkit_1.getPackageManagerCommand)().exec,
|
|
39
|
+
}, {
|
|
40
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
41
|
+
});
|
|
33
42
|
(0, ts_project_utils_1.configureTsProject)(tree, {
|
|
34
43
|
dir,
|
|
35
44
|
fullyQualifiedName,
|
|
36
45
|
});
|
|
46
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, fullyQualifiedName);
|
|
47
|
+
const targets = projectConfiguration.targets;
|
|
48
|
+
targets['compile'] = {
|
|
49
|
+
executor: '@nx/js:tsc',
|
|
50
|
+
outputs: ['{options.outputPath}'],
|
|
51
|
+
options: {
|
|
52
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', dir),
|
|
53
|
+
main: (0, devkit_1.joinPathFragments)(dir, 'src/index.ts'),
|
|
54
|
+
tsConfig: (0, devkit_1.joinPathFragments)(dir, 'tsconfig.json'),
|
|
55
|
+
assets: [(0, devkit_1.joinPathFragments)(dir, '*.md')],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
targets['build'] = {
|
|
59
|
+
dependsOn: ['lint', 'compile', 'test'],
|
|
60
|
+
};
|
|
61
|
+
targets['test'] = {
|
|
62
|
+
executor: '@nx/vite:test',
|
|
63
|
+
outputs: ['{options.reportsDirectory}'],
|
|
64
|
+
options: {
|
|
65
|
+
reportsDirectory: (0, devkit_1.joinPathFragments)((0, path_1.relative)((0, devkit_1.joinPathFragments)(tree.root, dir), tree.root), 'coverage', dir),
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
projectConfiguration.targets = Object.keys(targets)
|
|
69
|
+
.sort()
|
|
70
|
+
.reduce((obj, key) => {
|
|
71
|
+
obj[key] = targets[key];
|
|
72
|
+
return obj;
|
|
73
|
+
}, {});
|
|
74
|
+
(0, devkit_1.updateProjectConfiguration)(tree, fullyQualifiedName, projectConfiguration);
|
|
75
|
+
(0, format_1.formatFilesInSubtree)(tree);
|
|
37
76
|
return () => {
|
|
38
77
|
if (!schema.skipInstall) {
|
|
39
78
|
(0, devkit_1.installPackagesTask)(tree);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAUoB;AAEpB,+BAA0C;AAC1C,qDAA0D;AAC1D,yDAAwD;AACxD,6CAAgD;AAChD,+BAAgC;AAChC,+CAA0D;AAW1D;;GAEG;AACI,MAAM,eAAe,GAAG,CAC7B,IAAU,EACV,MAA4B,EACd,EAAE;;IAChB,MAAM,KAAK,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC;IACtC,MAAM,cAAc,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,kBAAkB,GAAG,GAAG,KAAK,GAAG,cAAc,EAAE,CAAC;IACvD,MAAM,GAAG,GAAG,IAAA,0BAAiB,EAC3B,MAAA,IAAA,mBAAW,EAAC,MAAM,CAAC,SAAS,CAAC,mCAAI,GAAG,EACpC,MAAA,IAAA,mBAAW,EAAC,MAAM,CAAC,YAAY,CAAC,mCAAI,cAAc,CACnD,CAAC;IACF,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,CAAC;AACrC,CAAC,CAAC;AAZW,QAAA,eAAe,mBAY1B;AACF;;GAEG;AACI,MAAM,cAAc,GAAG,CAC5B,IAAU,EACV,MAA4B,EACA,EAAE;IAC9B,MAAM,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,IAAA,uBAAe,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAClE,MAAM,IAAA,qBAAgB,EAAC,IAAI,kCACtB,MAAM,KACT,IAAI,EAAE,IAAA,mBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,EAC9B,SAAS,EAAE,GAAG,EACd,eAAe,EAAE,IAAI,EACrB,OAAO,EAA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BAA4B,CAAC;QACvC,OAAO,EAAE;YACP,gBAAgB,EAAE,IAAA,0BAAiB,EACjC,IAAA,eAAQ,EAAC,IAAA,0BAAiB,EAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EACtD,UAAU,EACV,GAAG,CACJ;SACF;KACF,CAAC;IACF,oBAAoB,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;SAChD,IAAI,EAAE;SACN,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnB,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QACxB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IAET,IAAA,mCAA0B,EAAC,IAAI,EAAE,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;IAE3E,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IAE3B,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACxB,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAA,CAAC;AA/EW,QAAA,cAAc,kBA+EzB;AACF,kBAAe,sBAAc,CAAC"}
|
package/src/ts/lib/schema.d.ts
CHANGED
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { LibraryGeneratorSchema } from '@nx/js/src/utils/schema';
|
|
6
|
-
|
|
7
6
|
export interface TsLibGeneratorSchema {
|
|
8
7
|
name: LibraryGeneratorSchema['name'];
|
|
9
8
|
directory?: string;
|
|
10
|
-
unitTestRunner?: LibraryGeneratorSchema['unitTestRunner'];
|
|
9
|
+
// unitTestRunner?: LibraryGeneratorSchema['unitTestRunner'];
|
|
11
10
|
// TODO: test and consider exposing alternate bundlers
|
|
12
11
|
// bundler?: LibraryGeneratorSchema['bundler'];
|
|
13
|
-
linter?: LibraryGeneratorSchema['linter'];
|
|
14
|
-
scope?: string;
|
|
15
12
|
subDirectory?: string;
|
|
16
13
|
skipInstall?: boolean;
|
|
17
14
|
}
|
package/src/ts/lib/schema.json
CHANGED
|
@@ -14,28 +14,9 @@
|
|
|
14
14
|
"type": "string",
|
|
15
15
|
"description": "Parent directory where the library is placed.",
|
|
16
16
|
"default": "packages",
|
|
17
|
-
"x-prompt": "Which directory do you want to create the library in?"
|
|
18
|
-
},
|
|
19
|
-
"linter": {
|
|
20
|
-
"description": "The tool to use for running lint checks.",
|
|
21
|
-
"type": "string",
|
|
22
|
-
"enum": ["none", "eslint"],
|
|
23
|
-
"default": "eslint",
|
|
17
|
+
"x-prompt": "Which directory do you want to create the library in?",
|
|
24
18
|
"x-priority": "important"
|
|
25
19
|
},
|
|
26
|
-
"unitTestRunner": {
|
|
27
|
-
"description": "Test runner to use for unit tests.",
|
|
28
|
-
"type": "string",
|
|
29
|
-
"enum": ["none", "jest", "vitest"],
|
|
30
|
-
"default": "none",
|
|
31
|
-
"x-priority": "important"
|
|
32
|
-
},
|
|
33
|
-
"scope": {
|
|
34
|
-
"type": "string",
|
|
35
|
-
"description": "Scope for your package, e.g. @my-company. If omitted this will be inferred",
|
|
36
|
-
"pattern": "^@[a-z0-9-]+(?:/[a-z0-9-]+)?$",
|
|
37
|
-
"x-prompt": "What namespace would you like your library to have? i.e: @myapi"
|
|
38
|
-
},
|
|
39
20
|
"subDirectory": {
|
|
40
21
|
"type": "string",
|
|
41
22
|
"description": "The sub directory the lib is placed in. By default this is the library name.",
|
|
@@ -43,4 +24,4 @@
|
|
|
43
24
|
}
|
|
44
25
|
},
|
|
45
26
|
"required": ["name"]
|
|
46
|
-
}
|
|
27
|
+
}
|
|
@@ -7,7 +7,6 @@ exports.configureTsProject = void 0;
|
|
|
7
7
|
*/
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
-
const generator_1 = require("../cjs-to-esm/generator");
|
|
11
10
|
const npm_scope_1 = require("../../utils/npm-scope");
|
|
12
11
|
const vitest_1 = require("./vitest");
|
|
13
12
|
const eslint_1 = require("./eslint");
|
|
@@ -23,10 +22,10 @@ const configureTsProject = (tree, options) => {
|
|
|
23
22
|
: (_b = tsConfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.module }) }));
|
|
24
23
|
});
|
|
25
24
|
const outDirToRootRelativePath = (0, path_1.relative)((0, path_1.join)(tree.root, options.dir), tree.root);
|
|
26
|
-
const distDir = (0, path_1.join)(outDirToRootRelativePath, 'dist'
|
|
25
|
+
const distDir = (0, path_1.join)(outDirToRootRelativePath, 'dist');
|
|
27
26
|
// Remove baseUrl and rootDir from the tsconfig.lib.json
|
|
28
27
|
if (tree.exists((0, path_1.join)(options.dir, 'tsconfig.lib.json'))) {
|
|
29
|
-
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.dir, 'tsconfig.lib.json'), (tsConfig) => (Object.assign(Object.assign({}, tsConfig), { compilerOptions: Object.assign(Object.assign({}, tsConfig.compilerOptions), { baseUrl: undefined, rootDir: undefined, outDir: distDir, tsBuildInfoFile: (0, path_1.join)(distDir, 'tsconfig.lib.tsbuildinfo') })
|
|
28
|
+
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.dir, 'tsconfig.lib.json'), (tsConfig) => (Object.assign(Object.assign({}, tsConfig), { compilerOptions: Object.assign(Object.assign({}, tsConfig.compilerOptions), { baseUrl: undefined, rootDir: undefined, outDir: distDir, tsBuildInfoFile: (0, path_1.join)(distDir, options.dir, 'tsconfig.lib.tsbuildinfo') }) })));
|
|
30
29
|
}
|
|
31
30
|
// Update root project tsconfig
|
|
32
31
|
(0, devkit_1.updateJson)(tree, 'tsconfig.base.json', (tsConfig) => {
|
|
@@ -56,21 +55,7 @@ const configureTsProject = (tree, options) => {
|
|
|
56
55
|
if (tree.exists((0, path_1.join)(options.dir, 'package.json'))) {
|
|
57
56
|
tree.delete((0, path_1.join)(options.dir, 'package.json'));
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
(0, generator_1.cjsToEsm)(tree, '.', {
|
|
61
|
-
include: ['eslint.config.js', '**/eslint.config.js', '**/src/**/*.ts'],
|
|
62
|
-
});
|
|
63
|
-
// Build task should both test and lint, so move build to compile and compose build as compile + test + lint
|
|
64
|
-
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.fullyQualifiedName);
|
|
65
|
-
if (projectConfiguration.targets.build &&
|
|
66
|
-
projectConfiguration.targets.build.executor === '@nx/js:tsc') {
|
|
67
|
-
projectConfiguration.targets.compile = projectConfiguration.targets.build;
|
|
68
|
-
projectConfiguration.targets.build = {
|
|
69
|
-
dependsOn: ['compile', 'lint', 'test'],
|
|
70
|
-
};
|
|
71
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.fullyQualifiedName, projectConfiguration);
|
|
72
|
-
}
|
|
73
|
-
(0, eslint_1.configureEslint)(tree, options);
|
|
58
|
+
(0, eslint_1.configureEslint)(tree);
|
|
74
59
|
(0, vitest_1.configureVitest)(tree, options);
|
|
75
60
|
};
|
|
76
61
|
exports.configureTsProject = configureTsProject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-project-utils.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/ts-project-utils.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"ts-project-utils.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/ts-project-utils.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAAiE;AACjE,+BAAsC;AACtC,qDAAqD;AAErD,qCAA2C;AAC3C,qCAA2C;AAC3C;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAChC,IAAU,EACV,OAAgC,EAChC,EAAE;IACF,mDAAmD;IACnD,IAAA,mBAAU,EAAC,IAAI,EAAE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AAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,IAAA,wBAAe,EAAC,IAAI,CAAC,CAAC;IACtB,IAAA,wBAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC;AAjFW,QAAA,kBAAkB,sBAiF7B"}
|
package/src/ts/lib/vitest.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configureVitest = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
10
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
11
|
const path_1 = require("path");
|
|
7
12
|
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
@@ -49,6 +54,7 @@ const passWithNoTests = (sourceFile) => {
|
|
|
49
54
|
return result.transformed[0];
|
|
50
55
|
};
|
|
51
56
|
const configureVitest = (tree, options) => {
|
|
57
|
+
var _a;
|
|
52
58
|
const configPath = (0, path_1.join)(options.dir, 'vite.config.ts');
|
|
53
59
|
if (tree.exists(configPath)) {
|
|
54
60
|
const originalSourceFile = tsquery_1.tsquery.ast(tree.read(configPath, 'utf-8'));
|
|
@@ -59,6 +65,12 @@ const configureVitest = (tree, options) => {
|
|
|
59
65
|
newLine: typescript_1.default.NewLineKind.LineFeed,
|
|
60
66
|
});
|
|
61
67
|
tree.write(configPath, printer.printNode(typescript_1.default.EmitHint.Unspecified, sourceFile, originalSourceFile));
|
|
68
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
69
|
+
(0, devkit_1.updateNxJson)(tree, Object.assign(Object.assign({}, nxJson), { targetDefaults: Object.assign(Object.assign({}, ((_a = nxJson.targetDefaults) !== null && _a !== void 0 ? _a : {})), { '@nx/vite:test': Object.assign({ cache: true, inputs: ['default', '^production'], configurations: {
|
|
70
|
+
'update-snapshot': {
|
|
71
|
+
args: '--update',
|
|
72
|
+
},
|
|
73
|
+
} }, nxJson.targetDefaults['@nx/vite:test']) }) }));
|
|
62
74
|
}
|
|
63
75
|
};
|
|
64
76
|
exports.configureVitest = configureVitest;
|
package/src/ts/lib/vitest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/vitest.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/vitest.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAA4D;AAC5D,uDAAoD;AACpD,+BAA4B;AAC5B,oEAA4B;AAE5B,MAAM,eAAe,GAAG,CAAC,UAAyB,EAAiB,EAAE;IACnE,MAAM,WAAW,GACf,CAAoB,OAAiC,EAAE,EAAE,CACzD,CAAC,QAAW,EAAE,EAAE;QACd,SAAS,KAAK,CAAC,IAAa;YAC1B,IACE,oBAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACzB,oBAAE,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC;gBAChC,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,cAAc;gBACvC,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAC3B,CAAC;gBACD,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACvC,IAAI,oBAAE,CAAC,yBAAyB,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC/C,MAAM,YAAY,GAA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AC,oBAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAC3E,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;QAChC,IAAA,qBAAY,EAAC,IAAI,kCACZ,MAAM,KACT,cAAc,kCACT,CAAC,MAAA,MAAM,CAAC,cAAc,mCAAI,EAAE,CAAC,KAChC,eAAe,kBACb,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,EAClC,cAAc,EAAE;wBACd,iBAAiB,EAAE;4BACjB,IAAI,EAAE,UAAU;yBACjB;qBACF,IACE,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC,QAG7C,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AApCW,QAAA,eAAe,mBAoC1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { Tree } from '@nx/devkit';
|
|
6
|
+
import { NodeTransformer } from '@phenomnomnominal/tsquery';
|
|
7
|
+
import { JsxChild, JsxClosingElement, JsxOpeningElement } from 'typescript';
|
|
8
|
+
export declare const destructuredImport: (tree: Tree, filePath: string, variableNames: string[], from: string) => string;
|
|
9
|
+
export declare const singleImport: (tree: Tree, filePath: string, variableName: string, from: string) => string;
|
|
10
|
+
export declare const addStarExport: (tree: Tree, filePath: string, from: string) => void;
|
|
11
|
+
export declare const replace: (tree: Tree, filePath: string, selector: string, transformer: NodeTransformer, errorIfNoMatches?: boolean) => void;
|
|
12
|
+
export declare const createJsxElementFromIdentifier: (identifier: string, children: readonly JsxChild[]) => import("typescript").JsxElement;
|
|
13
|
+
export declare const createJsxElement: (openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) => import("typescript").JsxElement;
|
package/src/utils/ast.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createJsxElement = exports.createJsxElementFromIdentifier = exports.replace = exports.addStarExport = exports.singleImport = exports.destructuredImport = void 0;
|
|
4
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
5
|
+
const typescript_1 = require("typescript");
|
|
6
|
+
const assertFilePath = (tree, filePath) => {
|
|
7
|
+
if (!tree.exists(filePath)) {
|
|
8
|
+
throw new Error(`No file located at ${filePath}`);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const destructuredImport = (tree, filePath, variableNames, from) => {
|
|
12
|
+
assertFilePath(tree, filePath);
|
|
13
|
+
const contents = tree.read(filePath).toString();
|
|
14
|
+
const sourceAst = (0, tsquery_1.ast)(contents);
|
|
15
|
+
// Check if any of the variables are already imported from the same module
|
|
16
|
+
const existingImports = tsquery_1.tsquery.query(sourceAst, `ImportDeclaration[moduleSpecifier.text="${from}"] ImportClause ImportSpecifier`);
|
|
17
|
+
const existingVariables = new Set(existingImports.map((node) => {
|
|
18
|
+
const importSpecifier = node;
|
|
19
|
+
return importSpecifier.name.escapedText.toString();
|
|
20
|
+
}));
|
|
21
|
+
// Filter out variables that are already imported
|
|
22
|
+
const newVariables = variableNames.filter((name) => !existingVariables.has(name.includes(' as ') ? name.split(' as ')[1] : name));
|
|
23
|
+
if (newVariables.length === 0) {
|
|
24
|
+
return contents;
|
|
25
|
+
}
|
|
26
|
+
const destructuredImport = typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, undefined, typescript_1.factory.createNamedImports([
|
|
27
|
+
...existingImports,
|
|
28
|
+
...newVariables.map((variableName) => {
|
|
29
|
+
const [name, alias] = variableName.split(' as ');
|
|
30
|
+
return typescript_1.factory.createImportSpecifier(false, alias ? typescript_1.factory.createIdentifier(name) : undefined, typescript_1.factory.createIdentifier(alias || name));
|
|
31
|
+
}),
|
|
32
|
+
])), typescript_1.factory.createStringLiteral(from, true));
|
|
33
|
+
const updatedContents = tsquery_1.tsquery
|
|
34
|
+
.map((0, tsquery_1.ast)(contents), 'SourceFile', (node) => {
|
|
35
|
+
return Object.assign(Object.assign({}, node), { statements: [destructuredImport, ...node.statements] });
|
|
36
|
+
})
|
|
37
|
+
.getFullText();
|
|
38
|
+
if (contents !== updatedContents) {
|
|
39
|
+
tree.write(filePath, updatedContents);
|
|
40
|
+
}
|
|
41
|
+
return updatedContents;
|
|
42
|
+
};
|
|
43
|
+
exports.destructuredImport = destructuredImport;
|
|
44
|
+
const singleImport = (tree, filePath, variableName, from) => {
|
|
45
|
+
assertFilePath(tree, filePath);
|
|
46
|
+
const contents = tree.read(filePath).toString();
|
|
47
|
+
const sourceAst = (0, tsquery_1.ast)(contents);
|
|
48
|
+
// Check if the import already exists
|
|
49
|
+
const existingImports = tsquery_1.tsquery.query(sourceAst, `ImportDeclaration[moduleSpecifier.text="${from}"] ImportClause > Identifier[text="${variableName}"]`);
|
|
50
|
+
if (existingImports.length > 0) {
|
|
51
|
+
return contents;
|
|
52
|
+
}
|
|
53
|
+
const importDeclaration = typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier(variableName), undefined), typescript_1.factory.createStringLiteral(from));
|
|
54
|
+
const updatedContents = tsquery_1.tsquery
|
|
55
|
+
.map((0, tsquery_1.ast)(contents), 'SourceFile', (node) => {
|
|
56
|
+
return Object.assign(Object.assign({}, node), { statements: [importDeclaration, ...node.statements] });
|
|
57
|
+
})
|
|
58
|
+
.getFullText();
|
|
59
|
+
if (contents !== updatedContents) {
|
|
60
|
+
tree.write(filePath, updatedContents);
|
|
61
|
+
}
|
|
62
|
+
return updatedContents;
|
|
63
|
+
};
|
|
64
|
+
exports.singleImport = singleImport;
|
|
65
|
+
const addStarExport = (tree, filePath, from) => {
|
|
66
|
+
const indexContents = tree.exists(filePath)
|
|
67
|
+
? tree.read(filePath).toString()
|
|
68
|
+
: '';
|
|
69
|
+
const hasExport = tsquery_1.tsquery.query((0, tsquery_1.ast)(indexContents), `ExportDeclaration StringLiteral[text="${from}"]`).length > 0;
|
|
70
|
+
if (!hasExport) {
|
|
71
|
+
const exportDeclaration = typescript_1.factory.createExportDeclaration(undefined, undefined, undefined, typescript_1.factory.createStringLiteral(from));
|
|
72
|
+
const updatedIndexContents = tsquery_1.tsquery
|
|
73
|
+
.map((0, tsquery_1.ast)(indexContents), 'SourceFile', (node) => (Object.assign(Object.assign({}, node), { statements: [exportDeclaration, ...node.statements] })))
|
|
74
|
+
.getFullText();
|
|
75
|
+
if (indexContents !== updatedIndexContents) {
|
|
76
|
+
tree.write(filePath, updatedIndexContents);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.addStarExport = addStarExport;
|
|
81
|
+
const replace = (tree, filePath, selector, transformer, errorIfNoMatches = true) => {
|
|
82
|
+
assertFilePath(tree, filePath);
|
|
83
|
+
const source = tree.read(filePath).toString();
|
|
84
|
+
if (errorIfNoMatches) {
|
|
85
|
+
const queryNodes = tsquery_1.tsquery.query((0, tsquery_1.ast)(source), selector);
|
|
86
|
+
if (queryNodes.length === 0) {
|
|
87
|
+
throw new Error(`Could not locate a element im ${filePath} matching ${selector}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const updatedSource = tsquery_1.tsquery
|
|
91
|
+
.map((0, tsquery_1.ast)(source), selector, transformer)
|
|
92
|
+
.getFullText();
|
|
93
|
+
if (source !== updatedSource) {
|
|
94
|
+
tree.write(filePath, updatedSource);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
exports.replace = replace;
|
|
98
|
+
const createJsxElementFromIdentifier = (identifier, children) => typescript_1.factory.createJsxElement(typescript_1.factory.createJsxOpeningElement(typescript_1.factory.createIdentifier(identifier), undefined, typescript_1.factory.createJsxAttributes([])), children, typescript_1.factory.createJsxClosingElement(typescript_1.factory.createIdentifier(identifier)));
|
|
99
|
+
exports.createJsxElementFromIdentifier = createJsxElementFromIdentifier;
|
|
100
|
+
const createJsxElement = (openingElement, children, closingElement) => typescript_1.factory.createJsxElement(openingElement, children, closingElement);
|
|
101
|
+
exports.createJsxElement = createJsxElement;
|
|
102
|
+
//# sourceMappingURL=ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/ast.ts"],"names":[],"mappings":";;;AAKA,uDAA0E;AAC1E,2CAQoB;AACpB,MAAM,cAAc,GAAG,CAAC,IAAU,EAAE,QAAgB,EAAE,EAAE;IACtD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC,CAAC;AACK,MAAM,kBAAkB,GAAG,CAChC,IAAU,EACV,QAAgB,EAChB,aAAuB,EACvB,IAAY,EACJ,EAAE;IACV,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;IAChD,MAAM,SAAS,GAAG,IAAA,aAAG,EAAC,QAAQ,CAAC,CAAC;IAChC,0EAA0E;IAC1E,MAAM,eAAe,GAAsB,iBAAO,CAAC,KAAK,CACtD,SAAS,EACT,2CAA2C,IAAI,iCAAiC,CACjF,CAAC;IACF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAC/B,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3B,MAAM,eAAe,GAAG,IAAuB,CAAC;QAChD,OAAO,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;IACrD,CAAC,CAAC,CACH,CAAC;IACF,iDAAiD;IACjD,MAAM,YAAY,GAAG,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/src/utils/files/common/constructs/src/{runtime-config → core}/runtime-config.ts.template
RENAMED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
SPDX-License-Identifier: Apache-2.0 */
|
|
3
1
|
import type { IRuntimeConfig } from '<%= scopeAlias %>common-types';
|
|
4
2
|
import { Stack } from 'aws-cdk-lib';
|
|
5
3
|
import { Construct } from 'constructs';
|
|
@@ -7,6 +5,8 @@ import { Construct } from 'constructs';
|
|
|
7
5
|
const RuntimeConfigKey = '__RuntimeConfig__';
|
|
8
6
|
|
|
9
7
|
export class RuntimeConfig extends Construct {
|
|
8
|
+
private readonly _runtimeConfig: Partial<IRuntimeConfig> = {};
|
|
9
|
+
|
|
10
10
|
static ensure(scope: Construct): RuntimeConfig {
|
|
11
11
|
const stack = Stack.of(scope);
|
|
12
12
|
return (
|
|
@@ -21,13 +21,11 @@ export class RuntimeConfig extends Construct {
|
|
|
21
21
|
| undefined;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
private readonly _runtimeConfig: IRuntimeConfig = {};
|
|
25
|
-
|
|
26
24
|
constructor(scope: Construct, id: string) {
|
|
27
25
|
super(scope, id);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
get config(): IRuntimeConfig {
|
|
28
|
+
get config(): Partial<IRuntimeConfig> {
|
|
31
29
|
return this._runtimeConfig;
|
|
32
30
|
}
|
|
33
31
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './app/index.js';
|
|
2
|
+
export * from './core/index.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# <%= fullyQualifiedName %>
|
|
2
|
+
|
|
3
|
+
This library was generated with [@aws/nx-plugin](https://github.com/awslabs/nx-plugin-for-aws/).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `<%= pkgMgrCmd %> nx build <%= fullyQualifiedName %> [--skip-nx-cache]` to build the application.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `<%= pkgMgrCmd %> nx test <%= fullyQualifiedName %>` to execute the unit tests via Vitest.
|
|
12
|
+
|
|
13
|
+
### Updating snapshots
|
|
14
|
+
|
|
15
|
+
To update snapshots, run the following command:
|
|
16
|
+
|
|
17
|
+
`<%= pkgMgrCmd %> nx test <%= fullyQualifiedName %> --configuration=update-snapshot`
|
|
18
|
+
|
|
19
|
+
## Run lint
|
|
20
|
+
|
|
21
|
+
Run `<%= pkgMgrCmd %> nx lint <%= fullyQualifiedName %>`
|
|
22
|
+
|
|
23
|
+
### Fixable issues
|
|
24
|
+
|
|
25
|
+
You can also automatiaclly fix some lint errors by running the following command:
|
|
26
|
+
|
|
27
|
+
`<%= pkgMgrCmd %> nx lint <%= fullyQualifiedName %> --configuration=fix`
|
|
28
|
+
|
|
29
|
+
## Useful links
|
|
30
|
+
|
|
31
|
+
- [<%= name %> reference docs](TODO)
|
|
32
|
+
- [Learn more about NX](https://nx.dev/getting-started/intro)
|
|
33
|
+
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
identityPoolId: string;
|
|
4
|
-
userPoolId: string;
|
|
5
|
-
userPoolWebClientId: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IRuntimeConfig {
|
|
9
|
-
cognitoProps?: ICognitoProps;
|
|
10
|
-
trpcApis?: {
|
|
11
|
-
[apiName: string]: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface
|
|
2
|
+
export interface IRuntimeConfig {}
|
package/src/utils/format.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ import { Tree } from '@nx/devkit';
|
|
|
7
7
|
* Format files in the given directory within the tree
|
|
8
8
|
* See https://github.com/nrwl/nx/blob/4cd640a9187954505d12de5b6d76a90d8ce4c2eb/packages/devkit/src/generators/format-files.ts#L11
|
|
9
9
|
*/
|
|
10
|
-
export declare function formatFilesInSubtree(tree: Tree, dir
|
|
10
|
+
export declare function formatFilesInSubtree(tree: Tree, dir?: string): Promise<void>;
|
package/src/utils/format.js
CHANGED
|
@@ -25,7 +25,7 @@ function formatFilesInSubtree(tree, dir) {
|
|
|
25
25
|
const files = new Set(tree
|
|
26
26
|
.listChanges()
|
|
27
27
|
.filter((file) => file.type !== 'DELETE')
|
|
28
|
-
.filter((file) => file.path.startsWith(dir)));
|
|
28
|
+
.filter((file) => (dir ? file.path.startsWith(dir) : true)));
|
|
29
29
|
const changedPrettierInTree = getChangedPrettierConfigInTree(tree);
|
|
30
30
|
yield Promise.all(Array.from(files).map((file) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
try {
|
|
@@ -33,7 +33,7 @@ function formatFilesInSubtree(tree, dir) {
|
|
|
33
33
|
const resolvedOptions = yield prettier.resolveConfig(systemPath, {
|
|
34
34
|
editorconfig: true,
|
|
35
35
|
});
|
|
36
|
-
const options = Object.assign(Object.assign(Object.assign({}, resolvedOptions), changedPrettierInTree), { filepath: systemPath });
|
|
36
|
+
const options = Object.assign(Object.assign(Object.assign({ trailingComma: 'all' }, resolvedOptions), changedPrettierInTree), { filepath: systemPath });
|
|
37
37
|
const support = yield prettier.getFileInfo(systemPath, options);
|
|
38
38
|
if (support.ignored || !support.inferredParser) {
|
|
39
39
|
return;
|
package/src/utils/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/format.ts"],"names":[],"mappings":";;AAYA,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/format.ts"],"names":[],"mappings":";;AAYA,oDAgDC;;AA5DD;;;GAGG;AACH,uCAA4C;AAC5C,wDAAwB;AAGxB;;;GAGG;AACH,SAAs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,CACR,IAAI,CAAC,IAAI;gBACT,gDAAgD;gBAChD,MAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAEnD,CACZ,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;YACvE,CAAC;QACH,CAAC,CAAA,CAAC,CACH,CAAC;IACJ,CAAC;CAAA;AACD,SAAS,8BAA8B,CAAC,IAAU;IAChD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,EAAE,CAAC;QACnE,IAAI,CAAC;YACH,OAAO,IAAA,iBAAQ,EAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACvC,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toKebabCase = exports.toClassName = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
const lodash_kebabcase_1 = tslib_1.__importDefault(require("lodash.kebabcase"));
|
|
10
|
+
const toClassName = (str) => {
|
|
11
|
+
if (!str) {
|
|
12
|
+
return str;
|
|
13
|
+
}
|
|
14
|
+
const words = str.replace(/[^a-zA-Z0-9]/g, ' ').split(/\s+/);
|
|
15
|
+
return words
|
|
16
|
+
.map((word, index) => {
|
|
17
|
+
if (index === 0 && /^\d/.test(word)) {
|
|
18
|
+
return '_' + word;
|
|
19
|
+
}
|
|
20
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
21
|
+
})
|
|
22
|
+
.join('');
|
|
23
|
+
};
|
|
24
|
+
exports.toClassName = toClassName;
|
|
25
|
+
const toKebabCase = (str) => str === null || str === void 0 ? void 0 : str.split('/').map(lodash_kebabcase_1.default).join('/');
|
|
26
|
+
exports.toKebabCase = toKebabCase;
|
|
27
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/names.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,gFAAyC;AAClC,MAAM,WAAW,GAAG,CAAC,GAAY,EAAU,EAAE;IAClD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7D,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACnB,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,OAAO,GAAG,GAAG,IAAI,CAAC;QACpB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC;AAbW,QAAA,WAAW,eAatB;AACK,MAAM,WAAW,GAAG,CAAC,GAAY,EAAU,EAAE,CAClD,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,0BAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;AAD9B,QAAA,WAAW,eACmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npm-scope.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/npm-scope.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"npm-scope.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/npm-scope.ts"],"names":[],"mappings":";;AAKA,kCAOC;AACD,8CAGC;AAID,oCAIC;AAxBD;;;GAGG;AACH,uCAA4C;AAC5C,SAAgB,WAAW,CAAC,IAAU;IACpC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAC1C,CAAC,CAAC,IAAA,iBAAQ,EAEL,IAAI,EAAE,cAAc,CAAC;QAC1B,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACnB,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC,GAAG,CAAC,EAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7E,CAAC;AACD,SAAgB,iBAAiB,CAAC,IAAU;IAC1C,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC;AACD;;GAEG;AACH,SAAgB,YAAY,CAAC,qBAA6B;IACxD,OAAO,qBAAqB,CAAC,UAAU,CAAC,GAAG,CAAC;QAC1C,CAAC,CAAC,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACtC,CAAC,CAAC,qBAAqB,CAAC;AAC5B,CAAC"}
|
package/src/utils/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/paths.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAA4D;
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/paths.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAA4D;AACrD,MAAM,qBAAqB,GAAG,CACnC,IAAU,EACV,WAAmB,EACX,EAAE;IACV,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC;IACvC,OAAO,IAAA,wCAAgC,EAAC,WAAW,CAAC,CAAC;AACvD,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC;AACK,MAAM,gCAAgC,GAAG,CAAC,SAAiB,EAAU,EAAE;IAC5E,wEAAwE;IACxE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAC3D,wCAAwC;IACxC,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC,CAAC;AALW,QAAA,gCAAgC,oCAK3C"}
|