contribute-now 0.7.2-dev.f0ed468 → 0.7.2-dev.f977908
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/cli.js +426 -1709
- package/package.json +1 -3
package/dist/cli.js
CHANGED
|
@@ -7540,6 +7540,9 @@ async function hasLocalWork(remote, branch) {
|
|
|
7540
7540
|
async function deleteRemoteBranch(remote, branch) {
|
|
7541
7541
|
return run(["push", remote, "--delete", branch]);
|
|
7542
7542
|
}
|
|
7543
|
+
async function stashChanges(message) {
|
|
7544
|
+
return run(["stash", "push", "-m", `contrib-save: ${message}`]);
|
|
7545
|
+
}
|
|
7543
7546
|
async function mergeSquash(branch) {
|
|
7544
7547
|
return run(["merge", "--squash", branch]);
|
|
7545
7548
|
}
|
|
@@ -11988,8 +11991,116 @@ ${import_picocolors8.default.bold("Stale branches (remote deleted, likely squash
|
|
|
11988
11991
|
}
|
|
11989
11992
|
});
|
|
11990
11993
|
|
|
11991
|
-
// src/commands/
|
|
11994
|
+
// src/commands/discard.ts
|
|
11992
11995
|
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
11996
|
+
var discard_default = defineCommand({
|
|
11997
|
+
meta: {
|
|
11998
|
+
name: "discard",
|
|
11999
|
+
description: "Discard the current feature branch and return to the base branch"
|
|
12000
|
+
},
|
|
12001
|
+
args: {
|
|
12002
|
+
force: {
|
|
12003
|
+
type: "boolean",
|
|
12004
|
+
alias: "f",
|
|
12005
|
+
description: "Skip confirmation and discard immediately",
|
|
12006
|
+
default: false
|
|
12007
|
+
}
|
|
12008
|
+
},
|
|
12009
|
+
async run({ args }) {
|
|
12010
|
+
if (!await isGitRepo()) {
|
|
12011
|
+
error("Not inside a git repository.");
|
|
12012
|
+
process.exit(1);
|
|
12013
|
+
}
|
|
12014
|
+
await assertCleanGitState("discarding a branch");
|
|
12015
|
+
const config = readConfig();
|
|
12016
|
+
if (!config) {
|
|
12017
|
+
error("No repo config found. Run `contrib setup` first.");
|
|
12018
|
+
process.exit(1);
|
|
12019
|
+
}
|
|
12020
|
+
const currentBranch = await getCurrentBranch();
|
|
12021
|
+
const baseBranch = getBaseBranch(config);
|
|
12022
|
+
await projectHeading("discard", "\uD83D\uDDD1\uFE0F");
|
|
12023
|
+
if (isBranchProtected(currentBranch, config)) {
|
|
12024
|
+
error(`${import_picocolors9.default.bold(currentBranch)} is a protected branch and cannot be discarded.`);
|
|
12025
|
+
info(`Switch to a feature branch first, then run ${import_picocolors9.default.bold("contrib discard")}.`);
|
|
12026
|
+
process.exit(1);
|
|
12027
|
+
}
|
|
12028
|
+
if (currentBranch === baseBranch) {
|
|
12029
|
+
info(`You are already on ${import_picocolors9.default.bold(baseBranch)}.`);
|
|
12030
|
+
process.exit(0);
|
|
12031
|
+
}
|
|
12032
|
+
const { origin } = config;
|
|
12033
|
+
const localWork = await hasLocalWork(origin, currentBranch);
|
|
12034
|
+
const hasWork = localWork.uncommitted || localWork.unpushedCommits > 0;
|
|
12035
|
+
if (hasWork) {
|
|
12036
|
+
if (localWork.uncommitted) {
|
|
12037
|
+
warn("You have uncommitted changes in your working tree.");
|
|
12038
|
+
}
|
|
12039
|
+
if (localWork.unpushedCommits > 0) {
|
|
12040
|
+
warn(`You have ${import_picocolors9.default.bold(String(localWork.unpushedCommits))} unpushed commit${localWork.unpushedCommits !== 1 ? "s" : ""} on this branch.`);
|
|
12041
|
+
}
|
|
12042
|
+
warn("Discarding this branch will permanently lose that work.");
|
|
12043
|
+
const SAVE_FIRST = "Save my changes first (cn save), then discard";
|
|
12044
|
+
const DISCARD_ANYWAY = "Discard anyway \u2014 I do not need this work";
|
|
12045
|
+
const CANCEL = "Keep the branch, take me back";
|
|
12046
|
+
const action = await selectPrompt("This branch has unsaved work. What would you like to do?", [SAVE_FIRST, DISCARD_ANYWAY, CANCEL]);
|
|
12047
|
+
if (action === CANCEL) {
|
|
12048
|
+
info("Discard cancelled. Your branch is untouched.");
|
|
12049
|
+
process.exit(0);
|
|
12050
|
+
}
|
|
12051
|
+
if (action === SAVE_FIRST) {
|
|
12052
|
+
if (!localWork.uncommitted) {
|
|
12053
|
+
info("No uncommitted changes to stash \u2014 unpushed commits will still be lost.");
|
|
12054
|
+
const confirm = await confirmPrompt("Continue discarding the branch?");
|
|
12055
|
+
if (!confirm) {
|
|
12056
|
+
info("Discard cancelled.");
|
|
12057
|
+
process.exit(0);
|
|
12058
|
+
}
|
|
12059
|
+
} else {
|
|
12060
|
+
const stashResult = await stashChanges(`work-in-progress on ${currentBranch}`);
|
|
12061
|
+
if (stashResult.exitCode !== 0) {
|
|
12062
|
+
error(`Failed to save changes: ${stashResult.stderr}`);
|
|
12063
|
+
process.exit(1);
|
|
12064
|
+
}
|
|
12065
|
+
success(`Changes saved. Use ${import_picocolors9.default.bold("contrib save --restore")} to bring them back.`);
|
|
12066
|
+
}
|
|
12067
|
+
}
|
|
12068
|
+
} else if (!args.force) {
|
|
12069
|
+
const confirmed = await confirmPrompt(`Discard ${import_picocolors9.default.bold(currentBranch)} and return to ${import_picocolors9.default.bold(baseBranch)}?`);
|
|
12070
|
+
if (!confirmed) {
|
|
12071
|
+
info("Discard cancelled.");
|
|
12072
|
+
process.exit(0);
|
|
12073
|
+
}
|
|
12074
|
+
}
|
|
12075
|
+
const upstreamRef = await getUpstreamRef();
|
|
12076
|
+
let deleteRemote = false;
|
|
12077
|
+
if (upstreamRef) {
|
|
12078
|
+
deleteRemote = await confirmPrompt(`Also delete the remote branch ${import_picocolors9.default.bold(upstreamRef)}?`);
|
|
12079
|
+
}
|
|
12080
|
+
const checkoutResult = await checkoutBranch(baseBranch);
|
|
12081
|
+
if (checkoutResult.exitCode !== 0) {
|
|
12082
|
+
error(`Failed to switch to ${import_picocolors9.default.bold(baseBranch)}: ${checkoutResult.stderr}`);
|
|
12083
|
+
process.exit(1);
|
|
12084
|
+
}
|
|
12085
|
+
const deleteResult = await forceDeleteBranch(currentBranch);
|
|
12086
|
+
if (deleteResult.exitCode !== 0) {
|
|
12087
|
+
error(`Failed to delete branch ${import_picocolors9.default.bold(currentBranch)}: ${deleteResult.stderr}`);
|
|
12088
|
+
process.exit(1);
|
|
12089
|
+
}
|
|
12090
|
+
success(`Discarded ${import_picocolors9.default.bold(currentBranch)} and switched back to ${import_picocolors9.default.bold(baseBranch)}`);
|
|
12091
|
+
if (deleteRemote) {
|
|
12092
|
+
const remoteDeleteResult = await deleteRemoteBranch(origin, currentBranch);
|
|
12093
|
+
if (remoteDeleteResult.exitCode !== 0) {
|
|
12094
|
+
warn(`Could not delete remote branch: ${remoteDeleteResult.stderr.trim()}`);
|
|
12095
|
+
} else {
|
|
12096
|
+
success(`Deleted remote branch ${import_picocolors9.default.bold(`${origin}/${currentBranch}`)}`);
|
|
12097
|
+
}
|
|
12098
|
+
}
|
|
12099
|
+
}
|
|
12100
|
+
});
|
|
12101
|
+
|
|
12102
|
+
// src/commands/commit.ts
|
|
12103
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
11993
12104
|
|
|
11994
12105
|
// src/utils/convention.ts
|
|
11995
12106
|
var CLEAN_COMMIT_PATTERN = /^(\uD83D\uDCE6|\uD83D\uDD27|\uD83D\uDDD1\uFE0F?|\uD83D\uDD12|\u2699\uFE0F?|\u2615|\uD83E\uDDEA|\uD83D\uDCD6|\uD83D\uDE80) (new|update|remove|security|setup|chore|test|docs|release)(!?)( \([a-zA-Z0-9][a-zA-Z0-9-]*\))?: .{1,72}$/u;
|
|
@@ -12096,9 +12207,9 @@ var commit_default = defineCommand({
|
|
|
12096
12207
|
process.exit(1);
|
|
12097
12208
|
}
|
|
12098
12209
|
console.log(`
|
|
12099
|
-
${
|
|
12210
|
+
${import_picocolors10.default.bold("Changed files:")}`);
|
|
12100
12211
|
for (const f3 of changedFiles) {
|
|
12101
|
-
console.log(` ${
|
|
12212
|
+
console.log(` ${import_picocolors10.default.dim("\u2022")} ${f3}`);
|
|
12102
12213
|
}
|
|
12103
12214
|
const stageAction = await selectPrompt("No staged changes. How would you like to stage?", [
|
|
12104
12215
|
"Stage all changes",
|
|
@@ -12140,8 +12251,8 @@ ${import_picocolors9.default.bold("Changed files:")}`);
|
|
|
12140
12251
|
const dirs = new Set(stagedFiles.map((f3) => f3.split("/")[0]));
|
|
12141
12252
|
if (dirs.size > 1) {
|
|
12142
12253
|
console.log();
|
|
12143
|
-
warn(`You're staging ${
|
|
12144
|
-
info(
|
|
12254
|
+
warn(`You're staging ${import_picocolors10.default.bold(String(stagedFiles.length))} files across ${import_picocolors10.default.bold(String(dirs.size))} directories in a single commit.`);
|
|
12255
|
+
info(import_picocolors10.default.dim("Large commits mixing different topics make history harder to read and bisect. " + "For cleaner history, consider splitting into atomic commits."));
|
|
12145
12256
|
const choice = await selectPrompt("How would you like to proceed?", [
|
|
12146
12257
|
"Continue as single commit",
|
|
12147
12258
|
"Switch to group mode (AI splits into atomic commits)",
|
|
@@ -12172,7 +12283,7 @@ ${import_picocolors9.default.bold("Changed files:")}`);
|
|
|
12172
12283
|
if (commitMessage) {
|
|
12173
12284
|
spinner.success("AI commit message generated.");
|
|
12174
12285
|
console.log(`
|
|
12175
|
-
${
|
|
12286
|
+
${import_picocolors10.default.dim("AI suggestion:")} ${import_picocolors10.default.bold(import_picocolors10.default.cyan(commitMessage))}`);
|
|
12176
12287
|
} else {
|
|
12177
12288
|
spinner.fail("AI did not return a commit message.");
|
|
12178
12289
|
warn("Falling back to manual entry.");
|
|
@@ -12200,7 +12311,7 @@ ${import_picocolors9.default.bold("Changed files:")}`);
|
|
|
12200
12311
|
if (regen) {
|
|
12201
12312
|
spinner.success("Commit message regenerated.");
|
|
12202
12313
|
console.log(`
|
|
12203
|
-
${
|
|
12314
|
+
${import_picocolors10.default.dim("AI suggestion:")} ${import_picocolors10.default.bold(import_picocolors10.default.cyan(regen))}`);
|
|
12204
12315
|
const ok = await confirmPrompt("Use this message?");
|
|
12205
12316
|
finalMessage = ok ? regen : await inputPrompt("Enter commit message manually");
|
|
12206
12317
|
} else {
|
|
@@ -12215,7 +12326,7 @@ ${import_picocolors9.default.bold("Changed files:")}`);
|
|
|
12215
12326
|
if (convention2 !== "none") {
|
|
12216
12327
|
console.log();
|
|
12217
12328
|
for (const hint of CONVENTION_FORMAT_HINTS[convention2]) {
|
|
12218
|
-
console.log(
|
|
12329
|
+
console.log(import_picocolors10.default.dim(hint));
|
|
12219
12330
|
}
|
|
12220
12331
|
console.log();
|
|
12221
12332
|
}
|
|
@@ -12239,8 +12350,7 @@ ${import_picocolors9.default.bold("Changed files:")}`);
|
|
|
12239
12350
|
error(`Failed to commit: ${result.stderr}`);
|
|
12240
12351
|
process.exit(1);
|
|
12241
12352
|
}
|
|
12242
|
-
success(`Committed: ${
|
|
12243
|
-
process.exit(0);
|
|
12353
|
+
success(`Committed: ${import_picocolors10.default.bold(finalMessage)}`);
|
|
12244
12354
|
}
|
|
12245
12355
|
});
|
|
12246
12356
|
async function runGroupCommit(model, config) {
|
|
@@ -12257,9 +12367,9 @@ async function runGroupCommit(model, config) {
|
|
|
12257
12367
|
process.exit(1);
|
|
12258
12368
|
}
|
|
12259
12369
|
console.log(`
|
|
12260
|
-
${
|
|
12370
|
+
${import_picocolors10.default.bold("Changed files:")}`);
|
|
12261
12371
|
for (const f3 of changedFiles) {
|
|
12262
|
-
console.log(` ${
|
|
12372
|
+
console.log(` ${import_picocolors10.default.dim("\u2022")} ${f3}`);
|
|
12263
12373
|
}
|
|
12264
12374
|
const spinner = createSpinner(changedFiles.length >= BATCH_CONFIG.LARGE_CHANGESET_THRESHOLD ? `Asking AI to group ${changedFiles.length} file(s) into logical commits (using optimized batching)...` : `Asking AI to group ${changedFiles.length} file(s) into logical commits...`, {
|
|
12265
12375
|
tips: LOADING_TIPS
|
|
@@ -12305,13 +12415,13 @@ ${import_picocolors9.default.bold("Changed files:")}`);
|
|
|
12305
12415
|
let commitAll = false;
|
|
12306
12416
|
while (!proceedToCommit) {
|
|
12307
12417
|
console.log(`
|
|
12308
|
-
${
|
|
12418
|
+
${import_picocolors10.default.bold(`AI suggested ${validGroups.length} commit group(s):`)}
|
|
12309
12419
|
`);
|
|
12310
12420
|
for (let i2 = 0;i2 < validGroups.length; i2++) {
|
|
12311
12421
|
const g3 = validGroups[i2];
|
|
12312
|
-
console.log(` ${
|
|
12422
|
+
console.log(` ${import_picocolors10.default.cyan(`Group ${i2 + 1}:`)} ${import_picocolors10.default.bold(g3.message)}`);
|
|
12313
12423
|
for (const f3 of g3.files) {
|
|
12314
|
-
console.log(` ${
|
|
12424
|
+
console.log(` ${import_picocolors10.default.dim("\u2022")} ${f3}`);
|
|
12315
12425
|
}
|
|
12316
12426
|
console.log();
|
|
12317
12427
|
}
|
|
@@ -12377,16 +12487,16 @@ ${import_picocolors9.default.bold(`AI suggested ${validGroups.length} commit gro
|
|
|
12377
12487
|
continue;
|
|
12378
12488
|
}
|
|
12379
12489
|
committed++;
|
|
12380
|
-
success(`Committed group ${i2 + 1}: ${
|
|
12490
|
+
success(`Committed group ${i2 + 1}: ${import_picocolors10.default.bold(group.message)}`);
|
|
12381
12491
|
}
|
|
12382
12492
|
} else {
|
|
12383
12493
|
for (let i2 = 0;i2 < validGroups.length; i2++) {
|
|
12384
12494
|
const group = validGroups[i2];
|
|
12385
|
-
console.log(
|
|
12495
|
+
console.log(import_picocolors10.default.bold(`
|
|
12386
12496
|
\u2500\u2500 Group ${i2 + 1}/${validGroups.length} \u2500\u2500`));
|
|
12387
|
-
console.log(` ${
|
|
12497
|
+
console.log(` ${import_picocolors10.default.cyan(group.message)}`);
|
|
12388
12498
|
for (const f3 of group.files) {
|
|
12389
|
-
console.log(` ${
|
|
12499
|
+
console.log(` ${import_picocolors10.default.dim("\u2022")} ${f3}`);
|
|
12390
12500
|
}
|
|
12391
12501
|
let message = group.message;
|
|
12392
12502
|
let actionDone = false;
|
|
@@ -12410,7 +12520,7 @@ ${import_picocolors9.default.bold(`AI suggested ${validGroups.length} commit gro
|
|
|
12410
12520
|
if (newMsg) {
|
|
12411
12521
|
message = newMsg;
|
|
12412
12522
|
group.message = newMsg;
|
|
12413
|
-
regenSpinner.success(`New message: ${
|
|
12523
|
+
regenSpinner.success(`New message: ${import_picocolors10.default.bold(message)}`);
|
|
12414
12524
|
} else {
|
|
12415
12525
|
regenSpinner.fail("AI could not generate a new message. Keeping current one.");
|
|
12416
12526
|
}
|
|
@@ -12473,7 +12583,7 @@ ${import_picocolors9.default.bold(`AI suggested ${validGroups.length} commit gro
|
|
|
12473
12583
|
continue;
|
|
12474
12584
|
}
|
|
12475
12585
|
committed++;
|
|
12476
|
-
success(`Committed group ${i2 + 1}: ${
|
|
12586
|
+
success(`Committed group ${i2 + 1}: ${import_picocolors10.default.bold(message)}`);
|
|
12477
12587
|
actionDone = true;
|
|
12478
12588
|
}
|
|
12479
12589
|
}
|
|
@@ -12488,7 +12598,7 @@ ${import_picocolors9.default.bold(`AI suggested ${validGroups.length} commit gro
|
|
|
12488
12598
|
}
|
|
12489
12599
|
|
|
12490
12600
|
// src/commands/config.ts
|
|
12491
|
-
var
|
|
12601
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
12492
12602
|
var WORKFLOW_OPTIONS = [
|
|
12493
12603
|
{ value: "clean-flow", label: WORKFLOW_DESCRIPTIONS["clean-flow"] },
|
|
12494
12604
|
{ value: "github-flow", label: WORKFLOW_DESCRIPTIONS["github-flow"] },
|
|
@@ -12704,7 +12814,7 @@ async function applyOllamaApiKeyEdit(result) {
|
|
|
12704
12814
|
if (result.ollamaApiKeyAction === "set" && result.ollamaApiKey) {
|
|
12705
12815
|
await setOllamaCloudApiKey(result.ollamaApiKey);
|
|
12706
12816
|
success("Stored Ollama Cloud API key in the local secrets store.");
|
|
12707
|
-
info(`Secrets path: ${
|
|
12817
|
+
info(`Secrets path: ${import_picocolors11.default.bold(getSecretsStorePath())}`);
|
|
12708
12818
|
return;
|
|
12709
12819
|
}
|
|
12710
12820
|
if (result.ollamaApiKeyAction === "delete") {
|
|
@@ -12717,29 +12827,29 @@ async function applyOllamaApiKeyEdit(result) {
|
|
|
12717
12827
|
}
|
|
12718
12828
|
}
|
|
12719
12829
|
function printConfigSummary(snapshot) {
|
|
12720
|
-
info(`Config source: ${
|
|
12721
|
-
info(`Config path: ${
|
|
12722
|
-
info(`Workflow: ${
|
|
12723
|
-
info(`Convention: ${
|
|
12724
|
-
info(`Role: ${
|
|
12830
|
+
info(`Config source: ${import_picocolors11.default.bold(snapshot.source)}`);
|
|
12831
|
+
info(`Config path: ${import_picocolors11.default.bold(snapshot.location)}`);
|
|
12832
|
+
info(`Workflow: ${import_picocolors11.default.bold(snapshot.workflowLabel)}`);
|
|
12833
|
+
info(`Convention: ${import_picocolors11.default.bold(snapshot.commitConventionLabel)}`);
|
|
12834
|
+
info(`Role: ${import_picocolors11.default.bold(snapshot.role)}`);
|
|
12725
12835
|
if (snapshot.devBranch) {
|
|
12726
|
-
info(`Main: ${
|
|
12836
|
+
info(`Main: ${import_picocolors11.default.bold(snapshot.mainBranch)} | Dev: ${import_picocolors11.default.bold(snapshot.devBranch)}`);
|
|
12727
12837
|
} else {
|
|
12728
|
-
info(`Main: ${
|
|
12838
|
+
info(`Main: ${import_picocolors11.default.bold(snapshot.mainBranch)}`);
|
|
12729
12839
|
}
|
|
12730
|
-
info(`Origin: ${
|
|
12731
|
-
info(`Branch prefixes: ${
|
|
12732
|
-
info(`Guides: ${
|
|
12733
|
-
info(`AI: ${
|
|
12840
|
+
info(`Origin: ${import_picocolors11.default.bold(snapshot.origin)} | Upstream: ${import_picocolors11.default.bold(snapshot.upstream)}`);
|
|
12841
|
+
info(`Branch prefixes: ${import_picocolors11.default.bold(snapshot.branchPrefixes.join(", "))}`);
|
|
12842
|
+
info(`Guides: ${import_picocolors11.default.bold(snapshot.showTips ? "shown" : "hidden")}`);
|
|
12843
|
+
info(`AI: ${import_picocolors11.default.bold(snapshot.ai.enabled ? "enabled" : "disabled")}`);
|
|
12734
12844
|
if (snapshot.ai.enabled && snapshot.ai.providerLabel) {
|
|
12735
|
-
info(`AI provider: ${
|
|
12845
|
+
info(`AI provider: ${import_picocolors11.default.bold(snapshot.ai.providerLabel)}`);
|
|
12736
12846
|
if (snapshot.ai.model) {
|
|
12737
|
-
info(`AI model: ${
|
|
12847
|
+
info(`AI model: ${import_picocolors11.default.bold(snapshot.ai.model)}`);
|
|
12738
12848
|
}
|
|
12739
12849
|
if (snapshot.ai.provider === "ollama-cloud") {
|
|
12740
|
-
info(`Ollama Cloud API key: ${
|
|
12850
|
+
info(`Ollama Cloud API key: ${import_picocolors11.default.bold(snapshot.ai.ollamaCloudApiKeyPresent ? "stored" : "missing")}`);
|
|
12741
12851
|
if (snapshot.ai.secretsPath) {
|
|
12742
|
-
info(`Secrets path: ${
|
|
12852
|
+
info(`Secrets path: ${import_picocolors11.default.bold(snapshot.ai.secretsPath)}`);
|
|
12743
12853
|
}
|
|
12744
12854
|
}
|
|
12745
12855
|
}
|
|
@@ -12815,18 +12925,18 @@ var config_default = defineCommand({
|
|
|
12815
12925
|
}
|
|
12816
12926
|
printConfigSummary(snapshot);
|
|
12817
12927
|
console.log();
|
|
12818
|
-
console.log(` ${
|
|
12928
|
+
console.log(` ${import_picocolors11.default.dim("Run `contrib config --edit` to update these settings.")}`);
|
|
12819
12929
|
console.log();
|
|
12820
12930
|
}
|
|
12821
12931
|
});
|
|
12822
12932
|
|
|
12823
12933
|
// src/commands/doctor.ts
|
|
12824
12934
|
import { execFile as execFileCb3 } from "child_process";
|
|
12825
|
-
var
|
|
12935
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
12826
12936
|
// package.json
|
|
12827
12937
|
var package_default = {
|
|
12828
12938
|
name: "contribute-now",
|
|
12829
|
-
version: "0.7.2-dev.
|
|
12939
|
+
version: "0.7.2-dev.f977908",
|
|
12830
12940
|
description: "Developer CLI that automates git workflows \u2014 branching, syncing, committing, and PRs \u2014 with multi-workflow and commit convention support.",
|
|
12831
12941
|
type: "module",
|
|
12832
12942
|
bin: {
|
|
@@ -12875,13 +12985,11 @@ var package_default = {
|
|
|
12875
12985
|
"@github/copilot-sdk": "^0.1.25",
|
|
12876
12986
|
"@wgtechlabs/log-engine": "^2.3.1",
|
|
12877
12987
|
citty: "^0.1.6",
|
|
12878
|
-
figlet: "^1.10.0",
|
|
12879
12988
|
picocolors: "^1.1.1"
|
|
12880
12989
|
},
|
|
12881
12990
|
devDependencies: {
|
|
12882
12991
|
"@biomejs/biome": "^2.4.4",
|
|
12883
12992
|
"@types/bun": "latest",
|
|
12884
|
-
"@types/figlet": "^1.7.0",
|
|
12885
12993
|
typescript: "^5.7.0"
|
|
12886
12994
|
}
|
|
12887
12995
|
};
|
|
@@ -12916,16 +13024,16 @@ async function getRepoInfoFromRemote(remote = "origin") {
|
|
|
12916
13024
|
}
|
|
12917
13025
|
|
|
12918
13026
|
// src/commands/doctor.ts
|
|
12919
|
-
var PASS = ` ${
|
|
12920
|
-
var FAIL = ` ${
|
|
12921
|
-
var WARN = ` ${
|
|
13027
|
+
var PASS = ` ${import_picocolors12.default.green("\u2714")} `;
|
|
13028
|
+
var FAIL = ` ${import_picocolors12.default.red("\u2717")} `;
|
|
13029
|
+
var WARN = ` ${import_picocolors12.default.yellow("\u26A0")} `;
|
|
12922
13030
|
function printReport(report) {
|
|
12923
13031
|
for (const section of report.sections) {
|
|
12924
13032
|
console.log(`
|
|
12925
|
-
${
|
|
13033
|
+
${import_picocolors12.default.bold(import_picocolors12.default.underline(section.title))}`);
|
|
12926
13034
|
for (const check of section.checks) {
|
|
12927
13035
|
const prefix = check.ok ? check.warning ? WARN : PASS : FAIL;
|
|
12928
|
-
const text = check.detail ? `${check.label} ${
|
|
13036
|
+
const text = check.detail ? `${check.label} ${import_picocolors12.default.dim(`\u2014 ${check.detail}`)}` : check.label;
|
|
12929
13037
|
console.log(`${prefix}${text}`);
|
|
12930
13038
|
}
|
|
12931
13039
|
}
|
|
@@ -13257,14 +13365,14 @@ var doctor_default = defineCommand({
|
|
|
13257
13365
|
const failures = total.filter((c3) => !c3.ok);
|
|
13258
13366
|
const warnings = total.filter((c3) => c3.ok && c3.warning);
|
|
13259
13367
|
if (failures.length === 0 && warnings.length === 0) {
|
|
13260
|
-
console.log(` ${
|
|
13368
|
+
console.log(` ${import_picocolors12.default.green("All checks passed!")} No issues detected.
|
|
13261
13369
|
`);
|
|
13262
13370
|
} else {
|
|
13263
13371
|
if (failures.length > 0) {
|
|
13264
|
-
console.log(` ${
|
|
13372
|
+
console.log(` ${import_picocolors12.default.red(`${failures.length} issue${failures.length !== 1 ? "s" : ""} found.`)}`);
|
|
13265
13373
|
}
|
|
13266
13374
|
if (warnings.length > 0) {
|
|
13267
|
-
console.log(` ${
|
|
13375
|
+
console.log(` ${import_picocolors12.default.yellow(`${warnings.length} warning${warnings.length !== 1 ? "s" : ""}.`)}`);
|
|
13268
13376
|
}
|
|
13269
13377
|
console.log();
|
|
13270
13378
|
}
|
|
@@ -13274,7 +13382,7 @@ var doctor_default = defineCommand({
|
|
|
13274
13382
|
// src/commands/hook.ts
|
|
13275
13383
|
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync5, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
13276
13384
|
import { join as join6 } from "path";
|
|
13277
|
-
var
|
|
13385
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
13278
13386
|
var HOOK_MARKER = "# managed by contribute-now";
|
|
13279
13387
|
function getHooksDir(cwd = process.cwd()) {
|
|
13280
13388
|
return join6(cwd, ".git", "hooks");
|
|
@@ -13366,8 +13474,8 @@ async function installHook() {
|
|
|
13366
13474
|
}
|
|
13367
13475
|
writeFileSync5(hookPath, generateHookScript(), { mode: 493 });
|
|
13368
13476
|
success(`commit-msg hook installed.`);
|
|
13369
|
-
info(`Convention: ${
|
|
13370
|
-
info(`Path: ${
|
|
13477
|
+
info(`Convention: ${import_picocolors13.default.bold(CONVENTION_LABELS[config.commitConvention])}`, "");
|
|
13478
|
+
info(`Path: ${import_picocolors13.default.dim(hookPath)}`, "");
|
|
13371
13479
|
warn("Note: hooks can be bypassed with `git commit --no-verify`.");
|
|
13372
13480
|
}
|
|
13373
13481
|
async function uninstallHook() {
|
|
@@ -13387,7 +13495,7 @@ async function uninstallHook() {
|
|
|
13387
13495
|
}
|
|
13388
13496
|
|
|
13389
13497
|
// src/commands/log.ts
|
|
13390
|
-
var
|
|
13498
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
13391
13499
|
function getDefaultOverviewRemoteCommitCount(hasLocalUnpushedCommits) {
|
|
13392
13500
|
return hasLocalUnpushedCommits ? 10 : 20;
|
|
13393
13501
|
}
|
|
@@ -13485,9 +13593,9 @@ var log_default = defineCommand({
|
|
|
13485
13593
|
} else if (mode === "local") {
|
|
13486
13594
|
if (!compareRef) {
|
|
13487
13595
|
console.log();
|
|
13488
|
-
console.log(
|
|
13489
|
-
console.log(
|
|
13490
|
-
console.log(
|
|
13596
|
+
console.log(import_picocolors14.default.yellow(" \u26A0 Could not determine a comparison branch."));
|
|
13597
|
+
console.log(import_picocolors14.default.dim(" No upstream tracking set and no remote base branch found."));
|
|
13598
|
+
console.log(import_picocolors14.default.dim(` Use ${import_picocolors14.default.bold("contrib log --full")} to see the full commit history instead.`));
|
|
13491
13599
|
console.log();
|
|
13492
13600
|
return;
|
|
13493
13601
|
}
|
|
@@ -13506,8 +13614,8 @@ var log_default = defineCommand({
|
|
|
13506
13614
|
const remoteBranch = compareRef ?? targetBranch;
|
|
13507
13615
|
if (!remoteBranch) {
|
|
13508
13616
|
console.log();
|
|
13509
|
-
console.log(
|
|
13510
|
-
console.log(
|
|
13617
|
+
console.log(import_picocolors14.default.yellow(" \u26A0 Could not determine a remote branch to display."));
|
|
13618
|
+
console.log(import_picocolors14.default.dim(" Set an upstream tracking branch or configure your base branch first."));
|
|
13511
13619
|
console.log();
|
|
13512
13620
|
return;
|
|
13513
13621
|
}
|
|
@@ -13566,31 +13674,31 @@ async function getOverviewRemoteCommitCount(currentBranch, compareRef) {
|
|
|
13566
13674
|
}
|
|
13567
13675
|
function printModeHeader(mode, currentBranch, compareRef, usingFallback = false) {
|
|
13568
13676
|
const branch = currentBranch ?? "HEAD";
|
|
13569
|
-
const fallbackNote = usingFallback ?
|
|
13677
|
+
const fallbackNote = usingFallback ? import_picocolors14.default.yellow(" (no upstream \u2014 comparing against base branch)") : "";
|
|
13570
13678
|
switch (mode) {
|
|
13571
13679
|
case "overview":
|
|
13572
|
-
console.log(
|
|
13680
|
+
console.log(import_picocolors14.default.dim(` mode: ${import_picocolors14.default.bold("overview")} \u2014 local unpushed commits and remote branch history for ${import_picocolors14.default.bold(branch)}`) + fallbackNote);
|
|
13573
13681
|
if (compareRef) {
|
|
13574
|
-
console.log(
|
|
13682
|
+
console.log(import_picocolors14.default.dim(` remote source: ${import_picocolors14.default.bold(compareRef)}`));
|
|
13575
13683
|
}
|
|
13576
13684
|
break;
|
|
13577
13685
|
case "local":
|
|
13578
|
-
console.log(
|
|
13686
|
+
console.log(import_picocolors14.default.dim(` mode: ${import_picocolors14.default.bold("local")} \u2014 unpushed commits on ${import_picocolors14.default.bold(branch)}`) + fallbackNote);
|
|
13579
13687
|
if (compareRef) {
|
|
13580
|
-
console.log(
|
|
13688
|
+
console.log(import_picocolors14.default.dim(` comparing: ${import_picocolors14.default.bold(compareRef)} \u279C ${import_picocolors14.default.bold("HEAD")}`));
|
|
13581
13689
|
}
|
|
13582
13690
|
break;
|
|
13583
13691
|
case "remote":
|
|
13584
|
-
console.log(
|
|
13692
|
+
console.log(import_picocolors14.default.dim(` mode: ${import_picocolors14.default.bold("remote")} \u2014 remote branch history relevant to ${import_picocolors14.default.bold(branch)}`) + fallbackNote);
|
|
13585
13693
|
if (compareRef) {
|
|
13586
|
-
console.log(
|
|
13694
|
+
console.log(import_picocolors14.default.dim(` branch: ${import_picocolors14.default.bold(compareRef)}`));
|
|
13587
13695
|
}
|
|
13588
13696
|
break;
|
|
13589
13697
|
case "full":
|
|
13590
|
-
console.log(
|
|
13698
|
+
console.log(import_picocolors14.default.dim(` mode: ${import_picocolors14.default.bold("full")} \u2014 complete commit history for ${import_picocolors14.default.bold(branch)}`));
|
|
13591
13699
|
break;
|
|
13592
13700
|
case "all":
|
|
13593
|
-
console.log(
|
|
13701
|
+
console.log(import_picocolors14.default.dim(` mode: ${import_picocolors14.default.bold("all")} \u2014 commits across all branches`));
|
|
13594
13702
|
break;
|
|
13595
13703
|
}
|
|
13596
13704
|
}
|
|
@@ -13614,7 +13722,7 @@ async function renderScopedLog(options) {
|
|
|
13614
13722
|
}
|
|
13615
13723
|
console.log();
|
|
13616
13724
|
for (const entry of entries) {
|
|
13617
|
-
const hashStr =
|
|
13725
|
+
const hashStr = import_picocolors14.default.yellow(entry.hash);
|
|
13618
13726
|
const refsStr = entry.refs ? ` ${colorizeRefs(entry.refs, protectedBranches, currentBranch)}` : "";
|
|
13619
13727
|
const subjectStr = colorizeSubject(entry.subject);
|
|
13620
13728
|
console.log(` ${hashStr}${refsStr} ${subjectStr}`);
|
|
@@ -13633,10 +13741,10 @@ async function renderOverviewLog(options) {
|
|
|
13633
13741
|
usingFallback
|
|
13634
13742
|
} = options;
|
|
13635
13743
|
console.log();
|
|
13636
|
-
console.log(
|
|
13744
|
+
console.log(import_picocolors14.default.bold(import_picocolors14.default.cyan(" Local Unpushed Commits")));
|
|
13637
13745
|
if (!compareRef) {
|
|
13638
|
-
console.log(
|
|
13639
|
-
console.log(
|
|
13746
|
+
console.log(import_picocolors14.default.dim(" No comparison branch detected for local commit status."));
|
|
13747
|
+
console.log(import_picocolors14.default.dim(" Set an upstream tracking branch or run cn log --full to inspect the current branch history."));
|
|
13640
13748
|
} else {
|
|
13641
13749
|
await renderScopedLog({
|
|
13642
13750
|
mode: "local",
|
|
@@ -13648,11 +13756,11 @@ async function renderOverviewLog(options) {
|
|
|
13648
13756
|
});
|
|
13649
13757
|
}
|
|
13650
13758
|
console.log();
|
|
13651
|
-
console.log(
|
|
13759
|
+
console.log(import_picocolors14.default.bold(import_picocolors14.default.cyan(" Remote Branch History")));
|
|
13652
13760
|
if (!compareRef) {
|
|
13653
|
-
console.log(
|
|
13761
|
+
console.log(import_picocolors14.default.dim(" No remote branch detected."));
|
|
13654
13762
|
if (usingFallback) {
|
|
13655
|
-
console.log(
|
|
13763
|
+
console.log(import_picocolors14.default.dim(" Configure your base branch or upstream tracking to enable the split view."));
|
|
13656
13764
|
}
|
|
13657
13765
|
return;
|
|
13658
13766
|
}
|
|
@@ -13665,15 +13773,15 @@ async function renderOverviewLog(options) {
|
|
|
13665
13773
|
currentBranch
|
|
13666
13774
|
});
|
|
13667
13775
|
if (!hasRemoteHistory) {
|
|
13668
|
-
console.log(
|
|
13776
|
+
console.log(import_picocolors14.default.dim(" No remote history found for the selected branch."));
|
|
13669
13777
|
}
|
|
13670
13778
|
}
|
|
13671
13779
|
function printEmptyState(mode) {
|
|
13672
13780
|
console.log();
|
|
13673
13781
|
if (mode === "local") {
|
|
13674
|
-
console.log(
|
|
13782
|
+
console.log(import_picocolors14.default.dim(" No local unpushed commits \u2014 you're up to date with remote!"));
|
|
13675
13783
|
} else {
|
|
13676
|
-
console.log(
|
|
13784
|
+
console.log(import_picocolors14.default.dim(" No remote-only commits \u2014 your local branch is up to date!"));
|
|
13677
13785
|
}
|
|
13678
13786
|
console.log();
|
|
13679
13787
|
}
|
|
@@ -13682,7 +13790,7 @@ async function renderFullLog(options) {
|
|
|
13682
13790
|
if (showGraph) {
|
|
13683
13791
|
const lines = await getLogGraph({ count, all, branch: targetBranch });
|
|
13684
13792
|
if (lines.length === 0) {
|
|
13685
|
-
console.log(
|
|
13793
|
+
console.log(import_picocolors14.default.dim(" No commits found."));
|
|
13686
13794
|
console.log();
|
|
13687
13795
|
return false;
|
|
13688
13796
|
}
|
|
@@ -13693,13 +13801,13 @@ async function renderFullLog(options) {
|
|
|
13693
13801
|
} else {
|
|
13694
13802
|
const entries = await getLogEntries({ count, all, branch: targetBranch });
|
|
13695
13803
|
if (entries.length === 0) {
|
|
13696
|
-
console.log(
|
|
13804
|
+
console.log(import_picocolors14.default.dim(" No commits found."));
|
|
13697
13805
|
console.log();
|
|
13698
13806
|
return false;
|
|
13699
13807
|
}
|
|
13700
13808
|
console.log();
|
|
13701
13809
|
for (const entry of entries) {
|
|
13702
|
-
const hashStr =
|
|
13810
|
+
const hashStr = import_picocolors14.default.yellow(entry.hash);
|
|
13703
13811
|
const refsStr = entry.refs ? ` ${colorizeRefs(entry.refs, protectedBranches, currentBranch)}` : "";
|
|
13704
13812
|
const subjectStr = colorizeSubject(entry.subject);
|
|
13705
13813
|
console.log(` ${hashStr}${refsStr} ${subjectStr}`);
|
|
@@ -13711,33 +13819,33 @@ function printFooter(mode, count, overviewRemoteCount, targetBranch) {
|
|
|
13711
13819
|
console.log();
|
|
13712
13820
|
switch (mode) {
|
|
13713
13821
|
case "overview":
|
|
13714
|
-
console.log(
|
|
13822
|
+
console.log(import_picocolors14.default.dim(` Showing up to ${count} local commits and ${overviewRemoteCount} remote commits`));
|
|
13715
13823
|
break;
|
|
13716
13824
|
case "local":
|
|
13717
|
-
console.log(
|
|
13825
|
+
console.log(import_picocolors14.default.dim(` Showing up to ${count} unpushed commits`));
|
|
13718
13826
|
break;
|
|
13719
13827
|
case "remote":
|
|
13720
|
-
console.log(
|
|
13828
|
+
console.log(import_picocolors14.default.dim(` Showing ${count} most recent commits from the remote branch`));
|
|
13721
13829
|
break;
|
|
13722
13830
|
case "full":
|
|
13723
|
-
console.log(
|
|
13831
|
+
console.log(import_picocolors14.default.dim(` Showing ${count} most recent commits${targetBranch ? ` (${targetBranch})` : ""}`));
|
|
13724
13832
|
break;
|
|
13725
13833
|
case "all":
|
|
13726
|
-
console.log(
|
|
13834
|
+
console.log(import_picocolors14.default.dim(` Showing ${count} most recent commits (all branches)`));
|
|
13727
13835
|
break;
|
|
13728
13836
|
}
|
|
13729
13837
|
}
|
|
13730
13838
|
function colorizeGraphLine(line, protectedBranches, currentBranch) {
|
|
13731
13839
|
const match = line.match(/^([|/\\*\s_.-]*)([a-f0-9]{7,12})(\s+\(([^)]+)\))?\s*(.*)/);
|
|
13732
13840
|
if (!match) {
|
|
13733
|
-
return
|
|
13841
|
+
return import_picocolors14.default.cyan(line);
|
|
13734
13842
|
}
|
|
13735
13843
|
const [, graphPart = "", hash, , refs, subject = ""] = match;
|
|
13736
13844
|
const parts = [];
|
|
13737
13845
|
if (graphPart) {
|
|
13738
13846
|
parts.push(colorizeGraphChars(graphPart));
|
|
13739
13847
|
}
|
|
13740
|
-
parts.push(
|
|
13848
|
+
parts.push(import_picocolors14.default.yellow(hash));
|
|
13741
13849
|
if (refs) {
|
|
13742
13850
|
parts.push(` (${colorizeRefs(refs, protectedBranches, currentBranch)})`);
|
|
13743
13851
|
}
|
|
@@ -13748,15 +13856,15 @@ function colorizeGraphChars(graphPart) {
|
|
|
13748
13856
|
return graphPart.split("").map((ch) => {
|
|
13749
13857
|
switch (ch) {
|
|
13750
13858
|
case "*":
|
|
13751
|
-
return
|
|
13859
|
+
return import_picocolors14.default.green(ch);
|
|
13752
13860
|
case "|":
|
|
13753
|
-
return
|
|
13861
|
+
return import_picocolors14.default.cyan(ch);
|
|
13754
13862
|
case "/":
|
|
13755
13863
|
case "\\":
|
|
13756
|
-
return
|
|
13864
|
+
return import_picocolors14.default.cyan(ch);
|
|
13757
13865
|
case "-":
|
|
13758
13866
|
case "_":
|
|
13759
|
-
return
|
|
13867
|
+
return import_picocolors14.default.cyan(ch);
|
|
13760
13868
|
default:
|
|
13761
13869
|
return ch;
|
|
13762
13870
|
}
|
|
@@ -13768,46 +13876,46 @@ function colorizeRefs(refs, protectedBranches, currentBranch) {
|
|
|
13768
13876
|
if (trimmed.startsWith("HEAD ->") || trimmed === "HEAD") {
|
|
13769
13877
|
const branchName = trimmed.replace("HEAD -> ", "");
|
|
13770
13878
|
if (trimmed === "HEAD") {
|
|
13771
|
-
return
|
|
13879
|
+
return import_picocolors14.default.bold(import_picocolors14.default.cyan("HEAD"));
|
|
13772
13880
|
}
|
|
13773
|
-
return `${
|
|
13881
|
+
return `${import_picocolors14.default.bold(import_picocolors14.default.cyan("HEAD"))} ${import_picocolors14.default.dim("->")} ${colorizeRefName(branchName, protectedBranches, currentBranch)}`;
|
|
13774
13882
|
}
|
|
13775
13883
|
if (trimmed.startsWith("tag:")) {
|
|
13776
|
-
return
|
|
13884
|
+
return import_picocolors14.default.bold(import_picocolors14.default.magenta(trimmed));
|
|
13777
13885
|
}
|
|
13778
13886
|
return colorizeRefName(trimmed, protectedBranches, currentBranch);
|
|
13779
|
-
}).join(
|
|
13887
|
+
}).join(import_picocolors14.default.dim(", "));
|
|
13780
13888
|
}
|
|
13781
13889
|
function colorizeRefName(name, protectedBranches, currentBranch) {
|
|
13782
13890
|
const isRemote = name.includes("/");
|
|
13783
13891
|
const localName = isRemote ? name.split("/").slice(1).join("/") : name;
|
|
13784
13892
|
if (protectedBranches.includes(localName)) {
|
|
13785
|
-
return isRemote ?
|
|
13893
|
+
return isRemote ? import_picocolors14.default.bold(import_picocolors14.default.red(name)) : import_picocolors14.default.bold(import_picocolors14.default.red(name));
|
|
13786
13894
|
}
|
|
13787
13895
|
if (localName === currentBranch) {
|
|
13788
|
-
return
|
|
13896
|
+
return import_picocolors14.default.bold(import_picocolors14.default.green(name));
|
|
13789
13897
|
}
|
|
13790
13898
|
if (isRemote) {
|
|
13791
|
-
return
|
|
13899
|
+
return import_picocolors14.default.blue(name);
|
|
13792
13900
|
}
|
|
13793
|
-
return
|
|
13901
|
+
return import_picocolors14.default.green(name);
|
|
13794
13902
|
}
|
|
13795
13903
|
function colorizeSubject(subject) {
|
|
13796
13904
|
const emojiMatch = subject.match(/^((?:\p{Emoji_Presentation}|\p{Emoji}\uFE0F)+\s*)/u);
|
|
13797
13905
|
if (emojiMatch) {
|
|
13798
13906
|
const emoji = emojiMatch[1];
|
|
13799
13907
|
const rest = subject.slice(emoji.length);
|
|
13800
|
-
return `${emoji}${
|
|
13908
|
+
return `${emoji}${import_picocolors14.default.white(rest)}`;
|
|
13801
13909
|
}
|
|
13802
13910
|
if (subject.startsWith("Merge ")) {
|
|
13803
|
-
return
|
|
13911
|
+
return import_picocolors14.default.dim(subject);
|
|
13804
13912
|
}
|
|
13805
|
-
return
|
|
13913
|
+
return import_picocolors14.default.white(subject);
|
|
13806
13914
|
}
|
|
13807
13915
|
|
|
13808
13916
|
// src/commands/save.ts
|
|
13809
13917
|
import { execFile as execFileCb4 } from "child_process";
|
|
13810
|
-
var
|
|
13918
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
13811
13919
|
function gitRun(args) {
|
|
13812
13920
|
return new Promise((resolve5) => {
|
|
13813
13921
|
execFileCb4("git", args, (err, stdout2, stderr) => {
|
|
@@ -13881,8 +13989,8 @@ async function handleSave(message) {
|
|
|
13881
13989
|
info("No uncommitted changes to save.");
|
|
13882
13990
|
return;
|
|
13883
13991
|
}
|
|
13884
|
-
success(`Saved: ${
|
|
13885
|
-
info(`Use ${
|
|
13992
|
+
success(`Saved: ${import_picocolors15.default.dim(label)}`);
|
|
13993
|
+
info(`Use ${import_picocolors15.default.bold("contrib save --restore")} to bring them back.`, "");
|
|
13886
13994
|
}
|
|
13887
13995
|
async function handleRestore() {
|
|
13888
13996
|
await projectHeading("save --restore", "\uD83D\uDCBE");
|
|
@@ -13898,7 +14006,7 @@ async function handleRestore() {
|
|
|
13898
14006
|
warn("You may have conflicts. Resolve them and run `git stash drop` when done.");
|
|
13899
14007
|
process.exit(1);
|
|
13900
14008
|
}
|
|
13901
|
-
success(`Restored: ${
|
|
14009
|
+
success(`Restored: ${import_picocolors15.default.dim(stashes[0].message)}`);
|
|
13902
14010
|
return;
|
|
13903
14011
|
}
|
|
13904
14012
|
const choices = stashes.map((s2) => `${s2.index} ${s2.message}`);
|
|
@@ -13911,7 +14019,7 @@ async function handleRestore() {
|
|
|
13911
14019
|
process.exit(1);
|
|
13912
14020
|
}
|
|
13913
14021
|
const match = stashes.find((s2) => String(s2.index) === idx);
|
|
13914
|
-
success(`Restored: ${
|
|
14022
|
+
success(`Restored: ${import_picocolors15.default.dim(match?.message ?? "saved changes")}`);
|
|
13915
14023
|
}
|
|
13916
14024
|
async function handleList() {
|
|
13917
14025
|
await projectHeading("save --list", "\uD83D\uDCBE");
|
|
@@ -13922,13 +14030,13 @@ async function handleList() {
|
|
|
13922
14030
|
}
|
|
13923
14031
|
console.log();
|
|
13924
14032
|
for (const s2 of stashes) {
|
|
13925
|
-
const idx =
|
|
14033
|
+
const idx = import_picocolors15.default.dim(`[${s2.index}]`);
|
|
13926
14034
|
const msg = s2.message;
|
|
13927
14035
|
console.log(` ${idx} ${msg}`);
|
|
13928
14036
|
}
|
|
13929
14037
|
console.log();
|
|
13930
|
-
info(`Use ${
|
|
13931
|
-
info(`Use ${
|
|
14038
|
+
info(`Use ${import_picocolors15.default.bold("contrib save --restore")} to bring changes back.`, "");
|
|
14039
|
+
info(`Use ${import_picocolors15.default.bold("contrib save --drop")} to discard saved changes.`, "");
|
|
13932
14040
|
}
|
|
13933
14041
|
async function handleDrop() {
|
|
13934
14042
|
await projectHeading("save --drop", "\uD83D\uDCBE");
|
|
@@ -13946,7 +14054,7 @@ async function handleDrop() {
|
|
|
13946
14054
|
process.exit(1);
|
|
13947
14055
|
}
|
|
13948
14056
|
const match = stashes.find((s2) => String(s2.index) === idx);
|
|
13949
|
-
success(`Dropped: ${
|
|
14057
|
+
success(`Dropped: ${import_picocolors15.default.dim(match?.message ?? "saved changes")}`);
|
|
13950
14058
|
}
|
|
13951
14059
|
async function getStashList() {
|
|
13952
14060
|
const result = await gitRun(["stash", "list"]);
|
|
@@ -13963,7 +14071,7 @@ async function getStashList() {
|
|
|
13963
14071
|
}
|
|
13964
14072
|
|
|
13965
14073
|
// src/commands/setup.ts
|
|
13966
|
-
var
|
|
14074
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
13967
14075
|
async function shouldContinueSetupWithExistingConfig(options) {
|
|
13968
14076
|
const { existingConfig, hasConfigFile, confirm, onInfo, onWarn, onSuccess, summary } = options;
|
|
13969
14077
|
if (existingConfig) {
|
|
@@ -14046,7 +14154,7 @@ var setup_default = defineCommand({
|
|
|
14046
14154
|
workflow = "github-flow";
|
|
14047
14155
|
else if (workflowChoice.startsWith("Git Flow"))
|
|
14048
14156
|
workflow = "git-flow";
|
|
14049
|
-
info(`Workflow: ${
|
|
14157
|
+
info(`Workflow: ${import_picocolors16.default.bold(WORKFLOW_DESCRIPTIONS[workflow])}`);
|
|
14050
14158
|
const conventionChoice = await selectPrompt("Which commit convention should this project use?", [
|
|
14051
14159
|
`${CONVENTION_DESCRIPTIONS["clean-commit"]} (recommended)`,
|
|
14052
14160
|
CONVENTION_DESCRIPTIONS.conventional,
|
|
@@ -14076,7 +14184,7 @@ var setup_default = defineCommand({
|
|
|
14076
14184
|
try {
|
|
14077
14185
|
await setOllamaCloudApiKey(apiKey);
|
|
14078
14186
|
success("Stored Ollama Cloud API key in the local secrets store.");
|
|
14079
|
-
info(`Secrets path: ${
|
|
14187
|
+
info(`Secrets path: ${import_picocolors16.default.bold(getSecretsStorePath())}`);
|
|
14080
14188
|
} catch (err) {
|
|
14081
14189
|
const message = err instanceof Error ? err.message : String(err);
|
|
14082
14190
|
error(`Failed to store Ollama Cloud API key: ${message}`);
|
|
@@ -14138,15 +14246,15 @@ var setup_default = defineCommand({
|
|
|
14138
14246
|
detectedRole = roleChoice;
|
|
14139
14247
|
detectionSource = "user selection";
|
|
14140
14248
|
} else {
|
|
14141
|
-
info(`Detected role: ${
|
|
14142
|
-
const confirmed = await confirmPrompt(`Role detected as ${
|
|
14249
|
+
info(`Detected role: ${import_picocolors16.default.bold(detectedRole)} (via ${detectionSource})`);
|
|
14250
|
+
const confirmed = await confirmPrompt(`Role detected as ${import_picocolors16.default.bold(detectedRole)}. Is this correct?`);
|
|
14143
14251
|
if (!confirmed) {
|
|
14144
14252
|
const roleChoice = await selectPrompt("Select your role:", ["maintainer", "contributor"]);
|
|
14145
14253
|
detectedRole = roleChoice;
|
|
14146
14254
|
}
|
|
14147
14255
|
}
|
|
14148
14256
|
const defaultConfig = getDefaultConfig();
|
|
14149
|
-
info(
|
|
14257
|
+
info(import_picocolors16.default.dim("Tip: press Enter to keep the default branch name shown in each prompt."));
|
|
14150
14258
|
const mainBranchDefault = defaultConfig.mainBranch;
|
|
14151
14259
|
const mainBranch = await inputPrompt(`Main branch name (default: ${mainBranchDefault} \u2014 press Enter to keep)`, mainBranchDefault);
|
|
14152
14260
|
let devBranch;
|
|
@@ -14172,7 +14280,7 @@ var setup_default = defineCommand({
|
|
|
14172
14280
|
error("Setup cannot continue without the upstream remote for contributors.");
|
|
14173
14281
|
process.exit(1);
|
|
14174
14282
|
}
|
|
14175
|
-
success(`Added remote ${
|
|
14283
|
+
success(`Added remote ${import_picocolors16.default.bold(upstreamRemote)} \u2192 ${upstreamUrl}`);
|
|
14176
14284
|
} else {
|
|
14177
14285
|
error("An upstream remote URL is required for contributors.");
|
|
14178
14286
|
info("Add it manually: git remote add upstream <url>", "");
|
|
@@ -14195,67 +14303,67 @@ var setup_default = defineCommand({
|
|
|
14195
14303
|
showTips
|
|
14196
14304
|
};
|
|
14197
14305
|
writeConfig(config);
|
|
14198
|
-
success(`Config written to ${
|
|
14306
|
+
success(`Config written to ${import_picocolors16.default.bold(getConfigLocationLabel())}`);
|
|
14199
14307
|
info("This setup is stored locally for this clone and does not modify tracked files.", "");
|
|
14200
14308
|
const syncRemote = config.role === "contributor" ? config.upstream : config.origin;
|
|
14201
|
-
info(`Fetching ${
|
|
14309
|
+
info(`Fetching ${import_picocolors16.default.bold(syncRemote)} to verify branch configuration...`, "");
|
|
14202
14310
|
await fetchRemote(syncRemote);
|
|
14203
14311
|
const mainRef = `${syncRemote}/${config.mainBranch}`;
|
|
14204
14312
|
if (!await refExists(mainRef)) {
|
|
14205
|
-
warn(`Main branch ref ${
|
|
14313
|
+
warn(`Main branch ref ${import_picocolors16.default.bold(mainRef)} not found on remote.`);
|
|
14206
14314
|
warn("Config was saved \u2014 verify the branch name and re-run setup if needed.");
|
|
14207
14315
|
}
|
|
14208
14316
|
if (config.devBranch) {
|
|
14209
14317
|
const devRef = `${syncRemote}/${config.devBranch}`;
|
|
14210
14318
|
if (!await refExists(devRef)) {
|
|
14211
|
-
warn(`Dev branch ref ${
|
|
14319
|
+
warn(`Dev branch ref ${import_picocolors16.default.bold(devRef)} not found on remote.`);
|
|
14212
14320
|
warn("Config was saved \u2014 verify the branch name and re-run setup if needed.");
|
|
14213
14321
|
}
|
|
14214
14322
|
}
|
|
14215
14323
|
console.log();
|
|
14216
14324
|
const resolvedAIConfig = resolveAIConfig(config);
|
|
14217
|
-
info(`Workflow: ${
|
|
14218
|
-
info(`Convention: ${
|
|
14219
|
-
info(`AI: ${
|
|
14325
|
+
info(`Workflow: ${import_picocolors16.default.bold(WORKFLOW_DESCRIPTIONS[config.workflow])}`);
|
|
14326
|
+
info(`Convention: ${import_picocolors16.default.bold(CONVENTION_DESCRIPTIONS[config.commitConvention])}`);
|
|
14327
|
+
info(`AI: ${import_picocolors16.default.bold(isAIEnabled(config) ? "enabled" : "disabled")}`);
|
|
14220
14328
|
if (isAIEnabled(config)) {
|
|
14221
|
-
info(`AI provider: ${
|
|
14329
|
+
info(`AI provider: ${import_picocolors16.default.bold(resolvedAIConfig.providerLabel)}`);
|
|
14222
14330
|
if (resolvedAIConfig.model) {
|
|
14223
|
-
info(`AI model: ${
|
|
14331
|
+
info(`AI model: ${import_picocolors16.default.bold(resolvedAIConfig.model)}`);
|
|
14224
14332
|
}
|
|
14225
14333
|
}
|
|
14226
|
-
info(`Guides: ${
|
|
14227
|
-
info(`Role: ${
|
|
14334
|
+
info(`Guides: ${import_picocolors16.default.bold(shouldShowTips(config) ? "shown" : "hidden")}`);
|
|
14335
|
+
info(`Role: ${import_picocolors16.default.bold(config.role)}`);
|
|
14228
14336
|
if (config.devBranch) {
|
|
14229
|
-
info(`Main: ${
|
|
14337
|
+
info(`Main: ${import_picocolors16.default.bold(config.mainBranch)} | Dev: ${import_picocolors16.default.bold(config.devBranch)}`);
|
|
14230
14338
|
} else {
|
|
14231
|
-
info(`Main: ${
|
|
14339
|
+
info(`Main: ${import_picocolors16.default.bold(config.mainBranch)}`);
|
|
14232
14340
|
}
|
|
14233
|
-
info(`Origin: ${
|
|
14341
|
+
info(`Origin: ${import_picocolors16.default.bold(config.origin)}${config.role === "contributor" ? ` | Upstream: ${import_picocolors16.default.bold(config.upstream)}` : ""}`);
|
|
14234
14342
|
}
|
|
14235
14343
|
});
|
|
14236
14344
|
function logConfigSummary(config) {
|
|
14237
14345
|
const aiConfig = resolveAIConfig(config);
|
|
14238
|
-
info(`Workflow: ${
|
|
14239
|
-
info(`Convention: ${
|
|
14240
|
-
info(`AI: ${
|
|
14346
|
+
info(`Workflow: ${import_picocolors16.default.bold(WORKFLOW_DESCRIPTIONS[config.workflow])}`);
|
|
14347
|
+
info(`Convention: ${import_picocolors16.default.bold(CONVENTION_DESCRIPTIONS[config.commitConvention])}`);
|
|
14348
|
+
info(`AI: ${import_picocolors16.default.bold(isAIEnabled(config) ? "enabled" : "disabled")}`);
|
|
14241
14349
|
if (isAIEnabled(config)) {
|
|
14242
|
-
info(`AI provider: ${
|
|
14350
|
+
info(`AI provider: ${import_picocolors16.default.bold(aiConfig.providerLabel)}`);
|
|
14243
14351
|
if (aiConfig.model) {
|
|
14244
|
-
info(`AI model: ${
|
|
14352
|
+
info(`AI model: ${import_picocolors16.default.bold(aiConfig.model)}`);
|
|
14245
14353
|
}
|
|
14246
14354
|
}
|
|
14247
|
-
info(`Guides: ${
|
|
14248
|
-
info(`Role: ${
|
|
14355
|
+
info(`Guides: ${import_picocolors16.default.bold(shouldShowTips(config) ? "shown" : "hidden")}`);
|
|
14356
|
+
info(`Role: ${import_picocolors16.default.bold(config.role)}`);
|
|
14249
14357
|
if (config.devBranch) {
|
|
14250
|
-
info(`Main: ${
|
|
14358
|
+
info(`Main: ${import_picocolors16.default.bold(config.mainBranch)} | Dev: ${import_picocolors16.default.bold(config.devBranch)}`);
|
|
14251
14359
|
} else {
|
|
14252
|
-
info(`Main: ${
|
|
14360
|
+
info(`Main: ${import_picocolors16.default.bold(config.mainBranch)}`);
|
|
14253
14361
|
}
|
|
14254
|
-
info(`Origin: ${
|
|
14362
|
+
info(`Origin: ${import_picocolors16.default.bold(config.origin)}${config.role === "contributor" ? ` | Upstream: ${import_picocolors16.default.bold(config.upstream)}` : ""}`);
|
|
14255
14363
|
}
|
|
14256
14364
|
|
|
14257
14365
|
// src/commands/start.ts
|
|
14258
|
-
var
|
|
14366
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
14259
14367
|
var start_default = defineCommand({
|
|
14260
14368
|
meta: {
|
|
14261
14369
|
name: "start",
|
|
@@ -14307,16 +14415,16 @@ var start_default = defineCommand({
|
|
|
14307
14415
|
warn("Start cancelled.");
|
|
14308
14416
|
process.exit(0);
|
|
14309
14417
|
}
|
|
14310
|
-
info(`Creating branch: ${
|
|
14418
|
+
info(`Creating branch: ${import_picocolors17.default.bold(branchName)}`);
|
|
14311
14419
|
await fetchRemote(syncSource.remote);
|
|
14312
14420
|
if (!await refExists(syncSource.ref)) {
|
|
14313
|
-
warn(`Remote ref ${
|
|
14421
|
+
warn(`Remote ref ${import_picocolors17.default.bold(syncSource.ref)} not found. Creating branch from local ${import_picocolors17.default.bold(baseBranch)}.`);
|
|
14314
14422
|
}
|
|
14315
14423
|
const currentBranch = await getCurrentBranch();
|
|
14316
14424
|
if (currentBranch === baseBranch && await refExists(syncSource.ref)) {
|
|
14317
14425
|
const ahead = await countCommitsAhead(baseBranch, syncSource.ref);
|
|
14318
14426
|
if (ahead > 0) {
|
|
14319
|
-
warn(`You are on ${
|
|
14427
|
+
warn(`You are on ${import_picocolors17.default.bold(baseBranch)} with ${import_picocolors17.default.bold(String(ahead))} local commit${ahead > 1 ? "s" : ""} not in ${import_picocolors17.default.bold(syncSource.ref)}.`);
|
|
14320
14428
|
info(" Syncing will discard those commits. Consider backing them up first (e.g. create a branch).");
|
|
14321
14429
|
const proceed = await confirmPrompt("Discard local commits and sync to remote?");
|
|
14322
14430
|
if (!proceed) {
|
|
@@ -14333,10 +14441,10 @@ var start_default = defineCommand({
|
|
|
14333
14441
|
error(`Failed to create branch: ${result2.stderr}`);
|
|
14334
14442
|
process.exit(1);
|
|
14335
14443
|
}
|
|
14336
|
-
success(`Created ${
|
|
14444
|
+
success(`Created ${import_picocolors17.default.bold(branchName)} from ${import_picocolors17.default.bold(syncSource.ref)}`);
|
|
14337
14445
|
return;
|
|
14338
14446
|
}
|
|
14339
|
-
error(`Failed to update ${
|
|
14447
|
+
error(`Failed to update ${import_picocolors17.default.bold(baseBranch)}: ${updateResult.stderr}`);
|
|
14340
14448
|
info("Make sure your base branch exists locally or the remote ref is available.", "");
|
|
14341
14449
|
process.exit(1);
|
|
14342
14450
|
}
|
|
@@ -14345,12 +14453,12 @@ var start_default = defineCommand({
|
|
|
14345
14453
|
error(`Failed to create branch: ${result.stderr}`);
|
|
14346
14454
|
process.exit(1);
|
|
14347
14455
|
}
|
|
14348
|
-
success(`Created ${
|
|
14456
|
+
success(`Created ${import_picocolors17.default.bold(branchName)} from latest ${import_picocolors17.default.bold(baseBranch)}`);
|
|
14349
14457
|
}
|
|
14350
14458
|
});
|
|
14351
14459
|
|
|
14352
14460
|
// src/commands/status.ts
|
|
14353
|
-
var
|
|
14461
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
14354
14462
|
var status_default = defineCommand({
|
|
14355
14463
|
meta: {
|
|
14356
14464
|
name: "status",
|
|
@@ -14367,8 +14475,8 @@ var status_default = defineCommand({
|
|
|
14367
14475
|
process.exit(1);
|
|
14368
14476
|
}
|
|
14369
14477
|
await projectHeading("status", "\uD83D\uDCCA");
|
|
14370
|
-
console.log(` ${
|
|
14371
|
-
console.log(` ${
|
|
14478
|
+
console.log(` ${import_picocolors18.default.dim("Workflow:")} ${import_picocolors18.default.bold(WORKFLOW_DESCRIPTIONS[config.workflow])}`);
|
|
14479
|
+
console.log(` ${import_picocolors18.default.dim("Role:")} ${import_picocolors18.default.bold(config.role)}`);
|
|
14372
14480
|
console.log();
|
|
14373
14481
|
await fetchAll();
|
|
14374
14482
|
const currentBranch = await getCurrentBranch();
|
|
@@ -14377,7 +14485,7 @@ var status_default = defineCommand({
|
|
|
14377
14485
|
const isContributor = config.role === "contributor";
|
|
14378
14486
|
const [dirty, fileStatus] = await Promise.all([hasUncommittedChanges(), getFileStatus()]);
|
|
14379
14487
|
if (dirty) {
|
|
14380
|
-
console.log(` ${
|
|
14488
|
+
console.log(` ${import_picocolors18.default.yellow("\u26A0")} ${import_picocolors18.default.yellow("Uncommitted changes in working tree")}`);
|
|
14381
14489
|
console.log();
|
|
14382
14490
|
}
|
|
14383
14491
|
const mainRemote = `${origin}/${mainBranch}`;
|
|
@@ -14396,16 +14504,16 @@ var status_default = defineCommand({
|
|
|
14396
14504
|
if (isFeatureBranch) {
|
|
14397
14505
|
const branchDiv = await getDivergence(currentBranch, baseBranch);
|
|
14398
14506
|
const branchLine = formatStatus(currentBranch, baseBranch, branchDiv.ahead, branchDiv.behind);
|
|
14399
|
-
console.log(branchLine +
|
|
14507
|
+
console.log(branchLine + import_picocolors18.default.dim(` (current ${import_picocolors18.default.green("*")})`));
|
|
14400
14508
|
branchStatus = await detectBranchStatus(currentBranch, baseBranch);
|
|
14401
14509
|
if (branchStatus.merged) {
|
|
14402
|
-
console.log(` ${
|
|
14510
|
+
console.log(` ${import_picocolors18.default.green("\u2713")} ${import_picocolors18.default.green("Branch merged")} \u2014 ${import_picocolors18.default.dim(branchStatus.mergedReason ?? "all commits reachable from base")}`);
|
|
14403
14511
|
}
|
|
14404
14512
|
if (branchStatus.stale) {
|
|
14405
|
-
console.log(` ${
|
|
14513
|
+
console.log(` ${import_picocolors18.default.yellow("\u23F3")} ${import_picocolors18.default.yellow("Branch is stale")} \u2014 ${import_picocolors18.default.dim(`last commit ${branchStatus.staleDaysAgo} days ago`)}`);
|
|
14406
14514
|
}
|
|
14407
14515
|
} else if (currentBranch) {
|
|
14408
|
-
console.log(
|
|
14516
|
+
console.log(import_picocolors18.default.dim(` (on ${import_picocolors18.default.bold(currentBranch)} branch)`));
|
|
14409
14517
|
}
|
|
14410
14518
|
let branchesAligned = true;
|
|
14411
14519
|
{
|
|
@@ -14442,20 +14550,20 @@ var status_default = defineCommand({
|
|
|
14442
14550
|
}
|
|
14443
14551
|
branchesAligned = groups.size === 1;
|
|
14444
14552
|
console.log();
|
|
14445
|
-
console.log(` ${
|
|
14553
|
+
console.log(` ${import_picocolors18.default.bold("\uD83D\uDD17 Branch Alignment")}`);
|
|
14446
14554
|
for (const [hash, names] of groups) {
|
|
14447
14555
|
const short = hash.slice(0, 7);
|
|
14448
|
-
const nameStr = names.map((n2) =>
|
|
14449
|
-
console.log(` ${
|
|
14556
|
+
const nameStr = names.map((n2) => import_picocolors18.default.bold(n2)).join(import_picocolors18.default.dim(" \xB7 "));
|
|
14557
|
+
console.log(` ${import_picocolors18.default.yellow(short)} ${import_picocolors18.default.dim("\u2500\u2500")} ${nameStr}`);
|
|
14450
14558
|
const subject = await getCommitSubject(hash);
|
|
14451
14559
|
if (subject) {
|
|
14452
|
-
console.log(` ${
|
|
14560
|
+
console.log(` ${import_picocolors18.default.dim(subject)}`);
|
|
14453
14561
|
}
|
|
14454
14562
|
}
|
|
14455
14563
|
if (branchesAligned) {
|
|
14456
|
-
console.log(` ${
|
|
14564
|
+
console.log(` ${import_picocolors18.default.green("\u2713")} ${import_picocolors18.default.green("All branches aligned")} ${import_picocolors18.default.dim("\u2014 ready to start")}`);
|
|
14457
14565
|
} else {
|
|
14458
|
-
console.log(` ${
|
|
14566
|
+
console.log(` ${import_picocolors18.default.yellow("\u26A0")} ${import_picocolors18.default.yellow("Branches are not fully aligned")}`);
|
|
14459
14567
|
}
|
|
14460
14568
|
}
|
|
14461
14569
|
}
|
|
@@ -14463,41 +14571,41 @@ var status_default = defineCommand({
|
|
|
14463
14571
|
if (hasFiles) {
|
|
14464
14572
|
console.log();
|
|
14465
14573
|
if (fileStatus.staged.length > 0) {
|
|
14466
|
-
console.log(` ${
|
|
14574
|
+
console.log(` ${import_picocolors18.default.green("Staged for commit:")}`);
|
|
14467
14575
|
for (const { file, status } of fileStatus.staged) {
|
|
14468
|
-
console.log(` ${
|
|
14576
|
+
console.log(` ${import_picocolors18.default.green("+")} ${import_picocolors18.default.dim(`${status}:`)} ${file}`);
|
|
14469
14577
|
}
|
|
14470
14578
|
}
|
|
14471
14579
|
if (fileStatus.modified.length > 0) {
|
|
14472
|
-
console.log(` ${
|
|
14580
|
+
console.log(` ${import_picocolors18.default.yellow("Unstaged changes:")}`);
|
|
14473
14581
|
for (const { file, status } of fileStatus.modified) {
|
|
14474
|
-
console.log(` ${
|
|
14582
|
+
console.log(` ${import_picocolors18.default.yellow("~")} ${import_picocolors18.default.dim(`${status}:`)} ${file}`);
|
|
14475
14583
|
}
|
|
14476
14584
|
}
|
|
14477
14585
|
if (fileStatus.untracked.length > 0) {
|
|
14478
|
-
console.log(` ${
|
|
14586
|
+
console.log(` ${import_picocolors18.default.red("Untracked files:")}`);
|
|
14479
14587
|
for (const file of fileStatus.untracked) {
|
|
14480
|
-
console.log(` ${
|
|
14588
|
+
console.log(` ${import_picocolors18.default.red("?")} ${file}`);
|
|
14481
14589
|
}
|
|
14482
14590
|
}
|
|
14483
14591
|
} else if (!dirty) {
|
|
14484
|
-
console.log(` ${
|
|
14592
|
+
console.log(` ${import_picocolors18.default.green("\u2713")} ${import_picocolors18.default.dim("Working tree clean")}`);
|
|
14485
14593
|
}
|
|
14486
14594
|
console.log();
|
|
14487
14595
|
}
|
|
14488
14596
|
});
|
|
14489
14597
|
function formatStatus(branch, base, ahead, behind) {
|
|
14490
|
-
const label =
|
|
14598
|
+
const label = import_picocolors18.default.bold(branch.padEnd(20));
|
|
14491
14599
|
if (ahead === 0 && behind === 0) {
|
|
14492
|
-
return ` ${
|
|
14600
|
+
return ` ${import_picocolors18.default.green("\u2713")} ${label} ${import_picocolors18.default.dim(`in sync with ${base}`)}`;
|
|
14493
14601
|
}
|
|
14494
14602
|
if (ahead > 0 && behind === 0) {
|
|
14495
|
-
return ` ${
|
|
14603
|
+
return ` ${import_picocolors18.default.yellow("\u2191")} ${label} ${import_picocolors18.default.yellow(`${ahead} commit${ahead !== 1 ? "s" : ""} ahead of ${base}`)}`;
|
|
14496
14604
|
}
|
|
14497
14605
|
if (behind > 0 && ahead === 0) {
|
|
14498
|
-
return ` ${
|
|
14606
|
+
return ` ${import_picocolors18.default.red("\u2193")} ${label} ${import_picocolors18.default.red(`${behind} commit${behind !== 1 ? "s" : ""} behind ${base}`)}`;
|
|
14499
14607
|
}
|
|
14500
|
-
return ` ${
|
|
14608
|
+
return ` ${import_picocolors18.default.red("\u26A1")} ${label} ${import_picocolors18.default.yellow(`${ahead} ahead`)}${import_picocolors18.default.dim(", ")}${import_picocolors18.default.red(`${behind} behind`)} ${import_picocolors18.default.dim(base)}`;
|
|
14501
14609
|
}
|
|
14502
14610
|
var STALE_THRESHOLD_DAYS = 14;
|
|
14503
14611
|
async function detectBranchStatus(branch, baseBranch) {
|
|
@@ -14548,15 +14656,15 @@ async function detectBranchStatus(branch, baseBranch) {
|
|
|
14548
14656
|
}
|
|
14549
14657
|
|
|
14550
14658
|
// src/commands/submit.ts
|
|
14551
|
-
var
|
|
14659
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
14552
14660
|
async function performSquashMerge(origin, baseBranch, featureBranch, options) {
|
|
14553
|
-
info(`Checking out ${
|
|
14661
|
+
info(`Checking out ${import_picocolors19.default.bold(baseBranch)}...`);
|
|
14554
14662
|
const coResult = await checkoutBranch(baseBranch);
|
|
14555
14663
|
if (coResult.exitCode !== 0) {
|
|
14556
14664
|
error(`Failed to checkout ${baseBranch}: ${coResult.stderr}`);
|
|
14557
14665
|
process.exit(1);
|
|
14558
14666
|
}
|
|
14559
|
-
info(`Squash merging ${
|
|
14667
|
+
info(`Squash merging ${import_picocolors19.default.bold(featureBranch)} into ${import_picocolors19.default.bold(baseBranch)}...`);
|
|
14560
14668
|
const mergeResult = await mergeSquash(featureBranch);
|
|
14561
14669
|
if (mergeResult.exitCode !== 0) {
|
|
14562
14670
|
error(`Squash merge failed: ${mergeResult.stderr}`);
|
|
@@ -14576,7 +14684,7 @@ async function performSquashMerge(origin, baseBranch, featureBranch, options) {
|
|
|
14576
14684
|
message = aiMsg;
|
|
14577
14685
|
spinner.success("AI commit message generated.");
|
|
14578
14686
|
console.log(`
|
|
14579
|
-
${
|
|
14687
|
+
${import_picocolors19.default.dim("AI suggestion:")} ${import_picocolors19.default.bold(import_picocolors19.default.cyan(message))}`);
|
|
14580
14688
|
break;
|
|
14581
14689
|
}
|
|
14582
14690
|
spinner.fail("AI did not return a commit message.");
|
|
@@ -14616,7 +14724,7 @@ async function performSquashMerge(origin, baseBranch, featureBranch, options) {
|
|
|
14616
14724
|
message = regen;
|
|
14617
14725
|
spinner.success("Commit message regenerated.");
|
|
14618
14726
|
console.log(`
|
|
14619
|
-
${
|
|
14727
|
+
${import_picocolors19.default.dim("AI suggestion:")} ${import_picocolors19.default.bold(import_picocolors19.default.cyan(regen))}`);
|
|
14620
14728
|
} else {
|
|
14621
14729
|
spinner.fail("Regeneration failed.");
|
|
14622
14730
|
}
|
|
@@ -14632,13 +14740,13 @@ async function performSquashMerge(origin, baseBranch, featureBranch, options) {
|
|
|
14632
14740
|
error(`Commit failed: ${commitResult.stderr}`);
|
|
14633
14741
|
process.exit(1);
|
|
14634
14742
|
}
|
|
14635
|
-
info(`Pushing ${
|
|
14743
|
+
info(`Pushing ${import_picocolors19.default.bold(baseBranch)} to ${origin}...`);
|
|
14636
14744
|
const pushResult = await pushBranch(origin, baseBranch);
|
|
14637
14745
|
if (pushResult.exitCode !== 0) {
|
|
14638
14746
|
error(`Failed to push ${baseBranch}: ${pushResult.stderr}`);
|
|
14639
14747
|
process.exit(1);
|
|
14640
14748
|
}
|
|
14641
|
-
info(`Deleting local branch ${
|
|
14749
|
+
info(`Deleting local branch ${import_picocolors19.default.bold(featureBranch)}...`);
|
|
14642
14750
|
const delLocal = await forceDeleteBranch(featureBranch);
|
|
14643
14751
|
if (delLocal.exitCode !== 0) {
|
|
14644
14752
|
warn(`Could not delete local branch: ${delLocal.stderr.trim()}`);
|
|
@@ -14646,14 +14754,14 @@ async function performSquashMerge(origin, baseBranch, featureBranch, options) {
|
|
|
14646
14754
|
const remoteBranchRef = `${origin}/${featureBranch}`;
|
|
14647
14755
|
const remoteExists = await branchExists(remoteBranchRef);
|
|
14648
14756
|
if (remoteExists) {
|
|
14649
|
-
info(`Deleting remote branch ${
|
|
14757
|
+
info(`Deleting remote branch ${import_picocolors19.default.bold(featureBranch)}...`);
|
|
14650
14758
|
const delRemote = await deleteRemoteBranch(origin, featureBranch);
|
|
14651
14759
|
if (delRemote.exitCode !== 0) {
|
|
14652
14760
|
warn(`Could not delete remote branch: ${delRemote.stderr.trim()}`);
|
|
14653
14761
|
}
|
|
14654
14762
|
}
|
|
14655
|
-
success(`Squash merged ${
|
|
14656
|
-
info(`Run ${
|
|
14763
|
+
success(`Squash merged ${import_picocolors19.default.bold(featureBranch)} into ${import_picocolors19.default.bold(baseBranch)} and pushed.`);
|
|
14764
|
+
info(`Run ${import_picocolors19.default.bold("contrib start")} to begin a new feature.`, "");
|
|
14657
14765
|
}
|
|
14658
14766
|
var submit_default = defineCommand({
|
|
14659
14767
|
meta: {
|
|
@@ -14710,7 +14818,7 @@ var submit_default = defineCommand({
|
|
|
14710
14818
|
}
|
|
14711
14819
|
if (protectedBranches.includes(currentBranch)) {
|
|
14712
14820
|
await projectHeading("submit", "\uD83D\uDE80");
|
|
14713
|
-
warn(`You're on ${
|
|
14821
|
+
warn(`You're on ${import_picocolors19.default.bold(currentBranch)}, which is a protected branch. PRs should come from feature branches.`);
|
|
14714
14822
|
await fetchAll();
|
|
14715
14823
|
const remoteRef = `${origin}/${currentBranch}`;
|
|
14716
14824
|
const localWork = await hasLocalWork(origin, currentBranch);
|
|
@@ -14719,11 +14827,11 @@ var submit_default = defineCommand({
|
|
|
14719
14827
|
const hasAnything = hasCommits || dirty;
|
|
14720
14828
|
if (!hasAnything) {
|
|
14721
14829
|
error("No local changes or commits to move. Switch to a feature branch first.");
|
|
14722
|
-
info(` Run ${
|
|
14830
|
+
info(` Run ${import_picocolors19.default.bold("contrib start")} to create a new feature branch.`, "");
|
|
14723
14831
|
process.exit(1);
|
|
14724
14832
|
}
|
|
14725
14833
|
if (hasCommits) {
|
|
14726
|
-
info(`Found ${
|
|
14834
|
+
info(`Found ${import_picocolors19.default.bold(String(localWork.unpushedCommits))} unpushed commit${localWork.unpushedCommits !== 1 ? "s" : ""} on ${import_picocolors19.default.bold(currentBranch)}.`);
|
|
14727
14835
|
}
|
|
14728
14836
|
if (dirty) {
|
|
14729
14837
|
info("You also have uncommitted changes in the working tree.");
|
|
@@ -14753,12 +14861,12 @@ var submit_default = defineCommand({
|
|
|
14753
14861
|
error(`Failed to create branch: ${branchResult.stderr}`);
|
|
14754
14862
|
process.exit(1);
|
|
14755
14863
|
}
|
|
14756
|
-
success(`Created ${
|
|
14864
|
+
success(`Created ${import_picocolors19.default.bold(newBranchName)} with your changes.`);
|
|
14757
14865
|
await updateLocalBranch(currentBranch, remoteRef);
|
|
14758
|
-
info(`Reset ${
|
|
14866
|
+
info(`Reset ${import_picocolors19.default.bold(currentBranch)} back to ${import_picocolors19.default.bold(remoteRef)} \u2014 no damage done.`, "");
|
|
14759
14867
|
console.log();
|
|
14760
|
-
success(`You're now on ${
|
|
14761
|
-
info(`Run ${
|
|
14868
|
+
success(`You're now on ${import_picocolors19.default.bold(newBranchName)} with all your work intact.`);
|
|
14869
|
+
info(`Run ${import_picocolors19.default.bold("contrib submit")} again to push and create your PR.`, "");
|
|
14762
14870
|
return;
|
|
14763
14871
|
}
|
|
14764
14872
|
await projectHeading("submit", "\uD83D\uDE80");
|
|
@@ -14767,7 +14875,7 @@ var submit_default = defineCommand({
|
|
|
14767
14875
|
if (ghInstalled && ghAuthed) {
|
|
14768
14876
|
const mergedPR = await getMergedPRForBranch(currentBranch);
|
|
14769
14877
|
if (mergedPR) {
|
|
14770
|
-
warn(`PR #${mergedPR.number} (${
|
|
14878
|
+
warn(`PR #${mergedPR.number} (${import_picocolors19.default.bold(mergedPR.title)}) was already merged.`);
|
|
14771
14879
|
const localWork = await hasLocalWork(origin, currentBranch);
|
|
14772
14880
|
const hasWork = localWork.uncommitted || localWork.unpushedCommits > 0;
|
|
14773
14881
|
if (hasWork) {
|
|
@@ -14775,7 +14883,7 @@ var submit_default = defineCommand({
|
|
|
14775
14883
|
warn("You have uncommitted changes in your working tree.");
|
|
14776
14884
|
}
|
|
14777
14885
|
if (localWork.unpushedCommits > 0) {
|
|
14778
|
-
warn(`You have ${
|
|
14886
|
+
warn(`You have ${import_picocolors19.default.bold(String(localWork.unpushedCommits))} local commit${localWork.unpushedCommits !== 1 ? "s" : ""} not in the merged PR.`);
|
|
14779
14887
|
}
|
|
14780
14888
|
const SAVE_NEW_BRANCH = "Save changes to a new branch";
|
|
14781
14889
|
const DISCARD = "Discard all changes and clean up";
|
|
@@ -14802,10 +14910,10 @@ var submit_default = defineCommand({
|
|
|
14802
14910
|
error(`Failed to rename branch: ${renameResult.stderr}`);
|
|
14803
14911
|
process.exit(1);
|
|
14804
14912
|
}
|
|
14805
|
-
success(`Renamed ${
|
|
14913
|
+
success(`Renamed ${import_picocolors19.default.bold(currentBranch)} \u2192 ${import_picocolors19.default.bold(newBranchName)}`);
|
|
14806
14914
|
await unsetUpstream();
|
|
14807
14915
|
const syncSource2 = getSyncSource(config);
|
|
14808
|
-
info(`Syncing ${
|
|
14916
|
+
info(`Syncing ${import_picocolors19.default.bold(newBranchName)} with latest ${import_picocolors19.default.bold(baseBranch)}...`);
|
|
14809
14917
|
await fetchRemote(syncSource2.remote);
|
|
14810
14918
|
let rebaseResult;
|
|
14811
14919
|
if (staleUpstreamHash) {
|
|
@@ -14816,17 +14924,17 @@ var submit_default = defineCommand({
|
|
|
14816
14924
|
}
|
|
14817
14925
|
if (rebaseResult.exitCode !== 0) {
|
|
14818
14926
|
warn("Rebase encountered conflicts. Resolve them manually, then run:");
|
|
14819
|
-
info(` ${
|
|
14927
|
+
info(` ${import_picocolors19.default.bold("git rebase --continue")}`, "");
|
|
14820
14928
|
} else {
|
|
14821
|
-
success(`Rebased ${
|
|
14929
|
+
success(`Rebased ${import_picocolors19.default.bold(newBranchName)} onto ${import_picocolors19.default.bold(syncSource2.ref)}.`);
|
|
14822
14930
|
}
|
|
14823
|
-
info(`All your changes are preserved. Run ${
|
|
14931
|
+
info(`All your changes are preserved. Run ${import_picocolors19.default.bold("contrib submit")} when ready to create a new PR.`, "");
|
|
14824
14932
|
return;
|
|
14825
14933
|
}
|
|
14826
14934
|
warn("Discarding local changes...");
|
|
14827
14935
|
}
|
|
14828
14936
|
const syncSource = getSyncSource(config);
|
|
14829
|
-
info(`Switching to ${
|
|
14937
|
+
info(`Switching to ${import_picocolors19.default.bold(baseBranch)} and syncing...`);
|
|
14830
14938
|
await fetchRemote(syncSource.remote);
|
|
14831
14939
|
await resetHard("HEAD");
|
|
14832
14940
|
const coResult = await checkoutBranch(baseBranch);
|
|
@@ -14835,23 +14943,23 @@ var submit_default = defineCommand({
|
|
|
14835
14943
|
process.exit(1);
|
|
14836
14944
|
}
|
|
14837
14945
|
await updateLocalBranch(baseBranch, syncSource.ref);
|
|
14838
|
-
success(`Synced ${
|
|
14839
|
-
info(`Deleting stale branch ${
|
|
14946
|
+
success(`Synced ${import_picocolors19.default.bold(baseBranch)} with ${import_picocolors19.default.bold(syncSource.ref)}.`);
|
|
14947
|
+
info(`Deleting stale branch ${import_picocolors19.default.bold(currentBranch)}...`);
|
|
14840
14948
|
const delResult = await forceDeleteBranch(currentBranch);
|
|
14841
14949
|
if (delResult.exitCode === 0) {
|
|
14842
|
-
success(`Deleted ${
|
|
14950
|
+
success(`Deleted ${import_picocolors19.default.bold(currentBranch)}.`);
|
|
14843
14951
|
} else {
|
|
14844
14952
|
warn(`Could not delete branch: ${delResult.stderr.trim()}`);
|
|
14845
14953
|
}
|
|
14846
14954
|
console.log();
|
|
14847
|
-
info(`You're now on ${
|
|
14955
|
+
info(`You're now on ${import_picocolors19.default.bold(baseBranch)}. Run ${import_picocolors19.default.bold("contrib start")} to begin a new feature.`);
|
|
14848
14956
|
return;
|
|
14849
14957
|
}
|
|
14850
14958
|
}
|
|
14851
14959
|
if (ghInstalled && ghAuthed) {
|
|
14852
14960
|
const existingPR = await getPRForBranch(currentBranch);
|
|
14853
14961
|
if (existingPR) {
|
|
14854
|
-
info(`Pushing ${
|
|
14962
|
+
info(`Pushing ${import_picocolors19.default.bold(currentBranch)} to ${origin}...`);
|
|
14855
14963
|
const pushResult2 = await pushSetUpstream(origin, currentBranch);
|
|
14856
14964
|
if (pushResult2.exitCode !== 0) {
|
|
14857
14965
|
error(`Failed to push: ${pushResult2.stderr}`);
|
|
@@ -14862,8 +14970,8 @@ var submit_default = defineCommand({
|
|
|
14862
14970
|
}
|
|
14863
14971
|
process.exit(1);
|
|
14864
14972
|
}
|
|
14865
|
-
success(`Pushed changes to existing PR #${existingPR.number}: ${
|
|
14866
|
-
console.log(` ${
|
|
14973
|
+
success(`Pushed changes to existing PR #${existingPR.number}: ${import_picocolors19.default.bold(existingPR.title)}`);
|
|
14974
|
+
console.log(` ${import_picocolors19.default.cyan(existingPR.url)}`);
|
|
14867
14975
|
return;
|
|
14868
14976
|
}
|
|
14869
14977
|
}
|
|
@@ -14885,10 +14993,10 @@ var submit_default = defineCommand({
|
|
|
14885
14993
|
prBody = result.body;
|
|
14886
14994
|
spinner.success("PR description generated.");
|
|
14887
14995
|
console.log(`
|
|
14888
|
-
${
|
|
14996
|
+
${import_picocolors19.default.dim("AI title:")} ${import_picocolors19.default.bold(import_picocolors19.default.cyan(prTitle))}`);
|
|
14889
14997
|
console.log(`
|
|
14890
|
-
${
|
|
14891
|
-
console.log(
|
|
14998
|
+
${import_picocolors19.default.dim("AI body preview:")}`);
|
|
14999
|
+
console.log(import_picocolors19.default.dim(prBody.slice(0, 300) + (prBody.length > 300 ? "..." : "")));
|
|
14892
15000
|
} else {
|
|
14893
15001
|
spinner.fail("AI did not return a PR description.");
|
|
14894
15002
|
}
|
|
@@ -14999,7 +15107,7 @@ ${import_picocolors18.default.dim("AI body preview:")}`);
|
|
|
14999
15107
|
warn("Submit cancelled.");
|
|
15000
15108
|
return;
|
|
15001
15109
|
}
|
|
15002
|
-
info(`Pushing ${
|
|
15110
|
+
info(`Pushing ${import_picocolors19.default.bold(currentBranch)} to ${origin}...`);
|
|
15003
15111
|
const pushResult = await pushSetUpstream(origin, currentBranch);
|
|
15004
15112
|
if (pushResult.exitCode !== 0) {
|
|
15005
15113
|
error(`Failed to push: ${pushResult.stderr}`);
|
|
@@ -15018,7 +15126,7 @@ ${import_picocolors18.default.dim("AI body preview:")}`);
|
|
|
15018
15126
|
const prUrl = `https://github.com/${repoInfo.owner}/${repoInfo.repo}/compare/${baseBranch}...${currentBranch}?expand=1`;
|
|
15019
15127
|
console.log();
|
|
15020
15128
|
info("Create your PR manually:", "");
|
|
15021
|
-
console.log(` ${
|
|
15129
|
+
console.log(` ${import_picocolors19.default.cyan(prUrl)}`);
|
|
15022
15130
|
} else {
|
|
15023
15131
|
info("gh CLI not available. Create your PR manually on GitHub.", "");
|
|
15024
15132
|
}
|
|
@@ -15052,7 +15160,7 @@ ${import_picocolors18.default.dim("AI body preview:")}`);
|
|
|
15052
15160
|
});
|
|
15053
15161
|
|
|
15054
15162
|
// src/commands/switch.ts
|
|
15055
|
-
var
|
|
15163
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
15056
15164
|
var switch_default = defineCommand({
|
|
15057
15165
|
meta: {
|
|
15058
15166
|
name: "switch",
|
|
@@ -15084,11 +15192,11 @@ var switch_default = defineCommand({
|
|
|
15084
15192
|
const choices = localBranches.filter((b2) => b2.name !== currentBranch).map((b2) => {
|
|
15085
15193
|
const labels = [];
|
|
15086
15194
|
if (protectedBranches.includes(b2.name))
|
|
15087
|
-
labels.push(
|
|
15195
|
+
labels.push(import_picocolors20.default.red("protected"));
|
|
15088
15196
|
if (b2.upstream)
|
|
15089
|
-
labels.push(
|
|
15197
|
+
labels.push(import_picocolors20.default.dim(`\u2192 ${b2.upstream}`));
|
|
15090
15198
|
if (b2.gone)
|
|
15091
|
-
labels.push(
|
|
15199
|
+
labels.push(import_picocolors20.default.red("remote gone"));
|
|
15092
15200
|
const suffix = labels.length > 0 ? ` ${labels.join(" \xB7 ")}` : "";
|
|
15093
15201
|
return `${b2.name}${suffix}`;
|
|
15094
15202
|
});
|
|
@@ -15100,7 +15208,7 @@ var switch_default = defineCommand({
|
|
|
15100
15208
|
targetBranch = selected.split(/\s{2,}/)[0].trim();
|
|
15101
15209
|
}
|
|
15102
15210
|
if (targetBranch === currentBranch) {
|
|
15103
|
-
info(`Already on ${
|
|
15211
|
+
info(`Already on ${import_picocolors20.default.bold(targetBranch)}.`);
|
|
15104
15212
|
return;
|
|
15105
15213
|
}
|
|
15106
15214
|
if (await hasUncommittedChanges()) {
|
|
@@ -15119,7 +15227,7 @@ var switch_default = defineCommand({
|
|
|
15119
15227
|
const stashMsg = `contrib-save: auto-save from ${currentBranch}`;
|
|
15120
15228
|
try {
|
|
15121
15229
|
await exec("git", ["stash", "push", "-m", stashMsg]);
|
|
15122
|
-
info(`Saved changes: ${
|
|
15230
|
+
info(`Saved changes: ${import_picocolors20.default.dim(stashMsg)}`);
|
|
15123
15231
|
} catch {
|
|
15124
15232
|
error("Failed to save changes. Please commit or save manually.");
|
|
15125
15233
|
process.exit(1);
|
|
@@ -15135,9 +15243,9 @@ var switch_default = defineCommand({
|
|
|
15135
15243
|
}
|
|
15136
15244
|
process.exit(1);
|
|
15137
15245
|
}
|
|
15138
|
-
success(`Switched to ${
|
|
15139
|
-
info(`Your changes from ${
|
|
15140
|
-
info(`Use ${
|
|
15246
|
+
success(`Switched to ${import_picocolors20.default.bold(targetBranch)}`);
|
|
15247
|
+
info(`Your changes from ${import_picocolors20.default.bold(currentBranch ?? "previous branch")} are saved.`, "");
|
|
15248
|
+
info(`Use ${import_picocolors20.default.bold("contrib save --restore")} to bring them back.`, "");
|
|
15141
15249
|
return;
|
|
15142
15250
|
}
|
|
15143
15251
|
const result = await checkoutBranch(targetBranch);
|
|
@@ -15145,12 +15253,12 @@ var switch_default = defineCommand({
|
|
|
15145
15253
|
error(`Failed to switch to ${targetBranch}: ${result.stderr}`);
|
|
15146
15254
|
process.exit(1);
|
|
15147
15255
|
}
|
|
15148
|
-
success(`Switched to ${
|
|
15256
|
+
success(`Switched to ${import_picocolors20.default.bold(targetBranch)}`);
|
|
15149
15257
|
}
|
|
15150
15258
|
});
|
|
15151
15259
|
|
|
15152
15260
|
// src/commands/sync.ts
|
|
15153
|
-
var
|
|
15261
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
15154
15262
|
var sync_default = defineCommand({
|
|
15155
15263
|
meta: {
|
|
15156
15264
|
name: "sync",
|
|
@@ -15202,24 +15310,24 @@ var sync_default = defineCommand({
|
|
|
15202
15310
|
await fetchRemote(origin);
|
|
15203
15311
|
}
|
|
15204
15312
|
if (!await refExists(syncSource.ref)) {
|
|
15205
|
-
error(`Remote ref ${
|
|
15313
|
+
error(`Remote ref ${import_picocolors21.default.bold(syncSource.ref)} does not exist.`);
|
|
15206
15314
|
info("This can happen if the branch was renamed or deleted on the remote.", "");
|
|
15207
|
-
info(`Check your config: the base branch may need updating via ${
|
|
15315
|
+
info(`Check your config: the base branch may need updating via ${import_picocolors21.default.bold("contrib setup")}.`, "");
|
|
15208
15316
|
process.exit(1);
|
|
15209
15317
|
}
|
|
15210
15318
|
let allowMergeCommit = false;
|
|
15211
15319
|
const div = await getDivergence(baseBranch, syncSource.ref);
|
|
15212
15320
|
if (div.ahead > 0 || div.behind > 0) {
|
|
15213
|
-
info(`${
|
|
15321
|
+
info(`${import_picocolors21.default.bold(baseBranch)} is ${import_picocolors21.default.yellow(`${div.ahead} ahead`)} and ${import_picocolors21.default.red(`${div.behind} behind`)} ${syncSource.ref}`);
|
|
15214
15322
|
} else {
|
|
15215
|
-
info(`${
|
|
15323
|
+
info(`${import_picocolors21.default.bold(baseBranch)} is already in sync with ${syncSource.ref}`);
|
|
15216
15324
|
}
|
|
15217
15325
|
if (div.ahead > 0) {
|
|
15218
15326
|
const currentBranch = await getCurrentBranch();
|
|
15219
15327
|
const protectedBranches = getProtectedBranches(config);
|
|
15220
15328
|
const isOnProtected = currentBranch && protectedBranches.includes(currentBranch);
|
|
15221
15329
|
if (isOnProtected) {
|
|
15222
|
-
warn(`You have ${
|
|
15330
|
+
warn(`You have ${import_picocolors21.default.bold(String(div.ahead))} local commit${div.ahead !== 1 ? "s" : ""} on ${import_picocolors21.default.bold(baseBranch)} that aren't on the remote.`);
|
|
15223
15331
|
info("Pulling now could create a merge commit, which breaks clean history.");
|
|
15224
15332
|
console.log();
|
|
15225
15333
|
const MOVE_BRANCH = "Move my commits to a new feature branch, then sync";
|
|
@@ -15249,7 +15357,7 @@ var sync_default = defineCommand({
|
|
|
15249
15357
|
error(`Failed to create branch: ${branchResult.stderr}`);
|
|
15250
15358
|
process.exit(1);
|
|
15251
15359
|
}
|
|
15252
|
-
success(`Created ${
|
|
15360
|
+
success(`Created ${import_picocolors21.default.bold(newBranchName)} with your commits.`);
|
|
15253
15361
|
const coResult2 = await checkoutBranch(baseBranch);
|
|
15254
15362
|
if (coResult2.exitCode !== 0) {
|
|
15255
15363
|
error(`Failed to checkout ${baseBranch}: ${coResult2.stderr}`);
|
|
@@ -15257,11 +15365,11 @@ var sync_default = defineCommand({
|
|
|
15257
15365
|
}
|
|
15258
15366
|
const remoteRef = syncSource.ref;
|
|
15259
15367
|
await updateLocalBranch(baseBranch, remoteRef);
|
|
15260
|
-
success(`Reset ${
|
|
15261
|
-
success(`${
|
|
15368
|
+
success(`Reset ${import_picocolors21.default.bold(baseBranch)} to ${import_picocolors21.default.bold(remoteRef)}.`);
|
|
15369
|
+
success(`${import_picocolors21.default.bold(baseBranch)} is now in sync with ${syncSource.ref}`);
|
|
15262
15370
|
console.log();
|
|
15263
|
-
info(`Your commits are safe on ${
|
|
15264
|
-
info(`Run ${
|
|
15371
|
+
info(`Your commits are safe on ${import_picocolors21.default.bold(newBranchName)}.`, "");
|
|
15372
|
+
info(`Run ${import_picocolors21.default.bold(`git checkout ${newBranchName}`)} then ${import_picocolors21.default.bold("contrib update")} to rebase onto the synced ${import_picocolors21.default.bold(baseBranch)}.`, "");
|
|
15265
15373
|
return;
|
|
15266
15374
|
}
|
|
15267
15375
|
allowMergeCommit = true;
|
|
@@ -15269,7 +15377,7 @@ var sync_default = defineCommand({
|
|
|
15269
15377
|
}
|
|
15270
15378
|
}
|
|
15271
15379
|
if (!args.yes) {
|
|
15272
|
-
const ok = await confirmPrompt(`This will pull ${
|
|
15380
|
+
const ok = await confirmPrompt(`This will pull ${import_picocolors21.default.bold(syncSource.ref)} into local ${import_picocolors21.default.bold(baseBranch)}.`);
|
|
15273
15381
|
if (!ok)
|
|
15274
15382
|
process.exit(0);
|
|
15275
15383
|
}
|
|
@@ -15283,8 +15391,8 @@ var sync_default = defineCommand({
|
|
|
15283
15391
|
if (allowMergeCommit) {
|
|
15284
15392
|
error(`Pull failed: ${pullResult.stderr.trim()}`);
|
|
15285
15393
|
} else {
|
|
15286
|
-
error(`Fast-forward pull failed. Your local ${
|
|
15287
|
-
info(`Use ${
|
|
15394
|
+
error(`Fast-forward pull failed. Your local ${import_picocolors21.default.bold(baseBranch)} may have diverged.`);
|
|
15395
|
+
info(`Use ${import_picocolors21.default.bold("contrib sync")} again and choose "Move my commits to a new feature branch" to fix this.`, "");
|
|
15288
15396
|
}
|
|
15289
15397
|
process.exit(1);
|
|
15290
15398
|
}
|
|
@@ -15292,7 +15400,7 @@ var sync_default = defineCommand({
|
|
|
15292
15400
|
if (hasDevBranch(workflow) && role === "maintainer") {
|
|
15293
15401
|
const mainDiv = await getDivergence(config.mainBranch, `${origin}/${config.mainBranch}`);
|
|
15294
15402
|
if (mainDiv.behind > 0) {
|
|
15295
|
-
info(`Also syncing ${
|
|
15403
|
+
info(`Also syncing ${import_picocolors21.default.bold(config.mainBranch)}...`);
|
|
15296
15404
|
const mainCoResult = await checkoutBranch(config.mainBranch);
|
|
15297
15405
|
if (mainCoResult.exitCode === 0) {
|
|
15298
15406
|
const mainPullResult = await pullFastForwardOnly(origin, config.mainBranch);
|
|
@@ -15333,20 +15441,20 @@ var sync_default = defineCommand({
|
|
|
15333
15441
|
}
|
|
15334
15442
|
}
|
|
15335
15443
|
console.log();
|
|
15336
|
-
console.log(` ${
|
|
15444
|
+
console.log(` ${import_picocolors21.default.bold("\uD83D\uDD17 Branch Alignment")}`);
|
|
15337
15445
|
for (const [hash, names] of groups) {
|
|
15338
15446
|
const short = hash.slice(0, 7);
|
|
15339
|
-
const nameStr = names.map((n2) =>
|
|
15340
|
-
console.log(` ${
|
|
15447
|
+
const nameStr = names.map((n2) => import_picocolors21.default.bold(n2)).join(import_picocolors21.default.dim(" \xB7 "));
|
|
15448
|
+
console.log(` ${import_picocolors21.default.yellow(short)} ${import_picocolors21.default.dim("\u2500\u2500")} ${nameStr}`);
|
|
15341
15449
|
const subject = await getCommitSubject(hash);
|
|
15342
15450
|
if (subject) {
|
|
15343
|
-
console.log(` ${
|
|
15451
|
+
console.log(` ${import_picocolors21.default.dim(subject)}`);
|
|
15344
15452
|
}
|
|
15345
15453
|
}
|
|
15346
15454
|
if (groups.size === 1) {
|
|
15347
|
-
console.log(` ${
|
|
15455
|
+
console.log(` ${import_picocolors21.default.green("\u2713")} ${import_picocolors21.default.green("All branches aligned")} ${import_picocolors21.default.dim("\u2014 ready to start")}`);
|
|
15348
15456
|
} else {
|
|
15349
|
-
console.log(` ${
|
|
15457
|
+
console.log(` ${import_picocolors21.default.yellow("\u26A0")} ${import_picocolors21.default.yellow("Branches are not fully aligned")}`);
|
|
15350
15458
|
}
|
|
15351
15459
|
}
|
|
15352
15460
|
}
|
|
@@ -15355,7 +15463,7 @@ var sync_default = defineCommand({
|
|
|
15355
15463
|
|
|
15356
15464
|
// src/commands/update.ts
|
|
15357
15465
|
import { readFileSync as readFileSync6 } from "fs";
|
|
15358
|
-
var
|
|
15466
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
15359
15467
|
function hasStaleBranchWorkToPreserve(uniqueCommitsAheadOfBase, hasUncommittedChanges2) {
|
|
15360
15468
|
return hasUncommittedChanges2 || uniqueCommitsAheadOfBase > 0;
|
|
15361
15469
|
}
|
|
@@ -15396,7 +15504,7 @@ var update_default = defineCommand({
|
|
|
15396
15504
|
}
|
|
15397
15505
|
if (protectedBranches.includes(currentBranch)) {
|
|
15398
15506
|
await projectHeading("update", "\uD83D\uDD03");
|
|
15399
|
-
warn(`You're on ${
|
|
15507
|
+
warn(`You're on ${import_picocolors22.default.bold(currentBranch)}, which is a protected branch. Updates (rebase) apply to feature branches.`);
|
|
15400
15508
|
await fetchAll();
|
|
15401
15509
|
const { origin } = config;
|
|
15402
15510
|
const remoteRef = `${origin}/${currentBranch}`;
|
|
@@ -15405,12 +15513,12 @@ var update_default = defineCommand({
|
|
|
15405
15513
|
const hasCommits = localWork.unpushedCommits > 0;
|
|
15406
15514
|
const hasAnything = hasCommits || dirty;
|
|
15407
15515
|
if (!hasAnything) {
|
|
15408
|
-
info(`No local changes found on ${
|
|
15409
|
-
info(`Use ${
|
|
15516
|
+
info(`No local changes found on ${import_picocolors22.default.bold(currentBranch)}.`);
|
|
15517
|
+
info(`Use ${import_picocolors22.default.bold("contrib sync")} to sync protected branches, or ${import_picocolors22.default.bold("contrib start")} to create a feature branch.`);
|
|
15410
15518
|
process.exit(1);
|
|
15411
15519
|
}
|
|
15412
15520
|
if (hasCommits) {
|
|
15413
|
-
info(`Found ${
|
|
15521
|
+
info(`Found ${import_picocolors22.default.bold(String(localWork.unpushedCommits))} unpushed commit${localWork.unpushedCommits !== 1 ? "s" : ""} on ${import_picocolors22.default.bold(currentBranch)}.`);
|
|
15414
15522
|
}
|
|
15415
15523
|
if (dirty) {
|
|
15416
15524
|
info("You also have uncommitted changes in the working tree.");
|
|
@@ -15440,12 +15548,12 @@ var update_default = defineCommand({
|
|
|
15440
15548
|
error(`Failed to create branch: ${branchResult.stderr}`);
|
|
15441
15549
|
process.exit(1);
|
|
15442
15550
|
}
|
|
15443
|
-
success(`Created ${
|
|
15551
|
+
success(`Created ${import_picocolors22.default.bold(newBranchName)} with your changes.`);
|
|
15444
15552
|
await updateLocalBranch(currentBranch, remoteRef);
|
|
15445
|
-
info(`Reset ${
|
|
15553
|
+
info(`Reset ${import_picocolors22.default.bold(currentBranch)} back to ${import_picocolors22.default.bold(remoteRef)} \u2014 no damage done.`, "");
|
|
15446
15554
|
console.log();
|
|
15447
|
-
success(`You're now on ${
|
|
15448
|
-
info(`Run ${
|
|
15555
|
+
success(`You're now on ${import_picocolors22.default.bold(newBranchName)} with all your work intact.`);
|
|
15556
|
+
info(`Run ${import_picocolors22.default.bold("contrib update")} again to rebase onto latest ${import_picocolors22.default.bold(baseBranch)}.`, "");
|
|
15449
15557
|
return;
|
|
15450
15558
|
}
|
|
15451
15559
|
if (await hasUncommittedChanges()) {
|
|
@@ -15455,8 +15563,8 @@ var update_default = defineCommand({
|
|
|
15455
15563
|
await projectHeading("update", "\uD83D\uDD03");
|
|
15456
15564
|
const mergedPR = await getMergedPRForBranch(currentBranch);
|
|
15457
15565
|
if (mergedPR) {
|
|
15458
|
-
warn(`PR #${mergedPR.number} (${
|
|
15459
|
-
info(`Link: ${
|
|
15566
|
+
warn(`PR #${mergedPR.number} (${import_picocolors22.default.bold(mergedPR.title)}) has already been merged.`);
|
|
15567
|
+
info(`Link: ${import_picocolors22.default.underline(mergedPR.url)}`, "");
|
|
15460
15568
|
const uniqueCommitsAheadOfBase = await countCommitsAhead(currentBranch, syncSource.ref);
|
|
15461
15569
|
const dirty = await hasUncommittedChanges();
|
|
15462
15570
|
const hasWork = hasStaleBranchWorkToPreserve(uniqueCommitsAheadOfBase, dirty);
|
|
@@ -15465,12 +15573,12 @@ var update_default = defineCommand({
|
|
|
15465
15573
|
info("You have uncommitted local changes.");
|
|
15466
15574
|
}
|
|
15467
15575
|
if (uniqueCommitsAheadOfBase > 0) {
|
|
15468
|
-
info(`You have ${uniqueCommitsAheadOfBase} local commit(s) not in ${
|
|
15576
|
+
info(`You have ${uniqueCommitsAheadOfBase} local commit(s) not in ${import_picocolors22.default.bold(syncSource.ref)}.`);
|
|
15469
15577
|
}
|
|
15470
15578
|
const SAVE_NEW_BRANCH = "Save changes to a new branch";
|
|
15471
15579
|
const DISCARD = "Discard all changes and clean up";
|
|
15472
15580
|
const CANCEL = "Cancel";
|
|
15473
|
-
const action = await selectPrompt(`${
|
|
15581
|
+
const action = await selectPrompt(`${import_picocolors22.default.bold(currentBranch)} is stale but has local work. What would you like to do?`, [SAVE_NEW_BRANCH, DISCARD, CANCEL]);
|
|
15474
15582
|
if (action === CANCEL) {
|
|
15475
15583
|
info("No changes made. You are still on your current branch.");
|
|
15476
15584
|
return;
|
|
@@ -15492,7 +15600,7 @@ var update_default = defineCommand({
|
|
|
15492
15600
|
error(`Failed to rename branch: ${renameResult.stderr}`);
|
|
15493
15601
|
process.exit(1);
|
|
15494
15602
|
}
|
|
15495
|
-
success(`Renamed ${
|
|
15603
|
+
success(`Renamed ${import_picocolors22.default.bold(currentBranch)} \u2192 ${import_picocolors22.default.bold(newBranchName)}`);
|
|
15496
15604
|
await unsetUpstream();
|
|
15497
15605
|
await fetchRemote(syncSource.remote);
|
|
15498
15606
|
let rebaseResult2;
|
|
@@ -15504,11 +15612,11 @@ var update_default = defineCommand({
|
|
|
15504
15612
|
}
|
|
15505
15613
|
if (rebaseResult2.exitCode !== 0) {
|
|
15506
15614
|
warn("Rebase encountered conflicts. Resolve them manually, then run:");
|
|
15507
|
-
info(` ${
|
|
15615
|
+
info(` ${import_picocolors22.default.bold("git rebase --continue")}`, "");
|
|
15508
15616
|
} else {
|
|
15509
|
-
success(`Rebased ${
|
|
15617
|
+
success(`Rebased ${import_picocolors22.default.bold(newBranchName)} onto ${import_picocolors22.default.bold(syncSource.ref)}.`);
|
|
15510
15618
|
}
|
|
15511
|
-
info(`All your changes are preserved. Run ${
|
|
15619
|
+
info(`All your changes are preserved. Run ${import_picocolors22.default.bold("contrib submit")} when ready to create a new PR.`, "");
|
|
15512
15620
|
return;
|
|
15513
15621
|
}
|
|
15514
15622
|
warn("Discarding local changes...");
|
|
@@ -15527,24 +15635,24 @@ var update_default = defineCommand({
|
|
|
15527
15635
|
process.exit(1);
|
|
15528
15636
|
}
|
|
15529
15637
|
await updateLocalBranch(baseBranch, syncSource.ref);
|
|
15530
|
-
success(`Synced ${
|
|
15531
|
-
info(`Deleting stale branch ${
|
|
15638
|
+
success(`Synced ${import_picocolors22.default.bold(baseBranch)} with ${import_picocolors22.default.bold(syncSource.ref)}.`);
|
|
15639
|
+
info(`Deleting stale branch ${import_picocolors22.default.bold(currentBranch)}...`);
|
|
15532
15640
|
await forceDeleteBranch(currentBranch);
|
|
15533
|
-
success(`Deleted ${
|
|
15534
|
-
info(`Run ${
|
|
15641
|
+
success(`Deleted ${import_picocolors22.default.bold(currentBranch)}.`);
|
|
15642
|
+
info(`Run ${import_picocolors22.default.bold("contrib start")} to begin a new feature branch.`, "");
|
|
15535
15643
|
return;
|
|
15536
15644
|
}
|
|
15537
|
-
info(`Updating ${
|
|
15645
|
+
info(`Updating ${import_picocolors22.default.bold(currentBranch)} with latest ${import_picocolors22.default.bold(baseBranch)}...`);
|
|
15538
15646
|
await fetchRemote(syncSource.remote);
|
|
15539
15647
|
if (!await refExists(syncSource.ref)) {
|
|
15540
|
-
error(`Remote ref ${
|
|
15648
|
+
error(`Remote ref ${import_picocolors22.default.bold(syncSource.ref)} does not exist.`);
|
|
15541
15649
|
error("Run `git fetch --all` and verify your remote configuration.");
|
|
15542
15650
|
process.exit(1);
|
|
15543
15651
|
}
|
|
15544
15652
|
await updateLocalBranch(baseBranch, syncSource.ref);
|
|
15545
15653
|
const rebaseStrategy = await determineRebaseStrategy(currentBranch, syncSource.ref);
|
|
15546
15654
|
if (rebaseStrategy.strategy === "onto" && rebaseStrategy.ontoOldBase) {
|
|
15547
|
-
info(
|
|
15655
|
+
info(import_picocolors22.default.dim(`Using --onto rebase (branch was based on a different ref)`));
|
|
15548
15656
|
}
|
|
15549
15657
|
const rebaseResult = rebaseStrategy.strategy === "onto" && rebaseStrategy.ontoOldBase ? await rebaseOnto(syncSource.ref, rebaseStrategy.ontoOldBase) : await rebase(syncSource.ref);
|
|
15550
15658
|
if (rebaseResult.exitCode !== 0) {
|
|
@@ -15575,10 +15683,10 @@ ${content.slice(0, 2000)}
|
|
|
15575
15683
|
if (suggestion) {
|
|
15576
15684
|
spinner.success("AI conflict guidance ready.");
|
|
15577
15685
|
console.log(`
|
|
15578
|
-
${
|
|
15579
|
-
console.log(
|
|
15686
|
+
${import_picocolors22.default.bold("\uD83D\uDCA1 AI Conflict Resolution Guidance:")}`);
|
|
15687
|
+
console.log(import_picocolors22.default.dim("\u2500".repeat(60)));
|
|
15580
15688
|
console.log(suggestion);
|
|
15581
|
-
console.log(
|
|
15689
|
+
console.log(import_picocolors22.default.dim("\u2500".repeat(60)));
|
|
15582
15690
|
console.log();
|
|
15583
15691
|
} else {
|
|
15584
15692
|
spinner.fail("AI could not analyze the conflicts.");
|
|
@@ -15586,21 +15694,21 @@ ${import_picocolors21.default.bold("\uD83D\uDCA1 AI Conflict Resolution Guidance
|
|
|
15586
15694
|
}
|
|
15587
15695
|
}
|
|
15588
15696
|
}
|
|
15589
|
-
console.log(
|
|
15697
|
+
console.log(import_picocolors22.default.bold("To resolve:"));
|
|
15590
15698
|
console.log(` 1. Fix conflicts in the affected files`);
|
|
15591
|
-
console.log(` 2. ${
|
|
15592
|
-
console.log(` 3. ${
|
|
15699
|
+
console.log(` 2. ${import_picocolors22.default.cyan("git add <resolved-files>")}`);
|
|
15700
|
+
console.log(` 3. ${import_picocolors22.default.cyan("git rebase --continue")}`);
|
|
15593
15701
|
console.log();
|
|
15594
|
-
console.log(` Or abort: ${
|
|
15702
|
+
console.log(` Or abort: ${import_picocolors22.default.cyan("git rebase --abort")}`);
|
|
15595
15703
|
process.exit(1);
|
|
15596
15704
|
}
|
|
15597
|
-
success(`${
|
|
15705
|
+
success(`${import_picocolors22.default.bold(currentBranch)} has been rebased onto latest ${import_picocolors22.default.bold(baseBranch)}`);
|
|
15598
15706
|
}
|
|
15599
15707
|
});
|
|
15600
15708
|
|
|
15601
15709
|
// src/commands/validate.ts
|
|
15602
15710
|
import { readFileSync as readFileSync7 } from "fs";
|
|
15603
|
-
var
|
|
15711
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
15604
15712
|
var validate_default = defineCommand({
|
|
15605
15713
|
meta: {
|
|
15606
15714
|
name: "validate",
|
|
@@ -15640,1402 +15748,14 @@ var validate_default = defineCommand({
|
|
|
15640
15748
|
}
|
|
15641
15749
|
const errors = getValidationError(convention);
|
|
15642
15750
|
for (const line of errors) {
|
|
15643
|
-
console.error(
|
|
15751
|
+
console.error(import_picocolors23.default.red(` \u2717 ${line}`));
|
|
15644
15752
|
}
|
|
15645
15753
|
process.exit(1);
|
|
15646
15754
|
}
|
|
15647
15755
|
});
|
|
15648
15756
|
|
|
15649
|
-
// node_modules/figlet/dist/node-figlet.mjs
|
|
15650
|
-
import * as fs2 from "fs";
|
|
15651
|
-
import * as path2 from "path";
|
|
15652
|
-
|
|
15653
|
-
// node_modules/figlet/dist/figlet-B0EdFl3_.js
|
|
15654
|
-
var LAYOUT = {
|
|
15655
|
-
FULL_WIDTH: 0,
|
|
15656
|
-
FITTING: 1,
|
|
15657
|
-
SMUSHING: 2,
|
|
15658
|
-
CONTROLLED_SMUSHING: 3
|
|
15659
|
-
};
|
|
15660
|
-
|
|
15661
|
-
class FigletFont {
|
|
15662
|
-
constructor() {
|
|
15663
|
-
this.comment = "";
|
|
15664
|
-
this.numChars = 0;
|
|
15665
|
-
this.options = {};
|
|
15666
|
-
}
|
|
15667
|
-
}
|
|
15668
|
-
var fontList = [
|
|
15669
|
-
"1Row",
|
|
15670
|
-
"3-D",
|
|
15671
|
-
"3D Diagonal",
|
|
15672
|
-
"3D-ASCII",
|
|
15673
|
-
"3x5",
|
|
15674
|
-
"4Max",
|
|
15675
|
-
"5 Line Oblique",
|
|
15676
|
-
"AMC 3 Line",
|
|
15677
|
-
"AMC 3 Liv1",
|
|
15678
|
-
"AMC AAA01",
|
|
15679
|
-
"AMC Neko",
|
|
15680
|
-
"AMC Razor",
|
|
15681
|
-
"AMC Razor2",
|
|
15682
|
-
"AMC Slash",
|
|
15683
|
-
"AMC Slider",
|
|
15684
|
-
"AMC Thin",
|
|
15685
|
-
"AMC Tubes",
|
|
15686
|
-
"AMC Untitled",
|
|
15687
|
-
"ANSI Compact",
|
|
15688
|
-
"ANSI Regular",
|
|
15689
|
-
"ANSI Shadow",
|
|
15690
|
-
"ASCII 12",
|
|
15691
|
-
"ASCII 9",
|
|
15692
|
-
"ASCII New Roman",
|
|
15693
|
-
"Acrobatic",
|
|
15694
|
-
"Alligator",
|
|
15695
|
-
"Alligator2",
|
|
15696
|
-
"Alpha",
|
|
15697
|
-
"Alphabet",
|
|
15698
|
-
"Arrows",
|
|
15699
|
-
"Avatar",
|
|
15700
|
-
"B1FF",
|
|
15701
|
-
"Babyface Lame",
|
|
15702
|
-
"Babyface Leet",
|
|
15703
|
-
"Banner",
|
|
15704
|
-
"Banner3-D",
|
|
15705
|
-
"Banner3",
|
|
15706
|
-
"Banner4",
|
|
15707
|
-
"Barbwire",
|
|
15708
|
-
"Basic",
|
|
15709
|
-
"Bear",
|
|
15710
|
-
"Bell",
|
|
15711
|
-
"Benjamin",
|
|
15712
|
-
"Big ASCII 12",
|
|
15713
|
-
"Big ASCII 9",
|
|
15714
|
-
"Big Chief",
|
|
15715
|
-
"Big Money-ne",
|
|
15716
|
-
"Big Money-nw",
|
|
15717
|
-
"Big Money-se",
|
|
15718
|
-
"Big Money-sw",
|
|
15719
|
-
"Big Mono 12",
|
|
15720
|
-
"Big Mono 9",
|
|
15721
|
-
"Big",
|
|
15722
|
-
"Bigfig",
|
|
15723
|
-
"Binary",
|
|
15724
|
-
"Block",
|
|
15725
|
-
"Blocks",
|
|
15726
|
-
"Bloody",
|
|
15727
|
-
"BlurVision ASCII",
|
|
15728
|
-
"Bolger",
|
|
15729
|
-
"Braced",
|
|
15730
|
-
"Bright",
|
|
15731
|
-
"Broadway KB",
|
|
15732
|
-
"Broadway",
|
|
15733
|
-
"Bubble",
|
|
15734
|
-
"Bulbhead",
|
|
15735
|
-
"Caligraphy",
|
|
15736
|
-
"Caligraphy2",
|
|
15737
|
-
"Calvin S",
|
|
15738
|
-
"Cards",
|
|
15739
|
-
"Catwalk",
|
|
15740
|
-
"Chiseled",
|
|
15741
|
-
"Chunky",
|
|
15742
|
-
"Circle",
|
|
15743
|
-
"Classy",
|
|
15744
|
-
"Coder Mini",
|
|
15745
|
-
"Coinstak",
|
|
15746
|
-
"Cola",
|
|
15747
|
-
"Colossal",
|
|
15748
|
-
"Computer",
|
|
15749
|
-
"Contessa",
|
|
15750
|
-
"Contrast",
|
|
15751
|
-
"Cosmike",
|
|
15752
|
-
"Cosmike2",
|
|
15753
|
-
"Crawford",
|
|
15754
|
-
"Crawford2",
|
|
15755
|
-
"Crazy",
|
|
15756
|
-
"Cricket",
|
|
15757
|
-
"Cursive",
|
|
15758
|
-
"Cyberlarge",
|
|
15759
|
-
"Cybermedium",
|
|
15760
|
-
"Cybersmall",
|
|
15761
|
-
"Cygnet",
|
|
15762
|
-
"DANC4",
|
|
15763
|
-
"DOS Rebel",
|
|
15764
|
-
"DWhistled",
|
|
15765
|
-
"Dancing Font",
|
|
15766
|
-
"Decimal",
|
|
15767
|
-
"Def Leppard",
|
|
15768
|
-
"Delta Corps Priest 1",
|
|
15769
|
-
"DiamFont",
|
|
15770
|
-
"Diamond",
|
|
15771
|
-
"Diet Cola",
|
|
15772
|
-
"Digital",
|
|
15773
|
-
"Doh",
|
|
15774
|
-
"Doom",
|
|
15775
|
-
"Dot Matrix",
|
|
15776
|
-
"Double Shorts",
|
|
15777
|
-
"Double",
|
|
15778
|
-
"Dr Pepper",
|
|
15779
|
-
"Efti Chess",
|
|
15780
|
-
"Efti Font",
|
|
15781
|
-
"Efti Italic",
|
|
15782
|
-
"Efti Piti",
|
|
15783
|
-
"Efti Robot",
|
|
15784
|
-
"Efti Wall",
|
|
15785
|
-
"Efti Water",
|
|
15786
|
-
"Electronic",
|
|
15787
|
-
"Elite",
|
|
15788
|
-
"Emboss 2",
|
|
15789
|
-
"Emboss",
|
|
15790
|
-
"Epic",
|
|
15791
|
-
"Fender",
|
|
15792
|
-
"Filter",
|
|
15793
|
-
"Fire Font-k",
|
|
15794
|
-
"Fire Font-s",
|
|
15795
|
-
"Flipped",
|
|
15796
|
-
"Flower Power",
|
|
15797
|
-
"Font Font",
|
|
15798
|
-
"Four Tops",
|
|
15799
|
-
"Fraktur",
|
|
15800
|
-
"Fun Face",
|
|
15801
|
-
"Fun Faces",
|
|
15802
|
-
"Future",
|
|
15803
|
-
"Fuzzy",
|
|
15804
|
-
"Georgi16",
|
|
15805
|
-
"Georgia11",
|
|
15806
|
-
"Ghost",
|
|
15807
|
-
"Ghoulish",
|
|
15808
|
-
"Glenyn",
|
|
15809
|
-
"Goofy",
|
|
15810
|
-
"Gothic",
|
|
15811
|
-
"Graceful",
|
|
15812
|
-
"Gradient",
|
|
15813
|
-
"Graffiti",
|
|
15814
|
-
"Greek",
|
|
15815
|
-
"Heart Left",
|
|
15816
|
-
"Heart Right",
|
|
15817
|
-
"Henry 3D",
|
|
15818
|
-
"Hex",
|
|
15819
|
-
"Hieroglyphs",
|
|
15820
|
-
"Hollywood",
|
|
15821
|
-
"Horizontal Left",
|
|
15822
|
-
"Horizontal Right",
|
|
15823
|
-
"ICL-1900",
|
|
15824
|
-
"Impossible",
|
|
15825
|
-
"Invita",
|
|
15826
|
-
"Isometric1",
|
|
15827
|
-
"Isometric2",
|
|
15828
|
-
"Isometric3",
|
|
15829
|
-
"Isometric4",
|
|
15830
|
-
"Italic",
|
|
15831
|
-
"Ivrit",
|
|
15832
|
-
"JS Block Letters",
|
|
15833
|
-
"JS Bracket Letters",
|
|
15834
|
-
"JS Capital Curves",
|
|
15835
|
-
"JS Cursive",
|
|
15836
|
-
"JS Stick Letters",
|
|
15837
|
-
"Jacky",
|
|
15838
|
-
"Jazmine",
|
|
15839
|
-
"Jerusalem",
|
|
15840
|
-
"Katakana",
|
|
15841
|
-
"Kban",
|
|
15842
|
-
"Keyboard",
|
|
15843
|
-
"Knob",
|
|
15844
|
-
"Konto Slant",
|
|
15845
|
-
"Konto",
|
|
15846
|
-
"LCD",
|
|
15847
|
-
"Larry 3D 2",
|
|
15848
|
-
"Larry 3D",
|
|
15849
|
-
"Lean",
|
|
15850
|
-
"Letter",
|
|
15851
|
-
"Letters",
|
|
15852
|
-
"Lil Devil",
|
|
15853
|
-
"Line Blocks",
|
|
15854
|
-
"Linux",
|
|
15855
|
-
"Lockergnome",
|
|
15856
|
-
"Madrid",
|
|
15857
|
-
"Marquee",
|
|
15858
|
-
"Maxfour",
|
|
15859
|
-
"Merlin1",
|
|
15860
|
-
"Merlin2",
|
|
15861
|
-
"Mike",
|
|
15862
|
-
"Mini",
|
|
15863
|
-
"Mirror",
|
|
15864
|
-
"Mnemonic",
|
|
15865
|
-
"Modular",
|
|
15866
|
-
"Mono 12",
|
|
15867
|
-
"Mono 9",
|
|
15868
|
-
"Morse",
|
|
15869
|
-
"Morse2",
|
|
15870
|
-
"Moscow",
|
|
15871
|
-
"Mshebrew210",
|
|
15872
|
-
"Muzzle",
|
|
15873
|
-
"NScript",
|
|
15874
|
-
"NT Greek",
|
|
15875
|
-
"NV Script",
|
|
15876
|
-
"Nancyj-Fancy",
|
|
15877
|
-
"Nancyj-Improved",
|
|
15878
|
-
"Nancyj-Underlined",
|
|
15879
|
-
"Nancyj",
|
|
15880
|
-
"Nipples",
|
|
15881
|
-
"O8",
|
|
15882
|
-
"OS2",
|
|
15883
|
-
"Octal",
|
|
15884
|
-
"Ogre",
|
|
15885
|
-
"Old Banner",
|
|
15886
|
-
"Pagga",
|
|
15887
|
-
"Patorjk's Cheese",
|
|
15888
|
-
"Patorjk-HeX",
|
|
15889
|
-
"Pawp",
|
|
15890
|
-
"Peaks Slant",
|
|
15891
|
-
"Peaks",
|
|
15892
|
-
"Pebbles",
|
|
15893
|
-
"Pepper",
|
|
15894
|
-
"Poison",
|
|
15895
|
-
"Puffy",
|
|
15896
|
-
"Puzzle",
|
|
15897
|
-
"Pyramid",
|
|
15898
|
-
"Rammstein",
|
|
15899
|
-
"Rebel",
|
|
15900
|
-
"Rectangles",
|
|
15901
|
-
"Red Phoenix",
|
|
15902
|
-
"Relief",
|
|
15903
|
-
"Relief2",
|
|
15904
|
-
"Reverse",
|
|
15905
|
-
"Roman",
|
|
15906
|
-
"Rot13",
|
|
15907
|
-
"Rotated",
|
|
15908
|
-
"Rounded",
|
|
15909
|
-
"Rowan Cap",
|
|
15910
|
-
"Rozzo",
|
|
15911
|
-
"RubiFont",
|
|
15912
|
-
"Runic",
|
|
15913
|
-
"Runyc",
|
|
15914
|
-
"S Blood",
|
|
15915
|
-
"SL Script",
|
|
15916
|
-
"Santa Clara",
|
|
15917
|
-
"Script",
|
|
15918
|
-
"Serifcap",
|
|
15919
|
-
"Shaded Blocky",
|
|
15920
|
-
"Shadow",
|
|
15921
|
-
"Shimrod",
|
|
15922
|
-
"Short",
|
|
15923
|
-
"Slant Relief",
|
|
15924
|
-
"Slant",
|
|
15925
|
-
"Slide",
|
|
15926
|
-
"Small ASCII 12",
|
|
15927
|
-
"Small ASCII 9",
|
|
15928
|
-
"Small Block",
|
|
15929
|
-
"Small Braille",
|
|
15930
|
-
"Small Caps",
|
|
15931
|
-
"Small Isometric1",
|
|
15932
|
-
"Small Keyboard",
|
|
15933
|
-
"Small Mono 12",
|
|
15934
|
-
"Small Mono 9",
|
|
15935
|
-
"Small Poison",
|
|
15936
|
-
"Small Script",
|
|
15937
|
-
"Small Shadow",
|
|
15938
|
-
"Small Slant",
|
|
15939
|
-
"Small Tengwar",
|
|
15940
|
-
"Small",
|
|
15941
|
-
"Soft",
|
|
15942
|
-
"Speed",
|
|
15943
|
-
"Spliff",
|
|
15944
|
-
"Stacey",
|
|
15945
|
-
"Stampate",
|
|
15946
|
-
"Stampatello",
|
|
15947
|
-
"Standard",
|
|
15948
|
-
"Star Strips",
|
|
15949
|
-
"Star Wars",
|
|
15950
|
-
"Stellar",
|
|
15951
|
-
"Stforek",
|
|
15952
|
-
"Stick Letters",
|
|
15953
|
-
"Stop",
|
|
15954
|
-
"Straight",
|
|
15955
|
-
"Stronger Than All",
|
|
15956
|
-
"Sub-Zero",
|
|
15957
|
-
"Swamp Land",
|
|
15958
|
-
"Swan",
|
|
15959
|
-
"Sweet",
|
|
15960
|
-
"THIS",
|
|
15961
|
-
"Tanja",
|
|
15962
|
-
"Tengwar",
|
|
15963
|
-
"Term",
|
|
15964
|
-
"Terrace",
|
|
15965
|
-
"Test1",
|
|
15966
|
-
"The Edge",
|
|
15967
|
-
"Thick",
|
|
15968
|
-
"Thin",
|
|
15969
|
-
"Thorned",
|
|
15970
|
-
"Three Point",
|
|
15971
|
-
"Ticks Slant",
|
|
15972
|
-
"Ticks",
|
|
15973
|
-
"Tiles",
|
|
15974
|
-
"Tinker-Toy",
|
|
15975
|
-
"Tmplr",
|
|
15976
|
-
"Tombstone",
|
|
15977
|
-
"Train",
|
|
15978
|
-
"Trek",
|
|
15979
|
-
"Tsalagi",
|
|
15980
|
-
"Tubular",
|
|
15981
|
-
"Twisted",
|
|
15982
|
-
"Two Point",
|
|
15983
|
-
"USA Flag",
|
|
15984
|
-
"Univers",
|
|
15985
|
-
"Upside Down Text",
|
|
15986
|
-
"Varsity",
|
|
15987
|
-
"Wavescape",
|
|
15988
|
-
"Wavy",
|
|
15989
|
-
"Weird",
|
|
15990
|
-
"Wet Letter",
|
|
15991
|
-
"Whimsy",
|
|
15992
|
-
"WideTerm",
|
|
15993
|
-
"Wow",
|
|
15994
|
-
"miniwi"
|
|
15995
|
-
];
|
|
15996
|
-
var renamedFonts = {
|
|
15997
|
-
"ANSI-Compact": "ANSI Compact"
|
|
15998
|
-
};
|
|
15999
|
-
var getFontName = (name) => {
|
|
16000
|
-
return renamedFonts[name] ? renamedFonts[name] : name;
|
|
16001
|
-
};
|
|
16002
|
-
function escapeRegExpChar(char) {
|
|
16003
|
-
const specialChars = /[.*+?^${}()|[\]\\]/;
|
|
16004
|
-
return specialChars.test(char) ? "\\" + char : char;
|
|
16005
|
-
}
|
|
16006
|
-
var figlet = (() => {
|
|
16007
|
-
const { FULL_WIDTH = 0, FITTING, SMUSHING, CONTROLLED_SMUSHING } = LAYOUT;
|
|
16008
|
-
const figFonts = {};
|
|
16009
|
-
const figDefaults = {
|
|
16010
|
-
font: "Standard",
|
|
16011
|
-
fontPath: "./fonts",
|
|
16012
|
-
fetchFontIfMissing: true
|
|
16013
|
-
};
|
|
16014
|
-
function removeEndChar(line, lineNum, fontHeight) {
|
|
16015
|
-
const endChar = escapeRegExpChar(line.trim().slice(-1)) || "@";
|
|
16016
|
-
const endCharRegEx = lineNum === fontHeight - 1 ? new RegExp(endChar + endChar + "?\\s*$") : new RegExp(endChar + "\\s*$");
|
|
16017
|
-
return line.replace(endCharRegEx, "");
|
|
16018
|
-
}
|
|
16019
|
-
function getSmushingRules(oldLayout = -1, newLayout = null) {
|
|
16020
|
-
let rules = {};
|
|
16021
|
-
let val;
|
|
16022
|
-
let codes = [
|
|
16023
|
-
[16384, "vLayout", SMUSHING],
|
|
16024
|
-
[8192, "vLayout", FITTING],
|
|
16025
|
-
[4096, "vRule5", true],
|
|
16026
|
-
[2048, "vRule4", true],
|
|
16027
|
-
[1024, "vRule3", true],
|
|
16028
|
-
[512, "vRule2", true],
|
|
16029
|
-
[256, "vRule1", true],
|
|
16030
|
-
[128, "hLayout", SMUSHING],
|
|
16031
|
-
[64, "hLayout", FITTING],
|
|
16032
|
-
[32, "hRule6", true],
|
|
16033
|
-
[16, "hRule5", true],
|
|
16034
|
-
[8, "hRule4", true],
|
|
16035
|
-
[4, "hRule3", true],
|
|
16036
|
-
[2, "hRule2", true],
|
|
16037
|
-
[1, "hRule1", true]
|
|
16038
|
-
];
|
|
16039
|
-
val = newLayout !== null ? newLayout : oldLayout;
|
|
16040
|
-
for (const [code, rule, value] of codes) {
|
|
16041
|
-
if (val >= code) {
|
|
16042
|
-
val -= code;
|
|
16043
|
-
if (rules[rule] === undefined) {
|
|
16044
|
-
rules[rule] = value;
|
|
16045
|
-
}
|
|
16046
|
-
} else if (rule !== "vLayout" && rule !== "hLayout") {
|
|
16047
|
-
rules[rule] = false;
|
|
16048
|
-
}
|
|
16049
|
-
}
|
|
16050
|
-
if (typeof rules["hLayout"] === "undefined") {
|
|
16051
|
-
if (oldLayout === 0) {
|
|
16052
|
-
rules["hLayout"] = FITTING;
|
|
16053
|
-
} else if (oldLayout === -1) {
|
|
16054
|
-
rules["hLayout"] = FULL_WIDTH;
|
|
16055
|
-
} else {
|
|
16056
|
-
if (rules["hRule1"] || rules["hRule2"] || rules["hRule3"] || rules["hRule4"] || rules["hRule5"] || rules["hRule6"]) {
|
|
16057
|
-
rules["hLayout"] = CONTROLLED_SMUSHING;
|
|
16058
|
-
} else {
|
|
16059
|
-
rules["hLayout"] = SMUSHING;
|
|
16060
|
-
}
|
|
16061
|
-
}
|
|
16062
|
-
} else if (rules["hLayout"] === SMUSHING) {
|
|
16063
|
-
if (rules["hRule1"] || rules["hRule2"] || rules["hRule3"] || rules["hRule4"] || rules["hRule5"] || rules["hRule6"]) {
|
|
16064
|
-
rules["hLayout"] = CONTROLLED_SMUSHING;
|
|
16065
|
-
}
|
|
16066
|
-
}
|
|
16067
|
-
if (typeof rules["vLayout"] === "undefined") {
|
|
16068
|
-
if (rules["vRule1"] || rules["vRule2"] || rules["vRule3"] || rules["vRule4"] || rules["vRule5"]) {
|
|
16069
|
-
rules["vLayout"] = CONTROLLED_SMUSHING;
|
|
16070
|
-
} else {
|
|
16071
|
-
rules["vLayout"] = FULL_WIDTH;
|
|
16072
|
-
}
|
|
16073
|
-
} else if (rules["vLayout"] === SMUSHING) {
|
|
16074
|
-
if (rules["vRule1"] || rules["vRule2"] || rules["vRule3"] || rules["vRule4"] || rules["vRule5"]) {
|
|
16075
|
-
rules["vLayout"] = CONTROLLED_SMUSHING;
|
|
16076
|
-
}
|
|
16077
|
-
}
|
|
16078
|
-
return rules;
|
|
16079
|
-
}
|
|
16080
|
-
function hRule1_Smush(ch1, ch2, hardBlank = "") {
|
|
16081
|
-
if (ch1 === ch2 && ch1 !== hardBlank) {
|
|
16082
|
-
return ch1;
|
|
16083
|
-
}
|
|
16084
|
-
return false;
|
|
16085
|
-
}
|
|
16086
|
-
function hRule2_Smush(ch1, ch2) {
|
|
16087
|
-
let rule2Str = "|/\\[]{}()<>";
|
|
16088
|
-
if (ch1 === "_") {
|
|
16089
|
-
if (rule2Str.indexOf(ch2) !== -1) {
|
|
16090
|
-
return ch2;
|
|
16091
|
-
}
|
|
16092
|
-
} else if (ch2 === "_") {
|
|
16093
|
-
if (rule2Str.indexOf(ch1) !== -1) {
|
|
16094
|
-
return ch1;
|
|
16095
|
-
}
|
|
16096
|
-
}
|
|
16097
|
-
return false;
|
|
16098
|
-
}
|
|
16099
|
-
function hRule3_Smush(ch1, ch2) {
|
|
16100
|
-
let rule3Classes = "| /\\ [] {} () <>";
|
|
16101
|
-
let r3_pos1 = rule3Classes.indexOf(ch1);
|
|
16102
|
-
let r3_pos2 = rule3Classes.indexOf(ch2);
|
|
16103
|
-
if (r3_pos1 !== -1 && r3_pos2 !== -1) {
|
|
16104
|
-
if (r3_pos1 !== r3_pos2 && Math.abs(r3_pos1 - r3_pos2) !== 1) {
|
|
16105
|
-
const startPos = Math.max(r3_pos1, r3_pos2);
|
|
16106
|
-
const endPos = startPos + 1;
|
|
16107
|
-
return rule3Classes.substring(startPos, endPos);
|
|
16108
|
-
}
|
|
16109
|
-
}
|
|
16110
|
-
return false;
|
|
16111
|
-
}
|
|
16112
|
-
function hRule4_Smush(ch1, ch2) {
|
|
16113
|
-
let rule4Str = "[] {} ()";
|
|
16114
|
-
let r4_pos1 = rule4Str.indexOf(ch1);
|
|
16115
|
-
let r4_pos2 = rule4Str.indexOf(ch2);
|
|
16116
|
-
if (r4_pos1 !== -1 && r4_pos2 !== -1) {
|
|
16117
|
-
if (Math.abs(r4_pos1 - r4_pos2) <= 1) {
|
|
16118
|
-
return "|";
|
|
16119
|
-
}
|
|
16120
|
-
}
|
|
16121
|
-
return false;
|
|
16122
|
-
}
|
|
16123
|
-
function hRule5_Smush(ch1, ch2) {
|
|
16124
|
-
const patterns = {
|
|
16125
|
-
"/\\": "|",
|
|
16126
|
-
"\\/": "Y",
|
|
16127
|
-
"><": "X"
|
|
16128
|
-
};
|
|
16129
|
-
return patterns[ch1 + ch2] || false;
|
|
16130
|
-
}
|
|
16131
|
-
function hRule6_Smush(ch1, ch2, hardBlank = "") {
|
|
16132
|
-
if (ch1 === hardBlank && ch2 === hardBlank) {
|
|
16133
|
-
return hardBlank;
|
|
16134
|
-
}
|
|
16135
|
-
return false;
|
|
16136
|
-
}
|
|
16137
|
-
function vRule1_Smush(ch1, ch2) {
|
|
16138
|
-
if (ch1 === ch2) {
|
|
16139
|
-
return ch1;
|
|
16140
|
-
}
|
|
16141
|
-
return false;
|
|
16142
|
-
}
|
|
16143
|
-
function vRule2_Smush(ch1, ch2) {
|
|
16144
|
-
return hRule2_Smush(ch1, ch2);
|
|
16145
|
-
}
|
|
16146
|
-
function vRule3_Smush(ch1, ch2) {
|
|
16147
|
-
return hRule3_Smush(ch1, ch2);
|
|
16148
|
-
}
|
|
16149
|
-
function vRule4_Smush(ch1, ch2) {
|
|
16150
|
-
if (ch1 === "-" && ch2 === "_" || ch1 === "_" && ch2 === "-") {
|
|
16151
|
-
return "=";
|
|
16152
|
-
}
|
|
16153
|
-
return false;
|
|
16154
|
-
}
|
|
16155
|
-
function vRule5_Smush(ch1, ch2) {
|
|
16156
|
-
if (ch1 === "|" && ch2 === "|") {
|
|
16157
|
-
return "|";
|
|
16158
|
-
}
|
|
16159
|
-
return false;
|
|
16160
|
-
}
|
|
16161
|
-
function uni_Smush(ch1, ch2, hardBlank) {
|
|
16162
|
-
if (ch2 === " " || ch2 === "") {
|
|
16163
|
-
return ch1;
|
|
16164
|
-
} else if (ch2 === hardBlank && ch1 !== " ") {
|
|
16165
|
-
return ch1;
|
|
16166
|
-
} else {
|
|
16167
|
-
return ch2;
|
|
16168
|
-
}
|
|
16169
|
-
}
|
|
16170
|
-
function canVerticalSmush(txt1, txt2, opts) {
|
|
16171
|
-
if (opts.fittingRules && opts.fittingRules.vLayout === FULL_WIDTH) {
|
|
16172
|
-
return "invalid";
|
|
16173
|
-
}
|
|
16174
|
-
let ii, len = Math.min(txt1.length, txt2.length), ch1, ch2, endSmush = false, validSmush;
|
|
16175
|
-
if (len === 0) {
|
|
16176
|
-
return "invalid";
|
|
16177
|
-
}
|
|
16178
|
-
for (ii = 0;ii < len; ii++) {
|
|
16179
|
-
ch1 = txt1.substring(ii, ii + 1);
|
|
16180
|
-
ch2 = txt2.substring(ii, ii + 1);
|
|
16181
|
-
if (ch1 !== " " && ch2 !== " ") {
|
|
16182
|
-
if (opts.fittingRules && opts.fittingRules.vLayout === FITTING) {
|
|
16183
|
-
return "invalid";
|
|
16184
|
-
} else if (opts.fittingRules && opts.fittingRules.vLayout === SMUSHING) {
|
|
16185
|
-
return "end";
|
|
16186
|
-
} else {
|
|
16187
|
-
if (vRule5_Smush(ch1, ch2)) {
|
|
16188
|
-
endSmush = endSmush || false;
|
|
16189
|
-
continue;
|
|
16190
|
-
}
|
|
16191
|
-
validSmush = false;
|
|
16192
|
-
validSmush = opts.fittingRules && opts.fittingRules.vRule1 ? vRule1_Smush(ch1, ch2) : validSmush;
|
|
16193
|
-
validSmush = !validSmush && opts.fittingRules && opts.fittingRules.vRule2 ? vRule2_Smush(ch1, ch2) : validSmush;
|
|
16194
|
-
validSmush = !validSmush && opts.fittingRules && opts.fittingRules.vRule3 ? vRule3_Smush(ch1, ch2) : validSmush;
|
|
16195
|
-
validSmush = !validSmush && opts.fittingRules && opts.fittingRules.vRule4 ? vRule4_Smush(ch1, ch2) : validSmush;
|
|
16196
|
-
endSmush = true;
|
|
16197
|
-
if (!validSmush) {
|
|
16198
|
-
return "invalid";
|
|
16199
|
-
}
|
|
16200
|
-
}
|
|
16201
|
-
}
|
|
16202
|
-
}
|
|
16203
|
-
if (endSmush) {
|
|
16204
|
-
return "end";
|
|
16205
|
-
} else {
|
|
16206
|
-
return "valid";
|
|
16207
|
-
}
|
|
16208
|
-
}
|
|
16209
|
-
function getVerticalSmushDist(lines1, lines2, opts) {
|
|
16210
|
-
let maxDist = lines1.length;
|
|
16211
|
-
let len1 = lines1.length;
|
|
16212
|
-
let subLines1, subLines2, slen;
|
|
16213
|
-
let curDist = 1;
|
|
16214
|
-
let ii, ret, result;
|
|
16215
|
-
while (curDist <= maxDist) {
|
|
16216
|
-
subLines1 = lines1.slice(Math.max(0, len1 - curDist), len1);
|
|
16217
|
-
subLines2 = lines2.slice(0, Math.min(maxDist, curDist));
|
|
16218
|
-
slen = subLines2.length;
|
|
16219
|
-
result = "";
|
|
16220
|
-
for (ii = 0;ii < slen; ii++) {
|
|
16221
|
-
ret = canVerticalSmush(subLines1[ii], subLines2[ii], opts);
|
|
16222
|
-
if (ret === "end") {
|
|
16223
|
-
result = ret;
|
|
16224
|
-
} else if (ret === "invalid") {
|
|
16225
|
-
result = ret;
|
|
16226
|
-
break;
|
|
16227
|
-
} else {
|
|
16228
|
-
if (result === "") {
|
|
16229
|
-
result = "valid";
|
|
16230
|
-
}
|
|
16231
|
-
}
|
|
16232
|
-
}
|
|
16233
|
-
if (result === "invalid") {
|
|
16234
|
-
curDist--;
|
|
16235
|
-
break;
|
|
16236
|
-
}
|
|
16237
|
-
if (result === "end") {
|
|
16238
|
-
break;
|
|
16239
|
-
}
|
|
16240
|
-
if (result === "valid") {
|
|
16241
|
-
curDist++;
|
|
16242
|
-
}
|
|
16243
|
-
}
|
|
16244
|
-
return Math.min(maxDist, curDist);
|
|
16245
|
-
}
|
|
16246
|
-
function verticallySmushLines(line1, line2, opts) {
|
|
16247
|
-
let ii, len = Math.min(line1.length, line2.length);
|
|
16248
|
-
let ch1, ch2, result = "", validSmush;
|
|
16249
|
-
const fittingRules = opts.fittingRules || {};
|
|
16250
|
-
for (ii = 0;ii < len; ii++) {
|
|
16251
|
-
ch1 = line1.substring(ii, ii + 1);
|
|
16252
|
-
ch2 = line2.substring(ii, ii + 1);
|
|
16253
|
-
if (ch1 !== " " && ch2 !== " ") {
|
|
16254
|
-
if (fittingRules.vLayout === FITTING) {
|
|
16255
|
-
result += uni_Smush(ch1, ch2);
|
|
16256
|
-
} else if (fittingRules.vLayout === SMUSHING) {
|
|
16257
|
-
result += uni_Smush(ch1, ch2);
|
|
16258
|
-
} else {
|
|
16259
|
-
validSmush = false;
|
|
16260
|
-
validSmush = fittingRules.vRule5 ? vRule5_Smush(ch1, ch2) : validSmush;
|
|
16261
|
-
validSmush = !validSmush && fittingRules.vRule1 ? vRule1_Smush(ch1, ch2) : validSmush;
|
|
16262
|
-
validSmush = !validSmush && fittingRules.vRule2 ? vRule2_Smush(ch1, ch2) : validSmush;
|
|
16263
|
-
validSmush = !validSmush && fittingRules.vRule3 ? vRule3_Smush(ch1, ch2) : validSmush;
|
|
16264
|
-
validSmush = !validSmush && fittingRules.vRule4 ? vRule4_Smush(ch1, ch2) : validSmush;
|
|
16265
|
-
result += validSmush;
|
|
16266
|
-
}
|
|
16267
|
-
} else {
|
|
16268
|
-
result += uni_Smush(ch1, ch2);
|
|
16269
|
-
}
|
|
16270
|
-
}
|
|
16271
|
-
return result;
|
|
16272
|
-
}
|
|
16273
|
-
function verticalSmush(lines1, lines2, overlap, opts) {
|
|
16274
|
-
let len1 = lines1.length;
|
|
16275
|
-
let len2 = lines2.length;
|
|
16276
|
-
let piece1 = lines1.slice(0, Math.max(0, len1 - overlap));
|
|
16277
|
-
let piece2_1 = lines1.slice(Math.max(0, len1 - overlap), len1);
|
|
16278
|
-
let piece2_2 = lines2.slice(0, Math.min(overlap, len2));
|
|
16279
|
-
let ii, len, line, piece2 = [], piece3;
|
|
16280
|
-
len = piece2_1.length;
|
|
16281
|
-
for (ii = 0;ii < len; ii++) {
|
|
16282
|
-
if (ii >= len2) {
|
|
16283
|
-
line = piece2_1[ii];
|
|
16284
|
-
} else {
|
|
16285
|
-
line = verticallySmushLines(piece2_1[ii], piece2_2[ii], opts);
|
|
16286
|
-
}
|
|
16287
|
-
piece2.push(line);
|
|
16288
|
-
}
|
|
16289
|
-
piece3 = lines2.slice(Math.min(overlap, len2), len2);
|
|
16290
|
-
return [...piece1, ...piece2, ...piece3];
|
|
16291
|
-
}
|
|
16292
|
-
function padLines(lines, numSpaces) {
|
|
16293
|
-
const padding = " ".repeat(numSpaces);
|
|
16294
|
-
return lines.map((line) => line + padding);
|
|
16295
|
-
}
|
|
16296
|
-
function smushVerticalFigLines(output, lines, opts) {
|
|
16297
|
-
let len1 = output[0].length;
|
|
16298
|
-
let len2 = lines[0].length;
|
|
16299
|
-
let overlap;
|
|
16300
|
-
if (len1 > len2) {
|
|
16301
|
-
lines = padLines(lines, len1 - len2);
|
|
16302
|
-
} else if (len2 > len1) {
|
|
16303
|
-
output = padLines(output, len2 - len1);
|
|
16304
|
-
}
|
|
16305
|
-
overlap = getVerticalSmushDist(output, lines, opts);
|
|
16306
|
-
return verticalSmush(output, lines, overlap, opts);
|
|
16307
|
-
}
|
|
16308
|
-
function getHorizontalSmushLength(txt1, txt2, opts) {
|
|
16309
|
-
const fittingRules = opts.fittingRules || {};
|
|
16310
|
-
if (fittingRules.hLayout === FULL_WIDTH) {
|
|
16311
|
-
return 0;
|
|
16312
|
-
}
|
|
16313
|
-
let ii, len1 = txt1.length, len2 = txt2.length;
|
|
16314
|
-
let maxDist = len1;
|
|
16315
|
-
let curDist = 1;
|
|
16316
|
-
let breakAfter = false;
|
|
16317
|
-
let seg1, seg2, ch1, ch2;
|
|
16318
|
-
if (len1 === 0) {
|
|
16319
|
-
return 0;
|
|
16320
|
-
}
|
|
16321
|
-
distCal:
|
|
16322
|
-
while (curDist <= maxDist) {
|
|
16323
|
-
const seg1StartPos = len1 - curDist;
|
|
16324
|
-
seg1 = txt1.substring(seg1StartPos, seg1StartPos + curDist);
|
|
16325
|
-
seg2 = txt2.substring(0, Math.min(curDist, len2));
|
|
16326
|
-
for (ii = 0;ii < Math.min(curDist, len2); ii++) {
|
|
16327
|
-
ch1 = seg1.substring(ii, ii + 1);
|
|
16328
|
-
ch2 = seg2.substring(ii, ii + 1);
|
|
16329
|
-
if (ch1 !== " " && ch2 !== " ") {
|
|
16330
|
-
if (fittingRules.hLayout === FITTING) {
|
|
16331
|
-
curDist = curDist - 1;
|
|
16332
|
-
break distCal;
|
|
16333
|
-
} else if (fittingRules.hLayout === SMUSHING) {
|
|
16334
|
-
if (ch1 === opts.hardBlank || ch2 === opts.hardBlank) {
|
|
16335
|
-
curDist = curDist - 1;
|
|
16336
|
-
}
|
|
16337
|
-
break distCal;
|
|
16338
|
-
} else {
|
|
16339
|
-
breakAfter = true;
|
|
16340
|
-
const validSmush = fittingRules.hRule1 && hRule1_Smush(ch1, ch2, opts.hardBlank) || fittingRules.hRule2 && hRule2_Smush(ch1, ch2) || fittingRules.hRule3 && hRule3_Smush(ch1, ch2) || fittingRules.hRule4 && hRule4_Smush(ch1, ch2) || fittingRules.hRule5 && hRule5_Smush(ch1, ch2) || fittingRules.hRule6 && hRule6_Smush(ch1, ch2, opts.hardBlank);
|
|
16341
|
-
if (!validSmush) {
|
|
16342
|
-
curDist = curDist - 1;
|
|
16343
|
-
break distCal;
|
|
16344
|
-
}
|
|
16345
|
-
}
|
|
16346
|
-
}
|
|
16347
|
-
}
|
|
16348
|
-
if (breakAfter) {
|
|
16349
|
-
break;
|
|
16350
|
-
}
|
|
16351
|
-
curDist++;
|
|
16352
|
-
}
|
|
16353
|
-
return Math.min(maxDist, curDist);
|
|
16354
|
-
}
|
|
16355
|
-
function horizontalSmush(textBlock1, textBlock2, overlap, opts) {
|
|
16356
|
-
let ii, jj, outputFig = [], overlapStart, piece1, piece2, piece3, len1, len2, txt1, txt2;
|
|
16357
|
-
const fittingRules = opts.fittingRules || {};
|
|
16358
|
-
if (typeof opts.height !== "number") {
|
|
16359
|
-
throw new Error("height is not defined.");
|
|
16360
|
-
}
|
|
16361
|
-
for (ii = 0;ii < opts.height; ii++) {
|
|
16362
|
-
txt1 = textBlock1[ii];
|
|
16363
|
-
txt2 = textBlock2[ii];
|
|
16364
|
-
len1 = txt1.length;
|
|
16365
|
-
len2 = txt2.length;
|
|
16366
|
-
overlapStart = len1 - overlap;
|
|
16367
|
-
piece1 = txt1.slice(0, Math.max(0, overlapStart));
|
|
16368
|
-
piece2 = "";
|
|
16369
|
-
const seg1StartPos = Math.max(0, len1 - overlap);
|
|
16370
|
-
let seg1 = txt1.substring(seg1StartPos, seg1StartPos + overlap);
|
|
16371
|
-
let seg2 = txt2.substring(0, Math.min(overlap, len2));
|
|
16372
|
-
for (jj = 0;jj < overlap; jj++) {
|
|
16373
|
-
let ch1 = jj < len1 ? seg1.substring(jj, jj + 1) : " ";
|
|
16374
|
-
let ch2 = jj < len2 ? seg2.substring(jj, jj + 1) : " ";
|
|
16375
|
-
if (ch1 !== " " && ch2 !== " ") {
|
|
16376
|
-
if (fittingRules.hLayout === FITTING || fittingRules.hLayout === SMUSHING) {
|
|
16377
|
-
piece2 += uni_Smush(ch1, ch2, opts.hardBlank);
|
|
16378
|
-
} else {
|
|
16379
|
-
const nextCh = fittingRules.hRule1 && hRule1_Smush(ch1, ch2, opts.hardBlank) || fittingRules.hRule2 && hRule2_Smush(ch1, ch2) || fittingRules.hRule3 && hRule3_Smush(ch1, ch2) || fittingRules.hRule4 && hRule4_Smush(ch1, ch2) || fittingRules.hRule5 && hRule5_Smush(ch1, ch2) || fittingRules.hRule6 && hRule6_Smush(ch1, ch2, opts.hardBlank) || uni_Smush(ch1, ch2, opts.hardBlank);
|
|
16380
|
-
piece2 += nextCh;
|
|
16381
|
-
}
|
|
16382
|
-
} else {
|
|
16383
|
-
piece2 += uni_Smush(ch1, ch2, opts.hardBlank);
|
|
16384
|
-
}
|
|
16385
|
-
}
|
|
16386
|
-
if (overlap >= len2) {
|
|
16387
|
-
piece3 = "";
|
|
16388
|
-
} else {
|
|
16389
|
-
piece3 = txt2.substring(overlap, overlap + Math.max(0, len2 - overlap));
|
|
16390
|
-
}
|
|
16391
|
-
outputFig[ii] = piece1 + piece2 + piece3;
|
|
16392
|
-
}
|
|
16393
|
-
return outputFig;
|
|
16394
|
-
}
|
|
16395
|
-
function newFigChar(len) {
|
|
16396
|
-
return new Array(len).fill("");
|
|
16397
|
-
}
|
|
16398
|
-
const figLinesWidth = function(textLines) {
|
|
16399
|
-
return Math.max(...textLines.map((line) => line.length));
|
|
16400
|
-
};
|
|
16401
|
-
function joinFigArray(array, len, opts) {
|
|
16402
|
-
return array.reduce(function(acc, data) {
|
|
16403
|
-
return horizontalSmush(acc, data.fig, data.overlap || 0, opts);
|
|
16404
|
-
}, newFigChar(len));
|
|
16405
|
-
}
|
|
16406
|
-
function breakWord(figChars, len, opts) {
|
|
16407
|
-
for (let i2 = figChars.length - 1;i2 > 0; i2--) {
|
|
16408
|
-
const w2 = joinFigArray(figChars.slice(0, i2), len, opts);
|
|
16409
|
-
if (figLinesWidth(w2) <= opts.width) {
|
|
16410
|
-
return {
|
|
16411
|
-
outputFigText: w2,
|
|
16412
|
-
chars: figChars.slice(i2)
|
|
16413
|
-
};
|
|
16414
|
-
}
|
|
16415
|
-
}
|
|
16416
|
-
return { outputFigText: newFigChar(len), chars: figChars };
|
|
16417
|
-
}
|
|
16418
|
-
function generateFigTextLines(txt, figChars, opts) {
|
|
16419
|
-
let charIndex, figChar, overlap = 0, row, outputFigText, len, height = opts.height, outputFigLines = [], maxWidth, nextFigChars = {
|
|
16420
|
-
chars: [],
|
|
16421
|
-
overlap
|
|
16422
|
-
}, figWords = [], char, isSpace, textFigWord, textFigLine, tmpBreak;
|
|
16423
|
-
if (typeof height !== "number") {
|
|
16424
|
-
throw new Error("height is not defined.");
|
|
16425
|
-
}
|
|
16426
|
-
outputFigText = newFigChar(height);
|
|
16427
|
-
const fittingRules = opts.fittingRules || {};
|
|
16428
|
-
if (opts.printDirection === 1) {
|
|
16429
|
-
txt = txt.split("").reverse().join("");
|
|
16430
|
-
}
|
|
16431
|
-
len = txt.length;
|
|
16432
|
-
for (charIndex = 0;charIndex < len; charIndex++) {
|
|
16433
|
-
char = txt.substring(charIndex, charIndex + 1);
|
|
16434
|
-
isSpace = char.match(/\s/);
|
|
16435
|
-
figChar = figChars[char.charCodeAt(0)];
|
|
16436
|
-
textFigLine = null;
|
|
16437
|
-
if (figChar) {
|
|
16438
|
-
if (fittingRules.hLayout !== FULL_WIDTH) {
|
|
16439
|
-
overlap = 1e4;
|
|
16440
|
-
for (row = 0;row < height; row++) {
|
|
16441
|
-
overlap = Math.min(overlap, getHorizontalSmushLength(outputFigText[row], figChar[row], opts));
|
|
16442
|
-
}
|
|
16443
|
-
overlap = overlap === 1e4 ? 0 : overlap;
|
|
16444
|
-
}
|
|
16445
|
-
if (opts.width > 0) {
|
|
16446
|
-
if (opts.whitespaceBreak) {
|
|
16447
|
-
textFigWord = joinFigArray(nextFigChars.chars.concat([
|
|
16448
|
-
{
|
|
16449
|
-
fig: figChar,
|
|
16450
|
-
overlap
|
|
16451
|
-
}
|
|
16452
|
-
]), height, opts);
|
|
16453
|
-
textFigLine = joinFigArray(figWords.concat([
|
|
16454
|
-
{
|
|
16455
|
-
fig: textFigWord,
|
|
16456
|
-
overlap: nextFigChars.overlap
|
|
16457
|
-
}
|
|
16458
|
-
]), height, opts);
|
|
16459
|
-
maxWidth = figLinesWidth(textFigLine);
|
|
16460
|
-
} else {
|
|
16461
|
-
textFigLine = horizontalSmush(outputFigText, figChar, overlap, opts);
|
|
16462
|
-
maxWidth = figLinesWidth(textFigLine);
|
|
16463
|
-
}
|
|
16464
|
-
if (maxWidth >= opts.width && charIndex > 0) {
|
|
16465
|
-
if (opts.whitespaceBreak) {
|
|
16466
|
-
outputFigText = joinFigArray(figWords.slice(0, -1), height, opts);
|
|
16467
|
-
if (figWords.length > 1) {
|
|
16468
|
-
outputFigLines.push(outputFigText);
|
|
16469
|
-
outputFigText = newFigChar(height);
|
|
16470
|
-
}
|
|
16471
|
-
figWords = [];
|
|
16472
|
-
} else {
|
|
16473
|
-
outputFigLines.push(outputFigText);
|
|
16474
|
-
outputFigText = newFigChar(height);
|
|
16475
|
-
}
|
|
16476
|
-
}
|
|
16477
|
-
}
|
|
16478
|
-
if (opts.width > 0 && opts.whitespaceBreak) {
|
|
16479
|
-
if (!isSpace || charIndex === len - 1) {
|
|
16480
|
-
nextFigChars.chars.push({ fig: figChar, overlap });
|
|
16481
|
-
}
|
|
16482
|
-
if (isSpace || charIndex === len - 1) {
|
|
16483
|
-
tmpBreak = null;
|
|
16484
|
-
while (true) {
|
|
16485
|
-
textFigLine = joinFigArray(nextFigChars.chars, height, opts);
|
|
16486
|
-
maxWidth = figLinesWidth(textFigLine);
|
|
16487
|
-
if (maxWidth >= opts.width) {
|
|
16488
|
-
tmpBreak = breakWord(nextFigChars.chars, height, opts);
|
|
16489
|
-
nextFigChars = { chars: tmpBreak.chars };
|
|
16490
|
-
outputFigLines.push(tmpBreak.outputFigText);
|
|
16491
|
-
} else {
|
|
16492
|
-
break;
|
|
16493
|
-
}
|
|
16494
|
-
}
|
|
16495
|
-
if (maxWidth > 0) {
|
|
16496
|
-
if (tmpBreak) {
|
|
16497
|
-
figWords.push({ fig: textFigLine, overlap: 1 });
|
|
16498
|
-
} else {
|
|
16499
|
-
figWords.push({
|
|
16500
|
-
fig: textFigLine,
|
|
16501
|
-
overlap: nextFigChars.overlap
|
|
16502
|
-
});
|
|
16503
|
-
}
|
|
16504
|
-
}
|
|
16505
|
-
if (isSpace) {
|
|
16506
|
-
figWords.push({ fig: figChar, overlap });
|
|
16507
|
-
outputFigText = newFigChar(height);
|
|
16508
|
-
}
|
|
16509
|
-
if (charIndex === len - 1) {
|
|
16510
|
-
outputFigText = joinFigArray(figWords, height, opts);
|
|
16511
|
-
}
|
|
16512
|
-
nextFigChars = {
|
|
16513
|
-
chars: [],
|
|
16514
|
-
overlap
|
|
16515
|
-
};
|
|
16516
|
-
continue;
|
|
16517
|
-
}
|
|
16518
|
-
}
|
|
16519
|
-
outputFigText = horizontalSmush(outputFigText, figChar, overlap, opts);
|
|
16520
|
-
}
|
|
16521
|
-
}
|
|
16522
|
-
if (figLinesWidth(outputFigText) > 0) {
|
|
16523
|
-
outputFigLines.push(outputFigText);
|
|
16524
|
-
}
|
|
16525
|
-
if (!opts.showHardBlanks) {
|
|
16526
|
-
outputFigLines.forEach(function(outputFigText2) {
|
|
16527
|
-
len = outputFigText2.length;
|
|
16528
|
-
for (row = 0;row < len; row++) {
|
|
16529
|
-
outputFigText2[row] = outputFigText2[row].replace(new RegExp("\\" + opts.hardBlank, "g"), " ");
|
|
16530
|
-
}
|
|
16531
|
-
});
|
|
16532
|
-
}
|
|
16533
|
-
if (txt === "" && outputFigLines.length === 0) {
|
|
16534
|
-
outputFigLines.push(new Array(height).fill(""));
|
|
16535
|
-
}
|
|
16536
|
-
return outputFigLines;
|
|
16537
|
-
}
|
|
16538
|
-
const getHorizontalFittingRules = function(layout, options) {
|
|
16539
|
-
let params;
|
|
16540
|
-
const fittingRules = options.fittingRules || {};
|
|
16541
|
-
if (layout === "default") {
|
|
16542
|
-
params = {
|
|
16543
|
-
hLayout: fittingRules.hLayout,
|
|
16544
|
-
hRule1: fittingRules.hRule1,
|
|
16545
|
-
hRule2: fittingRules.hRule2,
|
|
16546
|
-
hRule3: fittingRules.hRule3,
|
|
16547
|
-
hRule4: fittingRules.hRule4,
|
|
16548
|
-
hRule5: fittingRules.hRule5,
|
|
16549
|
-
hRule6: fittingRules.hRule6
|
|
16550
|
-
};
|
|
16551
|
-
} else if (layout === "full") {
|
|
16552
|
-
params = {
|
|
16553
|
-
hLayout: FULL_WIDTH,
|
|
16554
|
-
hRule1: false,
|
|
16555
|
-
hRule2: false,
|
|
16556
|
-
hRule3: false,
|
|
16557
|
-
hRule4: false,
|
|
16558
|
-
hRule5: false,
|
|
16559
|
-
hRule6: false
|
|
16560
|
-
};
|
|
16561
|
-
} else if (layout === "fitted") {
|
|
16562
|
-
params = {
|
|
16563
|
-
hLayout: FITTING,
|
|
16564
|
-
hRule1: false,
|
|
16565
|
-
hRule2: false,
|
|
16566
|
-
hRule3: false,
|
|
16567
|
-
hRule4: false,
|
|
16568
|
-
hRule5: false,
|
|
16569
|
-
hRule6: false
|
|
16570
|
-
};
|
|
16571
|
-
} else if (layout === "controlled smushing") {
|
|
16572
|
-
params = {
|
|
16573
|
-
hLayout: CONTROLLED_SMUSHING,
|
|
16574
|
-
hRule1: true,
|
|
16575
|
-
hRule2: true,
|
|
16576
|
-
hRule3: true,
|
|
16577
|
-
hRule4: true,
|
|
16578
|
-
hRule5: true,
|
|
16579
|
-
hRule6: true
|
|
16580
|
-
};
|
|
16581
|
-
} else if (layout === "universal smushing") {
|
|
16582
|
-
params = {
|
|
16583
|
-
hLayout: SMUSHING,
|
|
16584
|
-
hRule1: false,
|
|
16585
|
-
hRule2: false,
|
|
16586
|
-
hRule3: false,
|
|
16587
|
-
hRule4: false,
|
|
16588
|
-
hRule5: false,
|
|
16589
|
-
hRule6: false
|
|
16590
|
-
};
|
|
16591
|
-
} else {
|
|
16592
|
-
return;
|
|
16593
|
-
}
|
|
16594
|
-
return params;
|
|
16595
|
-
};
|
|
16596
|
-
const getVerticalFittingRules = function(layout, options) {
|
|
16597
|
-
let params = {};
|
|
16598
|
-
const fittingRules = options.fittingRules || {};
|
|
16599
|
-
if (layout === "default") {
|
|
16600
|
-
params = {
|
|
16601
|
-
vLayout: fittingRules.vLayout,
|
|
16602
|
-
vRule1: fittingRules.vRule1,
|
|
16603
|
-
vRule2: fittingRules.vRule2,
|
|
16604
|
-
vRule3: fittingRules.vRule3,
|
|
16605
|
-
vRule4: fittingRules.vRule4,
|
|
16606
|
-
vRule5: fittingRules.vRule5
|
|
16607
|
-
};
|
|
16608
|
-
} else if (layout === "full") {
|
|
16609
|
-
params = {
|
|
16610
|
-
vLayout: FULL_WIDTH,
|
|
16611
|
-
vRule1: false,
|
|
16612
|
-
vRule2: false,
|
|
16613
|
-
vRule3: false,
|
|
16614
|
-
vRule4: false,
|
|
16615
|
-
vRule5: false
|
|
16616
|
-
};
|
|
16617
|
-
} else if (layout === "fitted") {
|
|
16618
|
-
params = {
|
|
16619
|
-
vLayout: FITTING,
|
|
16620
|
-
vRule1: false,
|
|
16621
|
-
vRule2: false,
|
|
16622
|
-
vRule3: false,
|
|
16623
|
-
vRule4: false,
|
|
16624
|
-
vRule5: false
|
|
16625
|
-
};
|
|
16626
|
-
} else if (layout === "controlled smushing") {
|
|
16627
|
-
params = {
|
|
16628
|
-
vLayout: CONTROLLED_SMUSHING,
|
|
16629
|
-
vRule1: true,
|
|
16630
|
-
vRule2: true,
|
|
16631
|
-
vRule3: true,
|
|
16632
|
-
vRule4: true,
|
|
16633
|
-
vRule5: true
|
|
16634
|
-
};
|
|
16635
|
-
} else if (layout === "universal smushing") {
|
|
16636
|
-
params = {
|
|
16637
|
-
vLayout: SMUSHING,
|
|
16638
|
-
vRule1: false,
|
|
16639
|
-
vRule2: false,
|
|
16640
|
-
vRule3: false,
|
|
16641
|
-
vRule4: false,
|
|
16642
|
-
vRule5: false
|
|
16643
|
-
};
|
|
16644
|
-
} else {
|
|
16645
|
-
return;
|
|
16646
|
-
}
|
|
16647
|
-
return params;
|
|
16648
|
-
};
|
|
16649
|
-
const generateText = function(fontName, options, txt) {
|
|
16650
|
-
txt = txt.replace(/\r\n/g, `
|
|
16651
|
-
`).replace(/\r/g, `
|
|
16652
|
-
`);
|
|
16653
|
-
const actualFontName = getFontName(fontName);
|
|
16654
|
-
let lines = txt.split(`
|
|
16655
|
-
`);
|
|
16656
|
-
let figLines = [];
|
|
16657
|
-
let ii, len, output;
|
|
16658
|
-
len = lines.length;
|
|
16659
|
-
for (ii = 0;ii < len; ii++) {
|
|
16660
|
-
figLines = figLines.concat(generateFigTextLines(lines[ii], figFonts[actualFontName], options));
|
|
16661
|
-
}
|
|
16662
|
-
len = figLines.length;
|
|
16663
|
-
output = figLines[0];
|
|
16664
|
-
for (ii = 1;ii < len; ii++) {
|
|
16665
|
-
output = smushVerticalFigLines(output, figLines[ii], options);
|
|
16666
|
-
}
|
|
16667
|
-
return output ? output.join(`
|
|
16668
|
-
`) : "";
|
|
16669
|
-
};
|
|
16670
|
-
function _reworkFontOpts(fontMeta, options) {
|
|
16671
|
-
let myOpts;
|
|
16672
|
-
if (typeof structuredClone !== "undefined") {
|
|
16673
|
-
myOpts = structuredClone(fontMeta);
|
|
16674
|
-
} else {
|
|
16675
|
-
myOpts = JSON.parse(JSON.stringify(fontMeta));
|
|
16676
|
-
}
|
|
16677
|
-
myOpts.showHardBlanks = options.showHardBlanks || false;
|
|
16678
|
-
myOpts.width = options.width || -1;
|
|
16679
|
-
myOpts.whitespaceBreak = options.whitespaceBreak || false;
|
|
16680
|
-
if (options.horizontalLayout) {
|
|
16681
|
-
const params = getHorizontalFittingRules(options.horizontalLayout, fontMeta);
|
|
16682
|
-
if (params) {
|
|
16683
|
-
Object.assign(myOpts.fittingRules, params);
|
|
16684
|
-
}
|
|
16685
|
-
}
|
|
16686
|
-
if (options.verticalLayout) {
|
|
16687
|
-
const params = getVerticalFittingRules(options.verticalLayout, fontMeta);
|
|
16688
|
-
if (params) {
|
|
16689
|
-
Object.assign(myOpts.fittingRules, params);
|
|
16690
|
-
}
|
|
16691
|
-
}
|
|
16692
|
-
myOpts.printDirection = options.printDirection !== null && options.printDirection !== undefined ? options.printDirection : fontMeta.printDirection;
|
|
16693
|
-
return myOpts;
|
|
16694
|
-
}
|
|
16695
|
-
const me2 = async function(txt, optionsOrFontOrCallback, callback) {
|
|
16696
|
-
return me2.text(txt, optionsOrFontOrCallback, callback);
|
|
16697
|
-
};
|
|
16698
|
-
me2.text = async function(txt, optionsOrFontOrCallback, callback) {
|
|
16699
|
-
txt = txt + "";
|
|
16700
|
-
let options, next;
|
|
16701
|
-
if (typeof optionsOrFontOrCallback === "function") {
|
|
16702
|
-
next = optionsOrFontOrCallback;
|
|
16703
|
-
options = { font: figDefaults.font };
|
|
16704
|
-
} else if (typeof optionsOrFontOrCallback === "string") {
|
|
16705
|
-
options = { font: optionsOrFontOrCallback };
|
|
16706
|
-
next = callback;
|
|
16707
|
-
} else if (optionsOrFontOrCallback) {
|
|
16708
|
-
options = optionsOrFontOrCallback;
|
|
16709
|
-
next = callback;
|
|
16710
|
-
} else {
|
|
16711
|
-
options = { font: figDefaults.font };
|
|
16712
|
-
next = callback;
|
|
16713
|
-
}
|
|
16714
|
-
const fontName = options.font || figDefaults.font;
|
|
16715
|
-
try {
|
|
16716
|
-
const fontOpts = await me2.loadFont(fontName);
|
|
16717
|
-
const generatedTxt = fontOpts ? generateText(fontName, _reworkFontOpts(fontOpts, options), txt) : "";
|
|
16718
|
-
if (next) {
|
|
16719
|
-
next(null, generatedTxt);
|
|
16720
|
-
}
|
|
16721
|
-
return generatedTxt;
|
|
16722
|
-
} catch (err) {
|
|
16723
|
-
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
16724
|
-
if (next) {
|
|
16725
|
-
next(error2);
|
|
16726
|
-
return "";
|
|
16727
|
-
}
|
|
16728
|
-
throw error2;
|
|
16729
|
-
}
|
|
16730
|
-
};
|
|
16731
|
-
me2.textSync = function(txt, options) {
|
|
16732
|
-
txt = txt + "";
|
|
16733
|
-
if (typeof options === "string") {
|
|
16734
|
-
options = { font: options };
|
|
16735
|
-
} else {
|
|
16736
|
-
options = options || {};
|
|
16737
|
-
}
|
|
16738
|
-
const fontName = options.font || figDefaults.font;
|
|
16739
|
-
let fontOpts = _reworkFontOpts(me2.loadFontSync(fontName), options);
|
|
16740
|
-
return generateText(fontName, fontOpts, txt);
|
|
16741
|
-
};
|
|
16742
|
-
me2.metadata = async function(fontName, callback) {
|
|
16743
|
-
fontName = fontName + "";
|
|
16744
|
-
try {
|
|
16745
|
-
const fontOpts = await me2.loadFont(fontName);
|
|
16746
|
-
if (!fontOpts) {
|
|
16747
|
-
throw new Error("Error loading font.");
|
|
16748
|
-
}
|
|
16749
|
-
const actualFontName = getFontName(fontName);
|
|
16750
|
-
const font = figFonts[actualFontName] || {};
|
|
16751
|
-
const result = [fontOpts, font.comment || ""];
|
|
16752
|
-
if (callback) {
|
|
16753
|
-
callback(null, fontOpts, font.comment);
|
|
16754
|
-
}
|
|
16755
|
-
return result;
|
|
16756
|
-
} catch (err) {
|
|
16757
|
-
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
16758
|
-
if (callback) {
|
|
16759
|
-
callback(error2);
|
|
16760
|
-
return null;
|
|
16761
|
-
}
|
|
16762
|
-
throw error2;
|
|
16763
|
-
}
|
|
16764
|
-
};
|
|
16765
|
-
me2.defaults = function(opts) {
|
|
16766
|
-
if (opts && typeof opts === "object") {
|
|
16767
|
-
Object.assign(figDefaults, opts);
|
|
16768
|
-
}
|
|
16769
|
-
if (typeof structuredClone !== "undefined") {
|
|
16770
|
-
return structuredClone(figDefaults);
|
|
16771
|
-
} else {
|
|
16772
|
-
return JSON.parse(JSON.stringify(figDefaults));
|
|
16773
|
-
}
|
|
16774
|
-
};
|
|
16775
|
-
me2.parseFont = function(fontName, data, override = true) {
|
|
16776
|
-
if (figFonts[fontName] && !override) {
|
|
16777
|
-
return figFonts[fontName].options;
|
|
16778
|
-
}
|
|
16779
|
-
data = data.replace(/\r\n/g, `
|
|
16780
|
-
`).replace(/\r/g, `
|
|
16781
|
-
`);
|
|
16782
|
-
const font = new FigletFont;
|
|
16783
|
-
const lines = data.split(`
|
|
16784
|
-
`);
|
|
16785
|
-
const headerLine = lines.shift();
|
|
16786
|
-
if (!headerLine) {
|
|
16787
|
-
throw new Error("Invalid font file: missing header");
|
|
16788
|
-
}
|
|
16789
|
-
const headerData = headerLine.split(" ");
|
|
16790
|
-
const opts = {
|
|
16791
|
-
hardBlank: headerData[0].substring(5, 6),
|
|
16792
|
-
height: parseInt(headerData[1], 10),
|
|
16793
|
-
baseline: parseInt(headerData[2], 10),
|
|
16794
|
-
maxLength: parseInt(headerData[3], 10),
|
|
16795
|
-
oldLayout: parseInt(headerData[4], 10),
|
|
16796
|
-
numCommentLines: parseInt(headerData[5], 10),
|
|
16797
|
-
printDirection: headerData[6] ? parseInt(headerData[6], 10) : 0,
|
|
16798
|
-
fullLayout: headerData[7] ? parseInt(headerData[7], 10) : null,
|
|
16799
|
-
codeTagCount: headerData[8] ? parseInt(headerData[8], 10) : null
|
|
16800
|
-
};
|
|
16801
|
-
const hardBlank = opts.hardBlank || "";
|
|
16802
|
-
if (hardBlank.length !== 1 || [
|
|
16803
|
-
opts.height,
|
|
16804
|
-
opts.baseline,
|
|
16805
|
-
opts.maxLength,
|
|
16806
|
-
opts.oldLayout,
|
|
16807
|
-
opts.numCommentLines
|
|
16808
|
-
].some((val) => val === null || val === undefined || isNaN(val))) {
|
|
16809
|
-
throw new Error("FIGlet header contains invalid values.");
|
|
16810
|
-
}
|
|
16811
|
-
if (opts.height == null || opts.numCommentLines == null) {
|
|
16812
|
-
throw new Error("FIGlet header contains invalid values.");
|
|
16813
|
-
}
|
|
16814
|
-
opts.fittingRules = getSmushingRules(opts.oldLayout, opts.fullLayout);
|
|
16815
|
-
font.options = opts;
|
|
16816
|
-
const charNums = [];
|
|
16817
|
-
for (let i2 = 32;i2 <= 126; i2++) {
|
|
16818
|
-
charNums.push(i2);
|
|
16819
|
-
}
|
|
16820
|
-
charNums.push(196, 214, 220, 228, 246, 252, 223);
|
|
16821
|
-
if (lines.length < opts.numCommentLines + opts.height * charNums.length) {
|
|
16822
|
-
throw new Error(`FIGlet file is missing data. Line length: ${lines.length}. Comment lines: ${opts.numCommentLines}. Height: ${opts.height}. Num chars: ${charNums.length}.`);
|
|
16823
|
-
}
|
|
16824
|
-
font.comment = lines.splice(0, opts.numCommentLines).join(`
|
|
16825
|
-
`);
|
|
16826
|
-
font.numChars = 0;
|
|
16827
|
-
while (lines.length > 0 && font.numChars < charNums.length) {
|
|
16828
|
-
const cNum = charNums[font.numChars];
|
|
16829
|
-
font[cNum] = lines.splice(0, opts.height);
|
|
16830
|
-
for (let i2 = 0;i2 < opts.height; i2++) {
|
|
16831
|
-
if (typeof font[cNum][i2] === "undefined") {
|
|
16832
|
-
font[cNum][i2] = "";
|
|
16833
|
-
} else {
|
|
16834
|
-
font[cNum][i2] = removeEndChar(font[cNum][i2], i2, opts.height);
|
|
16835
|
-
}
|
|
16836
|
-
}
|
|
16837
|
-
font.numChars++;
|
|
16838
|
-
}
|
|
16839
|
-
while (lines.length > 0) {
|
|
16840
|
-
const cNumLine = lines.shift();
|
|
16841
|
-
if (!cNumLine || cNumLine.trim() === "")
|
|
16842
|
-
break;
|
|
16843
|
-
let cNum = cNumLine.split(" ")[0];
|
|
16844
|
-
let parsedNum;
|
|
16845
|
-
if (/^-?0[xX][0-9a-fA-F]+$/.test(cNum)) {
|
|
16846
|
-
parsedNum = parseInt(cNum, 16);
|
|
16847
|
-
} else if (/^-?0[0-7]+$/.test(cNum)) {
|
|
16848
|
-
parsedNum = parseInt(cNum, 8);
|
|
16849
|
-
} else if (/^-?[0-9]+$/.test(cNum)) {
|
|
16850
|
-
parsedNum = parseInt(cNum, 10);
|
|
16851
|
-
} else {
|
|
16852
|
-
throw new Error(`Error parsing data. Invalid data: ${cNum}`);
|
|
16853
|
-
}
|
|
16854
|
-
if (parsedNum === -1 || parsedNum < -2147483648 || parsedNum > 2147483647) {
|
|
16855
|
-
const msg = parsedNum === -1 ? "The char code -1 is not permitted." : `The char code cannot be ${parsedNum < -2147483648 ? "less than -2147483648" : "greater than 2147483647"}.`;
|
|
16856
|
-
throw new Error(`Error parsing data. ${msg}`);
|
|
16857
|
-
}
|
|
16858
|
-
font[parsedNum] = lines.splice(0, opts.height);
|
|
16859
|
-
for (let i2 = 0;i2 < opts.height; i2++) {
|
|
16860
|
-
if (typeof font[parsedNum][i2] === "undefined") {
|
|
16861
|
-
font[parsedNum][i2] = "";
|
|
16862
|
-
} else {
|
|
16863
|
-
font[parsedNum][i2] = removeEndChar(font[parsedNum][i2], i2, opts.height);
|
|
16864
|
-
}
|
|
16865
|
-
}
|
|
16866
|
-
font.numChars++;
|
|
16867
|
-
}
|
|
16868
|
-
figFonts[fontName] = font;
|
|
16869
|
-
return opts;
|
|
16870
|
-
};
|
|
16871
|
-
me2.loadedFonts = () => {
|
|
16872
|
-
return Object.keys(figFonts);
|
|
16873
|
-
};
|
|
16874
|
-
me2.clearLoadedFonts = () => {
|
|
16875
|
-
Object.keys(figFonts).forEach((key) => {
|
|
16876
|
-
delete figFonts[key];
|
|
16877
|
-
});
|
|
16878
|
-
};
|
|
16879
|
-
me2.loadFont = async function(fontName, callback) {
|
|
16880
|
-
const actualFontName = getFontName(fontName);
|
|
16881
|
-
if (figFonts[actualFontName]) {
|
|
16882
|
-
const result = figFonts[actualFontName].options;
|
|
16883
|
-
if (callback) {
|
|
16884
|
-
callback(null, result);
|
|
16885
|
-
}
|
|
16886
|
-
return Promise.resolve(result);
|
|
16887
|
-
}
|
|
16888
|
-
try {
|
|
16889
|
-
if (!figDefaults.fetchFontIfMissing) {
|
|
16890
|
-
throw new Error(`Font is not loaded: ${actualFontName}`);
|
|
16891
|
-
}
|
|
16892
|
-
const response = await fetch(`${figDefaults.fontPath}/${actualFontName}.flf`);
|
|
16893
|
-
if (!response.ok) {
|
|
16894
|
-
throw new Error(`Network response was not ok: ${response.status}`);
|
|
16895
|
-
}
|
|
16896
|
-
const text = await response.text();
|
|
16897
|
-
const result = me2.parseFont(actualFontName, text);
|
|
16898
|
-
if (callback) {
|
|
16899
|
-
callback(null, result);
|
|
16900
|
-
}
|
|
16901
|
-
return result;
|
|
16902
|
-
} catch (error2) {
|
|
16903
|
-
const err = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
16904
|
-
if (callback) {
|
|
16905
|
-
callback(err);
|
|
16906
|
-
return null;
|
|
16907
|
-
}
|
|
16908
|
-
throw err;
|
|
16909
|
-
}
|
|
16910
|
-
};
|
|
16911
|
-
me2.loadFontSync = function(name) {
|
|
16912
|
-
const actualFontName = getFontName(name);
|
|
16913
|
-
if (figFonts[actualFontName]) {
|
|
16914
|
-
return figFonts[actualFontName].options;
|
|
16915
|
-
}
|
|
16916
|
-
throw new Error("Synchronous font loading is not implemented for the browser, it will only work for fonts already loaded.");
|
|
16917
|
-
};
|
|
16918
|
-
me2.preloadFonts = async function(fonts, callback) {
|
|
16919
|
-
try {
|
|
16920
|
-
for (const name of fonts) {
|
|
16921
|
-
const actualFontName = getFontName(name);
|
|
16922
|
-
const response = await fetch(`${figDefaults.fontPath}/${actualFontName}.flf`);
|
|
16923
|
-
if (!response.ok) {
|
|
16924
|
-
throw new Error(`Failed to preload fonts. Error fetching font: ${actualFontName}, status code: ${response.statusText}`);
|
|
16925
|
-
}
|
|
16926
|
-
const data = await response.text();
|
|
16927
|
-
me2.parseFont(actualFontName, data);
|
|
16928
|
-
}
|
|
16929
|
-
if (callback) {
|
|
16930
|
-
callback();
|
|
16931
|
-
}
|
|
16932
|
-
} catch (error2) {
|
|
16933
|
-
const err = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
16934
|
-
if (callback) {
|
|
16935
|
-
callback(err);
|
|
16936
|
-
return;
|
|
16937
|
-
}
|
|
16938
|
-
throw error2;
|
|
16939
|
-
}
|
|
16940
|
-
};
|
|
16941
|
-
me2.fonts = function(callback) {
|
|
16942
|
-
return new Promise(function(resolve5, reject) {
|
|
16943
|
-
resolve5(fontList);
|
|
16944
|
-
if (callback) {
|
|
16945
|
-
callback(null, fontList);
|
|
16946
|
-
}
|
|
16947
|
-
});
|
|
16948
|
-
};
|
|
16949
|
-
me2.fontsSync = function() {
|
|
16950
|
-
return fontList;
|
|
16951
|
-
};
|
|
16952
|
-
me2.figFonts = figFonts;
|
|
16953
|
-
return me2;
|
|
16954
|
-
})();
|
|
16955
|
-
|
|
16956
|
-
// node_modules/figlet/dist/node-figlet.mjs
|
|
16957
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16958
|
-
var __filename2 = fileURLToPath2(import.meta.url);
|
|
16959
|
-
var __dirname2 = path2.dirname(__filename2);
|
|
16960
|
-
var fontPath = path2.join(__dirname2, "/../fonts/");
|
|
16961
|
-
var nodeFiglet = figlet;
|
|
16962
|
-
nodeFiglet.defaults({ fontPath });
|
|
16963
|
-
nodeFiglet.loadFont = function(name, callback) {
|
|
16964
|
-
const actualFontName = getFontName(name);
|
|
16965
|
-
return new Promise((resolve5, reject) => {
|
|
16966
|
-
if (nodeFiglet.figFonts[actualFontName]) {
|
|
16967
|
-
if (callback) {
|
|
16968
|
-
callback(null, nodeFiglet.figFonts[actualFontName].options);
|
|
16969
|
-
}
|
|
16970
|
-
resolve5(nodeFiglet.figFonts[actualFontName].options);
|
|
16971
|
-
return;
|
|
16972
|
-
}
|
|
16973
|
-
fs2.readFile(path2.join(nodeFiglet.defaults().fontPath, actualFontName + ".flf"), { encoding: "utf-8" }, (err, fontData) => {
|
|
16974
|
-
if (err) {
|
|
16975
|
-
if (callback) {
|
|
16976
|
-
callback(err);
|
|
16977
|
-
}
|
|
16978
|
-
reject(err);
|
|
16979
|
-
return;
|
|
16980
|
-
}
|
|
16981
|
-
fontData = fontData + "";
|
|
16982
|
-
try {
|
|
16983
|
-
const font = nodeFiglet.parseFont(actualFontName, fontData);
|
|
16984
|
-
if (callback) {
|
|
16985
|
-
callback(null, font);
|
|
16986
|
-
}
|
|
16987
|
-
resolve5(font);
|
|
16988
|
-
} catch (error2) {
|
|
16989
|
-
const typedError = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
16990
|
-
if (callback) {
|
|
16991
|
-
callback(typedError);
|
|
16992
|
-
}
|
|
16993
|
-
reject(typedError);
|
|
16994
|
-
}
|
|
16995
|
-
});
|
|
16996
|
-
});
|
|
16997
|
-
};
|
|
16998
|
-
nodeFiglet.loadFontSync = function(font) {
|
|
16999
|
-
const actualFontName = getFontName(font);
|
|
17000
|
-
if (nodeFiglet.figFonts[actualFontName]) {
|
|
17001
|
-
return nodeFiglet.figFonts[actualFontName].options;
|
|
17002
|
-
}
|
|
17003
|
-
const fontData = fs2.readFileSync(path2.join(nodeFiglet.defaults().fontPath, actualFontName + ".flf"), {
|
|
17004
|
-
encoding: "utf-8"
|
|
17005
|
-
}) + "";
|
|
17006
|
-
return nodeFiglet.parseFont(actualFontName, fontData);
|
|
17007
|
-
};
|
|
17008
|
-
nodeFiglet.fonts = function(next) {
|
|
17009
|
-
return new Promise((resolve5, reject) => {
|
|
17010
|
-
const fontList2 = [];
|
|
17011
|
-
fs2.readdir(nodeFiglet.defaults().fontPath, (err, files) => {
|
|
17012
|
-
if (err) {
|
|
17013
|
-
next && next(err);
|
|
17014
|
-
reject(err);
|
|
17015
|
-
return;
|
|
17016
|
-
}
|
|
17017
|
-
files.forEach((file) => {
|
|
17018
|
-
if (/\.flf$/.test(file)) {
|
|
17019
|
-
fontList2.push(file.replace(/\.flf$/, ""));
|
|
17020
|
-
}
|
|
17021
|
-
});
|
|
17022
|
-
next && next(null, fontList2);
|
|
17023
|
-
resolve5(fontList2);
|
|
17024
|
-
});
|
|
17025
|
-
});
|
|
17026
|
-
};
|
|
17027
|
-
nodeFiglet.fontsSync = function() {
|
|
17028
|
-
const fontList2 = [];
|
|
17029
|
-
fs2.readdirSync(nodeFiglet.defaults().fontPath).forEach((file) => {
|
|
17030
|
-
if (/\.flf$/.test(file)) {
|
|
17031
|
-
fontList2.push(file.replace(/\.flf$/, ""));
|
|
17032
|
-
}
|
|
17033
|
-
});
|
|
17034
|
-
return fontList2;
|
|
17035
|
-
};
|
|
17036
|
-
|
|
17037
15757
|
// src/ui/banner.ts
|
|
17038
|
-
var
|
|
15758
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
17039
15759
|
|
|
17040
15760
|
// src/data/announcements.json
|
|
17041
15761
|
var announcements_default = [
|
|
@@ -17066,19 +15786,12 @@ function shouldShowAnnouncement(announcement, cwd) {
|
|
|
17066
15786
|
}
|
|
17067
15787
|
|
|
17068
15788
|
// src/ui/banner.ts
|
|
17069
|
-
var
|
|
17070
|
-
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
|
|
17074
|
-
|
|
17075
|
-
}
|
|
17076
|
-
var LOGO_SMALL;
|
|
17077
|
-
try {
|
|
17078
|
-
LOGO_SMALL = nodeFiglet.textSync("Contribute Now", { font: "Slant" });
|
|
17079
|
-
} catch {
|
|
17080
|
-
LOGO_SMALL = "Contribute Now";
|
|
17081
|
-
}
|
|
15789
|
+
var LOGO = String.raw` ______ __ _ __ __ _ __
|
|
15790
|
+
/ ____/___ ____ / /______(_) /_ __ __/ /____ / | / /___ _ __
|
|
15791
|
+
/ / / __ \/ __ \/ __/ ___/ / __ \/ / / / __/ _ \ / |/ / __ \ | /| / /
|
|
15792
|
+
/ /___/ /_/ / / / / /_/ / / / /_/ / /_/ / /_/ __/ / /| / /_/ / |/ |/ /
|
|
15793
|
+
\____/\____/_/ /_/\__/_/ /_/_.___/\__,_/\__/\___/ /_/ |_/\____/|__/|__/
|
|
15794
|
+
`;
|
|
17082
15795
|
function getVersion() {
|
|
17083
15796
|
return package_default.version ?? "unknown";
|
|
17084
15797
|
}
|
|
@@ -17086,10 +15799,9 @@ function getAuthor() {
|
|
|
17086
15799
|
return typeof package_default.author === "string" ? package_default.author : "unknown";
|
|
17087
15800
|
}
|
|
17088
15801
|
function showBanner(variant = "small") {
|
|
17089
|
-
|
|
17090
|
-
|
|
17091
|
-
${
|
|
17092
|
-
console.log(` ${import_picocolors23.default.dim(`v${getVersion()}`)} ${import_picocolors23.default.dim("\u2014")} ${import_picocolors23.default.dim(`Built by ${getAuthor()}`)}`);
|
|
15802
|
+
console.log(import_picocolors24.default.cyan(`
|
|
15803
|
+
${LOGO}`));
|
|
15804
|
+
console.log(` ${import_picocolors24.default.dim(`v${getVersion()}`)} ${import_picocolors24.default.dim("\u2014")} ${import_picocolors24.default.dim(`Built by ${getAuthor()}`)}`);
|
|
17093
15805
|
const announcements = getActiveAnnouncements();
|
|
17094
15806
|
if (announcements.length > 0) {
|
|
17095
15807
|
console.log();
|
|
@@ -17098,27 +15810,27 @@ ${logo}`));
|
|
|
17098
15810
|
if (variant === "big") {
|
|
17099
15811
|
const panelLines = [
|
|
17100
15812
|
{
|
|
17101
|
-
label:
|
|
15813
|
+
label: import_picocolors24.default.bold(import_picocolors24.default.cyan("Getting Started")),
|
|
17102
15814
|
rawLabel: "Getting Started",
|
|
17103
15815
|
value: "",
|
|
17104
15816
|
rawValue: ""
|
|
17105
15817
|
},
|
|
17106
15818
|
{
|
|
17107
|
-
label:
|
|
15819
|
+
label: import_picocolors24.default.cyan("cn setup"),
|
|
17108
15820
|
rawLabel: "cn setup",
|
|
17109
|
-
value:
|
|
15821
|
+
value: import_picocolors24.default.dim("configure workflow, remotes, and defaults"),
|
|
17110
15822
|
rawValue: "configure workflow, remotes, and defaults"
|
|
17111
15823
|
},
|
|
17112
15824
|
{
|
|
17113
|
-
label:
|
|
15825
|
+
label: import_picocolors24.default.cyan("cn doctor"),
|
|
17114
15826
|
rawLabel: "cn doctor",
|
|
17115
|
-
value:
|
|
15827
|
+
value: import_picocolors24.default.dim("verify your environment before doing any work"),
|
|
17116
15828
|
rawValue: "verify your environment before doing any work"
|
|
17117
15829
|
},
|
|
17118
15830
|
{
|
|
17119
|
-
label:
|
|
15831
|
+
label: import_picocolors24.default.cyan("cn start"),
|
|
17120
15832
|
rawLabel: "cn start",
|
|
17121
|
-
value:
|
|
15833
|
+
value: import_picocolors24.default.dim("create a branch and begin the next task"),
|
|
17122
15834
|
rawValue: "create a branch and begin the next task"
|
|
17123
15835
|
},
|
|
17124
15836
|
{
|
|
@@ -17128,13 +15840,13 @@ ${logo}`));
|
|
|
17128
15840
|
rawValue: ""
|
|
17129
15841
|
},
|
|
17130
15842
|
{
|
|
17131
|
-
label:
|
|
15843
|
+
label: import_picocolors24.default.bold(import_picocolors24.default.cyan("Workflow")),
|
|
17132
15844
|
rawLabel: "Workflow",
|
|
17133
15845
|
value: "",
|
|
17134
15846
|
rawValue: ""
|
|
17135
15847
|
},
|
|
17136
15848
|
{
|
|
17137
|
-
label:
|
|
15849
|
+
label: import_picocolors24.default.dim("cn setup \u2192 cn commit \u2192 cn update \u2192 cn submit"),
|
|
17138
15850
|
rawLabel: "cn setup \u2192 cn commit \u2192 cn update \u2192 cn submit",
|
|
17139
15851
|
value: "",
|
|
17140
15852
|
rawValue: ""
|
|
@@ -17159,22 +15871,22 @@ ${logo}`));
|
|
|
17159
15871
|
return Math.max(max, lineLength);
|
|
17160
15872
|
}, 0));
|
|
17161
15873
|
console.log();
|
|
17162
|
-
console.log(` ${
|
|
15874
|
+
console.log(` ${import_picocolors24.default.dim(`\u250C${"\u2500".repeat(contentWidth + 2)}\u2510`)}`);
|
|
17163
15875
|
for (const line of rows) {
|
|
17164
15876
|
if (!line.rawLabel && !line.rawValue) {
|
|
17165
|
-
console.log(` ${
|
|
15877
|
+
console.log(` ${import_picocolors24.default.dim("\u2502")} ${" ".repeat(contentWidth)} ${import_picocolors24.default.dim("\u2502")}`);
|
|
17166
15878
|
continue;
|
|
17167
15879
|
}
|
|
17168
15880
|
const left = line.rawValue ? `${line.label}${" ".repeat(Math.max(0, labelWidth - line.rawLabel.length + 2))}` : line.label;
|
|
17169
|
-
const value = line.rawValue ?
|
|
15881
|
+
const value = line.rawValue ? import_picocolors24.default.dim(line.rawValue) : "";
|
|
17170
15882
|
const rawLength = line.rawValue ? labelWidth + 2 + line.rawValue.length : line.rawLabel.length;
|
|
17171
15883
|
const trailing = " ".repeat(Math.max(0, contentWidth - rawLength));
|
|
17172
|
-
console.log(` ${
|
|
15884
|
+
console.log(` ${import_picocolors24.default.dim("\u2502")} ${left}${value}${trailing} ${import_picocolors24.default.dim("\u2502")}`);
|
|
17173
15885
|
}
|
|
17174
|
-
console.log(` ${
|
|
15886
|
+
console.log(` ${import_picocolors24.default.dim(`\u2514${"\u2500".repeat(contentWidth + 2)}\u2518`)}`);
|
|
17175
15887
|
console.log();
|
|
17176
|
-
console.log(` ${
|
|
17177
|
-
console.log(` ${
|
|
15888
|
+
console.log(` ${import_picocolors24.default.dim("Star or contribute:")} ${import_picocolors24.default.dim(linkify("gh.waren.build/contribute-now", "https://gh.waren.build/contribute-now"))}`);
|
|
15889
|
+
console.log(` ${import_picocolors24.default.dim("Sponsor:")} ${import_picocolors24.default.dim(linkify("warengonzaga.com/sponsor", "https://warengonzaga.com/sponsor"))}`);
|
|
17178
15890
|
}
|
|
17179
15891
|
console.log();
|
|
17180
15892
|
}
|
|
@@ -17206,7 +15918,7 @@ function renderAnnouncementBanner(announcement) {
|
|
|
17206
15918
|
console.log(` ${tone.border(`\u250C${"\u2500".repeat(rawWidth + 2)}\u2510`)}`);
|
|
17207
15919
|
for (const line of lines) {
|
|
17208
15920
|
const trailing = " ".repeat(Math.max(0, rawWidth - line.length));
|
|
17209
|
-
const content = line === title ? tone.title(line) :
|
|
15921
|
+
const content = line === title ? tone.title(line) : import_picocolors24.default.dim(line);
|
|
17210
15922
|
console.log(` ${tone.border("\u2502")} ${content}${trailing} ${tone.border("\u2502")}`);
|
|
17211
15923
|
}
|
|
17212
15924
|
console.log(` ${tone.border(`\u2514${"\u2500".repeat(rawWidth + 2)}\u2518`)}`);
|
|
@@ -17242,20 +15954,20 @@ function getAnnouncementTone(kind) {
|
|
|
17242
15954
|
case "info":
|
|
17243
15955
|
return {
|
|
17244
15956
|
emoji: "\u2139",
|
|
17245
|
-
border:
|
|
17246
|
-
title: (value) =>
|
|
15957
|
+
border: import_picocolors24.default.blue,
|
|
15958
|
+
title: (value) => import_picocolors24.default.bold(import_picocolors24.default.blue(value))
|
|
17247
15959
|
};
|
|
17248
15960
|
case "warning":
|
|
17249
15961
|
return {
|
|
17250
15962
|
emoji: "\uD83D\uDEA8",
|
|
17251
|
-
border:
|
|
17252
|
-
title: (value) =>
|
|
15963
|
+
border: import_picocolors24.default.red,
|
|
15964
|
+
title: (value) => import_picocolors24.default.bold(import_picocolors24.default.red(value))
|
|
17253
15965
|
};
|
|
17254
15966
|
default:
|
|
17255
15967
|
return {
|
|
17256
15968
|
emoji: "\u26A0",
|
|
17257
|
-
border:
|
|
17258
|
-
title: (value) =>
|
|
15969
|
+
border: import_picocolors24.default.yellow,
|
|
15970
|
+
title: (value) => import_picocolors24.default.bold(import_picocolors24.default.yellow(value))
|
|
17259
15971
|
};
|
|
17260
15972
|
}
|
|
17261
15973
|
}
|
|
@@ -17286,6 +15998,7 @@ if (!isVersion) {
|
|
|
17286
15998
|
"update",
|
|
17287
15999
|
"submit",
|
|
17288
16000
|
"switch",
|
|
16001
|
+
"discard",
|
|
17289
16002
|
"save",
|
|
17290
16003
|
"clean",
|
|
17291
16004
|
"status",
|
|
@@ -17322,6 +16035,7 @@ var main = defineCommand({
|
|
|
17322
16035
|
update: update_default,
|
|
17323
16036
|
submit: submit_default,
|
|
17324
16037
|
switch: switch_default,
|
|
16038
|
+
discard: discard_default,
|
|
17325
16039
|
save: save_default,
|
|
17326
16040
|
branch: branch_default,
|
|
17327
16041
|
clean: clean_default,
|
|
@@ -17337,4 +16051,7 @@ var main = defineCommand({
|
|
|
17337
16051
|
}
|
|
17338
16052
|
}
|
|
17339
16053
|
});
|
|
17340
|
-
runMain(main)
|
|
16054
|
+
runMain(main).then(() => process.exit(process.exitCode ?? 0)).catch((err) => {
|
|
16055
|
+
console.error(err);
|
|
16056
|
+
process.exit(1);
|
|
16057
|
+
});
|