github-labels-template 0.8.0-patch.30e7740 → 0.8.0-patch.f835045
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 +28 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1240,7 +1240,7 @@ import pc8 from "picocolors";
|
|
|
1240
1240
|
// package.json
|
|
1241
1241
|
var package_default = {
|
|
1242
1242
|
name: "github-labels-template",
|
|
1243
|
-
version: "0.8.0-patch.
|
|
1243
|
+
version: "0.8.0-patch.f835045",
|
|
1244
1244
|
description: "A CLI tool to apply a curated GitHub labels template to any repository using gh CLI.",
|
|
1245
1245
|
type: "module",
|
|
1246
1246
|
bin: {
|
|
@@ -1306,15 +1306,15 @@ function getAuthor() {
|
|
|
1306
1306
|
}
|
|
1307
1307
|
function showUpdateBanner(latestVersion) {
|
|
1308
1308
|
const current = getVersion();
|
|
1309
|
-
const inner1 = ` Update available: v${current} → v${latestVersion} `;
|
|
1310
|
-
const inner2 = ` Run ${pc8.bold("ghlt update")} to upgrade. `;
|
|
1311
1309
|
const visibleLen = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
1312
|
-
const
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
console.log(pc8.yellow(
|
|
1317
|
-
console.log(pc8.yellow(
|
|
1310
|
+
const line1 = ` ${pc8.bold(`Update available: v${current} → v${latestVersion}`)} `;
|
|
1311
|
+
const line2 = ` Run ${pc8.bold("ghlt update")} to upgrade. `;
|
|
1312
|
+
const width = Math.max(visibleLen(line1), visibleLen(line2));
|
|
1313
|
+
const border = "─".repeat(width);
|
|
1314
|
+
console.log(pc8.yellow(`┌${border}┐`));
|
|
1315
|
+
console.log(pc8.yellow("│") + line1 + " ".repeat(width - visibleLen(line1)) + pc8.yellow("│"));
|
|
1316
|
+
console.log(pc8.yellow("│") + line2 + " ".repeat(width - visibleLen(line2)) + pc8.yellow("│"));
|
|
1317
|
+
console.log(pc8.yellow(`└${border}┘`));
|
|
1318
1318
|
console.log();
|
|
1319
1319
|
}
|
|
1320
1320
|
function showBanner(minimal = false) {
|
|
@@ -1332,17 +1332,19 @@ function showBanner(minimal = false) {
|
|
|
1332
1332
|
}
|
|
1333
1333
|
|
|
1334
1334
|
// src/utils/updater.ts
|
|
1335
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync } from "fs";
|
|
1336
|
-
import { join } from "path";
|
|
1337
|
-
import { homedir } from "os";
|
|
1335
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync, renameSync } from "fs";
|
|
1336
|
+
import { join, dirname } from "path";
|
|
1337
|
+
import { homedir, tmpdir } from "os";
|
|
1338
1338
|
var CACHE_DIR = join(homedir(), ".ghlt");
|
|
1339
1339
|
var CACHE_FILE = join(CACHE_DIR, "update-check.json");
|
|
1340
1340
|
var CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
1341
1341
|
var REGISTRY_URL = "https://registry.npmjs.org/github-labels-template/latest";
|
|
1342
1342
|
function isNewerVersion(latest, current) {
|
|
1343
|
-
const parse = (v) => v.replace(/^v/, "").split(".").map(Number);
|
|
1343
|
+
const parse = (v) => v.replace(/^v/, "").split(/[-+]/)[0].split(".").map(Number);
|
|
1344
1344
|
const [lMaj, lMin, lPatch] = parse(latest);
|
|
1345
1345
|
const [cMaj, cMin, cPatch] = parse(current);
|
|
1346
|
+
if ([lMaj, lMin, lPatch, cMaj, cMin, cPatch].some(isNaN))
|
|
1347
|
+
return false;
|
|
1346
1348
|
if (lMaj !== cMaj)
|
|
1347
1349
|
return lMaj > cMaj;
|
|
1348
1350
|
if (lMin !== cMin)
|
|
@@ -1361,10 +1363,12 @@ function readCache(cacheFile = CACHE_FILE) {
|
|
|
1361
1363
|
}
|
|
1362
1364
|
function writeCache(data, cacheFile = CACHE_FILE) {
|
|
1363
1365
|
try {
|
|
1364
|
-
const dir =
|
|
1366
|
+
const dir = dirname(cacheFile);
|
|
1365
1367
|
if (!existsSync2(dir))
|
|
1366
1368
|
mkdirSync(dir, { recursive: true });
|
|
1367
|
-
|
|
1369
|
+
const tmp = join(tmpdir(), `ghlt-update-${process.pid}-${Date.now()}.json`);
|
|
1370
|
+
writeFileSync2(tmp, JSON.stringify(data), "utf-8");
|
|
1371
|
+
renameSync(tmp, cacheFile);
|
|
1368
1372
|
} catch {}
|
|
1369
1373
|
}
|
|
1370
1374
|
async function fetchLatestVersion() {
|
|
@@ -1374,7 +1378,8 @@ async function fetchLatestVersion() {
|
|
|
1374
1378
|
return null;
|
|
1375
1379
|
const data = await res.json();
|
|
1376
1380
|
return data.version ?? null;
|
|
1377
|
-
} catch {
|
|
1381
|
+
} catch (err) {
|
|
1382
|
+
console.debug("Failed to fetch latest version from npm registry:", err);
|
|
1378
1383
|
return null;
|
|
1379
1384
|
}
|
|
1380
1385
|
}
|
|
@@ -1458,6 +1463,7 @@ var update_default = defineCommand7({
|
|
|
1458
1463
|
try {
|
|
1459
1464
|
const pm = detectPackageManager();
|
|
1460
1465
|
const cmd = getUpdateCommand(pm);
|
|
1466
|
+
info(`Running: ${cmd}`);
|
|
1461
1467
|
execSync(cmd, { stdio: "inherit" });
|
|
1462
1468
|
success(`ghlt updated to v${latest}`);
|
|
1463
1469
|
} catch {
|
|
@@ -1470,10 +1476,13 @@ var update_default = defineCommand7({
|
|
|
1470
1476
|
|
|
1471
1477
|
// src/index.ts
|
|
1472
1478
|
var isHelp = process.argv.includes("--help") || process.argv.includes("-h");
|
|
1479
|
+
var isUpdateCommand = process.argv.includes("update");
|
|
1473
1480
|
showBanner(isHelp);
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1481
|
+
if (!isUpdateCommand) {
|
|
1482
|
+
const availableUpdate = checkForUpdate();
|
|
1483
|
+
if (availableUpdate) {
|
|
1484
|
+
showUpdateBanner(availableUpdate);
|
|
1485
|
+
}
|
|
1477
1486
|
}
|
|
1478
1487
|
var main = defineCommand8({
|
|
1479
1488
|
meta: {
|
package/package.json
CHANGED