blun-king-cli 9.1.20 → 9.1.21
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/update-notice.js +47 -22
- package/blun.mjs +222 -197
- package/package.json +1 -1
- package/standard-tools/language-guard/blun_language_guard.py +22 -15
package/bin/update-notice.js
CHANGED
|
@@ -449,48 +449,65 @@ function installCommandText(version) {
|
|
|
449
449
|
function createUpdateProgress(output) {
|
|
450
450
|
const enabled = output?.isTTY === true;
|
|
451
451
|
const phaseCount = 4;
|
|
452
|
-
const width =
|
|
453
|
-
|
|
452
|
+
const width = 24;
|
|
453
|
+
const cyan = '\u001B[36m';
|
|
454
|
+
const dim = '\u001B[2m';
|
|
455
|
+
const reset = '\u001B[0m';
|
|
456
|
+
let active = false;
|
|
457
|
+
const update = (phase, label) => {
|
|
454
458
|
if (!enabled) return;
|
|
455
459
|
const completed = Math.max(0, Math.min(phaseCount, phase));
|
|
456
460
|
const filled = Math.round((completed / phaseCount) * width);
|
|
457
|
-
const bar = `${'
|
|
458
|
-
output.write(
|
|
461
|
+
const bar = `${'━'.repeat(filled)}${'─'.repeat(width - filled)}`;
|
|
462
|
+
output.write(`\r\u001B[2K${cyan}${bar}${reset} ${dim}${completed}/${phaseCount}${reset} ${label}`);
|
|
463
|
+
active = completed < phaseCount;
|
|
464
|
+
if (!active) output.write('\n');
|
|
459
465
|
};
|
|
466
|
+
update.finish = () => {
|
|
467
|
+
if (!enabled || !active) return;
|
|
468
|
+
active = false;
|
|
469
|
+
output.write('\n');
|
|
470
|
+
};
|
|
471
|
+
return update;
|
|
460
472
|
}
|
|
461
473
|
|
|
462
474
|
function promptUpdateAction({ currentVersion, release, input, output, processRef = process }) {
|
|
463
475
|
return new Promise((resolve, reject) => {
|
|
464
|
-
let selected =
|
|
476
|
+
let selected = 0;
|
|
465
477
|
let settled = false;
|
|
466
478
|
let cursorHidden = false;
|
|
467
479
|
let escapeTimer;
|
|
468
480
|
let pendingInput = '';
|
|
469
481
|
const decoder = new StringDecoder('utf8');
|
|
470
482
|
const wasRaw = input.isRaw === true;
|
|
483
|
+
const cyan = '\u001B[36m';
|
|
484
|
+
const dim = '\u001B[2m';
|
|
485
|
+
const underline = '\u001B[4m';
|
|
486
|
+
const reset = '\u001B[0m';
|
|
471
487
|
const actions = [
|
|
472
488
|
{
|
|
473
489
|
choice: 'install',
|
|
474
490
|
label: `Jetzt aktualisieren (führt \`${installCommandText(release.version)}\` aus)`,
|
|
475
491
|
},
|
|
476
|
-
{ choice: '
|
|
477
|
-
{ choice: 'skip-version', label: '
|
|
492
|
+
{ choice: 'skip-once', label: 'Überspringen' },
|
|
493
|
+
{ choice: 'skip-version', label: 'Auf den nächsten Release warten' },
|
|
478
494
|
];
|
|
479
495
|
const signalHandlers = new Map();
|
|
480
496
|
|
|
481
497
|
const renderActions = (refresh) => {
|
|
482
498
|
if (refresh) output.write(`\u001B[${actions.length + 1}F`);
|
|
483
499
|
for (let index = 0; index < actions.length; index += 1) {
|
|
484
|
-
|
|
500
|
+
const line = `${selected === index ? '›' : ' '} ${index + 1}. ${actions[index].label}`;
|
|
501
|
+
output.write(`\r\u001B[2K${selected === index ? cyan : ''}${line}${selected === index ? reset : ''}\n`);
|
|
485
502
|
}
|
|
486
|
-
output.write(
|
|
503
|
+
output.write(`\r\u001B[2K${dim}Enter drücken, um fortzufahren${reset}\n`);
|
|
487
504
|
};
|
|
488
505
|
const cleanup = () => {
|
|
489
506
|
if (escapeTimer !== undefined) clearTimeout(escapeTimer);
|
|
490
507
|
input.removeListener('data', onData);
|
|
491
|
-
input.removeListener('end',
|
|
492
|
-
input.removeListener('close',
|
|
493
|
-
input.removeListener('error',
|
|
508
|
+
input.removeListener('end', skipOnce);
|
|
509
|
+
input.removeListener('close', skipOnce);
|
|
510
|
+
input.removeListener('error', skipOnce);
|
|
494
511
|
for (const [signal, handler] of signalHandlers) {
|
|
495
512
|
processRef.removeListener(signal, handler);
|
|
496
513
|
}
|
|
@@ -537,14 +554,14 @@ function promptUpdateAction({ currentVersion, release, input, output, processRef
|
|
|
537
554
|
if (typeof processRef.exit === 'function') processRef.exit(exitCode);
|
|
538
555
|
reject(error);
|
|
539
556
|
};
|
|
540
|
-
function
|
|
541
|
-
finish('
|
|
557
|
+
function skipOnce() {
|
|
558
|
+
finish('skip-once');
|
|
542
559
|
}
|
|
543
560
|
const waitForEscapeSuffix = () => {
|
|
544
561
|
if (escapeTimer !== undefined) return;
|
|
545
562
|
escapeTimer = setTimeout(() => {
|
|
546
563
|
escapeTimer = undefined;
|
|
547
|
-
|
|
564
|
+
skipOnce();
|
|
548
565
|
}, UPDATE_KEY_ESCAPE_TIMEOUT_MS);
|
|
549
566
|
};
|
|
550
567
|
const clearEscapeTimer = () => {
|
|
@@ -573,7 +590,7 @@ function promptUpdateAction({ currentVersion, release, input, output, processRef
|
|
|
573
590
|
while (pendingInput.length > 0) {
|
|
574
591
|
const first = pendingInput[0];
|
|
575
592
|
if (first === '\u0003') {
|
|
576
|
-
|
|
593
|
+
skipOnce();
|
|
577
594
|
return;
|
|
578
595
|
}
|
|
579
596
|
if (first === '\r' || first === '\n') {
|
|
@@ -596,7 +613,7 @@ function promptUpdateAction({ currentVersion, release, input, output, processRef
|
|
|
596
613
|
&& (pendingInput[1] === '\r'
|
|
597
614
|
|| pendingInput[1] === '\n'
|
|
598
615
|
|| pendingInput[1] === '\u0003')) {
|
|
599
|
-
|
|
616
|
+
skipOnce();
|
|
600
617
|
return;
|
|
601
618
|
}
|
|
602
619
|
const sequence = readEscapeSequence();
|
|
@@ -638,16 +655,18 @@ function promptUpdateAction({ currentVersion, release, input, output, processRef
|
|
|
638
655
|
signalHandlers.set(signal, handler);
|
|
639
656
|
processRef.once(signal, handler);
|
|
640
657
|
}
|
|
641
|
-
output.write(`\
|
|
642
|
-
if (release.notesUrl)
|
|
658
|
+
output.write(`\nBLUN Code-Update verfügbar: ${currentVersion} -> ${release.version}\n`);
|
|
659
|
+
if (release.notesUrl) {
|
|
660
|
+
output.write(`${dim}Versionshinweise:${reset} ${underline}${release.notesUrl}${reset}\n`);
|
|
661
|
+
}
|
|
643
662
|
output.write('\n');
|
|
644
663
|
cursorHidden = true;
|
|
645
664
|
output.write('\u001B[?25l');
|
|
646
665
|
renderActions(false);
|
|
647
666
|
input.on('data', onData);
|
|
648
|
-
input.once('end',
|
|
649
|
-
input.once('close',
|
|
650
|
-
input.once('error',
|
|
667
|
+
input.once('end', skipOnce);
|
|
668
|
+
input.once('close', skipOnce);
|
|
669
|
+
input.once('error', skipOnce);
|
|
651
670
|
if (typeof input.setRawMode === 'function') input.setRawMode(true);
|
|
652
671
|
if (typeof input.resume === 'function') input.resume();
|
|
653
672
|
} catch (error) {
|
|
@@ -1260,6 +1279,9 @@ async function runUpdateFlow(options, explicitUpdate) {
|
|
|
1260
1279
|
}
|
|
1261
1280
|
if (action !== 'install') {
|
|
1262
1281
|
if (installerSession?.ready) await installerSession.cancel();
|
|
1282
|
+
if (action === 'skip-once') {
|
|
1283
|
+
return { kind: 'continue', reason: 'skipped_once' };
|
|
1284
|
+
}
|
|
1263
1285
|
if (action === 'skip-version') {
|
|
1264
1286
|
try {
|
|
1265
1287
|
writeSkippedVersion(blunDir, release.version);
|
|
@@ -1299,6 +1321,7 @@ async function runUpdateFlow(options, explicitUpdate) {
|
|
|
1299
1321
|
if (installResult?.leaseBusy === true
|
|
1300
1322
|
|| installResult?.leaseUnavailable === true
|
|
1301
1323
|
|| installResult?.unknownState === true) {
|
|
1324
|
+
updateProgress.finish();
|
|
1302
1325
|
return explicitUpdate
|
|
1303
1326
|
? explicitFailure(stderr, 'update_in_progress')
|
|
1304
1327
|
: { kind: 'update_in_progress' };
|
|
@@ -1310,12 +1333,14 @@ async function runUpdateFlow(options, explicitUpdate) {
|
|
|
1310
1333
|
}
|
|
1311
1334
|
|
|
1312
1335
|
if (Number.isInteger(installResult?.code) && installResult.code !== 0) {
|
|
1336
|
+
updateProgress.finish();
|
|
1313
1337
|
if (explicitUpdate) {
|
|
1314
1338
|
return explicitFailure(stderr, 'install_failed', installResult.code);
|
|
1315
1339
|
}
|
|
1316
1340
|
stderr.write(`Update fehlgeschlagen (Code ${installResult.code}). Die vorhandene Version wird gestartet.\n`);
|
|
1317
1341
|
return { kind: 'continue', reason: 'install_failed', exitCode: installResult.code };
|
|
1318
1342
|
}
|
|
1343
|
+
updateProgress.finish();
|
|
1319
1344
|
if (explicitUpdate) return explicitFailure(stderr, 'verification_failed');
|
|
1320
1345
|
stderr.write('Update konnte nicht verifiziert werden. Starte BLUN Code neu.\n');
|
|
1321
1346
|
return { kind: 'update_in_progress' };
|