create-nx-workspace 19.5.3 → 19.5.4

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.
@@ -14,7 +14,6 @@ const get_third_party_preset_1 = require("../src/utils/preset/get-third-party-pr
14
14
  const prompts_1 = require("../src/internal-utils/prompts");
15
15
  const yargs_options_1 = require("../src/internal-utils/yargs-options");
16
16
  const show_nx_warning_1 = require("../src/utils/nx/show-nx-warning");
17
- const nx_cloud_1 = require("../src/utils/nx/nx-cloud");
18
17
  const ab_testing_1 = require("../src/utils/nx/ab-testing");
19
18
  const error_utils_1 = require("../src/utils/error-utils");
20
19
  const fs_1 = require("fs");
@@ -125,7 +124,7 @@ async function main(parsedArgs) {
125
124
  ],
126
125
  });
127
126
  if (parsedArgs.nxCloud && workspaceInfo.nxCloudInfo) {
128
- (0, nx_cloud_1.printNxCloudSuccessMessage)(workspaceInfo.nxCloudInfo);
127
+ console.log(workspaceInfo.nxCloudInfo);
129
128
  }
130
129
  if ((0, preset_1.isKnownPreset)(parsedArgs.preset)) {
131
130
  (0, point_to_tutorial_and_course_1.pointToTutorialAndCourse)(parsedArgs.preset);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nx-workspace",
3
- "version": "19.5.3",
3
+ "version": "19.5.4",
4
4
  "private": false,
5
5
  "description": "Smart Monorepos · Fast CI",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "tmp": "~0.2.1",
38
38
  "tslib": "^2.3.0",
39
39
  "yargs": "^17.6.2",
40
- "axios": "^1.6.0"
40
+ "axios": "^1.7.2"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
@@ -26,19 +26,19 @@ async function createWorkspace(preset, options) {
26
26
  if (thirdPartyPackageName) {
27
27
  await (0, create_preset_1.createPreset)(thirdPartyPackageName, options, packageManager, directory);
28
28
  }
29
- let nxCloudInstallRes;
29
+ let connectUrl;
30
+ let nxCloudInfo;
30
31
  if (nxCloud !== 'skip') {
31
- nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub);
32
+ const token = await (0, nx_cloud_1.setupNxCloud)(directory, nxCloud, useGitHub);
32
33
  if (nxCloud !== 'yes') {
33
- await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
34
+ await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager);
34
35
  }
36
+ const { connectCloudUrl, output } = await (0, nx_cloud_1.getOnboardingInfo)(nxCloud, token, directory, useGitHub);
37
+ connectUrl = connectCloudUrl;
38
+ nxCloudInfo = output;
35
39
  }
36
40
  if (!skipGit) {
37
41
  try {
38
- let connectUrl;
39
- if (nxCloudInstallRes?.code === 0) {
40
- connectUrl = extractConnectUrl(nxCloudInstallRes?.stdout);
41
- }
42
42
  await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit, connectUrl });
43
43
  }
44
44
  catch (e) {
@@ -54,7 +54,7 @@ async function createWorkspace(preset, options) {
54
54
  }
55
55
  }
56
56
  return {
57
- nxCloudInfo: nxCloudInstallRes?.stdout,
57
+ nxCloudInfo,
58
58
  directory,
59
59
  };
60
60
  }
@@ -1,5 +1,5 @@
1
1
  import { PackageManager } from '../package-manager';
