@genrtl/grtl 2.2.1 → 2.3.0
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/dist/index.js +60 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1398,7 +1398,7 @@ function registerCbbCommands(program2) {
|
|
|
1398
1398
|
}
|
|
1399
1399
|
|
|
1400
1400
|
// src/commands/upgrade.ts
|
|
1401
|
-
import { confirm } from "@inquirer/prompts";
|
|
1401
|
+
import { confirm, select } from "@inquirer/prompts";
|
|
1402
1402
|
import { spawn } from "child_process";
|
|
1403
1403
|
import pc5 from "picocolors";
|
|
1404
1404
|
|
|
@@ -1570,11 +1570,24 @@ async function shouldShowUpdateNotification(info, options = {}) {
|
|
|
1570
1570
|
const now = options.now ?? Date.now();
|
|
1571
1571
|
const cooldownMs = options.cooldownMs ?? DEFAULT_CACHE_TTL_MS;
|
|
1572
1572
|
const state = await readUpdateState(options.stateFile);
|
|
1573
|
+
if (state.ignoredVersion === info.latestVersion) {
|
|
1574
|
+
return false;
|
|
1575
|
+
}
|
|
1573
1576
|
if (state.notifiedVersion === info.latestVersion && state.lastNotifiedAt && now - state.lastNotifiedAt < cooldownMs) {
|
|
1574
1577
|
return false;
|
|
1575
1578
|
}
|
|
1576
1579
|
return true;
|
|
1577
1580
|
}
|
|
1581
|
+
async function markUpdateNotificationIgnored(latestVersion, options = {}) {
|
|
1582
|
+
const state = await readUpdateState(options.stateFile);
|
|
1583
|
+
await writeUpdateState(
|
|
1584
|
+
{
|
|
1585
|
+
...state,
|
|
1586
|
+
ignoredVersion: latestVersion
|
|
1587
|
+
},
|
|
1588
|
+
options.stateFile
|
|
1589
|
+
);
|
|
1590
|
+
}
|
|
1578
1591
|
async function markUpdateNotificationShown(latestVersion, options = {}) {
|
|
1579
1592
|
const now = options.now ?? Date.now();
|
|
1580
1593
|
const state = await readUpdateState(options.stateFile);
|
|
@@ -1592,6 +1605,7 @@ function shouldSkipUpdateNotifier(argv = process.argv) {
|
|
|
1592
1605
|
}
|
|
1593
1606
|
|
|
1594
1607
|
// src/commands/upgrade.ts
|
|
1608
|
+
var RELEASE_NOTES_URL = "https://github.com/xroting/grtl/releases/latest";
|
|
1595
1609
|
function registerUpgradeCommand(program2) {
|
|
1596
1610
|
program2.command("upgrade").description("Check for a newer grtl version and upgrade when possible").option("-y, --yes", "Run the suggested upgrade command without prompting").option("--check", "Only check for updates without running the upgrade command").action(async (options) => {
|
|
1597
1611
|
await upgradeCommand(options);
|
|
@@ -1635,33 +1649,62 @@ async function maybeShowUpgradeNotice(options = {}) {
|
|
|
1635
1649
|
if (!info || !info.updateAvailable || !await shouldShowUpdateNotification(info)) {
|
|
1636
1650
|
return;
|
|
1637
1651
|
}
|
|
1652
|
+
const choices = [];
|
|
1638
1653
|
log.blank();
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1654
|
+
log.plain(`${pc5.dim("Release notes:")} ${pc5.underline(pc5.dim(RELEASE_NOTES_URL))}`);
|
|
1655
|
+
if (info.upgradePlan.canRun) {
|
|
1656
|
+
choices.push({
|
|
1657
|
+
name: `Update now (runs \`${info.upgradePlan.displayCommand}\`)`,
|
|
1658
|
+
value: "update"
|
|
1659
|
+
});
|
|
1660
|
+
} else {
|
|
1661
|
+
const verb = info.upgradePlan.needsExplicitVersion ? "Use" : "Run";
|
|
1662
|
+
log.info(`${verb} ${pc5.cyan(info.upgradePlan.displayCommand)} to update.`);
|
|
1663
|
+
}
|
|
1664
|
+
choices.push(
|
|
1665
|
+
{ name: "Skip", value: "skip" },
|
|
1666
|
+
{
|
|
1667
|
+
name: "Skip until next version",
|
|
1668
|
+
value: "skip-version",
|
|
1669
|
+
description: `Do not show this prompt again for v${info.latestVersion}.`
|
|
1670
|
+
}
|
|
1671
|
+
);
|
|
1672
|
+
let choice;
|
|
1673
|
+
try {
|
|
1674
|
+
choice = await select({
|
|
1675
|
+
message: `Update available: v${info.currentVersion} -> v${info.latestVersion}`,
|
|
1676
|
+
choices
|
|
1677
|
+
});
|
|
1678
|
+
} catch {
|
|
1644
1679
|
await markUpdateNotificationShown(info.latestVersion);
|
|
1645
1680
|
log.blank();
|
|
1646
1681
|
return;
|
|
1647
1682
|
}
|
|
1648
|
-
if (
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1683
|
+
if (choice === "skip-version") {
|
|
1684
|
+
await markUpdateNotificationIgnored(info.latestVersion);
|
|
1685
|
+
log.blank();
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
if (choice === "skip") {
|
|
1654
1689
|
await markUpdateNotificationShown(info.latestVersion);
|
|
1655
1690
|
log.blank();
|
|
1656
1691
|
return;
|
|
1657
1692
|
}
|
|
1658
|
-
log.box([
|
|
1659
|
-
`${pc5.white(pc5.bold("Update available:"))} ${pc5.green(pc5.bold(`v${info.currentVersion}`))} ${pc5.dim("->")} ${pc5.green(pc5.bold(`v${info.latestVersion}`))}`,
|
|
1660
|
-
`${pc5.white("Run")} ${pc5.yellow(pc5.bold("grtl upgrade"))} ${pc5.white("to update now")}`,
|
|
1661
|
-
`${pc5.white("Or run")} ${pc5.yellow(info.upgradePlan.displayCommand)}`
|
|
1662
|
-
]);
|
|
1663
1693
|
await markUpdateNotificationShown(info.latestVersion);
|
|
1664
1694
|
log.blank();
|
|
1695
|
+
const exitCode = await runUpgradePlan(info.upgradePlan);
|
|
1696
|
+
if (exitCode === 0) {
|
|
1697
|
+
log.blank();
|
|
1698
|
+
log.success("Upgrade complete.");
|
|
1699
|
+
log.info(`Restart your terminal or run ${pc5.cyan("grtl --version")} to verify.`);
|
|
1700
|
+
log.blank();
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
log.blank();
|
|
1704
|
+
log.error(`Upgrade command exited with code ${exitCode ?? "unknown"}.`);
|
|
1705
|
+
showUpgradeFailureHelp(info.upgradePlan);
|
|
1706
|
+
process.exitCode = 1;
|
|
1707
|
+
log.blank();
|
|
1665
1708
|
}
|
|
1666
1709
|
async function upgradeCommand(options) {
|
|
1667
1710
|
trackEvent("command", { name: "upgrade" });
|