@osdlc/wayfinder 0.7.3 → 0.8.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/CHANGELOG.md +221 -0
- package/CONTRIBUTING.md +6 -0
- package/README.md +295 -150
- package/SECURITY.md +19 -5
- package/dist/actions.d.ts +23 -0
- package/dist/actions.js +97 -0
- package/dist/app.d.ts +1 -13
- package/dist/app.js +1 -13
- package/dist/args.d.ts +11 -6
- package/dist/args.js +25 -7
- package/dist/cache.d.ts +2 -4
- package/dist/cache.js +5 -10
- package/dist/catalog.d.ts +30 -3
- package/dist/catalog.js +87 -11
- package/dist/clean-command.d.ts +65 -36
- package/dist/clean-command.js +372 -226
- package/dist/cli.d.ts +24 -57
- package/dist/cli.js +139 -568
- package/dist/commands/browse.d.ts +128 -0
- package/dist/commands/browse.js +151 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.js +71 -0
- package/dist/commands/list.d.ts +208 -0
- package/dist/commands/list.js +127 -0
- package/dist/commands/query.d.ts +166 -0
- package/dist/commands/query.js +73 -0
- package/dist/commands/run.d.ts +114 -0
- package/dist/commands/run.js +139 -0
- package/dist/commands/shared.d.ts +152 -0
- package/dist/commands/shared.js +209 -0
- package/dist/config-command.d.ts +27 -43
- package/dist/config-command.js +129 -330
- package/dist/config-keys.d.ts +25 -0
- package/dist/config-keys.js +29 -0
- package/dist/config.d.ts +271 -257
- package/dist/config.js +610 -460
- package/dist/core/copy-text.d.ts +30 -0
- package/dist/core/copy-text.js +50 -0
- package/dist/core/filter.d.ts +55 -0
- package/dist/core/filter.js +59 -0
- package/dist/core/run.d.ts +22 -0
- package/dist/core/run.js +59 -0
- package/dist/core/saved-view.d.ts +59 -0
- package/dist/core/saved-view.js +119 -0
- package/dist/core/session.d.ts +262 -0
- package/dist/core/session.js +589 -0
- package/dist/core/skills.d.ts +53 -0
- package/dist/core/skills.js +54 -0
- package/dist/core/unknowns.d.ts +72 -0
- package/dist/core/unknowns.js +68 -0
- package/dist/devlink.d.ts +3 -0
- package/dist/devlink.js +5 -2
- package/dist/document-schemas.generated.d.ts +22 -0
- package/dist/document-schemas.generated.js +916 -0
- package/dist/documents.d.ts +432 -0
- package/dist/documents.js +163 -0
- package/dist/groups.d.ts +22 -26
- package/dist/groups.js +13 -29
- package/dist/guide.d.ts +26 -13
- package/dist/guide.js +119 -103
- package/dist/index.d.ts +112 -0
- package/dist/index.js +58 -0
- package/dist/keys.d.ts +51 -0
- package/dist/keys.js +273 -0
- package/dist/page.d.ts +18 -8
- package/dist/page.js +28 -17
- package/dist/providers-command.d.ts +81 -20
- package/dist/providers-command.js +33 -75
- package/dist/schema.d.ts +48 -0
- package/dist/schema.js +61 -0
- package/dist/serve/auth.d.ts +46 -0
- package/dist/serve/auth.js +82 -0
- package/dist/serve/catalog-share.d.ts +51 -0
- package/dist/serve/catalog-share.js +116 -0
- package/dist/serve/index.d.ts +98 -0
- package/dist/serve/index.js +251 -0
- package/dist/serve/routes.d.ts +60 -0
- package/dist/serve/routes.js +186 -0
- package/dist/serve/terminal-input.d.ts +50 -0
- package/dist/serve/terminal-input.js +108 -0
- package/dist/skills.d.ts +19 -0
- package/dist/skills.js +54 -0
- package/dist/terminal-text.d.ts +8 -0
- package/dist/terminal-text.js +19 -6
- package/dist/tool-info.d.ts +24 -0
- package/dist/tool-info.js +17 -0
- package/dist/trust-command.d.ts +15 -27
- package/dist/trust-command.js +110 -208
- package/dist/trust-store.d.ts +5 -10
- package/dist/trust-store.js +9 -42
- package/dist/tui/app.d.ts +180 -0
- package/dist/tui/app.js +1278 -0
- package/dist/tui/copy.d.ts +29 -0
- package/dist/tui/copy.js +39 -0
- package/dist/tui/index.d.ts +33 -0
- package/dist/tui/index.js +97 -0
- package/dist/tui/keys-input.d.ts +27 -0
- package/dist/tui/keys-input.js +87 -0
- package/dist/tui/settings.d.ts +94 -0
- package/dist/tui/settings.js +198 -0
- package/dist/tui/style.d.ts +62 -0
- package/dist/tui/style.js +77 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +7 -0
- package/dist/vocabulary.d.ts +89 -0
- package/dist/vocabulary.js +153 -0
- package/dist/web/main.js +1965 -568
- package/dist/web/page.html +39 -33
- package/dist/web/styles.css +457 -329
- package/dist/xdg.d.ts +76 -4
- package/dist/xdg.js +77 -5
- package/package.json +28 -9
- package/schema/config.json +133 -0
- package/dist/http.d.ts +0 -22
- package/dist/http.js +0 -149
- package/dist/origin-owner.d.ts +0 -19
- package/dist/origin-owner.js +0 -85
- package/dist/serve.d.ts +0 -98
- package/dist/serve.js +0 -671
- package/dist/tui.d.ts +0 -177
- package/dist/tui.js +0 -840
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the terminal UI paints text, and how it fits a line to the width.
|
|
3
|
+
*
|
|
4
|
+
* Colors come from `@osdlc/ux` tokens. Text attributes (bold, dim, underline,
|
|
5
|
+
* inverse) are kept apart from color: `NO_COLOR` turns color off, not
|
|
6
|
+
* emphasis, so the selected row and a match stay visible. A state is never
|
|
7
|
+
* shown by color alone; each one also has a text mark (`>`, `[ ]`, `~`, `*`).
|
|
8
|
+
*/
|
|
9
|
+
import { ansiColors, detectColorLevel, displayWidth, fitWidth, } from '@osdlc/ux';
|
|
10
|
+
import { terminalSafe } from "../terminal-text.js";
|
|
11
|
+
const sgr = (on, off) => (s) => `\x1b[${on}m${s}\x1b[${off}m`;
|
|
12
|
+
const none = (s) => s;
|
|
13
|
+
/** The styles for `input`. */
|
|
14
|
+
export function makeStyles(input) {
|
|
15
|
+
const ansi = ansiColors(input.level, input.theme);
|
|
16
|
+
const color = (token) => (s) => {
|
|
17
|
+
const fg = ansi[token].fg;
|
|
18
|
+
return fg === '' ? s : `${fg}${s}\x1b[39m`;
|
|
19
|
+
};
|
|
20
|
+
const attr = (on, off) => (input.attributes ? sgr(on, off) : none);
|
|
21
|
+
const both = (...paints) => (s) => paints.reduceRight((text, p) => p(text), s);
|
|
22
|
+
const bold = attr('1', '22');
|
|
23
|
+
return {
|
|
24
|
+
dim: attr('2', '22'),
|
|
25
|
+
bold,
|
|
26
|
+
accent: color('accent'),
|
|
27
|
+
success: color('status-success'),
|
|
28
|
+
warning: color('status-warning'),
|
|
29
|
+
error: color('status-error'),
|
|
30
|
+
selected: attr('7', '27'),
|
|
31
|
+
match: both(bold, attr('4', '24'), color('accent')),
|
|
32
|
+
note: color('text-secondary'),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The terminal's background, from `COLORFGBG` (`15;0` is light text on a
|
|
37
|
+
* dark ground). Dark when it says nothing.
|
|
38
|
+
*/
|
|
39
|
+
export function terminalTheme(env) {
|
|
40
|
+
const bg = Number.parseInt(env['COLORFGBG']?.split(';').at(-1) ?? '', 10);
|
|
41
|
+
return bg === 7 || bg === 15 ? 'light' : 'dark';
|
|
42
|
+
}
|
|
43
|
+
/** The styles for a stream with this environment and TTY state. */
|
|
44
|
+
export function stylesFor(env, isTTY) {
|
|
45
|
+
return makeStyles({
|
|
46
|
+
level: detectColorLevel({ env, isTTY }),
|
|
47
|
+
theme: terminalTheme(env),
|
|
48
|
+
attributes: isTTY && env['TERM'] !== 'dumb',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Clear to the end of the line. */
|
|
52
|
+
export const CLEAR_EOL = '\x1b[K';
|
|
53
|
+
/** The columns `chunks` take, after {@link terminalSafe}. */
|
|
54
|
+
export function chunksWidth(chunks) {
|
|
55
|
+
return chunks.reduce((n, c) => n + displayWidth(terminalSafe(c.text)), 0);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Compose chunks into one line of at most `width` columns. The text is cut
|
|
59
|
+
* before it is painted, since an escape sequence has no width. Every chunk
|
|
60
|
+
* goes through {@link terminalSafe} first, so repository text never writes a
|
|
61
|
+
* control sequence; only `paint` adds escapes.
|
|
62
|
+
*/
|
|
63
|
+
export function line(chunks, width) {
|
|
64
|
+
let used = 0;
|
|
65
|
+
let out = '';
|
|
66
|
+
for (const chunk of chunks) {
|
|
67
|
+
if (used >= width)
|
|
68
|
+
break;
|
|
69
|
+
let text = terminalSafe(chunk.text);
|
|
70
|
+
const w = displayWidth(text);
|
|
71
|
+
if (used + w > width)
|
|
72
|
+
text = fitWidth(text, width - used);
|
|
73
|
+
used += displayWidth(text);
|
|
74
|
+
out += chunk.paint && text !== '' ? chunk.paint(text) : text;
|
|
75
|
+
}
|
|
76
|
+
return out + CLEAR_EOL;
|
|
77
|
+
}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** wayfinder's version, read from its own package.json. */
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
/**
|
|
4
|
+
* The `version` of the package this module is in. The source and the built
|
|
5
|
+
* `dist/` both sit one level below `package.json`.
|
|
6
|
+
*/
|
|
7
|
+
export const VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words every surface shows a person: the noun for a row, the name of a
|
|
3
|
+
* runner or group, and the one label for each thing wayfinder cannot know.
|
|
4
|
+
* The CLI, the terminal UI, the web view and the JSON documents take their
|
|
5
|
+
* wording from here, so a change happens in one place.
|
|
6
|
+
*
|
|
7
|
+
* Browser-safe: no Node built-in, so the page imports it.
|
|
8
|
+
*/
|
|
9
|
+
import type { ParametersUnknownReason } from '@osdlc/system-model/detect';
|
|
10
|
+
import type { StaleReason } from '@osdlc/system-model/detect';
|
|
11
|
+
export { APP, BIN } from './app.ts';
|
|
12
|
+
/** What one row is called on every surface. */
|
|
13
|
+
export declare const TASK_NOUN: {
|
|
14
|
+
readonly one: "task";
|
|
15
|
+
readonly many: "tasks";
|
|
16
|
+
};
|
|
17
|
+
/** `1 task`, `3 tasks`. */
|
|
18
|
+
export declare function countTasks(n: number): string;
|
|
19
|
+
/** `1 runner`, `3 runners`. */
|
|
20
|
+
export declare function countRunners(n: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* The name a person reads for a runner: the group's name for a synthesized
|
|
23
|
+
* group (`dependencies`, `tools`, `git hooks`), else the runner id. JSON and
|
|
24
|
+
* config keys keep the id.
|
|
25
|
+
*/
|
|
26
|
+
export declare function runnerLabel(runner: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* A task's path as a person reads it: a runner id at its head becomes the
|
|
29
|
+
* runner's label, so `package-manager > . > npm > install` reads
|
|
30
|
+
* `dependencies > . > npm > install`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function displayPath(path: readonly string[], runner: string): string[];
|
|
33
|
+
/** The word for a runner that was not read because reading it means running it. */
|
|
34
|
+
export declare const WITHHELD = "withheld";
|
|
35
|
+
/**
|
|
36
|
+
* Why a runner was withheld: the repository is not trusted, a tool the runner
|
|
37
|
+
* runs has no trust grant while others in the repository have one, or
|
|
38
|
+
* execution is off by a flag or a config file.
|
|
39
|
+
*/
|
|
40
|
+
export type WithheldReason = 'untrusted' | 'tool-untrusted' | 'exec-off';
|
|
41
|
+
/**
|
|
42
|
+
* What turned execution off: the `--no-exec` flag, or `allowExec: false` in
|
|
43
|
+
* the user or the project config.
|
|
44
|
+
*/
|
|
45
|
+
export type ExecOffSource = 'flag' | 'user' | 'project';
|
|
46
|
+
/** Why execution is off, in words: `--no-exec was given`. */
|
|
47
|
+
export declare function execOffLabel(source: ExecOffSource | undefined): string;
|
|
48
|
+
/**
|
|
49
|
+
* `withheld: this repository is not trusted`. For `tool-untrusted` with the
|
|
50
|
+
* missing tool ids: `withheld: mise is not trusted`. For `exec-off` with what
|
|
51
|
+
* turned it off: `withheld: --no-exec was given`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function withheldLabel(reason: WithheldReason, missing?: readonly string[], execOff?: ExecOffSource): string;
|
|
54
|
+
/** What a tool with no single language reports as its language. */
|
|
55
|
+
export declare const ANY_LANGUAGE = "any language";
|
|
56
|
+
/**
|
|
57
|
+
* The language a person reads for a tool's ecosystem id: `node` is
|
|
58
|
+
* `JavaScript`. An id with no entry is shown as it is. No ecosystem is
|
|
59
|
+
* {@link ANY_LANGUAGE}: make, just and moon serve every language.
|
|
60
|
+
*/
|
|
61
|
+
export declare function languageLabel(ecosystem: string | null | undefined): string;
|
|
62
|
+
/** What the Skills group's rows are called. */
|
|
63
|
+
export declare const SKILL_NOUN: {
|
|
64
|
+
readonly one: "skill";
|
|
65
|
+
readonly many: "skills";
|
|
66
|
+
};
|
|
67
|
+
/** `1 skill`, `3 skills`. */
|
|
68
|
+
export declare function countSkills(n: number): string;
|
|
69
|
+
/** The label for a task that uses an editor variable: it cannot run outside the editor. */
|
|
70
|
+
export declare const EDITOR_VARIABLE_LABEL = "cannot run here: the task uses an editor variable";
|
|
71
|
+
/**
|
|
72
|
+
* The label for a task whose parameters could not be read. An editor
|
|
73
|
+
* variable is not a gap in what is known: the task cannot run here at all,
|
|
74
|
+
* and the label says that ({@link EDITOR_VARIABLE_LABEL}).
|
|
75
|
+
*/
|
|
76
|
+
export declare function parametersUnknownLabel(reason: ParametersUnknownReason): string;
|
|
77
|
+
/** `stale: its files changed, 3m old`. */
|
|
78
|
+
export declare function staleLabel(reason: StaleReason | undefined, ageMs: number | undefined): string;
|
|
79
|
+
/** The label for a runner with nothing stored. */
|
|
80
|
+
export declare const NOT_CACHED = "not cached";
|
|
81
|
+
/** `just is not installed`. */
|
|
82
|
+
export declare function missingBinaryLabel(binary: string): string;
|
|
83
|
+
/** `probed in 1.2s`, for a runner read just now. */
|
|
84
|
+
export declare function probeTimeLabel(ms: number): string;
|
|
85
|
+
/**
|
|
86
|
+
* What a refresh of a runner usually costs, for a cache note: `refresh
|
|
87
|
+
* usually about 2.0s`, or that nothing has been measured here yet.
|
|
88
|
+
*/
|
|
89
|
+
export declare function refreshCostLabel(estimateMs: number | null): string;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words every surface shows a person: the noun for a row, the name of a
|
|
3
|
+
* runner or group, and the one label for each thing wayfinder cannot know.
|
|
4
|
+
* The CLI, the terminal UI, the web view and the JSON documents take their
|
|
5
|
+
* wording from here, so a change happens in one place.
|
|
6
|
+
*
|
|
7
|
+
* Browser-safe: no Node built-in, so the page imports it.
|
|
8
|
+
*/
|
|
9
|
+
import { groupOf } from '@osdlc/system-model/groups';
|
|
10
|
+
import { humanAge, humanMs } from '@osdlc/system-model/duration';
|
|
11
|
+
export { APP, BIN } from "./app.js";
|
|
12
|
+
/** What one row is called on every surface. */
|
|
13
|
+
export const TASK_NOUN = { one: 'task', many: 'tasks' };
|
|
14
|
+
/** `1 task`, `3 tasks`. */
|
|
15
|
+
export function countTasks(n) {
|
|
16
|
+
return `${n} ${n === 1 ? TASK_NOUN.one : TASK_NOUN.many}`;
|
|
17
|
+
}
|
|
18
|
+
/** `1 runner`, `3 runners`. */
|
|
19
|
+
export function countRunners(n) {
|
|
20
|
+
return `${n} runner${n === 1 ? '' : 's'}`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The name a person reads for a runner: the group's name for a synthesized
|
|
24
|
+
* group (`dependencies`, `tools`, `git hooks`), else the runner id. JSON and
|
|
25
|
+
* config keys keep the id.
|
|
26
|
+
*/
|
|
27
|
+
export function runnerLabel(runner) {
|
|
28
|
+
const group = groupOf(runner);
|
|
29
|
+
return group.runner === runner ? group.title.toLowerCase() : runner;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A task's path as a person reads it: a runner id at its head becomes the
|
|
33
|
+
* runner's label, so `package-manager > . > npm > install` reads
|
|
34
|
+
* `dependencies > . > npm > install`.
|
|
35
|
+
*/
|
|
36
|
+
export function displayPath(path, runner) {
|
|
37
|
+
return path[0] === runner ? [runnerLabel(runner), ...path.slice(1)] : [...path];
|
|
38
|
+
}
|
|
39
|
+
/** The word for a runner that was not read because reading it means running it. */
|
|
40
|
+
export const WITHHELD = 'withheld';
|
|
41
|
+
const WITHHELD_REASONS = {
|
|
42
|
+
untrusted: 'this repository is not trusted',
|
|
43
|
+
'tool-untrusted': 'a tool it runs is not trusted',
|
|
44
|
+
'exec-off': 'execution is off',
|
|
45
|
+
};
|
|
46
|
+
/** `a`, `a and b`, `a, b and c`. */
|
|
47
|
+
function listWords(words) {
|
|
48
|
+
if (words.length <= 1)
|
|
49
|
+
return words.join('');
|
|
50
|
+
return `${words.slice(0, -1).join(', ')} and ${words.at(-1)}`;
|
|
51
|
+
}
|
|
52
|
+
const EXEC_OFF = {
|
|
53
|
+
flag: '--no-exec was given',
|
|
54
|
+
user: 'allowExec is false in your user config',
|
|
55
|
+
project: 'allowExec is false in this project',
|
|
56
|
+
};
|
|
57
|
+
/** Why execution is off, in words: `--no-exec was given`. */
|
|
58
|
+
export function execOffLabel(source) {
|
|
59
|
+
return source === undefined ? WITHHELD_REASONS['exec-off'] : EXEC_OFF[source];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `withheld: this repository is not trusted`. For `tool-untrusted` with the
|
|
63
|
+
* missing tool ids: `withheld: mise is not trusted`. For `exec-off` with what
|
|
64
|
+
* turned it off: `withheld: --no-exec was given`.
|
|
65
|
+
*/
|
|
66
|
+
export function withheldLabel(reason, missing = [], execOff) {
|
|
67
|
+
if (reason === 'tool-untrusted' && missing.length > 0) {
|
|
68
|
+
return `${WITHHELD}: ${listWords(missing)} ${missing.length === 1 ? 'is' : 'are'} not trusted`;
|
|
69
|
+
}
|
|
70
|
+
if (reason === 'exec-off')
|
|
71
|
+
return `${WITHHELD}: ${execOffLabel(execOff)}`;
|
|
72
|
+
return `${WITHHELD}: ${WITHHELD_REASONS[reason]}`;
|
|
73
|
+
}
|
|
74
|
+
/** What a tool with no single language reports as its language. */
|
|
75
|
+
export const ANY_LANGUAGE = 'any language';
|
|
76
|
+
const LANGUAGES = {
|
|
77
|
+
node: 'JavaScript',
|
|
78
|
+
deno: 'JavaScript',
|
|
79
|
+
python: 'Python',
|
|
80
|
+
rust: 'Rust',
|
|
81
|
+
go: 'Go',
|
|
82
|
+
ruby: 'Ruby',
|
|
83
|
+
php: 'PHP',
|
|
84
|
+
jvm: 'Java',
|
|
85
|
+
dotnet: '.NET',
|
|
86
|
+
swift: 'Swift',
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The language a person reads for a tool's ecosystem id: `node` is
|
|
90
|
+
* `JavaScript`. An id with no entry is shown as it is. No ecosystem is
|
|
91
|
+
* {@link ANY_LANGUAGE}: make, just and moon serve every language.
|
|
92
|
+
*/
|
|
93
|
+
export function languageLabel(ecosystem) {
|
|
94
|
+
if (ecosystem === null || ecosystem === undefined)
|
|
95
|
+
return ANY_LANGUAGE;
|
|
96
|
+
return LANGUAGES[ecosystem] ?? ecosystem;
|
|
97
|
+
}
|
|
98
|
+
/** What the Skills group's rows are called. */
|
|
99
|
+
export const SKILL_NOUN = { one: 'skill', many: 'skills' };
|
|
100
|
+
/** `1 skill`, `3 skills`. */
|
|
101
|
+
export function countSkills(n) {
|
|
102
|
+
return `${n} ${n === 1 ? SKILL_NOUN.one : SKILL_NOUN.many}`;
|
|
103
|
+
}
|
|
104
|
+
const PARAMETERS_UNKNOWN = {
|
|
105
|
+
'exec-withheld': 'reading them needs execution, which is withheld',
|
|
106
|
+
'tool-missing': 'the tool is not installed',
|
|
107
|
+
'tool-failed': 'the tool could not list them',
|
|
108
|
+
'not-read': 'this runner does not read them',
|
|
109
|
+
};
|
|
110
|
+
/** The label for a task that uses an editor variable: it cannot run outside the editor. */
|
|
111
|
+
export const EDITOR_VARIABLE_LABEL = 'cannot run here: the task uses an editor variable';
|
|
112
|
+
/**
|
|
113
|
+
* The label for a task whose parameters could not be read. An editor
|
|
114
|
+
* variable is not a gap in what is known: the task cannot run here at all,
|
|
115
|
+
* and the label says that ({@link EDITOR_VARIABLE_LABEL}).
|
|
116
|
+
*/
|
|
117
|
+
export function parametersUnknownLabel(reason) {
|
|
118
|
+
return reason === 'editor-variable'
|
|
119
|
+
? EDITOR_VARIABLE_LABEL
|
|
120
|
+
: `parameters unknown: ${PARAMETERS_UNKNOWN[reason]}`;
|
|
121
|
+
}
|
|
122
|
+
const STALE_REASONS = {
|
|
123
|
+
changed: 'its files changed',
|
|
124
|
+
'max-age': 'it is past its age limit',
|
|
125
|
+
excludes: 'the excluded paths changed',
|
|
126
|
+
exec: 'it was read with another execution setting',
|
|
127
|
+
version: 'another version read it',
|
|
128
|
+
tool: 'the tool changed',
|
|
129
|
+
};
|
|
130
|
+
/** `stale: its files changed, 3m old`. */
|
|
131
|
+
export function staleLabel(reason, ageMs) {
|
|
132
|
+
const why = reason === undefined ? '' : `${STALE_REASONS[reason]}, `;
|
|
133
|
+
return `stale: ${why}${humanAge(ageMs)}`;
|
|
134
|
+
}
|
|
135
|
+
/** The label for a runner with nothing stored. */
|
|
136
|
+
export const NOT_CACHED = 'not cached';
|
|
137
|
+
/** `just is not installed`. */
|
|
138
|
+
export function missingBinaryLabel(binary) {
|
|
139
|
+
return `${binary} is not installed`;
|
|
140
|
+
}
|
|
141
|
+
/** `probed in 1.2s`, for a runner read just now. */
|
|
142
|
+
export function probeTimeLabel(ms) {
|
|
143
|
+
return `probed in ${humanMs(ms)}`;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* What a refresh of a runner usually costs, for a cache note: `refresh
|
|
147
|
+
* usually about 2.0s`, or that nothing has been measured here yet.
|
|
148
|
+
*/
|
|
149
|
+
export function refreshCostLabel(estimateMs) {
|
|
150
|
+
return estimateMs === null
|
|
151
|
+
? 'refresh cost not measured here yet'
|
|
152
|
+
: `refresh usually about ${humanMs(estimateMs)}`;
|
|
153
|
+
}
|