@@ -8,6 +8,10 @@ const execa = require("execa");
8
8
// reading and writing in out/ folder
9
9
const fs = require ( "fs" ) ;
10
10
11
+ // TODO change this
12
+ const cloudflareEmail = "me@bpmct.net" ;
13
+ const cloudflareDomain = "coding.pics" ;
14
+
11
15
require ( "dotenv" ) . config ( ) ;
12
16
13
17
const runHelperScript = async ( filename , params ) => {
@@ -90,6 +94,11 @@ export async function cli(args) {
90
94
alias : "n" ,
91
95
description : "Name for Coder subdomain" ,
92
96
} )
97
+ . option ( "namespace" , {
98
+ type : "string" ,
99
+ default : "coder" ,
100
+ description : "Namespace for Coder" ,
101
+ } )
93
102
. option ( "gcloud-project-id" , {
94
103
type : "string" ,
95
104
} )
@@ -206,9 +215,6 @@ export async function cli(args) {
206
215
} catch ( err ) {
207
216
// reset projects list
208
217
projects = [ ] ;
209
-
210
- // TODO: ensure it is actually no biggie
211
- console . log ( "Ran into an error fetching your projects... No biggie 🙂" ) ;
212
218
}
213
219
214
220
// show a select field if we found a list
@@ -227,7 +233,11 @@ export async function cli(args) {
227
233
choices : projects ,
228
234
} ) ) ,
229
235
} ;
230
- } else
236
+ } else {
237
+ console . log (
238
+ "🤔 We couldn't determine if you have any Google Cloud Projects.\n" ,
239
+ "\t➡️ Create one here: https://console.cloud.google.com/projectcreate"
240
+ ) ;
231
241
argv = {
232
242
...argv ,
233
243
...( await inquirer . prompt ( {
@@ -251,10 +261,13 @@ export async function cli(args) {
251
261
] ,
252
262
} ) ) ,
253
263
} ;
264
+ }
254
265
}
255
266
256
267
let gCloudCommand = generateGoogleClusterCommand ( argv ) ;
257
268
269
+ // TODO: add info on what this cluster means
270
+
258
271
// TODO: impliment pricing calculations with Google API
259
272
let pricing_info = "" ;
260
273
@@ -300,9 +313,9 @@ export async function cli(args) {
300
313
301
314
if ( ! runCommand . runIt ) {
302
315
console . log (
303
- `\n\nOk :) Feel free to modify the command as needed, run it yourself, then you can run "launch-coder --mode k8s" to install Coder on the cluster you manually created`
316
+ `\n\nOk :) Feel free to modify the command as needed, run it yourself, then you can run "launch-coder --method k8s" to install Coder on the cluster you manually created`
304
317
) ;
305
- return 0 ;
318
+ return ;
306
319
}
307
320
}
308
321
@@ -332,12 +345,17 @@ export async function cli(args) {
332
345
) ;
333
346
await fs . chmodSync ( argv . saveDir + "/createCluster.sh" , "755" ) ;
334
347
348
+ // TODO: find a way to actually make live updates work
349
+ // or point the user to the URL to watch live.
350
+ // ex. https://console.cloud.google.com/kubernetes/clusters/details/us-central1-a/coder/details?project=kubernetes-cluster-302420
351
+ // we have all the info
335
352
console . log ( "\n⏳ Creating your cluster. This will take a few minutes..." ) ;
336
353
337
354
try {
338
355
const subprocess = execa ( "/bin/sh" , [ argv . saveDir + "/createCluster.sh" ] ) ;
339
356
subprocess . stdout . pipe ( process . stdout ) ;
340
357
const { stdout } = await subprocess ;
358
+ // TODO: consolidate the spacers
341
359
console . log ( "------------" ) ;
342
360
console . log (
343
361
"✅" ,
@@ -375,9 +393,9 @@ export async function cli(args) {
375
393
// TODO: add checks to ensure the user has a cluster,
376
394
// and it has the necessary stuff for Coder
377
395
console . log (
378
- "This script does not currently verify that you cluster is ready for Coder yet .\n\nWe recommend checking the docs before continuing:"
396
+ "This script does not currently verify that your cluster is ready for Coder.\n\nWe recommend checking the docs before continuing:"
379
397
) ;
380
- console . log ( "\t➡️ https://coder.com/docs/setup/requirements" ) ;
398
+ console . log ( "\t➡️ https://coder.com/docs/setup/requirements\n " ) ;
381
399
382
400
if ( ! argv . skipConfirmPrompts ) {
383
401
const runCommand = await inquirer . prompt ( {
@@ -406,7 +424,7 @@ export async function cli(args) {
406
424
message : "What type of domain would you like to use?" ,
407
425
choices : [
408
426
{
409
- name : `A free domain from Coder (ex. [myname].${ process . env . CLOUDFLARE_DOMAIN } )` ,
427
+ name : `A free domain from Coder (ex. [myname].${ cloudflareDomain } )` ,
410
428
value : "auto" ,
411
429
} ,
412
430
{
@@ -420,13 +438,40 @@ export async function cli(args) {
420
438
] ,
421
439
} ) ) ,
422
440
} ;
441
+ } else {
442
+ console . log ( "------------" ) ;
423
443
}
424
444
425
445
// validate domainType
426
446
if ( argv . domainType == "auto" ) {
427
- console . log ( "AUTOMA" ) ;
447
+ // check if we have the cloudflare token
448
+ if ( ! process . env . DOMAIN_TOKEN ) {
449
+ console . log (
450
+ "\n🔒 At this time, you need a special token from a Coder rep to get a subdomain\n" +
451
+ "For more info, join our Slack Community: https://cdr.co/join-community"
452
+ ) ;
453
+ return ;
454
+ }
455
+
456
+ // sha256 validate the token
457
+ // used for verifying domain token
458
+ var sha256 = require ( "js-sha256" ) ;
459
+
460
+ // verify the token
461
+ // TODO: potentially do this server-side so that expired tokens
462
+ // don't get improperly verified on an old local version
463
+ if (
464
+ sha256 ( process . env . DOMAIN_TOKEN ) !=
465
+ "7d3eb96148c592b64ddfb4f3038a329acc22ea94669780dfa9de85b768ed27b1"
466
+ ) {
467
+ console . log ( "\n❌ The domain token you supplied is not valid." ) ;
468
+ return ;
469
+ }
470
+
471
+ // hello
428
472
} else if ( argv . domainType == "cloud-dns" ) {
429
473
console . log ( "Well, this is coming soon 💀" ) ;
474
+ return 0 ;
430
475
} else if ( argv . domainType == "none" ) {
431
476
console . log (
432
477
"\nWarning: This means you can't use Coder with DevURLs, a primary way of accessing web services\ninside of a Coder Workspace:\n" ,
@@ -435,7 +480,7 @@ export async function cli(args) {
435
480
) ;
436
481
437
482
console . log (
438
- "You can always add a domain later, and use a custom provider via our docs."
483
+ "You can always add a domain later, and use a custom provider via our docs.\n "
439
484
) ;
440
485
441
486
// TODO: add confirmations
@@ -447,5 +492,7 @@ export async function cli(args) {
447
492
448
493
// install and access Coder
449
494
495
+ // TODO: tell the user they can save this to a PRIVATE
496
+ // repo in GIT (maybe idk if that is bad practice)
450
497
console . log ( "\n\nat the end with a long argv:" , Object . keys ( argv ) . length ) ;
451
498
}
0 commit comments