Skip to content

Commit 7a8d23b

Browse files
authored
chore(core): lock in Nx Cloud prompt A/B winner for init and CNW (#35390)
## Current Behavior `create-nx-workspace` randomly serves one of three Nx Cloud prompt copy variants during the template flow; `nx init` pins a baseline copy that predates the test. A/B results (NXC-4336): - Variant 0 (baseline): `Enable remote caching to speed up builds with Nx Cloud?` — 15.4% yes / 29.2% never - Variant 1: `Never rebuild the same code twice — enable Nx Cloud?` — 13.4% yes / 28.4% never - **Variant 2: `Speed up GitHub Actions, GitLab CI, and more with Nx Cloud?` — 17.8% yes / 22.4% never** ## Expected Behavior Both `create-nx-workspace` (`setupNxCloudV2`) and `nx init` (`setupNxCloud`) serve the winning variant. Footer is reworded to lead with the free-tier messaging: > Free for small teams. Remote caching and task distribution. 2-minute setup: https://nx.dev/nx-cloud The CNW `setupNxCloudV2` array collapses from 3 variants to 1; `PromptMessages.getPrompt` already falls back to index 0 when `flowVariant >= length`, so existing flow-variant plumbing keeps working. Spec updated to assert the locked-in code for all flow variants (0/1/2) and docs generation. ## Related Issue(s) Fixes NXC-4336
1 parent a97bd37 commit 7a8d23b

3 files changed

Lines changed: 17 additions & 45 deletions

File tree

packages/create-nx-workspace/src/utils/nx/ab-testing.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('ab-testing', () => {
104104
});
105105
});
106106

107-
describe('setupNxCloudV2 prompt variants', () => {
107+
describe('setupNxCloudV2 prompt', () => {
108108
const originalEnv = process.env;
109109

110110
beforeEach(() => {
@@ -116,28 +116,28 @@ describe('ab-testing', () => {
116116
process.env = originalEnv;
117117
});
118118

119-
it.each([
120-
{ flowVariant: '0', expectedCode: 'connect-to-cloud' },
121-
{ flowVariant: '1', expectedCode: 'cloud-ab-never-rebuild' },
122-
{ flowVariant: '2', expectedCode: 'cloud-ab-ci-providers-speed' },
123-
])(
124-
'should select $expectedCode for flow variant $flowVariant',
125-
({ flowVariant, expectedCode }) => {
119+
it.each(['0', '1', '2'])(
120+
'should return the same prompt for flow variant %s',
121+
(flowVariant) => {
126122
jest.resetModules();
127123
process.env.NX_CNW_FLOW_VARIANT = flowVariant;
128124
const { PromptMessages: FreshPromptMessages } = require('./ab-testing');
129125
const pm = new FreshPromptMessages();
130-
expect(pm.getPrompt('setupNxCloudV2').code).toBe(expectedCode);
126+
expect(pm.getPrompt('setupNxCloudV2').code).toBe(
127+
'cloud-ci-providers-speed'
128+
);
131129
}
132130
);
133131

134-
it('should select variant 0 for docs generation', () => {
132+
it('should return the same prompt for docs generation', () => {
135133
process.env.NX_GENERATE_DOCS_PROCESS = 'true';
136134
const { PromptMessages: FreshPromptMessages } = jest.requireActual(
137135
'./ab-testing'
138136
) as typeof import('./ab-testing');
139137
const pm = new FreshPromptMessages();
140-
expect(pm.getPrompt('setupNxCloudV2').code).toBe('connect-to-cloud');
138+
expect(pm.getPrompt('setupNxCloudV2').code).toBe(
139+
'cloud-ci-providers-speed'
140+
);
141141
});
142142
});
143143
});

packages/create-nx-workspace/src/utils/nx/ab-testing.ts

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -205,39 +205,11 @@ const messageOptions: Record<string, MessageData[]> = {
205205
},
206206
],
207207
/**
208-
* Simplified Cloud prompt for template flow
208+
* Simplified Cloud prompt for template flow.
209209
*/
210210
setupNxCloudV2: [
211211
{
212-
code: 'connect-to-cloud',
213-
message: 'Enable remote caching to speed up builds with Nx Cloud?',
214-
initial: 0,
215-
choices: [
216-
{ value: 'yes', name: 'Yes' },
217-
{ value: 'skip', name: 'Skip for now' },
218-
{ value: 'never', name: chalk.dim("No, don't ask again") },
219-
],
220-
footer:
221-
'\nFree for small teams. 2-minute setup with GitHub — cache locally and in CI: https://nx.dev/nx-cloud',
222-
fallback: undefined,
223-
completionMessage: 'platform-setup',
224-
},
225-
{
226-
code: 'cloud-ab-never-rebuild',
227-
message: 'Never rebuild the same code twice \u2014 enable Nx Cloud?',
228-
initial: 0,
229-
choices: [
230-
{ value: 'yes', name: 'Yes' },
231-
{ value: 'skip', name: 'Skip for now' },
232-
{ value: 'never', name: chalk.dim("No, don't ask again") },
233-
],
234-
footer:
235-
'\nFree for small teams. Remote caching for local dev and CI. 2-minute setup: https://nx.dev/nx-cloud',
236-
fallback: undefined,
237-
completionMessage: 'platform-setup',
238-
},
239-
{
240-
code: 'cloud-ab-ci-providers-speed',
212+
code: 'cloud-ci-providers-speed',
241213
message: 'Speed up GitHub Actions, GitLab CI, and more with Nx Cloud?',
242214
initial: 0,
243215
choices: [
@@ -246,7 +218,7 @@ const messageOptions: Record<string, MessageData[]> = {
246218
{ value: 'never', name: chalk.dim("No, don't ask again") },
247219
],
248220
footer:
249-
'\nFree remote caching and task distribution. 2-minute setup: https://nx.dev/nx-cloud',
221+
'\nFree for small teams. Remote caching and task distribution. 2-minute setup: https://nx.dev/nx-cloud',
250222
fallback: undefined,
251223
completionMessage: 'platform-setup',
252224
},

packages/nx/src/utils/ab-testing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ interface MessageData {
4343
const messageOptions: Record<string, MessageData[]> = {
4444
setupNxCloud: [
4545
{
46-
code: 'cloud-ab-remote-cache-speed',
47-
message: 'Enable remote caching to speed up builds with Nx Cloud?',
46+
code: 'cloud-ci-providers-speed',
47+
message: 'Speed up GitHub Actions, GitLab CI, and more with Nx Cloud?',
4848
initial: 0,
4949
choices: [
5050
{ value: 'yes', name: 'Yes' },
5151
{ value: 'skip', name: 'Skip for now' },
5252
{ value: 'never', name: pc.dim("No, don't ask again") },
5353
],
5454
footer:
55-
'\nFree for small teams. 2-minute setup with GitHub — cache locally and in CI: https://nx.dev/nx-cloud',
55+
'\nFree for small teams. Remote caching and task distribution. 2-minute setup: https://nx.dev/nx-cloud',
5656
},
5757
],
5858
setupViewLogs: [

0 commit comments

Comments
 (0)