@trackunit/nx-utils 0.0.75-alpha-2936c016d71.0 → 0.0.77

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,8 +2,21 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
- ## [0.0.75-alpha-2936c016d71.0](https://github.com/Trackunit/manager/compare/nx-utils/0.0.74...nx-utils/0.0.75-alpha-2936c016d71.0) (2024-07-26)
5
+ ## [0.0.77](https://github.com/Trackunit/manager/compare/nx-utils/0.0.76...nx-utils/0.0.77) (2024-08-23)
6
6
 
7
+ ### Dependency Updates
8
+
9
+ * `test-setup` updated to version `0.0.76`
10
+ ## [0.0.76](https://github.com/Trackunit/manager/compare/nx-utils/0.0.75...nx-utils/0.0.76) (2024-08-12)
11
+
12
+ ### Dependency Updates
13
+
14
+ * `test-setup` updated to version `0.0.75`
15
+ ## [0.0.75](https://github.com/Trackunit/manager/compare/nx-utils/0.0.74...nx-utils/0.0.75) (2024-08-12)
16
+
17
+ ### Dependency Updates
18
+
19
+ * `test-setup` updated to version `0.0.74`
7
20
  ## [0.0.74](https://github.com/Trackunit/manager/compare/nx-utils/0.0.73...nx-utils/0.0.74) (2024-07-09)
8
21
 
9
22
  ### Dependency Updates
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@trackunit/nx-utils",
3
- "version": "0.0.75-alpha-2936c016d71.0",
4
- "main": "./src/index.js",
3
+ "version": "0.0.77",
4
+ "main": "src/index.js",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
7
7
  "engines": {
8
8
  "node": ">=20.x"
9
9
  },
10
10
  "dependencies": {
11
- "@nx/plugin": "18.3.3",
11
+ "@nx/plugin": "19.5.6",
12
12
  "tslib": "^2.6.2"
13
13
  },
14
- "type": "commonjs"
15
- }
14
+ "type": "commonjs",
15
+ "types": "./src/index.d.ts"
16
+ }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRootFolder = exports.unique = exports.uniqNxFolder = exports.runNxCommandAsync = exports.runCommandAsync = void 0;
3
+ exports.unique = exports.uniqNxFolder = void 0;
4
+ exports.runCommandAsync = runCommandAsync;
5
+ exports.runNxCommandAsync = runNxCommandAsync;
6
+ exports.createRootFolder = createRootFolder;
4
7
  // eslint-disable-next-line no-restricted-imports
5
8
  const testing_1 = require("@nx/plugin/testing");
6
9
  const child_process_1 = require("child_process");
@@ -28,7 +31,7 @@ function runCommandAsync(command, rootDir, opts = {
28
31
  }
29
32
  const childProcess = (0, child_process_1.spawn)(cmd, args, {
30
33
  cwd: rootDir,
31
- env: Object.assign(Object.assign({}, process.env), opts.env),
34
+ env: { ...process.env, ...opts.env },
32
35
  shell: true,
33
36
  });
34
37
  let stdout = "";
@@ -69,7 +72,6 @@ function runCommandAsync(command, rootDir, opts = {
69
72
  }
70
73
  });
71
74
  }
