servicemap 0.1.14 → 0.1.16
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.
- package/bin/servicemap.mjs +38 -2
- package/package.json +1 -1
package/bin/servicemap.mjs
CHANGED
|
@@ -475,6 +475,42 @@ function runSilent(command, args, options = {}) {
|
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
+
function wait(ms) {
|
|
479
|
+
return new Promise((resolvePromise) => {
|
|
480
|
+
setTimeout(resolvePromise, ms);
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
async function withSpinner(message, action, minimumMs = 900) {
|
|
485
|
+
if (!process.stdout.isTTY) {
|
|
486
|
+
return action();
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const frames = ['◒', '◐', '◓', '◑'];
|
|
490
|
+
let frame = 0;
|
|
491
|
+
let dots = '';
|
|
492
|
+
const startedAt = Date.now();
|
|
493
|
+
const writeFrame = () => {
|
|
494
|
+
process.stdout.write(`\r\x1b[J${frames[frame]} ${message}${dots}`);
|
|
495
|
+
frame = (frame + 1) % frames.length;
|
|
496
|
+
if (frame === 0) dots = dots.length >= 5 ? '' : `${dots}.`;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
process.stdout.write('\x1b[?25l');
|
|
500
|
+
writeFrame();
|
|
501
|
+
const interval = setInterval(writeFrame, 120);
|
|
502
|
+
|
|
503
|
+
try {
|
|
504
|
+
const result = await action();
|
|
505
|
+
const remainingMs = minimumMs - (Date.now() - startedAt);
|
|
506
|
+
if (remainingMs > 0) await wait(remainingMs);
|
|
507
|
+
return result;
|
|
508
|
+
} finally {
|
|
509
|
+
clearInterval(interval);
|
|
510
|
+
process.stdout.write('\r\x1b[J\x1b[?25h');
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
478
514
|
async function prepareStableSource(options) {
|
|
479
515
|
const sourceRoot = stableSourceRoot();
|
|
480
516
|
if (options.dryRun) {
|
|
@@ -487,11 +523,11 @@ async function prepareStableSource(options) {
|
|
|
487
523
|
|
|
488
524
|
try {
|
|
489
525
|
if (existsSync(join(sourceRoot, '.git'))) {
|
|
490
|
-
await runSilent('git', ['pull', '--ff-only'], { cwd: sourceRoot });
|
|
526
|
+
await withSpinner('Updating repository…', () => runSilent('git', ['pull', '--ff-only'], { cwd: sourceRoot }));
|
|
491
527
|
timelineStep('Repository updated');
|
|
492
528
|
} else {
|
|
493
529
|
await rm(sourceRoot, { recursive: true, force: true });
|
|
494
|
-
await runSilent('git', ['clone', '--depth', '1', repositoryUrl, sourceRoot]);
|
|
530
|
+
await withSpinner('Cloning repository…', () => runSilent('git', ['clone', '--depth', '1', repositoryUrl, sourceRoot]));
|
|
495
531
|
timelineStep('Repository cloned');
|
|
496
532
|
}
|
|
497
533
|
} catch (_error) {
|