@aws/nx-plugin 0.5.1 → 0.7.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 +157 -0
- package/generators.json +26 -10
- package/package.json +3 -1
- package/src/api-connection/README.md +0 -0
- package/src/api-connection/generator.d.ts +20 -0
- package/src/api-connection/generator.js +101 -0
- package/src/api-connection/generator.js.map +1 -0
- package/src/api-connection/schema.d.ts +10 -0
- package/src/api-connection/schema.json +32 -0
- package/src/cloudscape-website/app/README.md +3 -3
- package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +4 -2
- package/src/cloudscape-website/app/files/common/constructs/src/app/static-websites/__websiteNameKebabCase__.ts.template +1 -1
- package/src/cloudscape-website/app/generator.js +25 -10
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/cognito-auth/README.md +4 -4
- package/src/infra/app/README.md +3 -3
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +24 -41
- package/src/infra/app/generator.js +2 -1
- package/src/infra/app/generator.js.map +1 -1
- package/src/py/fast-api/files/app/__name__/main.py.template +9 -0
- package/src/py/fast-api/files/app/tests/test_main.py +7 -0
- package/src/py/fast-api/files/common/constructs/src/app/http-apis/__apiNameKebabCase__.ts.template +22 -0
- package/src/py/fast-api/generator.d.ts +11 -0
- package/src/py/fast-api/generator.js +120 -0
- package/src/py/fast-api/generator.js.map +1 -0
- package/src/py/fast-api/schema.d.ts +9 -0
- package/src/py/fast-api/schema.json +22 -0
- package/src/py/project/generator.d.ts +31 -0
- package/src/py/project/generator.js +103 -0
- package/src/py/project/generator.js.map +1 -0
- package/src/py/project/schema.d.ts +11 -0
- package/src/py/project/schema.json +32 -0
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +50 -44
- package/src/trpc/backend/files/common/constructs/src/app/{trpc-apis → http-apis}/__apiNameKebabCase__.ts.template +7 -3
- package/src/trpc/backend/generator.js +30 -23
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.json +1 -1
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/trpc/react/files/src/hooks/useSigV4.tsx.template +1 -1
- package/src/trpc/react/generator.js +1 -40
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.json +1 -1
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +12 -33
- package/src/ts/lib/eslint.js +28 -0
- package/src/ts/lib/eslint.js.map +1 -1
- package/src/ts/lib/generator.js +20 -12
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.js +2 -2
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/utils/ast.d.ts +4 -0
- package/src/utils/ast.js +10 -1
- package/src/utils/ast.js.map +1 -1
- package/src/{trpc/backend/files/common/constructs/src/core/trpc-api.ts.template → utils/files/http-api/common/constructs/src/core/http-api.ts.template} +20 -18
- package/src/utils/http-api.d.ts +6 -0
- package/src/utils/http-api.js +61 -0
- package/src/utils/http-api.js.map +1 -0
- package/src/utils/names.d.ts +1 -0
- package/src/utils/names.js +4 -1
- package/src/utils/names.js.map +1 -1
- package/src/utils/npm-scope.js +2 -2
- package/src/utils/npm-scope.js.map +1 -1
- package/src/utils/nx.d.ts +8 -0
- package/src/utils/nx.js +11 -0
- package/src/utils/nx.js.map +1 -0
- package/src/utils/shared-constructs.js +1 -1
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/versions.d.ts +5 -2
- package/src/utils/versions.js +4 -1
- package/src/utils/versions.js.map +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "TsLib",
|
|
4
|
+
"title": "Create a Python project",
|
|
5
|
+
"description": "Create a Python project.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Project name.",
|
|
11
|
+
"x-priority": "important"
|
|
12
|
+
},
|
|
13
|
+
"directory": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Parent directory where the project is placed.",
|
|
16
|
+
"default": "packages",
|
|
17
|
+
"x-prompt": "Which directory do you want to create the project in?",
|
|
18
|
+
"x-priority": "important"
|
|
19
|
+
},
|
|
20
|
+
"projectType": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Project type",
|
|
23
|
+
"default": "application",
|
|
24
|
+
"enum": ["application", "library"]
|
|
25
|
+
},
|
|
26
|
+
"moduleName": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "Python module name"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"required": ["name", "projectType"]
|
|
32
|
+
}
|
|
@@ -327,71 +327,46 @@ export type IEchoOutput = z.TypeOf<typeof EchoOutputSchema>;
|
|
|
327
327
|
"
|
|
328
328
|
`;
|
|
329
329
|
|
|
330
|
-
exports[`trpc backend generator > should set up shared constructs >
|
|
331
|
-
"export * from './test-api.js';
|
|
332
|
-
"
|
|
333
|
-
`;
|
|
334
|
-
|
|
335
|
-
exports[`trpc backend generator > should set up shared constructs > test-api.ts 1`] = `
|
|
336
|
-
"import { Construct } from 'constructs';
|
|
337
|
-
import * as url from 'url';
|
|
338
|
-
import { TrpcApi } from '../../core/trpc-api.js';
|
|
339
|
-
import { HttpIamAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
340
|
-
|
|
341
|
-
export class TestApi extends TrpcApi {
|
|
342
|
-
constructor(scope: Construct, id: string) {
|
|
343
|
-
super(scope, id, {
|
|
344
|
-
defaultAuthorizer: new HttpIamAuthorizer(),
|
|
345
|
-
handlerFilePath: url.fileURLToPath(
|
|
346
|
-
new URL(
|
|
347
|
-
'../../../../../../apps/test-api/backend/src/router.ts',
|
|
348
|
-
import.meta.url,
|
|
349
|
-
),
|
|
350
|
-
),
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
"
|
|
355
|
-
`;
|
|
356
|
-
|
|
357
|
-
exports[`trpc backend generator > should set up shared constructs > trpc-api.ts 1`] = `
|
|
330
|
+
exports[`trpc backend generator > should set up shared constructs > http-api.ts 1`] = `
|
|
358
331
|
"import { Construct } from 'constructs';
|
|
359
|
-
import { Runtime, RuntimeFamily } from 'aws-cdk-lib/aws-lambda';
|
|
360
332
|
import { CfnOutput, Duration } from 'aws-cdk-lib';
|
|
361
333
|
import {
|
|
362
334
|
CorsHttpMethod,
|
|
363
|
-
HttpApi,
|
|
335
|
+
HttpApi as _HttpApi,
|
|
364
336
|
HttpMethod,
|
|
365
337
|
IHttpRouteAuthorizer,
|
|
366
338
|
} from 'aws-cdk-lib/aws-apigatewayv2';
|
|
367
339
|
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
368
|
-
import {
|
|
340
|
+
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
369
341
|
import { Effect, IRole, PolicyStatement } from 'aws-cdk-lib/aws-iam';
|
|
370
342
|
import { RuntimeConfig } from './runtime-config.js';
|
|
371
343
|
|
|
372
|
-
export interface
|
|
344
|
+
export interface HttpApiProps {
|
|
345
|
+
readonly apiName: string;
|
|
346
|
+
readonly handler: string;
|
|
373
347
|
readonly handlerFilePath: string;
|
|
348
|
+
readonly runtime: Runtime;
|
|
374
349
|
readonly defaultAuthorizer: IHttpRouteAuthorizer;
|
|
375
350
|
readonly allowedOrigins?: string[];
|
|
376
351
|
}
|
|
377
352
|
|
|
378
|
-
export class
|
|
379
|
-
public readonly api:
|
|
353
|
+
export class HttpApi extends Construct {
|
|
354
|
+
public readonly api: _HttpApi;
|
|
380
355
|
|
|
381
|
-
constructor(scope: Construct, id: string, props:
|
|
356
|
+
constructor(scope: Construct, id: string, props: HttpApiProps) {
|
|
382
357
|
super(scope, id);
|
|
383
358
|
|
|
384
|
-
const routerFunction = new
|
|
359
|
+
const routerFunction = new Function(this, \`\${id}Handler\`, {
|
|
385
360
|
timeout: Duration.seconds(30),
|
|
386
|
-
runtime:
|
|
387
|
-
handler:
|
|
388
|
-
|
|
361
|
+
runtime: props.runtime,
|
|
362
|
+
handler: props.handler,
|
|
363
|
+
code: Code.fromAsset(props.handlerFilePath),
|
|
389
364
|
environment: {
|
|
390
365
|
AWS_CONNECTION_REUSE_ENABLED: '1',
|
|
391
366
|
},
|
|
392
367
|
});
|
|
393
368
|
|
|
394
|
-
this.api = new
|
|
369
|
+
this.api = new _HttpApi(this, id, {
|
|
395
370
|
corsPreflight: {
|
|
396
371
|
allowOrigins: props.allowedOrigins ?? ['*'],
|
|
397
372
|
allowMethods: [CorsHttpMethod.ANY],
|
|
@@ -422,11 +397,11 @@ export class TrpcApi extends Construct {
|
|
|
422
397
|
),
|
|
423
398
|
});
|
|
424
399
|
|
|
425
|
-
new CfnOutput(this, \`\${
|
|
400
|
+
new CfnOutput(this, \`\${props.apiName}Url\`, { value: this.api.url! });
|
|
426
401
|
|
|
427
|
-
RuntimeConfig.ensure(this).config.
|
|
428
|
-
...RuntimeConfig.ensure(this).config.
|
|
429
|
-
[
|
|
402
|
+
RuntimeConfig.ensure(this).config.httpApis = {
|
|
403
|
+
...RuntimeConfig.ensure(this).config.httpApis!,
|
|
404
|
+
[props.apiName]: this.api.url!,
|
|
430
405
|
};
|
|
431
406
|
}
|
|
432
407
|
|
|
@@ -442,3 +417,34 @@ export class TrpcApi extends Construct {
|
|
|
442
417
|
}
|
|
443
418
|
"
|
|
444
419
|
`;
|
|
420
|
+
|
|
421
|
+
exports[`trpc backend generator > should set up shared constructs > index.ts 1`] = `
|
|
422
|
+
"export * from './test-api.js';
|
|
423
|
+
"
|
|
424
|
+
`;
|
|
425
|
+
|
|
426
|
+
exports[`trpc backend generator > should set up shared constructs > test-api.ts 1`] = `
|
|
427
|
+
"import { Construct } from 'constructs';
|
|
428
|
+
import * as url from 'url';
|
|
429
|
+
import { HttpApi } from '../../core/http-api.js';
|
|
430
|
+
import { HttpIamAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
431
|
+
import { Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
432
|
+
|
|
433
|
+
export class TestApi extends HttpApi {
|
|
434
|
+
constructor(scope: Construct, id: string) {
|
|
435
|
+
super(scope, id, {
|
|
436
|
+
defaultAuthorizer: new HttpIamAuthorizer(),
|
|
437
|
+
apiName: 'TestApi',
|
|
438
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
439
|
+
handler: 'index.handler',
|
|
440
|
+
handlerFilePath: url.fileURLToPath(
|
|
441
|
+
new URL(
|
|
442
|
+
'../../../../../../dist/apps/test-api/backend/bundle',
|
|
443
|
+
import.meta.url,
|
|
444
|
+
),
|
|
445
|
+
),
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
"
|
|
450
|
+
`;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { Construct } from 'constructs';
|
|
2
2
|
import * as url from 'url';
|
|
3
|
-
import {
|
|
3
|
+
import { HttpApi } from '../../core/http-api.js';
|
|
4
4
|
import { HttpIamAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
5
|
+
import { Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
5
6
|
|
|
6
|
-
export class <%= apiNameClassName %> extends
|
|
7
|
+
export class <%= apiNameClassName %> extends HttpApi {
|
|
7
8
|
constructor(scope: Construct, id: string) {
|
|
8
9
|
super(scope, id, {
|
|
9
10
|
defaultAuthorizer: new HttpIamAuthorizer(),
|
|
11
|
+
apiName: '<%= apiNameClassName %>',
|
|
12
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
13
|
+
handler: 'index.handler',
|
|
10
14
|
handlerFilePath: url.fileURLToPath(
|
|
11
15
|
new URL(
|
|
12
|
-
'
|
|
16
|
+
'../../../../../../dist/<%= backendRoot %>/bundle',
|
|
13
17
|
import.meta.url
|
|
14
18
|
)
|
|
15
19
|
)
|
|
@@ -12,10 +12,11 @@ const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
|
12
12
|
const generator_1 = tslib_1.__importDefault(require("../../ts/lib/generator"));
|
|
13
13
|
const npm_scope_1 = require("../../utils/npm-scope");
|
|
14
14
|
const versions_1 = require("../../utils/versions");
|
|
15
|
-
const paths_1 = require("../../utils/paths");
|
|
16
15
|
const names_1 = require("../../utils/names");
|
|
17
16
|
const ast_1 = require("../../utils/ast");
|
|
18
17
|
const format_1 = require("../../utils/format");
|
|
18
|
+
const http_api_1 = require("../../utils/http-api");
|
|
19
|
+
const nx_1 = require("../../utils/nx");
|
|
19
20
|
function trpcBackendGenerator(tree, options) {
|
|
20
21
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
var _a;
|
|
@@ -24,7 +25,6 @@ function trpcBackendGenerator(tree, options) {
|
|
|
24
25
|
const apiNameKebabCase = (0, lodash_kebabcase_1.default)(options.apiName);
|
|
25
26
|
const apiNameClassName = (0, names_1.toClassName)(options.apiName);
|
|
26
27
|
const projectRoot = (0, devkit_1.joinPathFragments)((_a = options.directory) !== null && _a !== void 0 ? _a : '.', apiNameKebabCase);
|
|
27
|
-
const relativePathToProjectRoot = `${(0, devkit_1.joinPathFragments)((0, paths_1.getRelativePathToRoot)(tree, `${(0, npm_scope_1.getNpmScopePrefix)(tree)}common-constructs`), projectRoot)}`;
|
|
28
28
|
const schemaRoot = (0, devkit_1.joinPathFragments)(projectRoot, 'schema');
|
|
29
29
|
const backendRoot = (0, devkit_1.joinPathFragments)(projectRoot, 'backend');
|
|
30
30
|
const backendName = `${apiNameKebabCase}-backend`;
|
|
@@ -33,7 +33,7 @@ function trpcBackendGenerator(tree, options) {
|
|
|
33
33
|
const schemaProjectName = `${apiNamespace}${schemaName}`;
|
|
34
34
|
const enhancedOptions = Object.assign({ backendProjectName, backendProjectAlias: (0, npm_scope_1.toScopeAlias)(backendProjectName), schemaProjectName, schemaProjectAlias: (0, npm_scope_1.toScopeAlias)(schemaProjectName), apiNameKebabCase,
|
|
35
35
|
apiNameClassName,
|
|
36
|
-
|
|
36
|
+
backendRoot, pkgMgrCmd: (0, devkit_1.getPackageManagerCommand)().exec }, options);
|
|
37
37
|
yield (0, generator_1.default)(tree, {
|
|
38
38
|
name: backendName,
|
|
39
39
|
directory: projectRoot,
|
|
@@ -44,33 +44,40 @@ function trpcBackendGenerator(tree, options) {
|
|
|
44
44
|
directory: projectRoot,
|
|
45
45
|
subDirectory: 'schema',
|
|
46
46
|
});
|
|
47
|
-
if (!tree.exists((0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', '
|
|
47
|
+
if (!tree.exists((0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'http-apis', `${apiNameKebabCase}.ts`))) {
|
|
48
48
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app'), (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app'), enhancedOptions, {
|
|
49
49
|
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
50
50
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core'), (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core'), enhancedOptions, {
|
|
54
|
-
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'index.ts'), './trpc-apis/index.js');
|
|
58
|
-
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'trpc-apis', 'index.ts'), `./${apiNameKebabCase}.js`);
|
|
59
|
-
if (shouldGenerateCoreTrpcApiConstruct) {
|
|
60
|
-
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'core', 'index.ts'), './trpc-api.js');
|
|
61
|
-
}
|
|
51
|
+
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'index.ts'), './http-apis/index.js');
|
|
52
|
+
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_1.PACKAGES_DIR, shared_constructs_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'http-apis', 'index.ts'), `./${apiNameKebabCase}.js`);
|
|
62
53
|
}
|
|
54
|
+
(0, http_api_1.addHttpApi)(tree, apiNameClassName);
|
|
63
55
|
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(backendRoot, 'project.json'), (config) => {
|
|
56
|
+
var _a;
|
|
64
57
|
config.metadata = {
|
|
65
58
|
apiName: options.apiName,
|
|
59
|
+
apiType: 'trpc',
|
|
66
60
|
};
|
|
67
|
-
config.targets =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
config.targets.serve = {
|
|
62
|
+
executor: 'nx:run-commands',
|
|
63
|
+
options: {
|
|
64
|
+
commands: ['tsx src/local-server.ts'],
|
|
65
|
+
cwd: backendRoot,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
config.targets.bundle = {
|
|
69
|
+
cache: true,
|
|
70
|
+
executor: 'nx:run-commands',
|
|
71
|
+
outputs: [`{workspaceRoot}/dist/${backendRoot}/bundle`],
|
|
72
|
+
options: {
|
|
73
|
+
command: `esbuild ${backendRoot}/src/index.ts --bundle --outfile=dist/${backendRoot}/bundle/index.js --platform=node --format=cjs`
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
config.targets.build.dependsOn = [
|
|
77
|
+
...((_a = config.targets.build.dependsOn) !== null && _a !== void 0 ? _a : []),
|
|
78
|
+
'bundle',
|
|
79
|
+
];
|
|
80
|
+
config.targets = (0, nx_1.sortProjectTargets)(config.targets);
|
|
74
81
|
return config;
|
|
75
82
|
});
|
|
76
83
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'backend'), backendRoot, enhancedOptions, {
|
|
@@ -90,7 +97,7 @@ function trpcBackendGenerator(tree, options) {
|
|
|
90
97
|
'@trpc/server',
|
|
91
98
|
'aws4fetch',
|
|
92
99
|
'@aws-sdk/credential-providers',
|
|
93
|
-
]), (0, versions_1.withVersions)(['@types/aws-lambda', 'tsx']));
|
|
100
|
+
]), (0, versions_1.withVersions)(['@types/aws-lambda', 'esbuild', 'tsx']));
|
|
94
101
|
tree.delete((0, devkit_1.joinPathFragments)(backendRoot, 'package.json'));
|
|
95
102
|
tree.delete((0, devkit_1.joinPathFragments)(schemaRoot, 'package.json'));
|
|
96
103
|
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/backend/generator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/backend/generator.ts"],"names":[],"mappings":";;AA8BA,oDA0KC;;AAxMD;;;GAGG;AACH,uCAUoB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C,IAAA,0BAAiB,EAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACzD,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,uBAAY,EAAC;YACX,mBAAmB;YACnB,KAAK;YACL,+BAA+B;YAC/B,gCAAgC;YAChC,+BAA+B;YAC/B,cAAc;YACd,WAAW;YACX,+BAA+B;SAChC,CAAC,EACF,IAAA,uBAAY,EAAC,CAAC,mBAAmB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CACtD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;QAC3D,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,oBAAoB,CAAC"}
|
|
@@ -90,7 +90,7 @@ import { FC, PropsWithChildren } from 'react';
|
|
|
90
90
|
const TrpcClientProviders: FC<PropsWithChildren> = ({ children }) => {
|
|
91
91
|
const runtimeConfig = useRuntimeConfig();
|
|
92
92
|
return (
|
|
93
|
-
<TrpcApis.TestApi.Provider apiUrl={runtimeConfig.
|
|
93
|
+
<TrpcApis.TestApi.Provider apiUrl={runtimeConfig.httpApis.TestApi}>
|
|
94
94
|
{children}
|
|
95
95
|
</TrpcApis.TestApi.Provider>
|
|
96
96
|
);
|
|
@@ -50,6 +50,6 @@ export const useSigV4 = () => {
|
|
|
50
50
|
const awsClient = new AwsClient(credential);
|
|
51
51
|
return awsClient.fetch(input, init);
|
|
52
52
|
},
|
|
53
|
-
[cognitoProps, user?.id_token, user
|
|
53
|
+
[cognitoProps, user?.id_token, user?.profile.sub, withCachedCredentials]
|
|
54
54
|
);
|
|
55
55
|
};
|
|
@@ -10,7 +10,6 @@ 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");
|
|
14
13
|
const npm_scope_1 = require("../../utils/npm-scope");
|
|
15
14
|
const versions_1 = require("../../utils/versions");
|
|
16
15
|
const ast_1 = require("../../utils/ast");
|
|
@@ -34,44 +33,6 @@ function reactGenerator(tree, options) {
|
|
|
34
33
|
yield (0, generator_1.runtimeConfigGenerator)(tree, {
|
|
35
34
|
project: options.frontendProjectName,
|
|
36
35
|
});
|
|
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
36
|
// update main.tsx
|
|
76
37
|
const mainTsxPath = (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'main.tsx');
|
|
77
38
|
(0, ast_1.singleImport)(tree, mainTsxPath, 'TrpcClientProviders', './components/TrpcClients');
|
|
@@ -134,7 +95,7 @@ function reactGenerator(tree, options) {
|
|
|
134
95
|
? (_a = node.expression) === null || _a === void 0 ? void 0 : _a.expression
|
|
135
96
|
: node.expression;
|
|
136
97
|
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('
|
|
98
|
+
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('httpApis')), typescript_1.factory.createIdentifier(apiNameClassName)))),
|
|
138
99
|
])), [
|
|
139
100
|
(0, typescript_1.isJsxChild)(existingExpression) ||
|
|
140
101
|
(0, typescript_1.isJsxElement)(existingExpression) ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/react/generator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/react/generator.ts"],"names":[],"mappings":";;AAyCA,wCAuQC;;AAhTD;;;GAGG;AACH,uCAQoB;AAEpB,2CAcoB;AACpB,uDAAyD;AACzD,iFAA2F;AAC3F,qDAAqD;AACrD,mDAAoD;AACpD,yCAKyB;AACzB,6CAAgD;AAChD,+CAA0D;AAC1D,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,GAAG,MAAC,oBAAoB,CAAC,QAAgB,0CAAE,OAAO,CAAC;QAChE,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,mBAAmB,GAAG,IAAA,wBAAY,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAErE,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,OAAO,CAAC,EACrC,qBAAqB,CAAC,IAAI,gCAExB,OAAO,EACP,gBAAgB,EAAE,IAAA,mBAAW,EAAC,OAAO,CAAC,IACnC,OAAO,KACV,mBAAmB,EAAE,IAAA,wBAAY,EAAC,OAAO,CAAC,kBAAkB,CAAC,KAE/D;YACE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY;SAClD,CACF,CAAC;QACF,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,qBAAqB,CAAC,IAAI,yBAAyB,CAAC,CAAC;QACtE,CAAC;QACD,MAAM,IAAA,kCAAsB,EAAC,IAAI,EAAE;YACjC,OAAO,EAAE,OAAO,CA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C,gBAAgB,CAAC,UAAU,CAAC,EACpC,oBAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAC3C,EACD,oBAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CACb,CAC1B,CACF,CACF,CAAC;YACJ,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,IAAA,uBAAY,EAAC,CAAC,eAAe,CAAC,CAAC,CAChC,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,22 +23,15 @@ exports[`ts lib generator > should generate library with custom directory > cust
|
|
|
23
23
|
]
|
|
24
24
|
},
|
|
25
25
|
"compile": {
|
|
26
|
-
"executor": "
|
|
26
|
+
"executor": "nx:run-commands",
|
|
27
27
|
"outputs": [
|
|
28
|
-
"{
|
|
28
|
+
"{workspaceRoot}/dist/libs/test-lib/tsc"
|
|
29
29
|
],
|
|
30
30
|
"options": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"tsConfig": "libs/test-lib/tsconfig.json",
|
|
34
|
-
"assets": [
|
|
35
|
-
"libs/test-lib/*.md"
|
|
36
|
-
]
|
|
31
|
+
"command": "tsc --build tsconfig.lib.json",
|
|
32
|
+
"cwd": "{projectRoot}"
|
|
37
33
|
}
|
|
38
34
|
},
|
|
39
|
-
"lint": {
|
|
40
|
-
"executor": "@nx/eslint:lint"
|
|
41
|
-
},
|
|
42
35
|
"test": {
|
|
43
36
|
"executor": "@nx/vite:test",
|
|
44
37
|
"outputs": [
|
|
@@ -94,22 +87,15 @@ exports[`ts lib generator > should generate library with default options > proje
|
|
|
94
87
|
]
|
|
95
88
|
},
|
|
96
89
|
"compile": {
|
|
97
|
-
"executor": "
|
|
90
|
+
"executor": "nx:run-commands",
|
|
98
91
|
"outputs": [
|
|
99
|
-
"{
|
|
92
|
+
"{workspaceRoot}/dist/test-lib/tsc"
|
|
100
93
|
],
|
|
101
94
|
"options": {
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"tsConfig": "test-lib/tsconfig.json",
|
|
105
|
-
"assets": [
|
|
106
|
-
"test-lib/*.md"
|
|
107
|
-
]
|
|
95
|
+
"command": "tsc --build tsconfig.lib.json",
|
|
96
|
+
"cwd": "{projectRoot}"
|
|
108
97
|
}
|
|
109
98
|
},
|
|
110
|
-
"lint": {
|
|
111
|
-
"executor": "@nx/eslint:lint"
|
|
112
|
-
},
|
|
113
99
|
"test": {
|
|
114
100
|
"executor": "@nx/vite:test",
|
|
115
101
|
"outputs": [
|
|
@@ -165,22 +151,15 @@ exports[`ts lib generator > should generate library with subdirectory > subdir-p
|
|
|
165
151
|
]
|
|
166
152
|
},
|
|
167
153
|
"compile": {
|
|
168
|
-
"executor": "
|
|
154
|
+
"executor": "nx:run-commands",
|
|
169
155
|
"outputs": [
|
|
170
|
-
"{
|
|
156
|
+
"{workspaceRoot}/dist/feature/test-lib/tsc"
|
|
171
157
|
],
|
|
172
158
|
"options": {
|
|
173
|
-
"
|
|
174
|
-
"
|
|
175
|
-
"tsConfig": "feature/test-lib/tsconfig.json",
|
|
176
|
-
"assets": [
|
|
177
|
-
"feature/test-lib/*.md"
|
|
178
|
-
]
|
|
159
|
+
"command": "tsc --build tsconfig.lib.json",
|
|
160
|
+
"cwd": "{projectRoot}"
|
|
179
161
|
}
|
|
180
162
|
},
|
|
181
|
-
"lint": {
|
|
182
|
-
"executor": "@nx/eslint:lint"
|
|
183
|
-
},
|
|
184
163
|
"test": {
|
|
185
164
|
"executor": "@nx/vite:test",
|
|
186
165
|
"outputs": [
|
package/src/ts/lib/eslint.js
CHANGED
|
@@ -50,6 +50,34 @@ const configureEslint = (tree) => tslib_1.__awaiter(void 0, void 0, void 0, func
|
|
|
50
50
|
], true);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
+
// Check if ignores array exists in any object literal
|
|
54
|
+
const existingIgnores = tsquery_1.tsquery.query(updatedContent, 'ExportAssignment > ArrayLiteralExpression ObjectLiteralExpression > PropertyAssignment[name.text="ignores"]');
|
|
55
|
+
if (existingIgnores.length > 0) {
|
|
56
|
+
// Check if the entry already exists in the ignores array
|
|
57
|
+
const timestampIgnore = tsquery_1.tsquery.query(updatedContent, 'ExportAssignment > ArrayLiteralExpression ObjectLiteralExpression > PropertyAssignment[name.text="ignores"] > ArrayLiteralExpression StringLiteral[value="**/vite.config.ts.timestamp*"]');
|
|
58
|
+
if (timestampIgnore.length === 0) {
|
|
59
|
+
// Add to existing ignores array only if entry doesn't exist
|
|
60
|
+
updatedContent = tsquery_1.tsquery.map(updatedContent, 'ExportAssignment > ArrayLiteralExpression ObjectLiteralExpression > PropertyAssignment[name.text="ignores"] > ArrayLiteralExpression', (node) => {
|
|
61
|
+
return typescript_1.factory.createArrayLiteralExpression([
|
|
62
|
+
...node.elements,
|
|
63
|
+
typescript_1.factory.createStringLiteral('**/vite.config.ts.timestamp*'),
|
|
64
|
+
], true);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Create new object with ignores array
|
|
70
|
+
updatedContent = tsquery_1.tsquery.map(updatedContent, 'ExportAssignment > ArrayLiteralExpression', (node) => {
|
|
71
|
+
return typescript_1.factory.createArrayLiteralExpression([
|
|
72
|
+
...node.elements,
|
|
73
|
+
typescript_1.factory.createObjectLiteralExpression([
|
|
74
|
+
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('ignores'), typescript_1.factory.createArrayLiteralExpression([
|
|
75
|
+
typescript_1.factory.createStringLiteral('**/vite.config.ts.timestamp*'),
|
|
76
|
+
], true)),
|
|
77
|
+
], true),
|
|
78
|
+
], true);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
53
81
|
// Only write if changes were made
|
|
54
82
|
if (updatedContent !== sourceFile) {
|
|
55
83
|
tree.write(eslintConfigPath, updatedContent.getFullText());
|
package/src/ts/lib/eslint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/eslint.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAKoB;AACpB,mDAAoD;AACpD,uDAAyD;AACzD,2CAA6D;AAC7D,yCAA+C;AACxC,MAAM,eAAe,GAAG,CAAO,IAAU,EAAE,EAAE;;IAClD,0BAA0B;IAC1B,IAAI,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;IAC9B,IACE,CAAC,CAAA,MAAA,MAAM,CAAC,OAAO,0CACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,EACpC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,mBAAmB,CAAC,CAAA,EAChD,CAAC;QACD,IAAA,qBAAY,EAAC,IAAI,kCACZ,MAAM,KACT,OAAO,EAAE;gBACP,GAAG,CAAC,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC;gBACzB;oBACE,MAAM,EAAE,mBAAmB;oBAC3B,OAAO,EAAE;wBACP,UAAU,EAAE,MAAM;qBACnB;iBACF;aACF,IACD,CAAC;IACL,CAAC;IACD,IAAA,qCAA4B,EAC1B,IAAI,EACJ,EAAE,EACF,IAAA,uBAAY,EAAC,CAAC,UAAU,EAAE,wBAAwB,EAAE,qBAAqB,CAAC,CAAC,CAC5E,CAAC;IACF,qCAAqC;IACrC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;IAC7C,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAClC,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnE,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,mBAAmB,CAAC,CAAC;QAC5C,yBAAyB;QACzB,MAAM,cAAc,GAAG,iBAAO,CAAC,KAAK,CAClC,UAAU,EACV,kEAAkE,CACnE,CAAC;QACF,IAAI,cAAc,GAAG,UAAU,CAAC;QAChC,iCAAiC;QACjC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,cAAc,GAAG,IAAA,aAAG,EAClB,IAAA,kBAAY,EACV,IAAI,EACJ,gBAAgB,EAChB,iCAAiC,EACjC,oCAAoC,CACrC,CACF,CAAC;QACJ,CAAC;QACD,mEAAmE;QACnE,MAAM,cAAc,GAAG,iBAAO,CAAC,KAAK,CAClC,cAAc,EACd,8FAA8F,CAC/F,CAAC;QACF,mEAAmE;QACnE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,cAAc,GAAG,iBAAO,CAAC,GAAG,CAC1B,cAAc,EACd,2CAA2C,EAC3C,CAAC,IAA4B,EAAE,EAAE;gBAC/B,OAAO,oBAAO,CAAC,4BAA4B,CACzC;oBACE,oBAAO,CAAC,gBAAgB,CAAC,iCAAiC,CAAC;oBAC3D,GAAG,IAAI,CAAC,QAAQ;iBACjB,EACD,IAAI,CACL,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/eslint.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAKoB;AACp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