@navbook/cli 0.3.0 → 0.5.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/dist/args.d.ts +28 -0
- package/dist/args.js +48 -0
- package/dist/args.js.map +1 -0
- package/dist/commands/complete.d.ts +10 -0
- package/dist/commands/complete.js +59 -51
- package/dist/commands/complete.js.map +1 -1
- package/dist/commands/compose.d.ts +35 -0
- package/dist/commands/doctor.d.ts +15 -0
- package/dist/commands/entity.d.ts +73 -0
- package/dist/commands/entity.js +59 -44
- package/dist/commands/entity.js.map +1 -1
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/install.d.ts +17 -0
- package/dist/commands/install.js +6 -3
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/issue.d.ts +35 -0
- package/dist/commands/issue.js +4 -5
- package/dist/commands/issue.js.map +1 -1
- package/dist/commands/plugin.d.ts +36 -0
- package/dist/commands/plugin.js +386 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/policy.d.ts +58 -0
- package/dist/commands/policy.js +28 -2
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/pr-elsewhere.d.ts +40 -0
- package/dist/commands/pr-elsewhere.js +209 -0
- package/dist/commands/pr-elsewhere.js.map +1 -0
- package/dist/commands/pr.d.ts +69 -0
- package/dist/commands/pr.js +132 -68
- package/dist/commands/pr.js.map +1 -1
- package/dist/context.d.ts +42 -0
- package/dist/context.js +2 -0
- package/dist/context.js.map +1 -1
- package/dist/editor.d.ts +23 -0
- package/dist/editor.js +4 -0
- package/dist/editor.js.map +1 -1
- package/dist/errors.d.ts +17 -0
- package/dist/install/completions.d.ts +19 -0
- package/dist/install/hook.d.ts +32 -0
- package/dist/install/hook.js +48 -4
- package/dist/install/hook.js.map +1 -1
- package/dist/main.d.ts +21 -0
- package/dist/main.js +112 -8
- package/dist/main.js.map +1 -1
- package/dist/plugins/commands.d.ts +69 -0
- package/dist/plugins/commands.js +148 -0
- package/dist/plugins/commands.js.map +1 -0
- package/dist/plugins/hint.d.ts +23 -0
- package/dist/plugins/hint.js +65 -0
- package/dist/plugins/hint.js.map +1 -0
- package/dist/plugins/host.d.ts +125 -0
- package/dist/plugins/host.js +18 -0
- package/dist/plugins/host.js.map +1 -0
- package/dist/plugins/loader.d.ts +54 -0
- package/dist/plugins/loader.js +165 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/resolve.d.ts +50 -0
- package/dist/plugins/resolve.js +134 -0
- package/dist/plugins/resolve.js.map +1 -0
- package/dist/plugins/runtime.d.ts +69 -0
- package/dist/plugins/runtime.js +256 -0
- package/dist/plugins/runtime.js.map +1 -0
- package/dist/plugins/store.d.ts +96 -0
- package/dist/plugins/store.js +186 -0
- package/dist/plugins/store.js.map +1 -0
- package/dist/program.d.ts +49 -0
- package/dist/program.js +353 -114
- package/dist/program.js.map +1 -1
- package/dist/prompt.d.ts +31 -0
- package/dist/render/colors.d.ts +13 -0
- package/dist/render/detail.d.ts +22 -0
- package/dist/render/table.d.ts +32 -0
- package/dist/render/table.js +123 -13
- package/dist/render/table.js.map +1 -1
- package/dist/sort.d.ts +27 -0
- package/package.json +9 -2
- package/dist/commands/feature.js +0 -202
- package/dist/commands/feature.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nav install` / `nav uninstall` — spec 04 §4.1, §4.3, §4.5.
|
|
3
|
+
*
|
|
4
|
+
* Everything that touches the user's environment lives here, and nothing
|
|
5
|
+
* happens without printing the exact action first: the `git config` command to
|
|
6
|
+
* be run, the hook path, the completions file.
|
|
7
|
+
*/
|
|
8
|
+
import type { Ctx } from "../context.ts";
|
|
9
|
+
export interface InstallOptions {
|
|
10
|
+
alias?: string | boolean;
|
|
11
|
+
hooks?: boolean;
|
|
12
|
+
completions?: string | boolean;
|
|
13
|
+
mergeConfig?: boolean;
|
|
14
|
+
yes?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function cmdInstall(ctx: Ctx, opts: InstallOptions): void;
|
|
17
|
+
export declare function cmdUninstall(ctx: Ctx, opts: InstallOptions): void;
|
package/dist/commands/install.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { ALIAS_DEFAULT, aliasCommand, DIRECTORY_RENAMES_KEY, git, readGlobal, readLocal, setLocal, unsetGlobal, unsetLocal, } from "@navbook/core";
|
|
9
9
|
import { fail } from "../errors.js";
|
|
10
10
|
import { completionNote, completionPath, completionScript, detectShell, installCompletions, isShell, uninstallCompletions, } from "../install/completions.js";
|
|
11
|
-
import { hookPath, installHook, isInstalled, uninstallHook } from "../install/hook.js";
|
|
11
|
+
import { hookPath, hookState, installHook, isInstalled, uninstallHook } from "../install/hook.js";
|
|
12
12
|
import { confirmAndPerform } from "../prompt.js";
|
|
13
13
|
/** True when the user asked for specific pieces rather than "everything". */
|
|
14
14
|
function isSelective(opts) {
|
|
@@ -65,12 +65,15 @@ export function cmdInstall(ctx, opts) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
if (!selective || opts.hooks !== undefined) {
|
|
68
|
-
|
|
68
|
+
const state = hookState(ctx.repoRoot);
|
|
69
|
+
if (state === "current") {
|
|
69
70
|
notes.push("the pre-commit hook is already installed");
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
72
73
|
actions.push({
|
|
73
|
-
description:
|
|
74
|
+
description: state === "outdated"
|
|
75
|
+
? `update the navbook block in ${hookPath(ctx.repoRoot)} to this nav's`
|
|
76
|
+
: `append the navbook block to ${hookPath(ctx.repoRoot)}`,
|
|
74
77
|
perform: () => installHook(ctx.repoRoot),
|
|
75
78
|
});
|
|
76
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,GAAG,EACH,UAAU,EACV,SAAS,EACT,QAAQ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K,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC;YACX,WAAW,EAAE,UAAU,IAAI,sBAAsB;YACjD,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,oBAAoB,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC;SACzD,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nav issue <verb>` — spec 04 §4.3.
|
|
3
|
+
*/
|
|
4
|
+
import type { Ctx } from "../context.ts";
|
|
5
|
+
import type { GlobalFlags } from "./entity.ts";
|
|
6
|
+
export interface IssueOpenOptions extends GlobalFlags {
|
|
7
|
+
message?: string;
|
|
8
|
+
label?: string[];
|
|
9
|
+
assignee?: string[];
|
|
10
|
+
milestone?: string;
|
|
11
|
+
rank?: number;
|
|
12
|
+
deadline?: string;
|
|
13
|
+
parent?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Frontmatter a plugin contributed, from an option it declared (§2.12).
|
|
16
|
+
*
|
|
17
|
+
* Written by the same composer that writes the format's own keys, so a
|
|
18
|
+
* plugin's value lands in the file exactly as a built-in one would.
|
|
19
|
+
*/
|
|
20
|
+
ext?: Record<string, string | readonly string[]>;
|
|
21
|
+
}
|
|
22
|
+
export declare function cmdIssueOpen(ctx: Ctx, title: string, opts: IssueOpenOptions): void;
|
|
23
|
+
export interface IssueLinkOptions extends GlobalFlags {
|
|
24
|
+
parent: string;
|
|
25
|
+
force?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* File one issue under another — spec 04 §4.3.
|
|
29
|
+
*
|
|
30
|
+
* An issue that already has a parent is being moved, not merely linked, and
|
|
31
|
+
* that changes a structure somebody else may be reading, so it is confirmed
|
|
32
|
+
* first. As everywhere else, an unanswerable question counts as "no".
|
|
33
|
+
*/
|
|
34
|
+
export declare function cmdIssueLink(ctx: Ctx, prefix: string, opts: IssueLinkOptions): void;
|
|
35
|
+
export declare function cmdIssueUnlink(ctx: Ctx, prefix: string, opts: GlobalFlags): void;
|
package/dist/commands/issue.js
CHANGED
|
@@ -10,9 +10,8 @@ export function cmdIssueOpen(ctx, title, opts) {
|
|
|
10
10
|
fail("an issue needs a title");
|
|
11
11
|
// Refused here rather than left to the file's own validation, for the reason
|
|
12
12
|
// `--parent` is resolved here: being told a flag will not do is worth much
|
|
13
|
-
// more before an editor has been filled in than after.
|
|
14
|
-
|
|
15
|
-
fail("--rank must be a number");
|
|
13
|
+
// more before an editor has been filled in than after. `--rank` is refused
|
|
14
|
+
// earlier still, by its parser (args.ts).
|
|
16
15
|
if (opts.deadline !== undefined && !isCalendarDate(opts.deadline)) {
|
|
17
16
|
fail("--deadline must be a calendar date, as YYYY-MM-DD");
|
|
18
17
|
}
|
|
@@ -32,12 +31,12 @@ export function cmdIssueOpen(ctx, title, opts) {
|
|
|
32
31
|
labels: opts.label,
|
|
33
32
|
assignee: opts.assignee,
|
|
34
33
|
milestone: opts.milestone,
|
|
35
|
-
|
|
34
|
+
...(opts.ext ? { ext: opts.ext } : {}),
|
|
36
35
|
rank: opts.rank,
|
|
37
36
|
deadline: opts.deadline,
|
|
38
37
|
parent: parent?.id,
|
|
39
38
|
}),
|
|
40
|
-
validate: validateIssue,
|
|
39
|
+
validate: (parsed) => validateIssue(parsed, ctx.ext),
|
|
41
40
|
});
|
|
42
41
|
const result = openIssue(ctx, { content: composed.content, fallbackTitle: title }, { commit: opts.commit });
|
|
43
42
|
const { id, dirPath, run } = result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../src/commands/issue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,YAAY,EACZ,aAAa,EAC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U,KAAK,CAAC,EAAE,WAAW,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;IAC9E,2EAA2E;IAC3E,sEAAsE;IACtE,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC5C,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,KAAK,CAAC,EAAE,0BAA0B,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;IACjG,CAAC;IACD,IAAI,IAAI,CAAC,MAAM;QAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAQ,EAAE,MAAc,EAAE,IAAiB;IACxE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,GAAG,CAAC,MAAM,CAAC,KAAK,CACd,QAAQ,KAAK,SAAS;QACpB,CAAC,CAAC,aAAa,KAAK,CAAC,EAAE,IAAI;QAC3B,CAAC,CAAC,aAAa,KAAK,CAAC,EAAE,UAAU,QAAQ,IAAI,CAChD,CAAC;IACF,IAAI,IAAI,CAAC,MAAM;QAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nav plugin install | remove | update | list` — spec 04 §4.3.
|
|
3
|
+
*
|
|
4
|
+
* The verbs that put a plugin on a machine, and the one place in Navbook that
|
|
5
|
+
* fetches anything. Two rules shape all of it:
|
|
6
|
+
*
|
|
7
|
+
* - **Installing is explicit.** `install` with no argument reads the
|
|
8
|
+
* repository's declaration and offers to install what is missing; it never
|
|
9
|
+
* acts on it without being told. The declaration says what a tree contains,
|
|
10
|
+
* not what this machine should run.
|
|
11
|
+
* - **What arrives is checked.** npm will happily install any package by that
|
|
12
|
+
* name. Before a package is recorded as a plugin, its name, its keyword and
|
|
13
|
+
* its manifest are checked, and a package that fails is uninstalled again
|
|
14
|
+
* rather than left in a store that claims it is a plugin.
|
|
15
|
+
*/
|
|
16
|
+
import type { Ctx } from "../context.ts";
|
|
17
|
+
import { type IndexedPlugin } from "../plugins/store.ts";
|
|
18
|
+
export interface PluginInstallOptions {
|
|
19
|
+
yes?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface PluginListOptions {
|
|
22
|
+
json?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Install plugins, or the ones the repository declares and this machine lacks.
|
|
26
|
+
*
|
|
27
|
+
* The npm command is printed before it runs, so what the user agrees to is the
|
|
28
|
+
* command rather than a summary of it — the `nav install` rule (spec 04 §4.3).
|
|
29
|
+
*/
|
|
30
|
+
export declare function cmdPluginInstall(ctx: Ctx, names: string[], opts: PluginInstallOptions): void;
|
|
31
|
+
export declare function cmdPluginRemove(ctx: Ctx, names: string[], opts: PluginInstallOptions): void;
|
|
32
|
+
export declare function cmdPluginUpdate(ctx: Ctx, names: string[], opts: PluginInstallOptions): void;
|
|
33
|
+
export declare function cmdPluginList(ctx: Ctx, opts: PluginListOptions): void;
|
|
34
|
+
/** Names in the store's `node_modules`, for a caller that wants to look. */
|
|
35
|
+
export declare function installedNames(env: NodeJS.ProcessEnv): string[];
|
|
36
|
+
export type { IndexedPlugin };
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nav plugin install | remove | update | list` — spec 04 §4.3.
|
|
3
|
+
*
|
|
4
|
+
* The verbs that put a plugin on a machine, and the one place in Navbook that
|
|
5
|
+
* fetches anything. Two rules shape all of it:
|
|
6
|
+
*
|
|
7
|
+
* - **Installing is explicit.** `install` with no argument reads the
|
|
8
|
+
* repository's declaration and offers to install what is missing; it never
|
|
9
|
+
* acts on it without being told. The declaration says what a tree contains,
|
|
10
|
+
* not what this machine should run.
|
|
11
|
+
* - **What arrives is checked.** npm will happily install any package by that
|
|
12
|
+
* name. Before a package is recorded as a plugin, its name, its keyword and
|
|
13
|
+
* its manifest are checked, and a package that fails is uninstalled again
|
|
14
|
+
* rather than left in a store that claims it is a plugin.
|
|
15
|
+
*/
|
|
16
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
17
|
+
import { join, resolve } from "node:path";
|
|
18
|
+
import { expandPluginName, hasPluginKeyword, isPluginPackageName } from "@navbook/core";
|
|
19
|
+
import { fail } from "../errors.js";
|
|
20
|
+
import { resolvePlugins } from "../plugins/resolve.js";
|
|
21
|
+
import { installCommand, npmInstall, npmRemove, packageDir, readIndex, readPluginAt, storeDependencies, storeDir, writeIndex, } from "../plugins/store.js";
|
|
22
|
+
import { confirmAndPerform } from "../prompt.js";
|
|
23
|
+
/**
|
|
24
|
+
* Install plugins, or the ones the repository declares and this machine lacks.
|
|
25
|
+
*
|
|
26
|
+
* The npm command is printed before it runs, so what the user agrees to is the
|
|
27
|
+
* command rather than a summary of it — the `nav install` rule (spec 04 §4.3).
|
|
28
|
+
*/
|
|
29
|
+
export function cmdPluginInstall(ctx, names, opts) {
|
|
30
|
+
const choices = names.length > 0 ? names.map((name) => resolveName(ctx, name)) : declared(ctx).map((n) => [n]);
|
|
31
|
+
const wanted = choices.flat();
|
|
32
|
+
if (wanted.length === 0) {
|
|
33
|
+
ctx.stdout.write(ctx.hasNavbook
|
|
34
|
+
? "Nothing to do: every plugin this repository declares is installed.\n"
|
|
35
|
+
: "Nothing to do: name a plugin to install.\n");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// What the store held before npm ran. Comparing it with what it holds after
|
|
39
|
+
// is the only reliable account of what this install changed: a typed spec
|
|
40
|
+
// is not a directory name (`@navbook/plugin-kb@2.0.0`, a tarball, a folder),
|
|
41
|
+
// and a new version of a plugin already installed adds no new name.
|
|
42
|
+
const before = storeDependencies(ctx.env);
|
|
43
|
+
// The specs npm was actually given: a short name's fallback only when the
|
|
44
|
+
// first name was not found, so a plugin installed long ago under the other
|
|
45
|
+
// name is not reported as installed by this run.
|
|
46
|
+
const ran = [];
|
|
47
|
+
const agreed = confirmAndPerform(ctx, {
|
|
48
|
+
title: "nav plugin install will:",
|
|
49
|
+
actions: installActions(ctx, choices, ran),
|
|
50
|
+
assumeYes: opts.yes,
|
|
51
|
+
});
|
|
52
|
+
if (!agreed)
|
|
53
|
+
return;
|
|
54
|
+
const index = readIndex(ctx.env) ?? { version: 1, plugins: {} };
|
|
55
|
+
// What npm actually installed, by its real name: every dependency this run
|
|
56
|
+
// added or changed, plus any it left as it was but was asked for by name or
|
|
57
|
+
// path (a reinstall of the same version, or of a folder rebuilt in place).
|
|
58
|
+
// Only those: the store's manifest lists everything it has, and reporting a
|
|
59
|
+
// plugin installed months ago as installed now would be a lie in the output
|
|
60
|
+
// of a command that installed something else.
|
|
61
|
+
const after = storeDependencies(ctx.env);
|
|
62
|
+
const resolved = new Set(Object.entries(after)
|
|
63
|
+
.filter(([name, saved]) => before[name] !== saved || ran.some((spec) => asksFor(ctx, spec, name, saved)))
|
|
64
|
+
.map(([name]) => name));
|
|
65
|
+
const kept = [];
|
|
66
|
+
const rejected = [];
|
|
67
|
+
for (const name of resolved) {
|
|
68
|
+
const problem = record(ctx, index, name);
|
|
69
|
+
if (problem === null)
|
|
70
|
+
kept.push(name);
|
|
71
|
+
else {
|
|
72
|
+
rejected.push(name);
|
|
73
|
+
ctx.stderr.write(`nav: ${problem}\n`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (rejected.length > 0) {
|
|
77
|
+
// A package that is not a plugin must not be left in the store looking
|
|
78
|
+
// like one. Removing it is the only way `nav plugin list` stays truthful —
|
|
79
|
+
// and that includes the index entry of a plugin it replaced.
|
|
80
|
+
npmRemove(ctx.env, rejected);
|
|
81
|
+
for (const name of rejected)
|
|
82
|
+
delete index.plugins[name];
|
|
83
|
+
}
|
|
84
|
+
writeIndex(ctx.env, index);
|
|
85
|
+
for (const name of kept) {
|
|
86
|
+
const plugin = index.plugins[name];
|
|
87
|
+
ctx.stdout.write(`Installed ${name}@${plugin?.version ?? "?"}\n`);
|
|
88
|
+
}
|
|
89
|
+
if (kept.length > 0 && ctx.hasNavbook) {
|
|
90
|
+
const undeclaredNow = kept.filter((name) => !isDeclared(ctx, name));
|
|
91
|
+
for (const name of undeclaredNow) {
|
|
92
|
+
ctx.stdout.write(`Note: ${ctx.navDir}/navbook.json does not declare ${name}; add it so every clone knows.\n`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (kept.length === 0)
|
|
96
|
+
fail("nothing was installed");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The npm runs an install takes: one for every spec that means exactly one
|
|
100
|
+
* package, and one per short name, which falls back to its second expansion.
|
|
101
|
+
*
|
|
102
|
+
* A short name means `@navbook/plugin-<name>` or else `navbook-plugin-<name>`
|
|
103
|
+
* (spec 04 §4.3), and only the registry knows which exists. Asking it before
|
|
104
|
+
* the user has agreed would be a network call nobody consented to, so the
|
|
105
|
+
* fallback happens inside the agreed action — and the confirmation says so,
|
|
106
|
+
* naming both commands, so what runs is still what was shown.
|
|
107
|
+
*/
|
|
108
|
+
function installActions(ctx, choices, ran) {
|
|
109
|
+
const exact = choices.filter((specs) => specs.length === 1).flat();
|
|
110
|
+
const actions = [];
|
|
111
|
+
if (exact.length > 0) {
|
|
112
|
+
actions.push({
|
|
113
|
+
description: `run ${installCommand(exact)}`,
|
|
114
|
+
perform: () => {
|
|
115
|
+
ran.push(...exact);
|
|
116
|
+
const result = npmInstall(ctx.env, exact);
|
|
117
|
+
if (!result.ok)
|
|
118
|
+
fail("npm could not install the plugin", result.output.split("\n"));
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
for (const [first, second] of choices.filter((specs) => specs.length > 1)) {
|
|
123
|
+
const primary = first;
|
|
124
|
+
const fallback = second;
|
|
125
|
+
actions.push({
|
|
126
|
+
description: `run ${installCommand([primary])}, or ${installCommand([fallback])} if npm has no ${packageNameOf(primary)}`,
|
|
127
|
+
perform: () => {
|
|
128
|
+
ran.push(primary);
|
|
129
|
+
const tried = npmInstall(ctx.env, [primary]);
|
|
130
|
+
if (tried.ok)
|
|
131
|
+
return;
|
|
132
|
+
// Only a package that does not exist sends npm to the other name: any
|
|
133
|
+
// other failure (the network, a broken tarball) would fail the same
|
|
134
|
+
// way twice, and hiding the first behind the second helps nobody.
|
|
135
|
+
if (!isNotFound(tried.output, packageNameOf(primary))) {
|
|
136
|
+
fail("npm could not install the plugin", tried.output.split("\n"));
|
|
137
|
+
}
|
|
138
|
+
ran.push(fallback);
|
|
139
|
+
const result = npmInstall(ctx.env, [fallback]);
|
|
140
|
+
if (!result.ok) {
|
|
141
|
+
fail(`npm has neither ${packageNameOf(primary)} nor ${packageNameOf(fallback)}`, [
|
|
142
|
+
...result.output.split("\n"),
|
|
143
|
+
]);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return actions;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Whether npm failed because the registry has no package by this name — not
|
|
152
|
+
* because the package exists and one of its own dependencies does not.
|
|
153
|
+
*/
|
|
154
|
+
function isNotFound(output, name) {
|
|
155
|
+
if (!/\bE404\b|\b404 Not Found\b/.test(output))
|
|
156
|
+
return false;
|
|
157
|
+
// The name itself, as npm writes it — `'@scope/name@*'`, or URL-encoded in
|
|
158
|
+
// the GET line — and not merely a dependency whose name begins with it.
|
|
159
|
+
const literal = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
160
|
+
return [name, name.replace("/", "%2f"), name.replace("/", "%2F")].some((form) => new RegExp(`(^|[/'\\s])${literal(form)}(?=[@'\\s]|$)`, "m").test(output));
|
|
161
|
+
}
|
|
162
|
+
/** Check what npm fetched, and record it in the index. Returns a fault, or null. */
|
|
163
|
+
function record(ctx, index, name) {
|
|
164
|
+
const dir = packageDir(ctx.env, name);
|
|
165
|
+
const read = readPluginAt(dir);
|
|
166
|
+
if ("error" in read)
|
|
167
|
+
return read.error;
|
|
168
|
+
if (!isPluginPackageName(read.name)) {
|
|
169
|
+
return `${read.name} is not named as a plugin (spec 04 §4.3)`;
|
|
170
|
+
}
|
|
171
|
+
if (!hasKeyword(dir)) {
|
|
172
|
+
return `${read.name} does not carry the 'navbook-plugin' keyword`;
|
|
173
|
+
}
|
|
174
|
+
index.plugins[read.name] = read;
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
function hasKeyword(dir) {
|
|
178
|
+
try {
|
|
179
|
+
return hasPluginKeyword(JSON.parse(readFileSync(join(dir, "package.json"), "utf8")));
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Whether a spec the user typed names the package npm saved as `name`.
|
|
187
|
+
*
|
|
188
|
+
* A registry spec names it by its package name, with or without a version or
|
|
189
|
+
* tag. A local one names it by where it is, which npm saves as a `file:` path
|
|
190
|
+
* relative to the store; a git URL is saved as typed.
|
|
191
|
+
*/
|
|
192
|
+
function asksFor(ctx, spec, name, saved) {
|
|
193
|
+
if (!looksLocal(spec))
|
|
194
|
+
return packageNameOf(spec) === name;
|
|
195
|
+
if (hasScheme(spec) || !saved.startsWith("file:"))
|
|
196
|
+
return saved === spec;
|
|
197
|
+
const typed = spec.startsWith("file:") ? spec.slice("file:".length) : spec;
|
|
198
|
+
return resolve(storeDir(ctx.env), saved.slice("file:".length)) === resolve(ctx.cwd, typed);
|
|
199
|
+
}
|
|
200
|
+
/** The package name in a registry spec: `@scope/name@^2` is `@scope/name`. */
|
|
201
|
+
function packageNameOf(spec) {
|
|
202
|
+
const at = spec.indexOf("@", spec.startsWith("@") ? 1 : 0);
|
|
203
|
+
return at === -1 ? spec : spec.slice(0, at);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Expand what was typed to the specs it may mean, in the order to try them,
|
|
207
|
+
* refusing a name that is not a plugin's.
|
|
208
|
+
*/
|
|
209
|
+
function resolveName(ctx, name) {
|
|
210
|
+
// npm runs in the store, so a relative path must be made absolute here or
|
|
211
|
+
// npm would look for it there rather than where the user typed it.
|
|
212
|
+
if (looksLocal(name) && !hasScheme(name)) {
|
|
213
|
+
const path = name.startsWith("file:") ? name.slice("file:".length) : name;
|
|
214
|
+
return [resolve(ctx.cwd, path)];
|
|
215
|
+
}
|
|
216
|
+
// A URL is npm's to fetch as typed; what it turns out to be is checked by
|
|
217
|
+
// name and keyword once it is in the store, as a folder or a tarball is.
|
|
218
|
+
if (hasScheme(name))
|
|
219
|
+
return [name];
|
|
220
|
+
// The name is checked without its version or tag, which npm takes as typed:
|
|
221
|
+
// `kb@^2` is `@navbook/plugin-kb@^2`, then `navbook-plugin-kb@^2`.
|
|
222
|
+
const base = packageNameOf(name);
|
|
223
|
+
const version = name.slice(base.length);
|
|
224
|
+
const candidates = expandPluginName(base);
|
|
225
|
+
const only = candidates[0];
|
|
226
|
+
if (candidates.length === 1) {
|
|
227
|
+
if (!isPluginPackageName(only)) {
|
|
228
|
+
fail(`${only} is not named as a plugin`, [
|
|
229
|
+
"a plugin is @navbook/plugin-<name>, navbook-plugin-<name>, or @scope/navbook-plugin-<name>",
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
232
|
+
return [`${only}${version}`];
|
|
233
|
+
}
|
|
234
|
+
// A short name: which of the candidates exists is npm's to find out, inside
|
|
235
|
+
// the action the user agreed to (see `installActions`).
|
|
236
|
+
return candidates.map((candidate) => `${candidate}${version}`);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* True for a URL — `https:`, `git+ssh:` — which npm fetches as typed. `file:`
|
|
240
|
+
* is the one scheme that names a path here, and is made absolute like one.
|
|
241
|
+
*/
|
|
242
|
+
function hasScheme(spec) {
|
|
243
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(spec) && !spec.startsWith("file:");
|
|
244
|
+
}
|
|
245
|
+
/** True for a specifier npm reads as a path or a URL rather than a package name. */
|
|
246
|
+
function looksLocal(spec) {
|
|
247
|
+
return (spec.startsWith(".") ||
|
|
248
|
+
spec.startsWith("/") ||
|
|
249
|
+
spec.startsWith("file:") ||
|
|
250
|
+
spec.startsWith("git+") ||
|
|
251
|
+
spec.endsWith(".tgz"));
|
|
252
|
+
}
|
|
253
|
+
/** The declared plugins this machine does not have. */
|
|
254
|
+
function declared(ctx) {
|
|
255
|
+
if (!ctx.hasNavbook)
|
|
256
|
+
return [];
|
|
257
|
+
return resolvePlugins(ctx, ctx.env).missing;
|
|
258
|
+
}
|
|
259
|
+
function isDeclared(ctx, name) {
|
|
260
|
+
return resolvePlugins(ctx, ctx.env).declaration.plugins.has(name);
|
|
261
|
+
}
|
|
262
|
+
export function cmdPluginRemove(ctx, names, opts) {
|
|
263
|
+
const index = readIndex(ctx.env);
|
|
264
|
+
const known = [...new Set(names.flatMap((name) => installedAs(index, name) ?? []))];
|
|
265
|
+
const unknown = names.filter((name) => installedAs(index, name) === null);
|
|
266
|
+
for (const name of unknown)
|
|
267
|
+
ctx.stderr.write(`nav: ${name} is not installed\n`);
|
|
268
|
+
if (known.length === 0)
|
|
269
|
+
fail("nothing to remove");
|
|
270
|
+
const removed = confirmAndPerform(ctx, {
|
|
271
|
+
title: "nav plugin remove will:",
|
|
272
|
+
actions: known.map((name) => ({
|
|
273
|
+
description: `remove ${name} from ${storeDir(ctx.env)}`,
|
|
274
|
+
perform: () => {
|
|
275
|
+
const result = npmRemove(ctx.env, [name]);
|
|
276
|
+
if (!result.ok)
|
|
277
|
+
fail(`npm could not remove ${name}`, result.output.split("\n"));
|
|
278
|
+
},
|
|
279
|
+
})),
|
|
280
|
+
assumeYes: opts.yes,
|
|
281
|
+
});
|
|
282
|
+
if (!removed || index === null)
|
|
283
|
+
return;
|
|
284
|
+
for (const name of known)
|
|
285
|
+
delete index.plugins[name];
|
|
286
|
+
writeIndex(ctx.env, index);
|
|
287
|
+
for (const name of known)
|
|
288
|
+
ctx.stdout.write(`Removed ${name}\n`);
|
|
289
|
+
// Deliberately silent about the declaration: what a repository says its tree
|
|
290
|
+
// contains is a property of the tree, and one machine's uninstall does not
|
|
291
|
+
// change it (spec 04 §4.3).
|
|
292
|
+
}
|
|
293
|
+
export function cmdPluginUpdate(ctx, names, opts) {
|
|
294
|
+
const index = readIndex(ctx.env);
|
|
295
|
+
const installed = Object.keys(index?.plugins ?? {});
|
|
296
|
+
const unknown = names.filter((name) => installedAs(index, name) === null);
|
|
297
|
+
if (unknown.length > 0)
|
|
298
|
+
fail(`not installed: ${unknown.join(", ")}`);
|
|
299
|
+
const wanted = names.length > 0
|
|
300
|
+
? [...new Set(names.map((name) => installedAs(index, name)))]
|
|
301
|
+
: installed;
|
|
302
|
+
if (wanted.length === 0) {
|
|
303
|
+
ctx.stdout.write("Nothing to do: no plugins are installed.\n");
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const updated = confirmAndPerform(ctx, {
|
|
307
|
+
title: "nav plugin update will:",
|
|
308
|
+
actions: [
|
|
309
|
+
{
|
|
310
|
+
description: `run ${installCommand(wanted.map((name) => `${name}@latest`))}`,
|
|
311
|
+
perform: () => {
|
|
312
|
+
const result = npmInstall(ctx.env, wanted.map((name) => `${name}@latest`));
|
|
313
|
+
if (!result.ok)
|
|
314
|
+
fail("npm could not update the plugins", result.output.split("\n"));
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
assumeYes: opts.yes,
|
|
319
|
+
});
|
|
320
|
+
if (!updated || index === null)
|
|
321
|
+
return;
|
|
322
|
+
for (const name of wanted) {
|
|
323
|
+
const before = index.plugins[name]?.version;
|
|
324
|
+
const problem = record(ctx, index, name);
|
|
325
|
+
if (problem !== null) {
|
|
326
|
+
ctx.stderr.write(`nav: ${problem}\n`);
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
const after = index.plugins[name]?.version;
|
|
330
|
+
ctx.stdout.write(before === after ? `${name} is already ${after}\n` : `Updated ${name} ${before} → ${after}\n`);
|
|
331
|
+
}
|
|
332
|
+
writeIndex(ctx.env, index);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* The installed plugin a name means, or null when none is.
|
|
336
|
+
*
|
|
337
|
+
* The short name `install` accepts is accepted here too, and expanded the
|
|
338
|
+
* same way, so `nav plugin remove kb` undoes `nav plugin install kb`. Of its
|
|
339
|
+
* two expansions, the one the index holds is the one meant.
|
|
340
|
+
*/
|
|
341
|
+
function installedAs(index, name) {
|
|
342
|
+
return (expandPluginName(name).find((candidate) => index?.plugins[candidate] !== undefined) ?? null);
|
|
343
|
+
}
|
|
344
|
+
export function cmdPluginList(ctx, opts) {
|
|
345
|
+
const resolved = resolvePlugins(ctx, ctx.env);
|
|
346
|
+
const rows = resolved.active.map((plugin) => ({
|
|
347
|
+
name: plugin.name,
|
|
348
|
+
version: plugin.version,
|
|
349
|
+
declared: plugin.declared,
|
|
350
|
+
source: plugin.fromPath ? "path" : "store",
|
|
351
|
+
dir: plugin.dir,
|
|
352
|
+
}));
|
|
353
|
+
if (opts.json) {
|
|
354
|
+
for (const row of rows)
|
|
355
|
+
ctx.stdout.write(`${JSON.stringify(row)}\n`);
|
|
356
|
+
for (const name of resolved.missing) {
|
|
357
|
+
ctx.stdout.write(`${JSON.stringify({ name, declared: true, missing: true })}\n`);
|
|
358
|
+
}
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (rows.length === 0 && resolved.missing.length === 0) {
|
|
362
|
+
ctx.stdout.write(`No plugins installed. The store is ${storeDir(ctx.env)}\n`);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
for (const row of rows) {
|
|
366
|
+
const where = row.source === "path" ? ` (${row.dir})` : "";
|
|
367
|
+
const state = row.declared ? "declared" : "not declared here";
|
|
368
|
+
ctx.stdout.write(`${row.name} ${row.version} ${state}${where}\n`);
|
|
369
|
+
}
|
|
370
|
+
for (const name of resolved.missing) {
|
|
371
|
+
ctx.stdout.write(`${name} — declared, not installed\n`);
|
|
372
|
+
}
|
|
373
|
+
for (const { name, reason } of resolved.skipped) {
|
|
374
|
+
ctx.stderr.write(`nav: plugin ${name} skipped: ${reason}\n`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/** Names in the store's `node_modules`, for a caller that wants to look. */
|
|
378
|
+
export function installedNames(env) {
|
|
379
|
+
try {
|
|
380
|
+
return readdirSync(`${storeDir(env)}/node_modules`).filter((name) => !name.startsWith("."));
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
return [];
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/commands/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAEL,cAAc,EACd,UAAU,EACV,SAAS,EAET,UAAU,EACV,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAe,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAU9D;;;;;GAKG;AACH,MAAM,U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