yakuza0 2.23.32-beta.2 → 2.23.34

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.
Files changed (3) hide show
  1. package/cli/index.js +575 -458
  2. package/package.json +3 -2
  3. package/utils/secret.js +159 -87
package/cli/index.js CHANGED
@@ -21,10 +21,6 @@ var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
21
21
 
22
22
  var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
23
23
 
24
- var _extends2 = require('babel-runtime/helpers/extends');
25
-
26
- var _extends3 = _interopRequireDefault(_extends2);
27
-
28
24
  var _stringify = require('babel-runtime/core-js/json/stringify');
29
25
 
30
26
  var _stringify2 = _interopRequireDefault(_stringify);
@@ -37,6 +33,10 @@ var _promise = require('babel-runtime/core-js/promise');
37
33
 
38
34
  var _promise2 = _interopRequireDefault(_promise);
39
35
 
36
+ var _extends2 = require('babel-runtime/helpers/extends');
37
+
38
+ var _extends3 = _interopRequireDefault(_extends2);
39
+
40
40
  var _regenerator = require('babel-runtime/regenerator');
41
41
 
42
42
  var _regenerator2 = _interopRequireDefault(_regenerator);
@@ -254,6 +254,36 @@ var execCmd = function execCmd(cmd) {
254
254
  };
255
255
 
256
256
  var BUILD_HEARTBEAT_FILE = '.build.heartbeat';
257
+ var BUILD_HEARTBEAT_GRACE_MS = parseInt(process.env.YK0_BUILD_HEARTBEAT_GRACE_MS || '3000', 10);
258
+ var BUILD_HEARTBEAT_DELETE_ON_FINISH = process.env.YK0_BUILD_HEARTBEAT_DELETE_ON_FINISH !== 'false';
259
+
260
+ var readTextIfExists = function readTextIfExists(filePath) {
261
+ try {
262
+ return _fs2.default.readFileSync(filePath, 'utf8').trim();
263
+ } catch (e) {
264
+ return null;
265
+ }
266
+ };
267
+
268
+ var readContainerLimitSnapshot = function readContainerLimitSnapshot() {
269
+ var memoryLimitPath = ['/sys/fs/cgroup/memory.max', '/sys/fs/cgroup/memory/memory.limit_in_bytes'].find(function (filePath) {
270
+ return readTextIfExists(filePath) !== null;
271
+ });
272
+ var memoryCurrentPath = ['/sys/fs/cgroup/memory.current', '/sys/fs/cgroup/memory/memory.usage_in_bytes'].find(function (filePath) {
273
+ return readTextIfExists(filePath) !== null;
274
+ });
275
+
276
+ return {
277
+ memoryLimit: memoryLimitPath ? readTextIfExists(memoryLimitPath) : null,
278
+ memoryCurrent: memoryCurrentPath ? readTextIfExists(memoryCurrentPath) : null,
279
+ memoryLimitPath: memoryLimitPath,
280
+ memoryCurrentPath: memoryCurrentPath,
281
+ processMemoryRss: process.memoryUsage().rss,
282
+ processMemoryHeapUsed: process.memoryUsage().heapUsed,
283
+ cpus: _os2.default.cpus().length,
284
+ loadavg: _os2.default.loadavg()
285
+ };
286
+ };
257
287
 
258
288
  var createBuildHeartbeat = function createBuildHeartbeat() {
259
289
  var apps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -263,13 +293,16 @@ var createBuildHeartbeat = function createBuildHeartbeat() {
263
293
  var timer = null;
264
294
 
265
295
  var writeHeartbeat = function writeHeartbeat() {
296
+ var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'building';
297
+ var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
298
+
266
299
  _paths2.default.mkdir(heartbeatDir);
267
- _paths2.default.write(heartbeatPath, (0, _jsonFormat2.default)({
300
+ _paths2.default.write(heartbeatPath, (0, _jsonFormat2.default)((0, _extends3.default)({
268
301
  pid: process.pid,
269
- status: 'building',
302
+ status: status,
270
303
  apps: apps,
271
304
  updatedAt: new Date().toISOString()
272
- }));
305
+ }, extra)));
273
306
  };
274
307
 
275
308
  writeHeartbeat();
@@ -277,13 +310,77 @@ var createBuildHeartbeat = function createBuildHeartbeat() {
277
310
 
278
311
  return {
279
312
  heartbeatPath: heartbeatPath,
280
- stop: function stop() {
281
- if (timer) {
282
- clearInterval(timer);
283
- timer = null;
313
+ markCompleted: function markCompleted() {
314
+ var extra = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
315
+
316
+ writeHeartbeat('completed', (0, _extends3.default)({
317
+ completedAt: new Date().toISOString()
318
+ }, extra));
319
+ },
320
+ markFailed: function markFailed(error) {
321
+ writeHeartbeat('failed', {
322
+ failedAt: new Date().toISOString(),
323
+ error: error && error.message ? error.message : String(error || ''),
324
+ failedApp: error && error.appName ? error.appName : undefined,
325
+ signal: error && error.signal ? error.signal : undefined,
326
+ exitCode: typeof (error && error.exitCode) === 'number' ? error.exitCode : undefined,
327
+ resourceSnapshot: error && error.resourceSnapshot ? error.resourceSnapshot : undefined
328
+ });
329
+ },
330
+ stop: function () {
331
+ var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
332
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
333
+
334
+ var _options$graceMs, graceMs, _options$deleteOnFini, deleteOnFinish;
335
+
336
+ return _regenerator2.default.wrap(function _callee2$(_context2) {
337
+ while (1) {
338
+ switch (_context2.prev = _context2.next) {
339
+ case 0:
340
+ _options$graceMs = options.graceMs, graceMs = _options$graceMs === undefined ? BUILD_HEARTBEAT_GRACE_MS : _options$graceMs, _options$deleteOnFini = options.deleteOnFinish, deleteOnFinish = _options$deleteOnFini === undefined ? BUILD_HEARTBEAT_DELETE_ON_FINISH : _options$deleteOnFini;
341
+
342
+
343
+ if (timer) {
344
+ clearInterval(timer);
345
+ timer = null;
346
+ }
347
+
348
+ if (deleteOnFinish) {
349
+ _context2.next = 4;
350
+ break;
351
+ }
352
+
353
+ return _context2.abrupt('return');
354
+
355
+ case 4:
356
+ if (!(graceMs > 0)) {
357
+ _context2.next = 7;
358
+ break;
359
+ }
360
+
361
+ _context2.next = 7;
362
+ return new _promise2.default(function (resolve) {
363
+ setTimeout(resolve, graceMs);
364
+ });
365
+
366
+ case 7:
367
+
368
+ _paths2.default.rm(heartbeatPath);
369
+
370
+ case 8:
371
+ case 'end':
372
+ return _context2.stop();
373
+ }
374
+ }
375
+ }, _callee2, this);
376
+ }));
377
+
378
+ function stop() {
379
+ return _ref3.apply(this, arguments);
284
380
  }
285
- _paths2.default.rm(heartbeatPath);
286
- }
381
+
382
+ return stop;
383
+ }()
287
384
  };
288
385
  };
289
386
 
@@ -339,17 +436,27 @@ var spawnBuildProcess = function spawnBuildProcess(appName) {
339
436
  return;
340
437
  }
341
438
  if (signal) {
439
+ var error = new Error('Build interrupted for ' + appName + ' with signal ' + signal);
440
+ error.appName = appName;
441
+ error.signal = signal;
442
+ error.exitCode = exitCode;
443
+ error.resourceSnapshot = readContainerLimitSnapshot();
342
444
  if (abortState) {
343
445
  abortState.stopped = true;
344
446
  }
345
- settleReject(new Error('Build interrupted for ' + appName + ' with signal ' + signal));
447
+ settleReject(error);
346
448
  return;
347
449
  }
348
450
  if (exitCode !== 0) {
451
+ var _error = new Error('Build failed for ' + appName + ' with exit code ' + exitCode);
452
+ _error.appName = appName;
453
+ _error.signal = signal;
454
+ _error.exitCode = exitCode;
455
+ _error.resourceSnapshot = readContainerLimitSnapshot();
349
456
  if (abortState) {
350
457
  abortState.stopped = true;
351
458
  }
352
- settleReject(new Error('Build failed for ' + appName + ' with exit code ' + exitCode));
459
+ settleReject(_error);
353
460
  return;
354
461
  }
355
462
  settleResolve();
@@ -396,54 +503,54 @@ var resolveCurrentPlatformId = function resolveCurrentPlatformId() {
396
503
  };
397
504
 
