@nx/js 16.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/babel.d.ts +10 -0
- package/babel.js +89 -0
- package/babel.js.map +1 -0
- package/executors.json +37 -0
- package/generators.json +52 -0
- package/migrations.json +60 -0
- package/package.json +64 -0
- package/src/executors/node/compat.d.ts +2 -0
- package/src/executors/node/compat.js +6 -0
- package/src/executors/node/compat.js.map +1 -0
- package/src/executors/node/node-with-require-overrides.d.ts +5 -0
- package/src/executors/node/node-with-require-overrides.js +20 -0
- package/src/executors/node/node-with-require-overrides.js.map +1 -0
- package/src/executors/node/node.impl.d.ts +8 -0
- package/src/executors/node/node.impl.js +184 -0
- package/src/executors/node/node.impl.js.map +1 -0
- package/src/executors/node/schema.d.ts +16 -0
- package/src/executors/node/schema.json +74 -0
- package/src/executors/swc/compat.d.ts +2 -0
- package/src/executors/swc/compat.js +6 -0
- package/src/executors/swc/compat.js.map +1 -0
- package/src/executors/swc/schema.json +147 -0
- package/src/executors/swc/swc.impl.d.ts +11 -0
- package/src/executors/swc/swc.impl.js +126 -0
- package/src/executors/swc/swc.impl.js.map +1 -0
- package/src/executors/tsc/compat.d.ts +2 -0
- package/src/executors/tsc/compat.js +6 -0
- package/src/executors/tsc/compat.js.map +1 -0
- package/src/executors/tsc/schema.json +156 -0
- package/src/executors/tsc/tsc.impl.d.ts +7 -0
- package/src/executors/tsc/tsc.impl.js +106 -0
- package/src/executors/tsc/tsc.impl.js.map +1 -0
- package/src/generators/convert-to-swc/convert-to-swc.d.ts +5 -0
- package/src/generators/convert-to-swc/convert-to-swc.js +62 -0
- package/src/generators/convert-to-swc/convert-to-swc.js.map +1 -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 +5 -0
- package/src/generators/init/init.js +67 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +6 -0
- package/src/generators/init/schema.json +30 -0
- package/src/generators/library/files/jest-config/jest.config.__ext__ +24 -0
- package/src/generators/library/files/lib/README.md +19 -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.json__tmpl__ +14 -0
- package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +10 -0
- package/src/generators/library/library.d.ts +15 -0
- package/src/generators/library/library.js +388 -0
- package/src/generators/library/library.js.map +1 -0
- package/src/generators/library/schema.json +134 -0
- package/src/index.d.ts +15 -0
- package/src/index.js +24 -0
- package/src/index.js.map +1 -0
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.d.ts +2 -0
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js +32 -0
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js.map +1 -0
- package/src/migrations/update-13-8-5/update-node-executor.d.ts +2 -0
- package/src/migrations/update-13-8-5/update-node-executor.js +28 -0
- package/src/migrations/update-13-8-5/update-node-executor.js.map +1 -0
- package/src/migrations/update-13-8-5/update-swcrc.d.ts +2 -0
- package/src/migrations/update-13-8-5/update-swcrc.js +35 -0
- package/src/migrations/update-13-8-5/update-swcrc.js.map +1 -0
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.d.ts +3 -0
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js +27 -0
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js.map +1 -0
- package/src/migrations/update-14-1-5/update-swcrc-path.d.ts +3 -0
- package/src/migrations/update-14-1-5/update-swcrc-path.js +30 -0
- package/src/migrations/update-14-1-5/update-swcrc-path.js.map +1 -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 +81 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.js.map +1 -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 +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/utils/add-babel-inputs.d.ts +2 -0
- package/src/utils/add-babel-inputs.js +23 -0
- package/src/utils/add-babel-inputs.js.map +1 -0
- package/src/utils/assets/assets.d.ts +10 -0
- package/src/utils/assets/assets.js +38 -0
- package/src/utils/assets/assets.js.map +1 -0
- package/src/utils/assets/copy-assets-handler.d.ts +28 -0
- package/src/utils/assets/copy-assets-handler.js +155 -0
- package/src/utils/assets/copy-assets-handler.js.map +1 -0
- package/src/utils/assets/index.d.ts +16 -0
- package/src/utils/assets/index.js +31 -0
- package/src/utils/assets/index.js.map +1 -0
- package/src/utils/buildable-libs-utils.d.ts +32 -0
- package/src/utils/buildable-libs-utils.js +309 -0
- package/src/utils/buildable-libs-utils.js.map +1 -0
- package/src/utils/check-dependencies.d.ts +8 -0
- package/src/utils/check-dependencies.js +24 -0
- package/src/utils/check-dependencies.js.map +1 -0
- package/src/utils/code-frames/highlight.d.ts +1 -0
- package/src/utils/code-frames/highlight.js +87 -0
- package/src/utils/code-frames/highlight.js.map +1 -0
- package/src/utils/code-frames/identifiers.d.ts +5 -0
- package/src/utils/code-frames/identifiers.js +53 -0
- package/src/utils/code-frames/identifiers.js.map +1 -0
- package/src/utils/compiler-helper-dependency.d.ts +17 -0
- package/src/utils/compiler-helper-dependency.js +111 -0
- package/src/utils/compiler-helper-dependency.js.map +1 -0
- package/src/utils/generate-globs.d.ts +6 -0
- package/src/utils/generate-globs.js +81 -0
- package/src/utils/generate-globs.js.map +1 -0
- package/src/utils/inline.d.ts +19 -0
- package/src/utils/inline.js +211 -0
- package/src/utils/inline.js.map +1 -0
- package/src/utils/minimal-publish-script.d.ts +2 -0
- package/src/utils/minimal-publish-script.js +76 -0
- package/src/utils/minimal-publish-script.js.map +1 -0
- package/src/utils/package-json/index.d.ts +13 -0
- package/src/utils/package-json/index.js +34 -0
- package/src/utils/package-json/index.js.map +1 -0
- package/src/utils/package-json/update-package-json.d.ts +20 -0
- package/src/utils/package-json/update-package-json.js +142 -0
- package/src/utils/package-json/update-package-json.js.map +1 -0
- package/src/utils/prettier.d.ts +6 -0
- package/src/utils/prettier.js +38 -0
- package/src/utils/prettier.js.map +1 -0
- package/src/utils/schema.d.ts +81 -0
- package/src/utils/swc/add-swc-config.d.ts +3 -0
- package/src/utils/swc/add-swc-config.js +44 -0
- package/src/utils/swc/add-swc-config.js.map +1 -0
- package/src/utils/swc/add-swc-dependencies.d.ts +2 -0
- package/src/utils/swc/add-swc-dependencies.js +15 -0
- package/src/utils/swc/add-swc-dependencies.js.map +1 -0
- package/src/utils/swc/compile-swc.d.ts +13 -0
- package/src/utils/swc/compile-swc.js +161 -0
- package/src/utils/swc/compile-swc.js.map +1 -0
- package/src/utils/swc/get-swcrc-path.d.ts +2 -0
- package/src/utils/swc/get-swcrc-path.js +14 -0
- package/src/utils/swc/get-swcrc-path.js.map +1 -0
- package/src/utils/swc/inline.d.ts +2 -0
- package/src/utils/swc/inline.js +13 -0
- package/src/utils/swc/inline.js.map +1 -0
- package/src/utils/typescript/__mocks__/plugin-a.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-a.js +6 -0
- package/src/utils/typescript/__mocks__/plugin-a.js.map +1 -0
- package/src/utils/typescript/__mocks__/plugin-b.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-b.js +6 -0
- package/src/utils/typescript/__mocks__/plugin-b.js.map +1 -0
- package/src/utils/typescript/ast-utils.d.ts +22 -0
- package/src/utils/typescript/ast-utils.js +199 -0
- package/src/utils/typescript/ast-utils.js.map +1 -0
- package/src/utils/typescript/compile-typescript-files.d.ts +10 -0
- package/src/utils/typescript/compile-typescript-files.js +45 -0
- package/src/utils/typescript/compile-typescript-files.js.map +1 -0
- package/src/utils/typescript/create-ts-config.d.ts +17 -0
- package/src/utils/typescript/create-ts-config.js +48 -0
- package/src/utils/typescript/create-ts-config.js.map +1 -0
- package/src/utils/typescript/ensure-typescript.d.ts +1 -0
- package/src/utils/typescript/ensure-typescript.js +10 -0
- package/src/utils/typescript/ensure-typescript.js.map +1 -0
- package/src/utils/typescript/get-source-nodes.d.ts +2 -0
- package/src/utils/typescript/get-source-nodes.js +19 -0
- package/src/utils/typescript/get-source-nodes.js.map +1 -0
- package/src/utils/typescript/load-ts-transformers.d.ts +5 -0
- package/src/utils/typescript/load-ts-transformers.js +63 -0
- package/src/utils/typescript/load-ts-transformers.js.map +1 -0
- package/src/utils/typescript/print-diagnostics.d.ts +1 -0
- package/src/utils/typescript/print-diagnostics.js +22 -0
- package/src/utils/typescript/print-diagnostics.js.map +1 -0
- package/src/utils/typescript/run-type-check.d.ts +32 -0
- package/src/utils/typescript/run-type-check.js +125 -0
- package/src/utils/typescript/run-type-check.js.map +1 -0
- package/src/utils/typescript/ts-config.d.ts +6 -0
- package/src/utils/typescript/ts-config.js +50 -0
- package/src/utils/typescript/ts-config.js.map +1 -0
- package/src/utils/typescript/types.d.ts +18 -0
- package/src/utils/typescript/types.js +3 -0
- package/src/utils/typescript/types.js.map +1 -0
- package/src/utils/versions.d.ts +8 -0
- package/src/utils/versions.js +13 -0
- package/src/utils/versions.js.map +1 -0
- package/src/utils/watch-for-single-file-changes.d.ts +1 -0
- package/src/utils/watch-for-single-file-changes.js +27 -0
- package/src/utils/watch-for-single-file-changes.js.map +1 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHelperDependenciesFromProjectGraph = exports.getHelperDependency = exports.HelperDependency = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const ts_config_1 = require("./typescript/ts-config");
|
|
7
|
+
const get_swcrc_path_1 = require("./swc/get-swcrc-path");
|
|
8
|
+
var HelperDependency;
|
|
9
|
+
(function (HelperDependency) {
|
|
10
|
+
HelperDependency["tsc"] = "npm:tslib";
|
|
11
|
+
HelperDependency["swc"] = "npm:@swc/helpers";
|
|
12
|
+
})(HelperDependency = exports.HelperDependency || (exports.HelperDependency = {}));
|
|
13
|
+
const jsExecutors = {
|
|
14
|
+
'@nrwl/js:tsc': {
|
|
15
|
+
helperDependency: HelperDependency.tsc,
|
|
16
|
+
getConfigPath: (options, contextRoot, _) => (0, path_1.join)(contextRoot, options.tsConfig),
|
|
17
|
+
},
|
|
18
|
+
'@nrwl/js:swc': {
|
|
19
|
+
helperDependency: HelperDependency.swc,
|
|
20
|
+
getConfigPath: (options, contextRoot, projectRoot) => (0, get_swcrc_path_1.getSwcrcPath)(options, contextRoot, projectRoot),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Check and return a DependencyNode for the compiler's external helpers npm package. Return "null"
|
|
25
|
+
* if it doesn't need it or it cannot be found in the Project Graph
|
|
26
|
+
*
|
|
27
|
+
* @param {HelperDependency} helperDependency
|
|
28
|
+
* @param {string} configPath
|
|
29
|
+
* @param {DependentBuildableProjectNode[]} dependencies
|
|
30
|
+
* @param {boolean=false} returnDependencyIfFound
|
|
31
|
+
*/
|
|
32
|
+
function getHelperDependency(helperDependency, configPath, dependencies, projectGraph, returnDependencyIfFound = false) {
|
|
33
|
+
const dependency = dependencies.find((dep) => dep.name === helperDependency);
|
|
34
|
+
if (!!dependency) {
|
|
35
|
+
// if a helperDependency is found, we either return null or the found dependency
|
|
36
|
+
// We return the found return dependency for the cases where it is a part of a
|
|
37
|
+
// project's dependency's dependency instead
|
|
38
|
+
// eg: app-a -> lib-a (helperDependency is on lib-a instead of app-a)
|
|
39
|
+
// When building app-a, we'd want to know about the found helper dependency still
|
|
40
|
+
return returnDependencyIfFound ? dependency : null;
|
|
41
|
+
}
|
|
42
|
+
let isHelperNeeded = false;
|
|
43
|
+
switch (helperDependency) {
|
|
44
|
+
case HelperDependency.tsc:
|
|
45
|
+
isHelperNeeded = !!(0, ts_config_1.readTsConfig)(configPath).options['importHelpers'];
|
|
46
|
+
break;
|
|
47
|
+
case HelperDependency.swc:
|
|
48
|
+
isHelperNeeded = !!(0, devkit_1.readJsonFile)(configPath)['jsc']['externalHelpers'];
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
if (!isHelperNeeded)
|
|
52
|
+
return null;
|
|
53
|
+
const libNode = projectGraph.externalNodes[helperDependency];
|
|
54
|
+
if (!libNode) {
|
|
55
|
+
devkit_1.logger.warn(`Your library compilation option specifies that the compiler external helper (${helperDependency.split(':')[1]}) is needed but it is not installed.`);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
name: helperDependency,
|
|
60
|
+
outputs: [],
|
|
61
|
+
node: libNode,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
exports.getHelperDependency = getHelperDependency;
|
|
65
|
+
function getHelperDependenciesFromProjectGraph(contextRoot, sourceProject, projectGraph) {
|
|
66
|
+
// if the source project isn't part of the projectGraph nodes; skip
|
|
67
|
+
if (!projectGraph.nodes[sourceProject])
|
|
68
|
+
return [];
|
|
69
|
+
// if the source project does not have any dependencies; skip
|
|
70
|
+
if (!projectGraph.dependencies[sourceProject] ||
|
|
71
|
+
!projectGraph.dependencies[sourceProject].length)
|
|
72
|
+
return [];
|
|
73
|
+
const sourceDependencies = projectGraph.dependencies[sourceProject];
|
|
74
|
+
const internalDependencies = sourceDependencies.reduce((result, dependency) => {
|
|
75
|
+
// we check if a dependency is part of the workspace and if it's a library
|
|
76
|
+
// because we wouldn't want to include external dependencies (npm packages)
|
|
77
|
+
if (!dependency.target.startsWith('npm:') &&
|
|
78
|
+
!!projectGraph.nodes[dependency.target] &&
|
|
79
|
+
projectGraph.nodes[dependency.target].type === 'lib') {
|
|
80
|
+
const targetData = projectGraph.nodes[dependency.target].data;
|
|
81
|
+
// check if the dependency has a buildable target with one of the jsExecutors
|
|
82
|
+
const targetExecutor = Object.values(targetData.targets).find(({ executor }) => !!jsExecutors[executor]);
|
|
83
|
+
if (targetExecutor) {
|
|
84
|
+
const jsExecutor = jsExecutors[targetExecutor['executor']];
|
|
85
|
+
const { root: projectRoot } = targetData;
|
|
86
|
+
const configPath = jsExecutor.getConfigPath(targetExecutor['options'], contextRoot, projectRoot);
|
|
87
|
+
// construct the correct helperDependency configurations
|
|
88
|
+
// so we can compute the ProjectGraphDependency later
|
|
89
|
+
result.push({
|
|
90
|
+
helperDependency: jsExecutors[targetExecutor['executor']].helperDependency,
|
|
91
|
+
dependencies: projectGraph.dependencies[dependency.target],
|
|
92
|
+
configPath,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}, []);
|
|
98
|
+
return internalDependencies.reduce((result, { helperDependency, configPath, dependencies }) => {
|
|
99
|
+
const dependency = getHelperDependency(helperDependency, configPath, dependencies, projectGraph, true);
|
|
100
|
+
if (dependency) {
|
|
101
|
+
result.push({
|
|
102
|
+
type: 'static',
|
|
103
|
+
source: sourceProject,
|
|
104
|
+
target: dependency.name,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}, []);
|
|
109
|
+
}
|
|
110
|
+
exports.getHelperDependenciesFromProjectGraph = getHelperDependenciesFromProjectGraph;
|
|
111
|
+
//# sourceMappingURL=compiler-helper-dependency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-helper-dependency.js","sourceRoot":"","sources":["../../../../../packages/js/src/utils/compiler-helper-dependency.ts"],"names":[],"mappings":";;;AAAA,uCAKoB;AAEpB,+BAA4B;AAC5B,sDAAsD;AAEtD,yDAAoD;AAEpD,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AAU,CAAC,IAAI;aACE,CAAC,CAAC;SAC9B;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,EACD,EAA8B,CAC/B,CAAC;AACJ,CAAC;AA/ED,sFA+EC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a set of glob patterns based off the source root of the app and its dependencies
|
|
3
|
+
* @param dirPath workspace relative directory path that will be used to infer the parent project and dependencies
|
|
4
|
+
* @param fileGlobPattern pass a custom glob pattern to be used
|
|
5
|
+
*/
|
|
6
|
+
export declare function createGlobPatternsForDependencies(dirPath: string, fileGlobPattern: string): string[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGlobPatternsForDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const workspace_root_1 = require("nx/src/utils/workspace-root");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
8
|
+
const project_graph_utils_1 = require("nx/src/utils/project-graph-utils");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const ignore_1 = require("ignore");
|
|
11
|
+
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
12
|
+
function configureIgnore() {
|
|
13
|
+
let ig;
|
|
14
|
+
const pathToGitIgnore = (0, path_1.join)(workspace_root_1.workspaceRoot, '.gitignore');
|
|
15
|
+
if ((0, fs_1.existsSync)(pathToGitIgnore)) {
|
|
16
|
+
ig = (0, ignore_1.default)();
|
|
17
|
+
ig.add((0, fs_1.readFileSync)(pathToGitIgnore, { encoding: 'utf-8' }));
|
|
18
|
+
}
|
|
19
|
+
return ig;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generates a set of glob patterns based off the source root of the app and its dependencies
|
|
23
|
+
* @param dirPath workspace relative directory path that will be used to infer the parent project and dependencies
|
|
24
|
+
* @param fileGlobPattern pass a custom glob pattern to be used
|
|
25
|
+
*/
|
|
26
|
+
function createGlobPatternsForDependencies(dirPath, fileGlobPattern) {
|
|
27
|
+
let ig = configureIgnore();
|
|
28
|
+
const filenameRelativeToWorkspaceRoot = (0, devkit_1.normalizePath)((0, path_1.relative)(workspace_root_1.workspaceRoot, dirPath));
|
|
29
|
+
const projectGraph = (0, project_graph_1.readCachedProjectGraph)();
|
|
30
|
+
const projectRootMappings = (0, find_project_for_path_1.createProjectRootMappings)(projectGraph.nodes);
|
|
31
|
+
// find the project
|
|
32
|
+
let projectName;
|
|
33
|
+
try {
|
|
34
|
+
projectName = (0, find_project_for_path_1.findProjectForPath)(filenameRelativeToWorkspaceRoot, projectRootMappings);
|
|
35
|
+
if (!projectName) {
|
|
36
|
+
throw new Error(`createGlobPatternsForDependencies: Could not find any project containing the file "${filenameRelativeToWorkspaceRoot}" among it's project files`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
throw new Error(`createGlobPatternsForDependencies: Error when trying to determine main project.\n${e === null || e === void 0 ? void 0 : e.message}`);
|
|
41
|
+
}
|
|
42
|
+
// generate the glob
|
|
43
|
+
try {
|
|
44
|
+
const [projectDirs, warnings] = (0, project_graph_utils_1.getSourceDirOfDependentProjects)(projectName, projectGraph);
|
|
45
|
+
const dirsToUse = [];
|
|
46
|
+
const recursiveScanDirs = (dirPath) => {
|
|
47
|
+
const children = (0, fs_1.readdirSync)((0, path_1.resolve)(workspace_root_1.workspaceRoot, dirPath));
|
|
48
|
+
for (const child of children) {
|
|
49
|
+
const childPath = (0, path_1.join)(dirPath, child);
|
|
50
|
+
if ((ig === null || ig === void 0 ? void 0 : ig.ignores(childPath)) ||
|
|
51
|
+
!(0, fs_1.lstatSync)((0, path_1.resolve)(workspace_root_1.workspaceRoot, childPath)).isDirectory()) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, childPath, 'ng-package.json'))) {
|
|
55
|
+
dirsToUse.push(childPath);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
recursiveScanDirs(childPath);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
for (const srcDir of projectDirs) {
|
|
63
|
+
dirsToUse.push(srcDir);
|
|
64
|
+
const root = (0, path_1.dirname)(srcDir);
|
|
65
|
+
recursiveScanDirs(root);
|
|
66
|
+
}
|
|
67
|
+
if (warnings.length > 0) {
|
|
68
|
+
devkit_1.logger.warn(`
|
|
69
|
+
[createGlobPatternsForDependencies] Failed to generate glob pattern for the following:
|
|
70
|
+
${warnings.join('\n- ')}\n
|
|
71
|
+
due to missing "sourceRoot" in the dependencies' project configuration
|
|
72
|
+
`);
|
|
73
|
+
}
|
|
74
|
+
return dirsToUse.map((sourceDir) => (0, path_1.resolve)(workspace_root_1.workspaceRoot, (0, devkit_1.joinPathFragments)(sourceDir, fileGlobPattern)));
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
throw new Error(`createGlobPatternsForDependencies: Error when generating globs.\n${e === null || e === void 0 ? void 0 : e.message}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.createGlobPatternsForDependencies = createGlobPatternsForDependencies;
|
|
81
|
+
//# sourceMappingURL=generate-globs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-globs.js","sourceRoot":"","sources":["../../../../../packages/js/src/utils/generate-globs.ts"],"names":[],"mappings":";;;AAAA,uCAAsE;AACtE,gEAA4D;AAC5D,+BAAwD;AACxD,sEAA4E;AAC5E,0EAAmF;AACnF,2BAAsE;AACtE,mCAAwC;AACxC,4FAG0D;AAE1D,SAAS,eAAe;IACtB,IAAI,EAAU,CAAC;IACf,MAAM,eAAe,GAAG,IAAA,WAAI,EAAC,8BAAa,EAAE,YAAY,CAAC,CAAC;IAC1D,IA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
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { NormalizedExecutorOptions } from './schema';
|
|
3
|
+
interface InlineProjectNode {
|
|
4
|
+
name: string;
|
|
5
|
+
root: string;
|
|
6
|
+
sourceRoot: string;
|
|
7
|
+
pathAlias: string;
|
|
8
|
+
buildOutputPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface InlineProjectGraph {
|
|
11
|
+
nodes: Record<string, InlineProjectNode>;
|
|
12
|
+
externals: Record<string, InlineProjectNode>;
|
|
13
|
+
dependencies: Record<string, string[]>;
|
|
14
|
+
}
|
|
15
|
+
export declare function isInlineGraphEmpty(inlineGraph: InlineProjectGraph): boolean;
|
|
16
|
+
export declare function handleInliningBuild(context: ExecutorContext, options: NormalizedExecutorOptions, tsConfigPath: string): InlineProjectGraph;
|
|
17
|
+
export declare function postProcessInlinedDependencies(outputPath: string, parentOutputPath: string, inlineGraph: InlineProjectGraph): void;
|
|
18
|
+
export declare function getRootTsConfigPath(context: ExecutorContext): string | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRootTsConfigPath = exports.postProcessInlinedDependencies = exports.handleInliningBuild = exports.isInlineGraphEmpty = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
function isInlineGraphEmpty(inlineGraph) {
|
|
9
|
+
return Object.keys(inlineGraph.nodes).length === 0;
|
|
10
|
+
}
|
|
11
|
+
exports.isInlineGraphEmpty = isInlineGraphEmpty;
|
|
12
|
+
function handleInliningBuild(context, options, tsConfigPath) {
|
|
13
|
+
var _a;
|
|
14
|
+
const tsConfigJson = (0, devkit_1.readJsonFile)(tsConfigPath);
|
|
15
|
+
const pathAliases = ((_a = tsConfigJson['compilerOptions']) === null || _a === void 0 ? void 0 : _a['paths']) || readBasePathAliases(context);
|
|
16
|
+
const inlineGraph = createInlineGraph(context, options, pathAliases);
|
|
17
|
+
if (isInlineGraphEmpty(inlineGraph)) {
|
|
18
|
+
return inlineGraph;
|
|
19
|
+
}
|
|
20
|
+
buildInlineGraphExternals(context, inlineGraph, pathAliases);
|
|
21
|
+
return inlineGraph;
|
|
22
|
+
}
|
|
23
|
+
exports.handleInliningBuild = handleInliningBuild;
|
|
24
|
+
function postProcessInlinedDependencies(outputPath, parentOutputPath, inlineGraph) {
|
|
25
|
+
if (isInlineGraphEmpty(inlineGraph)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const parentDistPath = (0, path_1.join)(outputPath, parentOutputPath);
|
|
29
|
+
// move parentOutput
|
|
30
|
+
movePackage(parentDistPath, outputPath);
|
|
31
|
+
const inlinedDepsDestOutputRecord = {};
|
|
32
|
+
// move inlined outputs
|
|
33
|
+
for (const inlineDependenciesNames of Object.values(inlineGraph.dependencies)) {
|
|
34
|
+
for (const inlineDependenciesName of inlineDependenciesNames) {
|
|
35
|
+
const inlineDependency = inlineGraph.nodes[inlineDependenciesName];
|
|
36
|
+
const depOutputPath = inlineDependency.buildOutputPath ||
|
|
37
|
+
(0, path_1.join)(outputPath, inlineDependency.root);
|
|
38
|
+
const destDepOutputPath = (0, path_1.join)(outputPath, inlineDependency.name);
|
|
39
|
+
const isBuildable = !!inlineDependency.buildOutputPath;
|
|
40
|
+
if (isBuildable) {
|
|
41
|
+
(0, fs_extra_1.copySync)(depOutputPath, destDepOutputPath, { overwrite: true });
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
movePackage(depOutputPath, destDepOutputPath);
|
|
45
|
+
}
|
|
46
|
+
// TODO: hard-coded "src"
|
|
47
|
+
inlinedDepsDestOutputRecord[inlineDependency.pathAlias] =
|
|
48
|
+
destDepOutputPath + '/src';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
updateImports(outputPath, inlinedDepsDestOutputRecord);
|
|
52
|
+
}
|
|
53
|
+
exports.postProcessInlinedDependencies = postProcessInlinedDependencies;
|
|
54
|
+
function readBasePathAliases(context) {
|
|
55
|
+
var _a;
|
|
56
|
+
return (_a = (0, devkit_1.readJsonFile)(getRootTsConfigPath(context))) === null || _a === void 0 ? void 0 : _a['compilerOptions']['paths'];
|
|
57
|
+
}
|
|
58
|
+
function getRootTsConfigPath(context) {
|
|
59
|
+
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
60
|
+
const tsConfigPath = (0, path_1.join)(context.root, tsConfigName);
|
|
61
|
+
if ((0, fs_1.existsSync)(tsConfigPath)) {
|
|
62
|
+
return tsConfigPath;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw new Error('Could not find a root tsconfig.json or tsconfig.base.json file.');
|
|
66
|
+
}
|
|
67
|
+
exports.getRootTsConfigPath = getRootTsConfigPath;
|
|
68
|
+
function emptyInlineGraph() {
|
|
69
|
+
return { nodes: {}, externals: {}, dependencies: {} };
|
|
70
|
+
}
|
|
71
|
+
function projectNodeToInlineProjectNode(projectNode, pathAlias = '', buildOutputPath = '') {
|
|
72
|
+
return {
|
|
73
|
+
name: projectNode.name,
|
|
74
|
+
root: projectNode.data.root,
|
|
75
|
+
sourceRoot: projectNode.data.sourceRoot,
|
|
76
|
+
pathAlias,
|
|
77
|
+
buildOutputPath,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function createInlineGraph(context, options, pathAliases, projectName = context.projectName, inlineGraph = emptyInlineGraph()) {
|
|
81
|
+
var _a;
|
|
82
|
+
var _b;
|
|
83
|
+
if (options.external == null)
|
|
84
|
+
return inlineGraph;
|
|
85
|
+
const projectDependencies = context.projectGraph.dependencies[projectName] || [];
|
|
86
|
+
if (projectDependencies.length === 0)
|
|
87
|
+
return inlineGraph;
|
|
88
|
+
if (!inlineGraph.nodes[projectName]) {
|
|
89
|
+
inlineGraph.nodes[projectName] = projectNodeToInlineProjectNode(context.projectGraph.nodes[projectName]);
|
|
90
|
+
}
|
|
91
|
+
const implicitDependencies = context.projectGraph.nodes[projectName].data.implicitDependencies || [];
|
|
92
|
+
for (const projectDependency of projectDependencies) {
|
|
93
|
+
// skip npm packages
|
|
94
|
+
if (projectDependency.target.startsWith('npm')) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
// skip implicitDependencies
|
|
98
|
+
if (implicitDependencies.includes(projectDependency.target)) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const pathAlias = getPathAliasForPackage(context.projectGraph.nodes[projectDependency.target], pathAliases);
|
|
102
|
+
const buildOutputPath = getBuildOutputPath(projectDependency.target, context, options);
|
|
103
|
+
const shouldInline =
|
|
104
|
+
/**
|
|
105
|
+
* if all buildable libraries are marked as external,
|
|
106
|
+
* then push the project dependency that doesn't have a build target
|
|
107
|
+
*/
|
|
108
|
+
(options.external === 'all' && !buildOutputPath) ||
|
|
109
|
+
/**
|
|
110
|
+
* if all buildable libraries are marked as internal,
|
|
111
|
+
* then push every project dependency to be inlined
|
|
112
|
+
*/
|
|
113
|
+
options.external === 'none' ||
|
|
114
|
+
/**
|
|
115
|
+
* if some buildable libraries are marked as external,
|
|
116
|
+
* then push the project dependency that IS NOT marked as external OR doesn't have a build target
|
|
117
|
+
*/
|
|
118
|
+
(Array.isArray(options.external) &&
|
|
119
|
+
options.external.length > 0 &&
|
|
120
|
+
!options.external.includes(projectDependency.target)) ||
|
|
121
|
+
!buildOutputPath;
|
|
122
|
+
if (shouldInline) {
|
|
123
|
+
(_a = (_b = inlineGraph.dependencies)[projectName]) !== null && _a !== void 0 ? _a : (_b[projectName] = []);
|
|
124
|
+
inlineGraph.dependencies[projectName].push(projectDependency.target);
|
|
125
|
+
}
|
|
126
|
+
inlineGraph.nodes[projectDependency.target] =
|
|
127
|
+
projectNodeToInlineProjectNode(context.projectGraph.nodes[projectDependency.target], pathAlias, buildOutputPath);
|
|
128
|
+
if (context.projectGraph.dependencies[projectDependency.target].length > 0) {
|
|
129
|
+
inlineGraph = createInlineGraph(context, options, pathAliases, projectDependency.target, inlineGraph);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return inlineGraph;
|
|
133
|
+
}
|
|
134
|
+
function buildInlineGraphExternals(context, inlineProjectGraph, pathAliases) {
|
|
135
|
+
const allNodes = Object.assign({}, context.projectGraph.nodes);
|
|
136
|
+
for (const [parent, dependencies] of Object.entries(inlineProjectGraph.dependencies)) {
|
|
137
|
+
if (allNodes[parent]) {
|
|
138
|
+
delete allNodes[parent];
|
|
139
|
+
}
|
|
140
|
+
for (const dependencyName of dependencies) {
|
|
141
|
+
const dependencyNode = inlineProjectGraph.nodes[dependencyName];
|
|
142
|
+
// buildable is still external even if it is a dependency
|
|
143
|
+
if (dependencyNode.buildOutputPath) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (allNodes[dependencyName]) {
|
|
147
|
+
delete allNodes[dependencyName];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
for (const [projectName, projectNode] of Object.entries(allNodes)) {
|
|
152
|
+
if (!inlineProjectGraph.externals[projectName]) {
|
|
153
|
+
inlineProjectGraph.externals[projectName] =
|
|
154
|
+
projectNodeToInlineProjectNode(projectNode, getPathAliasForPackage(projectNode, pathAliases));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function movePackage(from, to) {
|
|
159
|
+
if (from === to)
|
|
160
|
+
return;
|
|
161
|
+
(0, fs_extra_1.copySync)(from, to, { overwrite: true });
|
|
162
|
+
(0, fs_extra_1.removeSync)(from);
|
|
163
|
+
}
|
|
164
|
+
function updateImports(destOutputPath, inlinedDepsDestOutputRecord) {
|
|
165
|
+
const importRegex = new RegExp(Object.keys(inlinedDepsDestOutputRecord)
|
|
166
|
+
.map((pathAlias) => `["'](${pathAlias})["']`)
|
|
167
|
+
.join('|'), 'g');
|
|
168
|
+
recursiveUpdateImport(destOutputPath, importRegex, inlinedDepsDestOutputRecord);
|
|
169
|
+
}
|
|
170
|
+
function recursiveUpdateImport(dirPath, importRegex, inlinedDepsDestOutputRecord, rootParentDir) {
|
|
171
|
+
const files = (0, fs_extra_1.readdirSync)(dirPath, { withFileTypes: true });
|
|
172
|
+
for (const file of files) {
|
|
173
|
+
// only check .js and .d.ts files
|
|
174
|
+
if (file.isFile() &&
|
|
175
|
+
(file.name.endsWith('.js') || file.name.endsWith('.d.ts'))) {
|
|
176
|
+
const filePath = (0, path_1.join)(dirPath, file.name);
|
|
177
|
+
const fileContent = (0, fs_extra_1.readFileSync)(filePath, 'utf-8');
|
|
178
|
+
const updatedContent = fileContent.replace(importRegex, (matched) => {
|
|
179
|
+
const result = matched.replace(/['"]/g, '');
|
|
180
|
+
// If a match is the same as the rootParentDir, we're checking its own files so we return the matched as in no changes.
|
|
181
|
+
if (result === rootParentDir)
|
|
182
|
+
return matched;
|
|
183
|
+
const importPath = `"${(0, path_1.relative)(dirPath, inlinedDepsDestOutputRecord[result])}"`;
|
|
184
|
+
return (0, devkit_1.normalizePath)(importPath);
|
|
185
|
+
});
|
|
186
|
+
(0, fs_extra_1.writeFileSync)(filePath, updatedContent);
|
|
187
|
+
}
|
|
188
|
+
else if (file.isDirectory()) {
|
|
189
|
+
recursiveUpdateImport((0, path_1.join)(dirPath, file.name), importRegex, inlinedDepsDestOutputRecord, rootParentDir || file.name);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function getPathAliasForPackage(packageNode, pathAliases) {
|
|
194
|
+
if (!packageNode)
|
|
195
|
+
return '';
|
|
196
|
+
for (const [alias, paths] of Object.entries(pathAliases)) {
|
|
197
|
+
if (paths.some((path) => path.includes(packageNode.data.root))) {
|
|
198
|
+
return alias;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return '';
|
|
202
|
+
}
|
|
203
|
+
function getBuildOutputPath(projectName, context, options) {
|
|
204
|
+
var _a, _b;
|
|
205
|
+
const projectTargets = (_b = (_a = context.projectGraph.nodes[projectName]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.targets;
|
|
206
|
+
if (!projectTargets)
|
|
207
|
+
return '';
|
|
208
|
+
const buildTarget = options.externalBuildTargets.find((buildTarget) => projectTargets[buildTarget]);
|
|
209
|
+
return buildTarget ? projectTargets[buildTarget].options['outputPath'] : '';
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=inline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline.js","sourceRoot":"","sources":["../../../../../packages/js/src/utils/inline.ts"],"names":[],"mappings":";;;AACA,uCAAyD;AACzD,uCAMkB;AAClB,+BAAsC;AAEtC,2BAAgC;AAgBhC,SAAgB,kBAAkB,CAAC,WAA+B;IAChE,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACrD,CAAC;AAFD,gDAEC;AAED,SAAgB,mBAAmB,CACjC,OAAwB,EACxB,OAAkC,EAClC,YAAoB;;IAEpB,MAAM,YAAY,GAAG,IAAA,qBAAY,EAAC,YAAY,CAAC,CAAC;IAChD,MAAM,WAAW,GACf,CAAA,MAAA,YAAY,CAAC,iBAAiB,CAAC,0CAAG,OAAO,CAAC,KAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC7E,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAErE,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE;QACnC,OAAO,WAAW,CAAC;KACpB;IAED,yBAAyB,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAE7D,OAAO,WAAW,CAAC;AACrB,CAAC;AAjBD,kDAiBC;AAED,SAAgB,8BAA8B,CAC5C,UAAkB,EAClB,g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AA,MAAA,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,0CAAE,IAAI,0CAAE,OAAO,CAAC;IAC9E,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAE/B,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,IAAI,CACnD,CAAC,WAAW,EAAE,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,CAC7C,CAAC;IAEF,OAAO,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addMinimalPublishScript = void 0;
|
|
4
|
+
const publishScriptContent = `
|
|
5
|
+
/**
|
|
6
|
+
* This is a minimal script to publish your package to "npm".
|
|
7
|
+
* This is meant to be used as-is or customize as you see fit.
|
|
8
|
+
*
|
|
9
|
+
* This script is executed on "dist/path/to/library" as "cwd" by default.
|
|
10
|
+
*
|
|
11
|
+
* You might need to authenticate with NPM before running this script.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { readCachedProjectGraph } from '@nrwl/devkit';
|
|
15
|
+
import { execSync } from 'child_process';
|
|
16
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
17
|
+
import chalk from 'chalk';
|
|
18
|
+
|
|
19
|
+
function invariant(condition, message) {
|
|
20
|
+
if (!condition) {
|
|
21
|
+
console.error(chalk.bold.red(message));
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag}
|
|
27
|
+
// Default "tag" to "next" so we won't publish the "latest" tag by accident.
|
|
28
|
+
const [, , name, version, tag = 'next'] = process.argv;
|
|
29
|
+
|
|
30
|
+
// A simple SemVer validation to validate the version
|
|
31
|
+
const validVersion = /^\\d+\\.\\d+\\.\\d+(-\\w+\\.\\d+)?/;
|
|
32
|
+
invariant(
|
|
33
|
+
version && validVersion.test(version),
|
|
34
|
+
\`No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got \${version}.\`
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const graph = readCachedProjectGraph();
|
|
39
|
+
const project = graph.nodes[name];
|
|
40
|
+
|
|
41
|
+
invariant(
|
|
42
|
+
project,
|
|
43
|
+
\`Could not find project "\${name}" in the workspace. Is the project.json configured correctly?\`
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const outputPath = project.data?.targets?.build?.options?.outputPath;
|
|
47
|
+
invariant(
|
|
48
|
+
outputPath,
|
|
49
|
+
\`Could not find "build.options.outputPath" of project "\${name}". Is project.json configured correctly?\`
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
process.chdir(outputPath);
|
|
53
|
+
|
|
54
|
+
// Updating the version in "package.json" before publishing
|
|
55
|
+
try {
|
|
56
|
+
const json = JSON.parse(readFileSync(\`package.json\`).toString());
|
|
57
|
+
json.version = version;
|
|
58
|
+
writeFileSync(\`package.json\`, JSON.stringify(json, null, 2));
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.error(
|
|
61
|
+
chalk.bold.red(\`Error reading package.json file from library build output.\`)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Execute "npm publish" to publish
|
|
66
|
+
execSync(\`npm publish --access public --tag \${tag}\`);
|
|
67
|
+
`;
|
|
68
|
+
function addMinimalPublishScript(tree) {
|
|
69
|
+
const publishScriptPath = 'tools/scripts/publish.mjs';
|
|
70
|
+
if (!tree.exists(publishScriptPath)) {
|
|
71
|
+
tree.write(publishScriptPath, publishScriptContent);
|
|
72
|
+
}
|
|
73
|
+
return publishScriptPath;
|
|
74
|
+
}
|
|
75
|
+
exports.addMinimalPublishScript = addMinimalPublishScript;
|
|
76
|
+
//# sourceMappingURL=minimal-publish-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-publish-script.js","sourceRoot":"","sources":["../../../../../packages/js/src/utils/minimal-publish-script.ts"],"names":[],"mappings":";;;AAEA,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+D5B,CAAC;AAEF,SAAgB,uBAAuB,CAAC,IAAU;IAChD,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;IAEtD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;QACnC,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;KACrD;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AARD,0DAQC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { DependentBuildableProjectNode } from '../buildable-libs-utils';
|
|
3
|
+
import type { UpdatePackageJsonOption } from './update-package-json';
|
|
4
|
+
export interface CopyPackageJsonOptions extends Omit<UpdatePackageJsonOption, 'projectRoot'> {
|
|
5
|
+
watch?: boolean;
|
|
6
|
+
extraDependencies?: DependentBuildableProjectNode[];
|
|
7
|
+
overrideDependencies?: DependentBuildableProjectNode[];
|
|
8
|
+
}
|
|
9
|
+
export interface CopyPackageJsonResult {
|
|
10
|
+
success?: boolean;
|
|
11
|
+
stop?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function copyPackageJson(_options: CopyPackageJsonOptions, context: ExecutorContext): Promise<CopyPackageJsonResult>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyPackageJson = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const watch_for_single_file_changes_1 = require("../watch-for-single-file-changes");
|
|
6
|
+
const update_package_json_1 = require("./update-package-json");
|
|
7
|
+
const check_dependencies_1 = require("../check-dependencies");
|
|
8
|
+
function copyPackageJson(_options, context) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
if (!context.target.options.tsConfig) {
|
|
11
|
+
throw new Error(`Could not find tsConfig option for "${context.targetName}" target of "${context.projectName}" project. Check that your project configuration is correct.`);
|
|
12
|
+
}
|
|
13
|
+
let { target, dependencies, projectRoot } = (0, check_dependencies_1.checkDependencies)(context, context.target.options.tsConfig);
|
|
14
|
+
const options = Object.assign(Object.assign({}, _options), { projectRoot });
|
|
15
|
+
if (options.extraDependencies) {
|
|
16
|
+
dependencies.push(...options.extraDependencies);
|
|
17
|
+
}
|
|
18
|
+
if (options.overrideDependencies) {
|
|
19
|
+
dependencies = options.overrideDependencies;
|
|
20
|
+
}
|
|
21
|
+
if (options.watch) {
|
|
22
|
+
const dispose = yield (0, watch_for_single_file_changes_1.watchForSingleFileChanges)(context.projectName, options.projectRoot, 'package.json', () => (0, update_package_json_1.updatePackageJson)(options, context, target, dependencies));
|
|
23
|
+
// Copy it once before changes
|
|
24
|
+
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies);
|
|
25
|
+
return { success: true, stop: dispose };
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies);
|
|
29
|
+
return { success: true };
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.copyPackageJson = copyPackageJson;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/package-json/index.ts"],"names":[],"mappings":";;;;AAGA,oFAA6E;AAE7E,+DAA0D;AAC1D,8DAA0D;AAe1D,SAAsB,eAAe,CACnC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1
|
+
import { ExecutorContext, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
+
import { DependentBuildableProjectNode } from '../buildable-libs-utils';
|
|
3
|
+
import type { PackageJson } from 'nx/src/utils/package-json';
|
|
4
|
+
export type SupportedFormat = 'cjs' | 'esm';
|
|
5
|
+
export interface UpdatePackageJsonOption {
|
|
6
|
+
projectRoot: string;
|
|
7
|
+
main: string;
|
|
8
|
+
format?: SupportedFormat[];
|
|
9
|
+
outputPath: string;
|
|
10
|
+
outputFileName?: string;
|
|
11
|
+
outputFileExtensionForCjs?: `.${string}`;
|
|
12
|
+
skipTypings?: boolean;
|
|
13
|
+
generateExportsField?: boolean;
|
|
14
|
+
excludeLibsInPackageJson?: boolean;
|
|
15
|
+
updateBuildableProjectDepsInPackageJson?: boolean;
|
|
16
|
+
buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
|
|
17
|
+
generateLockfile?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function updatePackageJson(options: UpdatePackageJsonOption, context: ExecutorContext, target: ProjectGraphProjectNode, dependencies: DependentBuildableProjectNode[]): void;
|
|
20
|
+
export declare function getUpdatedPackageJsonContent(packageJson: PackageJson, options: UpdatePackageJsonOption): PackageJson;
|