@narumitw/pi-starship 0.57.0 → 0.59.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/README.md +26 -2
- package/dist/chunks/{chunk-W2IYFPT4.ts → chunk-MTFSZ63Q.ts} +43 -21
- package/dist/chunks/chunk-MTFSZ63Q.ts.map +7 -0
- package/dist/chunks/{commands-TW2O3UVA.ts → commands-M6GHLJIR.ts} +326 -16
- package/dist/chunks/commands-M6GHLJIR.ts.map +7 -0
- package/dist/index.ts +2 -2
- package/package.json +5 -5
- package/skills/configuring-pi-starship/references/configuration.md +10 -3
- package/skills/configuring-pi-starship/references/module-catalog.md +1 -0
- package/src/command-configuration.ts +12 -0
- package/src/command-gist.ts +208 -0
- package/src/commands.ts +44 -6
- package/src/config.ts +18 -1
- package/src/effective-config.ts +1 -0
- package/src/gist.ts +133 -0
- package/src/modules/extension-status.ts +27 -17
- package/src/modules/render.ts +16 -5
- package/src/modules/types.ts +5 -3
- package/dist/chunks/chunk-W2IYFPT4.ts.map +0 -7
- package/dist/chunks/commands-TW2O3UVA.ts.map +0 -7
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
loadStarshipConfig,
|
|
12
12
|
removeConfigDocumentIfMatches,
|
|
13
13
|
validateConfigDocument
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-MTFSZ63Q.ts";
|
|
15
15
|
|
|
16
16
|
// src/commands.ts
|
|
17
|
-
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
17
|
+
import { defineMenu as defineMenu2, runMenu as runMenu2 } from "@narumitw/pi-tui-kit";
|
|
18
18
|
|
|
19
19
|
// src/command-configuration.ts
|
|
20
20
|
import { sanitizeTerminalText } from "@narumitw/pi-tui-kit/terminal-text";
|
|
@@ -205,6 +205,7 @@ function projectEffectiveConfig(config) {
|
|
|
205
205
|
table.separator = config.extensionStatus.separator;
|
|
206
206
|
table.max_statuses = config.extensionStatus.maxStatuses;
|
|
207
207
|
table.icons = sortedRecord(config.extensionStatus.icons);
|
|
208
|
+
table.styles = sortedRecord(config.extensionStatus.styles);
|
|
208
209
|
}
|
|
209
210
|
projected[definition.name] = table;
|
|
210
211
|
}
|
|
@@ -1070,6 +1071,18 @@ function configurationMenuScreen(loaded) {
|
|
|
1070
1071
|
label: "Reload from disk\u2026",
|
|
1071
1072
|
description: "Validate and preview external changes",
|
|
1072
1073
|
action: "configuration-reload"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
id: "gist-share",
|
|
1077
|
+
label: "Share settings as Gist\u2026",
|
|
1078
|
+
description: "Upload reviewed TOML to GitHub \xB7 unlisted, not private \xB7 requires gh",
|
|
1079
|
+
action: "gist-share"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
id: "gist-import",
|
|
1083
|
+
label: "Import settings from Gist\u2026",
|
|
1084
|
+
description: "Review and preview remote TOML before replacing settings \xB7 requires gh",
|
|
1085
|
+
action: "gist-import"
|
|
1073
1086
|
}
|
|
1074
1087
|
],
|
|
1075
1088
|
hint: "back"
|
|
@@ -1266,6 +1279,277 @@ function formatError(error) {
|
|
|
1266
1279
|
return error instanceof Error ? error.message : String(error);
|
|
1267
1280
|
}
|
|
1268
1281
|
|
|
1282
|
+
// src/command-gist.ts
|
|
1283
|
+
import { defineMenu, runMenu, runTask } from "@narumitw/pi-tui-kit";
|
|
1284
|
+
import { sanitizeTerminalText as sanitizeTerminalText2 } from "@narumitw/pi-tui-kit/terminal-text";
|
|
1285
|
+
|
|
1286
|
+
// src/gist.ts
|
|
1287
|
+
import { spawn } from "node:child_process";
|
|
1288
|
+
var GIST_FILENAME = "pi-starship.toml";
|
|
1289
|
+
var MAX_GIST_DOCUMENT_BYTES = 64 * 1024;
|
|
1290
|
+
var MAX_RESPONSE_BYTES = 512 * 1024;
|
|
1291
|
+
var REQUEST_TIMEOUT_MS = 3e4;
|
|
1292
|
+
function gistId(value) {
|
|
1293
|
+
const text = value.trim();
|
|
1294
|
+
if (/^[a-f\d]{5,64}$/iu.test(text)) return text;
|
|
1295
|
+
try {
|
|
1296
|
+
const url = new URL(text);
|
|
1297
|
+
const match = /^\/(?:[\w-]+\/)?([a-f\d]{5,64})\/?$/iu.exec(url.pathname);
|
|
1298
|
+
if (url.protocol === "https:" && url.hostname === "gist.github.com" && !url.port && !url.username && !url.password && !url.search && match?.[1])
|
|
1299
|
+
return match[1];
|
|
1300
|
+
} catch {
|
|
1301
|
+
}
|
|
1302
|
+
throw new Error("Enter a github.com Gist ID or https://gist.github.com/<owner>/<id> URL.");
|
|
1303
|
+
}
|
|
1304
|
+
function checkGistDocument(rawDocument) {
|
|
1305
|
+
if (!rawDocument.trim()) throw new Error("The Gist settings document is empty.");
|
|
1306
|
+
if (Buffer.byteLength(rawDocument, "utf8") > MAX_GIST_DOCUMENT_BYTES) {
|
|
1307
|
+
throw new Error("The Gist settings document exceeds 64 KiB.");
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
async function createSettingsGist(rawDocument, signal, api = executeGhApi) {
|
|
1311
|
+
checkGistDocument(rawDocument);
|
|
1312
|
+
const response = JSON.parse(
|
|
1313
|
+
await api(
|
|
1314
|
+
["/gists", "--method", "POST", "--input", "-"],
|
|
1315
|
+
JSON.stringify({
|
|
1316
|
+
description: "pi-starship footer settings",
|
|
1317
|
+
public: false,
|
|
1318
|
+
files: { [GIST_FILENAME]: { content: rawDocument } }
|
|
1319
|
+
}),
|
|
1320
|
+
signal
|
|
1321
|
+
)
|
|
1322
|
+
);
|
|
1323
|
+
signal.throwIfAborted();
|
|
1324
|
+
if (!isRecord(response) || response.public !== false || typeof response.html_url !== "string") {
|
|
1325
|
+
throw new Error("GitHub returned an invalid Gist response. Check your Gists before retrying.");
|
|
1326
|
+
}
|
|
1327
|
+
return `https://gist.github.com/${gistId(response.html_url)}`;
|
|
1328
|
+
}
|
|
1329
|
+
async function fetchSettingsGist(value, signal, api = executeGhApi) {
|
|
1330
|
+
const id = gistId(value);
|
|
1331
|
+
const response = JSON.parse(await api([`/gists/${id}`, "--method", "GET"], void 0, signal));
|
|
1332
|
+
signal.throwIfAborted();
|
|
1333
|
+
const file = isRecord(response) && isRecord(response.files) ? response.files[GIST_FILENAME] : void 0;
|
|
1334
|
+
if (!isRecord(file) || typeof file.content !== "string" || file.truncated !== false) {
|
|
1335
|
+
throw new Error(`The Gist must contain a complete ${GIST_FILENAME} file. Truncated files are not supported.`);
|
|
1336
|
+
}
|
|
1337
|
+
checkGistDocument(file.content);
|
|
1338
|
+
return file.content;
|
|
1339
|
+
}
|
|
1340
|
+
function isRecord(value) {
|
|
1341
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1342
|
+
}
|
|
1343
|
+
var executeGhApi = (args, input, signal) => {
|
|
1344
|
+
signal.throwIfAborted();
|
|
1345
|
+
return new Promise((resolve, reject) => {
|
|
1346
|
+
const child = spawn(process.platform === "win32" ? "gh.exe" : "gh", ["api", "--hostname", "github.com", ...args], {
|
|
1347
|
+
env: { ...process.env, GH_PROMPT_DISABLED: "1", GH_PAGER: "", GH_DEBUG: "" },
|
|
1348
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
1349
|
+
windowsHide: true
|
|
1350
|
+
});
|
|
1351
|
+
const chunks = [];
|
|
1352
|
+
let bytes = 0;
|
|
1353
|
+
let failure;
|
|
1354
|
+
const stop = (error) => {
|
|
1355
|
+
failure ??= error;
|
|
1356
|
+
child.kill("SIGKILL");
|
|
1357
|
+
};
|
|
1358
|
+
const onAbort = () => stop(new Error("Gist request cancelled."));
|
|
1359
|
+
const timer = setTimeout(
|
|
1360
|
+
() => stop(new Error("Gist request timed out. Check GitHub before retrying an upload.")),
|
|
1361
|
+
REQUEST_TIMEOUT_MS
|
|
1362
|
+
);
|
|
1363
|
+
timer.unref();
|
|
1364
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1365
|
+
child.stdout.on("data", (chunk) => {
|
|
1366
|
+
bytes += chunk.length;
|
|
1367
|
+
if (bytes > MAX_RESPONSE_BYTES) stop(new Error("GitHub Gist response exceeds 512 KiB."));
|
|
1368
|
+
else chunks.push(chunk);
|
|
1369
|
+
});
|
|
1370
|
+
child.stdin.on("error", () => {
|
|
1371
|
+
stop(new Error("Unable to send settings to gh."));
|
|
1372
|
+
});
|
|
1373
|
+
child.on("error", () => {
|
|
1374
|
+
failure ??= new Error("Unable to start gh. Install GitHub CLI and run gh auth login with Gist access.");
|
|
1375
|
+
});
|
|
1376
|
+
child.on("close", (code) => {
|
|
1377
|
+
clearTimeout(timer);
|
|
1378
|
+
signal.removeEventListener("abort", onAbort);
|
|
1379
|
+
if (failure) reject(failure);
|
|
1380
|
+
else if (code !== 0)
|
|
1381
|
+
reject(
|
|
1382
|
+
new Error(
|
|
1383
|
+
"Gist request failed. Check gh auth status, Gist access, and connectivity. An upload may already exist."
|
|
1384
|
+
)
|
|
1385
|
+
);
|
|
1386
|
+
else resolve(Buffer.concat(chunks).toString("utf8"));
|
|
1387
|
+
});
|
|
1388
|
+
if (signal.aborted) onAbort();
|
|
1389
|
+
child.stdin.end(input);
|
|
1390
|
+
});
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
// src/command-gist.ts
|
|
1394
|
+
async function shareSettingsGist(ctx, options, owner, api) {
|
|
1395
|
+
if (ctx.mode !== "tui" || !current(owner)) return "cancel";
|
|
1396
|
+
const loaded = options.getLoaded();
|
|
1397
|
+
if (loaded.diagnostics.some((item) => item.severity === "error")) {
|
|
1398
|
+
ctx.ui.notify("Fix configuration errors before sharing settings.", "warning");
|
|
1399
|
+
return "cancel";
|
|
1400
|
+
}
|
|
1401
|
+
const raw = loaded.rawDocument ?? BUILT_IN_EXAMPLE;
|
|
1402
|
+
try {
|
|
1403
|
+
checkGistDocument(raw);
|
|
1404
|
+
} catch (error) {
|
|
1405
|
+
ctx.ui.notify(safeError2(error), "error");
|
|
1406
|
+
return "cancel";
|
|
1407
|
+
}
|
|
1408
|
+
const review = await reviewDocument(
|
|
1409
|
+
ctx,
|
|
1410
|
+
owner,
|
|
1411
|
+
"Share settings as Gist",
|
|
1412
|
+
raw,
|
|
1413
|
+
[
|
|
1414
|
+
"Review the entire loaded document, including comments and unknown fields, for secrets and local paths.",
|
|
1415
|
+
"No settings file is created when sharing built-in defaults."
|
|
1416
|
+
],
|
|
1417
|
+
"Share unlisted Gist\u2026"
|
|
1418
|
+
);
|
|
1419
|
+
if (!current(owner)) return "cancel";
|
|
1420
|
+
if (!review) return "close";
|
|
1421
|
+
const confirmed = await ctx.ui.confirm(
|
|
1422
|
+
"Upload settings to GitHub?",
|
|
1423
|
+
[
|
|
1424
|
+
"Send the reviewed pi-starship.toml to github.com as a new unlisted Gist?",
|
|
1425
|
+
"Unlisted is not private: anyone with the link can read it. Comments and unknown fields are included.",
|
|
1426
|
+
"Cancellation or a network error cannot undo an upload already accepted by GitHub; check your Gists before retrying."
|
|
1427
|
+
].join("\n"),
|
|
1428
|
+
{ signal: owner.signal }
|
|
1429
|
+
);
|
|
1430
|
+
if (!current(owner) || !confirmed) return "cancel";
|
|
1431
|
+
const result = await runTask(ctx, {
|
|
1432
|
+
label: "Sharing settings with GitHub\u2026",
|
|
1433
|
+
signal: owner.signal,
|
|
1434
|
+
isCurrent: owner.isCurrent,
|
|
1435
|
+
task: ({ signal }) => createSettingsGist(raw, signal, api),
|
|
1436
|
+
onError: () => ctx.ui.notify(
|
|
1437
|
+
"Gist upload failed. Check gh auth status, Gist access, connectivity, and your Gists before retrying. The upload may already exist.",
|
|
1438
|
+
"error"
|
|
1439
|
+
)
|
|
1440
|
+
});
|
|
1441
|
+
if (!current(owner)) return "cancel";
|
|
1442
|
+
if (result.kind === "completed") {
|
|
1443
|
+
ctx.ui.notify(`Settings Gist: ${result.value}`, "info");
|
|
1444
|
+
return "cancel";
|
|
1445
|
+
}
|
|
1446
|
+
return result.kind === "error" ? "cancel" : "close";
|
|
1447
|
+
}
|
|
1448
|
+
async function importSettingsGist(ctx, options, owner, reviewImport, api) {
|
|
1449
|
+
if (ctx.mode !== "tui" || !current(owner)) return "cancel";
|
|
1450
|
+
const previous = options.getLoaded();
|
|
1451
|
+
const revision = options.getLoadedRevision?.();
|
|
1452
|
+
const disk = diskSnapshot(options);
|
|
1453
|
+
const guardedOwner = {
|
|
1454
|
+
signal: owner.signal,
|
|
1455
|
+
isCurrent: () => current(owner) && options.getLoadedRevision?.() === revision && options.getLoaded().rawDocument === previous.rawDocument && options.getLoaded().source === previous.source
|
|
1456
|
+
};
|
|
1457
|
+
const value = await ctx.ui.input("Import pi-starship settings from Gist", "https://gist.github.com/<owner>/<id>", {
|
|
1458
|
+
signal: owner.signal
|
|
1459
|
+
});
|
|
1460
|
+
if (!current(guardedOwner) || value === void 0) return "cancel";
|
|
1461
|
+
let id;
|
|
1462
|
+
try {
|
|
1463
|
+
id = gistId(value);
|
|
1464
|
+
} catch (error) {
|
|
1465
|
+
ctx.ui.notify(safeError2(error), "error");
|
|
1466
|
+
return "cancel";
|
|
1467
|
+
}
|
|
1468
|
+
const result = await runTask(ctx, {
|
|
1469
|
+
label: "Reading settings from GitHub\u2026",
|
|
1470
|
+
signal: owner.signal,
|
|
1471
|
+
isCurrent: guardedOwner.isCurrent,
|
|
1472
|
+
task: ({ signal }) => fetchSettingsGist(id, signal, api),
|
|
1473
|
+
onError: () => ctx.ui.notify(
|
|
1474
|
+
"Gist import failed. Check the Gist ID, gh auth status, connectivity, and a complete pi-starship.toml file (up to 64 KiB).",
|
|
1475
|
+
"error"
|
|
1476
|
+
)
|
|
1477
|
+
});
|
|
1478
|
+
if (!current(guardedOwner)) return "cancel";
|
|
1479
|
+
if (result.kind !== "completed") return result.kind === "error" ? "cancel" : "close";
|
|
1480
|
+
let validated;
|
|
1481
|
+
try {
|
|
1482
|
+
validated = (options.validate ?? validateConfigDocument)(options.settingsPath, result.value);
|
|
1483
|
+
} catch (error) {
|
|
1484
|
+
ctx.ui.notify(`Gist settings are invalid: ${safeError2(error)}`, "error");
|
|
1485
|
+
return "cancel";
|
|
1486
|
+
}
|
|
1487
|
+
const reviewed = await reviewDocument(
|
|
1488
|
+
ctx,
|
|
1489
|
+
guardedOwner,
|
|
1490
|
+
"Review Gist settings",
|
|
1491
|
+
result.value,
|
|
1492
|
+
[
|
|
1493
|
+
`Source: https://gist.github.com/${id}`,
|
|
1494
|
+
"Untrusted settings can enable local commands and network requests. Review the complete TOML before applying.",
|
|
1495
|
+
"Import replaces the entire local document, including comments and unknown fields; no backup is kept after success."
|
|
1496
|
+
],
|
|
1497
|
+
"Preview imported footer\u2026"
|
|
1498
|
+
);
|
|
1499
|
+
if (!current(guardedOwner)) return "cancel";
|
|
1500
|
+
if (!reviewed) return "close";
|
|
1501
|
+
return reviewImport(
|
|
1502
|
+
validated,
|
|
1503
|
+
{
|
|
1504
|
+
...options,
|
|
1505
|
+
save(path, raw) {
|
|
1506
|
+
if (!current(guardedOwner) || diskSnapshot(options) !== disk) {
|
|
1507
|
+
throw new Error("Settings changed during import. Start a new import to review the latest state.");
|
|
1508
|
+
}
|
|
1509
|
+
return (options.save ?? atomicSaveConfigDocument)(path, raw);
|
|
1510
|
+
}
|
|
1511
|
+
},
|
|
1512
|
+
guardedOwner
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
async function reviewDocument(ctx, owner, title, content, lines, label) {
|
|
1516
|
+
let approved = false;
|
|
1517
|
+
const menu = defineMenu({
|
|
1518
|
+
start: "document",
|
|
1519
|
+
screens: {
|
|
1520
|
+
document: () => ({
|
|
1521
|
+
kind: "review",
|
|
1522
|
+
title,
|
|
1523
|
+
lines,
|
|
1524
|
+
content,
|
|
1525
|
+
format: { kind: "code", language: "toml" },
|
|
1526
|
+
viewportSize: "adaptive",
|
|
1527
|
+
enableSearch: true,
|
|
1528
|
+
confirm: { id: "continue", label, action: "continue" },
|
|
1529
|
+
hint: "close"
|
|
1530
|
+
})
|
|
1531
|
+
},
|
|
1532
|
+
actions: {
|
|
1533
|
+
continue: () => {
|
|
1534
|
+
approved = true;
|
|
1535
|
+
return { kind: "close" };
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
await runMenu(ctx, menu, { getState: () => void 0, signal: owner.signal, isCurrent: owner.isCurrent });
|
|
1540
|
+
return current(owner) && approved;
|
|
1541
|
+
}
|
|
1542
|
+
function diskSnapshot(options) {
|
|
1543
|
+
const loaded = (options.read ?? loadStarshipConfig)(options.settingsPath);
|
|
1544
|
+
return JSON.stringify([loaded.rawDocument, loaded.source, loaded.diagnostics]);
|
|
1545
|
+
}
|
|
1546
|
+
function current(owner) {
|
|
1547
|
+
return !owner.signal.aborted && owner.isCurrent();
|
|
1548
|
+
}
|
|
1549
|
+
function safeError2(error) {
|
|
1550
|
+
return sanitizeTerminalText2(error instanceof Error ? error.message : String(error));
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1269
1553
|
// src/command-inspector.ts
|
|
1270
1554
|
import { stripVTControlCharacters as stripVTControlCharacters2 } from "node:util";
|
|
1271
1555
|
function formatFooterExplanation(inspection) {
|
|
@@ -1307,9 +1591,9 @@ function safeDisplayText2(value) {
|
|
|
1307
1591
|
// src/command-preset-picker.ts
|
|
1308
1592
|
import { runLiveChoice } from "@narumitw/pi-tui-kit";
|
|
1309
1593
|
async function showPresetPicker(ctx, options) {
|
|
1310
|
-
const
|
|
1594
|
+
const current2 = options.presets.find((preset) => preset.id === options.activePresetId)?.label ?? "Custom configuration";
|
|
1311
1595
|
const result = await runLiveChoice(ctx, {
|
|
1312
|
-
title: `Presets \xB7 current: ${
|
|
1596
|
+
title: `Presets \xB7 current: ${current2}`,
|
|
1313
1597
|
items: options.presets.map((preset) => ({
|
|
1314
1598
|
id: preset.id,
|
|
1315
1599
|
label: preset.label,
|
|
@@ -1396,7 +1680,7 @@ async function showMainMenu(ctx, options) {
|
|
|
1396
1680
|
signal: fallbackController.signal,
|
|
1397
1681
|
isCurrent: () => !fallbackController.signal.aborted
|
|
1398
1682
|
};
|
|
1399
|
-
const menu =
|
|
1683
|
+
const menu = defineMenu2({
|
|
1400
1684
|
start: "main",
|
|
1401
1685
|
screens: {
|
|
1402
1686
|
main: () => {
|
|
@@ -1501,7 +1785,7 @@ async function showMainMenu(ctx, options) {
|
|
|
1501
1785
|
"Presets live-previews the cursor in the footer; Enter confirms apply and e customizes first.",
|
|
1502
1786
|
"Explain footer breaks down the modules currently showing from the existing snapshot.",
|
|
1503
1787
|
"Modules searches every supported module and explains its current read-only state.",
|
|
1504
|
-
"Configuration
|
|
1788
|
+
"Configuration includes disk reload plus unlisted Gist sharing and reviewed Gist import through gh.",
|
|
1505
1789
|
`Settings: ${safeText(options.settingsPath)}`,
|
|
1506
1790
|
"Docs: https://github.com/narumiruna/pi-extensions/tree/main/packages/pi-starship"
|
|
1507
1791
|
],
|
|
@@ -1517,6 +1801,23 @@ async function showMainMenu(ctx, options) {
|
|
|
1517
1801
|
const result = await choosePreset(ctx, options, owner);
|
|
1518
1802
|
return result === "applied" || result === "close" ? { kind: "close" } : { kind: "stay" };
|
|
1519
1803
|
},
|
|
1804
|
+
"gist-share": async () => {
|
|
1805
|
+
const result = await shareSettingsGist(ctx, options, owner, options.gistApi);
|
|
1806
|
+
return result === "close" ? { kind: "close" } : { kind: "stay" };
|
|
1807
|
+
},
|
|
1808
|
+
"gist-import": async () => {
|
|
1809
|
+
const result = await importSettingsGist(
|
|
1810
|
+
ctx,
|
|
1811
|
+
options,
|
|
1812
|
+
owner,
|
|
1813
|
+
async (loaded, guardedOptions, guardedOwner) => {
|
|
1814
|
+
const applied = await reviewAndApply(ctx, guardedOptions, loaded, { kind: "import" }, guardedOwner);
|
|
1815
|
+
return applied === "edit" ? "cancel" : applied;
|
|
1816
|
+
},
|
|
1817
|
+
options.gistApi
|
|
1818
|
+
);
|
|
1819
|
+
return result === "applied" || result === "close" ? { kind: "close" } : { kind: "stay" };
|
|
1820
|
+
},
|
|
1520
1821
|
"configuration-reload": async () => {
|
|
1521
1822
|
const result = await reloadConfiguration(ctx, options, owner);
|
|
1522
1823
|
return result === "close" ? { kind: "close" } : { kind: "stay" };
|
|
@@ -1533,7 +1834,7 @@ async function showMainMenu(ctx, options) {
|
|
|
1533
1834
|
}
|
|
1534
1835
|
});
|
|
1535
1836
|
try {
|
|
1536
|
-
await
|
|
1837
|
+
await runMenu2(ctx, menu, {
|
|
1537
1838
|
getState: () => void 0,
|
|
1538
1839
|
signal: owner.signal,
|
|
1539
1840
|
isCurrent: owner.isCurrent
|
|
@@ -1674,7 +1975,7 @@ async function reviewAndApply(ctx, options, validated, intent, owner, skipReview
|
|
|
1674
1975
|
(width) => reviewPreviewBody(ctx, options, validated, width, intent),
|
|
1675
1976
|
[
|
|
1676
1977
|
{ value: PREVIEW_ACTIONS.continue, label: continueLabel(intent) },
|
|
1677
|
-
...intent.kind === "restore" ? [] : [
|
|
1978
|
+
...intent.kind === "restore" || intent.kind === "import" ? [] : [
|
|
1678
1979
|
{
|
|
1679
1980
|
value: PREVIEW_ACTIONS.edit,
|
|
1680
1981
|
label: intent.kind === "preset" ? "Customize before applying" : "Continue editing"
|
|
@@ -1697,7 +1998,8 @@ async function reviewAndApply(ctx, options, validated, intent, owner, skipReview
|
|
|
1697
1998
|
reviewRequired = true;
|
|
1698
1999
|
const confirmed = await ctx.ui.confirm(
|
|
1699
2000
|
confirmationTitle(intent),
|
|
1700
|
-
confirmationMessage(options.settingsPath, intent)
|
|
2001
|
+
confirmationMessage(options.settingsPath, intent),
|
|
2002
|
+
{ signal: owner.signal }
|
|
1701
2003
|
);
|
|
1702
2004
|
if (!isCurrentOwner2(owner)) return "cancel";
|
|
1703
2005
|
if (!confirmed) {
|
|
@@ -1739,6 +2041,8 @@ function reviewTitle(intent) {
|
|
|
1739
2041
|
return "Footer preview";
|
|
1740
2042
|
case "restore":
|
|
1741
2043
|
return "Restore preview";
|
|
2044
|
+
case "import":
|
|
2045
|
+
return "Gist footer preview";
|
|
1742
2046
|
case "preset":
|
|
1743
2047
|
return `${intent.preset.label} preset preview`;
|
|
1744
2048
|
}
|
|
@@ -1749,6 +2053,8 @@ function continueLabel(intent) {
|
|
|
1749
2053
|
return "Apply changes\u2026";
|
|
1750
2054
|
case "restore":
|
|
1751
2055
|
return "Replace with built-in\u2026";
|
|
2056
|
+
case "import":
|
|
2057
|
+
return "Replace with Gist settings\u2026";
|
|
1752
2058
|
case "preset":
|
|
1753
2059
|
return `Apply ${intent.preset.label} preset\u2026`;
|
|
1754
2060
|
}
|
|
@@ -1759,13 +2065,15 @@ function confirmationTitle(intent) {
|
|
|
1759
2065
|
return "Apply footer changes?";
|
|
1760
2066
|
case "restore":
|
|
1761
2067
|
return "Restore built-in footer?";
|
|
2068
|
+
case "import":
|
|
2069
|
+
return "Replace settings with Gist?";
|
|
1762
2070
|
case "preset":
|
|
1763
2071
|
return `Apply ${intent.preset.label} preset?`;
|
|
1764
2072
|
}
|
|
1765
2073
|
}
|
|
1766
2074
|
function confirmationMessage(settingsPath, intent) {
|
|
1767
2075
|
if (intent.kind === "customize") return "Save this configuration and apply it immediately?";
|
|
1768
|
-
const replacement = intent.kind === "restore" ? "the built-in configuration" : `the ${intent.preset.label} preset`;
|
|
2076
|
+
const replacement = intent.kind === "restore" ? "the built-in configuration" : intent.kind === "import" ? "the reviewed Gist settings" : `the ${intent.preset.label} preset`;
|
|
1769
2077
|
return `Replace ${safeText(settingsPath)} entirely with ${replacement}? All custom settings, unknown fields, and comments will be removed. No backup is kept after success.`;
|
|
1770
2078
|
}
|
|
1771
2079
|
function successMessage(intent) {
|
|
@@ -1774,6 +2082,8 @@ function successMessage(intent) {
|
|
|
1774
2082
|
return "Footer settings saved and applied";
|
|
1775
2083
|
case "restore":
|
|
1776
2084
|
return "Built-in footer restored and applied";
|
|
2085
|
+
case "import":
|
|
2086
|
+
return "Gist settings saved and applied";
|
|
1777
2087
|
case "preset":
|
|
1778
2088
|
return `${intent.preset.label} preset saved and applied`;
|
|
1779
2089
|
}
|
|
@@ -1807,12 +2117,12 @@ function restorePreviousConfiguration(ctx, options, previous, saved) {
|
|
|
1807
2117
|
}
|
|
1808
2118
|
function reviewPreviewBody(ctx, options, loaded, width, intent) {
|
|
1809
2119
|
if (intent.kind === "restore") return restorePreviewBody(ctx, options, loaded, width);
|
|
1810
|
-
if (intent.kind === "customize") return previewBody(ctx, options, loaded, width);
|
|
1811
|
-
const
|
|
2120
|
+
if (intent.kind === "customize" || intent.kind === "import") return previewBody(ctx, options, loaded, width);
|
|
2121
|
+
const current2 = configurationPresentation(options.getLoaded());
|
|
1812
2122
|
return [
|
|
1813
2123
|
`Preset: ${intent.preset.label}`,
|
|
1814
2124
|
`Requirement: ${intent.preset.requiresNerdFont ? "Nerd Font" : "No special font"}`,
|
|
1815
|
-
`Current: ${
|
|
2125
|
+
`Current: ${current2.state}`,
|
|
1816
2126
|
`Path: ${safeText(options.settingsPath)}`,
|
|
1817
2127
|
"Applying replaces the entire settings document, including custom settings, unknown fields, and comments.",
|
|
1818
2128
|
"No backup is kept after a successful apply.",
|
|
@@ -1821,9 +2131,9 @@ function reviewPreviewBody(ctx, options, loaded, width, intent) {
|
|
|
1821
2131
|
];
|
|
1822
2132
|
}
|
|
1823
2133
|
function restorePreviewBody(ctx, options, loaded, width) {
|
|
1824
|
-
const
|
|
2134
|
+
const current2 = configurationPresentation(options.getLoaded());
|
|
1825
2135
|
return [
|
|
1826
|
-
`Current: ${
|
|
2136
|
+
`Current: ${current2.state}`,
|
|
1827
2137
|
`Path: ${safeText(options.settingsPath)}`,
|
|
1828
2138
|
"The entire settings document will be replaced, including custom settings, unknown fields, and comments.",
|
|
1829
2139
|
"No backup is kept after a successful restore.",
|
|
@@ -1891,4 +2201,4 @@ export {
|
|
|
1891
2201
|
handleStarshipCommand,
|
|
1892
2202
|
registerStarshipCommand
|
|
1893
2203
|
};
|
|
1894
|
-
//# sourceMappingURL=commands-
|
|
2204
|
+
//# sourceMappingURL=commands-M6GHLJIR.ts.map
|