From c2e8bf74ca905d553bf06049e005b1ed2ae14335 Mon Sep 17 00:00:00 2001 From: AgentEnder Date: Wed, 3 May 2023 14:26:13 -0400 Subject: [PATCH] fix(misc): use generated directory path as cwd rather than attempting to rederive it Closes: #16326 --- docs/generated/devkit/nx_devkit.md | 6 +++--- docs/generated/packages/devkit/documents/nx_devkit.md | 6 +++--- .../create-nx-workspace/src/create-empty-workspace.ts | 10 ++++++---- packages/create-nx-workspace/src/create-workspace.ts | 4 ++-- packages/create-nx-workspace/src/utils/ci/setup-ci.ts | 5 ++--- packages/create-nx-workspace/src/utils/nx/nx-cloud.ts | 5 ++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/generated/devkit/nx_devkit.md b/docs/generated/devkit/nx_devkit.md index 701054a8d1e6a..bb34792585efd 100644 --- a/docs/generated/devkit/nx_devkit.md +++ b/docs/generated/devkit/nx_devkit.md @@ -992,9 +992,9 @@ Use this to expose a compatible Angular Builder #### Parameters -| Name | Type | -| :--------- | :------------------------------------------------------ | -| `executor` | [`Executor`](../../devkit/documents/nx_devkit#executor) | +| Name | Type | +| :--------- | :-------------------------------------------------------------- | +| `executor` | [`Executor`](../../devkit/documents/nx_devkit#executor)<`any`\> | #### Returns diff --git a/docs/generated/packages/devkit/documents/nx_devkit.md b/docs/generated/packages/devkit/documents/nx_devkit.md index 701054a8d1e6a..bb34792585efd 100644 --- a/docs/generated/packages/devkit/documents/nx_devkit.md +++ b/docs/generated/packages/devkit/documents/nx_devkit.md @@ -992,9 +992,9 @@ Use this to expose a compatible Angular Builder #### Parameters -| Name | Type | -| :--------- | :------------------------------------------------------ | -| `executor` | [`Executor`](../../devkit/documents/nx_devkit#executor) | +| Name | Type | +| :--------- | :-------------------------------------------------------------- | +| `executor` | [`Executor`](../../devkit/documents/nx_devkit#executor)<`any`\> | #### Returns diff --git a/packages/create-nx-workspace/src/create-empty-workspace.ts b/packages/create-nx-workspace/src/create-empty-workspace.ts index ff647d5a30850..2e91ef7470edd 100644 --- a/packages/create-nx-workspace/src/create-empty-workspace.ts +++ b/packages/create-nx-workspace/src/create-empty-workspace.ts @@ -32,13 +32,15 @@ export async function createEmptyWorkspace( options.packageManager = packageManager; } + const directory = getFileName(name); + const args = unparse({ ...options, }).join(' '); const pmc = getPackageManagerCommand(packageManager); - const command = `new ${name} ${args}`; + const command = `new ${directory} ${args}`; const workingDir = process.cwd().replace(/\\/g, '/'); let nxWorkspaceRoot = `"${workingDir}"`; @@ -56,7 +58,7 @@ export async function createEmptyWorkspace( } } let workspaceSetupSpinner = ora( - `Creating your workspace in ${getFileName(name)}` + `Creating your workspace in ${directory}` ).start(); try { @@ -64,7 +66,7 @@ export async function createEmptyWorkspace( await execAndWait(fullCommand, tmpDir); workspaceSetupSpinner.succeed( - `Successfully created the workspace: ${getFileName(name)}.` + `Successfully created the workspace: ${directory}.` ); } catch (e) { workspaceSetupSpinner.fail(); @@ -80,5 +82,5 @@ export async function createEmptyWorkspace( } finally { workspaceSetupSpinner.stop(); } - return join(workingDir, getFileName(name)); + return join(workingDir, directory); } diff --git a/packages/create-nx-workspace/src/create-workspace.ts b/packages/create-nx-workspace/src/create-workspace.ts index 125889b930c99..08a4a2aed6b98 100644 --- a/packages/create-nx-workspace/src/create-workspace.ts +++ b/packages/create-nx-workspace/src/create-workspace.ts @@ -48,11 +48,11 @@ export async function createWorkspace( let nxCloudInstallRes; if (nxCloud) { - nxCloudInstallRes = await setupNxCloud(name, packageManager); + nxCloudInstallRes = await setupNxCloud(directory, packageManager); } if (ci) { await setupCI( - name, + directory, ci, packageManager, nxCloud && nxCloudInstallRes?.code === 0 diff --git a/packages/create-nx-workspace/src/utils/ci/setup-ci.ts b/packages/create-nx-workspace/src/utils/ci/setup-ci.ts index 76ab094011910..391842b2148f2 100644 --- a/packages/create-nx-workspace/src/utils/ci/setup-ci.ts +++ b/packages/create-nx-workspace/src/utils/ci/setup-ci.ts @@ -5,10 +5,9 @@ import { execAndWait } from '../child-process-utils'; import { mapErrorToBodyLines } from '../error-utils'; import { output } from '../output'; import { getPackageManagerCommand, PackageManager } from '../package-manager'; -import { getFileName } from '../string-utils'; export async function setupCI( - name: string, + directory: string, ci: string, packageManager: PackageManager, nxCloudSuccessfullyInstalled: boolean @@ -27,7 +26,7 @@ export async function setupCI( const pmc = getPackageManagerCommand(packageManager); const res = await execAndWait( `${pmc.exec} nx g @nx/workspace:ci-workflow --ci=${ci}`, - join(process.cwd(), getFileName(name)) + directory ); ciSpinner.succeed('CI workflow has been generated successfully'); return res; diff --git a/packages/create-nx-workspace/src/utils/nx/nx-cloud.ts b/packages/create-nx-workspace/src/utils/nx/nx-cloud.ts index 66dca6128315a..0d9174fbf13ba 100644 --- a/packages/create-nx-workspace/src/utils/nx/nx-cloud.ts +++ b/packages/create-nx-workspace/src/utils/nx/nx-cloud.ts @@ -3,11 +3,10 @@ import { join } from 'path'; import { execAndWait } from '../child-process-utils'; import { output } from '../output'; import { getPackageManagerCommand, PackageManager } from '../package-manager'; -import { getFileName } from '../string-utils'; import { mapErrorToBodyLines } from '../error-utils'; export async function setupNxCloud( - name: string, + directory: string, packageManager: PackageManager ) { const nxCloudSpinner = ora(`Setting up NxCloud`).start(); @@ -15,7 +14,7 @@ export async function setupNxCloud( const pmc = getPackageManagerCommand(packageManager); const res = await execAndWait( `${pmc.exec} nx g nx-cloud:init --no-analytics --installationSource=create-nx-workspace`, - join(process.cwd(), getFileName(name)) + directory ); nxCloudSpinner.succeed('NxCloud has been set up successfully'); return res;