2
- export declare function setupCI(directory: string, ci: string, packageManager: PackageManager, nxCloudSuccessfullyInstalled: boolean): Promise<{
2
+ export declare function setupCI(directory: string, ci: string, packageManager: PackageManager): Promise<{
3
3
  code: number;
4
4
  stdout: string;
5
5
  }>;
@@ -6,16 +6,7 @@ const child_process_utils_1 = require("../child-process-utils");
6
6
  const error_utils_1 = require("../error-utils");
7
7
  const output_1 = require("../output");
8
8
  const package_manager_1 = require("../package-manager");
9
- async function setupCI(directory, ci, packageManager, nxCloudSuccessfullyInstalled) {
10
- if (!nxCloudSuccessfullyInstalled) {
11
- output_1.output.error({
12
- title: `CI workflow generation skipped`,
13
- bodyLines: [
14
- `Nx Cloud was not installed`,
15
- `The autogenerated CI workflow requires Nx Cloud to be set-up.`,
16
- ],
17
- });
18
- }
9
+ async function setupCI(directory, ci, packageManager) {
19
10
  const ciSpinner = ora(`Generating CI workflow`).start();
20
11
  try {
21
12
  const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
@@ -0,0 +1,259 @@
1
+ declare const outputMessages: {
2
+ readonly 'create-nx-workspace-success-ci-setup': readonly [{
3
+ readonly code: "nx-cloud-workspace-push-goto";
4
+ readonly createMessage: (url: string) => {
5
+ title: string;
6
+ type: string;
7
+ bodyLines: string[];
8
+ };
9
+ }, {
10
+ readonly code: "nx-cloud-powered-ci-setup-visit";
11
+ readonly createMessage: (url: string) => {
12
+ title: string;
13
+ type: string;
14
+ bodyLines: string[];
15
+ };
16
+ }, {
17
+ readonly code: "nx-cloud-powered-ci-setup-connect";
18
+ readonly createMessage: (url: string) => {
19
+ title: string;
20
+ type: string;
21
+ bodyLines: string[];
22
+ };
23
+ }, {
24
+ readonly code: "ci-setup-visit";
25
+ readonly createMessage: (url: string) => {
26
+ title: string;
27
+ type: string;
28
+ bodyLines: string[];
29
+ };
30
+ }, {
31
+ readonly code: "ci-setup-connect";
32
+ readonly createMessage: (url: string) => {
33
+ title: string;
34
+ type: string;
35
+ bodyLines: string[];
36
+ };
37
+ }, {
38
+ readonly code: "nx-cloud-powered-ci-setup-visit-warn";
39
+ readonly createMessage: (url: string) => {
40
+ title: string;
41
+ type: string;
42
+ bodyLines: string[];
43
+ };
44
+ }, {
45
+ readonly code: "nx-cloud-powered-ci-setup-connect-warn";
46
+ readonly createMessage: (url: string) => {
47
+ title: string;
48
+ type: string;
49
+ bodyLines: string[];
50
+ };
51
+ }, {
52
+ readonly code: "ci-setup-visit-warn";
53
+ readonly createMessage: (url: string) => {
54
+ title: string;
55
+ type: string;
56
+ bodyLines: string[];
57
+ };
58
+ }, {
59
+ readonly code: "ci-setup-connect-warn";
60
+ readonly createMessage: (url: string) => {
61
+ title: string;
62
+ type: string;
63
+ bodyLines: string[];
64
+ };
65
+ }];
66
+ readonly 'create-nx-workspace-success-cache-setup': readonly [{
67
+ readonly code: "nx-cloud-workspace-push-goto";
68
+ readonly createMessage: (url: string) => {
69
+ title: string;
70
+ type: string;
71
+ bodyLines: string[];
72
+ };
73
+ }, {
74
+ readonly code: "nx-cloud-remote-cache-setup-finish";
75
+ readonly createMessage: (url: string) => {
76
+ title: string;
77
+ type: string;
78
+ bodyLines: string[];
79
+ };
80
+ }, {
81
+ readonly code: "nx-cloud-remote-cache-setup-connect";
82
+ readonly createMessage: (url: string) => {
83
+ title: string;
84
+ type: string;
85
+ bodyLines: string[];
86
+ };
87
+ }, {
88
+ readonly code: "remote-cache-visit";
89
+ readonly createMessage: (url: string) => {
90
+ title: string;
91
+ type: string;
92
+ bodyLines: string[];
93
+ };
94
+ }, {
95
+ readonly code: "remote-cache-connect";
96
+ readonly createMessage: (url: string) => {
97
+ title: string;
98
+ type: string;
99
+ bodyLines: string[];
100
+ };
101
+ }, {
102
+ readonly code: "nx-cloud-remote-cache-setup-visit-warn";
103
+ readonly createMessage: (url: string) => {
104
+ title: string;
105
+ type: string;
106
+ bodyLines: string[];
107
+ };
108
+ }, {
109
+ readonly code: "nx-cloud-remote-cache-setup-connect-warn";
110
+ readonly createMessage: (url: string) => {
111
+ title: string;
112
+ type: string;
113
+ bodyLines: string[];
114
+ };
115
+ }, {
116
+ readonly code: "remote-cache-visit-warn";
117
+ readonly createMessage: (url: string) => {
118
+ title: string;
119
+ type: string;
120
+ bodyLines: string[];
121
+ };
122
+ }, {
123
+ readonly code: "remote-cache-connect-warn";
124
+ readonly createMessage: (url: string) => {
125
+ title: string;
126
+ type: string;
127
+ bodyLines: string[];
128
+ };
129
+ }];
130
+ };
131
+ type OutputMessageKey = keyof typeof outputMessages;
132
+ export declare function getMessageFactory(key: OutputMessageKey): {
133
+ readonly code: "nx-cloud-workspace-push-goto";
134
+ readonly createMessage: (url: string) => {
135
+ title: string;
136
+ type: string;
137
+ bodyLines: string[];
138
+ };
139
+ } | {
140
+ readonly code: "nx-cloud-powered-ci-setup-visit";
141
+ readonly createMessage: (url: string) => {
142
+ title: string;
143
+ type: string;
144
+ bodyLines: string[];
145
+ };
146
+ } | {
147
+ readonly code: "nx-cloud-powered-ci-setup-connect";
148
+ readonly createMessage: (url: string) => {
149
+ title: string;
150
+ type: string;
151
+ bodyLines: string[];
152
+ };
153
+ } | {
154
+ readonly code: "ci-setup-visit";
155
+ readonly createMessage: (url: string) => {
156
+ title: string;
157
+ type: string;
158
+ bodyLines: string[];
159
+ };
160
+ } | {
161
+ readonly code: "ci-setup-connect";
162
+ readonly createMessage: (url: string) => {
163
+ title: string;
164
+ type: string;
165
+ bodyLines: string[];
166
+ };
167
+ } | {
168
+ readonly code: "nx-cloud-powered-ci-setup-visit-warn";
169
+ readonly createMessage: (url: string) => {
170
+ title: string;
171
+ type: string;
172
+ bodyLines: string[];
173
+ };
174
+ } | {
175
+ readonly code: "nx-cloud-powered-ci-setup-connect-warn";
176
+ readonly createMessage: (url: string) => {
177
+ title: string;
178
+ type: string;
179
+ bodyLines: string[];
180
+ };
181
+ } | {
182
+ readonly code: "ci-setup-visit-warn";
183
+ readonly createMessage: (url: string) => {
184
+ title: string;
185
+ type: string;
186
+ bodyLines: string[];
187
+ };
188
+ } | {
189
+ readonly code: "ci-setup-connect-warn";
190
+ readonly createMessage: (url: string) => {
191
+ title: string;
192
+ type: string;
193
+ bodyLines: string[];
194
+ };
195
+ } | {
196
+ readonly code: "nx-cloud-workspace-push-goto";
197
+ readonly createMessage: (url: string) => {
198
+ title: string;
199
+ type: string;
200
+ bodyLines: string[];
201
+ };
202
+ } | {
203
+ readonly code: "nx-cloud-remote-cache-setup-finish";
204
+ readonly createMessage: (url: string) => {
205
+ title: string;
206
+ type: string;
207
+ bodyLines: string[];
208
+ };
209
+ } | {
210
+ readonly code: "nx-cloud-remote-cache-setup-connect";
211
+ readonly createMessage: (url: string) => {
212
+ title: string;
213
+ type: string;
214
+ bodyLines: string[];
215
+ };
216
+ } | {
217
+ readonly code: "remote-cache-visit";
218
+ readonly createMessage: (url: string) => {
219
+ title: string;
220
+ type: string;
221
+ bodyLines: string[];
222
+ };
223
+ } | {
224
+ readonly code: "remote-cache-connect";
225
+ readonly createMessage: (url: string) => {
226
+ title: string;
227
+ type: string;
228
+ bodyLines: string[];
229
+ };
230
+ } | {
231
+ readonly code: "nx-cloud-remote-cache-setup-visit-warn";
232
+ readonly createMessage: (url: string) => {
233
+ title: string;
234
+ type: string;
235
+ bodyLines: string[];
236
+ };
237
+ } | {
238
+ readonly code: "nx-cloud-remote-cache-setup-connect-warn";
239
+ readonly createMessage: (url: string) => {
240
+ title: string;
241
+ type: string;
242
+ bodyLines: string[];
243
+ };
244
+ } | {
245
+ readonly code: "remote-cache-visit-warn";
246
+ readonly createMessage: (url: string) => {
247
+ title: string;
248
+ type: string;
249
+ bodyLines: string[];
250
+ };
251
+ } | {
252
+ readonly code: "remote-cache-connect-warn";
253
+ readonly createMessage: (url: string) => {
254
+ title: string;
255
+ type: string;
256
+ bodyLines: string[];
257
+ };
258
+ };
259
+ export {};
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMessageFactory = getMessageFactory;
4
+ const outputMessages = {
5
+ 'create-nx-workspace-success-ci-setup': [
6
+ {
7
+ code: 'nx-cloud-workspace-push-goto',
8
+ createMessage: (url) => ({
9
+ title: `Your Nx Cloud workspace is ready.`,
10
+ type: 'success',
11
+ bodyLines: [
12
+ `To claim it, connect it to your Nx Cloud account:`,
13
+ `- Push your repository to your git hosting provider.`,
14
+ `- Go to the following URL to connect your workspace to Nx Cloud:`,
15
+ '',
16
+ `${url}`,
17
+ ],
18
+ }),
19
+ },
20
+ {
21
+ code: 'nx-cloud-powered-ci-setup-visit',
22
+ createMessage: (url) => ({
23
+ title: `Your CI setup powered by Nx Cloud is almost complete.`,
24
+ type: 'success',
25
+ bodyLines: [`Finish it by visiting: ${url}`],
26
+ }),
27
+ },
28
+ {
29
+ code: 'nx-cloud-powered-ci-setup-connect',
30
+ createMessage: (url) => ({
31
+ title: `Your CI setup powered by Nx Cloud is almost complete.`,
32
+ type: 'success',
33
+ bodyLines: [`Connect your repository: ${url}`],
34
+ }),
35
+ },
36
+ {
37
+ code: 'ci-setup-visit',
38
+ createMessage: (url) => ({
39
+ title: `Your CI setup is almost complete.`,
40
+ type: 'success',
41
+ bodyLines: [`Finish it by visiting: ${url}`],
42
+ }),
43
+ },
44
+ {
45
+ code: 'ci-setup-connect',
46
+ createMessage: (url) => ({
47
+ title: `Your CI setup is almost complete.`,
48
+ type: 'success',
49
+ bodyLines: [`Connect your repository: ${url}`],
50
+ }),
51
+ },
52
+ {
53
+ code: 'nx-cloud-powered-ci-setup-visit-warn',
54
+ createMessage: (url) => ({
55
+ title: `Your CI setup powered by Nx Cloud is almost complete.`,
56
+ type: 'warning',
57
+ bodyLines: [`Finish it by visiting: ${url}`],
58
+ }),
59
+ },
60
+ {
61
+ code: 'nx-cloud-powered-ci-setup-connect-warn',
62
+ createMessage: (url) => ({
63
+ title: `Your CI setup powered by Nx Cloud is almost complete.`,
64
+ type: 'warning',
65
+ bodyLines: [`Connect your repository: ${url}`],
66
+ }),
67
+ },
68
+ {
69
+ code: 'ci-setup-visit-warn',
70
+ createMessage: (url) => ({
71
+ title: `Your CI setup is almost complete.`,
72
+ type: 'warning',
73
+ bodyLines: [`Finish it by visiting: ${url}`],
74
+ }),
75
+ },
76
+ {
77
+ code: 'ci-setup-connect-warn',
78
+ createMessage: (url) => ({
79
+ title: `Your CI setup is almost complete.`,
80
+ type: 'warning',
81
+ bodyLines: [`Connect your repository: ${url}`],
82
+ }),
83
+ },
84
+ ],
85
+ 'create-nx-workspace-success-cache-setup': [
86
+ {
87
+ code: 'nx-cloud-workspace-push-goto',
88
+ createMessage: (url) => ({
89
+ title: `Your Nx Cloud workspace is ready.`,
90
+ type: 'success',
91
+ bodyLines: [
92
+ `To claim it, connect it to your Nx Cloud account:`,
93
+ `- Push your repository to your git hosting provider.`,
94
+ `- Go to the following URL to connect your workspace to Nx Cloud:`,
95
+ '',
96
+ `${url}`,
97
+ ],
98
+ }),
99
+ },
100
+ {
101
+ code: 'nx-cloud-remote-cache-setup-finish',
102
+ createMessage: (url) => ({
103
+ title: `Your Nx Cloud remote cache setup is almost complete.`,
104
+ type: 'success',
105
+ bodyLines: [`Finish it by visiting: ${url}`],
106
+ }),
107
+ },
108
+ {
109
+ code: 'nx-cloud-remote-cache-setup-connect',
110
+ createMessage: (url) => ({
111
+ title: `Your Nx Cloud remote cache setup is almost complete.`,
112
+ type: 'success',
113
+ bodyLines: [`Connect your repository: ${url}`],
114
+ }),
115
+ },
116
+ {
117
+ code: 'remote-cache-visit',
118
+ createMessage: (url) => ({
119
+ title: `Your remote cache setup is almost complete.`,
120
+ type: 'success',
121
+ bodyLines: [`Finish it by visiting: ${url}`],
122
+ }),
123
+ },
124
+ {
125
+ code: 'remote-cache-connect',
126
+ createMessage: (url) => ({
127
+ title: `Your remote cache setup is almost complete.`,
128
+ type: 'success',
129
+ bodyLines: [`Connect your repository: ${url}`],
130
+ }),
131
+ },
132
+ {
133
+ code: 'nx-cloud-remote-cache-setup-visit-warn',
134
+ createMessage: (url) => ({
135
+ title: `Your Nx Cloud remote cache setup is almost complete.`,
136
+ type: 'warning',
137
+ bodyLines: [`Finish it by visiting: ${url}`],
138
+ }),
139
+ },
140
+ {
141
+ code: 'nx-cloud-remote-cache-setup-connect-warn',
142
+ createMessage: (url) => ({
143
+ title: `Your Nx Cloud remote cache setup is almost complete.`,
144
+ type: 'warning',
145
+ bodyLines: [`Connect your repository: ${url}`],
146
+ }),
147
+ },
148
+ {
149
+ code: 'remote-cache-visit-warn',
150
+ createMessage: (url) => ({
151
+ title: `Your remote cache setup is almost complete.`,
152
+ type: 'warning',
153
+ bodyLines: [`Finish it by visiting: ${url}`],
154
+ }),
155
+ },
156
+ {
157
+ code: 'remote-cache-connect-warn',
158
+ createMessage: (url) => ({
159
+ title: `Your remote cache setup is almost complete.`,
160
+ type: 'warning',
161
+ bodyLines: [`Connect your repository: ${url}`],
162
+ }),
163
+ },
164
+ ],
165
+ };
166
+ class ABTestingMessages {
167
+ constructor() {
168
+ this.selectedMessages = {};
169
+ }
170
+ getMessageFactory(key) {
171
+ if (this.selectedMessages[key] === undefined) {
172
+ if (process.env.NX_GENERATE_DOCS_PROCESS === 'true') {
173
+ this.selectedMessages[key] = 0;
174
+ }
175
+ else {
176
+ this.selectedMessages[key] = Math.floor(Math.random() * outputMessages[key].length);
177
+ }
178
+ }
179
+ return outputMessages[key][this.selectedMessages[key]];
180
+ }
181
+ }
182
+ const messages = new ABTestingMessages();
183
+ function getMessageFactory(key) {
184
+ return messages.getMessageFactory(key);
185
+ }
@@ -1,7 +1,6 @@
1
- import { PackageManager } from '../package-manager';
2
1
  export type NxCloud = 'yes' | 'github' | 'circleci' | 'skip';
3
- export declare function setupNxCloud(directory: string, packageManager: PackageManager, nxCloud: NxCloud, useGitHub?: boolean): Promise<{
4
- code: number;
5
- stdout: string;
2
+ export declare function setupNxCloud(directory: string, nxCloud: NxCloud, useGitHub?: boolean): Promise<string>;
3
+ export declare function getOnboardingInfo(nxCloud: NxCloud, token: string, directory: string, useGithub?: boolean): Promise<{
4
+ output: string;
5
+ connectCloudUrl: string;
6
6
  }>;
7
- export declare function printNxCloudSuccessMessage(nxCloudOut: string): void;
@@ -1,24 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupNxCloud = setupNxCloud;
4
- exports.printNxCloudSuccessMessage = printNxCloudSuccessMessage;
4
+ exports.getOnboardingInfo = getOnboardingInfo;
5
5
  const ora = require("ora");
6
- const child_process_utils_1 = require("../child-process-utils");
7
6
  const output_1 = require("../output");
8
- const package_manager_1 = require("../package-manager");
9
7
  const error_utils_1 = require("../error-utils");
10
- async function setupNxCloud(directory, packageManager, nxCloud, useGitHub) {
8
+ const messages_1 = require("./messages");
9
+ async function setupNxCloud(directory, nxCloud, useGitHub) {
11
10
  const nxCloudSpinner = ora(`Setting up Nx Cloud`).start();
12
11
  try {
13
- const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
14
- const res = await (0, child_process_utils_1.execAndWait)(`${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=create-nx-workspace --directory=${directory} ${useGitHub ? '--github' : ''} --no-interactive`, directory);
15
- if (nxCloud !== 'yes') {
16
- nxCloudSpinner.succeed('CI workflow with Nx Cloud has been generated successfully');
12
+ // nx-ignore-next-line
13
+ const { connectWorkspaceToCloud } = require(require.resolve('nx/src/command-line/connect/connect-to-nx-cloud', {
14
+ paths: [directory],
17
15
  }
18
- else {
19
- nxCloudSpinner.succeed('Nx Cloud has been set up successfully');
20
- }
21
- return res;
16
+ // nx-ignore-next-line
17
+ ));
18
+ const accessToken = await connectWorkspaceToCloud({
19
+ installationSource: 'create-nx-workspace',
20
+ directory,
21
+ github: useGitHub,
22
+ });
23
+ nxCloudSpinner.succeed('Nx Cloud has been set up successfully');
24
+ return accessToken;
22
25
  }
23
26
  catch (e) {
24
27
  nxCloudSpinner.fail();
@@ -37,19 +40,26 @@ async function setupNxCloud(directory, packageManager, nxCloud, useGitHub) {
37
40
  nxCloudSpinner.stop();
38
41
  }
39
42
  }
40
- function printNxCloudSuccessMessage(nxCloudOut) {
41
- // remove leading Nx carret and any new lines
42
- const logContent = nxCloudOut.split('NX ')[1];
43
- const indexOfTitleEnd = logContent.indexOf('\n');
44
- const title = logContent.slice(0, logContent.indexOf('\n')).trim();
45
- const bodyLines = logContent
46
- .slice(indexOfTitleEnd)
47
- .replace(/^\n*/, '') // remove leading new lines
48
- .replace(/\n*$/, '') // remove trailing new lines
49
- .split('\n')
50
- .map((r) => r.trim());
51
- output_1.output.warn({
52
- title,
53
- bodyLines,
54
- });
43
+ async function getOnboardingInfo(nxCloud, token, directory, useGithub) {
44
+ // nx-ignore-next-line
45
+ const { createNxCloudOnboardingURL } = require(require.resolve('nx/src/nx-cloud/utilities/url-shorten', {
46
+ paths: [directory],
47
+ }
48
+ // nx-ignore-next-line
49
+ ));
50
+ const source = nxCloud === 'yes'
51
+ ? 'create-nx-workspace-success-cache-setup'
52
+ : 'create-nx-workspace-success-ci-setup';
53
+ const { code, createMessage } = (0, messages_1.getMessageFactory)(source);
54
+ const connectCloudUrl = await createNxCloudOnboardingURL(source, token, useGithub ??
55
+ (nxCloud === 'yes' || nxCloud === 'github' || nxCloud === 'circleci'), code);
56
+ const out = new output_1.CLIOutput(false);
57
+ const message = createMessage(connectCloudUrl);
58
+ if (message.type === 'success') {
59
+ out.success(message);
60
+ }
61
+ else {
62
+ out.warn(message);
63
+ }
64
+ return { output: out.getOutput(), connectCloudUrl };
55
65
  }
@@ -15,7 +15,10 @@ export interface CLISuccessMessageConfig {
15
15
  title: string;
16
16
  bodyLines?: string[];
17
17
  }
18
- declare class CLIOutput {
18
+ export declare class CLIOutput {
19
+ private real;
20
+ private outstream;
21
+ constructor(real?: boolean);
19
22
  /**
20
23
  * Longer dash character which forms more of a continuous line when place side to side
21
24
  * with itself, unlike the standard dash character
@@ -53,6 +56,6 @@ declare class CLIOutput {
53
56
  log({ title, bodyLines, color }: CLIWarnMessageConfig & {
54
57
  color?: string;
55
58
  }): void;
59
+ getOutput(): string;
56
60
  }
57
61
  export declare const output: CLIOutput;
58
- export {};
@@ -4,7 +4,7 @@
4
4
  * we duplicate the helper functions from @nx/workspace in this file.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.output = void 0;
7
+ exports.output = exports.CLIOutput = void 0;
8
8
  const chalk = require("chalk");
9
9
  const os_1 = require("os");
10
10
  const is_ci_1 = require("./ci/is-ci");
@@ -15,7 +15,9 @@ if ((0, is_ci_1.isCI)()) {
15
15
  chalk.level = 0;
16
16
  }
17
17
  class CLIOutput {
18
- constructor() {
18
+ constructor(real = true) {
19
+ this.real = real;
20
+ this.outstream = this.real ? process.stdout : new FakeStdout();
19
21
  /**
20
22
  * Expose some color and other utility functions so that other parts of the codebase that need
21
23
  * more fine-grained control of message bodies are still using a centralized
@@ -45,7 +47,7 @@ class CLIOutput {
45
47
  return divider;
46
48
  }
47
49
  writeToStdOut(str) {
48
- process.stdout.write(str);
50
+ this.outstream.write(str);
49
51
  }
50
52
  writeOutputTitle({ color, title, }) {
51
53
  this.writeToStdOut(`${this.applyCLIPrefix(color, title)}${os_1.EOL}`);
@@ -134,5 +136,20 @@ class CLIOutput {
134
136
  this.writeOptionalOutputBody(bodyLines);
135
137
  this.addNewline();
136
138
  }
139
+ getOutput() {
140
+ return this.outstream.toString();
141
+ }
137
142
  }
143
+ exports.CLIOutput = CLIOutput;
138
144
  exports.output = new CLIOutput();
145
+ class FakeStdout {
146
+ constructor() {
147
+ this.content = '';
148
+ }
149
+ write(str) {
150
+ this.content += str;
151
+ }
152
+ toString() {
153
+ return this.content;
154
+ }
155
+ }