398
505
  var fetchJson = function () {
399
- var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(url) {
506
+ var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(url) {
400
507
  var res;
401
- return _regenerator2.default.wrap(function _callee2$(_context2) {
508
+ return _regenerator2.default.wrap(function _callee3$(_context3) {
402
509
  while (1) {
403
- switch (_context2.prev = _context2.next) {
510
+ switch (_context3.prev = _context3.next) {
404
511
  case 0:
405
- _context2.next = 2;
512
+ _context3.next = 2;
406
513
  return fetch(url, { headers: { accept: 'application/json' } });
407
514
 
408
515
  case 2:
409
- res = _context2.sent;
516
+ res = _context3.sent;
410
517
 
411
518
  if (res.ok) {
412
- _context2.next = 5;
519
+ _context3.next = 5;
413
520
  break;
414
521
  }
415
522
 
416
523
  throw new Error('Failed to fetch ' + url + ': ' + res.status + ' ' + res.statusText);
417
524
 
418
525
  case 5:
419
- _context2.next = 7;
526
+ _context3.next = 7;
420
527
  return res.json();
421
528
 
422
529
  case 7:
423
- return _context2.abrupt('return', _context2.sent);
530
+ return _context3.abrupt('return', _context3.sent);
424
531
 
425
532
  case 8:
426
533
  case 'end':
427
- return _context2.stop();
534
+ return _context3.stop();
428
535
  }
429
536
  }
430
- }, _callee2, undefined);
537
+ }, _callee3, undefined);
431
538
  }));
432
539
 
433
- return function fetchJson(_x5) {
434
- return _ref3.apply(this, arguments);
540
+ return function fetchJson(_x9) {
541
+ return _ref4.apply(this, arguments);
435
542
  };
436
543
  }();
437
544
 
438
545
  var fetchWithTimeout = function () {
439
- var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(url) {
546
+ var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(url) {
440
547
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
441
548
  var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CLN_CI_CONNECT_TIMEOUT;
442
- return _regenerator2.default.wrap(function _callee3$(_context3) {
549
+ return _regenerator2.default.wrap(function _callee4$(_context4) {
443
550
  while (1) {
444
- switch (_context3.prev = _context3.next) {
551
+ switch (_context4.prev = _context4.next) {
445
552
  case 0:
446
- _context3.next = 2;
553
+ _context4.next = 2;
447
554
  return _promise2.default.race([fetch(url, options), new _promise2.default(function (_, reject) {
448
555
  setTimeout(function () {
449
556
  reject(new Error('Request timeout for ' + url));
@@ -451,18 +558,18 @@ var fetchWithTimeout = function () {
451
558
  })]);
452
559
 
453
560
  case 2:
454
- return _context3.abrupt('return', _context3.sent);
561
+ return _context4.abrupt('return', _context4.sent);
455
562
 
456
563
  case 3:
457
564
  case 'end':
458
- return _context3.stop();
565
+ return _context4.stop();
459
566
  }
460
567
  }
461
- }, _callee3, undefined);
568
+ }, _callee4, undefined);
462
569
  }));
463
570
 
464
- return function fetchWithTimeout(_x8) {
465
- return _ref4.apply(this, arguments);
571
+ return function fetchWithTimeout(_x12) {
572
+ return _ref5.apply(this, arguments);
466
573
  };
467
574
  }();
468
575
 
@@ -506,20 +613,20 @@ var finalizeDownloadProgress = function finalizeDownloadProgress() {
506
613
  };
507
614
 
508
615
  var downloadFile = function () {
509
- var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(url, destination) {
616
+ var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(url, destination) {
510
617
  var res, tempPath, buffer;
511
- return _regenerator2.default.wrap(function _callee4$(_context4) {
618
+ return _regenerator2.default.wrap(function _callee5$(_context5) {
512
619
  while (1) {
513
- switch (_context4.prev = _context4.next) {
620
+ switch (_context5.prev = _context5.next) {
514
621
  case 0:
515
- _context4.next = 2;
622
+ _context5.next = 2;
516
623
  return fetch(url);
517
624
 
518
625
  case 2:
519
- res = _context4.sent;
626
+ res = _context5.sent;
520
627
 
521
628
  if (res.ok) {
522
- _context4.next = 5;
629
+ _context5.next = 5;
523
630
  break;
524
631
  }
525
632
 
@@ -527,66 +634,66 @@ var downloadFile = function () {
527
634
 
528
635
  case 5:
529
636
  tempPath = destination + '.download';
530
- _context4.next = 8;
637
+ _context5.next = 8;
531
638
  return _fs2.default.promises.mkdir(_path2.default.dirname(destination), { recursive: true });
532
639
 
533
640
  case 8:
534
- _context4.prev = 8;
535
- _context4.next = 11;
641
+ _context5.prev = 8;
642
+ _context5.next = 11;
536
643
  return res.buffer();
537
644
 
538
645
  case 11:
539
- buffer = _context4.sent;
646
+ buffer = _context5.sent;
540
647
 
541
648
  renderDownloadProgress(buffer.length, buffer.length);
542
- _context4.next = 15;
649
+ _context5.next = 15;
543
650
  return _fs2.default.promises.writeFile(tempPath, buffer);
544
651
 
545
652
  case 15:
546
653
  finalizeDownloadProgress();
547
- _context4.next = 18;
654
+ _context5.next = 18;
548
655
  return _fs2.default.promises.rename(tempPath, destination);
549
656
 
550
657
  case 18:
551
- _context4.next = 26;
658
+ _context5.next = 26;
552
659
  break;
553
660
 
554
661
  case 20:
555
- _context4.prev = 20;
556
- _context4.t0 = _context4['catch'](8);
662
+ _context5.prev = 20;
663
+ _context5.t0 = _context5['catch'](8);
557
664
 
558
665
  finalizeDownloadProgress();
559
- _context4.next = 25;
666
+ _context5.next = 25;
560
667
  return _fs2.default.promises.rm(tempPath, { force: true }).catch(function () {
561
668
  return undefined;
562
669
  });
563
670
 
564
671
  case 25:
565
- throw _context4.t0;
672
+ throw _context5.t0;
566
673
 
567
674
  case 26:
568
675
  case 'end':
569
- return _context4.stop();
676
+ return _context5.stop();
570
677
  }
571
678
  }
572
- }, _callee4, undefined, [[8, 20]]);
679
+ }, _callee5, undefined, [[8, 20]]);
573
680
  }));
574
681
 
575
- return function downloadFile(_x9, _x10) {
576
- return _ref5.apply(this, arguments);
682
+ return function downloadFile(_x13, _x14) {
683
+ return _ref6.apply(this, arguments);
577
684
  };
578
685
  }();
579
686
 
580
687
  var sha256File = function () {
581
- var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(filePath) {
688
+ var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(filePath) {
582
689
  var hash, stream;
583
- return _regenerator2.default.wrap(function _callee5$(_context5) {
690
+ return _regenerator2.default.wrap(function _callee6$(_context6) {
584
691
  while (1) {
585
- switch (_context5.prev = _context5.next) {
692
+ switch (_context6.prev = _context6.next) {
586
693
  case 0:
587
694
  hash = (0, _crypto.createHash)('sha256');
588
695
  stream = _fs2.default.createReadStream(filePath);
589
- _context5.next = 4;
696
+ _context6.next = 4;
590
697
  return new _promise2.default(function (resolve, reject) {
591
698
  stream.on('error', reject);
592
699
  stream.on('data', function (chunk) {
@@ -596,111 +703,111 @@ var sha256File = function () {
596
703
  });
597
704
 
598
705
  case 4:
599
- return _context5.abrupt('return', hash.digest('hex'));
706
+ return _context6.abrupt('return', hash.digest('hex'));
600
707
 
601
708
  case 5:
602
709
  case 'end':
603
- return _context5.stop();
710
+ return _context6.stop();
604
711
  }
605
712
  }
606
- }, _callee5, undefined);
713
+ }, _callee6, undefined);
607
714
  }));
608
715
 
609
- return function sha256File(_x11) {
610
- return _ref6.apply(this, arguments);
716
+ return function sha256File(_x15) {
717
+ return _ref7.apply(this, arguments);
611
718
  };
612
719
  }();
613
720
 
614
721
  var tryReplaceFile = function () {
615
- var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(sourcePath, targetPath) {
616
- return _regenerator2.default.wrap(function _callee6$(_context6) {
722
+ var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(sourcePath, targetPath) {
723
+ return _regenerator2.default.wrap(function _callee7$(_context7) {
617
724
  while (1) {
618
- switch (_context6.prev = _context6.next) {
725
+ switch (_context7.prev = _context7.next) {
619
726
  case 0:
620
- _context6.prev = 0;
621
- _context6.next = 3;
727
+ _context7.prev = 0;
728
+ _context7.next = 3;
622
729
  return _fs2.default.promises.rename(sourcePath, targetPath);
623
730
 
624
731
  case 3:
625
- return _context6.abrupt('return');
732
+ return _context7.abrupt('return');
626
733
 
627
734
  case 6:
628
- _context6.prev = 6;
629
- _context6.t0 = _context6['catch'](0);
735
+ _context7.prev = 6;
736
+ _context7.t0 = _context7['catch'](0);
630
737
 
631
- if (!(_context6.t0.code !== 'EEXIST')) {
632
- _context6.next = 10;
738
+ if (!(_context7.t0.code !== 'EEXIST')) {
739
+ _context7.next = 10;
633
740
  break;
634
741
  }
635
742
 
636
- throw _context6.t0;
743
+ throw _context7.t0;
637
744
 
638
745
  case 10:
639
- _context6.prev = 10;
640
- _context6.next = 13;
746
+ _context7.prev = 10;
747
+ _context7.next = 13;
641
748
  return _fs2.default.promises.rm(targetPath, { force: true });
642
749
 
643
750
  case 13:
644
- _context6.next = 19;
751
+ _context7.next = 19;
645
752
  break;
646
753
 
647
754
  case 15:
648
- _context6.prev = 15;
649
- _context6.t1 = _context6['catch'](10);
755
+ _context7.prev = 15;
756
+ _context7.t1 = _context7['catch'](10);
650
757
 
651
- if (['EBUSY', 'EPERM', 'ENOENT'].includes(_context6.t1.code)) {
652
- _context6.next = 19;
758
+ if (['EBUSY', 'EPERM', 'ENOENT'].includes(_context7.t1.code)) {
759
+ _context7.next = 19;
653
760
  break;
654
761
  }
655
762
 
656
- throw _context6.t1;
763
+ throw _context7.t1;
657
764
 
658
765
  case 19:
659
- _context6.next = 21;
766
+ _context7.next = 21;
660
767
  return _fs2.default.promises.rename(sourcePath, targetPath);
661
768
 
662
769
  case 21:
663
770
  case 'end':
664
- return _context6.stop();
771
+ return _context7.stop();
665
772
  }
666
773
  }
667
- }, _callee6, undefined, [[0, 6], [10, 15]]);
774
+ }, _callee7, undefined, [[0, 6], [10, 15]]);
668
775
  }));
669
776
 
670
- return function tryReplaceFile(_x12, _x13) {
671
- return _ref7.apply(this, arguments);
777
+ return function tryReplaceFile(_x16, _x17) {
778
+ return _ref8.apply(this, arguments);
672
779
  };
673
780
  }();
674
781
 
675
782
  var moveExtractedBinary = function () {
676
- var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(extractedPath, outputDir, entry) {
783
+ var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(extractedPath, outputDir, entry) {
677
784
  var targetPath, entryDir, entryName, tempName, tempEntry, tempPath;
678
- return _regenerator2.default.wrap(function _callee7$(_context7) {
785
+ return _regenerator2.default.wrap(function _callee8$(_context8) {
679
786
  while (1) {
680
- switch (_context7.prev = _context7.next) {
787
+ switch (_context8.prev = _context8.next) {
681
788
  case 0:
682
789
  targetPath = _path2.default.join(outputDir, entry);
683
- _context7.next = 3;
790
+ _context8.next = 3;
684
791
  return _fs2.default.promises.mkdir(_path2.default.dirname(targetPath), { recursive: true });
685
792
 
686
793
  case 3:
687
- _context7.prev = 3;
688
- _context7.next = 6;
794
+ _context8.prev = 3;
795
+ _context8.next = 6;
689
796
  return tryReplaceFile(extractedPath, targetPath);
690
797
 
691
798
  case 6:
692
- return _context7.abrupt('return', { entryPath: targetPath, entryRelative: entry });
799
+ return _context8.abrupt('return', { entryPath: targetPath, entryRelative: entry });
693
800
 
694
801
  case 9:
695
- _context7.prev = 9;
696
- _context7.t0 = _context7['catch'](3);
802
+ _context8.prev = 9;
803
+ _context8.t0 = _context8['catch'](3);
697
804
 
698
- if (['EBUSY', 'EPERM'].includes(_context7.t0.code)) {
699
- _context7.next = 13;
805
+ if (['EBUSY', 'EPERM'].includes(_context8.t0.code)) {
806
+ _context8.next = 13;
700
807
  break;
701
808
  }
702
809
 
703
- throw _context7.t0;
810
+ throw _context8.t0;
704
811
 
705
812
  case 13:
706
813
  entryDir = _path2.default.dirname(entry);
@@ -708,82 +815,82 @@ var moveExtractedBinary = function () {
708
815
  tempName = entryName + '.tmp-' + Date.now() + '-' + Math.random().toString(16).slice(2, 8);
709
816
  tempEntry = _path2.default.join(entryDir === '.' ? '' : entryDir, tempName);
710
817
  tempPath = _path2.default.join(outputDir, tempEntry);
711
- _context7.next = 20;
818
+ _context8.next = 20;
712
819
  return _fs2.default.promises.mkdir(_path2.default.dirname(tempPath), { recursive: true });
713
820
 
714
821
  case 20:
715
- _context7.next = 22;
822
+ _context8.next = 22;
716
823
  return _fs2.default.promises.rename(extractedPath, tempPath);
717
824
 
718
825
  case 22:
719
- return _context7.abrupt('return', { entryPath: tempPath, entryRelative: entry, tempEntry: tempEntry });
826
+ return _context8.abrupt('return', { entryPath: tempPath, entryRelative: entry, tempEntry: tempEntry });
720
827
 
721
828
  case 23:
722
829
  case 'end':
723
- return _context7.stop();
830
+ return _context8.stop();
724
831
  }
725
832
  }
726
- }, _callee7, undefined, [[3, 9]]);
833
+ }, _callee8, undefined, [[3, 9]]);
727
834
  }));
728
835
 
729
- return function moveExtractedBinary(_x14, _x15, _x16) {
730
- return _ref8.apply(this, arguments);
836
+ return function moveExtractedBinary(_x18, _x19, _x20) {
837
+ return _ref9.apply(this, arguments);
731
838
  };
732
839
  }();
733
840
 
734
841
  var extractZip = function () {
735
- var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(archivePath, outputDir, entry) {
842
+ var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(archivePath, outputDir, entry) {
736
843
  var tempDir, extractedPath;
737
- return _regenerator2.default.wrap(function _callee8$(_context8) {
844
+ return _regenerator2.default.wrap(function _callee9$(_context9) {
738
845
  while (1) {
739
- switch (_context8.prev = _context8.next) {
846
+ switch (_context9.prev = _context9.next) {
740
847
  case 0:
741
848
  tempDir = _path2.default.join(outputDir, '.tmp-' + Date.now() + '-' + Math.random().toString(16).slice(2));
742
- _context8.next = 3;
849
+ _context9.next = 3;
743
850
  return _fs2.default.promises.mkdir(tempDir, { recursive: true });
744
851
 
745
852
  case 3:
746
- _context8.prev = 3;
747
- _context8.next = 6;
853
+ _context9.prev = 3;
854
+ _context9.next = 6;
748
855
  return (0, _decompress2.default)(archivePath, tempDir);
749
856
 
750
857
  case 6:
751
858
  extractedPath = _path2.default.join(tempDir, entry);
752
859
 
753
860
  if (_fs2.default.existsSync(extractedPath)) {
754
- _context8.next = 9;
861
+ _context9.next = 9;
755
862
  break;
756
863
  }
757
864
 
758
865
  throw new Error('Expected entry ' + entry + ' was not found after extraction.');
759
866
 
760
867
  case 9:
761
- _context8.next = 11;
868
+ _context9.next = 11;
762
869
  return moveExtractedBinary(extractedPath, outputDir, entry);
763
870
 
764
871
  case 11:
765
- return _context8.abrupt('return', _context8.sent);
872
+ return _context9.abrupt('return', _context9.sent);
766
873
 
767
874
  case 12:
768
- _context8.prev = 12;
769
- _context8.next = 15;
875
+ _context9.prev = 12;
876
+ _context9.next = 15;
770
877
  return _fs2.default.promises.rm(tempDir, { recursive: true, force: true }).catch(function () {
771
878
  return undefined;
772
879
  });
773
880
 
774
881
  case 15:
775
- return _context8.finish(12);
882
+ return _context9.finish(12);
776
883
 
777
884
  case 16:
778
885
  case 'end':
779
- return _context8.stop();
886
+ return _context9.stop();
780
887
  }
781
888
  }
782
- }, _callee8, undefined, [[3,, 12, 16]]);
889
+ }, _callee9, undefined, [[3,, 12, 16]]);
783
890
  }));
784
891
 
785
- return function extractZip(_x17, _x18, _x19) {
786
- return _ref9.apply(this, arguments);
892
+ return function extractZip(_x21, _x22, _x23) {
893
+ return _ref10.apply(this, arguments);
787
894
  };
788
895
  }();
789
896
 
@@ -877,67 +984,67 @@ var getClnCiCacheDir = function getClnCiCacheDir(platformId) {
877
984
  };
878
985
 
879
986
  var ensureClnCiDir = function () {
880
- var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(dirPath) {
881
- return _regenerator2.default.wrap(function _callee9$(_context9) {
987
+ var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(dirPath) {
988
+ return _regenerator2.default.wrap(function _callee10$(_context10) {
882
989
  while (1) {
883
- switch (_context9.prev = _context9.next) {
990
+ switch (_context10.prev = _context10.next) {
884
991
  case 0:
885
- _context9.next = 2;
992
+ _context10.next = 2;
886
993
  return _fs2.default.promises.mkdir(dirPath, { recursive: true });
887
994
 
888
995
  case 2:
889
996
  case 'end':
890
- return _context9.stop();
997
+ return _context10.stop();
891
998
  }
892
999
  }
893
- }, _callee9, undefined);
1000
+ }, _callee10, undefined);
894
1001
  }));
895
1002
 
896
- return function ensureClnCiDir(_x20) {
897
- return _ref10.apply(this, arguments);
1003
+ return function ensureClnCiDir(_x24) {
1004
+ return _ref11.apply(this, arguments);
898
1005
  };
899
1006
  }();
900
1007
 
901
1008
  var removeDirIfEmpty = function () {
902
- var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(dirPath) {
1009
+ var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(dirPath) {
903
1010
  var entries;
904
- return _regenerator2.default.wrap(function _callee10$(_context10) {
1011
+ return _regenerator2.default.wrap(function _callee11$(_context11) {
905
1012
  while (1) {
906
- switch (_context10.prev = _context10.next) {
1013
+ switch (_context11.prev = _context11.next) {
907
1014
  case 0:
908
- _context10.prev = 0;
909
- _context10.next = 3;
1015
+ _context11.prev = 0;
1016
+ _context11.next = 3;
910
1017
  return _fs2.default.promises.readdir(dirPath);
911
1018
 
912
1019
  case 3:
913
- entries = _context10.sent;
1020
+ entries = _context11.sent;
914
1021
 
915
1022
  if (!(entries.length === 0)) {
916
- _context10.next = 7;
1023
+ _context11.next = 7;
917
1024
  break;
918
1025
  }
919
1026
 
920
- _context10.next = 7;
1027
+ _context11.next = 7;
921
1028
  return _fs2.default.promises.rmdir(dirPath);
922
1029
 
923
1030
  case 7:
924
- _context10.next = 11;
1031
+ _context11.next = 11;
925
1032
  break;
926
1033
 
927
1034
  case 9:
928
- _context10.prev = 9;
929
- _context10.t0 = _context10['catch'](0);
1035
+ _context11.prev = 9;
1036
+ _context11.t0 = _context11['catch'](0);
930
1037
 
931
1038
  case 11:
932
1039
  case 'end':
933
- return _context10.stop();
1040
+ return _context11.stop();
934
1041
  }
935
1042
  }
936
- }, _callee10, undefined, [[0, 9]]);
1043
+ }, _callee11, undefined, [[0, 9]]);
937
1044
  }));
938
1045
 
939
- return function removeDirIfEmpty(_x21) {
940
- return _ref11.apply(this, arguments);
1046
+ return function removeDirIfEmpty(_x25) {
1047
+ return _ref12.apply(this, arguments);
941
1048
  };
942
1049
  }();
943
1050
 
@@ -953,63 +1060,63 @@ var readMetadata = function readMetadata(metadataPath) {
953
1060
  };
954
1061
 
955
1062
  var writeMetadata = function () {
956
- var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(metadataPath, metadata) {
957
- return _regenerator2.default.wrap(function _callee11$(_context11) {
1063
+ var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(metadataPath, metadata) {
1064
+ return _regenerator2.default.wrap(function _callee12$(_context12) {
958
1065
  while (1) {
959
- switch (_context11.prev = _context11.next) {
1066
+ switch (_context12.prev = _context12.next) {
960
1067
  case 0:
961
- _context11.next = 2;
1068
+ _context12.next = 2;
962
1069
  return _fs2.default.promises.mkdir(_path2.default.dirname(metadataPath), { recursive: true });
963
1070
 
964
1071
  case 2:
965
- _context11.next = 4;
1072
+ _context12.next = 4;
966
1073
  return _fs2.default.promises.writeFile(metadataPath, (0, _stringify2.default)(metadata, null, 2));
967
1074
 
968
1075
  case 4:
969
1076
  case 'end':
970
- return _context11.stop();
1077
+ return _context12.stop();
971
1078
  }
972
1079
  }
973
- }, _callee11, undefined);
1080
+ }, _callee12, undefined);
974
1081
  }));
975
1082
 
976
- return function writeMetadata(_x22, _x23) {
977
- return _ref12.apply(this, arguments);
1083
+ return function writeMetadata(_x26, _x27) {
1084
+ return _ref13.apply(this, arguments);
978
1085
  };
979
1086
  }();
980
1087
 
981
1088
  var isClnCiReachable = function () {
982
- var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12() {
1089
+ var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13() {
983
1090
  var res;
984
- return _regenerator2.default.wrap(function _callee12$(_context12) {
1091
+ return _regenerator2.default.wrap(function _callee13$(_context13) {
985
1092
  while (1) {
986
- switch (_context12.prev = _context12.next) {
1093
+ switch (_context13.prev = _context13.next) {
987
1094
  case 0:
988
- _context12.prev = 0;
989
- _context12.next = 3;
1095
+ _context13.prev = 0;
1096
+ _context13.next = 3;
990
1097
  return fetchWithTimeout(CLN_CI_INDEX_URL, {
991
1098
  headers: { accept: 'application/json' }
992
1099
  });
993
1100
 
994
1101
  case 3:
995
- res = _context12.sent;
996
- return _context12.abrupt('return', !!(res && res.ok));
1102
+ res = _context13.sent;
1103
+ return _context13.abrupt('return', !!(res && res.ok));
997
1104
 
998
1105
  case 7:
999
- _context12.prev = 7;
1000
- _context12.t0 = _context12['catch'](0);
1001
- return _context12.abrupt('return', false);
1106
+ _context13.prev = 7;
1107
+ _context13.t0 = _context13['catch'](0);
1108
+ return _context13.abrupt('return', false);
1002
1109
 
1003
1110
  case 10:
1004
1111
  case 'end':
1005
- return _context12.stop();
1112
+ return _context13.stop();
1006
1113
  }
1007
1114
  }
1008
- }, _callee12, undefined, [[0, 7]]);
1115
+ }, _callee13, undefined, [[0, 7]]);
1009
1116
  }));
1010
1117
 
1011
1118
  return function isClnCiReachable() {
1012
- return _ref13.apply(this, arguments);
1119
+ return _ref14.apply(this, arguments);
1013
1120
  };
1014
1121
  }();
1015
1122
 
@@ -1018,23 +1125,23 @@ var resolvePlatformId = function resolvePlatformId(platformInfo) {
1018
1125
  };
1019
1126
 
1020
1127
  var ensureClnCiPlatformBinary = function () {
1021
- var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(platformInfo) {
1128
+ var _ref15 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14(platformInfo) {
1022
1129
  var online = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1023
1130
 
1024
1131
  var platformId, cacheDir, _metadataPath, _cached, _targetBinaryPath, _fallbackBinaryPath, manifest, file, metadataPath, cached, targetBinaryPath, fallbackBinaryPath, archiveName, archivePath, isCacheValid, binaryPath, actualSha, extracted;
1025
1132
 
1026
- return _regenerator2.default.wrap(function _callee13$(_context13) {
1133
+ return _regenerator2.default.wrap(function _callee14$(_context14) {
1027
1134
  while (1) {
1028
- switch (_context13.prev = _context13.next) {
1135
+ switch (_context14.prev = _context14.next) {
1029
1136
  case 0:
1030
1137
  platformId = resolvePlatformId(platformInfo);
1031
1138
  cacheDir = getClnCiCacheDir(platformId);
1032
- _context13.next = 4;
1139
+ _context14.next = 4;
1033
1140
  return ensureClnCiDir(cacheDir);
1034
1141
 
1035
1142
  case 4:
1036
1143
  if (online) {
1037
- _context13.next = 14;
1144
+ _context14.next = 14;
1038
1145
  break;
1039
1146
  }
1040
1147
 
@@ -1044,11 +1151,11 @@ var ensureClnCiPlatformBinary = function () {
1044
1151
  _fallbackBinaryPath = _cached && _cached.tempEntry ? _path2.default.join(cacheDir, _cached.tempEntry) : null;
1045
1152
 
1046
1153
  if (!(_targetBinaryPath && _fs2.default.existsSync(_targetBinaryPath))) {
1047
- _context13.next = 11;
1154
+ _context14.next = 11;
1048
1155
  break;
1049
1156
  }
1050
1157
 
1051
- return _context13.abrupt('return', {
1158
+ return _context14.abrupt('return', {
1052
1159
  binaryPath: _targetBinaryPath,
1053
1160
  version: _cached.version,
1054
1161
  platformId: platformId
@@ -1056,11 +1163,11 @@ var ensureClnCiPlatformBinary = function () {
1056
1163
 
1057
1164
  case 11:
1058
1165
  if (!(_fallbackBinaryPath && _fs2.default.existsSync(_fallbackBinaryPath))) {
1059
- _context13.next = 13;
1166
+ _context14.next = 13;
1060
1167
  break;
1061
1168
  }
1062
1169
 
1063
- return _context13.abrupt('return', {
1170
+ return _context14.abrupt('return', {
1064
1171
  binaryPath: _fallbackBinaryPath,
1065
1172
  version: _cached.version,
1066
1173
  platformId: platformId
@@ -1070,15 +1177,15 @@ var ensureClnCiPlatformBinary = function () {
1070
1177
  throw new Error('Local cln-ci binary not found for ' + platformId + ' in ' + cacheDir);
1071
1178
 
1072
1179
  case 14:
1073
- _context13.next = 16;
1180
+ _context14.next = 16;
1074
1181
  return fetchJson(resolveDownloadUrl(platformInfo.manifest));
1075
1182
 
1076
1183
  case 16:
1077
- manifest = _context13.sent;
1184
+ manifest = _context14.sent;
1078
1185
  file = manifest.files && manifest.files[0];
1079
1186
 
1080
1187
  if (!(!file || !file.pack || file.pack.format !== 'zip')) {
1081
- _context13.next = 20;
1188
+ _context14.next = 20;
1082
1189
  break;
1083
1190
  }
1084
1191
 
@@ -1095,26 +1202,26 @@ var ensureClnCiPlatformBinary = function () {
1095
1202
  binaryPath = targetBinaryPath;
1096
1203
 
1097
1204
  if (isCacheValid) {
1098
- _context13.next = 49;
1205
+ _context14.next = 49;
1099
1206
  break;
1100
1207
  }
1101
1208
 
1102
- _context13.next = 31;
1209
+ _context14.next = 31;
1103
1210
  return downloadFile(resolveDownloadUrl(file.url), archivePath);
1104
1211
 
1105
1212
  case 31:
1106
- _context13.next = 33;
1213
+ _context14.next = 33;
1107
1214
  return sha256File(archivePath);
1108
1215
 
1109
1216
  case 33:
1110
- actualSha = _context13.sent;
1217
+ actualSha = _context14.sent;
1111
1218
 
1112
1219
  if (!(actualSha !== file.sha256)) {
1113
- _context13.next = 38;
1220
+ _context14.next = 38;
1114
1221
  break;
1115
1222
  }
1116
1223
 
1117
- _context13.next = 37;
1224
+ _context14.next = 37;
1118
1225
  return _fs2.default.promises.rm(archivePath, { force: true }).catch(function () {
1119
1226
  return undefined;
1120
1227
  });
@@ -1123,24 +1230,24 @@ var ensureClnCiPlatformBinary = function () {
1123
1230
  throw new Error('Downloaded cln-ci package failed sha256 verification.');
1124
1231
 
1125
1232
  case 38:
1126
- _context13.next = 40;
1233
+ _context14.next = 40;
1127
1234
  return extractZip(archivePath, cacheDir, file.pack.entry);
1128
1235
 
1129
1236
  case 40:
1130
- extracted = _context13.sent;
1237
+ extracted = _context14.sent;
1131
1238
 
1132
1239
  binaryPath = extracted.entryPath;
1133
1240
 
1134
1241
  if (!(process.platform !== 'win32')) {
1135
- _context13.next = 45;
1242
+ _context14.next = 45;
1136
1243
  break;
1137
1244
  }
1138
1245
 
1139
- _context13.next = 45;
1246
+ _context14.next = 45;
1140
1247
  return _fs2.default.promises.chmod(binaryPath, 493);
1141
1248
 
1142
1249
  case 45:
1143
- _context13.next = 47;
1250
+ _context14.next = 47;
1144
1251
  return writeMetadata(metadataPath, {
1145
1252
  version: manifest.version,
1146
1253
  entry: file.pack.entry,
@@ -1150,7 +1257,7 @@ var ensureClnCiPlatformBinary = function () {
1150
1257
  });
1151
1258
 
1152
1259
  case 47:
1153
- _context13.next = 50;
1260
+ _context14.next = 50;
1154
1261
  break;
1155
1262
 
1156
1263
  case 49:
@@ -1160,47 +1267,47 @@ var ensureClnCiPlatformBinary = function () {
1160
1267
 
1161
1268
  case 50:
1162
1269
  if (!_fs2.default.existsSync(targetBinaryPath)) {
1163
- _context13.next = 55;
1270
+ _context14.next = 55;
1164
1271
  break;
1165
1272
  }
1166
1273
 
1167
1274
  binaryPath = targetBinaryPath;
1168
1275
 
1169
1276
  if (!(cached && cached.tempEntry)) {
1170
- _context13.next = 55;
1277
+ _context14.next = 55;
1171
1278
  break;
1172
1279
  }
1173
1280
 
1174
- _context13.next = 55;
1281
+ _context14.next = 55;
1175
1282
  return _fs2.default.promises.rm(_path2.default.join(cacheDir, cached.tempEntry), { force: true }).catch(function () {
1176
1283
  return undefined;
1177
1284
  });
1178
1285
 
1179
1286
  case 55:
1180
- return _context13.abrupt('return', { binaryPath: binaryPath, version: manifest.version });
1287
+ return _context14.abrupt('return', { binaryPath: binaryPath, version: manifest.version });
1181
1288
 
1182
1289
  case 56:
1183
1290
  case 'end':
1184
- return _context13.stop();
1291
+ return _context14.stop();
1185
1292
  }
1186
1293
  }
1187
- }, _callee13, undefined);
1294
+ }, _callee14, undefined);
1188
1295
  }));
1189
1296
 
1190
- return function ensureClnCiPlatformBinary(_x25) {
1191
- return _ref14.apply(this, arguments);
1297
+ return function ensureClnCiPlatformBinary(_x29) {
1298
+ return _ref15.apply(this, arguments);
1192
1299
  };
1193
1300
  }();
1194
1301
 
1195
1302
  var ensureLocalClnCiBinary = function () {
1196
- var _ref15 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14() {
1303
+ var _ref16 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15() {
1197
1304
  var platformId;
1198
- return _regenerator2.default.wrap(function _callee14$(_context14) {
1305
+ return _regenerator2.default.wrap(function _callee15$(_context15) {
1199
1306
  while (1) {
1200
- switch (_context14.prev = _context14.next) {
1307
+ switch (_context15.prev = _context15.next) {
1201
1308
  case 0:
1202
1309
  platformId = resolveCurrentPlatformId();
1203
- _context14.next = 3;
1310
+ _context15.next = 3;
1204
1311
  return ensureClnCiPlatformBinary({
1205
1312
  os: getClnCiPlatform().os,
1206
1313
  arch: getClnCiPlatform().arch,
@@ -1208,68 +1315,68 @@ var ensureLocalClnCiBinary = function () {
1208
1315
  }, false);
1209
1316
 
1210
1317
  case 3:
1211
- return _context14.abrupt('return', _context14.sent);
1318
+ return _context15.abrupt('return', _context15.sent);
1212
1319
 
1213
1320
  case 4:
1214
1321
  case 'end':
1215
- return _context14.stop();
1322
+ return _context15.stop();
1216
1323
  }
1217
1324
  }
1218
- }, _callee14, undefined);
1325
+ }, _callee15, undefined);
1219
1326
  }));
1220
1327
 
1221
1328
  return function ensureLocalClnCiBinary() {
1222
- return _ref15.apply(this, arguments);
1329
+ return _ref16.apply(this, arguments);
1223
1330
  };
1224
1331
  }();
1225
1332
 
1226
1333
  var ensureClnCiBinary = function () {
1227
- var _ref16 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16() {
1334
+ var _ref17 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17() {
1228
1335
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1229
1336
  var platformKey, online, currentPlatformId, index, platforms, currentPlatformInfo;
1230
- return _regenerator2.default.wrap(function _callee16$(_context16) {
1337
+ return _regenerator2.default.wrap(function _callee17$(_context17) {
1231
1338
  while (1) {
1232
- switch (_context16.prev = _context16.next) {
1339
+ switch (_context17.prev = _context17.next) {
1233
1340
  case 0:
1234
1341
  platformKey = getClnCiPlatform();
1235
- _context16.next = 3;
1342
+ _context17.next = 3;
1236
1343
  return ensureClnCiDir(getClnCiRootDir());
1237
1344
 
1238
1345
  case 3:
1239
- _context16.next = 5;
1346
+ _context17.next = 5;
1240
1347
  return ensureClnCiDir(getClnCiBinRootDir());
1241
1348
 
1242
1349
  case 5:
1243
1350
  if (!options.preferLocal) {
1244
- _context16.next = 14;
1351
+ _context17.next = 14;
1245
1352
  break;
1246
1353
  }
1247
1354
 
1248
- _context16.prev = 6;
1249
- _context16.next = 9;
1355
+ _context17.prev = 6;
1356
+ _context17.next = 9;
1250
1357
  return ensureLocalClnCiBinary();
1251
1358
 
1252
1359
  case 9:
1253
- return _context16.abrupt('return', _context16.sent);
1360
+ return _context17.abrupt('return', _context17.sent);
1254
1361
 
1255
1362
  case 12:
1256
- _context16.prev = 12;
1257
- _context16.t0 = _context16['catch'](6);
1363
+ _context17.prev = 12;
1364
+ _context17.t0 = _context17['catch'](6);
1258
1365
 
1259
1366
  case 14:
1260
- _context16.next = 16;
1367
+ _context17.next = 16;
1261
1368
  return isClnCiReachable();
1262
1369
 
1263
1370
  case 16:
1264
- online = _context16.sent;
1371
+ online = _context17.sent;
1265
1372
  currentPlatformId = platformKey.os + '-' + platformKey.arch;
1266
1373
 
1267
1374
  if (online) {
1268
- _context16.next = 22;
1375
+ _context17.next = 22;
1269
1376
  break;
1270
1377
  }
1271
1378
 
1272
- _context16.next = 21;
1379
+ _context17.next = 21;
1273
1380
  return ensureClnCiPlatformBinary({
1274
1381
  os: platformKey.os,
1275
1382
  arch: platformKey.arch,
@@ -1277,100 +1384,100 @@ var ensureClnCiBinary = function () {
1277
1384
  }, false);
1278
1385
 
1279
1386
  case 21:
1280
- return _context16.abrupt('return', _context16.sent);
1387
+ return _context17.abrupt('return', _context17.sent);
1281
1388
 
1282
1389
  case 22:
1283
- _context16.next = 24;
1390
+ _context17.next = 24;
1284
1391
  return fetchJson(CLN_CI_INDEX_URL);
1285
1392
 
1286
1393
  case 24:
1287
- index = _context16.sent;
1394
+ index = _context17.sent;
1288
1395
  platforms = index.platforms || [];
1289
1396
  currentPlatformInfo = platforms.find(function (entry) {
1290
1397
  return entry.os === platformKey.os && entry.arch === platformKey.arch;
1291
1398
  });
1292
1399
 
1293
1400
  if (currentPlatformInfo) {
1294
- _context16.next = 29;
1401
+ _context17.next = 29;
1295
1402
  break;
1296
1403
  }
1297
1404
 
1298
1405
  throw new Error('No cln-ci build for ' + platformKey.os + '/' + platformKey.arch);
1299
1406
 
1300
1407
  case 29:
1301
- _context16.next = 31;
1408
+ _context17.next = 31;
1302
1409
  return _promise2.default.all(platforms.map(function () {
1303
- var _ref17 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15(entry) {
1304
- return _regenerator2.default.wrap(function _callee15$(_context15) {
1410
+ var _ref18 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16(entry) {
1411
+ return _regenerator2.default.wrap(function _callee16$(_context16) {
1305
1412
  while (1) {
1306
- switch (_context15.prev = _context15.next) {
1413
+ switch (_context16.prev = _context16.next) {
1307
1414
  case 0:
1308
- _context15.prev = 0;
1309
- _context15.next = 3;
1415
+ _context16.prev = 0;
1416
+ _context16.next = 3;
1310
1417
  return ensureClnCiPlatformBinary(entry, true);
1311
1418
 
1312
1419
  case 3:
1313
- _context15.next = 12;
1420
+ _context16.next = 12;
1314
1421
  break;
1315
1422
 
1316
1423
  case 5:
1317
- _context15.prev = 5;
1318
- _context15.t0 = _context15['catch'](0);
1424
+ _context16.prev = 5;
1425
+ _context16.t0 = _context16['catch'](0);
1319
1426
 
1320
1427
  if (!(resolvePlatformId(entry) === resolvePlatformId(currentPlatformInfo))) {
1321
- _context15.next = 9;
1428
+ _context16.next = 9;
1322
1429
  break;
1323
1430
  }
1324
1431
 
1325
- throw _context15.t0;
1432
+ throw _context16.t0;
1326
1433
 
1327
1434
  case 9:
1328
- _context15.next = 11;
1435
+ _context16.next = 11;
1329
1436
  return removeDirIfEmpty(getClnCiCacheDir(resolvePlatformId(entry)));
1330
1437
 
1331
1438
  case 11:
1332
- _consola2.default.warn('Skip syncing optional cln-ci platform ' + resolvePlatformId(entry) + ': ' + (_context15.t0 && _context15.t0.message ? _context15.t0.message : _context15.t0));
1439
+ _consola2.default.warn('Skip syncing optional cln-ci platform ' + resolvePlatformId(entry) + ': ' + (_context16.t0 && _context16.t0.message ? _context16.t0.message : _context16.t0));
1333
1440
 
1334
1441
  case 12:
1335
1442
  case 'end':
1336
- return _context15.stop();
1443
+ return _context16.stop();
1337
1444
  }
1338
1445
  }
1339
- }, _callee15, undefined, [[0, 5]]);
1446
+ }, _callee16, undefined, [[0, 5]]);
1340
1447
  }));
1341
1448
 
1342
- return function (_x27) {
1343
- return _ref17.apply(this, arguments);
1449
+ return function (_x31) {
1450
+ return _ref18.apply(this, arguments);
1344
1451
  };
1345
1452
  }()));
1346
1453
 
1347
1454
  case 31:
1348
- _context16.next = 33;
1455
+ _context17.next = 33;
1349
1456
  return ensureClnCiPlatformBinary(currentPlatformInfo, true);
1350
1457
 
1351
1458
  case 33:
1352
- return _context16.abrupt('return', _context16.sent);
1459
+ return _context17.abrupt('return', _context17.sent);
1353
1460
 
1354
1461
  case 34:
1355
1462
  case 'end':
1356
- return _context16.stop();
1463
+ return _context17.stop();
1357
1464
  }
1358
1465
  }
1359
- }, _callee16, undefined, [[6, 12]]);
1466
+ }, _callee17, undefined, [[6, 12]]);
1360
1467
  }));
1361
1468
 
1362
1469
  return function ensureClnCiBinary() {
1363
- return _ref16.apply(this, arguments);
1470
+ return _ref17.apply(this, arguments);
1364
1471
  };
1365
1472
  }();
1366
1473
 
1367
1474
  var spawnClnCiBinary = function () {
1368
- var _ref18 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17(binaryPath, args) {
1369
- return _regenerator2.default.wrap(function _callee17$(_context17) {
1475
+ var _ref19 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee18(binaryPath, args) {
1476
+ return _regenerator2.default.wrap(function _callee18$(_context18) {
1370
1477
  while (1) {
1371
- switch (_context17.prev = _context17.next) {
1478
+ switch (_context18.prev = _context18.next) {
1372
1479
  case 0:
1373
- _context17.next = 2;
1480
+ _context18.next = 2;
1374
1481
  return new _promise2.default(function (resolve, reject) {
1375
1482
  var child = spawn(binaryPath, args, {
1376
1483
  stdio: 'inherit',
@@ -1388,18 +1495,18 @@ var spawnClnCiBinary = function () {
1388
1495
  });
1389
1496
 
1390
1497
  case 2:
1391
- return _context17.abrupt('return', _context17.sent);
1498
+ return _context18.abrupt('return', _context18.sent);
1392
1499
 
1393
1500
  case 3:
1394
1501
  case 'end':
1395
- return _context17.stop();
1502
+ return _context18.stop();
1396
1503
  }
1397
1504
  }
1398
- }, _callee17, undefined);
1505
+ }, _callee18, undefined);
1399
1506
  }));
1400
1507
 
1401
- return function spawnClnCiBinary(_x28, _x29) {
1402
- return _ref18.apply(this, arguments);
1508
+ return function spawnClnCiBinary(_x32, _x33) {
1509
+ return _ref19.apply(this, arguments);
1403
1510
  };
1404
1511
  }();
1405
1512
 
@@ -1424,114 +1531,114 @@ var parseClnCiArgs = function parseClnCiArgs() {
1424
1531
  };
1425
1532
 
1426
1533
  var runClnCiCommand = function () {
1427
- var _ref19 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee18(command) {
1534
+ var _ref20 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee19(command) {
1428
1535
  var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1429
1536
 
1430
- var parsed, _ref20, binaryPath;
1537
+ var parsed, _ref21, binaryPath;
1431
1538
 
1432
- return _regenerator2.default.wrap(function _callee18$(_context18) {
1539
+ return _regenerator2.default.wrap(function _callee19$(_context19) {
1433
1540
  while (1) {
1434
- switch (_context18.prev = _context18.next) {
1541
+ switch (_context19.prev = _context19.next) {
1435
1542
  case 0:
1436
1543
  parsed = parseClnCiArgs(args);
1437
- _context18.next = 3;
1544
+ _context19.next = 3;
1438
1545
  return ensureClnCiBinary({
1439
1546
  preferLocal: parsed.preferLocal
1440
1547
  });
1441
1548
 
1442
1549
  case 3:
1443
- _ref20 = _context18.sent;
1444
- binaryPath = _ref20.binaryPath;
1445
- _context18.next = 7;
1550
+ _ref21 = _context19.sent;
1551
+ binaryPath = _ref21.binaryPath;
1552
+ _context19.next = 7;
1446
1553
  return spawnClnCiBinary(binaryPath, [command].concat((0, _toConsumableArray3.default)(parsed.args)));
1447
1554
 
1448
1555
  case 7:
1449
- return _context18.abrupt('return', _context18.sent);
1556
+ return _context19.abrupt('return', _context19.sent);
1450
1557
 
1451
1558
  case 8:
1452
1559
  case 'end':
1453
- return _context18.stop();
1560
+ return _context19.stop();
1454
1561
  }
1455
1562
  }
1456
- }, _callee18, undefined);
1563
+ }, _callee19, undefined);
1457
1564
  }));
1458
1565
 
1459
- return function runClnCiCommand(_x32) {
1460
- return _ref19.apply(this, arguments);
1566
+ return function runClnCiCommand(_x36) {
1567
+ return _ref20.apply(this, arguments);
1461
1568
  };
1462
1569
  }();
1463
1570
 
1464
1571
  var run = exports.run = function () {
1465
- var _ref21 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee33(_argv) {
1572
+ var _ref22 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee34(_argv) {
1466
1573
  var argv, rawArgs, command, commandArgs, exitCode;
1467
- return _regenerator2.default.wrap(function _callee33$(_context33) {
1574
+ return _regenerator2.default.wrap(function _callee34$(_context34) {
1468
1575
  while (1) {
1469
- switch (_context33.prev = _context33.next) {
1576
+ switch (_context34.prev = _context34.next) {
1470
1577
  case 0:
1471
1578
  argv = Array.isArray(_argv) && _argv.length > 0 ? _argv : process.argv;
1472
1579
  rawArgs = argv.slice(2);
1473
1580
 
1474
1581
  if (!(rawArgs[0] === 'image')) {
1475
- _context33.next = 17;
1582
+ _context34.next = 17;
1476
1583
  break;
1477
1584
  }
1478
1585
 
1479
- _context33.prev = 3;
1586
+ _context34.prev = 3;
1480
1587
  command = rawArgs[1] || 'image';
1481
1588
  commandArgs = rawArgs[1] ? rawArgs.slice(2) : [];
1482
- _context33.next = 8;
1589
+ _context34.next = 8;
1483
1590
  return runClnCiCommand(command, commandArgs);
1484
1591
 
1485
1592
  case 8:
1486
- exitCode = _context33.sent;
1593
+ exitCode = _context34.sent;
1487
1594
 
1488
1595
  process.exitCode = exitCode;
1489
- _context33.next = 16;
1596
+ _context34.next = 16;
1490
1597
  break;
1491
1598
 
1492
1599
  case 12:
1493
- _context33.prev = 12;
1494
- _context33.t0 = _context33['catch'](3);
1600
+ _context34.prev = 12;
1601
+ _context34.t0 = _context34['catch'](3);
1495
1602
 
1496
- _consola2.default.error(_context33.t0 && _context33.t0.message ? _context33.t0.message : _context33.t0);
1603
+ _consola2.default.error(_context34.t0 && _context34.t0.message ? _context34.t0.message : _context34.t0);
1497
1604
  process.exitCode = 1;
1498
1605
 
1499
1606
  case 16:
1500
- return _context33.abrupt('return');
1607
+ return _context34.abrupt('return');
1501
1608
 
1502
1609
  case 17:
1503
1610
 
1504
1611
  _commander2.default.version(_package2.default.version, '-v, --version');
1505
1612
 
1506
1613
  _commander2.default.command('dev').description('go into developer mode').option('-y0ba, --yk0-build-app <appName>', 'Building a specified application').option('-e, --env <envName>', 'yk server env').option('-m, --mode <modeName>', 'yk develop start mode').action(function () {
1507
- var _ref23 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee19(_ref22) {
1508
- var yk0BuildApp = _ref22.yk0BuildApp,
1509
- env = _ref22.env,
1510
- mode = _ref22.mode;
1614
+ var _ref24 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee20(_ref23) {
1615
+ var yk0BuildApp = _ref23.yk0BuildApp,
1616
+ env = _ref23.env,
1617
+ mode = _ref23.mode;
1511
1618
 
1512
- var _ref24, apps, bin;
1619
+ var _ref25, apps, bin;
1513
1620
 
1514
- return _regenerator2.default.wrap(function _callee19$(_context19) {
1621
+ return _regenerator2.default.wrap(function _callee20$(_context20) {
1515
1622
  while (1) {
1516
- switch (_context19.prev = _context19.next) {
1623
+ switch (_context20.prev = _context20.next) {
1517
1624
  case 0:
1518
1625
  // console.log(args);
1519
1626
  _consola2.default.log('In the preparation...');
1520
1627
  process.env.NODE_ENV = 'development';
1521
- _context19.next = 4;
1628
+ _context20.next = 4;
1522
1629
  return gi({ app: yk0BuildApp, ykServerEnv: env });
1523
1630
 
1524
1631
  case 4:
1525
- _ref24 = _context19.sent;
1526
- apps = _ref24.apps;
1632
+ _ref25 = _context20.sent;
1633
+ apps = _ref25.apps;
1527
1634
  bin = "yk-dev";
1528
- _context19.t0 = _os2.default.type();
1529
- _context19.next = _context19.t0 === "Linux" ? 10 : 12;
1635
+ _context20.t0 = _os2.default.type();
1636
+ _context20.next = _context20.t0 === "Linux" ? 10 : 12;
1530
1637
  break;
1531
1638
 
1532
1639
  case 10:
1533
1640
  bin = "yk";
1534
- return _context19.abrupt('break', 12);
1641
+ return _context20.abrupt('break', 12);
1535
1642
 
1536
1643
  case 12:
1537
1644
 
@@ -1549,71 +1656,71 @@ var run = exports.run = function () {
1549
1656
 
1550
1657
  case 13:
1551
1658
  case 'end':
1552
- return _context19.stop();
1659
+ return _context20.stop();
1553
1660
  }
1554
1661
  }
1555
- }, _callee19, undefined);
1662
+ }, _callee20, undefined);
1556
1663
  }));
1557
1664
 
1558
- return function (_x34) {
1559
- return _ref23.apply(this, arguments);
1665
+ return function (_x38) {
1666
+ return _ref24.apply(this, arguments);
1560
1667
  };
1561
1668
  }());
1562
1669
 
1563
1670
  _commander2.default.command('serve <cmd>').description('go into developer mode')
1564
1671
  // .option('-y0ba, --yk0-build-app <appName>', 'Building a specified application')
1565
1672
  .action(function () {
1566
- var _ref25 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee21(cmd) {
1567
- return _regenerator2.default.wrap(function _callee21$(_context21) {
1673
+ var _ref26 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee22(cmd) {
1674
+ return _regenerator2.default.wrap(function _callee22$(_context22) {
1568
1675
  while (1) {
1569
- switch (_context21.prev = _context21.next) {
1676
+ switch (_context22.prev = _context22.next) {
1570
1677
  case 0:
1571
1678
  // console.log(args);
1572
1679
  process.env.NODE_ENV = 'development';
1573
1680
  // gi({app: yk0BuildApp});
1574
- _context21.next = 3;
1681
+ _context22.next = 3;
1575
1682
  return _server._.asyncMap(cmd.split(','), function () {
1576
- var _ref26 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee20(key) {
1577
- return _regenerator2.default.wrap(function _callee20$(_context20) {
1683
+ var _ref27 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee21(key) {
1684
+ return _regenerator2.default.wrap(function _callee21$(_context21) {
1578
1685
  while (1) {
1579
- switch (_context20.prev = _context20.next) {
1686
+ switch (_context21.prev = _context21.next) {
1580
1687
  case 0:
1581
1688
  alias({ appName: key });
1582
- _context20.next = 3;
1689
+ _context21.next = 3;
1583
1690
  return require(params.serverPath)('dev', key);
1584
1691
 
1585
1692
  case 3:
1586
1693
  case 'end':
1587
- return _context20.stop();
1694
+ return _context21.stop();
1588
1695
  }
1589
1696
  }
1590
- }, _callee20, undefined);
1697
+ }, _callee21, undefined);
1591
1698
  }));
1592
1699
 
1593
- return function (_x36) {
1594
- return _ref26.apply(this, arguments);
1700
+ return function (_x40) {
1701
+ return _ref27.apply(this, arguments);
1595
1702
  };
1596
1703
  }());
1597
1704
 
1598
1705
  case 3:
1599
1706
  case 'end':
1600
- return _context21.stop();
1707
+ return _context22.stop();
1601
1708
  }
1602
1709
  }
1603
- }, _callee21, undefined);
1710
+ }, _callee22, undefined);
1604
1711
  }));
1605
1712
 
1606
- return function (_x35) {
1607
- return _ref25.apply(this, arguments);
1713
+ return function (_x39) {
1714
+ return _ref26.apply(this, arguments);
1608
1715
  };
1609
1716
  }());
1610
1717
 
1611
- _commander2.default.command('init').description('cln2 is initialized.').action((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee22() {
1718
+ _commander2.default.command('init').description('cln2 is initialized.').action((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee23() {
1612
1719
  var pkgPath, _pkg, obj;
1613
1720
 
1614
- return _regenerator2.default.wrap(function _callee22$(_context22) {
1721
+ return _regenerator2.default.wrap(function _callee23$(_context23) {
1615
1722
  while (1) {
1616
- switch (_context22.prev = _context22.next) {
1723
+ switch (_context23.prev = _context23.next) {
1617
1724
  case 0:
1618
1725
  // add image
1619
1726
  try {
@@ -1636,10 +1743,10 @@ var run = exports.run = function () {
1636
1743
 
1637
1744
  case 2:
1638
1745
  case 'end':
1639
- return _context22.stop();
1746
+ return _context23.stop();
1640
1747
  }
1641
1748
  }
1642
- }, _callee22, undefined);
1749
+ }, _callee23, undefined);
1643
1750
  })));
1644
1751
 
1645
1752
  _commander2.default.command('image').description('Build image with cln-ci.');
@@ -1647,16 +1754,16 @@ var run = exports.run = function () {
1647
1754
  _commander2.default.command('build').description('build a model').option('-y0ba, --yk0-build-app <appName>', 'Building a specified application').option('-workers <workers>', 'Building a specified application').option('-e, --env <envName>', 'yk server env')
1648
1755
  // .action(async ({app}) => {
1649
1756
  .action(function () {
1650
- var _ref29 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee24(_ref28) {
1651
- var yk0BuildApp = _ref28.yk0BuildApp,
1652
- env = _ref28.env,
1653
- wk = _ref28.workers;
1757
+ var _ref30 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee25(_ref29) {
1758
+ var yk0BuildApp = _ref29.yk0BuildApp,
1759
+ env = _ref29.env,
1760
+ wk = _ref29.workers;
1654
1761
 
1655
- var _ref30, apps, workers, cpuLen, concurrency, nextIndex, activeChildren, heartbeat, abortState, stopActiveChildren, runWorker;
1762
+ var _ref31, apps, workers, cpuLen, concurrency, nextIndex, activeChildren, heartbeat, buildSucceeded, abortState, stopActiveChildren, runWorker;
1656
1763
 
1657
- return _regenerator2.default.wrap(function _callee24$(_context24) {
1764
+ return _regenerator2.default.wrap(function _callee25$(_context25) {
1658
1765
  while (1) {
1659
- switch (_context24.prev = _context24.next) {
1766
+ switch (_context25.prev = _context25.next) {
1660
1767
  case 0:
1661
1768
  // process.env.NODE_ENV = 'production';
1662
1769
  // process.env.NODE_CMD = 'build';
@@ -1666,12 +1773,12 @@ var run = exports.run = function () {
1666
1773
  _consola2.default.log('In the preparation...');
1667
1774
  process.env.NODE_ENV = 'production';
1668
1775
  process.env.NODE_CMD = 'build';
1669
- _context24.next = 5;
1776
+ _context25.next = 5;
1670
1777
  return gi({ app: yk0BuildApp, ykServerEnv: env });
1671
1778
 
1672
1779
  case 5:
1673
- _ref30 = _context24.sent;
1674
- apps = _ref30.apps;
1780
+ _ref31 = _context25.sent;
1781
+ apps = _ref31.apps;
1675
1782
  workers = wk || process.env.YK0_CONFIG_WORKERS || process.env.npm_config_workers;
1676
1783
  // const workers = process.env.npm_config_workers;
1677
1784
 
@@ -1689,6 +1796,7 @@ var run = exports.run = function () {
1689
1796
  nextIndex = 0;
1690
1797
  activeChildren = new _set2.default();
1691
1798
  heartbeat = createBuildHeartbeat(apps);
1799
+ buildSucceeded = false;
1692
1800
  abortState = {
1693
1801
  stopped: false,
1694
1802
  error: null
@@ -1703,87 +1811,96 @@ var run = exports.run = function () {
1703
1811
  };
1704
1812
 
1705
1813
  runWorker = function () {
1706
- var _ref31 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee23() {
1814
+ var _ref32 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee24() {
1707
1815
  var currentIndex;
1708
- return _regenerator2.default.wrap(function _callee23$(_context23) {
1816
+ return _regenerator2.default.wrap(function _callee24$(_context24) {
1709
1817
  while (1) {
1710
- switch (_context23.prev = _context23.next) {
1818
+ switch (_context24.prev = _context24.next) {
1711
1819
  case 0:
1712
1820
  if (!(!abortState.stopped && nextIndex < apps.length)) {
1713
- _context23.next = 14;
1821
+ _context24.next = 14;
1714
1822
  break;
1715
1823
  }
1716
1824
 
1717
1825
  currentIndex = nextIndex;
1718
1826
 
1719
1827
  nextIndex += 1;
1720
- _context23.prev = 3;
1721
- _context23.next = 6;
1828
+ _context24.prev = 3;
1829
+ _context24.next = 6;
1722
1830
  return spawnBuildProcess(apps[currentIndex], { activeChildren: activeChildren, abortState: abortState });
1723
1831
 
1724
1832
  case 6:
1725
- _context23.next = 12;
1833
+ _context24.next = 12;
1726
1834
  break;
1727
1835
 
1728
1836
  case 8:
1729
- _context23.prev = 8;
1730
- _context23.t0 = _context23['catch'](3);
1837
+ _context24.prev = 8;
1838
+ _context24.t0 = _context24['catch'](3);
1731
1839
 
1732
1840
  if (!abortState.error) {
1733
- abortState.error = _context23.t0;
1841
+ abortState.error = _context24.t0;
1734
1842
  abortState.stopped = true;
1735
1843
  stopActiveChildren();
1736
1844
  }
1737
- throw _context23.t0;
1845
+ throw _context24.t0;
1738
1846
 
1739
1847
  case 12:
1740
- _context23.next = 0;
1848
+ _context24.next = 0;
1741
1849
  break;
1742
1850
 
1743
1851
  case 14:
1744
1852
  case 'end':
1745
- return _context23.stop();
1853
+ return _context24.stop();
1746
1854
  }
1747
1855
  }
1748
- }, _callee23, undefined, [[3, 8]]);
1856
+ }, _callee24, undefined, [[3, 8]]);
1749
1857
  }));
1750
1858
 
1751
1859
  return function runWorker() {
1752
- return _ref31.apply(this, arguments);
1860
+ return _ref32.apply(this, arguments);
1753
1861
  };
1754
1862
  }();
1755
1863
 
1756
- _context24.prev = 18;
1757
- _context24.next = 21;
1864
+ _context25.prev = 19;
1865
+ _context25.next = 22;
1758
1866
  return _promise2.default.all((0, _from2.default)({ length: concurrency }, function () {
1759
1867
  return runWorker();
1760
1868
  }));
1761
1869
 
1762
- case 21:
1763
- _context24.next = 26;
1870
+ case 22:
1871
+ buildSucceeded = true;
1872
+ heartbeat.markCompleted({ appCount: apps.length });
1873
+ _consola2.default.success('Build completed for ' + apps.length + ' app(s).');
1874
+ _context25.next = 31;
1764
1875
  break;
1765
1876
 
1766
- case 23:
1767
- _context24.prev = 23;
1768
- _context24.t0 = _context24['catch'](18);
1769
- throw abortState.error || _context24.t0;
1877
+ case 27:
1878
+ _context25.prev = 27;
1879
+ _context25.t0 = _context25['catch'](19);
1880
+
1881
+ heartbeat.markFailed(abortState.error || _context25.t0);
1882
+ throw abortState.error || _context25.t0;
1770
1883
 
1771
- case 26:
1772
- _context24.prev = 26;
1884
+ case 31:
1885
+ _context25.prev = 31;
1886
+ _context25.next = 34;
1887
+ return heartbeat.stop({
1888
+ graceMs: buildSucceeded ? BUILD_HEARTBEAT_GRACE_MS : 0
1889
+ });
1773
1890
 
1774
- heartbeat.stop();
1775
- return _context24.finish(26);
1891
+ case 34:
1892
+ return _context25.finish(31);
1776
1893
 
1777
- case 29:
1894
+ case 35:
1778
1895
  case 'end':
1779
- return _context24.stop();
1896
+ return _context25.stop();
1780
1897
  }
1781
1898
  }
1782
- }, _callee24, undefined, [[18, 23, 26, 29]]);
1899
+ }, _callee25, undefined, [[19, 27, 31, 35]]);
1783
1900
  }));
1784
1901
 
1785
- return function (_x37) {
1786
- return _ref29.apply(this, arguments);
1902
+ return function (_x41) {
1903
+ return _ref30.apply(this, arguments);
1787
1904
  };
1788
1905
  }());
1789
1906
 
@@ -1791,147 +1908,147 @@ var run = exports.run = function () {
1791
1908
  // .option('-y0ba, --yk0-build-app <appName>', 'Building a specified application')
1792
1909
  // .action(async ({app}) => {
1793
1910
  .action(function () {
1794
- var _ref32 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee25(cmd) {
1795
- return _regenerator2.default.wrap(function _callee25$(_context25) {
1911
+ var _ref33 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee26(cmd) {
1912
+ return _regenerator2.default.wrap(function _callee26$(_context26) {
1796
1913
  while (1) {
1797
- switch (_context25.prev = _context25.next) {
1914
+ switch (_context26.prev = _context26.next) {
1798
1915
  case 0:
1799
1916
  process.env.NODE_ENV = 'production';
1800
1917
  process.env.NODE_CMD = 'build';
1801
1918
  // console.log(app);
1802
1919
  // gi({app: yk0BuildApp});
1803
1920
  alias({ appName: cmd });
1804
- _context25.next = 5;
1921
+ _context26.next = 5;
1805
1922
  return require(params.serverPath)('build', cmd);
1806
1923
 
1807
1924
  case 5:
1808
1925
  case 'end':
1809
- return _context25.stop();
1926
+ return _context26.stop();
1810
1927
  }
1811
1928
  }
1812
- }, _callee25, undefined);
1929
+ }, _callee26, undefined);
1813
1930
  }));
1814
1931
 
1815
- return function (_x38) {
1816
- return _ref32.apply(this, arguments);
1932
+ return function (_x42) {
1933
+ return _ref33.apply(this, arguments);
1817
1934
  };
1818
1935
  }());
1819
1936
 
1820
- _commander2.default.command('generate').alias('g').description('generate a model').action((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee26() {
1821
- return _regenerator2.default.wrap(function _callee26$(_context26) {
1937
+ _commander2.default.command('generate').alias('g').description('generate a model').action((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee27() {
1938
+ return _regenerator2.default.wrap(function _callee27$(_context27) {
1822
1939
  while (1) {
1823
- switch (_context26.prev = _context26.next) {
1940
+ switch (_context27.prev = _context27.next) {
1824
1941
  case 0:
1825
1942
  process.env.NODE_ENV = 'production';
1826
- _context26.next = 3;
1943
+ _context27.next = 3;
1827
1944
  return gi();
1828
1945
 
1829
1946
  case 3:
1830
- _context26.prev = 3;
1831
- _context26.next = 6;
1947
+ _context27.prev = 3;
1948
+ _context27.next = 6;
1832
1949
  return nuxtCli.run(['generate']);
1833
1950
 
1834
1951
  case 6:
1835
- _context26.next = 12;
1952
+ _context27.next = 12;
1836
1953
  break;
1837
1954
 
1838
1955
  case 8:
1839
- _context26.prev = 8;
1840
- _context26.t0 = _context26['catch'](3);
1956
+ _context27.prev = 8;
1957
+ _context27.t0 = _context27['catch'](3);
1841
1958
 
1842
- _consola2.default.fatal(_context26.t0);
1959
+ _consola2.default.fatal(_context27.t0);
1843
1960
  process.exit(2);
1844
1961
 
1845
1962
  case 12:
1846
1963
  case 'end':
1847
- return _context26.stop();
1964
+ return _context27.stop();
1848
1965
  }
1849
1966
  }
1850
- }, _callee26, undefined, [[3, 8]]);
1967
+ }, _callee27, undefined, [[3, 8]]);
1851
1968
  })));
1852
1969
 
1853
- _commander2.default.command('clean').description('clean cache').action((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee27() {
1854
- return _regenerator2.default.wrap(function _callee27$(_context27) {
1970
+ _commander2.default.command('clean').description('clean cache').action((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee28() {
1971
+ return _regenerator2.default.wrap(function _callee28$(_context28) {
1855
1972
  while (1) {
1856
- switch (_context27.prev = _context27.next) {
1973
+ switch (_context28.prev = _context28.next) {
1857
1974
  case 0:
1858
1975
  _rimraf2.default.sync(_paths2.default.hardSourceCache);
1859
1976
  _rimraf2.default.sync(_paths2.default.ykRootCacheDir);
1860
1977
 
1861
1978
  case 2:
1862
1979
  case 'end':
1863
- return _context27.stop();
1980
+ return _context28.stop();
1864
1981
  }
1865
1982
  }
1866
- }, _callee27, undefined);
1983
+ }, _callee28, undefined);
1867
1984
  })));
1868
1985
 
1869
- _commander2.default.command('cr').description('Code screening secondary compression').action((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee28() {
1870
- return _regenerator2.default.wrap(function _callee28$(_context28) {
1986
+ _commander2.default.command('cr').description('Code screening secondary compression').action((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee29() {
1987
+ return _regenerator2.default.wrap(function _callee29$(_context29) {
1871
1988
  while (1) {
1872
- switch (_context28.prev = _context28.next) {
1989
+ switch (_context29.prev = _context29.next) {
1873
1990
  case 0:
1874
- _context28.next = 2;
1991
+ _context29.next = 2;
1875
1992
  return (0, _compress2.default)();
1876
1993
 
1877
1994
  case 2:
1878
1995
  case 'end':
1879
- return _context28.stop();
1996
+ return _context29.stop();
1880
1997
  }
1881
1998
  }
1882
- }, _callee28, undefined);
1999
+ }, _callee29, undefined);
1883
2000
  })));
1884
2001
 
1885
2002
  _commander2.default.command('verify <cmd>').option('-ed, --edit <envName>', 'commit file').option('-m, --msg <msg>', 'commit msg').option('-y0ba, --yk0-build-app <appName>', 'Building a specified application').option('-e, --env <envName>', 'yk server env').description('husky').action(function () {
1886
- var _ref37 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee29(cmd, _ref36) {
1887
- var edit = _ref36.edit,
1888
- msg = _ref36.msg,
1889
- yk0BuildApp = _ref36.yk0BuildApp,
1890
- env = _ref36.env;
1891
- return _regenerator2.default.wrap(function _callee29$(_context29) {
2003
+ var _ref38 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee30(cmd, _ref37) {
2004
+ var edit = _ref37.edit,
2005
+ msg = _ref37.msg,
2006
+ yk0BuildApp = _ref37.yk0BuildApp,
2007
+ env = _ref37.env;
2008
+ return _regenerator2.default.wrap(function _callee30$(_context30) {
1892
2009
  while (1) {
1893
- switch (_context29.prev = _context29.next) {
2010
+ switch (_context30.prev = _context30.next) {
1894
2011
  case 0:
1895
2012
  alias({ appName: "__common" });
1896
2013
 
1897
2014
  if (!(cmd !== "commit-init")) {
1898
- _context29.next = 4;
2015
+ _context30.next = 4;
1899
2016
  break;
1900
2017
  }
1901
2018
 
1902
- _context29.next = 4;
2019
+ _context30.next = 4;
1903
2020
  return gi({ app: yk0BuildApp, ykServerEnv: env, appsNoneExit: false });
1904
2021
 
1905
2022
  case 4:
1906
- _context29.t0 = cmd;
1907
- _context29.next = _context29.t0 === "commit-init" ? 7 : 8;
2023
+ _context30.t0 = cmd;
2024
+ _context30.next = _context30.t0 === "commit-init" ? 7 : 8;
1908
2025
  break;
1909
2026
 
1910
2027
  case 7:
1911
- return _context29.abrupt('break', 14);
2028
+ return _context30.abrupt('break', 14);
1912
2029
 
1913
2030
  case 8:
1914
- _context29.next = 10;
2031
+ _context30.next = 10;
1915
2032
  return (0, _verify.commitEsLint)({ edit: edit });
1916
2033
 
1917
2034
  case 10:
1918
- _context29.next = 12;
2035
+ _context30.next = 12;
1919
2036
  return (0, _verify.commitStyleLint)({ edit: edit });
1920
2037
 
1921
2038
  case 12:
1922
- _context29.next = 14;
2039
+ _context30.next = 14;
1923
2040
  return (0, _verify.commitMsg)({ edit: msg });
1924
2041
 
1925
2042
  case 14:
1926
2043
  case 'end':
1927
- return _context29.stop();
2044
+ return _context30.stop();
1928
2045
  }
1929
2046
  }
1930
- }, _callee29, undefined);
2047
+ }, _callee30, undefined);
1931
2048
  }));
1932
2049
 
1933
- return function (_x39, _x40) {
1934
- return _ref37.apply(this, arguments);
2050
+ return function (_x43, _x44) {
2051
+ return _ref38.apply(this, arguments);
1935
2052
  };
1936
2053
  }()
1937
2054
  // case "commit-eslint":
@@ -1946,78 +2063,78 @@ var run = exports.run = function () {
1946
2063
  );
1947
2064
 
1948
2065
  _commander2.default.command('server <cmd>').alias('s').option('-y0ba, --yk0-build-app <appName>', 'Building a specified application').option('-e, --env <envName>', 'yk server env').description('service control').action(function () {
1949
- var _ref39 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee31(cmd, _ref38) {
1950
- var yk0BuildApp = _ref38.yk0BuildApp,
1951
- env = _ref38.env;
2066
+ var _ref40 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee32(cmd, _ref39) {
2067
+ var yk0BuildApp = _ref39.yk0BuildApp,
2068
+ env = _ref39.env;
1952
2069
 
1953
- var _ref40, apps;
2070
+ var _ref41, apps;
1954
2071
 
1955
- return _regenerator2.default.wrap(function _callee31$(_context31) {
2072
+ return _regenerator2.default.wrap(function _callee32$(_context32) {
1956
2073
  while (1) {
1957
- switch (_context31.prev = _context31.next) {
2074
+ switch (_context32.prev = _context32.next) {
1958
2075
  case 0:
1959
2076
  if (!(_os2.default.platform() === 'win32')) {
1960
- _context31.next = 3;
2077
+ _context32.next = 3;
1961
2078
  break;
1962
2079
  }
1963
2080
 
1964
2081
  _consola2.default.error(_msg.errMsg['os.win32.cmd.server']);
1965
- return _context31.abrupt('return');
2082
+ return _context32.abrupt('return');
1966
2083
 
1967
2084
  case 3:
1968
2085
  process.env.NODE_ENV = 'production';
1969
2086
  process.env.NODE_CMD = 'server ' + cmd;
1970
- _context31.next = 7;
2087
+ _context32.next = 7;
1971
2088
  return gi({ app: yk0BuildApp, ykServerEnv: env });
1972
2089
 
1973
2090
  case 7:
1974
- _ref40 = _context31.sent;
1975
- apps = _ref40.apps;
2091
+ _ref41 = _context32.sent;
2092
+ apps = _ref41.apps;
1976
2093
 
1977
2094
  if (!['start', 'stop', 'restart', 'lite', 'container'].includes(cmd)) {
1978
- _context31.next = 21;
2095
+ _context32.next = 21;
1979
2096
  break;
1980
2097
  }
1981
2098
 
1982
- _context31.t0 = cmd;
1983
- _context31.next = _context31.t0 === 'lite' ? 13 : 17;
2099
+ _context32.t0 = cmd;
2100
+ _context32.next = _context32.t0 === 'lite' ? 13 : 17;
1984
2101
  break;
1985
2102
 
1986
2103
  case 13:
1987
2104
  alias({ appName: apps[0] });
1988
- _context31.next = 16;
2105
+ _context32.next = 16;
1989
2106
  return require(params.serverLite)(cmd);
1990
2107
 
1991
2108
  case 16:
1992
- return _context31.abrupt('break', 19);
2109
+ return _context32.abrupt('break', 19);
1993
2110
 
1994
2111
  case 17:
1995
- _context31.next = 19;
2112
+ _context32.next = 19;
1996
2113
  return _server._.asyncMap(apps, function () {
1997
- var _ref41 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee30(key, j) {
1998
- return _regenerator2.default.wrap(function _callee30$(_context30) {
2114
+ var _ref42 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee31(key, j) {
2115
+ return _regenerator2.default.wrap(function _callee31$(_context31) {
1999
2116
  while (1) {
2000
- switch (_context30.prev = _context30.next) {
2117
+ switch (_context31.prev = _context31.next) {
2001
2118
  case 0:
2002
2119
  alias({ appName: key });
2003
- _context30.next = 3;
2120
+ _context31.next = 3;
2004
2121
  return require(params.serverPath)(cmd, key, j !== apps.length - 1);
2005
2122
 
2006
2123
  case 3:
2007
2124
  case 'end':
2008
- return _context30.stop();
2125
+ return _context31.stop();
2009
2126
  }
2010
2127
  }
2011
- }, _callee30, undefined);
2128
+ }, _callee31, undefined);
2012
2129
  }));
2013
2130
 
2014
- return function (_x43, _x44) {
2015
- return _ref41.apply(this, arguments);
2131
+ return function (_x47, _x48) {
2132
+ return _ref42.apply(this, arguments);
2016
2133
  };
2017
2134
  }());
2018
2135
 
2019
2136
  case 19:
2020
- _context31.next = 23;
2137
+ _context32.next = 23;
2021
2138
  break;
2022
2139
 
2023
2140
  case 21:
@@ -2026,14 +2143,14 @@ var run = exports.run = function () {
2026
2143
 
2027
2144
  case 23:
2028
2145
  case 'end':
2029
- return _context31.stop();
2146
+ return _context32.stop();
2030
2147
  }
2031
2148
  }
2032
- }, _callee31, undefined);
2149
+ }, _callee32, undefined);
2033
2150
  }));
2034
2151
 
2035
- return function (_x41, _x42) {
2036
- return _ref39.apply(this, arguments);
2152
+ return function (_x45, _x46) {
2153
+ return _ref40.apply(this, arguments);
2037
2154
  };
2038
2155
  }()).on('--help', function () {
2039
2156
  console.log('');
@@ -2045,29 +2162,29 @@ var run = exports.run = function () {
2045
2162
  });
2046
2163
 
2047
2164
  _commander2.default.command('publish').alias('pub').description('Publish to server').action(function () {
2048
- var _ref42 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee32(env, options) {
2049
- return _regenerator2.default.wrap(function _callee32$(_context32) {
2165
+ var _ref43 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee33(env, options) {
2166
+ return _regenerator2.default.wrap(function _callee33$(_context33) {
2050
2167
  while (1) {
2051
- switch (_context32.prev = _context32.next) {
2168
+ switch (_context33.prev = _context33.next) {
2052
2169
  case 0:
2053
2170
  process.env.NODE_TYPE = 'publish';
2054
- _context32.next = 3;
2171
+ _context33.next = 3;
2055
2172
  return gi();
2056
2173
 
2057
2174
  case 3:
2058
- _context32.next = 5;
2175
+ _context33.next = 5;
2059
2176
  return require('../utils/deployment')();
2060
2177
 
2061
2178
  case 5:
2062
2179
  case 'end':
2063
- return _context32.stop();
2180
+ return _context33.stop();
2064
2181
  }
2065
2182
  }
2066
- }, _callee32, undefined);
2183
+ }, _callee33, undefined);
2067
2184
  }));
2068
2185
 
2069
- return function (_x45, _x46) {
2070
- return _ref42.apply(this, arguments);
2186
+ return function (_x49, _x50) {
2187
+ return _ref43.apply(this, arguments);
2071
2188
  };
2072
2189
  }());
2073
2190
 
@@ -2080,14 +2197,14 @@ var run = exports.run = function () {
2080
2197
 
2081
2198
  case 32:
2082
2199
  case 'end':
2083
- return _context33.stop();
2200
+ return _context34.stop();
2084
2201
  }
2085
2202
  }
2086
- }, _callee33, undefined, [[3, 12]]);
2203
+ }, _callee34, undefined, [[3, 12]]);
2087
2204
  }));
2088
2205
 
2089
- return function run(_x33) {
2090
- return _ref21.apply(this, arguments);
2206
+ return function run(_x37) {
2207
+ return _ref22.apply(this, arguments);
2091
2208
  };
2092
2209
  }();
2093
2210