@trackunit/nx-utils 0.0.11 → 0.0.13

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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.13](https://github.com/Trackunit/manager/compare/nx-utils/0.0.12...nx-utils/0.0.13) (2023-04-27)
6
+
7
+ ## [0.0.12](https://github.com/Trackunit/manager/compare/nx-utils/0.0.11...nx-utils/0.0.12) (2023-04-25)
8
+
5
9
  ## [0.0.11](https://github.com/Trackunit/manager/compare/nx-utils/0.0.10...nx-utils/0.0.11) (2023-04-20)
6
10
 
7
11
  ## [0.0.10](https://github.com/Trackunit/manager/compare/nx-utils/0.0.9...nx-utils/0.0.10) (2023-04-19)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/nx-utils",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "main": "src/index.js",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -1,37 +1,92 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureNxProjects = exports.runNxCommandAsync = exports.runCommandAsync = void 0;
3
+ exports.unique = exports.uniqNxFolder = exports.createNxWorkspaceSetup = exports.runNxCommandAsync = exports.runCommandAsync = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nrwl/devkit");
6
6
  // eslint-disable-next-line no-restricted-imports
7
7
  const testing_1 = require("@nrwl/nx-plugin/testing");
8
8
  const child_process_1 = require("child_process");
9
- const fs = tslib_1.__importStar(require("fs"));
9
+ const fs_1 = require("fs");
10
+ const os_1 = require("os");
10
11
  const path_1 = require("path");
11
- const runNxNewCommand = (nxRoot, args, silent) => {
12
- const localTmpDir = (0, testing_1.tmpProjPath)();
13
- return (0, child_process_1.execSync)(`node ${require.resolve("@nrwl/tao")} new ${nxRoot} --nx-workspace-root=${localTmpDir} --no-interactive --skip-install --collection=@nrwl/workspace --npmScope=proj --preset=ts ${args || ""}`, Object.assign({ cwd: localTmpDir }, (silent && false ? { stdio: ["ignore", "ignore", "ignore"] } : {})));
12
+ /**
13
+ * Returns the path to the project's dist folder based on the package.json name
14
+ *
15
+ * @returns { ProjectDistPath[] } the path to the project's dist folder based on the package.json name
16
+ */
17
+ const getProjectDetails = () => {
18
+ var _a, _b;
19
+ const workspaces = new devkit_1.Workspaces(process.cwd());
20
+ const workspaceConfig = workspaces.readWorkspaceConfiguration();
21
+ const projects = [];
22
+ for (const project of Object.entries(workspaceConfig.projects)) {
23
+ const projectConfig = project[1];
24
+ if ((_a = projectConfig.targets) === null || _a === void 0 ? void 0 : _a.build) {
25
+ const buildTarget = projectConfig.targets.build;
26
+ const outputPath = (_b = buildTarget === null || buildTarget === void 0 ? void 0 : buildTarget.options) === null || _b === void 0 ? void 0 : _b.outputPath;
27
+ if (outputPath) {
28
+ const packageJsonPath = (0, path_1.join)(process.cwd(), projectConfig.root, "package.json");
29
+ if ((0, testing_1.fileExists)(packageJsonPath)) {
30
+ const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
31
+ projects.push({
32
+ package: packageJson.name,
33
+ path: outputPath,
34
+ });
35
+ }
36
+ }
37
+ }
38
+ }
39
+ return projects;
40
+ };
41
+ function copyFolderSync(source, destination) {
42
+ // Check if source exists and is a directory
43
+ if (!(0, fs_1.existsSync)(source) || !(0, fs_1.lstatSync)(source).isDirectory()) {
44
+ return;
45
+ }
46
+ // Create destination directory if it doesn't exist
47
+ if (!(0, fs_1.existsSync)(destination)) {
48
+ (0, fs_1.mkdirSync)(destination);
49
+ }
50
+ // Get all files and directories inside the source directory
51
+ const items = (0, fs_1.readdirSync)(source);
52
+ // Iterate over each item and copy it to the destination directory
53
+ items.forEach(item => {
54
+ const itemPath = (0, path_1.join)(source, item);
55
+ const destinationPath = (0, path_1.join)(destination, item);
56
+ // If the item is a directory, recursively copy it
57
+ if ((0, fs_1.lstatSync)(itemPath).isDirectory()) {
58
+ copyFolderSync(itemPath, destinationPath);
59
+ }
60
+ else {
61
+ // Otherwise, copy the file
62
+ (0, fs_1.copyFileSync)(itemPath, destinationPath);
63
+ }
64
+ });
65
+ }
66
+ const runNxNewCommand = (nxRoot, silent) => {
67
+ const projectName = nxRoot.split(path_1.sep).pop();
68
+ const nxRootParent = (0, path_1.dirname)(nxRoot);
69
+ const cmd = `npx create-nx-workspace@15.9.2 ${projectName} --interactive=false --skip-install --npmScope=e2e --preset=ts --verbose --nxCloud=false --packageManager=yarn`;
70
+ return (0, child_process_1.execSync)(cmd, Object.assign({ cwd: nxRootParent }, (silent && false ? { stdio: ["ignore", "ignore", "ignore"] } : {})));
14
71
  };
15
72
  /**
16
73
  * Run a command asynchronously inside the e2e directory.
17
74
  *
18
75
  * @param command command to run
19
- * @param projectName the name of the project in e2e directory
76
+ * @param nxRootDir the nx workspace root directory
20
77
  * @param opts options
21
78
  */
22
- function runCommandAsync(command, projectName, opts = {
79
+ function runCommandAsync(command, nxRootDir, opts = {
23
80
  silenceError: false,
24
81
  }) {
25
82
  return new Promise((resolve, reject) => {
26
83
  (0, child_process_1.exec)(command, {
27
- cwd: (0, testing_1.tmpProjPath)(projectName),
84
+ cwd: nxRootDir,
28
85
  env: Object.assign(Object.assign({}, process.env), opts.env),
29
86
  }, (err, stdout, stderr) => {
30
87
  if (command.includes("--verbose") || (stderr === null || stderr === void 0 ? void 0 : stderr.length) > 0) {
31
88
  // eslint-disable-next-line no-console
32
- console.log(`Stdout for cmd: ${command}:\n`, stdout);
33
- // eslint-disable-next-line no-console
34
- console.log(`Stderr for cmd: ${command}:\n`, stderr);
89
+ console.log(`---------------------\n`, `Cwd: ${nxRootDir}\n`, `Cmd: ${command}\n`, `Stdout:\n`, stdout, `\nStderr:\n`, stderr, `\n---------------------`);
35
90
  }
36
91
  if (!opts.silenceError && err) {
37
92
  reject(err);
@@ -42,107 +97,153 @@ function runCommandAsync(command, projectName, opts = {
42
97
  }
43
98
  exports.runCommandAsync = runCommandAsync;
44
99
  /**
45
- * Run a nx command asynchronously inside the e2e directory
100
+ * Run a nx command asynchronously inside the nx workspace directory
46
101
  *
47
102
  * @param command command to run
48
- * @param projectName the name of the project in e2e directory
103
+ * @param nxRootDir the nx workspace root directory
49
104
  * @param opts options
50
105
  */
51
- function runNxCommandAsync(command, projectName, opts = {
106
+ function runNxCommandAsync(command, nxRootDir, opts = {
52
107
  silenceError: false,
53
108
  }) {
54
- if ((0, testing_1.fileExists)((0, testing_1.tmpProjPath)((0, path_1.join)(projectName, "package.json")))) {
55
- return runCommandAsync(`yarn nx ${command}`, projectName, opts);
56
- }
57
- else if (process.platform === "win32") {
58
- return runCommandAsync(`./nx.bat ${command}`, projectName, opts);
109
+ if (process.platform === "win32") {
110
+ return runCommandAsync(`./nx.bat ${command}`, nxRootDir, opts);
59
111
  }
60
112
  else {
61
- return runCommandAsync(`./nx ${command}`, projectName, opts);
113
+ return runCommandAsync(`INSTALL_TU_PACKAGES=false nx ${command}`, nxRootDir, opts);
62
114
  }
63
115
  }
64
116
  exports.runNxCommandAsync = runNxCommandAsync;
65
- const newNxProject = (nxRootDir, nxRootPath, dependencies, devDependencies, packageManager) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
66
- runNxNewCommand(nxRootDir, `--package-manager=${packageManager}`, true);
67
- updateWorkspaceLayout(nxRootPath);
68
- patchDistProjects(dependencies, "dependencies");
69
- patchDistProjects(devDependencies, "devDependencies");
70
- patchDistProjects(dependencies, "peerDependencies");
71
- patchDistProjects(devDependencies, "peerDependencies");
72
- patchMainPackageJson(nxRootPath, dependencies, "dependencies", true);
73
- patchMainPackageJson(nxRootPath, devDependencies, "devDependencies", true);
74
- patchMainPackageJson(nxRootPath, dependencies, "dependencies");
75
- patchMainPackageJson(nxRootPath, dependencies, "devDependencies");
76
- patchMainPackageJson(nxRootPath, dependencies, "peerDependencies");
77
- patchMainPackageJson(nxRootPath, devDependencies, "dependencies");
78
- patchMainPackageJson(nxRootPath, devDependencies, "devDependencies");
79
- patchMainPackageJson(nxRootPath, devDependencies, "peerDependencies");
80
- updatePackageJson(nxRootPath);
81
- yield runCommandAsync("yarn", nxRootDir);
117
+ /**
118
+ * Create new Nx workspace
119
+ *
120
+ * @param nxRootDir the nx workspace root directory
121
+ * @param dependencies dependencies to add to the nx repos package.json
122
+ * @param devDependencies devDependencies to add to the nx repos package.json
123
+ */
124
+ const newNxWorkspace = (nxRootDir, dependencies, devDependencies) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
125
+ if (!(0, path_1.isAbsolute)(nxRootDir)) {
126
+ throw new Error("nxRootDir must be absolute path");
127
+ }
128
+ runNxNewCommand(nxRootDir, true);
129
+ updateWorkspaceLayout(nxRootDir);
130
+ // copy dist folder to nxRootDir
131
+ const newDistFolder = (0, path_1.join)(nxRootDir, "dist");
132
+ const managerDistFolder = (0, path_1.join)(process.cwd(), "dist");
133
+ copyFolderSync(managerDistFolder, newDistFolder);
134
+ // Fix paths in package.json for dist folder
135
+ const details = getProjectDetails();
136
+ dependencies.push(...patchDistProjects(nxRootDir, details, "dependencies"));
137
+ devDependencies.push(...patchDistProjects(nxRootDir, details, "devDependencies"));
138
+ // Patch package.json with own dependencies
139
+ patchMainPackageJson(nxRootDir, dependencies, details, "dependencies");
140
+ patchMainPackageJson(nxRootDir, devDependencies, details, "devDependencies");
141
+ updatePackageJson(nxRootDir);
142
+ // Since npm install is not installing local dependencies, we need to run this command
143
+ yield runCommandAsync("yarn install", nxRootDir);
82
144
  });
83
- function getAbsPath(distPath) {
84
- return (0, path_1.join)(process.cwd(), distPath);
85
- }
86
145
  /**
87
- * Ensure nx projects are in package.json in tmp nxRootDir
146
+ * Create a new nx workspace with the given dependencies and devDependencies.
147
+ * The workspace will be created in the given nxRootDir.
148
+ * If the nxRootDir already exists, it will be deleted first then created.
149
+ * The nxRootDir must be an absolute path.
150
+ * The dependencies and devDependencies will be added to the nx workspace package.json.
151
+ * It is expected that the dist folder of your repo has built the needed packages beforehand.
152
+ * The dist folder will be copied to the nx workspace root directory.
153
+ * The nx workspace will be created with the following options:
154
+ * - preset=ts
155
+ * - npmScope=e2e
156
+ * - skip-install
157
+ * - interactive=false
158
+ * - nxCloud=false
159
+ * - packageManager=yarn
160
+ *
161
+ * @param dependencies dependencies to add to the nx repos package.json
162
+ * @param devDependencies devDependencies to add to the nx repos package.json
163
+ * @param nxRootDir the nx workspace root directory
88
164
  */
89
- const ensureNxProjects = (dependencies, devDependencies, nxRootDir, packageManager = "yarn") => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
90
- const nxRootPath = (0, testing_1.tmpProjPath)(nxRootDir);
91
- if (fs.existsSync(nxRootPath)) {
92
- fs.rmSync(nxRootPath, { recursive: true });
165
+ const createNxWorkspaceSetup = (dependencies, devDependencies, nxRootDir) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
166
+ if ((0, fs_1.existsSync)(nxRootDir)) {
167
+ (0, fs_1.rmSync)(nxRootDir, { recursive: true });
93
168
  }
94
- fs.mkdirSync(nxRootPath, { recursive: true });
169
+ (0, fs_1.mkdirSync)(nxRootDir, { recursive: true });
95
170
  // eslint-disable-next-line no-console
96
- console.log("Using NX root dir:", nxRootPath);
97
- yield newNxProject(nxRootDir, nxRootPath, dependencies, devDependencies, packageManager);
171
+ console.log("Using NX workspace:", nxRootDir);
172
+ yield newNxWorkspace(nxRootDir, dependencies, devDependencies);
98
173
  });
99
- exports.ensureNxProjects = ensureNxProjects;
174
+ exports.createNxWorkspaceSetup = createNxWorkspaceSetup;
100
175
  /**
176
+ * Patch the main nx repo package.json with the given dependencies given type
101
177
  *
102
- * @param paths paths
103
- * @param type type
104
- * @param forceAdd force it
178
+ * @param nxRootDir the nx workspace root directory
179
+ * @param packagesToAdd packages to add
180
+ * @param paths paths to the dist folder of the packages
181
+ * @param type type of dependency to add
105
182
  */
106
- const patchMainPackageJson = (testDir, paths, type, forceAdd = false) => {
107
- const absPackageJson = (0, path_1.join)(testDir, "package.json");
183
+ const patchMainPackageJson = (nxRootDir, packagesToAdd, paths, type) => {
184
+ const absPackageJson = (0, path_1.join)(nxRootDir, "package.json");
108
185
  const packageJson = (0, devkit_1.readJsonFile)(absPackageJson);
109
186
  const packageDeps = (packageJson === null || packageJson === void 0 ? void 0 : packageJson[type]) || {};
110
187
  const newPackageJson = Object.assign({}, packageJson);
111
- for (const pkg of paths) {
112
- const absDistPath = `file:/${getAbsPath(pkg.path)}`;
113
- if (packageDeps[pkg.package] && packageDeps[pkg.package] !== absDistPath) {
114
- // eslint-disable-next-line no-console
115
- console.log(`Update ${pkg.package} => ${absDistPath}`);
116
- packageDeps[pkg.package] = absDistPath;
117
- }
118
- else if (forceAdd) {
119
- // eslint-disable-next-line no-console
120
- console.log(`Added ${pkg.package} => ${absDistPath}`);
121
- packageDeps[pkg.package] = absDistPath;
188
+ for (const packageToAdd of packagesToAdd) {
189
+ const path = paths.filter(p => p.package === packageToAdd)[0].path;
190
+ if (path) {
191
+ const absDistPath = `file:${(0, path_1.join)(nxRootDir, path)}`;
192
+ packageDeps[packageToAdd] = absDistPath;
122
193
  }
123
194
  }
124
195
  newPackageJson[type] = packageDeps;
125
196
  (0, devkit_1.writeJsonFile)(absPackageJson, newPackageJson);
126
197
  };
127
- const patchDistProjects = (paths, type) => {
198
+ /**
199
+ * Patch the package.json of the dist folder of the given paths with the given type
200
+ * This is needed because the dist folder of the packages are not published to npm
201
+ * and therefore the package.json of the dist folder needs to be patched with the
202
+ * correct path to the dist folder.
203
+ *
204
+ * @param nxRootDir the nx workspace root directory
205
+ * @param paths paths to the dist folder of the packages
206
+ * @param type type of dependency to add
207
+ * @returns { string[] } packages that were patched
208
+ */
209
+ const patchDistProjects = (nxRootDir, paths, type) => {
210
+ const libsUsed = [];
128
211
  for (const path of paths) {
129
- const absDistPath1 = getAbsPath(path.path);
130
- const absPackageJson = (0, path_1.join)(absDistPath1, "package.json");
131
- const packageJson = (0, devkit_1.readJsonFile)(absPackageJson);
132
- const packageDeps = (packageJson === null || packageJson === void 0 ? void 0 : packageJson[type]) || {};
133
- for (const pkg of paths) {
134
- const absDistPath = `file:/${getAbsPath(pkg.path)}`;
135
- if (packageDeps[pkg.package] && packageDeps[pkg.package] !== absDistPath) {
136
- // eslint-disable-next-line no-console
137
- console.log(` In ${path.package} => Update ${pkg.package} => ${absDistPath}`);
138
- packageDeps[pkg.package] = absDistPath;
212
+ const absDistPath1 = (0, path_1.join)(nxRootDir, path.path);
213
+ if ((0, fs_1.existsSync)(absDistPath1)) {
214
+ const absPackageJson = (0, path_1.join)(absDistPath1, "package.json");
215
+ const packageJson = (0, devkit_1.readJsonFile)(absPackageJson);
216
+ const packageDeps = (packageJson === null || packageJson === void 0 ? void 0 : packageJson[type]) || {};
217
+ for (const pkgPackageName of Object.keys(packageDeps)) {
218
+ const foundInDist = paths.filter(p => p.package === pkgPackageName);
219
+ if (foundInDist.length > 0) {
220
+ const pathToFolders = (0, path_1.join)(nxRootDir, foundInDist[0].path);
221
+ if ((0, fs_1.existsSync)(pathToFolders)) {
222
+ const absDistPath = `file:${pathToFolders}`;
223
+ if (packageDeps[pkgPackageName] !== absDistPath) {
224
+ packageDeps[pkgPackageName] = absDistPath;
225
+ libsUsed.push(pkgPackageName);
226
+ }
227
+ }
228
+ else {
229
+ throw new Error(`${absDistPath1} does not exist, maybe you need to add a implicit dependency to the test projects project.json`);
230
+ }
231
+ }
139
232
  }
233
+ const newPackageJson = Object.assign({}, packageJson);
234
+ newPackageJson[type] = packageDeps;
235
+ (0, devkit_1.writeJsonFile)(absPackageJson, newPackageJson);
140
236
  }
141
- const newPackageJson = Object.assign({}, packageJson);
142
- newPackageJson[type] = packageDeps;
143
- (0, devkit_1.writeJsonFile)(absPackageJson, newPackageJson);
144
237
  }
238
+ return libsUsed;
145
239
  };
240
+ /**
241
+ * Update the nx.json workspaceLayout to the new format
242
+ * This is needed because the nx.json workspaceLayout is not updated when creating a new nx workspace
243
+ * with the nx cli.
244
+ *
245
+ * @param nxRootPath the nx workspace root directory
246
+ */
146
247
  const updateWorkspaceLayout = (nxRootPath) => {
147
248
  const nxJsonPath = (0, path_1.join)(nxRootPath, "nx.json");
148
249
  const nxJson = (0, devkit_1.readJsonFile)(nxJsonPath);
@@ -152,6 +253,14 @@ const updateWorkspaceLayout = (nxRootPath) => {
152
253
  };
153
254
  (0, devkit_1.writeJsonFile)(nxJsonPath, nxJson);
154
255
  };
256
+ /**
257
+ * Update the package.json engines and volta to the new format
258
+ * This is needed because the package.json engines and volta is not updated when creating a new nx workspace
259
+ * with the nx cli.
260
+ * The engines and volta are copied from the package.json of the nx cli.
261
+ *
262
+ * @param nxRootPath the nx workspace root directory
263
+ */
155
264
  const updatePackageJson = (nxRootPath) => {
156
265
  const absPackageJson = (0, path_1.join)(nxRootPath, "package.json");
157
266
  const newNxPackageJson = (0, devkit_1.readJsonFile)(absPackageJson);
@@ -161,4 +270,25 @@ const updatePackageJson = (nxRootPath) => {
161
270
  newNxPackageJson.volta = managerPackageJson.volta;
162
271
  (0, devkit_1.writeJsonFile)(absPackageJson, newNxPackageJson);
163
272
  };
273
+ /**
274
+ * Creates a unique path to a folder in the tmp directory of the OS or in the tmp directory of this repo.
275
+ *
276
+ * @returns { string } unique path
277
+ */
278
+ const uniqNxFolder = (name, parentFolder) => {
279
+ if (parentFolder === "THIS_REPO") {
280
+ return (0, path_1.join)((0, testing_1.tmpProjPath)(), (0, testing_1.uniq)(name));
281
+ }
282
+ return (0, path_1.join)((0, os_1.tmpdir)(), "e2e", (0, testing_1.uniq)(name));
283
+ };
284
+ exports.uniqNxFolder = uniqNxFolder;
285
+ /**
286
+ * Creates a unique name for a project.
287
+ *
288
+ * @returns { string } unique name
289
+ */
290
+ const unique = (name) => {
291
+ return (0, testing_1.uniq)(name);
292
+ };
293
+ exports.unique = unique;
164
294
  //# sourceMappingURL=projectUtils.js.map
@@ -1 +1 @@
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EAAE,SAAS,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,UAAU,CAAC,CAAC;IACxC,MAAM,CAAC,eAAe,GAAG;QACvB,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,MAAM;KAChB,CAAC;IACF,IAAA,sBAAa,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;AACF,MAAM,iBAAiB,GAAG,CAAC,UAAkB,EAAE,EAAE;IAC/C,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACxD,MAAM,gBAAgB,GAAG,IAAA,qBAAY,EAAC,cAAc,CAAC,CAAC;IACtD,MAAM,sBAAsB,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACvF,MAAM,kBAAkB,GAAG,IAAA,qBAAY,EAAC,sBAAsB,CAAC,CAAC;IAChE,gBAAgB,CAAC,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC;IACtD,gBAAgB,CAAC,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC;IAClD,IAAA,sBAAa,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAClD,CAAC,CAAC","sourcesContent":["import { readJsonFile, writeJsonFile } from \"@nrwl/devkit\";\n// eslint-disable-next-line no-restricted-imports\nimport { fileExists, tmpProjPath } from \"@nrwl/nx-plugin/testing\";\nimport { exec, execSync } from \"child_process\";\nimport * as fs from \"fs\";\nimport { join } from \"path\";\nexport interface ProjectDistPath {\n package: string;\n path: string;\n}\n\nconst runNxNewCommand = (nxRoot: string, args?: string, silent?: boolean) => {\n const localTmpDir = tmpProjPath();\n return execSync(\n `node ${require.resolve(\n \"@nrwl/tao\"\n )} new ${nxRoot} --nx-workspace-root=${localTmpDir} --no-interactive --skip-install --collection=@nrwl/workspace --npmScope=proj --preset=ts ${\n args || \"\"\n }`,\n {\n cwd: localTmpDir,\n ...(silent && false ? { stdio: [\"ignore\", \"ignore\", \"ignore\"] } : {}),\n }\n );\n};\n\n/**\n * Run a command asynchronously inside the e2e directory.\n *\n * @param command command to run\n * @param projectName the name of the project in e2e directory\n * @param opts options\n */\nexport function runCommandAsync(\n command: string,\n projectName: string,\n opts: { silenceError?: boolean; env?: NodeJS.ProcessEnv } = {\n silenceError: false,\n }\n): Promise<{ stdout: string; stderr: string }> {\n return new Promise((resolve, reject) => {\n exec(\n command,\n {\n cwd: tmpProjPath(projectName),\n env: { ...process.env, ...opts.env },\n },\n (err, stdout, stderr) => {\n if (command.includes(\"--verbose\") || stderr?.length > 0) {\n // eslint-disable-next-line no-console\n console.log(`Stdout for cmd: ${command}:\\n`, stdout);\n // eslint-disable-next-line no-console\n console.log(`Stderr for cmd: ${command}:\\n`, stderr);\n }\n if (!opts.silenceError && err) {\n reject(err);\n }\n resolve({ stdout, stderr });\n }\n );\n });\n}\n\n/**\n * Run a nx command asynchronously inside the e2e directory\n *\n * @param command command to run\n * @param projectName the name of the project in e2e directory\n * @param opts options\n */\nexport function runNxCommandAsync(\n command: string,\n projectName: string,\n opts: { silenceError?: boolean; env?: NodeJS.ProcessEnv } = {\n silenceError: false,\n }\n): Promise<{ stdout: string; stderr: string }> {\n if (fileExists(tmpProjPath(join(projectName, \"package.json\")))) {\n return runCommandAsync(`yarn nx ${command}`, projectName, opts);\n } else if (process.platform === \"win32\") {\n return runCommandAsync(`./nx.bat ${command}`, projectName, opts);\n } else {\n return runCommandAsync(`./nx ${command}`, projectName, opts);\n }\n}\n\nconst newNxProject = async (\n nxRootDir: string,\n nxRootPath: string,\n dependencies: ProjectDistPath[],\n devDependencies: ProjectDistPath[],\n packageManager: string\n) => {\n runNxNewCommand(nxRootDir, `--package-manager=${packageManager}`, true);\n updateWorkspaceLayout(nxRootPath);\n patchDistProjects(dependencies, \"dependencies\");\n patchDistProjects(devDependencies, \"devDependencies\");\n\n patchDistProjects(dependencies, \"peerDependencies\");\n patchDistProjects(devDependencies, \"peerDependencies\");\n patchMainPackageJson(nxRootPath, dependencies, \"dependencies\", true);\n\n patchMainPackageJson(nxRootPath, devDependencies, \"devDependencies\", true);\n\n patchMainPackageJson(nxRootPath, dependencies, \"dependencies\");\n patchMainPackageJson(nxRootPath, dependencies, \"devDependencies\");\n patchMainPackageJson(nxRootPath, dependencies, \"peerDependencies\");\n\n patchMainPackageJson(nxRootPath, devDependencies, \"dependencies\");\n patchMainPackageJson(nxRootPath, devDependencies, \"devDependencies\");\n patchMainPackageJson(nxRootPath, devDependencies, \"peerDependencies\");\n\n updatePackageJson(nxRootPath);\n\n await runCommandAsync(\"yarn\", nxRootDir);\n};\n\nfunction getAbsPath(distPath: string) {\n return join(process.cwd(), distPath);\n}\n\n/**\n * Ensure nx projects are in package.json in tmp nxRootDir\n */\nexport const ensureNxProjects = async (\n dependencies: ProjectDistPath[],\n devDependencies: ProjectDistPath[],\n nxRootDir: string,\n packageManager = \"yarn\"\n) => {\n const nxRootPath = tmpProjPath(nxRootDir);\n if (fs.existsSync(nxRootPath)) {\n fs.rmSync(nxRootPath, { recursive: true });\n }\n fs.mkdirSync(nxRootPath, { recursive: true });\n // eslint-disable-next-line no-console\n console.log(\"Using NX root dir:\", nxRootPath);\n await newNxProject(nxRootDir, nxRootPath, dependencies, devDependencies, packageManager);\n};\n\n/**\n *\n * @param paths paths\n * @param type type\n * @param forceAdd force it\n */\nconst patchMainPackageJson = (\n testDir: string,\n paths: ProjectDistPath[],\n type: \"dependencies\" | \"devDependencies\" | \"peerDependencies\",\n forceAdd = false\n) => {\n const absPackageJson = join(testDir, \"package.json\");\n const packageJson = readJsonFile(absPackageJson);\n const packageDeps = packageJson?.[type] || {};\n\n const newPackageJson = { ...packageJson };\n\n for (const pkg of paths) {\n const absDistPath = `file:/${getAbsPath(pkg.path)}`;\n if (packageDeps[pkg.package] && packageDeps[pkg.package] !== absDistPath) {\n // eslint-disable-next-line no-console\n console.log(`Update ${pkg.package} => ${absDistPath}`);\n packageDeps[pkg.package] = absDistPath;\n } else if (forceAdd) {\n // eslint-disable-next-line no-console\n console.log(`Added ${pkg.package} => ${absDistPath}`);\n packageDeps[pkg.package] = absDistPath;\n }\n }\n newPackageJson[type] = packageDeps;\n writeJsonFile(absPackageJson, newPackageJson);\n};\n\nconst patchDistProjects = (paths: ProjectDistPath[], type: \"dependencies\" | \"devDependencies\" | \"peerDependencies\") => {\n for (const path of paths) {\n const absDistPath1 = getAbsPath(path.path);\n const absPackageJson = join(absDistPath1, \"package.json\");\n const packageJson = readJsonFile(absPackageJson);\n const packageDeps = packageJson?.[type] || {};\n\n for (const pkg of paths) {\n const absDistPath = `file:/${getAbsPath(pkg.path)}`;\n if (packageDeps[pkg.package] && packageDeps[pkg.package] !== absDistPath) {\n // eslint-disable-next-line no-console\n console.log(` In ${path.package} => Update ${pkg.package} => ${absDistPath}`);\n packageDeps[pkg.package] = absDistPath;\n }\n }\n const newPackageJson = { ...packageJson };\n newPackageJson[type] = packageDeps;\n writeJsonFile(absPackageJson, newPackageJson);\n }\n};\nconst updateWorkspaceLayout = (nxRootPath: string) => {\n const nxJsonPath = join(nxRootPath, \"nx.json\");\n const nxJson = readJsonFile(nxJsonPath);\n nxJson.workspaceLayout = {\n appsDir: \"apps\",\n libsDir: \"libs\",\n };\n writeJsonFile(nxJsonPath, nxJson);\n};\nconst updatePackageJson = (nxRootPath: string) => {\n const absPackageJson = join(nxRootPath, \"package.json\");\n const newNxPackageJson = readJsonFile(absPackageJson);\n const managerPackageJsonPath = join(__dirname, \"..\", \"..\", \"..\", \"..\", \"package.json\");\n const managerPackageJson = readJsonFile(managerPackageJsonPath);\n newNxPackageJson.engines = managerPackageJson.engines;\n newNxPackageJson.volta = managerPackageJson.volta;\n writeJsonFile(absPackageJson, newNxPackageJson);\n};\n"]}
1
+ {"version":3,"file":"projectUtils.js","sourceRoot":"","sources":["../../../../../libs/nx/utils/src/projectUtils.ts"],"names":[],"mappings":";;;;AAAA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Y,EAAE,YAAoC,EAAE,EAAE;IACjF,IAAI,YAAY,KAAK,WAAW,EAAE;QAChC,OAAO,IAAA,WAAI,EAAC,IAAA,qBAAW,GAAE,EAAE,IAAA,cAAI,EAAC,IAAI,CAAC,CAAC,CAAC;KACxC;IACD,OAAO,IAAA,WAAI,EAAC,IAAA,WAAM,GAAE,EAAE,KAAK,EAAE,IAAA,cAAI,EAAC,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB;AAEF;;;;GAIG;AACI,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE;IACrC,OAAO,IAAA,cAAI,EAAC,IAAI,CAAC,CAAC;AACpB,CAAC,CAAC;AAFW,QAAA,MAAM,UAEjB","sourcesContent":["import { readJsonFile, Workspaces, writeJsonFile } from \"@nrwl/devkit\";\n// eslint-disable-next-line no-restricted-imports\nimport { fileExists, tmpProjPath, uniq } from \"@nrwl/nx-plugin/testing\";\nimport { exec, execSync } from \"child_process\";\nimport { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, rmSync } from \"fs\";\nimport { PackageJson } from \"nx/src/utils/package-json\";\nimport { tmpdir } from \"os\";\nimport { dirname, isAbsolute, join, sep } from \"path\";\n\n/**\n * The path to the project's dist folder based on the package.json name\n */\nexport interface ProjectDistPath {\n package: string;\n path: string;\n}\n\n/**\n * Returns the path to the project's dist folder based on the package.json name\n *\n * @returns { ProjectDistPath[] } the path to the project's dist folder based on the package.json name\n */\nconst getProjectDetails = (): ProjectDistPath[] => {\n const workspaces = new Workspaces(process.cwd());\n const workspaceConfig = workspaces.readWorkspaceConfiguration();\n\n const projects: ProjectDistPath[] = [];\n for (const project of Object.entries(workspaceConfig.projects)) {\n const projectConfig = project[1];\n if (projectConfig.targets?.build) {\n const buildTarget = projectConfig.targets.build;\n const outputPath = buildTarget?.options?.outputPath;\n\n if (outputPath) {\n const packageJsonPath = join(process.cwd(), projectConfig.root, \"package.json\");\n if (fileExists(packageJsonPath)) {\n const packageJson = readJsonFile(packageJsonPath);\n projects.push({\n package: packageJson.name,\n path: outputPath,\n });\n }\n }\n }\n }\n return projects;\n};\n\nfunction copyFolderSync(source: string, destination: string) {\n // Check if source exists and is a directory\n if (!existsSync(source) || !lstatSync(source).isDirectory()) {\n return;\n }\n\n // Create destination directory if it doesn't exist\n if (!existsSync(destination)) {\n mkdirSync(destination);\n }\n\n // Get all files and directories inside the source directory\n const items = readdirSync(source);\n\n // Iterate over each item and copy it to the destination directory\n items.forEach(item => {\n const itemPath = join(source, item);\n const destinationPath = join(destination, item);\n\n // If the item is a directory, recursively copy it\n if (lstatSync(itemPath).isDirectory()) {\n copyFolderSync(itemPath, destinationPath);\n } else {\n // Otherwise, copy the file\n copyFileSync(itemPath, destinationPath);\n }\n });\n}\n\nconst runNxNewCommand = (nxRoot: string, silent?: boolean) => {\n const projectName = nxRoot.split(sep).pop();\n const nxRootParent = dirname(nxRoot);\n\n const cmd = `npx create-nx-workspace@15.9.2 ${projectName} --interactive=false --skip-install --npmScope=e2e --preset=ts --verbose --nxCloud=false --packageManager=yarn`;\n return execSync(cmd, {\n cwd: nxRootParent,\n ...(silent && false ? { stdio: [\"ignore\", \"ignore\", \"ignore\"] } : {}),\n });\n};\n\n/**\n * Run a command asynchronously inside the e2e directory.\n *\n * @param command command to run\n * @param nxRootDir the nx workspace root directory\n * @param opts options\n */\nexport function runCommandAsync(\n command: string,\n nxRootDir: string,\n opts: { silenceError?: boolean; env?: NodeJS.ProcessEnv } = {\n silenceError: false,\n }\n): Promise<{ stdout: string; stderr: string }> {\n return new Promise((resolve, reject) => {\n exec(\n command,\n {\n cwd: nxRootDir,\n env: { ...process.env, ...opts.env },\n },\n (err, stdout, stderr) => {\n if (command.includes(\"--verbose\") || stderr?.length > 0) {\n // eslint-disable-next-line no-console\n console.log(\n `---------------------\\n`,\n `Cwd: ${nxRootDir}\\n`,\n `Cmd: ${command}\\n`,\n `Stdout:\\n`,\n stdout,\n `\\nStderr:\\n`,\n stderr,\n `\\n---------------------`\n );\n }\n if (!opts.silenceError && err) {\n reject(err);\n }\n resolve({ stdout, stderr });\n }\n );\n });\n}\n\n/**\n * Run a nx command asynchronously inside the nx workspace directory\n *\n * @param command command to run\n * @param nxRootDir the nx workspace root directory\n * @param opts options\n */\nexport function runNxCommandAsync(\n command: string,\n nxRootDir: string,\n opts: { silenceError?: boolean; env?: NodeJS.ProcessEnv } = {\n silenceError: false,\n }\n): Promise<{ stdout: string; stderr: string }> {\n if (process.platform === \"win32\") {\n return runCommandAsync(`./nx.bat ${command}`, nxRootDir, opts);\n } else {\n return runCommandAsync(`INSTALL_TU_PACKAGES=false nx ${command}`, nxRootDir, opts);\n }\n}\n\n/**\n * Create new Nx workspace\n *\n * @param nxRootDir the nx workspace root directory\n * @param dependencies dependencies to add to the nx repos package.json\n * @param devDependencies devDependencies to add to the nx repos package.json\n */\nconst newNxWorkspace = async (nxRootDir: string, dependencies: string[], devDependencies: string[]) => {\n if (!isAbsolute(nxRootDir)) {\n throw new Error(\"nxRootDir must be absolute path\");\n }\n runNxNewCommand(nxRootDir, true);\n updateWorkspaceLayout(nxRootDir);\n\n // copy dist folder to nxRootDir\n const newDistFolder = join(nxRootDir, \"dist\");\n const managerDistFolder = join(process.cwd(), \"dist\");\n copyFolderSync(managerDistFolder, newDistFolder);\n\n // Fix paths in package.json for dist folder\n const details = getProjectDetails();\n dependencies.push(...patchDistProjects(nxRootDir, details, \"dependencies\"));\n devDependencies.push(...patchDistProjects(nxRootDir, details, \"devDependencies\"));\n\n // Patch package.json with own dependencies\n patchMainPackageJson(nxRootDir, dependencies, details, \"dependencies\");\n patchMainPackageJson(nxRootDir, devDependencies, details, \"devDependencies\");\n\n updatePackageJson(nxRootDir);\n\n // Since npm install is not installing local dependencies, we need to run this command\n await runCommandAsync(\"yarn install\", nxRootDir);\n};\n\n/**\n * Create a new nx workspace with the given dependencies and devDependencies.\n * The workspace will be created in the given nxRootDir.\n * If the nxRootDir already exists, it will be deleted first then created.\n * The nxRootDir must be an absolute path.\n * The dependencies and devDependencies will be added to the nx workspace package.json.\n * It is expected that the dist folder of your repo has built the needed packages beforehand.\n * The dist folder will be copied to the nx workspace root directory.\n * The nx workspace will be created with the following options:\n * - preset=ts\n * - npmScope=e2e\n * - skip-install\n * - interactive=false\n * - nxCloud=false\n * - packageManager=yarn\n *\n * @param dependencies dependencies to add to the nx repos package.json\n * @param devDependencies devDependencies to add to the nx repos package.json\n * @param nxRootDir the nx workspace root directory\n */\nexport const createNxWorkspaceSetup = async (dependencies: string[], devDependencies: string[], nxRootDir: string) => {\n if (existsSync(nxRootDir)) {\n rmSync(nxRootDir, { recursive: true });\n }\n mkdirSync(nxRootDir, { recursive: true });\n // eslint-disable-next-line no-console\n console.log(\"Using NX workspace:\", nxRootDir);\n await newNxWorkspace(nxRootDir, dependencies, devDependencies);\n};\n\n/**\n * Patch the main nx repo package.json with the given dependencies given type\n *\n * @param nxRootDir the nx workspace root directory\n * @param packagesToAdd packages to add\n * @param paths paths to the dist folder of the packages\n * @param type type of dependency to add\n */\nconst patchMainPackageJson = (\n nxRootDir: string,\n packagesToAdd: string[],\n paths: ProjectDistPath[],\n type: \"dependencies\" | \"devDependencies\"\n) => {\n const absPackageJson = join(nxRootDir, \"package.json\");\n const packageJson = readJsonFile(absPackageJson);\n const packageDeps = packageJson?.[type] || {};\n\n const newPackageJson = { ...packageJson };\n\n for (const packageToAdd of packagesToAdd) {\n const path = paths.filter(p => p.package === packageToAdd)[0].path;\n if (path) {\n const absDistPath = `file:${join(nxRootDir, path)}`;\n packageDeps[packageToAdd] = absDistPath;\n }\n }\n newPackageJson[type] = packageDeps;\n writeJsonFile(absPackageJson, newPackageJson);\n};\n\n/**\n * Patch the package.json of the dist folder of the given paths with the given type\n * This is needed because the dist folder of the packages are not published to npm\n * and therefore the package.json of the dist folder needs to be patched with the\n * correct path to the dist folder.\n *\n * @param nxRootDir the nx workspace root directory\n * @param paths paths to the dist folder of the packages\n * @param type type of dependency to add\n * @returns { string[] } packages that were patched\n */\nconst patchDistProjects = (nxRootDir: string, paths: ProjectDistPath[], type: \"dependencies\" | \"devDependencies\") => {\n const libsUsed: string[] = [];\n for (const path of paths) {\n const absDistPath1 = join(nxRootDir, path.path);\n if (existsSync(absDistPath1)) {\n const absPackageJson = join(absDistPath1, \"package.json\");\n const packageJson = readJsonFile(absPackageJson) as PackageJson;\n const packageDeps = packageJson?.[type] || {};\n\n for (const pkgPackageName of Object.keys(packageDeps)) {\n const foundInDist = paths.filter(p => p.package === pkgPackageName);\n if (foundInDist.length > 0) {\n const pathToFolders = join(nxRootDir, foundInDist[0].path);\n if (existsSync(pathToFolders)) {\n const absDistPath = `file:${pathToFolders}`;\n if (packageDeps[pkgPackageName] !== absDistPath) {\n packageDeps[pkgPackageName] = absDistPath;\n libsUsed.push(pkgPackageName);\n }\n } else {\n throw new Error(\n `${absDistPath1} does not exist, maybe you need to add a implicit dependency to the test projects project.json`\n );\n }\n }\n }\n const newPackageJson = { ...packageJson };\n newPackageJson[type] = packageDeps;\n writeJsonFile(absPackageJson, newPackageJson);\n }\n }\n return libsUsed;\n};\n\n/**\n * Update the nx.json workspaceLayout to the new format\n * This is needed because the nx.json workspaceLayout is not updated when creating a new nx workspace\n * with the nx cli.\n *\n * @param nxRootPath the nx workspace root directory\n */\nconst updateWorkspaceLayout = (nxRootPath: string) => {\n const nxJsonPath = join(nxRootPath, \"nx.json\");\n const nxJson = readJsonFile(nxJsonPath);\n nxJson.workspaceLayout = {\n appsDir: \"apps\",\n libsDir: \"libs\",\n };\n writeJsonFile(nxJsonPath, nxJson);\n};\n\n/**\n * Update the package.json engines and volta to the new format\n * This is needed because the package.json engines and volta is not updated when creating a new nx workspace\n * with the nx cli.\n * The engines and volta are copied from the package.json of the nx cli.\n *\n * @param nxRootPath the nx workspace root directory\n */\nconst updatePackageJson = (nxRootPath: string) => {\n const absPackageJson = join(nxRootPath, \"package.json\");\n const newNxPackageJson = readJsonFile(absPackageJson);\n const managerPackageJsonPath = join(__dirname, \"..\", \"..\", \"..\", \"..\", \"package.json\");\n const managerPackageJson = readJsonFile(managerPackageJsonPath);\n newNxPackageJson.engines = managerPackageJson.engines;\n newNxPackageJson.volta = managerPackageJson.volta;\n writeJsonFile(absPackageJson, newNxPackageJson);\n};\n\n/**\n * Creates a unique path to a folder in the tmp directory of the OS or in the tmp directory of this repo.\n *\n * @returns { string } unique path\n */\nexport const uniqNxFolder = (name: string, parentFolder: \"OS_TMP\" | \"THIS_REPO\") => {\n if (parentFolder === \"THIS_REPO\") {\n return join(tmpProjPath(), uniq(name));\n }\n return join(tmpdir(), \"e2e\", uniq(name));\n};\n\n/**\n * Creates a unique name for a project.\n *\n * @returns { string } unique name\n */\nexport const unique = (name: string) => {\n return uniq(name);\n};\n"]}