Skip to content

Commit

Permalink
fix(misc): use generated directory path as cwd rather than attempting…
Browse files Browse the repository at this point in the history
… to rederive it

Closes: #16326
  • Loading branch information
AgentEnder committed May 3, 2023
1 parent 58e23b1 commit c2e8bf7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions docs/generated/devkit/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions docs/generated/packages/devkit/documents/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions packages/create-nx-workspace/src/create-empty-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ export async function createEmptyWorkspace<T extends CreateWorkspaceOptions>(
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}"`;
Expand All @@ -56,15 +58,15 @@ export async function createEmptyWorkspace<T extends CreateWorkspaceOptions>(
}
}
let workspaceSetupSpinner = ora(
`Creating your workspace in ${getFileName(name)}`
`Creating your workspace in ${directory}`
).start();

try {
const fullCommand = `${pmc.exec} nx ${command} --nxWorkspaceRoot=${nxWorkspaceRoot}`;
await execAndWait(fullCommand, tmpDir);

workspaceSetupSpinner.succeed(
`Successfully created the workspace: ${getFileName(name)}.`
`Successfully created the workspace: ${directory}.`
);
} catch (e) {
workspaceSetupSpinner.fail();
Expand All @@ -80,5 +82,5 @@ export async function createEmptyWorkspace<T extends CreateWorkspaceOptions>(
} finally {
workspaceSetupSpinner.stop();
}
return join(workingDir, getFileName(name));
return join(workingDir, directory);
}
4 changes: 2 additions & 2 deletions packages/create-nx-workspace/src/create-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export async function createWorkspace<T extends CreateWorkspaceOptions>(

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
Expand Down
5 changes: 2 additions & 3 deletions packages/create-nx-workspace/src/utils/ci/setup-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions packages/create-nx-workspace/src/utils/nx/nx-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ 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();
try {
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;
Expand Down

0 comments on commit c2e8bf7

Please sign in to comment.