@nx/devkit 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/index.d.ts +19 -0
- package/index.js +27 -0
- package/migrations.json +12 -0
- package/ngcli-adapter.d.ts +4 -0
- package/ngcli-adapter.js +13 -0
- package/ngcli-adapter.js.map +1 -0
- package/nx-reexports-pre16.d.ts +127 -0
- package/nx-reexports-pre16.js +141 -0
- package/nx-reexports-pre16.js.map +1 -0
- package/nx.d.ts +1 -0
- package/nx.js +13 -0
- package/nx.js.map +1 -0
- package/package.json +49 -0
- package/public-api.d.ts +82 -0
- package/public-api.js +114 -0
- package/public-api.js.map +1 -0
- package/src/executors/parse-target-string.d.ts +31 -0
- package/src/executors/parse-target-string.js +36 -0
- package/src/executors/parse-target-string.js.map +1 -0
- package/src/executors/read-target-options.d.ts +8 -0
- package/src/executors/read-target-options.js +24 -0
- package/src/executors/read-target-options.js.map +1 -0
- package/src/generators/executor-options-utils.d.ts +21 -0
- package/src/generators/executor-options-utils.js +50 -0
- package/src/generators/executor-options-utils.js.map +1 -0
- package/src/generators/format-files.d.ts +6 -0
- package/src/generators/format-files.js +75 -0
- package/src/generators/format-files.js.map +1 -0
- package/src/generators/generate-files.d.ts +26 -0
- package/src/generators/generate-files.js +120 -0
- package/src/generators/generate-files.js.map +1 -0
- package/src/generators/run-tasks-in-serial.d.ts +7 -0
- package/src/generators/run-tasks-in-serial.js +18 -0
- package/src/generators/run-tasks-in-serial.js.map +1 -0
- package/src/generators/to-js.d.ts +5 -0
- package/src/generators/to-js.js +25 -0
- package/src/generators/to-js.js.map +1 -0
- package/src/generators/typescript/insert-import.d.ts +1 -0
- package/src/generators/typescript/insert-import.js +6 -0
- package/src/generators/typescript/insert-import.js.map +1 -0
- package/src/generators/typescript/insert-statement.d.ts +1 -0
- package/src/generators/typescript/insert-statement.js +6 -0
- package/src/generators/typescript/insert-statement.js.map +1 -0
- package/src/generators/update-ts-configs-to-js.d.ts +4 -0
- package/src/generators/update-ts-configs-to-js.js +50 -0
- package/src/generators/update-ts-configs-to-js.js.map +1 -0
- package/src/generators/visit-not-ignored-files.d.ts +5 -0
- package/src/generators/visit-not-ignored-files.js +37 -0
- package/src/generators/visit-not-ignored-files.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/tasks/install-packages-task.d.ts +10 -0
- package/src/tasks/install-packages-task.js +35 -0
- package/src/tasks/install-packages-task.js.map +1 -0
- package/src/utils/async-iterable/combine-async-iterables.d.ts +3 -0
- package/src/utils/async-iterable/combine-async-iterables.js +82 -0
- package/src/utils/async-iterable/combine-async-iterables.js.map +1 -0
- package/src/utils/async-iterable/create-async-iterable.d.ts +6 -0
- package/src/utils/async-iterable/create-async-iterable.js +62 -0
- package/src/utils/async-iterable/create-async-iterable.js.map +1 -0
- package/src/utils/async-iterable/index.d.ts +4 -0
- package/src/utils/async-iterable/index.js +8 -0
- package/src/utils/async-iterable/index.js.map +1 -0
- package/src/utils/async-iterable/map-async-iteratable.d.ts +1 -0
- package/src/utils/async-iterable/map-async-iteratable.js +24 -0
- package/src/utils/async-iterable/map-async-iteratable.js.map +1 -0
- package/src/utils/async-iterable/tap-async-iteratable.d.ts +1 -0
- package/src/utils/async-iterable/tap-async-iteratable.js +15 -0
- package/src/utils/async-iterable/tap-async-iteratable.js.map +1 -0
- package/src/utils/convert-nx-executor.d.ts +7 -0
- package/src/utils/convert-nx-executor.js +88 -0
- package/src/utils/convert-nx-executor.js.map +1 -0
- package/src/utils/get-workspace-layout.d.ts +25 -0
- package/src/utils/get-workspace-layout.js +53 -0
- package/src/utils/get-workspace-layout.js.map +1 -0
- package/src/utils/invoke-nx-generator.d.ts +6 -0
- package/src/utils/invoke-nx-generator.js +174 -0
- package/src/utils/invoke-nx-generator.js.map +1 -0
- package/src/utils/module-federation/dependencies.d.ts +6 -0
- package/src/utils/module-federation/dependencies.js +47 -0
- package/src/utils/module-federation/dependencies.js.map +1 -0
- package/src/utils/module-federation/index.d.ts +5 -0
- package/src/utils/module-federation/index.js +9 -0
- package/src/utils/module-federation/index.js.map +1 -0
- package/src/utils/module-federation/models/index.d.ts +39 -0
- package/src/utils/module-federation/models/index.js +3 -0
- package/src/utils/module-federation/models/index.js.map +1 -0
- package/src/utils/module-federation/package-json.d.ts +8 -0
- package/src/utils/module-federation/package-json.js +15 -0
- package/src/utils/module-federation/package-json.js.map +1 -0
- package/src/utils/module-federation/remotes.d.ts +19 -0
- package/src/utils/module-federation/remotes.js +59 -0
- package/src/utils/module-federation/remotes.js.map +1 -0
- package/src/utils/module-federation/secondary-entry-points.d.ts +12 -0
- package/src/utils/module-federation/secondary-entry-points.js +106 -0
- package/src/utils/module-federation/secondary-entry-points.js.map +1 -0
- package/src/utils/module-federation/share.d.ts +48 -0
- package/src/utils/module-federation/share.js +187 -0
- package/src/utils/module-federation/share.js.map +1 -0
- package/src/utils/module-federation/typescript.d.ts +3 -0
- package/src/utils/module-federation/typescript.js +39 -0
- package/src/utils/module-federation/typescript.js.map +1 -0
- package/src/utils/move-dir.d.ts +5 -0
- package/src/utils/move-dir.js +29 -0
- package/src/utils/move-dir.js.map +1 -0
- package/src/utils/names.d.ts +18 -0
- package/src/utils/names.js +63 -0
- package/src/utils/names.js.map +1 -0
- package/src/utils/offset-from-root.d.ts +13 -0
- package/src/utils/offset-from-root.js +30 -0
- package/src/utils/offset-from-root.js.map +1 -0
- package/src/utils/package-json.d.ts +74 -0
- package/src/utils/package-json.js +305 -0
- package/src/utils/package-json.js.map +1 -0
- package/src/utils/replace-package.d.ts +2 -0
- package/src/utils/replace-package.js +107 -0
- package/src/utils/replace-package.js.map +1 -0
- package/src/utils/rxjs-for-await.d.ts +109 -0
- package/src/utils/rxjs-for-await.js +373 -0
- package/src/utils/rxjs-for-await.js.map +1 -0
- package/src/utils/semver.d.ts +1 -0
- package/src/utils/semver.js +19 -0
- package/src/utils/semver.js.map +1 -0
- package/src/utils/string-change.d.ts +62 -0
- package/src/utils/string-change.js +110 -0
- package/src/utils/string-change.js.map +1 -0
- package/src/utils/string-utils.d.ts +95 -0
- package/src/utils/string-utils.js +148 -0
- package/src/utils/string-utils.js.map +1 -0
- package/testing-pre16.d.ts +2 -0
- package/testing-pre16.js +10 -0
- package/testing-pre16.js.map +1 -0
- package/testing.d.ts +2 -0
- package/testing.js +9 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyAdditionalShared = exports.applySharedFunction = exports.sharePackages = exports.getNpmPackageSharedConfig = exports.shareWorkspaceLibraries = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const package_json_1 = require("./package-json");
|
|
6
|
+
const typescript_1 = require("./typescript");
|
|
7
|
+
const secondary_entry_points_1 = require("./secondary-entry-points");
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
9
|
+
const typescript_2 = require("nx/src/utils/typescript");
|
|
10
|
+
const nx_1 = require("../../../nx");
|
|
11
|
+
const { workspaceRoot, logger } = (0, nx_1.requireNx)();
|
|
12
|
+
/**
|
|
13
|
+
* Build an object of functions to be used with the ModuleFederationPlugin to
|
|
14
|
+
* share Nx Workspace Libraries between Hosts and Remotes.
|
|
15
|
+
*
|
|
16
|
+
* @param libraries - The Nx Workspace Libraries to share
|
|
17
|
+
* @param tsConfigPath - The path to TS Config File that contains the Path Mappings for the Libraries
|
|
18
|
+
*/
|
|
19
|
+
function shareWorkspaceLibraries(libraries, tsConfigPath) {
|
|
20
|
+
var _a;
|
|
21
|
+
if (tsConfigPath === void 0) { tsConfigPath = (_a = process.env.NX_TSCONFIG_PATH) !== null && _a !== void 0 ? _a : (0, typescript_2.getRootTsConfigPath)(); }
|
|
22
|
+
if (!libraries) {
|
|
23
|
+
return getEmptySharedLibrariesConfig();
|
|
24
|
+
}
|
|
25
|
+
const tsconfigPathAliases = (0, typescript_1.readTsPathMappings)(tsConfigPath);
|
|
26
|
+
if (!Object.keys(tsconfigPathAliases).length) {
|
|
27
|
+
return getEmptySharedLibrariesConfig();
|
|
28
|
+
}
|
|
29
|
+
const pathMappings = [];
|
|
30
|
+
for (const [key, paths] of Object.entries(tsconfigPathAliases)) {
|
|
31
|
+
const library = libraries.find((lib) => lib.importKey === key);
|
|
32
|
+
if (!library) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
// This is for Angular Projects that use ng-package.json
|
|
36
|
+
// It will do nothing for React Projects
|
|
37
|
+
(0, secondary_entry_points_1.collectWorkspaceLibrarySecondaryEntryPoints)(library, tsconfigPathAliases).forEach(({ name, path }) => pathMappings.push({
|
|
38
|
+
name,
|
|
39
|
+
path,
|
|
40
|
+
}));
|
|
41
|
+
pathMappings.push({
|
|
42
|
+
name: key,
|
|
43
|
+
path: (0, path_1.normalize)((0, path_1.join)(workspaceRoot, paths[0])),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const webpack = require('webpack');
|
|
47
|
+
return {
|
|
48
|
+
getAliases: () => pathMappings.reduce((aliases, library) => (Object.assign(Object.assign({}, aliases), { [library.name]: library.path })), {}),
|
|
49
|
+
getLibraries: (eager) => pathMappings.reduce((libraries, library) => (Object.assign(Object.assign({}, libraries), { [library.name]: { requiredVersion: false, eager } })), {}),
|
|
50
|
+
getReplacementPlugin: () => new webpack.NormalModuleReplacementPlugin(/./, (req) => {
|
|
51
|
+
if (!req.request.startsWith('.')) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const from = req.context;
|
|
55
|
+
const to = (0, path_1.normalize)((0, path_1.join)(req.context, req.request));
|
|
56
|
+
for (const library of pathMappings) {
|
|
57
|
+
const libFolder = (0, path_1.normalize)((0, path_1.dirname)(library.path));
|
|
58
|
+
if (!from.startsWith(libFolder) && to.startsWith(libFolder)) {
|
|
59
|
+
req.request = library.name;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.shareWorkspaceLibraries = shareWorkspaceLibraries;
|
|
66
|
+
/**
|
|
67
|
+
* Build the Module Federation Share Config for a specific package and the
|
|
68
|
+
* specified version of that package.
|
|
69
|
+
* @param pkgName - Name of the package to share
|
|
70
|
+
* @param version - Version of the package to require by other apps in the Module Federation setup
|
|
71
|
+
*/
|
|
72
|
+
function getNpmPackageSharedConfig(pkgName, version) {
|
|
73
|
+
if (!version) {
|
|
74
|
+
logger.warn(`Could not find a version for "${pkgName}" in the root "package.json" ` +
|
|
75
|
+
'when collecting shared packages for the Module Federation setup. ' +
|
|
76
|
+
'The package will not be shared.');
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return { singleton: true, strictVersion: true, requiredVersion: version };
|
|
80
|
+
}
|
|
81
|
+
exports.getNpmPackageSharedConfig = getNpmPackageSharedConfig;
|
|
82
|
+
/**
|
|
83
|
+
* Create a dictionary of packages and their Module Federation Shared Config
|
|
84
|
+
* from an array of package names.
|
|
85
|
+
*
|
|
86
|
+
* Lookup the versions of the packages from the root package.json file in the
|
|
87
|
+
* workspace.
|
|
88
|
+
* @param packages - Array of package names as strings
|
|
89
|
+
*/
|
|
90
|
+
function sharePackages(packages) {
|
|
91
|
+
const pkgJson = (0, package_json_1.readRootPackageJson)();
|
|
92
|
+
const allPackages = [];
|
|
93
|
+
packages.forEach((pkg) => {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
const pkgVersion = (_b = (_a = pkgJson.dependencies) === null || _a === void 0 ? void 0 : _a[pkg]) !== null && _b !== void 0 ? _b : (_c = pkgJson.devDependencies) === null || _c === void 0 ? void 0 : _c[pkg];
|
|
96
|
+
allPackages.push({ name: pkg, version: pkgVersion });
|
|
97
|
+
(0, secondary_entry_points_1.collectPackageSecondaryEntryPoints)(pkg, pkgVersion, allPackages);
|
|
98
|
+
});
|
|
99
|
+
return allPackages.reduce((shared, pkg) => {
|
|
100
|
+
const config = getNpmPackageSharedConfig(pkg.name, pkg.version);
|
|
101
|
+
if (config) {
|
|
102
|
+
shared[pkg.name] = config;
|
|
103
|
+
}
|
|
104
|
+
return shared;
|
|
105
|
+
}, {});
|
|
106
|
+
}
|
|
107
|
+
exports.sharePackages = sharePackages;
|
|
108
|
+
/**
|
|
109
|
+
* Apply a custom function provided by the user that will modify the Shared Config
|
|
110
|
+
* of the dependencies for the Module Federation build.
|
|
111
|
+
*
|
|
112
|
+
* @param sharedConfig - The original Shared Config to be modified
|
|
113
|
+
* @param sharedFn - The custom function to run
|
|
114
|
+
*/
|
|
115
|
+
function applySharedFunction(sharedConfig, sharedFn) {
|
|
116
|
+
if (!sharedFn) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
for (const [libraryName, library] of Object.entries(sharedConfig)) {
|
|
120
|
+
const mappedDependency = sharedFn(libraryName, library);
|
|
121
|
+
if (mappedDependency === false) {
|
|
122
|
+
delete sharedConfig[libraryName];
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
else if (!mappedDependency) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
sharedConfig[libraryName] = mappedDependency;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.applySharedFunction = applySharedFunction;
|
|
132
|
+
/**
|
|
133
|
+
* Add additional dependencies to the shared package that may not have been
|
|
134
|
+
* discovered by the project graph.
|
|
135
|
+
*
|
|
136
|
+
* This can be useful for applications that use a Dependency Injection system
|
|
137
|
+
* that expects certain Singleton values to be present in the shared injection
|
|
138
|
+
* hierarchy.
|
|
139
|
+
*
|
|
140
|
+
* @param sharedConfig - The original Shared Config
|
|
141
|
+
* @param additionalShared - The additional dependencies to add
|
|
142
|
+
* @param projectGraph - The Nx project graph
|
|
143
|
+
*/
|
|
144
|
+
function applyAdditionalShared(sharedConfig, additionalShared, projectGraph) {
|
|
145
|
+
if (!additionalShared) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
for (const shared of additionalShared) {
|
|
149
|
+
if (typeof shared === 'string') {
|
|
150
|
+
addStringDependencyToSharedConfig(sharedConfig, shared, projectGraph);
|
|
151
|
+
}
|
|
152
|
+
else if (Array.isArray(shared)) {
|
|
153
|
+
sharedConfig[shared[0]] = shared[1];
|
|
154
|
+
}
|
|
155
|
+
else if (typeof shared === 'object') {
|
|
156
|
+
sharedConfig[shared.libraryName] = shared.sharedConfig;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.applyAdditionalShared = applyAdditionalShared;
|
|
161
|
+
function addStringDependencyToSharedConfig(sharedConfig, dependency, projectGraph) {
|
|
162
|
+
var _a, _b, _c, _d;
|
|
163
|
+
if (projectGraph.nodes[dependency]) {
|
|
164
|
+
sharedConfig[dependency] = { requiredVersion: false };
|
|
165
|
+
}
|
|
166
|
+
else if ((_a = projectGraph.externalNodes) === null || _a === void 0 ? void 0 : _a[`npm:${dependency}`]) {
|
|
167
|
+
const pkgJson = (0, package_json_1.readRootPackageJson)();
|
|
168
|
+
const config = getNpmPackageSharedConfig(dependency, (_c = (_b = pkgJson.dependencies) === null || _b === void 0 ? void 0 : _b[dependency]) !== null && _c !== void 0 ? _c : (_d = pkgJson.devDependencies) === null || _d === void 0 ? void 0 : _d[dependency]);
|
|
169
|
+
if (!config) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
sharedConfig[dependency] = config;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
throw new Error(`The specified dependency "${dependency}" in the additionalShared configuration does not exist in the project graph. ` +
|
|
176
|
+
`Please check your additionalShared configuration and make sure you are including valid workspace projects or npm packages.`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function getEmptySharedLibrariesConfig() {
|
|
180
|
+
const webpack = require('webpack');
|
|
181
|
+
return {
|
|
182
|
+
getAliases: () => ({}),
|
|
183
|
+
getLibraries: () => ({}),
|
|
184
|
+
getReplacementPlugin: () => new webpack.NormalModuleReplacementPlugin(/./, () => { }),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=share.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share.js","sourceRoot":"","sources":["../../../../../../packages/devkit/src/utils/module-federation/share.ts"],"names":[],"mappings":";;;AAMA,+BAAgD;AAChD,iDAAqD;AACrD,6CAAkD;AAClD,qEAGkC;AAClC,oEAAoE;AACpE,wDAA8D;AAE9D,oCAAwC;AAExC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,IAAA,cAAS,GAAE,CAAC;AAE9C;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,SAA6B,EAC7B,YAAoE;;iCAApE,EAAA,qBAAe,OAAO,CAAC,GAAG,CAAC,gBAAgB,mCAAI,IAAA,gCAAmB,GAAE;IAEpE,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,6BAA6B,EAAE,CAAC;KACxC;IAED,MAAM,mBAAmB,GAAG,IAAA,+BAAkB,EAAC,YAAY,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,MAAM,EAAE;QAC5C,OAAO,6BAA6B,EAAE,CAAC;KACxC;IAED,MAAM,YAAY,GAAqC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE;QAC9D,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC;QAC/D,IAAI,CAAC,OAA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AC;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTsConfig = exports.readTsPathMappings = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
6
|
+
const typescript_1 = require("nx/src/utils/typescript");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
let tsConfig;
|
|
9
|
+
let tsPathMappings;
|
|
10
|
+
function readTsPathMappings(tsConfigPath) {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
if (tsConfigPath === void 0) { tsConfigPath = (_a = process.env.NX_TSCONFIG_PATH) !== null && _a !== void 0 ? _a : (0, typescript_1.getRootTsConfigPath)(); }
|
|
13
|
+
if (tsPathMappings) {
|
|
14
|
+
return tsPathMappings;
|
|
15
|
+
}
|
|
16
|
+
tsConfig !== null && tsConfig !== void 0 ? tsConfig : (tsConfig = readTsConfiguration(tsConfigPath));
|
|
17
|
+
tsPathMappings = {};
|
|
18
|
+
Object.entries((_c = (_b = tsConfig.options) === null || _b === void 0 ? void 0 : _b.paths) !== null && _c !== void 0 ? _c : {}).forEach(([alias, paths]) => {
|
|
19
|
+
tsPathMappings[alias] = paths.map((path) => path.replace(/^\.\//, ''));
|
|
20
|
+
});
|
|
21
|
+
return tsPathMappings;
|
|
22
|
+
}
|
|
23
|
+
exports.readTsPathMappings = readTsPathMappings;
|
|
24
|
+
function readTsConfiguration(tsConfigPath) {
|
|
25
|
+
if (!(0, fs_1.existsSync)(tsConfigPath)) {
|
|
26
|
+
throw new Error(`NX MF: TsConfig Path for workspace libraries does not exist! (${tsConfigPath}).`);
|
|
27
|
+
}
|
|
28
|
+
return readTsConfig(tsConfigPath);
|
|
29
|
+
}
|
|
30
|
+
let tsModule;
|
|
31
|
+
function readTsConfig(tsConfigPath) {
|
|
32
|
+
if (!tsModule) {
|
|
33
|
+
tsModule = require('typescript');
|
|
34
|
+
}
|
|
35
|
+
const readResult = tsModule.readConfigFile(tsConfigPath, tsModule.sys.readFile);
|
|
36
|
+
return tsModule.parseJsonConfigFileContent(readResult.config, tsModule.sys, (0, path_1.dirname)(tsConfigPath));
|
|
37
|
+
}
|
|
38
|
+
exports.readTsConfig = readTsConfig;
|
|
39
|
+
//# sourceMappingURL=typescript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../../../../packages/devkit/src/utils/module-federation/typescript.ts"],"names":[],"mappings":";;;AAAA,2BAAgC;AAEhC,oEAAoE;AACpE,wDAA8D;AAC9D,+BAA+B;AAE/B,IAAI,QAA2B,CAAC;AAChC,IAAI,cAAqD,CAAC;AAE1D,SAAgB,kBAAkB,CAChC,YAA4E;;iCAA5E,EAAA,qBAAuB,OAAO,CAAC,GAAG,CAAC,gBAAgB,mCAAI,IAAA,gCAAmB,GAAE;IAE5E,IAAI,cAAc,EAAE;QAClB,OAAO,cAAc,CAAC;KACvB;IAED,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,mBAAmB,CAAC,YAAY,CAAC,EAAC;IAC/C,cAAc,GAAG,EAAE,CAAC;IACpB,MAAM,CAAC,OAAO,CAAC,MAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,KAAK,mCAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE;QACvE,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC;AAdD,gDAcC;AAED,SAAS,mBAAmB,CAAC,YAAoB;IAC/C,IAAI,CAAC,IAAA,eAAU,EAAC,YAAY,CAAC,EAAE;QAC7B,MAAM,IAAI,KAAK,CACb,iEAAiE,YAAY,IAAI,CAClF,CAAC;KACH;IAED,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC;AACpC,CAAC;AAED,IAAI,QAAqC,CAAC;AAC1C,SAAgB,YAAY,CAAC,YAAoB;IAC/C,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;KAClC;IACD,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CACxC,YAAY,EACZ,QAAQ,CAAC,GAAG,CAAC,QAAQ,CACtB,CAAC;IACF,OAAO,QAAQ,CAAC,0BAA0B,CACxC,UAAU,CAAC,MAAM,EACjB,QAAQ,CAAC,GAAG,EACZ,IAAA,cAAO,EAAC,YAAY,CAAC,CACtB,CAAC;AACJ,CAAC;AAbD,oCAaC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.moveFilesToNewDirectory = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const visit_not_ignored_files_1 = require("../generators/visit-not-ignored-files");
|
|
6
|
+
const nx_1 = require("../../nx");
|
|
7
|
+
const { normalizePath } = (0, nx_1.requireNx)();
|
|
8
|
+
/**
|
|
9
|
+
* Analogous to cp -r oldDir newDir
|
|
10
|
+
*/
|
|
11
|
+
function moveFilesToNewDirectory(tree, oldDir, newDir) {
|
|
12
|
+
oldDir = normalizePath(oldDir);
|
|
13
|
+
newDir = normalizePath(newDir);
|
|
14
|
+
(0, visit_not_ignored_files_1.visitNotIgnoredFiles)(tree, oldDir, (file) => {
|
|
15
|
+
try {
|
|
16
|
+
tree.rename(file, `${newDir}/${(0, path_1.relative)(oldDir, file)}`);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
if (!tree.exists(oldDir)) {
|
|
20
|
+
console.warn(`Path ${oldDir} does not exist`);
|
|
21
|
+
}
|
|
22
|
+
else if (!tree.exists(newDir)) {
|
|
23
|
+
console.warn(`Path ${newDir} does not exist`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.moveFilesToNewDirectory = moveFilesToNewDirectory;
|
|
29
|
+
//# sourceMappingURL=move-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-dir.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/utils/move-dir.ts"],"names":[],"mappings":";;;AACA,+BAAgC;AAChC,mFAA6E;AAC7E,iCAAqC;AAErC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,cAAS,GAAE,CAAC;AACtC;;GAEG;AACH,SAAgB,uBAAuB,CACrC,IAAU,EACV,MAAc,EACd,MAAc;IAEd,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAA,8CAAoB,EAAC,IAAI,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QAC1C,IAAI;YACF,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,MAAM,IAAI,IAAA,eAAQ,EAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;SAC1D;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;gBACxB,OAAO,CAAC,IAAI,CAAC,QAAQ,MAAM,iBAAiB,CAAC,CAAC;aAC/C;iBAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,QAAQ,MAAM,iBAAiB,CAAC,CAAC;aAC/C;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAlBD,0DAkBC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Util function to generate different strings based off the provided name.
|
|
3
|
+
*
|
|
4
|
+
* Examples:
|
|
5
|
+
*
|
|
6
|
+
* ```typescript
|
|
7
|
+
* names("my-name") // {name: 'my-name', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'}
|
|
8
|
+
* names("myName") // {name: 'myName', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'}
|
|
9
|
+
* ```
|
|
10
|
+
* @param name
|
|
11
|
+
*/
|
|
12
|
+
export declare function names(name: string): {
|
|
13
|
+
name: string;
|
|
14
|
+
className: string;
|
|
15
|
+
propertyName: string;
|
|
16
|
+
constantName: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.names = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Util function to generate different strings based off the provided name.
|
|
6
|
+
*
|
|
7
|
+
* Examples:
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* names("my-name") // {name: 'my-name', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'}
|
|
11
|
+
* names("myName") // {name: 'myName', className: 'MyName', propertyName: 'myName', constantName: 'MY_NAME', fileName: 'my-name'}
|
|
12
|
+
* ```
|
|
13
|
+
* @param name
|
|
14
|
+
*/
|
|
15
|
+
function names(name) {
|
|
16
|
+
return {
|
|
17
|
+
name,
|
|
18
|
+
className: toClassName(name),
|
|
19
|
+
propertyName: toPropertyName(name),
|
|
20
|
+
constantName: toConstantName(name),
|
|
21
|
+
fileName: toFileName(name),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.names = names;
|
|
25
|
+
/**
|
|
26
|
+
* Hyphenated to UpperCamelCase
|
|
27
|
+
*/
|
|
28
|
+
function toClassName(str) {
|
|
29
|
+
return toCapitalCase(toPropertyName(str));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hyphenated to lowerCamelCase
|
|
33
|
+
*/
|
|
34
|
+
function toPropertyName(s) {
|
|
35
|
+
return s
|
|
36
|
+
.replace(/([^a-zA-Z0-9])+(.)?/g, (_, __, chr) => chr ? chr.toUpperCase() : '')
|
|
37
|
+
.replace(/[^a-zA-Z\d]/g, '')
|
|
38
|
+
.replace(/^([A-Z])/, (m) => m.toLowerCase());
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Hyphenated to CONSTANT_CASE
|
|
42
|
+
*/
|
|
43
|
+
function toConstantName(s) {
|
|
44
|
+
return toFileName(toPropertyName(s))
|
|
45
|
+
.replace(/([^a-zA-Z0-9])/g, '_')
|
|
46
|
+
.toUpperCase();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Upper camelCase to lowercase, hyphenated
|
|
50
|
+
*/
|
|
51
|
+
function toFileName(s) {
|
|
52
|
+
return s
|
|
53
|
+
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
|
|
54
|
+
.toLowerCase()
|
|
55
|
+
.replace(/(?!^[_])[ _]/g, '-');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Capitalizes the first letter of a string
|
|
59
|
+
*/
|
|
60
|
+
function toCapitalCase(s) {
|
|
61
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/utils/names.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,SAAgB,KAAK,CAAC,IAAY;IAOhC,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC;QAC5B,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC;QAClC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC;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|
+
* Examples:
|
|
6
|
+
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* offsetFromRoot("apps/mydir/myapp/") // returns "../../../"
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param fullPathToDir - directory path
|
|
12
|
+
*/
|
|
13
|
+
export declare function offsetFromRoot(fullPathToDir: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.offsetFromRoot = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
/**
|
|
6
|
+
* Calculates an offset from the root of the workspace, which is useful for
|
|
7
|
+
* constructing relative URLs.
|
|
8
|
+
*
|
|
9
|
+
* Examples:
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* offsetFromRoot("apps/mydir/myapp/") // returns "../../../"
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param fullPathToDir - directory path
|
|
16
|
+
*/
|
|
17
|
+
function offsetFromRoot(fullPathToDir) {
|
|
18
|
+
if (fullPathToDir === '.')
|
|
19
|
+
return './';
|
|
20
|
+
const parts = (0, path_1.normalize)(fullPathToDir).split(path_1.sep);
|
|
21
|
+
let offset = '';
|
|
22
|
+
for (let i = 0; i < parts.length; ++i) {
|
|
23
|
+
if (parts[i].length > 0) {
|
|
24
|
+
offset += '../';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return offset;
|
|
28
|
+
}
|
|
29
|
+
exports.offsetFromRoot = offsetFromRoot;
|
|
30
|
+
//# sourceMappingURL=offset-from-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offset-from-root.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/utils/offset-from-root.ts"],"names":[],"mappings":";;;AAAA,+BAAsC;AAEtC;;;;;;;;;;;GAWG;AACH,SAAgB,cAAc,CAAC,aAAqB;IAClD,IAAI,aAAa,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAEvC,MAAM,KAAK,GAAG,IAAA,gBAAS,EAAC,aAAa,CAAC,CAAC,KAAK,CAAC,UAAG,CAAC,CAAC;IAClD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACrC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC;SACjB;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAXD,wCAWC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Tree } from 'nx/src/generators/tree';
|
|
2
|
+
import type { GeneratorCallback } from 'nx/src/config/misc-interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Add Dependencies and Dev Dependencies to package.json
|
|
5
|
+
*
|
|
6
|
+
* For example:
|
|
7
|
+
* ```typescript
|
|
8
|
+
* addDependenciesToPackageJson(tree, { react: 'latest' }, { jest: 'latest' })
|
|
9
|
+
* ```
|
|
10
|
+
* This will **add** `react` and `jest` to the dependencies and devDependencies sections of package.json respectively.
|
|
11
|
+
*
|
|
12
|
+
* @param tree Tree representing file system to modify
|
|
13
|
+
* @param dependencies Dependencies to be added to the dependencies section of package.json
|
|
14
|
+
* @param devDependencies Dependencies to be added to the devDependencies section of package.json
|
|
15
|
+
* @param packageJsonPath Path to package.json
|
|
16
|
+
* @returns Callback to install dependencies only if necessary, no-op otherwise
|
|
17
|
+
*/
|
|
18
|
+
export declare function addDependenciesToPackageJson(tree: Tree, dependencies: Record<string, string>, devDependencies: Record<string, string>, packageJsonPath?: string): GeneratorCallback;
|
|
19
|
+
/**
|
|
20
|
+
* Remove Dependencies and Dev Dependencies from package.json
|
|
21
|
+
*
|
|
22
|
+
* For example:
|
|
23
|
+
* ```typescript
|
|
24
|
+
* removeDependenciesFromPackageJson(tree, ['react'], ['jest'])
|
|
25
|
+
* ```
|
|
26
|
+
* This will **remove** `react` and `jest` from the dependencies and devDependencies sections of package.json respectively.
|
|
27
|
+
*
|
|
28
|
+
* @param dependencies Dependencies to be removed from the dependencies section of package.json
|
|
29
|
+
* @param devDependencies Dependencies to be removed from the devDependencies section of package.json
|
|
30
|
+
* @returns Callback to uninstall dependencies only if necessary. undefined is returned if changes are not necessary.
|
|
31
|
+
*/
|
|
32
|
+
export declare function removeDependenciesFromPackageJson(tree: Tree, dependencies: string[], devDependencies: string[], packageJsonPath?: string): GeneratorCallback;
|
|
33
|
+
/**
|
|
34
|
+
* @typedef EnsurePackageOptions
|
|
35
|
+
* @type {object}
|
|
36
|
+
* @property {boolean} dev indicate if the package is a dev dependency
|
|
37
|
+
* @property {throwOnMissing} boolean throws an error when the package is missing
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use the other function signature without a Tree
|
|
41
|
+
*
|
|
42
|
+
* Use a package that has not been installed as a dependency.
|
|
43
|
+
*
|
|
44
|
+
* For example:
|
|
45
|
+
* ```typescript
|
|
46
|
+
* ensurePackage(tree, '@nrwl/jest', nxVersion)
|
|
47
|
+
* ```
|
|
48
|
+
* This install the @nrwl/jest@<nxVersion> and return the module
|
|
49
|
+
* When running with --dryRun, the function will throw when dependencies are missing.
|
|
50
|
+
*
|
|
51
|
+
* @param tree the file system tree
|
|
52
|
+
* @param pkg the package to check (e.g. @nrwl/jest)
|
|
53
|
+
* @param requiredVersion the version or semver range to check (e.g. ~1.0.0, >=1.0.0 <2.0.0)
|
|
54
|
+
* @param {EnsurePackageOptions} options?
|
|
55
|
+
*/
|
|
56
|
+
export declare function ensurePackage(tree: Tree, pkg: string, requiredVersion: string, options?: {
|
|
57
|
+
dev?: boolean;
|
|
58
|
+
throwOnMissing?: boolean;
|
|
59
|
+
}): void;
|
|
60
|
+
/**
|
|
61
|
+
* Ensure that dependencies and devDependencies from package.json are installed at the required versions.
|
|
62
|
+
*
|
|
63
|
+
* For example:
|
|
64
|
+
* ```typescript
|
|
65
|
+
* ensurePackage(tree, '@nrwl/jest', nxVersion)
|
|
66
|
+
* ```
|
|
67
|
+
* @param pkg the package to install and require
|
|
68
|
+
* @param version the version to install if the package doesn't exist already
|
|
69
|
+
*/
|
|
70
|
+
export declare function ensurePackage<T extends any = any>(pkg: string, version: string): T;
|
|
71
|
+
/**
|
|
72
|
+
* @description The version of Nx used by the workspace. Returns null if no version is found.
|
|
73
|
+
*/
|
|
74
|
+
export declare const NX_VERSION: string;
|