@osdlc/wayfinder 0.7.1 → 0.7.2
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 +23 -0
- package/README.md +210 -182
- package/SECURITY.md +39 -1
- package/bin/way.js +14 -9
- package/dist/args.d.ts +16 -16
- package/dist/args.js +19 -19
- package/dist/cache.js +3 -4
- package/dist/clean-command.d.ts +18 -18
- package/dist/clean-command.js +35 -36
- package/dist/cli.d.ts +19 -20
- package/dist/cli.js +76 -69
- package/dist/config-command.d.ts +15 -14
- package/dist/config-command.js +63 -59
- package/dist/config.d.ts +135 -130
- package/dist/config.js +156 -149
- package/dist/devlink.d.ts +6 -2
- package/dist/devlink.js +7 -2
- package/dist/guide.js +5 -4
- package/dist/origin-owner.d.ts +7 -2
- package/dist/origin-owner.js +20 -4
- package/dist/providers-command.d.ts +1 -1
- package/dist/providers-command.js +11 -23
- package/dist/serve.d.ts +43 -42
- package/dist/serve.js +251 -258
- package/dist/terminal-text.d.ts +57 -0
- package/dist/terminal-text.js +91 -0
- package/dist/tools.d.ts +4 -4
- package/dist/tools.js +4 -4
- package/dist/trust-command.d.ts +6 -7
- package/dist/trust-command.js +48 -50
- package/dist/trust-store.d.ts +1 -1
- package/dist/tui.d.ts +65 -66
- package/dist/tui.js +124 -130
- package/dist/web/main.js +371 -386
- package/dist/web/page.html +6 -5
- package/dist/web/styles.css +258 -271
- package/package.json +7 -7
package/SECURITY.md
CHANGED
|
@@ -33,11 +33,49 @@ making `way` run code the user did not choose to run are in scope.
|
|
|
33
33
|
- **Tool modules are code.** A module named by `--config` or the user file is
|
|
34
34
|
the user's own choice. One named by the project file loads only when the
|
|
35
35
|
repository is trusted and execution is allowed.
|
|
36
|
+
- **Detection turns off the git config keys that run commands.** Discovery and
|
|
37
|
+
the owner lookup run git with `core.fsmonitor` off. The other keys that run
|
|
38
|
+
commands (hooks, `diff.external`, `filter.*`, `core.sshCommand`,
|
|
39
|
+
`core.pager`) do not apply to the git commands detection runs. git still
|
|
40
|
+
reads the rest of `.git/config`, such as the `origin` URL and `insteadOf`
|
|
41
|
+
rewrites.
|
|
42
|
+
- **Detection runs the git on your PATH, not one in the repository.** Every
|
|
43
|
+
command detection and the owner lookup start is looked up on the absolute
|
|
44
|
+
`PATH` entries only. A relative or empty entry (`bin`, `.`,
|
|
45
|
+
`node_modules/.bin`) is skipped, and on Windows the current folder is not
|
|
46
|
+
searched. An absolute entry is still searched, even one inside the
|
|
47
|
+
repository: direnv's `PATH_add`, mise's `_.path` and `npx` add such
|
|
48
|
+
entries, and each is a choice you made. `way providers` uses the same
|
|
49
|
+
lookup, and a tool found only through a relative entry reads as not
|
|
50
|
+
installed.
|
|
51
|
+
- **Owner trust believes the repository's own git config.** `trust.owners`
|
|
52
|
+
matches the remote URL the repository's `.git/config` reports. That file
|
|
53
|
+
comes with the directory: a folder from an archive or a shared drive can
|
|
54
|
+
name any owner. Owner trust fits clones you made yourself. `trust.paths` is
|
|
55
|
+
the stronger form, since a repository cannot choose where it is on your disk.
|
|
56
|
+
- **Repository text cannot drive the terminal.** Task names, docs, paths and
|
|
57
|
+
config values have their control characters (C0, DEL, C1) and bidi controls
|
|
58
|
+
(U+202A-202E, U+2066-2069) replaced with U+FFFD before the terminal UI,
|
|
59
|
+
`--list`, `query`, `trust`, `config`, `providers`, `dev`, the `--serve`
|
|
60
|
+
summary or stderr prints them. Copied commands get the same text. `--json`,
|
|
61
|
+
`way dev … --json` included, keeps every value exact: C0 is escaped by JSON
|
|
62
|
+
itself, and DEL, C1 and the bidi controls are written as `\u` escapes, so
|
|
63
|
+
the output is safe to print. An error no command catches is printed the
|
|
64
|
+
same way, on one line.
|
|
65
|
+
- **The installed `way` runs its own code.** It hands off to a checkout only
|
|
66
|
+
when `WAY_HOME` (an absolute path) or `way dev link` names one, and only when
|
|
67
|
+
that checkout's `package.json` is named `@osdlc/wayfinder`. `bun` is looked
|
|
68
|
+
up on the absolute `PATH` entries only, like git. The checkout runs
|
|
69
|
+
under Bun with `--no-env-file` and an empty config, so the `.env` and
|
|
70
|
+
`bunfig.toml` of the directory you stand in are not read. A relative `HOME`,
|
|
71
|
+
`XDG_*` or `WAYFINDER_CONFIG` is ignored, so no config, trust store or link
|
|
72
|
+
file is looked up under that directory. The directory you run it in does not
|
|
73
|
+
choose the code that runs.
|
|
36
74
|
- **Tasks run without a shell.** A task is spawned from an argument vector.
|
|
37
75
|
Typed arguments are bound by the task's tool and never replace its binary.
|
|
38
76
|
- **The web view listens on 127.0.0.1.** Any local process and any page the
|
|
39
77
|
browser visits can reach the port. A one-shot boot token and a session token
|
|
40
|
-
|
|
78
|
+
protect every route. `/api/run` takes a task id from the server's own catalog,
|
|
41
79
|
never a command. `/api/trust` refuses when a grant would not apply, so
|
|
42
80
|
`--no-exec` cannot be lifted from the page.
|
|
43
81
|
- **Trust is keyed on the resolved path.** A trusted repository that later
|
package/bin/way.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// The installed `way`. Before running its own code it asks devlink which
|
|
3
|
-
// checkout should answer: `WAY_HOME
|
|
4
|
-
// linked
|
|
5
|
-
//
|
|
3
|
+
// checkout should answer: the one `WAY_HOME` names, or the one `way dev link`
|
|
4
|
+
// linked. A checkout other than this one runs there instead. The cwd is never
|
|
5
|
+
// searched, so a repository you stand in cannot choose the code that runs.
|
|
6
6
|
// Requires the built dist/ (`pnpm run build`).
|
|
7
7
|
import { execSelection, resolve } from '@osdlc/cli-tool/devlink'
|
|
8
8
|
|
|
9
9
|
import { main } from '../dist/cli.js'
|
|
10
10
|
import { WAYFINDER_SPEC, checkoutRoot } from '../dist/devlink.js'
|
|
11
|
+
import { guardedExit, terminalSafe } from '../dist/terminal-text.js'
|
|
11
12
|
|
|
12
13
|
const argv = process.argv.slice(2)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
|
|
14
|
+
// An error nothing caught is printed terminal-safe, not raw by Node.
|
|
15
|
+
process.exitCode = await guardedExit(() => {
|
|
16
|
+
const handedOff = execSelection(
|
|
17
|
+
WAYFINDER_SPEC,
|
|
18
|
+
resolve(WAYFINDER_SPEC, { self: checkoutRoot() }),
|
|
19
|
+
argv,
|
|
20
|
+
{ announce: (line) => process.stderr.write(`${terminalSafe(line)}\n`) },
|
|
21
|
+
)
|
|
22
|
+
return handedOff ?? main(argv)
|
|
23
|
+
})
|
package/dist/args.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Turns typed trailing arguments into argv entries. The terminal's entry line
|
|
3
|
+
* and the page's run bar share it, so the two always split quotes the same way.
|
|
4
4
|
*
|
|
5
|
-
* {@link runArgv} and {@link acceptArgs}
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* {@link runArgv} and {@link acceptArgs} decide what a caller may add to a
|
|
6
|
+
* spawn and what it may not. As pure functions they can be tested. The route
|
|
7
|
+
* they protect cannot, because a successful call hands over the terminal and
|
|
8
|
+
* exits the process.
|
|
9
9
|
*/
|
|
10
10
|
import type { Project, Task } from '@osdlc/system-model/detect';
|
|
11
11
|
/**
|
|
@@ -23,22 +23,22 @@ export declare function runArgv(project: Project, task: Task, args?: readonly st
|
|
|
23
23
|
/**
|
|
24
24
|
* The argument list from an untrusted JSON body, or an empty one.
|
|
25
25
|
*
|
|
26
|
-
* Non-strings are
|
|
27
|
-
*
|
|
26
|
+
* Non-strings are dropped rather than converted. `String(value)` would quietly
|
|
27
|
+
* pass `"[object Object]"` or `"null"` to a spawn as a real argument, and an
|
|
28
28
|
* argument nobody typed is worse than a missing one.
|
|
29
29
|
*/
|
|
30
30
|
export declare function acceptArgs(value: unknown): string[];
|
|
31
31
|
/**
|
|
32
|
-
* Split
|
|
33
|
-
*
|
|
32
|
+
* Split typed arguments into words the way a shell does, and do nothing else
|
|
33
|
+
* a shell does.
|
|
34
34
|
*
|
|
35
35
|
* Quotes group and a backslash escapes the next character. There is no
|
|
36
|
-
* globbing, no variable expansion, no operators
|
|
37
|
-
* goes to an `execvp`-style spawn as separate argv entries, never to a
|
|
38
|
-
* so `*.log` is passed through as the
|
|
39
|
-
* the same rule `argv`
|
|
36
|
+
* globbing, no variable expansion, no operators and no substitution. The
|
|
37
|
+
* result goes to an `execvp`-style spawn as separate argv entries, never to a
|
|
38
|
+
* shell, so `*.log` is passed through as the five characters typed. This is
|
|
39
|
+
* the same rule that keeps `argv` separate from `display`.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* This is not `.split(/\s+/)` for one reason: a quoted `"two words"` must stay
|
|
42
|
+
* one argument.
|
|
43
43
|
*/
|
|
44
44
|
export declare function splitArgs(input: string): string[];
|
package/dist/args.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Turns typed trailing arguments into argv entries. The terminal's entry line
|
|
3
|
+
* and the page's run bar share it, so the two always split quotes the same way.
|
|
4
4
|
*
|
|
5
|
-
* {@link runArgv} and {@link acceptArgs}
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* {@link runArgv} and {@link acceptArgs} decide what a caller may add to a
|
|
6
|
+
* spawn and what it may not. As pure functions they can be tested. The route
|
|
7
|
+
* they protect cannot, because a successful call hands over the terminal and
|
|
8
|
+
* exits the process.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
11
|
* The argv a task runs with: the caller's arguments bound the way the task's
|
|
@@ -30,8 +30,8 @@ export function runArgv(project, task, args = []) {
|
|
|
30
30
|
/**
|
|
31
31
|
* The argument list from an untrusted JSON body, or an empty one.
|
|
32
32
|
*
|
|
33
|
-
* Non-strings are
|
|
34
|
-
*
|
|
33
|
+
* Non-strings are dropped rather than converted. `String(value)` would quietly
|
|
34
|
+
* pass `"[object Object]"` or `"null"` to a spawn as a real argument, and an
|
|
35
35
|
* argument nobody typed is worse than a missing one.
|
|
36
36
|
*/
|
|
37
37
|
export function acceptArgs(value) {
|
|
@@ -40,17 +40,17 @@ export function acceptArgs(value) {
|
|
|
40
40
|
return value.filter((a) => typeof a === 'string');
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Split
|
|
44
|
-
*
|
|
43
|
+
* Split typed arguments into words the way a shell does, and do nothing else
|
|
44
|
+
* a shell does.
|
|
45
45
|
*
|
|
46
46
|
* Quotes group and a backslash escapes the next character. There is no
|
|
47
|
-
* globbing, no variable expansion, no operators
|
|
48
|
-
* goes to an `execvp`-style spawn as separate argv entries, never to a
|
|
49
|
-
* so `*.log` is passed through as the
|
|
50
|
-
* the same rule `argv`
|
|
47
|
+
* globbing, no variable expansion, no operators and no substitution. The
|
|
48
|
+
* result goes to an `execvp`-style spawn as separate argv entries, never to a
|
|
49
|
+
* shell, so `*.log` is passed through as the five characters typed. This is
|
|
50
|
+
* the same rule that keeps `argv` separate from `display`.
|
|
51
51
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
52
|
+
* This is not `.split(/\s+/)` for one reason: a quoted `"two words"` must stay
|
|
53
|
+
* one argument.
|
|
54
54
|
*/
|
|
55
55
|
export function splitArgs(input) {
|
|
56
56
|
const out = [];
|
|
@@ -84,9 +84,9 @@ export function splitArgs(input) {
|
|
|
84
84
|
current += ch;
|
|
85
85
|
started = true;
|
|
86
86
|
}
|
|
87
|
-
// An
|
|
88
|
-
// user
|
|
89
|
-
//
|
|
87
|
+
// An unclosed quote keeps what was typed rather than dropping it. Losing the
|
|
88
|
+
// user's text would be worse than passing a word they can see in the
|
|
89
|
+
// command shown above the run.
|
|
90
90
|
if (started)
|
|
91
91
|
out.push(current);
|
|
92
92
|
return out;
|
package/dist/cache.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { homedir } from 'node:os';
|
|
2
1
|
import { join } from 'node:path';
|
|
3
|
-
import { xdgHome } from '@osdlc/trust-repo';
|
|
2
|
+
import { homeDir, xdgHome } from '@osdlc/trust-repo';
|
|
4
3
|
import { APP, LEGACY_APP } from "./app.js";
|
|
5
4
|
/**
|
|
6
5
|
* Where stored runner probes live: `$XDG_CACHE_HOME/wayfinder`, else
|
|
7
6
|
* `~/.cache/wayfinder`. `@osdlc/system-model` owns the layout inside it.
|
|
8
7
|
*/
|
|
9
|
-
export function cacheDir(env = process.env, home =
|
|
8
|
+
export function cacheDir(env = process.env, home = homeDir()) {
|
|
10
9
|
return join(xdgHome(env, home, 'XDG_CACHE_HOME', '.cache'), APP);
|
|
11
10
|
}
|
|
12
11
|
/** The old waypost cache directory. Never read; `way clean` offers to remove it. */
|
|
13
|
-
export function legacyCacheDir(env = process.env, home =
|
|
12
|
+
export function legacyCacheDir(env = process.env, home = homeDir()) {
|
|
14
13
|
return join(xdgHome(env, home, 'XDG_CACHE_HOME', '.cache'), LEGACY_APP);
|
|
15
14
|
}
|
package/dist/clean-command.d.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `clean` subcommand: the three stores wayfinder keeps outside your
|
|
3
3
|
* repositories (cache, trust, config). `--cache` and `--trust` also clear
|
|
4
|
-
* the old waypost cache and trust store.
|
|
5
|
-
* something.
|
|
4
|
+
* the old waypost cache and trust store. An old store is listed only when it
|
|
5
|
+
* holds something.
|
|
6
6
|
*
|
|
7
7
|
* ## Nothing is removed unless asked
|
|
8
8
|
*
|
|
9
|
-
* Bare `clean`
|
|
10
|
-
* is in it. A `--dry-run` flag would put the safe behaviour behind a
|
|
11
|
-
* forget
|
|
9
|
+
* Bare `clean` only reports: what each store is, where it is, and whether
|
|
10
|
+
* anything is in it. A `--dry-run` flag would put the safe behaviour behind a
|
|
11
|
+
* flag people forget. Instead the flags name what to remove, and with no flag
|
|
12
|
+
* nothing is removed.
|
|
12
13
|
*
|
|
13
14
|
* ## Why `--config` alone needs `--yes`
|
|
14
15
|
*
|
|
15
|
-
* The three stores are not equally
|
|
16
|
-
*
|
|
16
|
+
* The three stores are not equally easy to replace, and the check follows
|
|
17
|
+
* that:
|
|
17
18
|
*
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
* -
|
|
19
|
+
* - The cache is derived. Deleting it costs one slow probe.
|
|
20
|
+
* - The trust store is consent. Deleting it means answering the trust
|
|
21
|
+
* question again for each repository. That is annoying, but nothing is lost.
|
|
22
|
+
* - The config is the only one a person wrote. Nothing regenerates it.
|
|
22
23
|
*
|
|
23
|
-
* So `--config` (and `--all`, which includes it)
|
|
24
|
+
* So `--config` (and `--all`, which includes it) also needs `--yes`.
|
|
24
25
|
*
|
|
25
26
|
* ## What it will not touch
|
|
26
27
|
*
|
|
27
28
|
* Anything inside a repository. `wayfinder.config.json` is a project file that
|
|
28
|
-
* belongs to whoever wrote it,
|
|
29
|
-
*
|
|
30
|
-
* is. Only paths under the user's home (or their XDG overrides) are candidates.
|
|
29
|
+
* belongs to whoever wrote it, not to this tool's data. Only paths under the
|
|
30
|
+
* user's home (or their XDG overrides) are removed.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* `stdout`, `stderr`, `env` and `home` are injected, so a test cannot read or
|
|
33
|
+
* delete the developer's real stores.
|
|
34
34
|
*/
|
|
35
35
|
import { type CliIo } from '@osdlc/cli-tool';
|
|
36
36
|
/** `CliIo` plus the environment this command needs injected. */
|
|
37
37
|
export interface CleanCommandIO extends CliIo {
|
|
38
38
|
/** Defaults to `process.env`. Supplies the XDG overrides. */
|
|
39
39
|
env?: Record<string, string | undefined>;
|
|
40
|
-
/** Defaults to `
|
|
40
|
+
/** Defaults to `homeDir()` from `@osdlc/trust-repo`. The base for every non-XDG path. */
|
|
41
41
|
home?: string;
|
|
42
42
|
}
|
|
43
43
|
export declare function runCleanCommand(toolName: string, argv: string[], io: CleanCommandIO): Promise<number>;
|
package/dist/clean-command.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `clean` subcommand: the three stores wayfinder keeps outside your
|
|
3
3
|
* repositories (cache, trust, config). `--cache` and `--trust` also clear
|
|
4
|
-
* the old waypost cache and trust store.
|
|
5
|
-
* something.
|
|
4
|
+
* the old waypost cache and trust store. An old store is listed only when it
|
|
5
|
+
* holds something.
|
|
6
6
|
*
|
|
7
7
|
* ## Nothing is removed unless asked
|
|
8
8
|
*
|
|
9
|
-
* Bare `clean`
|
|
10
|
-
* is in it. A `--dry-run` flag would put the safe behaviour behind a
|
|
11
|
-
* forget
|
|
9
|
+
* Bare `clean` only reports: what each store is, where it is, and whether
|
|
10
|
+
* anything is in it. A `--dry-run` flag would put the safe behaviour behind a
|
|
11
|
+
* flag people forget. Instead the flags name what to remove, and with no flag
|
|
12
|
+
* nothing is removed.
|
|
12
13
|
*
|
|
13
14
|
* ## Why `--config` alone needs `--yes`
|
|
14
15
|
*
|
|
15
|
-
* The three stores are not equally
|
|
16
|
-
*
|
|
16
|
+
* The three stores are not equally easy to replace, and the check follows
|
|
17
|
+
* that:
|
|
17
18
|
*
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
* -
|
|
19
|
+
* - The cache is derived. Deleting it costs one slow probe.
|
|
20
|
+
* - The trust store is consent. Deleting it means answering the trust
|
|
21
|
+
* question again for each repository. That is annoying, but nothing is lost.
|
|
22
|
+
* - The config is the only one a person wrote. Nothing regenerates it.
|
|
22
23
|
*
|
|
23
|
-
* So `--config` (and `--all`, which includes it)
|
|
24
|
+
* So `--config` (and `--all`, which includes it) also needs `--yes`.
|
|
24
25
|
*
|
|
25
26
|
* ## What it will not touch
|
|
26
27
|
*
|
|
27
28
|
* Anything inside a repository. `wayfinder.config.json` is a project file that
|
|
28
|
-
* belongs to whoever wrote it,
|
|
29
|
-
*
|
|
30
|
-
* is. Only paths under the user's home (or their XDG overrides) are candidates.
|
|
29
|
+
* belongs to whoever wrote it, not to this tool's data. Only paths under the
|
|
30
|
+
* user's home (or their XDG overrides) are removed.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* `stdout`, `stderr`, `env` and `home` are injected, so a test cannot read or
|
|
33
|
+
* delete the developer's real stores.
|
|
34
34
|
*/
|
|
35
35
|
import { readdir, rm, rmdir, stat } from 'node:fs/promises';
|
|
36
|
-
import { homedir } from 'node:os';
|
|
37
36
|
import { dirname } from 'node:path';
|
|
38
37
|
import { BIN } from "./app.js";
|
|
39
38
|
import { cacheDir, legacyCacheDir } from "./cache.js";
|
|
40
39
|
import { LEGACY_TRUST_STORE_TOOL, TRUST_STORE_TOOL, configLocations } from "./config.js";
|
|
41
40
|
import { EXIT } from '@osdlc/cli-tool';
|
|
42
|
-
import { trustStoreDir } from '@osdlc/trust-repo';
|
|
41
|
+
import { homeDir, trustStoreDir } from '@osdlc/trust-repo';
|
|
42
|
+
import { jsonText } from "./terminal-text.js";
|
|
43
43
|
function usage() {
|
|
44
44
|
return `${BIN} clean — remove the data this tool stores outside your repositories
|
|
45
45
|
|
|
@@ -90,9 +90,9 @@ function humanBytes(bytes) {
|
|
|
90
90
|
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
91
91
|
}
|
|
92
92
|
function storesFor(env, home) {
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
93
|
+
// This command touches only the user config path, which does not depend on
|
|
94
|
+
// the root. The project layer is out of scope. `home` is passed as the root
|
|
95
|
+
// because the call needs one and no repository is involved.
|
|
96
96
|
const user = configLocations(home, env, home).user;
|
|
97
97
|
return [
|
|
98
98
|
{
|
|
@@ -128,7 +128,7 @@ function storesFor(env, home) {
|
|
|
128
128
|
{ key: 'config', flag: '--config', what: 'your user configuration', path: user, file: true },
|
|
129
129
|
];
|
|
130
130
|
}
|
|
131
|
-
/** A store's
|
|
131
|
+
/** A store's reported fields. `file` is internal and is left out. */
|
|
132
132
|
function reportOf(store, bytes, removed) {
|
|
133
133
|
return { key: store.key, flag: store.flag, what: store.what, path: store.path, bytes, removed };
|
|
134
134
|
}
|
|
@@ -178,10 +178,9 @@ export async function runCleanCommand(toolName, argv, io) {
|
|
|
178
178
|
return EXIT.ok;
|
|
179
179
|
}
|
|
180
180
|
const env = io.env ?? process.env;
|
|
181
|
-
const home = io.home ??
|
|
181
|
+
const home = io.home ?? homeDir();
|
|
182
182
|
const stores = storesFor(env, home);
|
|
183
|
-
//
|
|
184
|
-
// before anything is removed rather than inside the removal branch.
|
|
183
|
+
// A bare `clean` prints the report and removes nothing.
|
|
185
184
|
if (parsed.chosen.size === 0) {
|
|
186
185
|
const reports = [];
|
|
187
186
|
for (const store of stores) {
|
|
@@ -191,7 +190,7 @@ export async function runCleanCommand(toolName, argv, io) {
|
|
|
191
190
|
reports.push(reportOf(store, bytes, false));
|
|
192
191
|
}
|
|
193
192
|
if (parsed.json) {
|
|
194
|
-
io.stdout(`${
|
|
193
|
+
io.stdout(`${jsonText({ stores: reports }, 2)}\n`);
|
|
195
194
|
return EXIT.ok;
|
|
196
195
|
}
|
|
197
196
|
const lines = [`${toolName} stores three things outside your repositories:\n`];
|
|
@@ -227,9 +226,9 @@ export async function runCleanCommand(toolName, argv, io) {
|
|
|
227
226
|
}
|
|
228
227
|
try {
|
|
229
228
|
await rm(store.path, { recursive: true, force: true });
|
|
230
|
-
// A config file leaves its directory behind. Remove
|
|
231
|
-
//
|
|
232
|
-
//
|
|
229
|
+
// A config file leaves its directory behind. Remove the directory when it
|
|
230
|
+
// is now empty, and leave it when it is not, since a future version may
|
|
231
|
+
// keep other files there.
|
|
233
232
|
if (store.file) {
|
|
234
233
|
const dir = dirname(store.path);
|
|
235
234
|
try {
|
|
@@ -237,7 +236,7 @@ export async function runCleanCommand(toolName, argv, io) {
|
|
|
237
236
|
await rmdir(dir);
|
|
238
237
|
}
|
|
239
238
|
catch {
|
|
240
|
-
// Not
|
|
239
|
+
// Not required. The file is gone, which is what was asked.
|
|
241
240
|
}
|
|
242
241
|
}
|
|
243
242
|
reports.push(reportOf(store, size, true));
|
|
@@ -248,8 +247,8 @@ export async function runCleanCommand(toolName, argv, io) {
|
|
|
248
247
|
}
|
|
249
248
|
catch (err) {
|
|
250
249
|
io.stderr(`${toolName}: could not remove ${store.path}: ${String(err)}\n`);
|
|
251
|
-
//
|
|
252
|
-
//
|
|
250
|
+
// Record the failure and stop. A store that would not delete is a reason
|
|
251
|
+
// to stop deleting the others.
|
|
253
252
|
reports.push(reportOf(store, size, false));
|
|
254
253
|
failed = true;
|
|
255
254
|
break;
|
|
@@ -258,12 +257,12 @@ export async function runCleanCommand(toolName, argv, io) {
|
|
|
258
257
|
// One document, printed once, so a --json caller parses a single object
|
|
259
258
|
// whether the run finished or stopped on a failure.
|
|
260
259
|
if (parsed.json)
|
|
261
|
-
io.stdout(`${
|
|
260
|
+
io.stdout(`${jsonText({ stores: reports }, 2)}\n`);
|
|
262
261
|
if (failed)
|
|
263
262
|
return EXIT.error;
|
|
264
263
|
if (removed > 0 && parsed.chosen.has('trust')) {
|
|
265
|
-
//
|
|
266
|
-
//
|
|
264
|
+
// A side note, not the answer, so under --json it goes to stderr and
|
|
265
|
+
// stdout stays one JSON object.
|
|
267
266
|
const note = 'Trusted repositories will ask again the next time you read them.\n';
|
|
268
267
|
if (parsed.json)
|
|
269
268
|
io.stderr(note);
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `way`: browse and run every task in a repository.
|
|
3
3
|
*
|
|
4
|
-
* wayfinder is
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `--no-exec` opts out.
|
|
4
|
+
* wayfinder's `allowExec` default is `true`. You usually run it in your own
|
|
5
|
+
* repository, and a task browser that cannot see the build graph is of little
|
|
6
|
+
* use. `--no-exec` turns execution off.
|
|
8
7
|
*
|
|
9
|
-
* The default
|
|
10
|
-
* `policyExecGate` combines the configured value
|
|
11
|
-
* user file's `trust.paths`/`trust.owners`
|
|
12
|
-
*
|
|
13
|
-
* this repository. A configured `false` means no
|
|
14
|
-
* repository is.
|
|
8
|
+
* The default alone does not allow execution. The repository must also be
|
|
9
|
+
* trusted. `@osdlc/trust-repo`'s `policyExecGate` combines the configured value
|
|
10
|
+
* with the marker store and the user file's `trust.paths`/`trust.owners`
|
|
11
|
+
* policy. Execution happens only once a person, or a policy they configured,
|
|
12
|
+
* has trusted this repository. A configured `false` means no execution, however
|
|
13
|
+
* trusted the repository is.
|
|
15
14
|
*/
|
|
16
15
|
import { type CliIo } from '@osdlc/cli-tool';
|
|
17
16
|
import { type Catalog, type RunnerCacheState } from '@osdlc/system-model/detect';
|
|
@@ -21,13 +20,13 @@ import { type GuideTool } from './guide.ts';
|
|
|
21
20
|
export declare const GUIDE_TOOL: GuideTool;
|
|
22
21
|
/**
|
|
23
22
|
* Optional fields are absent unless their flag was given, so the config layer
|
|
24
|
-
* can
|
|
25
|
-
* {@link main}, below that layer.
|
|
23
|
+
* can supply the value instead. wayfinder's `allowExec: true` default is
|
|
24
|
+
* applied in {@link main}, below that layer.
|
|
26
25
|
*/
|
|
27
26
|
interface Flags {
|
|
28
27
|
mode: 'tui' | 'serve' | 'json' | 'list' | 'query';
|
|
29
28
|
dir: string;
|
|
30
|
-
/** Answer --json/--list from the stored probe. The UI surfaces do
|
|
29
|
+
/** Answer --json/--list from the stored probe. The UI surfaces always do. */
|
|
31
30
|
cached: boolean;
|
|
32
31
|
allowExec?: boolean;
|
|
33
32
|
open: boolean;
|
|
@@ -36,14 +35,14 @@ interface Flags {
|
|
|
36
35
|
exclude?: string[];
|
|
37
36
|
/**
|
|
38
37
|
* Repeatable: `--exclude-path a --exclude-path b` means both. Passing any
|
|
39
|
-
*
|
|
38
|
+
* replaces the configured list, as with every other array setting.
|
|
40
39
|
*/
|
|
41
40
|
excludePaths?: string[];
|
|
42
41
|
discovery?: 'git' | 'walk' | 'auto';
|
|
43
42
|
help: boolean;
|
|
44
43
|
/**
|
|
45
|
-
* `query`'s search terms
|
|
46
|
-
*
|
|
44
|
+
* `query`'s search terms. Present only for a query. In every other mode the
|
|
45
|
+
* one positional is a directory instead.
|
|
47
46
|
*/
|
|
48
47
|
terms?: string[];
|
|
49
48
|
/** `query --json`: the matching tasks, rather than one command line each. */
|
|
@@ -58,10 +57,10 @@ interface Flags {
|
|
|
58
57
|
toolModules: string[];
|
|
59
58
|
}
|
|
60
59
|
/**
|
|
61
|
-
* `query` is
|
|
62
|
-
* {@link main}),
|
|
63
|
-
*
|
|
64
|
-
*
|
|
60
|
+
* `query` is matched before the flags are parsed, like `config` and `trust`
|
|
61
|
+
* (see {@link main}), because it changes what a positional means: search terms
|
|
62
|
+
* instead of a directory. Every collection flag still applies after it, so it
|
|
63
|
+
* is not a command with its own flag list.
|
|
65
64
|
*/
|
|
66
65
|
export declare function parseArgs(argv: readonly string[], io: CliIo, cwd?: string): Flags | {
|
|
67
66
|
error: string;
|