72
- exports.runCommandAsync = runCommandAsync;
73
75
  /**
74
76
  * Run a nx command asynchronously inside the given nx workspace directory
75
77
  *
@@ -87,7 +89,6 @@ function runNxCommandAsync(command, nxRootDir, opts = {
87
89
  const cmd = `${process.platform === "win32" ? "./nx.bat" : "nx"} ${command}`;
88
90
  return runCommandAsync(cmd, nxRootDir, opts);
89
91
  }
90
- exports.runNxCommandAsync = runNxCommandAsync;
91
92
  /**
92
93
  * Creates a unique path to a folder in the tmp directory of the OS or in the tmp directory of this repo.
93
94
  *
@@ -120,5 +121,4 @@ function createRootFolder(e2eRootDir) {
120
121
  // eslint-disable-next-line no-console
121
122
  console.log("Using E2E root folder:", e2eRootDir);
122
123
  }
123
- exports.createRootFolder = createRootFolder;
124
124
  //# sourceMappingURL=projectUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"projectUtils.js","sourceRoot":"","sources":["../../../../../libs/nx/utils/src/projectUtils.ts"],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sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;AACpD,CAAC;AAPD,4CAOC","sourcesContent":["// eslint-disable-next-line no-restricted-imports\nimport { tmpProjPath, uniq } from \"@nx/plugin/testing\";\nimport { ChildProcessWithoutNullStreams, spawn } from \"child_process\";\nimport { existsSync, mkdirSync, rmSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\n/**\n * Run a command asynchronously with the option of outputting stdout and stderr.\n *\n * @param command command to run\n * @param rootDir command execution directory\n * @param opts options\n * @param opts.silenceError silence errors logged to console\n * @param opts.waitForProcessToTerminate Wait for the process to terminate before resolving.\n * @param opts.env environment variables to pass to the command\n */\nexport function runCommandAsync(\n command: string,\n rootDir: string,\n opts: { silenceError?: boolean; waitForProcessToTerminate?: boolean; env?: NodeJS.ProcessEnv } = {\n silenceError: false,\n waitForProcessToTerminate: true,\n }\n): Promise<{ process: ChildProcessWithoutNullStreams; stdout: string; stderr: string }> {\n return new Promise((resolve, reject) => {\n const [cmd, ...args] = [...command.split(\" \")];\n if (!cmd) {\n throw new Error(\"Command cannot be empty\");\n }\n const childProcess = spawn(cmd, args, {\n cwd: rootDir,\n env: { ...process.env, ...opts.env },\n shell: true,\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n childProcess.stdout.on(\"data\", data => {\n stdout += data.toString();\n if (!opts.waitForProcessToTerminate && command.includes(\"--verbose\")) {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n }\n });\n\n childProcess.stderr.on(\"data\", data => {\n stderr += data.toString();\n if (!opts.waitForProcessToTerminate && command.includes(\"--verbose\")) {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n }\n });\n\n childProcess.on(\"close\", code => {\n if (code !== 0 && !opts.silenceError) {\n reject(new Error(stderr));\n } else if (opts.waitForProcessToTerminate) {\n if (command.includes(\"--verbose\") || stderr.length > 0) {\n // eslint-disable-next-line no-console\n console.log(\n `---------------------\\n`,\n `Cwd: ${rootDir}\\n`,\n `Cmd: ${command}\\n`,\n `Stdout:\\n`,\n stdout,\n `\\nStderr:\\n`,\n stderr,\n `\\n---------------------`\n );\n }\n resolve({ process: childProcess, stdout, stderr });\n }\n });\n\n childProcess.on(\"error\", err => {\n if (!opts.silenceError) {\n reject(err);\n }\n });\n\n if (!opts.waitForProcessToTerminate) {\n resolve({ process: childProcess, stdout: \"\", stderr: \"\" });\n }\n });\n}\n\n/**\n * Run a nx command asynchronously inside the given nx workspace directory\n *\n * @param command command to run\n * @param nxRootDir the nx workspace root directory\n * @param opts options\n * @param opts.silenceError silence errors logged to console\n * @param opts.waitForProcessToTerminate Wait for the process to terminate before resolving.\n * @param opts.env environment variables to pass to the command\n */\nexport function runNxCommandAsync(\n command: string,\n nxRootDir: string,\n opts: { silenceError?: boolean; waitForProcessToTerminate?: boolean; env?: NodeJS.ProcessEnv } = {\n silenceError: false,\n waitForProcessToTerminate: true,\n }\n): Promise<{ process: ChildProcessWithoutNullStreams; stdout: string; stderr: string }> {\n const cmd = `${process.platform === \"win32\" ? \"./nx.bat\" : \"nx\"} ${command}`;\n return runCommandAsync(cmd, nxRootDir, opts);\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\n/**\n * Creates a new root folder for the end 2 end test.\n */\nexport function createRootFolder(e2eRootDir: string) {\n if (existsSync(e2eRootDir)) {\n rmSync(e2eRootDir, { recursive: true });\n }\n mkdirSync(e2eRootDir, { recursive: true });\n // eslint-disable-next-line no-console\n console.log(\"Using E2E root folder:\", e2eRootDir);\n}\n"]}
1
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C,CAAC;IAC1C,CAAC;IACD,IAAA,cAAS,EAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;AACpD,CAAC","sourcesContent":["// eslint-disable-next-line no-restricted-imports\nimport { tmpProjPath, uniq } from \"@nx/plugin/testing\";\nimport { ChildProcessWithoutNullStreams, spawn } from \"child_process\";\nimport { existsSync, mkdirSync, rmSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\n/**\n * Run a command asynchronously with the option of outputting stdout and stderr.\n *\n * @param command command to run\n * @param rootDir command execution directory\n * @param opts options\n * @param opts.silenceError silence errors logged to console\n * @param opts.waitForProcessToTerminate Wait for the process to terminate before resolving.\n * @param opts.env environment variables to pass to the command\n */\nexport function runCommandAsync(\n command: string,\n rootDir: string,\n opts: { silenceError?: boolean; waitForProcessToTerminate?: boolean; env?: NodeJS.ProcessEnv } = {\n silenceError: false,\n waitForProcessToTerminate: true,\n }\n): Promise<{ process: ChildProcessWithoutNullStreams; stdout: string; stderr: string }> {\n return new Promise((resolve, reject) => {\n const [cmd, ...args] = [...command.split(\" \")];\n if (!cmd) {\n throw new Error(\"Command cannot be empty\");\n }\n const childProcess = spawn(cmd, args, {\n cwd: rootDir,\n env: { ...process.env, ...opts.env },\n shell: true,\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n childProcess.stdout.on(\"data\", data => {\n stdout += data.toString();\n if (!opts.waitForProcessToTerminate && command.includes(\"--verbose\")) {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n }\n });\n\n childProcess.stderr.on(\"data\", data => {\n stderr += data.toString();\n if (!opts.waitForProcessToTerminate && command.includes(\"--verbose\")) {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n }\n });\n\n childProcess.on(\"close\", code => {\n if (code !== 0 && !opts.silenceError) {\n reject(new Error(stderr));\n } else if (opts.waitForProcessToTerminate) {\n if (command.includes(\"--verbose\") || stderr.length > 0) {\n // eslint-disable-next-line no-console\n console.log(\n `---------------------\\n`,\n `Cwd: ${rootDir}\\n`,\n `Cmd: ${command}\\n`,\n `Stdout:\\n`,\n stdout,\n `\\nStderr:\\n`,\n stderr,\n `\\n---------------------`\n );\n }\n resolve({ process: childProcess, stdout, stderr });\n }\n });\n\n childProcess.on(\"error\", err => {\n if (!opts.silenceError) {\n reject(err);\n }\n });\n\n if (!opts.waitForProcessToTerminate) {\n resolve({ process: childProcess, stdout: \"\", stderr: \"\" });\n }\n });\n}\n\n/**\n * Run a nx command asynchronously inside the given nx workspace directory\n *\n * @param command command to run\n * @param nxRootDir the nx workspace root directory\n * @param opts options\n * @param opts.silenceError silence errors logged to console\n * @param opts.waitForProcessToTerminate Wait for the process to terminate before resolving.\n * @param opts.env environment variables to pass to the command\n */\nexport function runNxCommandAsync(\n command: string,\n nxRootDir: string,\n opts: { silenceError?: boolean; waitForProcessToTerminate?: boolean; env?: NodeJS.ProcessEnv } = {\n silenceError: false,\n waitForProcessToTerminate: true,\n }\n): Promise<{ process: ChildProcessWithoutNullStreams; stdout: string; stderr: string }> {\n const cmd = `${process.platform === \"win32\" ? \"./nx.bat\" : \"nx\"} ${command}`;\n return runCommandAsync(cmd, nxRootDir, opts);\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\n/**\n * Creates a new root folder for the end 2 end test.\n */\nexport function createRootFolder(e2eRootDir: string) {\n if (existsSync(e2eRootDir)) {\n rmSync(e2eRootDir, { recursive: true });\n }\n mkdirSync(e2eRootDir, { recursive: true });\n // eslint-disable-next-line no-console\n console.log(\"Using E2E root folder:\", e2eRootDir);\n}\n"]}