@@ -83,80 +83,64 @@ async function printSuccessMessage(
83
83
usesGithub ?: boolean ,
84
84
directory ?: string
85
85
) {
86
- if ( process . env . NX_NEW_CLOUD_ONBOARDING !== 'true' ) {
87
- let origin = 'https://nx.app' ;
88
- try {
89
- origin = new URL ( url ) . origin ;
90
- } catch ( e ) { }
86
+ const connectCloudUrl = await shortenedCloudUrl (
87
+ installationSource ,
88
+ token ,
89
+ usesGithub
90
+ ) ;
91
91
92
- output . note ( {
93
- title : `Your Nx Cloud workspace is public` ,
94
- bodyLines : [
95
- `To restrict access, connect it to your Nx Cloud account:` ,
96
- `- Push your changes` ,
97
- `- Login at ${ origin } to connect your repository` ,
98
- ] ,
99
- } ) ;
92
+ if ( installationSource === 'nx-connect' && usesGithub ) {
93
+ try {
94
+ const cloudConnectSpinner = ora (
95
+ `Opening Nx Cloud ${ connectCloudUrl } in your browser to connect your workspace.`
96
+ ) . start ( ) ;
97
+ await sleep ( 2000 ) ;
98
+ open ( connectCloudUrl ) ;
99
+ cloudConnectSpinner . succeed ( ) ;
100
+ } catch ( e ) {
101
+ output . note ( {
102
+ title : `Your Nx Cloud workspace is ready.` ,
103
+ bodyLines : [
104
+ `To claim it, connect it to your Nx Cloud account:` ,
105
+ `- Go to the following URL to connect your workspace to Nx Cloud:` ,
106
+ '' ,
107
+ `${ connectCloudUrl } ` ,
108
+ ] ,
109
+ } ) ;
110
+ }
100
111
} else {
101
- const connectCloudUrl = await shortenedCloudUrl (
102
- installationSource ,
103
- token ,
104
- usesGithub
105
- ) ;
106
-
107
- if ( installationSource === 'nx-connect' && usesGithub ) {
108
- try {
109
- const cloudConnectSpinner = ora (
110
- `Opening Nx Cloud ${ connectCloudUrl } in your browser to connect your workspace.`
111
- ) . start ( ) ;
112
- await sleep ( 2000 ) ;
113
- open ( connectCloudUrl ) ;
114
- cloudConnectSpinner . succeed ( ) ;
115
- } catch ( e ) {
116
- output . note ( {
117
- title : `Your Nx Cloud workspace is ready.` ,
118
- bodyLines : [
119
- `To claim it, connect it to your Nx Cloud account:` ,
120
- `- Go to the following URL to connect your workspace to Nx Cloud:` ,
121
- '' ,
122
- `${ connectCloudUrl } ` ,
123
- ] ,
124
- } ) ;
125
- }
126
- } else {
127
- if ( installationSource === 'create-nx-workspace' ) {
128
- output . note ( {
129
- title : `Your Nx Cloud workspace is ready.` ,
130
- bodyLines : [
131
- `To claim it, connect it to your Nx Cloud account:` ,
132
- `- Push your repository to your git hosting provider.` ,
133
- `- Go to the following URL to connect your workspace to Nx Cloud:` ,
134
- '' ,
135
- `${ connectCloudUrl } ` ,
136
- ] ,
137
- } ) ;
138
- commitChanges (
139
- `feat(nx): Added Nx Cloud token to your nx.json
112
+ if ( installationSource === 'create-nx-workspace' ) {
113
+ output . note ( {
114
+ title : `Your Nx Cloud workspace is ready.` ,
115
+ bodyLines : [
116
+ `To claim it, connect it to your Nx Cloud account:` ,
117
+ `- Push your repository to your git hosting provider.` ,
118
+ `- Go to the following URL to connect your workspace to Nx Cloud:` ,
119
+ '' ,
120
+ `${ connectCloudUrl } ` ,
121
+ ] ,
122
+ } ) ;
123
+ commitChanges (
124
+ `feat(nx): Added Nx Cloud token to your nx.json
140
125
141
126
To connect your workspace to Nx Cloud, push your repository
142
127
to your git hosting provider and go to the following URL:
143
128
144
129
${ connectCloudUrl } ` ,
145
- directory
146
- ) ;
147
- } else {
148
- output . note ( {
149
- title : `Your Nx Cloud workspace is ready.` ,
150
- bodyLines : [
151
- `To claim it, connect it to your Nx Cloud account:` ,
152
- `- Commit and push your changes.` ,
153
- `- Create a pull request for the changes.` ,
154
- `- Go to the following URL to connect your workspace to Nx Cloud:` ,
155
- '' ,
156
- `${ connectCloudUrl } ` ,
157
- ] ,
158
- } ) ;
159
- }
130
+ directory
131
+ ) ;
132
+ } else {
133
+ output . note ( {
134
+ title : `Your Nx Cloud workspace is ready.` ,
135
+ bodyLines : [
136
+ `To claim it, connect it to your Nx Cloud account:` ,
137
+ `- Commit and push your changes.` ,
138
+ `- Create a pull request for the changes.` ,
139
+ `- Go to the following URL to connect your workspace to Nx Cloud:` ,
140
+ '' ,
141
+ `${ connectCloudUrl } ` ,
142
+ ] ,
143
+ } ) ;
160
144
}
161
145
}
162
146
}
@@ -200,65 +184,45 @@ export async function connectToNxCloud(
200
184
printCloudConnectionDisabledMessage ( ) ;
201
185
} ;
202
186
} else {
203
- if ( process . env . NX_NEW_CLOUD_ONBOARDING !== 'true' ) {
204
- // TODO: Change to using loading light client when that is enabled by default
205
- const r = await createNxCloudWorkspace (
187
+ const usesGithub = await repoUsesGithub ( schema . github ) ;
188
+
189
+ let responseFromCreateNxCloudWorkspace :
190
+ | {
191
+ token : string ;
192
+ url : string ;
193
+ }
194
+ | undefined ;
195
+
196
+ // do NOT create Nx Cloud token (createNxCloudWorkspace)
197
+ // if user is using github and is running nx-connect
198
+ if ( ! ( usesGithub && schema . installationSource === 'nx-connect' ) ) {
199
+ responseFromCreateNxCloudWorkspace = await createNxCloudWorkspace (
206
200
getRootPackageName ( tree ) ,
207
201
schema . installationSource ,
208
202
getNxInitDate ( )
209
203
) ;
210
204
211
- addNxCloudOptionsToNxJson ( tree , nxJson , r . token ) ;
205
+ addNxCloudOptionsToNxJson (
206
+ tree ,
207
+ nxJson ,
208
+ responseFromCreateNxCloudWorkspace ?. token
209
+ ) ;
212
210
213
211
await formatChangedFilesWithPrettierIfAvailable ( tree , {
214
212
silent : schema . hideFormatLogs ,
215
213
} ) ;
216
-
217
- return async ( ) =>
218
- await printSuccessMessage ( r . url , r . token , schema . installationSource ) ;
219
- } else {
220
- const usesGithub = await repoUsesGithub ( schema . github ) ;
221
-
222
- let responseFromCreateNxCloudWorkspace :
223
- | {
224
- token : string ;
225
- url : string ;
226
- }
227
- | undefined ;
228
-
229
- // do NOT create Nx Cloud token (createNxCloudWorkspace)
230
- // if user is using github and is running nx-connect
231
- if ( ! ( usesGithub && schema . installationSource === 'nx-connect' ) ) {
232
- responseFromCreateNxCloudWorkspace = await createNxCloudWorkspace (
233
- getRootPackageName ( tree ) ,
234
- schema . installationSource ,
235
- getNxInitDate ( )
236
- ) ;
237
-
238
- addNxCloudOptionsToNxJson (
239
- tree ,
240
- nxJson ,
241
- responseFromCreateNxCloudWorkspace ?. token
242
- ) ;
243
-
244
- await formatChangedFilesWithPrettierIfAvailable ( tree , {
245
- silent : schema . hideFormatLogs ,
246
- } ) ;
247
- }
248
- const apiUrl = removeTrailingSlash (
249
- process . env . NX_CLOUD_API ||
250
- process . env . NRWL_API ||
251
- `https://cloud.nx.app`
252
- ) ;
253
- return async ( ) =>
254
- await printSuccessMessage (
255
- responseFromCreateNxCloudWorkspace ?. url ?? apiUrl ,
256
- responseFromCreateNxCloudWorkspace ?. token ,
257
- schema . installationSource ,
258
- usesGithub ,
259
- schema . directory
260
- ) ;
261
214
}
215
+ const apiUrl = removeTrailingSlash (
216
+ process . env . NX_CLOUD_API || process . env . NRWL_API || `https://cloud.nx.app`
217
+ ) ;
218
+ return async ( ) =>
219
+ await printSuccessMessage (
220
+ responseFromCreateNxCloudWorkspace ?. url ?? apiUrl ,
221
+ responseFromCreateNxCloudWorkspace ?. token ,
222
+ schema . installationSource ,
223
+ usesGithub ,
224
+ schema . directory
225
+ ) ;
262
226
}
263
227
}
264
228
0 commit comments