@aws/nx-plugin 0.1.0 → 0.1.2
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 +175 -0
- package/LICENSE-THIRD-PARTY +37594 -0
- package/NOTICE +2 -0
- package/package.json +11 -10
- package/src/cloudscape-website/app/generator.d.ts +4 -0
- package/src/cloudscape-website/app/generator.js +139 -170
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/app/schema.d.ts +4 -0
- package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +0 -4
- package/src/cloudscape-website/cognito-auth/generator.d.ts +4 -0
- package/src/cloudscape-website/cognito-auth/generator.js +82 -93
- package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
- package/src/cloudscape-website/cognito-auth/schema.d.ts +4 -0
- package/src/cloudscape-website/runtime-config/generator.d.ts +4 -0
- package/src/cloudscape-website/runtime-config/generator.js +56 -70
- package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
- package/src/cloudscape-website/runtime-config/schema.d.ts +4 -0
- package/src/gitlab/generator.d.ts +4 -0
- package/src/gitlab/generator.js +13 -22
- package/src/gitlab/generator.js.map +1 -1
- package/src/gitlab/schema.d.ts +4 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +4 -2
- package/src/index.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/infra/app/generator.d.ts +4 -0
- package/src/infra/app/generator.js +57 -71
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.ts +4 -0
- package/src/trpc/backend/generator.d.ts +4 -0
- package/src/trpc/backend/generator.js +95 -116
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +4 -1
- package/src/trpc/react/generator.d.ts +4 -0
- package/src/trpc/react/generator.js +62 -76
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.d.ts +4 -0
- package/src/ts/cjs-to-esm/generator.d.ts +4 -0
- package/src/ts/cjs-to-esm/generator.js +131 -143
- package/src/ts/cjs-to-esm/generator.js.map +1 -1
- package/src/ts/cjs-to-esm/schema.d.ts +4 -0
- package/src/ts/lib/eslint.d.ts +6 -2
- package/src/ts/lib/eslint.js +20 -28
- package/src/ts/lib/eslint.js.map +1 -1
- package/src/ts/lib/generator.d.ts +6 -2
- package/src/ts/lib/generator.js +35 -51
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.d.ts +6 -2
- package/src/ts/lib/ts-project-utils.d.ts +6 -2
- package/src/ts/lib/ts-project-utils.js +53 -83
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/types.d.ts +4 -0
- package/src/ts/lib/types.js +1 -4
- package/src/ts/lib/types.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +6 -2
- package/src/ts/lib/vitest.js +49 -51
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/utils/npm-scope.d.ts +4 -0
- package/src/utils/npm-scope.js +19 -27
- package/src/utils/npm-scope.js.map +1 -1
- package/src/utils/paths.d.ts +5 -1
- package/src/utils/paths.js +13 -23
- package/src/utils/paths.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +4 -0
- package/src/utils/shared-constructs.js +44 -68
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/versions.d.ts +23 -18
- package/src/utils/versions.js +35 -45
- package/src/utils/versions.js.map +1 -1
- package/src/cloudscape-website/app/schema.d.js +0 -6
- package/src/cloudscape-website/app/schema.d.js.map +0 -1
- package/src/cloudscape-website/cognito-auth/schema.d.js +0 -6
- package/src/cloudscape-website/cognito-auth/schema.d.js.map +0 -1
- package/src/cloudscape-website/runtime-config/schema.d.js +0 -6
- package/src/cloudscape-website/runtime-config/schema.d.js.map +0 -1
- package/src/gitlab/files/.gitlab-ci.yml.template +0 -26
- package/src/gitlab/schema.d.js +0 -6
- package/src/gitlab/schema.d.js.map +0 -1
- package/src/infra/app/schema.d.js +0 -6
- package/src/infra/app/schema.d.js.map +0 -1
- package/src/trpc/backend/schema.d.js +0 -6
- package/src/trpc/backend/schema.d.js.map +0 -1
- package/src/trpc/react/schema.d.js +0 -6
- package/src/trpc/react/schema.d.js.map +0 -1
- package/src/ts/cjs-to-esm/schema.d.js +0 -6
- package/src/ts/cjs-to-esm/schema.d.js.map +0 -1
- package/src/ts/lib/schema.d.js +0 -6
- package/src/ts/lib/schema.d.js.map +0 -1
package/src/ts/lib/eslint.js
CHANGED
|
@@ -1,41 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const _extends = require("@swc/helpers/_/_extends");
|
|
12
|
-
const _devkit = require("@nx/devkit");
|
|
13
|
-
const configureEslint = (tree, options)=>{
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureEslint = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const configureEslint = (tree, options) => {
|
|
10
|
+
var _a;
|
|
14
11
|
// Configure the lint task
|
|
15
|
-
const projectConfiguration = (0,
|
|
12
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.fullyQualifiedName);
|
|
16
13
|
if (!projectConfiguration.targets.lint) {
|
|
17
14
|
projectConfiguration.targets.lint = {
|
|
18
|
-
executor:
|
|
15
|
+
executor: '@nx/eslint:lint',
|
|
19
16
|
options: {
|
|
20
|
-
fix: true
|
|
21
|
-
}
|
|
17
|
+
fix: true,
|
|
18
|
+
},
|
|
22
19
|
};
|
|
23
|
-
(0,
|
|
20
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.fullyQualifiedName, projectConfiguration);
|
|
24
21
|
}
|
|
25
|
-
const nxJson = (0,
|
|
26
|
-
|
|
27
|
-
(0, _devkit.updateNxJson)(tree, _extends._({}, nxJson, {
|
|
28
|
-
targetDefaults: _extends._({}, (_nxJson_targetDefaults = nxJson.targetDefaults) != null ? _nxJson_targetDefaults : {}, {
|
|
29
|
-
lint: {
|
|
22
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
23
|
+
(0, devkit_1.updateNxJson)(tree, Object.assign(Object.assign({}, nxJson), { targetDefaults: Object.assign(Object.assign({}, ((_a = nxJson.targetDefaults) !== null && _a !== void 0 ? _a : {})), { lint: {
|
|
30
24
|
cache: true,
|
|
31
25
|
inputs: [
|
|
32
26
|
'default',
|
|
33
27
|
'{workspaceRoot}/eslint.config.js',
|
|
34
|
-
'{projectRoot}/eslint.config.js'
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
}));
|
|
28
|
+
'{projectRoot}/eslint.config.js',
|
|
29
|
+
],
|
|
30
|
+
} }) }));
|
|
39
31
|
};
|
|
40
|
-
|
|
32
|
+
exports.configureEslint = configureEslint;
|
|
41
33
|
//# sourceMappingURL=eslint.js.map
|
package/src/ts/lib/eslint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/eslint.ts"],"
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/eslint.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAMoB;AAGb,MAAM,eAAe,GAAG,CAC7B,IAAU,EACV,OAAgC,EAChC,EAAE;;IACF,0BAA0B;IAC1B,MAAM,oBAAoB,GAAG,IAAA,iCAAwB,EACnD,IAAI,EACJ,OAAO,CAAC,kBAAkB,CAC3B,CAAC;IACF,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACvC,oBAAoB,CAAC,OAAO,CAAC,IAAI,GAAG;YAClC,QAAQ,EAAE,iBAAiB;YAC3B,OAAO,EAAE;gBACP,GAAG,EAAE,IAAI;aACV;SACF,CAAC;QAEF,IAAA,mCAA0B,EACxB,IAAI,EACJ,OAAO,CAAC,kBAAkB,EAC1B,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;IAChC,IAAA,qBAAY,EAAC,IAAI,kCACZ,MAAM,KACT,cAAc,kCACT,CAAC,MAAA,MAAM,CAAC,cAAc,mCAAI,EAAE,CAAC,KAChC,IAAI,EAAE;gBACJ,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE;oBACN,SAAS;oBACT,kCAAkC;oBAClC,gCAAgC;iBACjC;aACF,OAEH,CAAC;AACL,CAAC,CAAC;AAvCW,QAAA,eAAe,mBAuC1B"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
6
|
+
import { TsLibGeneratorSchema } from './schema';
|
|
3
7
|
export interface TsLibDetails {
|
|
4
8
|
/**
|
|
5
9
|
* Full package name including scope (eg @foo/bar)
|
package/src/ts/lib/generator.js
CHANGED
|
@@ -1,61 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return tsLibGenerator;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _extends = require("@swc/helpers/_/_extends");
|
|
23
|
-
const _devkit = require("@nx/devkit");
|
|
24
|
-
const _js = require("@nx/js");
|
|
25
|
-
const _npmscope = require("../../utils/npm-scope");
|
|
26
|
-
const _tsprojectutils = require("./ts-project-utils");
|
|
27
|
-
const getTsLibDetails = (tree, schema)=>{
|
|
28
|
-
const scope = schema.scope ? `${schema.scope}/` : (0, _npmscope.getNpmScopePrefix)(tree);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tsLibGenerator = exports.getTsLibDetails = 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 devkit_1 = require("@nx/devkit");
|
|
10
|
+
const js_1 = require("@nx/js");
|
|
11
|
+
const npm_scope_1 = require("../../utils/npm-scope");
|
|
12
|
+
const ts_project_utils_1 = require("./ts-project-utils");
|
|
13
|
+
/**
|
|
14
|
+
* Returns details about the TS library to be created
|
|
15
|
+
*/
|
|
16
|
+
const getTsLibDetails = (tree, schema) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const scope = schema.scope ? `${schema.scope}/` : (0, npm_scope_1.getNpmScopePrefix)(tree);
|
|
29
19
|
const fullyQualifiedName = `${scope}${schema.name}`;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
dir,
|
|
34
|
-
fullyQualifiedName
|
|
35
|
-
};
|
|
20
|
+
const dir = (0, devkit_1.joinPathFragments)((_a = schema.directory) !== null && _a !== void 0 ? _a : '.', (_b = schema.subDirectory) !== null && _b !== void 0 ? _b : schema.name);
|
|
21
|
+
return { dir, fullyQualifiedName };
|
|
36
22
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
bundler: "tsc"
|
|
45
|
-
}));
|
|
23
|
+
exports.getTsLibDetails = getTsLibDetails;
|
|
24
|
+
/**
|
|
25
|
+
* Generates a typescript library
|
|
26
|
+
*/
|
|
27
|
+
const tsLibGenerator = (tree, schema) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const { fullyQualifiedName, dir } = (0, exports.getTsLibDetails)(tree, schema);
|
|
29
|
+
yield (0, js_1.libraryGenerator)(tree, Object.assign(Object.assign({}, schema), { name: fullyQualifiedName, directory: dir, projectNameAndRootFormat: 'as-provided', skipPackageJson: true, bundler: 'tsc' }));
|
|
46
30
|
// Replace with simpler sample source code
|
|
47
|
-
tree.delete((0,
|
|
48
|
-
(0,
|
|
49
|
-
(0,
|
|
31
|
+
tree.delete((0, devkit_1.joinPathFragments)(dir, 'src'));
|
|
32
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'src'), (0, devkit_1.joinPathFragments)(dir, 'src'), {});
|
|
33
|
+
(0, ts_project_utils_1.configureTsProject)(tree, {
|
|
50
34
|
dir,
|
|
51
|
-
fullyQualifiedName
|
|
35
|
+
fullyQualifiedName,
|
|
52
36
|
});
|
|
53
|
-
return ()=>{
|
|
37
|
+
return () => {
|
|
54
38
|
if (!schema.skipInstall) {
|
|
55
|
-
(0,
|
|
39
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
56
40
|
}
|
|
57
41
|
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
|
|
42
|
+
});
|
|
43
|
+
exports.tsLibGenerator = tsLibGenerator;
|
|
44
|
+
exports.default = exports.tsLibGenerator;
|
|
61
45
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"
|
|
1
|
+
{"version":3,"file":"generator.js","s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K,CAAC,EAC5C,IAAA,0BAAiB,EAAC,GAAG,EAAE,KAAK,CAAC,EAC7B,EAAE,CACH,CAAC;IAEF,IAAA,qCAAkB,EAAC,IAAI,EAAE;QACvB,GAAG;QACH,kBAAkB;KACnB,CAAC,CAAC;IAEH,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;AAlCW,QAAA,cAAc,kBAkCzB;AAEF,kBAAe,sBAAc,CAAC"}
|
package/src/ts/lib/schema.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { LibraryGeneratorSchema } from '@nx/js/src/utils/schema';
|
|
2
6
|
|
|
3
7
|
export interface TsLibGeneratorSchema {
|
|
4
8
|
name: LibraryGeneratorSchema['name'];
|
|
@@ -10,4 +14,4 @@ export interface TsLibGeneratorSchema {
|
|
|
10
14
|
scope?: string;
|
|
11
15
|
subDirectory?: string;
|
|
12
16
|
skipInstall?: boolean;
|
|
13
|
-
}
|
|
17
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { ConfigureProjectOptions } from './types';
|
|
3
7
|
/**
|
|
4
8
|
* Updates typescript projects
|
|
5
9
|
*/
|
|
@@ -1,107 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const configureTsProject = (tree, options)=>{
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureTsProject = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const generator_1 = require("../cjs-to-esm/generator");
|
|
11
|
+
const npm_scope_1 = require("../../utils/npm-scope");
|
|
12
|
+
const vitest_1 = require("./vitest");
|
|
13
|
+
const eslint_1 = require("./eslint");
|
|
14
|
+
/**
|
|
15
|
+
* Updates typescript projects
|
|
16
|
+
*/
|
|
17
|
+
const configureTsProject = (tree, options) => {
|
|
19
18
|
// Remove conflicting commonjs module from tsconfig
|
|
20
|
-
(0,
|
|
21
|
-
var
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
});
|
|
19
|
+
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.dir, 'tsconfig.json'), (tsConfig) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return (Object.assign(Object.assign({}, tsConfig), { compilerOptions: Object.assign(Object.assign({}, tsConfig.compilerOptions), { module: ((_a = tsConfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.module) === 'commonjs'
|
|
22
|
+
? undefined
|
|
23
|
+
: (_b = tsConfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.module }) }));
|
|
27
24
|
});
|
|
28
|
-
const outDirToRootRelativePath = (0,
|
|
29
|
-
const distDir = (0,
|
|
25
|
+
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', options.dir);
|
|
30
27
|
// Remove baseUrl and rootDir from the tsconfig.lib.json
|
|
31
|
-
if (tree.exists((0,
|
|
32
|
-
(0,
|
|
33
|
-
compilerOptions: _extends._({}, tsConfig.compilerOptions, {
|
|
34
|
-
baseUrl: undefined,
|
|
35
|
-
rootDir: undefined,
|
|
36
|
-
outDir: distDir,
|
|
37
|
-
tsBuildInfoFile: (0, _path.join)(distDir, "tsconfig.lib.tsbuildinfo")
|
|
38
|
-
}),
|
|
39
|
-
include: undefined
|
|
40
|
-
}));
|
|
28
|
+
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') }), include: undefined })));
|
|
41
30
|
}
|
|
42
31
|
// Update root project tsconfig
|
|
43
|
-
(0,
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
return _extends._({}, tsConfig, {
|
|
47
|
-
compilerOptions: _extends._({}, tsConfig.compilerOptions, {
|
|
48
|
-
baseUrl: '.',
|
|
49
|
-
rootDir: '.',
|
|
50
|
-
paths: _extends._({}, Object.fromEntries(Object.entries((_tsConfig_compilerOptions_paths = (_tsConfig_compilerOptions = tsConfig.compilerOptions) == null ? void 0 : _tsConfig_compilerOptions.paths) != null ? _tsConfig_compilerOptions_paths : {}).filter(([k])=>k !== options.fullyQualifiedName)), {
|
|
32
|
+
(0, devkit_1.updateJson)(tree, 'tsconfig.base.json', (tsConfig) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
return (Object.assign(Object.assign({}, tsConfig), { compilerOptions: Object.assign(Object.assign({}, tsConfig.compilerOptions), { baseUrl: '.', rootDir: '.', paths: Object.assign(Object.assign({}, Object.fromEntries(Object.entries((_b = (_a = tsConfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths) !== null && _b !== void 0 ? _b : {}).filter(([k]) => k !== options.fullyQualifiedName))), {
|
|
51
35
|
// Add aliases which begin with colon (eg :foo/bar) to avoid sniping attacks
|
|
52
|
-
[(0,
|
|
53
|
-
(0,
|
|
54
|
-
(0,
|
|
55
|
-
]
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
});
|
|
36
|
+
[(0, npm_scope_1.toScopeAlias)(options.fullyQualifiedName)]: [
|
|
37
|
+
(0, devkit_1.joinPathFragments)(options.dir, 'src', 'index.ts'),
|
|
38
|
+
(0, devkit_1.joinPathFragments)('dist', options.dir, 'src', 'index.d.ts'),
|
|
39
|
+
] }) }) }));
|
|
59
40
|
});
|
|
60
|
-
if (tree.exists(
|
|
61
|
-
(0,
|
|
62
|
-
var
|
|
63
|
-
return
|
|
64
|
-
references: [
|
|
41
|
+
if (tree.exists('tsconfig.json')) {
|
|
42
|
+
(0, devkit_1.updateJson)(tree, 'tsconfig.json', (tsConfig) => {
|
|
43
|
+
var _a;
|
|
44
|
+
return (Object.assign(Object.assign({}, tsConfig), { references: [
|
|
65
45
|
// Add project references, ensuring no duplication
|
|
66
|
-
...((
|
|
46
|
+
...((_a = tsConfig.references) !== null && _a !== void 0 ? _a : []).filter((ref) => ref.path !== `./${options.dir}`),
|
|
67
47
|
{
|
|
68
|
-
path: `./${options.dir}
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
});
|
|
48
|
+
path: `./${options.dir}`,
|
|
49
|
+
},
|
|
50
|
+
] }));
|
|
72
51
|
});
|
|
73
52
|
}
|
|
74
53
|
// Update the root package.json
|
|
75
|
-
(0,
|
|
76
|
-
type: "module"
|
|
77
|
-
}));
|
|
54
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => (Object.assign(Object.assign({}, packageJson), { type: 'module' })));
|
|
78
55
|
// Remove package.json if it exists
|
|
79
|
-
if (tree.exists((0,
|
|
80
|
-
tree.delete((0,
|
|
56
|
+
if (tree.exists((0, path_1.join)(options.dir, 'package.json'))) {
|
|
57
|
+
tree.delete((0, path_1.join)(options.dir, 'package.json'));
|
|
81
58
|
}
|
|
82
59
|
// Convert cjs files to esm for eslint configs and source code, including root monorepo config.
|
|
83
|
-
(0,
|
|
84
|
-
include: [
|
|
85
|
-
"eslint.config.js",
|
|
86
|
-
"**/eslint.config.js",
|
|
87
|
-
"**/src/**/*.ts"
|
|
88
|
-
]
|
|
60
|
+
(0, generator_1.cjsToEsm)(tree, '.', {
|
|
61
|
+
include: ['eslint.config.js', '**/eslint.config.js', '**/src/**/*.ts'],
|
|
89
62
|
});
|
|
90
63
|
// Build task should both test and lint, so move build to compile and compose build as compile + test + lint
|
|
91
|
-
const projectConfiguration = (0,
|
|
92
|
-
if (projectConfiguration.targets.build &&
|
|
64
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.fullyQualifiedName);
|
|
65
|
+
if (projectConfiguration.targets.build &&
|
|
66
|
+
projectConfiguration.targets.build.executor === '@nx/js:tsc') {
|
|
93
67
|
projectConfiguration.targets.compile = projectConfiguration.targets.build;
|
|
94
68
|
projectConfiguration.targets.build = {
|
|
95
|
-
dependsOn: [
|
|
96
|
-
"compile",
|
|
97
|
-
"lint",
|
|
98
|
-
"test"
|
|
99
|
-
]
|
|
69
|
+
dependsOn: ['compile', 'lint', 'test'],
|
|
100
70
|
};
|
|
101
|
-
(0,
|
|
71
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.fullyQualifiedName, projectConfiguration);
|
|
102
72
|
}
|
|
103
|
-
(0,
|
|
104
|
-
(0,
|
|
73
|
+
(0, eslint_1.configureEslint)(tree, options);
|
|
74
|
+
(0, vitest_1.configureVitest)(tree, options);
|
|
105
75
|
};
|
|
106
|
-
|
|
76
|
+
exports.configureTsProject = configureTsProject;
|
|
107
77
|
//# sourceMappingURL=ts-project-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/ts-project-utils.ts"],"
|
|
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,uCAMoB;AACpB,+BAAsC;AACtC,uDAAmD;AACnD,qDAAqD;AAErD,qCAA2C;AAC3C,qCAA2C;AAE3C;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAChC,IAAU,EACV,OAAgC,EAChC,EAAE;IACF,mDAAmD;IACnD,IAAA,mBAAU,EAAC,IAAI,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE;;QAAC,OAAA,iCAC9D,QAAQ,KACX,eAAe,kCACV,QAAQ,CAAC,eAAe,KAC3B,MAAM,EACJ,CAAA,MAAA,QAAQ,CAAC,eAAe,0CAAE,MAAM,MAAK,UAAU;oBAC7C,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,MAAA,QAAQ,CAAC,eAAe,0CAAE,MAAM,OAExC,CAAA;KAAA,CAAC,CAAC;IAEJ,MAAM,wBAAwB,GAAG,IAAA,eAAQ,EACvC,IAAA,WAAI,EAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAC5B,IAAI,CAAC,IAAI,CACV,CAAC;IACF,MAAM,OAAO,GAAG,IAAA,WAAI,EAAC,wBAAwB,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAEpE,wDAAwD;IACxD,IAAI,IAAI,CAAC,MAAM,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC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,CAAC,KAAK,GAAG;YACnC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;SACvC,CAAC;QAEF,IAAA,mCAA0B,EACxB,IAAI,EACJ,OAAO,CAAC,kBAAkB,EAC1B,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED,IAAA,wBAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAA,wBAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC;AAlHW,QAAA,kBAAkB,sBAkH7B"}
|
package/src/ts/lib/types.d.ts
CHANGED
package/src/ts/lib/types.js
CHANGED
package/src/ts/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/types.ts"],"names":[],"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/types.ts"],"names":[],"mappings":""}
|
package/src/ts/lib/vitest.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { ConfigureProjectOptions } from './types';
|
|
3
7
|
export declare const configureVitest: (tree: Tree, options: ConfigureProjectOptions) => void;
|
package/src/ts/lib/vitest.js
CHANGED
|
@@ -1,67 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureVitest = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
8
|
+
const passWithNoTests = (sourceFile) => {
|
|
9
|
+
const transformer = (context) => (rootNode) => {
|
|
10
|
+
function visit(node) {
|
|
11
|
+
if (typescript_1.default.isCallExpression(node) &&
|
|
12
|
+
typescript_1.default.isIdentifier(node.expression) &&
|
|
13
|
+
node.expression.text === 'defineConfig' &&
|
|
14
|
+
node.arguments.length === 1) {
|
|
15
|
+
const configObject = node.arguments[0];
|
|
16
|
+
if (typescript_1.default.isObjectLiteralExpression(configObject)) {
|
|
17
|
+
const testProperty = configObject.properties.find((p) => typescript_1.default.isPropertyAssignment(p) &&
|
|
18
|
+
typescript_1.default.isIdentifier(p.name) &&
|
|
19
|
+
p.name.text === 'test');
|
|
20
|
+
if (testProperty && typescript_1.default.isPropertyAssignment(testProperty)) {
|
|
21
|
+
const testValue = testProperty.initializer;
|
|
22
|
+
if (typescript_1.default.isObjectLiteralExpression(testValue)) {
|
|
23
|
+
// Check if passWithNoTests already exists
|
|
24
|
+
const hasPassWithNoTests = testValue.properties.some((p) => typescript_1.default.isPropertyAssignment(p) &&
|
|
25
|
+
typescript_1.default.isIdentifier(p.name) &&
|
|
26
|
+
p.name.text === 'passWithNoTests');
|
|
27
|
+
if (!hasPassWithNoTests) {
|
|
28
|
+
// Add passWithNoTests: true to the test object
|
|
29
|
+
const newTestValue = context.factory.updateObjectLiteralExpression(testValue, [
|
|
30
|
+
...testValue.properties,
|
|
31
|
+
context.factory.createPropertyAssignment('passWithNoTests', context.factory.createTrue()),
|
|
32
|
+
]);
|
|
33
|
+
// Update the test property with the new value
|
|
34
|
+
const newTestProperty = context.factory.updatePropertyAssignment(testProperty, testProperty.name, newTestValue);
|
|
35
|
+
// Update the config object with the new test property
|
|
36
|
+
return context.factory.updateCallExpression(node, node.expression, node.typeArguments, [
|
|
37
|
+
context.factory.updateObjectLiteralExpression(configObject, configObject.properties.map((p) => p === testProperty ? newTestProperty : p)),
|
|
38
|
+
]);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
return _typescript.default.visitEachChild(node, visit, context);
|
|
45
43
|
}
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
]);
|
|
44
|
+
return typescript_1.default.visitEachChild(node, visit, context);
|
|
45
|
+
}
|
|
46
|
+
return typescript_1.default.visitNode(rootNode, visit);
|
|
47
|
+
};
|
|
48
|
+
const result = typescript_1.default.transform(sourceFile, [transformer]);
|
|
51
49
|
return result.transformed[0];
|
|
52
50
|
};
|
|
53
|
-
const configureVitest = (tree, options)=>{
|
|
54
|
-
const configPath = (0,
|
|
51
|
+
const configureVitest = (tree, options) => {
|
|
52
|
+
const configPath = (0, path_1.join)(options.dir, 'vite.config.ts');
|
|
55
53
|
if (tree.exists(configPath)) {
|
|
56
|
-
const originalSourceFile =
|
|
54
|
+
const originalSourceFile = tsquery_1.tsquery.ast(tree.read(configPath, 'utf-8'));
|
|
57
55
|
let sourceFile = originalSourceFile;
|
|
58
56
|
sourceFile = passWithNoTests(sourceFile);
|
|
59
|
-
const printer =
|
|
57
|
+
const printer = typescript_1.default.createPrinter({
|
|
60
58
|
removeComments: false,
|
|
61
|
-
newLine:
|
|
59
|
+
newLine: typescript_1.default.NewLineKind.LineFeed,
|
|
62
60
|
});
|
|
63
|
-
tree.write(configPath, printer.printNode(
|
|
61
|
+
tree.write(configPath, printer.printNode(typescript_1.default.EmitHint.Unspecified, sourceFile, originalSourceFile));
|
|
64
62
|
}
|
|
65
63
|
};
|
|
66
|
-
|
|
64
|
+
exports.configureVitest = configureVitest;
|
|
67
65
|
//# sourceMappingURL=vitest.js.map
|