@nx/js 0.0.0-pr-22179-271588f
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 +22 -0
- package/README.md +68 -0
- package/babel.d.ts +13 -0
- package/babel.js +91 -0
- package/executors.json +32 -0
- package/generators.json +46 -0
- package/migrations.json +159 -0
- package/package.json +76 -0
- package/plugins/jest/local-registry.d.ts +1 -0
- package/plugins/jest/local-registry.js +4 -0
- package/src/executors/node/lib/kill-tree.d.ts +2 -0
- package/src/executors/node/lib/kill-tree.js +114 -0
- package/src/executors/node/node-with-require-overrides.d.ts +7 -0
- package/src/executors/node/node-with-require-overrides.js +21 -0
- package/src/executors/node/node.impl.d.ts +7 -0
- package/src/executors/node/node.impl.js +288 -0
- package/src/executors/node/schema.d.ts +18 -0
- package/src/executors/node/schema.json +92 -0
- package/src/executors/release-publish/format-bytes.d.ts +1 -0
- package/src/executors/release-publish/format-bytes.js +28 -0
- package/src/executors/release-publish/log-tar.d.ts +1 -0
- package/src/executors/release-publish/log-tar.js +68 -0
- package/src/executors/release-publish/release-publish.impl.d.ts +5 -0
- package/src/executors/release-publish/release-publish.impl.js +198 -0
- package/src/executors/release-publish/schema.d.ts +8 -0
- package/src/executors/release-publish/schema.json +26 -0
- package/src/executors/swc/schema.json +154 -0
- package/src/executors/swc/swc.impl.d.ts +10 -0
- package/src/executors/swc/swc.impl.js +149 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +5 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +62 -0
- package/src/executors/tsc/lib/batch/index.d.ts +4 -0
- package/src/executors/tsc/lib/batch/index.js +7 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.d.ts +3 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.js +14 -0
- package/src/executors/tsc/lib/batch/types.d.ts +17 -0
- package/src/executors/tsc/lib/batch/types.js +2 -0
- package/src/executors/tsc/lib/batch/watch.d.ts +3 -0
- package/src/executors/tsc/lib/batch/watch.js +56 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.d.ts +3 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.js +13 -0
- package/src/executors/tsc/lib/get-task-options.d.ts +3 -0
- package/src/executors/tsc/lib/get-task-options.js +34 -0
- package/src/executors/tsc/lib/get-tsconfig.d.ts +4 -0
- package/src/executors/tsc/lib/get-tsconfig.js +86 -0
- package/src/executors/tsc/lib/index.d.ts +4 -0
- package/src/executors/tsc/lib/index.js +7 -0
- package/src/executors/tsc/lib/normalize-options.d.ts +2 -0
- package/src/executors/tsc/lib/normalize-options.js +39 -0
- package/src/executors/tsc/lib/typescript-compilation.d.ts +29 -0
- package/src/executors/tsc/lib/typescript-compilation.js +203 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.d.ts +3 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.js +37 -0
- package/src/executors/tsc/schema.json +163 -0
- package/src/executors/tsc/tsc.batch-impl.d.ts +5 -0
- package/src/executors/tsc/tsc.batch-impl.js +180 -0
- package/src/executors/tsc/tsc.impl.d.ts +7 -0
- package/src/executors/tsc/tsc.impl.js +97 -0
- package/src/executors/verdaccio/schema.d.ts +7 -0
- package/src/executors/verdaccio/schema.json +35 -0
- package/src/executors/verdaccio/verdaccio.impl.d.ts +12 -0
- package/src/executors/verdaccio/verdaccio.impl.js +220 -0
- package/src/generators/convert-to-swc/convert-to-swc.d.ts +4 -0
- package/src/generators/convert-to-swc/convert-to-swc.js +59 -0
- package/src/generators/convert-to-swc/schema.d.ts +4 -0
- package/src/generators/convert-to-swc/schema.json +36 -0
- package/src/generators/init/files/__fileName__ +20 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +114 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +36 -0
- package/src/generators/library/files/jest-config/jest.config.__ext__ +30 -0
- package/src/generators/library/files/lib/src/index.ts__tmpl__ +1 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ +7 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ +3 -0
- package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +14 -0
- package/src/generators/library/files/readme/README.md +19 -0
- package/src/generators/library/library.d.ts +16 -0
- package/src/generators/library/library.js +751 -0
- package/src/generators/library/schema.json +151 -0
- package/src/generators/release-version/release-version.d.ts +5 -0
- package/src/generators/release-version/release-version.js +390 -0
- package/src/generators/release-version/schema.d.ts +1 -0
- package/src/generators/release-version/schema.json +67 -0
- package/src/generators/release-version/test-utils/create-workspace-with-package-dependencies.d.ts +16 -0
- package/src/generators/release-version/test-utils/create-workspace-with-package-dependencies.js +40 -0
- package/src/generators/release-version/utils/package.d.ts +12 -0
- package/src/generators/release-version/utils/package.js +34 -0
- package/src/generators/release-version/utils/resolve-local-package-dependencies.d.ts +12 -0
- package/src/generators/release-version/utils/resolve-local-package-dependencies.js +78 -0
- package/src/generators/release-version/utils/resolve-version-spec.d.ts +1 -0
- package/src/generators/release-version/utils/resolve-version-spec.js +29 -0
- package/src/generators/release-version/utils/update-lock-file.d.ts +5 -0
- package/src/generators/release-version/utils/update-lock-file.js +105 -0
- package/src/generators/setup-build/generator.d.ts +4 -0
- package/src/generators/setup-build/generator.js +142 -0
- package/src/generators/setup-build/schema.d.ts +7 -0
- package/src/generators/setup-build/schema.json +42 -0
- package/src/generators/setup-verdaccio/files/config.yml +28 -0
- package/src/generators/setup-verdaccio/generator.d.ts +4 -0
- package/src/generators/setup-verdaccio/generator.js +56 -0
- package/src/generators/setup-verdaccio/schema.d.ts +3 -0
- package/src/generators/setup-verdaccio/schema.json +16 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +28 -0
- package/src/internal.d.ts +4 -0
- package/src/internal.js +15 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.d.ts +2 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.js +77 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.d.ts +2 -0
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +34 -0
- package/src/migrations/update-16-8-2/update-swcrc.d.ts +2 -0
- package/src/migrations/update-16-8-2/update-swcrc.js +23 -0
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.d.ts +6 -0
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.js +30 -0
- package/src/plugins/jest/start-local-registry.d.ts +12 -0
- package/src/plugins/jest/start-local-registry.js +63 -0
- package/src/plugins/rollup/type-definitions.d.ts +8 -0
- package/src/plugins/rollup/type-definitions.js +48 -0
- package/src/utils/add-babel-inputs.d.ts +3 -0
- package/src/utils/add-babel-inputs.js +23 -0
- package/src/utils/add-local-registry-scripts.d.ts +5 -0
- package/src/utils/add-local-registry-scripts.js +77 -0
- package/src/utils/assets/assets.d.ts +10 -0
- package/src/utils/assets/assets.js +36 -0
- package/src/utils/assets/copy-assets-handler.d.ts +32 -0
- package/src/utils/assets/copy-assets-handler.js +154 -0
- package/src/utils/assets/index.d.ts +16 -0
- package/src/utils/assets/index.js +27 -0
- package/src/utils/buildable-libs-utils.d.ts +43 -0
- package/src/utils/buildable-libs-utils.js +375 -0
- package/src/utils/check-dependencies.d.ts +8 -0
- package/src/utils/check-dependencies.js +23 -0
- package/src/utils/code-frames/highlight.d.ts +1 -0
- package/src/utils/code-frames/highlight.js +86 -0
- package/src/utils/code-frames/identifiers.d.ts +5 -0
- package/src/utils/code-frames/identifiers.js +52 -0
- package/src/utils/compiler-helper-dependency.d.ts +18 -0
- package/src/utils/compiler-helper-dependency.js +120 -0
- package/src/utils/find-npm-dependencies.d.ts +9 -0
- package/src/utils/find-npm-dependencies.js +140 -0
- package/src/utils/generate-globs.d.ts +6 -0
- package/src/utils/generate-globs.js +80 -0
- package/src/utils/get-import-path.d.ts +5 -0
- package/src/utils/get-import-path.js +14 -0
- package/src/utils/get-main-file-dir.d.ts +1 -0
- package/src/utils/get-main-file-dir.js +11 -0
- package/src/utils/inline.d.ts +19 -0
- package/src/utils/inline.js +210 -0
- package/src/utils/package-json/create-entry-points.d.ts +1 -0
- package/src/utils/package-json/create-entry-points.js +23 -0
- package/src/utils/package-json/get-npm-scope.d.ts +5 -0
- package/src/utils/package-json/get-npm-scope.js +16 -0
- package/src/utils/package-json/index.d.ts +13 -0
- package/src/utils/package-json/index.js +30 -0
- package/src/utils/package-json/update-package-json.d.ts +30 -0
- package/src/utils/package-json/update-package-json.js +179 -0
- package/src/utils/prettier.d.ts +6 -0
- package/src/utils/prettier.js +34 -0
- package/src/utils/schema.d.ts +87 -0
- package/src/utils/swc/add-swc-config.d.ts +3 -0
- package/src/utils/swc/add-swc-config.js +41 -0
- package/src/utils/swc/add-swc-dependencies.d.ts +3 -0
- package/src/utils/swc/add-swc-dependencies.js +18 -0
- package/src/utils/swc/compile-swc.d.ts +13 -0
- package/src/utils/swc/compile-swc.js +160 -0
- package/src/utils/swc/get-swcrc-path.d.ts +5 -0
- package/src/utils/swc/get-swcrc-path.js +15 -0
- package/src/utils/swc/inline.d.ts +2 -0
- package/src/utils/swc/inline.js +11 -0
- package/src/utils/typescript/__mocks__/plugin-a.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-a.js +5 -0
- package/src/utils/typescript/__mocks__/plugin-b.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-b.js +5 -0
- package/src/utils/typescript/add-tslib-dependencies.d.ts +2 -0
- package/src/utils/typescript/add-tslib-dependencies.js +11 -0
- package/src/utils/typescript/ast-utils.d.ts +32 -0
- package/src/utils/typescript/ast-utils.js +266 -0
- package/src/utils/typescript/compile-typescript-files.d.ts +10 -0
- package/src/utils/typescript/compile-typescript-files.js +43 -0
- package/src/utils/typescript/create-ts-config.d.ts +18 -0
- package/src/utils/typescript/create-ts-config.js +48 -0
- package/src/utils/typescript/ensure-typescript.d.ts +1 -0
- package/src/utils/typescript/ensure-typescript.js +9 -0
- package/src/utils/typescript/get-source-nodes.d.ts +2 -0
- package/src/utils/typescript/get-source-nodes.js +18 -0
- package/src/utils/typescript/load-ts-transformers.d.ts +5 -0
- package/src/utils/typescript/load-ts-transformers.js +62 -0
- package/src/utils/typescript/print-diagnostics.d.ts +1 -0
- package/src/utils/typescript/print-diagnostics.js +18 -0
- package/src/utils/typescript/run-type-check.d.ts +32 -0
- package/src/utils/typescript/run-type-check.js +128 -0
- package/src/utils/typescript/ts-config.d.ts +9 -0
- package/src/utils/typescript/ts-config.js +85 -0
- package/src/utils/typescript/tsnode-register.d.ts +1 -0
- package/src/utils/typescript/tsnode-register.js +24 -0
- package/src/utils/typescript/types.d.ts +18 -0
- package/src/utils/typescript/types.js +2 -0
- package/src/utils/versions.d.ts +17 -0
- package/src/utils/versions.js +21 -0
- package/src/utils/watch-for-single-file-changes.d.ts +1 -0
- package/src/utils/watch-for-single-file-changes.js +22 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPackageJson = exports.getLockFileName = exports.createLockFile = exports.initGenerator = exports.libraryGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./utils/typescript/add-tslib-dependencies"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./utils/typescript/load-ts-transformers"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./utils/typescript/print-diagnostics"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./utils/typescript/run-type-check"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./utils/typescript/get-source-nodes"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./utils/compiler-helper-dependency"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./utils/typescript/ts-config"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./utils/typescript/create-ts-config"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./utils/typescript/ast-utils"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./utils/package-json"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./utils/assets"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./utils/package-json/update-package-json"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./utils/package-json/create-entry-points"), exports);
|
|
18
|
+
var library_1 = require("./generators/library/library");
|
|
19
|
+
Object.defineProperty(exports, "libraryGenerator", { enumerable: true, get: function () { return library_1.libraryGenerator; } });
|
|
20
|
+
var init_1 = require("./generators/init/init");
|
|
21
|
+
Object.defineProperty(exports, "initGenerator", { enumerable: true, get: function () { return init_1.initGenerator; } });
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
23
|
+
var lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
24
|
+
Object.defineProperty(exports, "createLockFile", { enumerable: true, get: function () { return lock_file_1.createLockFile; } });
|
|
25
|
+
Object.defineProperty(exports, "getLockFileName", { enumerable: true, get: function () { return lock_file_1.getLockFileName; } });
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
27
|
+
var create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
|
|
28
|
+
Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return create_package_json_1.createPackageJson; } });
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { resolveModuleByImport } from './utils/typescript/ast-utils';
|
|
2
|
+
export { registerTsProject, registerTsConfigPaths, } from 'nx/src/plugins/js/utils/register';
|
|
3
|
+
export { TargetProjectLocator } from 'nx/src/plugins/js/project-graph/build-dependencies/target-project-locator';
|
|
4
|
+
export { findProjectsNpmDependencies } from 'nx/src/plugins/js/package-json/create-package-json';
|
package/src/internal.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findProjectsNpmDependencies = exports.TargetProjectLocator = exports.registerTsConfigPaths = exports.registerTsProject = exports.resolveModuleByImport = void 0;
|
|
4
|
+
var ast_utils_1 = require("./utils/typescript/ast-utils");
|
|
5
|
+
Object.defineProperty(exports, "resolveModuleByImport", { enumerable: true, get: function () { return ast_utils_1.resolveModuleByImport; } });
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
7
|
+
var register_1 = require("nx/src/plugins/js/utils/register");
|
|
8
|
+
Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
|
|
9
|
+
Object.defineProperty(exports, "registerTsConfigPaths", { enumerable: true, get: function () { return register_1.registerTsConfigPaths; } });
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
11
|
+
var target_project_locator_1 = require("nx/src/plugins/js/project-graph/build-dependencies/target-project-locator");
|
|
12
|
+
Object.defineProperty(exports, "TargetProjectLocator", { enumerable: true, get: function () { return target_project_locator_1.TargetProjectLocator; } });
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
14
|
+
var create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
|
|
15
|
+
Object.defineProperty(exports, "findProjectsNpmDependencies", { enumerable: true, get: function () { return create_package_json_1.findProjectsNpmDependencies; } });
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
async function default_1(tree) {
|
|
7
|
+
let changesMade = false;
|
|
8
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
9
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/js:swc', (_, projectName, target, configurationName) => {
|
|
10
|
+
const projectConfiguration = projects.get(projectName);
|
|
11
|
+
const executorOptions = configurationName
|
|
12
|
+
? projectConfiguration.targets[target].configurations[configurationName]
|
|
13
|
+
: projectConfiguration.targets[target].options;
|
|
14
|
+
// if the project uses a custom path to swcrc file
|
|
15
|
+
// and only if it's the default name
|
|
16
|
+
if (executorOptions.swcrc &&
|
|
17
|
+
executorOptions.swcrc.includes('.lib.swcrc')) {
|
|
18
|
+
const newSwcrc = executorOptions.swcrc.replace('.lib.swcrc', '.swcrc');
|
|
19
|
+
// rename the swcrc file first
|
|
20
|
+
tree.rename(executorOptions.swcrc, newSwcrc);
|
|
21
|
+
// then update the executor options
|
|
22
|
+
executorOptions.swcrc = newSwcrc;
|
|
23
|
+
changesMade = true;
|
|
24
|
+
}
|
|
25
|
+
const libSwcrcPath = (0, devkit_1.joinPathFragments)(projectConfiguration.root, '.lib.swcrc') ||
|
|
26
|
+
(0, devkit_1.joinPathFragments)(projectConfiguration.sourceRoot, '.lib.swcrc');
|
|
27
|
+
const isLibSwcrcExist = tree.exists(libSwcrcPath);
|
|
28
|
+
if (isLibSwcrcExist) {
|
|
29
|
+
tree.rename(libSwcrcPath, libSwcrcPath.replace('.lib.swcrc', '.swcrc'));
|
|
30
|
+
changesMade = true;
|
|
31
|
+
}
|
|
32
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
33
|
+
});
|
|
34
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (_, projectName, target, configurationName) => {
|
|
35
|
+
const projectConfiguration = projects.get(projectName);
|
|
36
|
+
const executorOptions = configurationName
|
|
37
|
+
? projectConfiguration.targets[target].configurations[configurationName]
|
|
38
|
+
: projectConfiguration.targets[target].options;
|
|
39
|
+
const isJestConfigExist = executorOptions.jestConfig && tree.exists(executorOptions.jestConfig);
|
|
40
|
+
if (isJestConfigExist) {
|
|
41
|
+
const jestConfig = tree.read(executorOptions.jestConfig, 'utf-8');
|
|
42
|
+
const jsonParseNodes = tsquery_1.tsquery.query(jestConfig, ':matches(CallExpression:has(Identifier[name="JSON"]):has(Identifier[name="parse"]))');
|
|
43
|
+
if (jsonParseNodes.length) {
|
|
44
|
+
// if we already assign false to swcrc, skip
|
|
45
|
+
if (jestConfig.includes('.swcrc = false')) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let updatedJestConfig = tsquery_1.tsquery.replace(jestConfig, 'CallExpression:has(Identifier[name="JSON"]):has(Identifier[name="parse"]) TemplateSpan', (templateSpan) => {
|
|
49
|
+
if (templateSpan.literal.text === '/.lib.swcrc') {
|
|
50
|
+
return templateSpan
|
|
51
|
+
.getFullText()
|
|
52
|
+
.replace('.lib.swcrc', '.swcrc');
|
|
53
|
+
}
|
|
54
|
+
return '';
|
|
55
|
+
});
|
|
56
|
+
updatedJestConfig = tsquery_1.tsquery.replace(updatedJestConfig, ':matches(ExportAssignment, BinaryExpression:has(Identifier[name="module"]):has(Identifier[name="exports"]))', (node) => {
|
|
57
|
+
return `
|
|
58
|
+
|
|
59
|
+
// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves.
|
|
60
|
+
// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude"
|
|
61
|
+
if (swcJestConfig.swcrc === undefined) {
|
|
62
|
+
swcJestConfig.swcrc = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
${node.getFullText()}
|
|
66
|
+
`;
|
|
67
|
+
});
|
|
68
|
+
tree.write(executorOptions.jestConfig, updatedJestConfig);
|
|
69
|
+
changesMade = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
if (changesMade) {
|
|
74
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/js', '@nx/js');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
8
|
+
}
|
|
9
|
+
exports.default = replacePackage;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const executors = new Set([
|
|
5
|
+
'@nx/js:swc',
|
|
6
|
+
'@nrwl/js:swc',
|
|
7
|
+
'@nx/js:tsc',
|
|
8
|
+
'@nrwl/js:tsc',
|
|
9
|
+
]);
|
|
10
|
+
async function default_1(tree) {
|
|
11
|
+
// use project graph to get the expanded target configurations
|
|
12
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
13
|
+
for (const [projectName, { data: projectData }] of Object.entries(projectGraph.nodes)) {
|
|
14
|
+
if (projectData.projectType !== 'library') {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
for (const [targetName, target] of Object.entries(projectData.targets || {})) {
|
|
18
|
+
if (!executors.has(target.executor)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (!target.options ||
|
|
22
|
+
target.options.updateBuildableProjectDepsInPackageJson === undefined) {
|
|
23
|
+
// read the project configuration to write the explicit project configuration
|
|
24
|
+
// and avoid writing the expanded target configuration
|
|
25
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
26
|
+
project.targets[targetName].options ??= {};
|
|
27
|
+
project.targets[targetName].options.updateBuildableProjectDepsInPackageJson = true;
|
|
28
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
33
|
+
}
|
|
34
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
7
|
+
for (const config of projects.values()) {
|
|
8
|
+
const swcrcPath = (0, path_1.join)(config.root, '.swcrc');
|
|
9
|
+
if (!tree.exists(swcrcPath))
|
|
10
|
+
continue;
|
|
11
|
+
const json = (0, devkit_1.readJson)(tree, swcrcPath);
|
|
12
|
+
// No longer need strict or noInterop for es6 modules
|
|
13
|
+
// See: https://github.com/swc-project/swc/commit/7e8d72d
|
|
14
|
+
if (json.module?.type === 'es6' &&
|
|
15
|
+
(json.module?.strict || json.module?.noInterop)) {
|
|
16
|
+
delete json.module.noInterop;
|
|
17
|
+
delete json.module.strict;
|
|
18
|
+
(0, devkit_1.writeJson)(tree, swcrcPath, json);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
22
|
+
}
|
|
23
|
+
exports.default = update;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
/**
|
|
5
|
+
* Removes deprecated
|
|
6
|
+
* @param tree
|
|
7
|
+
*/
|
|
8
|
+
async function default_1(tree) {
|
|
9
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
10
|
+
for (const [projectName, projectConfig] of projects) {
|
|
11
|
+
let shouldUpdate = false;
|
|
12
|
+
if (!projectConfig.targets)
|
|
13
|
+
continue;
|
|
14
|
+
for (const target of Object.values(projectConfig.targets)) {
|
|
15
|
+
if (target.executor?.startsWith('@nx/') &&
|
|
16
|
+
target.options &&
|
|
17
|
+
('buildableProjectDepsInPackageJsonType' in target.options ||
|
|
18
|
+
'updateBuildableProjectDepsInPackageJson' in target.options)) {
|
|
19
|
+
delete target.options['buildableProjectDepsInPackageJsonType'];
|
|
20
|
+
delete target.options['updateBuildableProjectDepsInPackageJson'];
|
|
21
|
+
shouldUpdate = true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (shouldUpdate) {
|
|
25
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
29
|
+
}
|
|
30
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function is used to start a local registry for testing purposes.
|
|
3
|
+
* @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
|
|
4
|
+
* @param storage the storage location for the local registry
|
|
5
|
+
* @param verbose whether to log verbose output
|
|
6
|
+
*/
|
|
7
|
+
export declare function startLocalRegistry({ localRegistryTarget, storage, verbose, }: {
|
|
8
|
+
localRegistryTarget: string;
|
|
9
|
+
storage?: string;
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
}): Promise<() => void>;
|
|
12
|
+
export default startLocalRegistry;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startLocalRegistry = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
/**
|
|
6
|
+
* This function is used to start a local registry for testing purposes.
|
|
7
|
+
* @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
|
|
8
|
+
* @param storage the storage location for the local registry
|
|
9
|
+
* @param verbose whether to log verbose output
|
|
10
|
+
*/
|
|
11
|
+
function startLocalRegistry({ localRegistryTarget, storage, verbose, }) {
|
|
12
|
+
if (!localRegistryTarget) {
|
|
13
|
+
throw new Error(`localRegistryTarget is required`);
|
|
14
|
+
}
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const childProcess = (0, child_process_1.fork)(require.resolve('nx'), [
|
|
17
|
+
...`run ${localRegistryTarget} --location none --clear true`.split(' '),
|
|
18
|
+
...(storage ? [`--storage`, storage] : []),
|
|
19
|
+
], { stdio: 'pipe' });
|
|
20
|
+
const listener = (data) => {
|
|
21
|
+
if (verbose) {
|
|
22
|
+
process.stdout.write(data);
|
|
23
|
+
}
|
|
24
|
+
if (data.toString().includes('http://localhost:')) {
|
|
25
|
+
const port = parseInt(data.toString().match(/localhost:(?<port>\d+)/)?.groups?.port);
|
|
26
|
+
console.log('Local registry started on port ' + port);
|
|
27
|
+
const registry = `http://localhost:${port}`;
|
|
28
|
+
process.env.npm_config_registry = registry;
|
|
29
|
+
(0, child_process_1.execSync)(`npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`);
|
|
30
|
+
// yarnv1
|
|
31
|
+
process.env.YARN_REGISTRY = registry;
|
|
32
|
+
// yarnv2
|
|
33
|
+
process.env.YARN_NPM_REGISTRY_SERVER = registry;
|
|
34
|
+
process.env.YARN_UNSAFE_HTTP_WHITELIST = 'localhost';
|
|
35
|
+
console.log('Set npm and yarn config registry to ' + registry);
|
|
36
|
+
resolve(() => {
|
|
37
|
+
childProcess.kill();
|
|
38
|
+
(0, child_process_1.execSync)(`npm config delete //localhost:${port}/:_authToken`);
|
|
39
|
+
});
|
|
40
|
+
childProcess?.stdout?.off('data', listener);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
childProcess?.stdout?.on('data', listener);
|
|
44
|
+
childProcess?.stderr?.on('data', (data) => {
|
|
45
|
+
process.stderr.write(data);
|
|
46
|
+
});
|
|
47
|
+
childProcess.on('error', (err) => {
|
|
48
|
+
console.log('local registry error', err);
|
|
49
|
+
reject(err);
|
|
50
|
+
});
|
|
51
|
+
childProcess.on('exit', (code) => {
|
|
52
|
+
console.log('local registry exit', code);
|
|
53
|
+
if (code !== 0) {
|
|
54
|
+
reject(code);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
resolve(() => { });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.startLocalRegistry = startLocalRegistry;
|
|
63
|
+
exports.default = startLocalRegistry;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typeDefinitions = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
//NOTE: This is here so we can share between `@nx/rollup` and `@nx/vite`.
|
|
7
|
+
/*
|
|
8
|
+
* This plugin takes all entry-points from the generated bundle and creates a
|
|
9
|
+
* bundled version of corresponding d.ts files.
|
|
10
|
+
*
|
|
11
|
+
* For example, `src/index.ts` generates two corresponding files:
|
|
12
|
+
* - `dist/xyz/index.js`
|
|
13
|
+
* - `dist/xyz/src/index.d.ts`
|
|
14
|
+
*
|
|
15
|
+
* We want a third file: `dist/index.d.ts` that re-exports from `src/index.d.ts`.
|
|
16
|
+
* That way, when TSC or IDEs look for types, it will find them in the right place.
|
|
17
|
+
*/
|
|
18
|
+
function typeDefinitions(options) {
|
|
19
|
+
return {
|
|
20
|
+
name: 'dts-bundle',
|
|
21
|
+
async generateBundle(_opts, bundle) {
|
|
22
|
+
for (const [name, file] of Object.entries(bundle)) {
|
|
23
|
+
if (file.type === 'asset' ||
|
|
24
|
+
!file.isEntry ||
|
|
25
|
+
file.facadeModuleId == null) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const hasDefaultExport = file.exports.includes('default');
|
|
29
|
+
const entrySourceFileName = (0, path_1.relative)(options.projectRoot, file.facadeModuleId);
|
|
30
|
+
const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, '');
|
|
31
|
+
const dtsFileName = file.fileName.replace(/\.[cm]?js$/, '.d.ts');
|
|
32
|
+
const relativeSourceDtsName = JSON.stringify('./' + entrySourceDtsName);
|
|
33
|
+
const dtsFileSource = hasDefaultExport
|
|
34
|
+
? (0, devkit_1.stripIndents) `
|
|
35
|
+
export * from ${relativeSourceDtsName};
|
|
36
|
+
export { default } from ${relativeSourceDtsName};
|
|
37
|
+
`
|
|
38
|
+
: `export * from ${relativeSourceDtsName};\n`;
|
|
39
|
+
this.emitFile({
|
|
40
|
+
type: 'asset',
|
|
41
|
+
fileName: dtsFileName,
|
|
42
|
+
source: dtsFileSource,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.typeDefinitions = typeDefinitions;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addBabelInputs = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/** @deprecated Do not use this function as the root babel.config.json file is no longer needed */
|
|
6
|
+
// TODO(jack): Remove This in Nx 17 once we don't need to support Nx 15 anymore. Currently this function is used in v15 migrations.
|
|
7
|
+
function addBabelInputs(tree) {
|
|
8
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
9
|
+
let globalBabelFile = ['babel.config.js', 'babel.config.json'].find((file) => tree.exists(file));
|
|
10
|
+
if (!globalBabelFile) {
|
|
11
|
+
(0, devkit_1.writeJson)(tree, '/babel.config.json', {
|
|
12
|
+
babelrcRoots: ['*'], // Make sure .babelrc files other than root can be loaded in a monorepo
|
|
13
|
+
});
|
|
14
|
+
globalBabelFile = 'babel.config.json';
|
|
15
|
+
}
|
|
16
|
+
if (nxJson.namedInputs?.sharedGlobals) {
|
|
17
|
+
const sharedGlobalFileset = new Set(nxJson.namedInputs.sharedGlobals);
|
|
18
|
+
sharedGlobalFileset.add((0, devkit_1.joinPathFragments)('{workspaceRoot}', globalBabelFile));
|
|
19
|
+
nxJson.namedInputs.sharedGlobals = Array.from(sharedGlobalFileset);
|
|
20
|
+
}
|
|
21
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
22
|
+
}
|
|
23
|
+
exports.addBabelInputs = addBabelInputs;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addLocalRegistryScripts = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const startLocalRegistryScript = (localRegistryTarget) => `
|
|
6
|
+
/**
|
|
7
|
+
* This script starts a local registry for e2e testing purposes.
|
|
8
|
+
* It is meant to be called in jest's globalSetup.
|
|
9
|
+
*/
|
|
10
|
+
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
|
|
11
|
+
import { execFileSync } from 'child_process';
|
|
12
|
+
import { releasePublish, releaseVersion } from 'nx/release';
|
|
13
|
+
|
|
14
|
+
export default async () => {
|
|
15
|
+
// local registry target to run
|
|
16
|
+
const localRegistryTarget = '${localRegistryTarget}';
|
|
17
|
+
// storage folder for the local registry
|
|
18
|
+
const storage = './tmp/local-registry/storage';
|
|
19
|
+
|
|
20
|
+
global.stopLocalRegistry = await startLocalRegistry({
|
|
21
|
+
localRegistryTarget,
|
|
22
|
+
storage,
|
|
23
|
+
verbose: false,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await releaseVersion({
|
|
27
|
+
specifier: '0.0.0-e2e',
|
|
28
|
+
stageChanges: false,
|
|
29
|
+
gitCommit: false,
|
|
30
|
+
gitTag: false,
|
|
31
|
+
firstRelease: true,
|
|
32
|
+
generatorOptionsOverrides: {
|
|
33
|
+
skipLockFileUpdate: true
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
await releasePublish({
|
|
37
|
+
tag: 'e2e',
|
|
38
|
+
firstRelease: true
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
`;
|
|
42
|
+
const stopLocalRegistryScript = `
|
|
43
|
+
/**
|
|
44
|
+
* This script stops the local registry for e2e testing purposes.
|
|
45
|
+
* It is meant to be called in jest's globalTeardown.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
export default () => {
|
|
49
|
+
if (global.stopLocalRegistry) {
|
|
50
|
+
global.stopLocalRegistry();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
`;
|
|
54
|
+
function addLocalRegistryScripts(tree) {
|
|
55
|
+
const startLocalRegistryPath = 'tools/scripts/start-local-registry.ts';
|
|
56
|
+
const stopLocalRegistryPath = 'tools/scripts/stop-local-registry.ts';
|
|
57
|
+
const projectConfiguration = (0, devkit_1.readJson)(tree, 'project.json');
|
|
58
|
+
const localRegistryTarget = `${projectConfiguration.name}:local-registry`;
|
|
59
|
+
if (!tree.exists(startLocalRegistryPath)) {
|
|
60
|
+
tree.write(startLocalRegistryPath, startLocalRegistryScript(localRegistryTarget));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const existingStartLocalRegistryScript = tree
|
|
64
|
+
.read(startLocalRegistryPath)
|
|
65
|
+
.toString();
|
|
66
|
+
if (!existingStartLocalRegistryScript.includes('nx/release')) {
|
|
67
|
+
devkit_1.output.warn({
|
|
68
|
+
title: 'Your `start-local-registry.ts` script may be outdated. To ensure that newly generated packages are published appropriately when running end to end tests, update this script to use Nx Release. See https://nx.dev/recipes/nx-release/update-local-registry-setup for details.',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!tree.exists(stopLocalRegistryPath)) {
|
|
73
|
+
tree.write(stopLocalRegistryPath, stopLocalRegistryScript);
|
|
74
|
+
}
|
|
75
|
+
return { startLocalRegistryPath, stopLocalRegistryPath };
|
|
76
|
+
}
|
|
77
|
+
exports.addLocalRegistryScripts = addLocalRegistryScripts;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type FileInputOutput = {
|
|
2
|
+
input: string;
|
|
3
|
+
output: string;
|
|
4
|
+
};
|
|
5
|
+
export type AssetGlob = FileInputOutput & {
|
|
6
|
+
glob: string;
|
|
7
|
+
ignore?: string[];
|
|
8
|
+
dot?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function assetGlobsToFiles(assets: Array<AssetGlob | string>, rootDir: string, outDir: string): FileInputOutput[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assetGlobsToFiles = void 0;
|
|
4
|
+
const fastGlob = require("fast-glob");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
function assetGlobsToFiles(assets, rootDir, outDir) {
|
|
7
|
+
const files = [];
|
|
8
|
+
const globbedFiles = (pattern, input = '', ignore = [], dot = false) => {
|
|
9
|
+
return fastGlob.sync(pattern, {
|
|
10
|
+
cwd: input,
|
|
11
|
+
onlyFiles: true,
|
|
12
|
+
dot,
|
|
13
|
+
ignore,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
assets.forEach((asset) => {
|
|
17
|
+
if (typeof asset === 'string') {
|
|
18
|
+
globbedFiles(asset, rootDir).forEach((globbedFile) => {
|
|
19
|
+
files.push({
|
|
20
|
+
input: (0, path_1.join)(rootDir, globbedFile),
|
|
21
|
+
output: (0, path_1.join)(outDir, (0, path_1.basename)(globbedFile)),
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
globbedFiles(asset.glob, (0, path_1.join)(rootDir, asset.input), asset.ignore, asset.dot ?? false).forEach((globbedFile) => {
|
|
27
|
+
files.push({
|
|
28
|
+
input: (0, path_1.join)(rootDir, asset.input, globbedFile),
|
|
29
|
+
output: (0, path_1.join)(outDir, asset.output, globbedFile),
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return files;
|
|
35
|
+
}
|
|
36
|
+
exports.assetGlobsToFiles = assetGlobsToFiles;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AssetGlob } from './assets';
|
|
2
|
+
import { ChangedFile } from 'nx/src/daemon/client/client';
|
|
3
|
+
export type FileEventType = 'create' | 'update' | 'delete';
|
|
4
|
+
export interface FileEvent {
|
|
5
|
+
type: FileEventType;
|
|
6
|
+
src: string;
|
|
7
|
+
dest: string;
|
|
8
|
+
}
|
|
9
|
+
interface CopyAssetHandlerOptions {
|
|
10
|
+
projectDir: string;
|
|
11
|
+
rootDir: string;
|
|
12
|
+
outputDir: string;
|
|
13
|
+
assets: (string | AssetGlob)[];
|
|
14
|
+
callback?: (events: FileEvent[]) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const defaultFileEventHandler: (events: FileEvent[]) => void;
|
|
17
|
+
export declare class CopyAssetsHandler {
|
|
18
|
+
private readonly projectDir;
|
|
19
|
+
private readonly rootDir;
|
|
20
|
+
private readonly outputDir;
|
|
21
|
+
private readonly assetGlobs;
|
|
22
|
+
private readonly ignore;
|
|
23
|
+
private readonly callback;
|
|
24
|
+
constructor(opts: CopyAssetHandlerOptions);
|
|
25
|
+
processAllAssetsOnce(): Promise<void>;
|
|
26
|
+
processAllAssetsOnceSync(): void;
|
|
27
|
+
watchAndProcessOnAssetChange(): Promise<() => void>;
|
|
28
|
+
processWatchEvents(events: ChangedFile[]): Promise<void>;
|
|
29
|
+
private filesToEvent;
|
|
30
|
+
private normalizeAssetPattern;
|
|
31
|
+
}
|
|
32
|
+
export {};
|