Skip to content

Commit 2366622

Browse files
jaysoonx-cloud[bot]
authored andcommitted
fix(misc): prevent nxCloudId from being generated for new workspaces (#34532)
## Current Behavior When creating a new workspace using `create-nx-workspace` with the "custom" preset flow, an `nxCloudId` is generated and added to `nx.json`. This happens even though the onboarding flow is supposed to handle Cloud setup separately via a short URL. ## Expected Behavior New workspaces created via `create-nx-workspace` should not have `nxCloudId` set in `nx.json`. Instead, a short URL is provided for users to finish Cloud onboarding on their own. The `nxCloud: 'skip'` option is now passed for the custom flow to prevent the ID from being generated. E2E tests are updated to verify that `nxCloudId` is undefined in the generated `nx.json` across all workspace presets. ## Related Issue(s) N/A - internal fix for workspace creation behavior. --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> (cherry picked from commit 221ed88)
1 parent 744cb3a commit 2366622

10 files changed

+34
-1
lines changed

e2e/utils/create-project-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export function runCreateWorkspace(
297297
// Needed for bun workarounds, see below
298298
const registry = execSync('npm config get registry').toString().trim();
299299

300-
let command = `${pm.createWorkspace} ${name} --nxCloud=skip --no-interactive`;
300+
let command = `${pm.createWorkspace} ${name} --no-interactive`;
301301

302302
if (preset) {
303303
command += ` --preset=${preset}`;

e2e/workspace-create/src/create-nx-workspace-angular.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
cleanupProject,
55
expectCodeIsFormatted,
66
getSelectedPackageManager,
7+
readJson,
78
runCreateWorkspace,
89
uniq,
910
} from '@nx/e2e-utils';
@@ -34,6 +35,9 @@ describe('create-nx-workspace --preset=angular', () => {
3435
checkFilesExist('src/app/app-module.ts');
3536
checkFilesDoNotExist('src/app/app.routes.ts');
3637
expectCodeIsFormatted();
38+
39+
const nxJson = readJson(`nx.json`);
40+
expect(nxJson.nxCloudId).toBeUndefined();
3741
});
3842

3943
it('should create a workspace with a single angular app at the root using standalone APIs', () => {

e2e/workspace-create/src/create-nx-workspace-base-templates.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
cleanupProject,
3+
readJson,
34
runCLI,
45
runCreateWorkspace,
56
uniq,
@@ -25,6 +26,9 @@ describe('create-nx-workspace --template', () => {
2526
});
2627

2728
expect(() => runCLI('run-many -t lint,test,build')).not.toThrow();
29+
30+
const nxJson = readJson(`nx.json`);
31+
expect(nxJson.nxCloudId).toBeUndefined();
2832
},
2933
600_000
3034
);

e2e/workspace-create/src/create-nx-workspace-frameworks-next.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
expectCodeIsFormatted,
55
expectNoAngularDevkit,
66
getSelectedPackageManager,
7+
readJson,
78
runCreateWorkspace,
89
uniq,
910
} from '@nx/e2e-utils';
@@ -30,6 +31,9 @@ describe('create-nx-workspace --preset=next', () => {
3031

3132
expectNoAngularDevkit();
3233
expectCodeIsFormatted();
34+
35+
const nxJson = readJson(`nx.json`);
36+
expect(nxJson.nxCloudId).toBeUndefined();
3337
});
3438

3539
it('should be able to create a nextjs standalone workspace using app router', () => {

e2e/workspace-create/src/create-nx-workspace-frameworks-nuxt.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
cleanupProject,
44
expectCodeIsFormatted,
55
getSelectedPackageManager,
6+
readJson,
67
runCreateWorkspace,
78
uniq,
89
} from '@nx/e2e-utils';
@@ -29,6 +30,9 @@ describe('create-nx-workspace --preset=nuxt', () => {
2930
checkFilesExist('app/app.vue');
3031
checkFilesExist('app/pages/index.vue');
3132
expectCodeIsFormatted();
33+
34+
const nxJson = readJson(`nx.json`);
35+
expect(nxJson.nxCloudId).toBeUndefined();
3236
});
3337

3438
it('should be able to create a nuxt monorepo', () => {

e2e/workspace-create/src/create-nx-workspace-frameworks-vue.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
cleanupProject,
44
expectCodeIsFormatted,
55
getSelectedPackageManager,
6+
readJson,
67
runCreateWorkspace,
78
uniq,
89
} from '@nx/e2e-utils';
@@ -29,6 +30,9 @@ describe('create-nx-workspace --preset=vue', () => {
2930
checkFilesExist('src/main.ts');
3031
checkFilesExist('src/app/App.vue');
3132
expectCodeIsFormatted();
33+
34+
const nxJson = readJson(`nx.json`);
35+
expect(nxJson.nxCloudId).toBeUndefined();
3236
});
3337

3438
it('should be able to create a vue monorepo', () => {

e2e/workspace-create/src/create-nx-workspace-npm.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ describe('create-nx-workspace --preset=npm', () => {
4646
} else {
4747
expect(packageJson.workspaces).toEqual(['packages/*']);
4848
}
49+
50+
const nxJson = readJson(`nx.json`);
51+
expect(nxJson.nxCloudId).toBeUndefined();
4952
});
5053

5154
it('should add angular application', () => {

e2e/workspace-create/src/create-nx-workspace-react-template.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
cleanupProject,
33
runCLI,
4+
readJson,
45
runCreateWorkspace,
56
uniq,
67
} from '@nx/e2e-utils';
@@ -22,6 +23,9 @@ describe('create-nx-workspace --template', () => {
2223
});
2324

2425
expect(() => runCLI('run-many -t lint,test,build')).not.toThrow();
26+
27+
const nxJson = readJson(`nx.json`);
28+
expect(nxJson.nxCloudId).toBeUndefined();
2529
},
2630
600_000
2731
);

e2e/workspace-create/src/create-nx-workspace-react.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ describe('create-nx-workspace --preset=react', () => {
3333
checkFilesExist('vite.config.mts');
3434
checkFilesDoNotExist('tsconfig.base.json');
3535
expectCodeIsFormatted();
36+
37+
const nxJson = readJson(`nx.json`);
38+
expect(nxJson.nxCloudId).toBeUndefined();
3639
});
3740

3841
it('should create a workspace with a single react app with webpack and playwright at the root', () => {

packages/create-nx-workspace/src/create-workspace.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ export async function createWorkspace<T extends CreateWorkspaceOptions>(
158158
...options,
159159
preset,
160160
workspaceGlobs,
161+
// We want new workspaces to have a short URL to finish Cloud onboarding, but not have nxCloudId set up since it will be handled as part of the onboarding flow.
162+
// This is skipping nxCloudId for the "custom" flow.
163+
nxCloud: 'skip',
161164
});
162165

163166
// Mark workspace as ready for SIGINT handler

0 commit comments

Comments
 (0)