zion 3.0.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/dist/cli.js +276 -75
- package/package.json +2 -1
- package/dist/LiveNow-XJH5YXPH.js +0 -136
- package/dist/chunk-77CMFBWR.js +0 -190
package/README.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
### zion
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
my site, dotfiles, agent skills and more, in your terminal
|
|
4
4
|
|
|
5
|
-
run `npx zion`
|
|
5
|
+
run `npx zion` to see what it can do
|
|
6
6
|
|
|
7
7
|
#### commands
|
|
8
8
|
|
|
9
|
-
| command | what it does
|
|
10
|
-
| ------------------- |
|
|
11
|
-
| `npx zion` |
|
|
12
|
-
| `npx zion
|
|
13
|
-
| `npx zion
|
|
14
|
-
| `npx zion
|
|
15
|
-
| `npx zion
|
|
9
|
+
| command | what it does |
|
|
10
|
+
| ------------------- | ------------------------------------------------------------------------------ |
|
|
11
|
+
| `npx zion` | list commands |
|
|
12
|
+
| `npx zion tui` | open the terminal version of zzzzion.com |
|
|
13
|
+
| `npx zion dotfiles` | set up [my dotfiles](https://github.com/zion-off/dotfiles) |
|
|
14
|
+
| `npx zion skills` | install my agent skills |
|
|
15
|
+
| `npx zion now` | see what I'm listening to, reading and coding |
|
|
16
|
+
| `npx zion help` | list commands; `npx zion help <command>` or `npx zion <command> help` for more |
|
|
16
17
|
|
|
17
18
|
Global flags: `--no-color` (or `NO_COLOR`), `--no-input` (never prompt), `-h/--help`, `-v/--version`.
|
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
CancelledError,
|
|
4
|
-
CliError,
|
|
5
|
-
PaintContext,
|
|
6
|
-
ReportedError,
|
|
7
|
-
UsageError,
|
|
8
|
-
errorCode,
|
|
9
|
-
errorMessage,
|
|
10
|
-
exitCodeFor,
|
|
11
|
-
formatNow,
|
|
12
|
-
paintFor,
|
|
13
|
-
symbols,
|
|
14
|
-
usePaint
|
|
15
|
-
} from "./chunk-77CMFBWR.js";
|
|
16
2
|
import {
|
|
17
3
|
__export
|
|
18
4
|
} from "./chunk-K3NQKI34.js";
|
|
@@ -22,7 +8,53 @@ import os3 from "os";
|
|
|
22
8
|
import path12 from "path";
|
|
23
9
|
|
|
24
10
|
// package.json
|
|
25
|
-
var version = "
|
|
11
|
+
var version = "4.0.0";
|
|
12
|
+
|
|
13
|
+
// src/lib/theme.ts
|
|
14
|
+
import { Chalk, supportsColor, supportsColorStderr } from "chalk";
|
|
15
|
+
var palette = {
|
|
16
|
+
brand: "#264b96",
|
|
17
|
+
accent: "#5c9fd4",
|
|
18
|
+
success: "#3fb950",
|
|
19
|
+
warning: "#f9a73e",
|
|
20
|
+
error: "#e5534b"
|
|
21
|
+
};
|
|
22
|
+
var symbols = {
|
|
23
|
+
start: "\u250C",
|
|
24
|
+
bar: "\u2502",
|
|
25
|
+
end: "\u2514",
|
|
26
|
+
active: "\u25C6",
|
|
27
|
+
done: "\u25C7",
|
|
28
|
+
warning: "\u25B2",
|
|
29
|
+
error: "\u25A0",
|
|
30
|
+
radioOn: "\u25CF",
|
|
31
|
+
radioOff: "\u25CB",
|
|
32
|
+
checkOn: "\u25FC",
|
|
33
|
+
checkOff: "\u25FB",
|
|
34
|
+
tick: "\u2714",
|
|
35
|
+
cross: "\u2716",
|
|
36
|
+
spinner: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"]
|
|
37
|
+
};
|
|
38
|
+
function createPaint(chalk) {
|
|
39
|
+
return {
|
|
40
|
+
accent: chalk.hex(palette.accent),
|
|
41
|
+
success: chalk.hex(palette.success),
|
|
42
|
+
warning: chalk.hex(palette.warning),
|
|
43
|
+
error: chalk.hex(palette.error),
|
|
44
|
+
muted: chalk.gray,
|
|
45
|
+
dim: chalk.dim,
|
|
46
|
+
bold: chalk.bold,
|
|
47
|
+
white: chalk.white,
|
|
48
|
+
inverse: chalk.inverse,
|
|
49
|
+
hex: (color) => chalk.hex(color),
|
|
50
|
+
badge: (text) => chalk.bgHex(palette.brand).hex("#ffffff").bold(` ${text} `)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function paintFor(stream, { color, env }) {
|
|
54
|
+
const detected = stream === process.stderr ? supportsColorStderr : supportsColor;
|
|
55
|
+
const noColor = Boolean(env.NO_COLOR) && !("FORCE_COLOR" in env);
|
|
56
|
+
return createPaint(new Chalk({ level: !color || noColor || !detected ? 0 : detected.level }));
|
|
57
|
+
}
|
|
26
58
|
|
|
27
59
|
// src/prompts/format.ts
|
|
28
60
|
function toneColor(paint) {
|
|
@@ -108,6 +140,50 @@ function keyHints(paint, hints) {
|
|
|
108
140
|
return hints.map(([key, action]) => `${paint.white(key)} ${action}`).join(paint.muted(" \xB7 "));
|
|
109
141
|
}
|
|
110
142
|
|
|
143
|
+
// src/cli/errors.ts
|
|
144
|
+
var CliError = class extends Error {
|
|
145
|
+
constructor(message, hint, exitCode = 1) {
|
|
146
|
+
super(message);
|
|
147
|
+
this.hint = hint;
|
|
148
|
+
this.exitCode = exitCode;
|
|
149
|
+
this.name = "CliError";
|
|
150
|
+
}
|
|
151
|
+
hint;
|
|
152
|
+
exitCode;
|
|
153
|
+
};
|
|
154
|
+
var UsageError = class extends CliError {
|
|
155
|
+
constructor(message, hint) {
|
|
156
|
+
super(message, hint, 2);
|
|
157
|
+
this.name = "UsageError";
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var CancelledError = class extends Error {
|
|
161
|
+
constructor() {
|
|
162
|
+
super("Cancelled");
|
|
163
|
+
this.name = "CancelledError";
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
var ReportedError = class extends Error {
|
|
167
|
+
exitCode;
|
|
168
|
+
constructor(cause) {
|
|
169
|
+
super(errorMessage(cause), { cause });
|
|
170
|
+
this.name = "ReportedError";
|
|
171
|
+
this.exitCode = exitCodeFor(cause);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
function exitCodeFor(error62) {
|
|
175
|
+
if (error62 instanceof ReportedError) return error62.exitCode;
|
|
176
|
+
if (error62 instanceof CancelledError) return 130;
|
|
177
|
+
if (error62 instanceof CliError) return error62.exitCode;
|
|
178
|
+
return 1;
|
|
179
|
+
}
|
|
180
|
+
function errorMessage(error62) {
|
|
181
|
+
return error62 instanceof Error ? error62.message : String(error62);
|
|
182
|
+
}
|
|
183
|
+
function errorCode(error62) {
|
|
184
|
+
return error62 instanceof Error && "code" in error62 && typeof error62.code === "string" ? error62.code : void 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
111
187
|
// src/cli/Cli.ts
|
|
112
188
|
var HELP_FLAGS = /* @__PURE__ */ new Set(["-h", "--help"]);
|
|
113
189
|
var VERSION_FLAGS = /* @__PURE__ */ new Set(["-v", "--version"]);
|
|
@@ -140,9 +216,9 @@ var Cli = class {
|
|
|
140
216
|
return { bin, version: version3, stdin, stdout, stderr, paint, interactive: terminal && !noInput };
|
|
141
217
|
}
|
|
142
218
|
async dispatch(args, ctx) {
|
|
143
|
-
const { registry: registry3,
|
|
219
|
+
const { registry: registry3, help: help2 } = this.options;
|
|
144
220
|
const [first, ...rest] = args;
|
|
145
|
-
if (first === void 0) return
|
|
221
|
+
if (first === void 0) return this.print(ctx, help2.home(ctx));
|
|
146
222
|
if (HELP_FLAGS.has(first)) return this.print(ctx, help2.root(ctx));
|
|
147
223
|
if (VERSION_FLAGS.has(first)) return this.print(ctx, `${ctx.version}
|
|
148
224
|
`);
|
|
@@ -155,7 +231,8 @@ var Cli = class {
|
|
|
155
231
|
suggestion ? `did you mean ${ctx.bin} ${suggestion}?` : `run ${ctx.bin} --help to see all commands`
|
|
156
232
|
);
|
|
157
233
|
}
|
|
158
|
-
|
|
234
|
+
const wantsHelp = rest[0] === "help" || optionsOf(rest).some((arg) => HELP_FLAGS.has(arg));
|
|
235
|
+
if (wantsHelp) return this.print(ctx, help2.command(command, ctx));
|
|
159
236
|
return command.run(rest, ctx);
|
|
160
237
|
}
|
|
161
238
|
print(ctx, text) {
|
|
@@ -222,26 +299,32 @@ var SHARED_OPTIONS = [
|
|
|
222
299
|
["--no-input", "never prompt; fail if input is needed"]
|
|
223
300
|
];
|
|
224
301
|
var HelpPrinter = class {
|
|
225
|
-
constructor(registry3
|
|
302
|
+
constructor(registry3) {
|
|
226
303
|
this.registry = registry3;
|
|
227
|
-
this.fallback = fallback2;
|
|
228
304
|
}
|
|
229
305
|
registry;
|
|
230
|
-
|
|
306
|
+
/** Shown when no command is given: a short welcome rather than the full reference. */
|
|
307
|
+
home(ctx) {
|
|
308
|
+
const paint = ctx.paint.stdout;
|
|
309
|
+
return render([
|
|
310
|
+
header(paint, ctx, "my site, dotfiles, agent skills and more, in your terminal"),
|
|
311
|
+
section(paint, "Commands", table(paint, this.commandRows())),
|
|
312
|
+
[indent(`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`)]
|
|
313
|
+
]);
|
|
314
|
+
}
|
|
231
315
|
root(ctx) {
|
|
232
316
|
const paint = ctx.paint.stdout;
|
|
233
|
-
const commands = this.registry.list().map((command) => [command.name, command.summary]);
|
|
234
317
|
return render([
|
|
235
318
|
header(paint, ctx),
|
|
236
319
|
section(paint, "Usage", [`${ctx.bin} ${paint.muted("[command] [options]")}`]),
|
|
237
|
-
section(paint, "Commands", table(paint,
|
|
320
|
+
section(paint, "Commands", table(paint, this.commandRows())),
|
|
238
321
|
section(paint, "Options", table(paint, [HELP_OPTION, VERSION_OPTION, ...SHARED_OPTIONS])),
|
|
239
|
-
[
|
|
240
|
-
`Run ${paint.accent(ctx.bin)} with no command to ${this.fallback.summary}.`,
|
|
241
|
-
`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`
|
|
242
|
-
].map(indent)
|
|
322
|
+
[indent(`Run ${paint.accent(`${ctx.bin} help <command>`)} for details on a command.`)]
|
|
243
323
|
]);
|
|
244
324
|
}
|
|
325
|
+
commandRows() {
|
|
326
|
+
return this.registry.list().map((command) => [command.name, command.summary]);
|
|
327
|
+
}
|
|
245
328
|
command(command, ctx) {
|
|
246
329
|
const paint = ctx.paint.stdout;
|
|
247
330
|
const { help: help2 } = command;
|
|
@@ -326,11 +409,37 @@ ${blocks.filter((block) => block.length > 0).map((block) => block.join("\n")).jo
|
|
|
326
409
|
`;
|
|
327
410
|
}
|
|
328
411
|
|
|
412
|
+
// src/commands/TuiCommand.tsx
|
|
413
|
+
import { parseArgs } from "util";
|
|
414
|
+
|
|
415
|
+
// src/cli/parseArgs.ts
|
|
416
|
+
function describeParseError(error62) {
|
|
417
|
+
const code = errorCode(error62);
|
|
418
|
+
const message = errorMessage(error62);
|
|
419
|
+
const option = message.match(/'(-[^']*)'/)?.[1];
|
|
420
|
+
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && option) return `unknown option "${option}"`;
|
|
421
|
+
if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" && option) return `option "${option}" needs a value`;
|
|
422
|
+
const positional = message.match(/^Unexpected argument '([^']*)'/)?.[1];
|
|
423
|
+
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL" && positional) return `unexpected argument "${positional}"`;
|
|
424
|
+
return message;
|
|
425
|
+
}
|
|
426
|
+
|
|
329
427
|
// src/commands/TuiCommand.tsx
|
|
330
428
|
import { jsx } from "react/jsx-runtime";
|
|
331
429
|
var TuiCommand = class {
|
|
430
|
+
name = "tui";
|
|
332
431
|
summary = "browse zzzzion.com in your terminal";
|
|
333
|
-
|
|
432
|
+
help = {
|
|
433
|
+
usage: "[options]",
|
|
434
|
+
description: "Opens a full-screen version of zzzzion.com with the home page, blog and portfolio. Needs an interactive terminal.",
|
|
435
|
+
examples: ["tui"]
|
|
436
|
+
};
|
|
437
|
+
async run(args, ctx) {
|
|
438
|
+
try {
|
|
439
|
+
parseArgs({ args: [...args], strict: true, options: {} });
|
|
440
|
+
} catch (error62) {
|
|
441
|
+
throw new UsageError(describeParseError(error62), `run ${ctx.bin} tui --help for usage`);
|
|
442
|
+
}
|
|
334
443
|
if (!ctx.interactive || !ctx.stdout.isTTY) {
|
|
335
444
|
throw new UsageError(
|
|
336
445
|
"browsing zzzzion.com needs an interactive terminal",
|
|
@@ -435,6 +544,17 @@ var PromptStore = class {
|
|
|
435
544
|
// src/prompts/components/ConfirmPrompt.tsx
|
|
436
545
|
import { useRef, useState } from "react";
|
|
437
546
|
import { Text, useInput } from "ink";
|
|
547
|
+
|
|
548
|
+
// src/prompts/components/PaintContext.ts
|
|
549
|
+
import { createContext, useContext } from "react";
|
|
550
|
+
var PaintContext = createContext(null);
|
|
551
|
+
function usePaint() {
|
|
552
|
+
const paint = useContext(PaintContext);
|
|
553
|
+
if (!paint) throw new Error("usePaint needs a PaintContext provider");
|
|
554
|
+
return paint;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// src/prompts/components/ConfirmPrompt.tsx
|
|
438
558
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
439
559
|
function ConfirmPrompt({ message, defaultValue, onSubmit }) {
|
|
440
560
|
const paint = usePaint();
|
|
@@ -627,9 +747,9 @@ function TextPrompt({ message, defaultValue = "", validate: validate2, onSubmit
|
|
|
627
747
|
}
|
|
628
748
|
if (key.ctrl || key.meta || key.escape || key.tab || key.upArrow || key.downArrow) return;
|
|
629
749
|
if (key.leftArrow || key.rightArrow) return;
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
632
|
-
setValue((v) => v +
|
|
750
|
+
const printable2 = input2.replace(/[\r\n\t]/g, "");
|
|
751
|
+
if (printable2) {
|
|
752
|
+
setValue((v) => v + printable2);
|
|
633
753
|
setError(void 0);
|
|
634
754
|
}
|
|
635
755
|
});
|
|
@@ -1006,26 +1126,12 @@ function modeFromFlags(action, flags) {
|
|
|
1006
1126
|
}
|
|
1007
1127
|
|
|
1008
1128
|
// src/commands/dotfiles/options.ts
|
|
1009
|
-
import { parseArgs } from "util";
|
|
1010
|
-
|
|
1011
|
-
// src/cli/parseArgs.ts
|
|
1012
|
-
function describeParseError(error62) {
|
|
1013
|
-
const code = errorCode(error62);
|
|
1014
|
-
const message = errorMessage(error62);
|
|
1015
|
-
const option = message.match(/'(-[^']*)'/)?.[1];
|
|
1016
|
-
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && option) return `unknown option "${option}"`;
|
|
1017
|
-
if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" && option) return `option "${option}" needs a value`;
|
|
1018
|
-
const positional = message.match(/^Unexpected argument '([^']*)'/)?.[1];
|
|
1019
|
-
if (code === "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL" && positional) return `unexpected argument "${positional}"`;
|
|
1020
|
-
return message;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
// src/commands/dotfiles/options.ts
|
|
1129
|
+
import { parseArgs as parseArgs2 } from "util";
|
|
1024
1130
|
function parseDotfilesOptions(args, bin) {
|
|
1025
1131
|
const usageHint = `run ${bin} dotfiles --help for usage`;
|
|
1026
1132
|
let parsed;
|
|
1027
1133
|
try {
|
|
1028
|
-
parsed =
|
|
1134
|
+
parsed = parseArgs2({
|
|
1029
1135
|
args: [...args],
|
|
1030
1136
|
allowPositionals: true,
|
|
1031
1137
|
strict: true,
|
|
@@ -1090,7 +1196,7 @@ var DotfilesCommand = class {
|
|
|
1090
1196
|
}
|
|
1091
1197
|
deps;
|
|
1092
1198
|
name = "dotfiles";
|
|
1093
|
-
summary = "set up
|
|
1199
|
+
summary = "set up my dotfiles on this machine";
|
|
1094
1200
|
help;
|
|
1095
1201
|
async run(args, ctx) {
|
|
1096
1202
|
const options = parseDotfilesOptions(args, ctx.bin);
|
|
@@ -2013,7 +2119,7 @@ function putProp(target, key, value) {
|
|
|
2013
2119
|
else
|
|
2014
2120
|
target[key] = value;
|
|
2015
2121
|
}
|
|
2016
|
-
function mirrorShape(target, source, keys,
|
|
2122
|
+
function mirrorShape(target, source, keys, wrap3) {
|
|
2017
2123
|
const raw = sourceShape(source);
|
|
2018
2124
|
for (const key of keys) {
|
|
2019
2125
|
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
@@ -2022,10 +2128,10 @@ function mirrorShape(target, source, keys, wrap2) {
|
|
|
2022
2128
|
if (desc.get) {
|
|
2023
2129
|
deferProp(target, key, () => {
|
|
2024
2130
|
const value = source._zod.def.shape[key];
|
|
2025
|
-
return
|
|
2131
|
+
return wrap3 ? wrap3(value, key) : value;
|
|
2026
2132
|
});
|
|
2027
2133
|
} else
|
|
2028
|
-
putProp(target, key,
|
|
2134
|
+
putProp(target, key, wrap3 ? wrap3(desc.value, key) : desc.value);
|
|
2029
2135
|
}
|
|
2030
2136
|
}
|
|
2031
2137
|
function mirrorProps(target, source) {
|
|
@@ -21048,30 +21154,129 @@ var HttpNowApi = class {
|
|
|
21048
21154
|
return this.url.host;
|
|
21049
21155
|
}
|
|
21050
21156
|
get(signal) {
|
|
21051
|
-
return getJson(this.fetchImpl, { url: this.url, schema: Now, failure: "say what
|
|
21157
|
+
return getJson(this.fetchImpl, { url: this.url, schema: Now, failure: "say what I'm up to", signal });
|
|
21052
21158
|
}
|
|
21053
21159
|
};
|
|
21054
21160
|
|
|
21055
21161
|
// src/commands/now/NowCommand.ts
|
|
21056
|
-
import { parseArgs as
|
|
21162
|
+
import { parseArgs as parseArgs3 } from "util";
|
|
21057
21163
|
|
|
21058
21164
|
// src/lib/spinner.ts
|
|
21059
|
-
|
|
21165
|
+
var FRAME_MS = 80;
|
|
21166
|
+
var DELAY_MS = 200;
|
|
21167
|
+
async function whileSpinning(ctx, work) {
|
|
21060
21168
|
if (!ctx.interactive) return work;
|
|
21061
21169
|
const { stderr } = ctx;
|
|
21062
|
-
const paint = ctx.paint.stderr;
|
|
21063
21170
|
let frame = 0;
|
|
21171
|
+
let drawn = false;
|
|
21172
|
+
let timer;
|
|
21064
21173
|
const draw = () => {
|
|
21065
|
-
stderr.write(`\r${
|
|
21174
|
+
stderr.write(`\r${symbols.spinner[frame++ % symbols.spinner.length]}`);
|
|
21175
|
+
drawn = true;
|
|
21066
21176
|
};
|
|
21067
|
-
|
|
21068
|
-
|
|
21177
|
+
const delay = setTimeout(() => {
|
|
21178
|
+
draw();
|
|
21179
|
+
timer = setInterval(draw, FRAME_MS);
|
|
21180
|
+
}, DELAY_MS);
|
|
21069
21181
|
try {
|
|
21070
21182
|
return await work;
|
|
21071
21183
|
} finally {
|
|
21184
|
+
clearTimeout(delay);
|
|
21072
21185
|
clearInterval(timer);
|
|
21073
|
-
stderr.write("\r\x1B[K");
|
|
21186
|
+
if (drawn) stderr.write("\r\x1B[K");
|
|
21187
|
+
}
|
|
21188
|
+
}
|
|
21189
|
+
|
|
21190
|
+
// src/commands/now/format.ts
|
|
21191
|
+
import terminalLink from "terminal-link";
|
|
21192
|
+
var LABEL_WIDTH = 14;
|
|
21193
|
+
var PAD_X = 2;
|
|
21194
|
+
function formatNow(paint, now, at, columns) {
|
|
21195
|
+
const sections = sectionsOf(now, at);
|
|
21196
|
+
const margin = " ".repeat(PAD_X);
|
|
21197
|
+
if (sections.length === 0) return `
|
|
21198
|
+
${margin}${paint.muted(NOTHING)}
|
|
21199
|
+
|
|
21200
|
+
`;
|
|
21201
|
+
const width = columns ? Math.max(20, columns - PAD_X * 2 - LABEL_WIDTH) : Infinity;
|
|
21202
|
+
const body = sections.map(
|
|
21203
|
+
(entries) => entries.flatMap((entry) => entryRows(paint, entry, width)).map((row) => `${margin}${paint.muted(row.label.padEnd(LABEL_WIDTH))}${row.text}`).join("\n")
|
|
21204
|
+
).join("\n\n");
|
|
21205
|
+
return `
|
|
21206
|
+
${body}
|
|
21207
|
+
|
|
21208
|
+
`;
|
|
21209
|
+
}
|
|
21210
|
+
var NOTHING = "Nothing to show right now.";
|
|
21211
|
+
function sectionsOf(now, at) {
|
|
21212
|
+
const sections = [];
|
|
21213
|
+
if (now.listening) sections.push([listening(now.listening, at)]);
|
|
21214
|
+
if (now.reading?.length) sections.push(now.reading.map(reading));
|
|
21215
|
+
if (now.coding) sections.push([coding(now.coding, at)]);
|
|
21216
|
+
return sections;
|
|
21217
|
+
}
|
|
21218
|
+
function entryRows(paint, entry, width) {
|
|
21219
|
+
const bold = paint.bold(printable(entry.title));
|
|
21220
|
+
const linked = /^https:\/\//.test(entry.url) ? terminalLink(bold, printable(entry.url), { fallback: () => bold }) : bold;
|
|
21221
|
+
const rows = [{ label: entry.label, text: linked }];
|
|
21222
|
+
if (entry.detail) {
|
|
21223
|
+
for (const line of wrap2(printable(entry.detail), width)) rows.push({ label: "", text: paint.muted(line) });
|
|
21074
21224
|
}
|
|
21225
|
+
return rows;
|
|
21226
|
+
}
|
|
21227
|
+
function wrap2(text, width) {
|
|
21228
|
+
const lines = [];
|
|
21229
|
+
let line = "";
|
|
21230
|
+
for (const word of text.split(/\s+/)) {
|
|
21231
|
+
if (line && line.length + word.length + 1 > width) {
|
|
21232
|
+
lines.push(line);
|
|
21233
|
+
line = word;
|
|
21234
|
+
} else {
|
|
21235
|
+
line = line ? `${line} ${word}` : word;
|
|
21236
|
+
}
|
|
21237
|
+
}
|
|
21238
|
+
if (line) lines.push(line);
|
|
21239
|
+
return lines;
|
|
21240
|
+
}
|
|
21241
|
+
function listening(track, at) {
|
|
21242
|
+
const played = track.playedAt === null ? null : ago(new Date(track.playedAt), at);
|
|
21243
|
+
return {
|
|
21244
|
+
label: played === null ? "listening to" : "listened to",
|
|
21245
|
+
title: track.title,
|
|
21246
|
+
url: track.url,
|
|
21247
|
+
detail: played === null ? track.artist : [track.artist, played].join(" \xB7 ")
|
|
21248
|
+
};
|
|
21249
|
+
}
|
|
21250
|
+
function reading(book, i) {
|
|
21251
|
+
return { label: i === 0 ? "reading" : "", title: book.title, url: book.url, detail: book.author };
|
|
21252
|
+
}
|
|
21253
|
+
function coding(push, at) {
|
|
21254
|
+
return {
|
|
21255
|
+
label: "pushed to",
|
|
21256
|
+
title: push.repo,
|
|
21257
|
+
url: push.url,
|
|
21258
|
+
detail: [push.message, ago(new Date(push.pushedAt), at)].join(" \xB7 ")
|
|
21259
|
+
};
|
|
21260
|
+
}
|
|
21261
|
+
var UNITS = [
|
|
21262
|
+
["year", 365 * 24 * 3600],
|
|
21263
|
+
["month", 30 * 24 * 3600],
|
|
21264
|
+
["week", 7 * 24 * 3600],
|
|
21265
|
+
["day", 24 * 3600],
|
|
21266
|
+
["hour", 3600],
|
|
21267
|
+
["minute", 60]
|
|
21268
|
+
];
|
|
21269
|
+
function ago(then, at) {
|
|
21270
|
+
const seconds = (at.getTime() - then.getTime()) / 1e3;
|
|
21271
|
+
if (Number.isNaN(seconds)) return "";
|
|
21272
|
+
const format = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
21273
|
+
for (const [unit, size] of UNITS) {
|
|
21274
|
+
if (seconds >= size) return format.format(-Math.floor(seconds / size), unit);
|
|
21275
|
+
}
|
|
21276
|
+
return "just now";
|
|
21277
|
+
}
|
|
21278
|
+
function printable(text) {
|
|
21279
|
+
return text.replace(new RegExp("\\p{Cc}", "gu"), "");
|
|
21075
21280
|
}
|
|
21076
21281
|
|
|
21077
21282
|
// src/commands/now/NowCommand.ts
|
|
@@ -21080,34 +21285,32 @@ var NowCommand = class {
|
|
|
21080
21285
|
this.deps = deps;
|
|
21081
21286
|
this.help = {
|
|
21082
21287
|
usage: "[options]",
|
|
21083
|
-
description: `Asks ${deps.api.host} what
|
|
21288
|
+
description: `Asks ${deps.api.host} what I last played on Last.fm, am reading on Goodreads and last pushed to GitHub.`,
|
|
21084
21289
|
options: [["--json", "print it as JSON"]],
|
|
21085
21290
|
examples: ["now", "now --json"]
|
|
21086
21291
|
};
|
|
21087
21292
|
}
|
|
21088
21293
|
deps;
|
|
21089
21294
|
name = "now";
|
|
21090
|
-
summary = "see what
|
|
21295
|
+
summary = "see what I'm listening to, reading and coding";
|
|
21091
21296
|
help;
|
|
21092
21297
|
async run(args, ctx) {
|
|
21093
21298
|
const { json: json2 } = parseNowOptions(args, ctx.bin);
|
|
21094
|
-
|
|
21095
|
-
const { runLive } = await import("./LiveNow-XJH5YXPH.js");
|
|
21096
|
-
return runLive(ctx, this.deps);
|
|
21097
|
-
}
|
|
21098
|
-
const status = await whileSpinning(ctx, `asking ${this.deps.api.host}`, this.deps.api.get());
|
|
21299
|
+
const status = await whileSpinning(ctx, this.deps.api.get());
|
|
21099
21300
|
if (json2) {
|
|
21100
21301
|
ctx.stdout.write(`${JSON.stringify(status, null, 2)}
|
|
21101
21302
|
`);
|
|
21102
21303
|
return 0;
|
|
21103
21304
|
}
|
|
21104
|
-
ctx.stdout.write(
|
|
21305
|
+
ctx.stdout.write(
|
|
21306
|
+
formatNow(ctx.paint.stdout, status, this.deps.clock(), ctx.stdout.isTTY ? ctx.stdout.columns : void 0)
|
|
21307
|
+
);
|
|
21105
21308
|
return 0;
|
|
21106
21309
|
}
|
|
21107
21310
|
};
|
|
21108
21311
|
function parseNowOptions(args, bin) {
|
|
21109
21312
|
try {
|
|
21110
|
-
const { values } =
|
|
21313
|
+
const { values } = parseArgs3({
|
|
21111
21314
|
args: [...args],
|
|
21112
21315
|
strict: true,
|
|
21113
21316
|
options: { json: { type: "boolean", default: false } }
|
|
@@ -21801,12 +22004,12 @@ function findSkillsAction(name) {
|
|
|
21801
22004
|
}
|
|
21802
22005
|
|
|
21803
22006
|
// src/commands/skills/options.ts
|
|
21804
|
-
import { parseArgs as
|
|
22007
|
+
import { parseArgs as parseArgs4 } from "util";
|
|
21805
22008
|
function parseSkillsOptions(args, bin, targetIds) {
|
|
21806
22009
|
const usageHint = `run ${bin} skills --help for usage`;
|
|
21807
22010
|
let parsed;
|
|
21808
22011
|
try {
|
|
21809
|
-
parsed =
|
|
22012
|
+
parsed = parseArgs4({
|
|
21810
22013
|
args: [...args],
|
|
21811
22014
|
allowPositionals: true,
|
|
21812
22015
|
strict: true,
|
|
@@ -21931,7 +22134,7 @@ var SkillsCommand = class {
|
|
|
21931
22134
|
}
|
|
21932
22135
|
deps;
|
|
21933
22136
|
name = "skills";
|
|
21934
|
-
summary = "install
|
|
22137
|
+
summary = "install my agent skills";
|
|
21935
22138
|
help;
|
|
21936
22139
|
async run(args, ctx) {
|
|
21937
22140
|
const options = parseSkillsOptions(
|
|
@@ -22196,18 +22399,16 @@ var registry2 = new CommandRegistry().register(
|
|
|
22196
22399
|
createPrompter,
|
|
22197
22400
|
now: () => /* @__PURE__ */ new Date()
|
|
22198
22401
|
})
|
|
22199
|
-
).register(
|
|
22402
|
+
).register(new TuiCommand()).register(
|
|
22200
22403
|
new NowCommand({
|
|
22201
22404
|
api: new HttpNowApi(process.env.ZION_NOW_URL || "https://zzzzion.com/api/now"),
|
|
22202
22405
|
clock: () => /* @__PURE__ */ new Date()
|
|
22203
22406
|
})
|
|
22204
22407
|
);
|
|
22205
|
-
var
|
|
22206
|
-
var help = new HelpPrinter(registry2, fallback);
|
|
22408
|
+
var help = new HelpPrinter(registry2);
|
|
22207
22409
|
registry2.register(new HelpCommand(help, registry2));
|
|
22208
22410
|
var cli = new Cli({
|
|
22209
22411
|
registry: registry2,
|
|
22210
|
-
fallback,
|
|
22211
22412
|
help,
|
|
22212
22413
|
environment: {
|
|
22213
22414
|
bin: "npx zion",
|
package/package.json
CHANGED
package/dist/LiveNow-XJH5YXPH.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
LABEL_WIDTH,
|
|
4
|
-
NOTHING,
|
|
5
|
-
PaintContext,
|
|
6
|
-
entryRows,
|
|
7
|
-
errorMessage,
|
|
8
|
-
palette,
|
|
9
|
-
sectionsOf,
|
|
10
|
-
usePaint
|
|
11
|
-
} from "./chunk-77CMFBWR.js";
|
|
12
|
-
import "./chunk-K3NQKI34.js";
|
|
13
|
-
|
|
14
|
-
// src/commands/now/live/LiveNow.tsx
|
|
15
|
-
import { useEffect, useState } from "react";
|
|
16
|
-
import { Box, Text, render, useApp, useInput } from "ink";
|
|
17
|
-
|
|
18
|
-
// src/commands/now/live/effects.ts
|
|
19
|
-
var WHITE = "#ffffff";
|
|
20
|
-
function shimmer(paint, text, ms) {
|
|
21
|
-
const chars = Array.from(text);
|
|
22
|
-
const reach = 4;
|
|
23
|
-
const center = ms / 1400 % 1 * (chars.length + reach * 2) - reach;
|
|
24
|
-
return chars.map((char, i) => paint.hex(mix(palette.accent, WHITE, Math.max(0, 1 - Math.abs(i - center) / reach)))(char)).join("");
|
|
25
|
-
}
|
|
26
|
-
var LEVELS = ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
|
|
27
|
-
function bars(paint, ms, count = 4) {
|
|
28
|
-
return Array.from({ length: count }, (_, i) => {
|
|
29
|
-
const level = (wave(ms / (260 + i * 70) + i * 1.7) + wave(ms / (410 - i * 45) + i)) / 2;
|
|
30
|
-
return paint.hex(mix(palette.accent, WHITE, level))(LEVELS[Math.round(level * (LEVELS.length - 1))]);
|
|
31
|
-
}).join("");
|
|
32
|
-
}
|
|
33
|
-
function wave(x) {
|
|
34
|
-
return (Math.sin(x) + 1) / 2;
|
|
35
|
-
}
|
|
36
|
-
function mix(from, to, t) {
|
|
37
|
-
const channel = (hex, at) => parseInt(hex.slice(at, at + 2), 16);
|
|
38
|
-
return `#${[1, 3, 5].map((at) => Math.round(channel(from, at) + (channel(to, at) - channel(from, at)) * t)).map((value) => value.toString(16).padStart(2, "0")).join("")}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/commands/now/live/LiveNow.tsx
|
|
42
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
43
|
-
var FRAME_MS = 80;
|
|
44
|
-
var REFRESH_MS = 3e4;
|
|
45
|
-
async function runLive(ctx, deps) {
|
|
46
|
-
let code = 0;
|
|
47
|
-
const instance = render(
|
|
48
|
-
/* @__PURE__ */ jsx(PaintContext.Provider, { value: ctx.paint.stdout, children: /* @__PURE__ */ jsx(
|
|
49
|
-
LiveNow,
|
|
50
|
-
{
|
|
51
|
-
...deps,
|
|
52
|
-
onQuit: (quitWith) => {
|
|
53
|
-
code = quitWith;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
) }),
|
|
57
|
-
{ stdout: ctx.stdout, stdin: ctx.stdin, exitOnCtrlC: false, patchConsole: false }
|
|
58
|
-
);
|
|
59
|
-
await instance.waitUntilExit();
|
|
60
|
-
return code;
|
|
61
|
-
}
|
|
62
|
-
function LiveNow({ api, clock, onQuit }) {
|
|
63
|
-
const paint = usePaint();
|
|
64
|
-
const { exit } = useApp();
|
|
65
|
-
const [ms, setMs] = useState(() => clock().getTime());
|
|
66
|
-
const [now, setNow] = useState(null);
|
|
67
|
-
const [status, setStatus] = useState("live");
|
|
68
|
-
const [failure, setFailure] = useState(null);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
const timer = setInterval(() => setMs(clock().getTime()), FRAME_MS);
|
|
71
|
-
return () => clearInterval(timer);
|
|
72
|
-
}, [clock]);
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
const controller = new AbortController();
|
|
75
|
-
let loaded = false;
|
|
76
|
-
let loading = false;
|
|
77
|
-
const load = () => {
|
|
78
|
-
if (loading) return;
|
|
79
|
-
loading = true;
|
|
80
|
-
api.get(controller.signal).then(
|
|
81
|
-
(latest) => {
|
|
82
|
-
loaded = true;
|
|
83
|
-
setNow(latest);
|
|
84
|
-
setStatus((current) => current === "quit" ? current : "live");
|
|
85
|
-
},
|
|
86
|
-
(error) => {
|
|
87
|
-
if (controller.signal.aborted) return;
|
|
88
|
-
if (!loaded) setFailure(error instanceof Error ? error : new Error(errorMessage(error)));
|
|
89
|
-
else setStatus((current) => current === "quit" ? current : "stale");
|
|
90
|
-
}
|
|
91
|
-
).finally(() => {
|
|
92
|
-
loading = false;
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
load();
|
|
96
|
-
const timer = setInterval(load, REFRESH_MS);
|
|
97
|
-
return () => {
|
|
98
|
-
clearInterval(timer);
|
|
99
|
-
controller.abort();
|
|
100
|
-
};
|
|
101
|
-
}, [api]);
|
|
102
|
-
useInput((input, key) => {
|
|
103
|
-
const code = input === "q" || key.escape ? 0 : key.ctrl && input === "c" ? 130 : null;
|
|
104
|
-
if (code === null) return;
|
|
105
|
-
onQuit(code);
|
|
106
|
-
setStatus("quit");
|
|
107
|
-
});
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
if (failure) exit(failure);
|
|
110
|
-
else if (status === "quit") exit();
|
|
111
|
-
}, [exit, failure, status]);
|
|
112
|
-
if (failure) return null;
|
|
113
|
-
return /* @__PURE__ */ jsx(Box, { paddingX: 2, paddingY: 1, children: now ? frame(paint, now, clock(), ms, status) : /* @__PURE__ */ jsx(Text, { children: asking(paint, api.host, ms) }) });
|
|
114
|
-
}
|
|
115
|
-
function asking(paint, host, ms) {
|
|
116
|
-
return shimmer(paint, `asking ${host}`, ms);
|
|
117
|
-
}
|
|
118
|
-
function frame(paint, now, at, ms, status) {
|
|
119
|
-
const quit = status === "quit";
|
|
120
|
-
const playing = quit ? "" : ` ${bars(paint, ms)}`;
|
|
121
|
-
const sections = sectionsOf(now, at).map(
|
|
122
|
-
(entries) => entries.flatMap((entry) => entryRows(paint, entry, entry.playing ? playing : ""))
|
|
123
|
-
);
|
|
124
|
-
const footer = status === "stale" ? `${paint.warning("\u25B2")} ${paint.muted("couldn't refresh, still trying \xB7 q to quit")}` : paint.muted("q to quit");
|
|
125
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", rowGap: 1, children: [
|
|
126
|
-
sections.length === 0 && /* @__PURE__ */ jsx(Text, { children: paint.muted(NOTHING) }),
|
|
127
|
-
sections.map((rows, i) => /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: rows.map((row, j) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
128
|
-
/* @__PURE__ */ jsx(Box, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx(Text, { children: paint.muted(row.label) }) }),
|
|
129
|
-
/* @__PURE__ */ jsx(Text, { children: row.text })
|
|
130
|
-
] }, j)) }, i)),
|
|
131
|
-
!quit && /* @__PURE__ */ jsx(Text, { children: footer })
|
|
132
|
-
] });
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
runLive
|
|
136
|
-
};
|
package/dist/chunk-77CMFBWR.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/cli/errors.ts
|
|
4
|
-
var CliError = class extends Error {
|
|
5
|
-
constructor(message, hint, exitCode = 1) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.hint = hint;
|
|
8
|
-
this.exitCode = exitCode;
|
|
9
|
-
this.name = "CliError";
|
|
10
|
-
}
|
|
11
|
-
hint;
|
|
12
|
-
exitCode;
|
|
13
|
-
};
|
|
14
|
-
var UsageError = class extends CliError {
|
|
15
|
-
constructor(message, hint) {
|
|
16
|
-
super(message, hint, 2);
|
|
17
|
-
this.name = "UsageError";
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var CancelledError = class extends Error {
|
|
21
|
-
constructor() {
|
|
22
|
-
super("Cancelled");
|
|
23
|
-
this.name = "CancelledError";
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var ReportedError = class extends Error {
|
|
27
|
-
exitCode;
|
|
28
|
-
constructor(cause) {
|
|
29
|
-
super(errorMessage(cause), { cause });
|
|
30
|
-
this.name = "ReportedError";
|
|
31
|
-
this.exitCode = exitCodeFor(cause);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
function exitCodeFor(error) {
|
|
35
|
-
if (error instanceof ReportedError) return error.exitCode;
|
|
36
|
-
if (error instanceof CancelledError) return 130;
|
|
37
|
-
if (error instanceof CliError) return error.exitCode;
|
|
38
|
-
return 1;
|
|
39
|
-
}
|
|
40
|
-
function errorMessage(error) {
|
|
41
|
-
return error instanceof Error ? error.message : String(error);
|
|
42
|
-
}
|
|
43
|
-
function errorCode(error) {
|
|
44
|
-
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/prompts/components/PaintContext.ts
|
|
48
|
-
import { createContext, useContext } from "react";
|
|
49
|
-
var PaintContext = createContext(null);
|
|
50
|
-
function usePaint() {
|
|
51
|
-
const paint = useContext(PaintContext);
|
|
52
|
-
if (!paint) throw new Error("usePaint needs a PaintContext provider");
|
|
53
|
-
return paint;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/commands/now/format.ts
|
|
57
|
-
import terminalLink from "terminal-link";
|
|
58
|
-
var LABEL_WIDTH = 14;
|
|
59
|
-
function formatNow(paint, now, at) {
|
|
60
|
-
const sections = sectionsOf(now, at);
|
|
61
|
-
if (sections.length === 0) return `${paint.muted(NOTHING)}
|
|
62
|
-
`;
|
|
63
|
-
return `${sections.map(
|
|
64
|
-
(entries) => entries.flatMap((entry) => entryRows(paint, entry)).map((row) => `${paint.muted(row.label.padEnd(LABEL_WIDTH))}${row.text}`).join("\n")
|
|
65
|
-
).join("\n\n")}
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
var NOTHING = "Nothing to show right now.";
|
|
69
|
-
function sectionsOf(now, at) {
|
|
70
|
-
const sections = [];
|
|
71
|
-
if (now.listening) sections.push([listening(now.listening, at)]);
|
|
72
|
-
if (now.reading?.length) sections.push(now.reading.map(reading));
|
|
73
|
-
if (now.coding) sections.push([coding(now.coding, at)]);
|
|
74
|
-
return sections;
|
|
75
|
-
}
|
|
76
|
-
function entryRows(paint, entry, after = "") {
|
|
77
|
-
const bold = paint.bold(printable(entry.title));
|
|
78
|
-
const linked = /^https:\/\//.test(entry.url) ? terminalLink(bold, printable(entry.url), { fallback: () => bold }) : bold;
|
|
79
|
-
const rows = [{ label: entry.label, text: `${linked}${after}` }];
|
|
80
|
-
if (entry.detail) rows.push({ label: "", text: paint.muted(printable(entry.detail)) });
|
|
81
|
-
return rows;
|
|
82
|
-
}
|
|
83
|
-
function listening(track, at) {
|
|
84
|
-
const played = track.playedAt === null ? null : ago(new Date(track.playedAt), at);
|
|
85
|
-
return {
|
|
86
|
-
label: played === null ? "listening to" : "listened to",
|
|
87
|
-
title: track.title,
|
|
88
|
-
url: track.url,
|
|
89
|
-
detail: played === null ? track.artist : [track.artist, played].join(" \xB7 "),
|
|
90
|
-
playing: played === null
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function reading(book, i) {
|
|
94
|
-
return { label: i === 0 ? "reading" : "", title: book.title, url: book.url, detail: book.author, playing: false };
|
|
95
|
-
}
|
|
96
|
-
function coding(push, at) {
|
|
97
|
-
return {
|
|
98
|
-
label: "pushed to",
|
|
99
|
-
title: push.repo,
|
|
100
|
-
url: push.url,
|
|
101
|
-
detail: [push.message, ago(new Date(push.pushedAt), at)].join(" \xB7 "),
|
|
102
|
-
playing: false
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
var UNITS = [
|
|
106
|
-
["year", 365 * 24 * 3600],
|
|
107
|
-
["month", 30 * 24 * 3600],
|
|
108
|
-
["week", 7 * 24 * 3600],
|
|
109
|
-
["day", 24 * 3600],
|
|
110
|
-
["hour", 3600],
|
|
111
|
-
["minute", 60]
|
|
112
|
-
];
|
|
113
|
-
function ago(then, at) {
|
|
114
|
-
const seconds = (at.getTime() - then.getTime()) / 1e3;
|
|
115
|
-
if (Number.isNaN(seconds)) return "";
|
|
116
|
-
const format = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
117
|
-
for (const [unit, size] of UNITS) {
|
|
118
|
-
if (seconds >= size) return format.format(-Math.floor(seconds / size), unit);
|
|
119
|
-
}
|
|
120
|
-
return "just now";
|
|
121
|
-
}
|
|
122
|
-
function printable(text) {
|
|
123
|
-
return text.replace(new RegExp("\\p{Cc}", "gu"), "");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// src/lib/theme.ts
|
|
127
|
-
import { Chalk, supportsColor, supportsColorStderr } from "chalk";
|
|
128
|
-
var palette = {
|
|
129
|
-
brand: "#264b96",
|
|
130
|
-
accent: "#5c9fd4",
|
|
131
|
-
success: "#3fb950",
|
|
132
|
-
warning: "#f9a73e",
|
|
133
|
-
error: "#e5534b"
|
|
134
|
-
};
|
|
135
|
-
var symbols = {
|
|
136
|
-
start: "\u250C",
|
|
137
|
-
bar: "\u2502",
|
|
138
|
-
end: "\u2514",
|
|
139
|
-
active: "\u25C6",
|
|
140
|
-
done: "\u25C7",
|
|
141
|
-
warning: "\u25B2",
|
|
142
|
-
error: "\u25A0",
|
|
143
|
-
radioOn: "\u25CF",
|
|
144
|
-
radioOff: "\u25CB",
|
|
145
|
-
checkOn: "\u25FC",
|
|
146
|
-
checkOff: "\u25FB",
|
|
147
|
-
tick: "\u2714",
|
|
148
|
-
cross: "\u2716",
|
|
149
|
-
spinner: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"]
|
|
150
|
-
};
|
|
151
|
-
function createPaint(chalk) {
|
|
152
|
-
return {
|
|
153
|
-
accent: chalk.hex(palette.accent),
|
|
154
|
-
success: chalk.hex(palette.success),
|
|
155
|
-
warning: chalk.hex(palette.warning),
|
|
156
|
-
error: chalk.hex(palette.error),
|
|
157
|
-
muted: chalk.gray,
|
|
158
|
-
dim: chalk.dim,
|
|
159
|
-
bold: chalk.bold,
|
|
160
|
-
white: chalk.white,
|
|
161
|
-
inverse: chalk.inverse,
|
|
162
|
-
hex: (color) => chalk.hex(color),
|
|
163
|
-
badge: (text) => chalk.bgHex(palette.brand).hex("#ffffff").bold(` ${text} `)
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function paintFor(stream, { color, env }) {
|
|
167
|
-
const detected = stream === process.stderr ? supportsColorStderr : supportsColor;
|
|
168
|
-
const noColor = Boolean(env.NO_COLOR) && !("FORCE_COLOR" in env);
|
|
169
|
-
return createPaint(new Chalk({ level: !color || noColor || !detected ? 0 : detected.level }));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export {
|
|
173
|
-
palette,
|
|
174
|
-
symbols,
|
|
175
|
-
paintFor,
|
|
176
|
-
CliError,
|
|
177
|
-
UsageError,
|
|
178
|
-
CancelledError,
|
|
179
|
-
ReportedError,
|
|
180
|
-
exitCodeFor,
|
|
181
|
-
errorMessage,
|
|
182
|
-
errorCode,
|
|
183
|
-
PaintContext,
|
|
184
|
-
usePaint,
|
|
185
|
-
LABEL_WIDTH,
|
|
186
|
-
formatNow,
|
|
187
|
-
NOTHING,
|
|
188
|
-
sectionsOf,
|
|
189
|
-
entryRows
|
|
190
|
-
};
|