@trackunit/nx-utils 0.0.14 → 0.0.16

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,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.16](https://github.com/Trackunit/manager/compare/nx-utils/0.0.15...nx-utils/0.0.16) (2023-05-11)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `test-setup` updated to version `0.0.1`
10
+ ## [0.0.15](https://github.com/Trackunit/manager/compare/nx-utils/0.0.14...nx-utils/0.0.15) (2023-05-11)
11
+
5
12
  ## [0.0.14](https://github.com/Trackunit/manager/compare/nx-utils/0.0.13...nx-utils/0.0.14) (2023-05-03)
6
13
 
7
14
  ### Dependency Updates
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@trackunit/nx-utils",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "main": "src/index.js",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
7
7
  "dependencies": {
8
- "@react-google-maps/api": "2.17.1",
8
+ "@react-google-maps/api": "2.18.1",
9
9
  "@react-spring/web": "9.6.0",
10
10
  "i18next": "21.10.0",
11
11
  "jest-canvas-mock": "2.4.0",
@@ -66,7 +66,7 @@ function copyFolderSync(source, destination) {
66
66
  const runNxNewCommand = (nxRoot, silent) => {
67
67
  const projectName = nxRoot.split(path_1.sep).pop();
68
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`;
69
+ const cmd = `npx create-nx-workspace@15.9.4 ${projectName} --interactive=false --skip-install --npmScope=e2e --preset=ts --verbose --nxCloud=false --packageManager=yarn`;
70
70
  return (0, child_process_1.execSync)(cmd, Object.assign({ cwd: nxRootParent }, (silent && false ? { stdio: ["ignore", "ignore", "ignore"] } : {})));
71
71
  };
72
72
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"projectUtils.js","sourceRoot":"","sources":["../../../../../libs/nx/utils/src/projectUtils.ts"],"names":[],"mappings":";;;;AAAA,yCAAuE;AACvE,iDAAiD;AACjD,qDAAwE;AACxE,iDAA+C;AAC/C,2BAAyF;AAEzF,2BAA4B;AAC5B,+BAAsD;AAUtD;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,GAAsB,EAAE;;IAChD,MAAM,UAAU,GAAG,IAAI,mBAAU,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,UAAU,CAAC,0BAA0B,EAAE,CAAC;IAEhE,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;QAC9D,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,MAAA,aAAa,CAAC,OAAO,0CAAE,KAAK,EAAE;YAChC,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC;YAChD,MAAM,UAAU,GAAG,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,0CAAE,UAAU,CAAC;YAEpD,IAAI,UAAU,EAAE;gBACd,MAAM,eAAe,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;gBAChF,IAAI,IAAA,oBAAU,EAAC,eAAe,CAAC,EAAE;oBAC/B,MAAM,WAAW,GAAG,IAAA,qBAAY,EAAC,eAAe,CAAC,CAAC;oBAClD,QAAQ,CAAC,IAAI,CAAC;wBACZ,OAAO,EAAE,WAAW,CAAC,IAAI;wBACzB,IAAI,EAAE,UAAU;qBACj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C,OAAO,CAAC;IACtD,gBAAgB,CAAC,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC;IAClD,IAAA,sBAAa,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,IAAY,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"]}
1
+ {"version":3,"file":"projectUtils.js","sourceRoot":"","sources":["../../../../../libs/nx/utils/src/projectUtils.ts"],"names":[],"mappings":";;;;AAAA,yCAAuE;AACvE,iDAAiD;AACjD,qDAAwE;AACxE,iDAA+C;AAC/C,2BAAyF;AAEzF,2BAA4B;AAC5B,+BAAsD;AAUtD;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,GAAsB,EAAE;;IAChD,MAAM,UAAU,GAAG,IAAI,mBAAU,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,UAAU,CAAC,0BAA0B,EAAE,CAAC;IAEhE,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;QAC9D,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC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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.4 ${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"]}