forked from trailheadapps/ecars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecarsDeploy.js
662 lines (600 loc) · 20.6 KB
/
ecarsDeploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
'use strict';
const sh = require('shelljs');
const { execFileSync } = require('child_process');
const chalk = require('chalk');
const wrap = require('wrap-ansi');
const { prompt } = require('enquirer');
const {
validateAppName,
getDefaultDevHub,
generateUniqueAppName,
checkForRequiredCommands,
isHerokuLoggedIn
} = require('./utils');
const log = console.log;
// Exit immediately on first error
sh.set('-e');
const isWin = process.platform === 'win32';
const COMMAND_DELIMITER = isWin ? ' & ^' : ' ; \\';
let isScratchOrgCreated = false;
sh.env.VAPID_PUBLIC_KEY = '';
sh.env.VAPID_PRIVATE_KEY = '';
sh.env.VAPID_EMAIL = '[email protected]';
sh.env.SF_USERNAME = '';
sh.env.SF_PASSWORD = '';
sh.env.SF_LOGIN_URL = 'https://test.salesforce.com';
sh.env.DATABASE_PWA_URL = '';
sh.env.DATABASE_REALTIME_URL = '';
sh.env.HEROKU_PWA_URL = '';
sh.env.HEROKU_SERVICES_URL = '';
sh.env.HEROKU_MQTT_URL = '';
sh.env.PROJECT_ROOT_DIR = sh
.exec('git rev-parse --show-toplevel')
.toString()
.replace(/\n+$/, '');
sh.env.CURRENT_BRANCH = sh
.exec('git branch --show-current', {
silent: true
})
.toString()
.replace(/\n+$/, '');
log('');
log(chalk.bgWhite.green.bold(' *** Welcome to eCars Sample App *** '));
log('');
/*
* Run setup steps
*/
(async () => {
// Show explanation text to the user
showExplanation();
// Check that required CLI commands are installed
const requiredCmds = ['git', 'node', 'sfdx', 'heroku'];
log(
chalk.bold(
`*** Checking for required commands: ${requiredCmds.join(', ')}`
)
);
await checkForRequiredCommands(requiredCmds);
isHerokuLoggedIn();
log(chalk.green('*** ✔ Done checking for required commands.'));
// Run the commands in the rest of this script from the root directory
sh.cd(sh.env.PROJECT_ROOT_DIR);
// Ask user to input values needed for the deploy
await get_user_input();
log('');
log('*** Starting the eCars sample app setup ***');
sf_org_setup();
mqtt_broker_setup();
realtime_setup();
pwa_setup();
heroku_services_setup();
showFinalInstructions();
showCleanupInstructions();
sh.exit();
})();
function showExplanation() {
const intro1 =
'This sample app is actually several apps deployed together and integrated with ' +
'with each other to show an example of how you might solve a specific ' +
'business problem using the full spectrum of the Salesforce Platform.';
const intro2 =
'Here is what will be deployed. Note that in order to deploy this ' +
`you\'ll need to have a ${chalk.bold(
'paid Heroku account'
)} and be subscribed to ` +
`the ${chalk.bold('Heroku Eco')} and ${chalk.bold(
'Heroku Postgres Mini'
)} plans.`;
const steps = `
${chalk.bold(
'1'
)}. Create and push source to a Salesforce scratch org (see force-app directory).
${chalk.bold(
'2'
)}. Deploy a Heroku application to serve as MQTT broker (see apps/ecars-mqtt-broker directory)
${chalk.bold(
'3'
)}. Deploy a Heroku application to manage streaming event data (see apps/ecars-realtime directory)
${chalk.bold(
'4'
)}. Deploy a Heroku application that is a customer-facing Progressive Web App (PWA) (see apps/ecars-pwa directory)
${chalk.bold(
'5'
)}. Deploy a Heroku application to provide additional functionality not available natively in Salesforce (see apps/ears-services directory)`;
log(wrap(intro1, 80));
log('');
log(wrap(intro2, 80));
log(wrap(steps, 80));
log('');
}
async function get_user_input() {
log('');
log(chalk.bold('*** Please provide the following information: '));
const response = await prompt([
{
type: 'input',
name: 'devhub',
message: 'Existing SFDX DevHub Alias',
initial: getDefaultDevHub
},
{
type: 'input',
name: 'scratchorg',
message: 'SFDX Scratch Org Alias',
initial: 'ecars'
},
{
type: 'input',
name: 'ecars-pwa',
message: 'eCars PWA Heroku App Name',
initial: generateUniqueAppName,
validate: validateAppName
},
{
type: 'input',
name: 'ecars-mqtt',
message: 'eCars MQTT Heroku App Name',
initial: generateUniqueAppName,
validate: validateAppName
},
{
type: 'input',
name: 'ecars-rt',
message: 'eCars Realtime Heroku App Name',
initial: generateUniqueAppName,
validate: validateAppName
},
{
type: 'input',
name: 'ecars-serv',
message: 'eCars Services Heroku App Name',
initial: generateUniqueAppName,
validate: validateAppName
}
]);
sh.env.SFDX_DEV_HUB = response.devhub;
sh.env.SFDX_SCRATCH_ORG = response.scratchorg;
sh.env.HEROKU_PWA_APP_NAME = response['ecars-pwa'];
sh.env.HEROKU_MQTT_APP_NAME = response['ecars-mqtt'];
sh.env.HEROKU_REALTIME_APP_NAME = response['ecars-rt'];
sh.env.HEROKU_SERVICES_APP_NAME = response['ecars-serv'];
}
/*
* Create a scratch org, push source to it, apply permset, and save user login details
*/
function sf_org_setup(..._$args) {
log('');
log(
`${chalk.bold('*** Setting up Salesforce App')} ${chalk.dim(
'(step 1 of 5)'
)}`
);
log('*** Creating scratch org');
sh.exec(
`sfdx force:org:create -s -f config/project-scratch-def.json -a ${sh.env.SFDX_SCRATCH_ORG} -d 30 -v ${sh.env.SFDX_DEV_HUB}`
);
isScratchOrgCreated = true;
log(`*** Updating source with Heroku app URLs`);
sh.sed(
'-i',
/wss:\/\/.*(\.herokuapp\.com)/,
`wss://${sh.env.HEROKU_REALTIME_APP_NAME}$1`,
'force-app/main/default/cspTrustedSites/WebSockets.cspTrustedSite-meta.xml'
);
sh.sed(
'-i',
/wss:\/\/.*(\.herokuapp\.com)/,
`wss://${sh.env.HEROKU_REALTIME_APP_NAME}$1`,
'force-app/main/default/lwc/liveData/liveData.js'
);
sh.sed(
'-i',
/https:\/\/.*(\.herokuapp\.com)/,
`https:\/\/${sh.env.HEROKU_SERVICES_APP_NAME}$1`,
'force-app/main/default/namedCredentials/Heroku_App.namedCredential-meta.xml'
);
// Use execFileSync because shelljs does not handle either the progress
// bar or errors correctly running this command.
log('*** Pushing source to scratch org');
execFileSync('sfdx', ['force:source:push'], { stdio: 'inherit' });
log('*** Assigning permission sets');
sh.exec('sfdx force:user:permset:assign -n ecars,Walkthroughs');
log('*** Loading sample data');
sh.exec('sfdx force:data:tree:import --plan ./data/data-plan.json');
log('*** Generating user password');
sh.exec('sfdx force:user:password:generate');
log('*** Fetching user data');
const userData = JSON.parse(
sh.exec('sfdx force:user:display --json', { silent: true })
);
sh.env.SF_USERNAME = userData.result.username;
sh.env.SF_PASSWORD = userData.result.password;
log(chalk.green('*** ✔ Done with the Salesforce scratch org setup'));
}
function mqtt_broker_setup(..._$args) {
log('');
log(
`${chalk.bold('*** Setting up MQTT Broker Heroku app')} ${chalk.dim(
'(step 2 of 5)'
)}`
);
sh.cd('apps/ecars-mqtt-broker');
log(`*** Creating Heroku app ${chalk.bold(sh.env.HEROKU_MQTT_APP_NAME)}`);
const appData = JSON.parse(
sh.exec(
`heroku apps:create ${sh.env.HEROKU_MQTT_APP_NAME} --json --buildpack https://github.com/lstoll/heroku-buildpack-monorepo.git`,
{ silent: true }
)
);
sh.env.HEROKU_MQTT_APP_NAME = appData.name;
sh.env.HEROKU_MQTT_URL = appData.web_url.replace(
/(http)(s)?\:\/\//,
'ws$2://'
);
log('*** Adding Node.js Buildpack');
sh.exec(
`heroku buildpacks:add -a ${sh.env.HEROKU_MQTT_APP_NAME} heroku/nodejs`,
{ silent: true }
);
log('*** Setting remote configuration parameters');
sh.exec(
`heroku config:set APP_BASE=apps/ecars-mqtt-broker -a ${sh.env.HEROKU_MQTT_APP_NAME}`,
{ silent: true }
);
log('*** Pushing app to Heroku');
sh.cd('../../');
sh.exec(
`git push https://git.heroku.com/${sh.env.HEROKU_MQTT_APP_NAME}.git ${sh.env.CURRENT_BRANCH}:main`
);
log(
chalk.green(
`*** ✔ Done deploying Heroku app ${chalk.bold(
sh.env.HEROKU_MQTT_APP_NAME
)}`
)
);
}
function realtime_setup(..._$args) {
log('');
log(
`${chalk.bold('*** Setting up streaming data Heroku app')} ${chalk.dim(
'(step 3 of 5)'
)}`
);
sh.cd('apps/ecars-realtime');
log(
`*** Creating Heroku app ${chalk.bold(sh.env.HEROKU_REALTIME_APP_NAME)}`
);
const appData = JSON.parse(
sh.exec(
`heroku apps:create ${sh.env.HEROKU_REALTIME_APP_NAME} --json --buildpack https://github.com/lstoll/heroku-buildpack-monorepo.git`,
{ silent: true }
)
);
sh.env.HEROKU_REALTIME_APP_NAME = appData.name;
log('*** Adding Node.js Buildpack');
sh.exec(
`heroku buildpacks:add -a ${sh.env.HEROKU_REALTIME_APP_NAME} heroku/nodejs`,
{ silent: true }
);
log('*** Creating Heroku Postgres database (Mini)');
sh.exec(
`heroku addons:create heroku-postgresql:mini -a ${sh.env.HEROKU_REALTIME_APP_NAME} --wait`,
{ silent: true }
);
sh.env.DATABASE_REALTIME_URL = sh
.exec(
`heroku config:get DATABASE_URL -a ${sh.env.HEROKU_REALTIME_APP_NAME}`,
{
silent: true
}
)
.toString()
.replace(/\n+$/, '');
log('*** Setting remote configuration parameters');
sh.exec(
`heroku config:set APP_BASE=apps/ecars-realtime SIMULATOR_INTERVAL=500 MQTT_BROKER_URL=${sh.env.HEROKU_MQTT_URL} -a ${sh.env.HEROKU_REALTIME_APP_NAME}`,
{ silent: true }
);
log('*** Writing .env file for local development');
sh.echo('DATABASE_URL=' + sh.env.DATABASE_REALTIME_URL).toEnd('.env');
sh.echo('MQTT_BROKER_URL=' + sh.env.HEROKU_MQTT_URL).toEnd('.env');
log('*** Pushing app to Heroku');
sh.cd('../../');
sh.exec(
`git push https://git.heroku.com/${sh.env.HEROKU_REALTIME_APP_NAME}.git ${sh.env.CURRENT_BRANCH}:main`
);
log('*** Starting Simulator Worker');
sh.exec(
`heroku ps:scale sensor-simulator=1 -a ${sh.env.HEROKU_REALTIME_APP_NAME}`,
{
silent: true
}
);
log('*** Provisioning Database');
execFileSync('heroku', [
'run',
"'cd packages/ecars-db && npx sequelize db:migrate'",
'-a',
sh.env.HEROKU_REALTIME_APP_NAME
]);
log(
chalk.green(
`*** ✔ Done deploying Heroku app ${chalk.bold(
sh.env.HEROKU_REALTIME_APP_NAME
)}`
)
);
}
function pwa_setup(..._$args) {
log('');
log(
`${chalk.bold('*** Setting up PWA Heroku app')} ${chalk.dim(
'(step 4 of 5)'
)}`
);
sh.cd('apps/ecars-pwa');
log('*** Generating Vapid keys');
const vapidOutput = JSON.parse(
sh.exec('npx web-push generate-vapid-keys --json', {
silent: true
})
);
sh.env.VAPID_PUBLIC_KEY = vapidOutput.publicKey;
sh.env.VAPID_PRIVATE_KEY = vapidOutput.privateKey;
log(`*** Creating Heroku app ${chalk.bold(sh.env.HEROKU_PWA_APP_NAME)}`);
const appData = JSON.parse(
sh.exec(
`heroku apps:create ${sh.env.HEROKU_PWA_APP_NAME} --json --buildpack https://github.com/lstoll/heroku-buildpack-monorepo.git`,
{ silent: true }
)
);
sh.env.HEROKU_PWA_APP_NAME = appData.name;
sh.env.HEROKU_PWA_URL = appData.web_url;
log('*** Adding Node.js Buildpack');
sh.exec(
`heroku buildpacks:add -a ${sh.env.HEROKU_PWA_APP_NAME} heroku/nodejs`,
{
silent: true
}
);
log('*** Creating Heroku Postgres database (Mini)');
sh.exec(
`heroku addons:create heroku-postgresql:mini -a ${sh.env.HEROKU_PWA_APP_NAME}`,
{ silent: true }
);
sh.env.DATABASE_PWA_URL = sh
.exec(
`heroku config:get DATABASE_URL -a ${sh.env.HEROKU_PWA_APP_NAME}`,
{
silent: true
}
)
.toString()
.replace(/\n+$/, '');
log('*** Initializing Heroku Postgres database');
sh.exec(
`heroku run node scripts/createPostgresTable.js -a ${sh.env.HEROKU_PWA_APP_NAME}`,
{ silent: true }
);
log('*** Setting remote configuration parameters');
sh.exec(
`heroku config:set APP_BASE=apps/ecars-pwa VAPID_PUBLIC_KEY='${sh.env.VAPID_PUBLIC_KEY}' VAPID_PRIVATE_KEY='${sh.env.VAPID_PRIVATE_KEY}' VAPID_EMAIL='${sh.env.VAPID_EMAIL}' SF_USERNAME='${sh.env.SF_USERNAME}' SF_PASSWORD='${sh.env.SF_PASSWORD}' SF_LOGIN_URL='${sh.env.SF_LOGIN_URL}' -a ${sh.env.HEROKU_PWA_APP_NAME}`,
{ silent: true }
);
log('*** Writing .env file for local development');
sh.echo('VAPID_PUBLIC_KEY=' + sh.env.VAPID_PUBLIC_KEY).to('.env');
sh.echo('VAPID_PRIVATE_KEY=' + sh.env.VAPID_PRIVATE_KEY).toEnd('.env');
sh.echo('VAPID_EMAIL=' + sh.env.VAPID_EMAIL).toEnd('.env');
sh.echo('SF_USERNAME=' + sh.env.SF_USERNAME).toEnd('.env');
sh.echo('SF_PASSWORD=' + sh.env.SF_PASSWORD).toEnd('.env');
sh.echo('SF_LOGIN_URL=' + sh.env.SF_LOGIN_URL).toEnd('.env');
sh.echo('DATABASE_URL=' + sh.env.DATABASE_PWA_URL).toEnd('.env');
log('*** Pushing app to Heroku');
sh.cd('../../');
sh.exec(
`git push https://git.heroku.com/${sh.env.HEROKU_PWA_APP_NAME}.git ${sh.env.CURRENT_BRANCH}:main`
);
log(
chalk.green(
`*** ✔ Done deploying Heroku app ${chalk.bold(
sh.env.HEROKU_PWA_APP_NAME
)}`
)
);
}
function heroku_services_setup(..._$args) {
log('');
log(
`${chalk.bold('*** Setting up PDF and WebPush Heroku app')} ${chalk.dim(
'(step 5 of 5)'
)}`
);
sh.cd('apps/ecars-services');
log(
`*** Creating Heroku app ${chalk.bold(sh.env.HEROKU_SERVICES_APP_NAME)}`
);
const appData = JSON.parse(
sh.exec(
`heroku apps:create ${sh.env.HEROKU_SERVICES_APP_NAME} --json --buildpack https://github.com/lstoll/heroku-buildpack-monorepo.git`,
{ silent: true }
)
);
sh.env.HEROKU_SERVICES_APP_NAME = appData.name;
sh.env.HEROKU_SERVICES_URL = appData.web_url;
log('*** Adding Node.js Buildpack');
sh.exec(
`heroku buildpacks:add -a ${sh.env.HEROKU_SERVICES_APP_NAME} heroku/nodejs`,
{ silent: true }
);
log('*** Setting remote configuration parameters');
sh.exec(
`heroku config:set APP_BASE=apps/ecars-services VAPID_PUBLIC_KEY='${sh.env.VAPID_PUBLIC_KEY}' VAPID_PRIVATE_KEY='${sh.env.VAPID_PRIVATE_KEY}' VAPID_EMAIL='${sh.env.VAPID_EMAIL}' APPLICATION_URL='${sh.env.HEROKU_PWA_URL}' DATABASE_URL='${sh.env.DATABASE_PWA_URL}' SF_USERNAME='${sh.env.SF_USERNAME}' SF_PASSWORD='${sh.env.SF_PASSWORD}' SF_LOGIN_URL=${sh.env.SF_LOGIN_URL} -a ${sh.env.HEROKU_SERVICES_APP_NAME}`,
{ silent: true }
);
log('*** Writing .env file for local development');
sh.echo('VAPID_PUBLIC_KEY=' + sh.env.VAPID_PUBLIC_KEY).to('.env');
sh.echo('VAPID_PRIVATE_KEY=' + sh.env.VAPID_PRIVATE_KEY).toEnd('.env');
sh.echo('VAPID_EMAIL=' + sh.env.VAPID_EMAIL).toEnd('.env');
sh.echo('SF_LOGIN_URL=' + sh.env.SF_LOGIN_URL).toEnd('.env');
sh.echo('SF_USERNAME=' + sh.env.SF_USERNAME).toEnd('.env');
sh.echo('SF_PASSWORD=' + sh.env.SF_PASSWORD).toEnd('.env');
sh.echo('APPLICATION_URL=' + sh.env.HEROKU_PWA_URL).toEnd('.env');
sh.echo('DATABASE_URL=' + sh.env.DATABASE_PWA_URL).toEnd('.env');
log('*** Pushing app to Heroku');
sh.cd('../../');
sh.exec(
`git push https://git.heroku.com/${sh.env.HEROKU_SERVICES_APP_NAME}.git ${sh.env.CURRENT_BRANCH}:main`
);
log(
chalk.green(
`*** ✔ Done deploying Heroku app ${chalk.bold(
sh.env.HEROKU_SERVICES_APP_NAME
)}`
)
);
}
function showFinalInstructions() {
log('');
log('');
log(
chalk.bgWhite.green.bold(
' Almost done!! Now, please complete the following steps '
)
);
log('');
log('1. Run this sfdx CLI command:');
log(
chalk.dim(
` sfdx force:org:open -u ${sh.env.SFDX_SCRATCH_ORG} -p /lightning/settings/personal/ResetApiToken/home`
)
);
log("2. Click 'Reset Security Token' on the page that the above command");
log(' opens to generate a Security Token.');
log(
'3. Copy the Security Token from your email, and add it as a Config Var'
);
log(' named SF_TOKEN to two of the Heroku apps that were just deployed');
log(
' (' +
chalk.bold(sh.env.HEROKU_SERVICES_APP_NAME) +
' and ' +
chalk.bold(sh.env.HEROKU_PWA_APP_NAME) +
'):'
);
log(' Here are the two Heroku CLI commands to run to do this:');
log(
' (Replace abc in each command with the Security Token from your email)'
);
log(
chalk.dim(
' heroku config:set --app ' +
sh.env.HEROKU_SERVICES_APP_NAME +
' SF_TOKEN=abc'
)
);
log(
chalk.dim(
' heroku config:set --app ' +
sh.env.HEROKU_PWA_APP_NAME +
' SF_TOKEN=abc'
)
);
log(
'4. (Optional) Run this sfdx CLI command, and activate the `Pulsar Bold` theme:'
);
log(
chalk.dim(
` sfdx force:org:open -u ${sh.env.SFDX_SCRATCH_ORG} -p /lightning/setup/ThemingAndBranding/home`
)
);
log(
'5. Now run the following two CLI commands to start playing with the demo:'
);
log(
` Start as a consumer interested in buying a Pulsar Motors car:
${chalk.dim('heroku open --app ' + sh.env.HEROKU_PWA_APP_NAME)}`
);
log(` Proceed as a Pulsar Motors Salesperson:
${chalk.dim(
`sfdx force:org:open -u ${sh.env.SFDX_SCRATCH_ORG} -p /lightning/n/Car_Configurator`
)}`);
log(` Finish the demo as a Pulsar Motors Service Manager:
${chalk.dim(
`sfdx force:org:open -u ${sh.env.SFDX_SCRATCH_ORG} -p /lightning/o/Case/list`
)}`);
log('');
}
function showCleanupInstructions() {
log(
'To delete everything created by this setup script run these CLI commands:'
);
log(
chalk.dim(
` sfdx force:org:delete -u ${sh.env.SFDX_SCRATCH_ORG} ${COMMAND_DELIMITER}`
)
);
if (sh.env.HEROKU_MQTT_APP_NAME)
log(
chalk.dim(
' heroku apps:destroy --app ' +
sh.env.HEROKU_MQTT_APP_NAME +
COMMAND_DELIMITER
)
);
if (sh.env.HEROKU_REALTIME_APP_NAME)
log(
chalk.dim(
' heroku apps:destroy --app ' +
sh.env.HEROKU_REALTIME_APP_NAME +
COMMAND_DELIMITER
)
);
if (sh.env.HEROKU_PWA_APP_NAME)
log(
chalk.dim(
' heroku apps:destroy --app ' +
sh.env.HEROKU_PWA_APP_NAME +
COMMAND_DELIMITER
)
);
if (sh.env.HEROKU_SERVICES_APP_NAME)
log(
chalk.dim(
' heroku apps:destroy --app ' +
sh.env.HEROKU_SERVICES_APP_NAME
)
);
log('');
if (isWin) {
log(
`Tip: If you are using PowerShell, use ${chalk.bold(
'`'
)} as command delimiter instead of ${chalk.bold(COMMAND_DELIMITER)}`
);
log('');
}
}
process.on('uncaughtException', handleError);
process.on('unhandledRejection', handleError);
function handleError(err) {
console.log('');
if (err.message && err.stack) {
console.log(chalk.red(err.message));
// console.log(err.stack);
} else {
console.log(chalk.red(err));
}
console.log('');
console.log(
`Sorry, ${chalk.red(
'an error occurred'
)}. You may need to run the following commands to delete`
);
console.log(' anything created by this script before running it again.');
console.log('');
if (isScratchOrgCreated) {
showCleanupInstructions();
}
sh.exit(1);
}