@itsaakashpatel/seo-webmaster-mcp 0.0.0-stage → 1.1.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 +36 -0
- package/LICENSE +21 -0
- package/README.md +380 -2
- package/build/approvals/format.d.ts +29 -0
- package/build/approvals/format.js +88 -0
- package/build/approvals/gate.d.ts +23 -0
- package/build/approvals/gate.js +102 -0
- package/build/approvals/groups.d.ts +14 -0
- package/build/approvals/groups.js +113 -0
- package/build/approvals/session.d.ts +8 -0
- package/build/approvals/session.js +23 -0
- package/build/cli/args.d.ts +18 -0
- package/build/cli/args.js +41 -0
- package/build/cli/commands.d.ts +8 -0
- package/build/cli/commands.js +64 -0
- package/build/cli/engines.d.ts +1 -0
- package/build/cli/engines.js +6 -0
- package/build/cli/help.d.ts +2 -0
- package/build/cli/help.js +29 -0
- package/build/cli/install/clients.d.ts +18 -0
- package/build/cli/install/clients.js +46 -0
- package/build/cli/install/command.d.ts +21 -0
- package/build/cli/install/command.js +44 -0
- package/build/cli/install/exec.d.ts +3 -0
- package/build/cli/install/exec.js +14 -0
- package/build/cli/install/flow.d.ts +14 -0
- package/build/cli/install/flow.js +114 -0
- package/build/cli/install/json-config.d.ts +24 -0
- package/build/cli/install/json-config.js +70 -0
- package/build/cli/prompter.d.ts +21 -0
- package/build/cli/prompter.js +15 -0
- package/build/cli/run.d.ts +17 -0
- package/build/cli/run.js +48 -0
- package/build/cli/screens.d.ts +45 -0
- package/build/cli/screens.js +83 -0
- package/build/cli/setup/approvals.d.ts +2 -0
- package/build/cli/setup/approvals.js +59 -0
- package/build/cli/setup/bing.d.ts +2 -0
- package/build/cli/setup/bing.js +35 -0
- package/build/cli/setup/flow.d.ts +8 -0
- package/build/cli/setup/flow.js +91 -0
- package/build/cli/setup/google.d.ts +2 -0
- package/build/cli/setup/google.js +94 -0
- package/build/cli/setup/helpers.d.ts +13 -0
- package/build/cli/setup/helpers.js +38 -0
- package/build/cli/setup/indexnow.d.ts +3 -0
- package/build/cli/setup/indexnow.js +89 -0
- package/build/cli/setup/services.d.ts +5 -0
- package/build/cli/setup/services.js +62 -0
- package/build/cli/setup/text.d.ts +10 -0
- package/build/cli/setup/text.js +40 -0
- package/build/cli/setup/types.d.ts +35 -0
- package/build/cli/setup/types.js +1 -0
- package/build/cli/status.d.ts +14 -0
- package/build/cli/status.js +54 -0
- package/build/cli/terminal.d.ts +6 -0
- package/build/cli/terminal.js +134 -0
- package/build/config/file.d.ts +29 -0
- package/build/config/file.js +58 -0
- package/build/config/index.d.ts +24 -0
- package/build/config/index.js +72 -0
- package/build/config/paths.d.ts +11 -0
- package/build/config/paths.js +19 -0
- package/build/core/analytics.d.ts +5 -0
- package/build/core/analytics.js +18 -0
- package/build/core/constants.d.ts +9 -0
- package/build/core/constants.js +9 -0
- package/build/core/errors.d.ts +18 -0
- package/build/core/errors.js +53 -0
- package/build/core/filters.d.ts +14 -0
- package/build/core/filters.js +42 -0
- package/build/core/guards.d.ts +11 -0
- package/build/core/guards.js +32 -0
- package/build/core/http.d.ts +17 -0
- package/build/core/http.js +51 -0
- package/build/core/insights/compare.d.ts +32 -0
- package/build/core/insights/compare.js +56 -0
- package/build/core/insights/crawl.d.ts +9 -0
- package/build/core/insights/crawl.js +61 -0
- package/build/core/insights/links.d.ts +5 -0
- package/build/core/insights/links.js +20 -0
- package/build/core/insights/metrics.d.ts +8 -0
- package/build/core/insights/metrics.js +15 -0
- package/build/core/insights/opportunities.d.ts +15 -0
- package/build/core/insights/opportunities.js +40 -0
- package/build/core/insights/periods.d.ts +12 -0
- package/build/core/insights/periods.js +38 -0
- package/build/core/insights/types.d.ts +31 -0
- package/build/core/insights/types.js +1 -0
- package/build/core/markdown.d.ts +14 -0
- package/build/core/markdown.js +28 -0
- package/build/core/paging.d.ts +11 -0
- package/build/core/paging.js +5 -0
- package/build/core/provider.d.ts +15 -0
- package/build/core/provider.js +1 -0
- package/build/core/rate-limit.d.ts +8 -0
- package/build/core/rate-limit.js +19 -0
- package/build/core/registry.d.ts +11 -0
- package/build/core/registry.js +16 -0
- package/build/core/responses.d.ts +13 -0
- package/build/core/responses.js +9 -0
- package/build/core/secrets.d.ts +2 -0
- package/build/core/secrets.js +9 -0
- package/build/core/types.d.ts +137 -0
- package/build/core/types.js +13 -0
- package/build/core/untrusted.d.ts +11 -0
- package/build/core/untrusted.js +34 -0
- package/build/core/urls.d.ts +16 -0
- package/build/core/urls.js +80 -0
- package/build/core/validation.d.ts +23 -0
- package/build/core/validation.js +100 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +30 -0
- package/build/providers/bing/auth.d.ts +11 -0
- package/build/providers/bing/auth.js +87 -0
- package/build/providers/bing/mappers.d.ts +18 -0
- package/build/providers/bing/mappers.js +87 -0
- package/build/providers/bing/operations.d.ts +8 -0
- package/build/providers/bing/operations.js +40 -0
- package/build/providers/bing/provider.d.ts +16 -0
- package/build/providers/bing/provider.js +132 -0
- package/build/providers/bing/records.d.ts +11 -0
- package/build/providers/bing/records.js +47 -0
- package/build/providers/bing/wire.d.ts +86 -0
- package/build/providers/bing/wire.js +38 -0
- package/build/providers/bing/writes.d.ts +9 -0
- package/build/providers/bing/writes.js +31 -0
- package/build/providers/google/auth.d.ts +13 -0
- package/build/providers/google/auth.js +174 -0
- package/build/providers/google/indexing.d.ts +14 -0
- package/build/providers/google/indexing.js +89 -0
- package/build/providers/google/mappers.d.ts +6 -0
- package/build/providers/google/mappers.js +96 -0
- package/build/providers/google/probe.d.ts +9 -0
- package/build/providers/google/probe.js +42 -0
- package/build/providers/google/provider.d.ts +15 -0
- package/build/providers/google/provider.js +118 -0
- package/build/providers/index.d.ts +4 -0
- package/build/providers/index.js +7 -0
- package/build/providers/indexnow/probe.d.ts +8 -0
- package/build/providers/indexnow/probe.js +17 -0
- package/build/providers/indexnow/provider.d.ts +21 -0
- package/build/providers/indexnow/provider.js +96 -0
- package/build/providers/insights/bing.d.ts +2 -0
- package/build/providers/insights/bing.js +73 -0
- package/build/providers/insights/google.d.ts +2 -0
- package/build/providers/insights/google.js +67 -0
- package/build/providers/insights/index.d.ts +5 -0
- package/build/providers/insights/index.js +15 -0
- package/build/providers/insights/source.d.ts +14 -0
- package/build/providers/insights/source.js +1 -0
- package/build/server.d.ts +2 -0
- package/build/server.js +14 -0
- package/build/tools/bing/catalog-crawl.d.ts +2 -0
- package/build/tools/bing/catalog-crawl.js +125 -0
- package/build/tools/bing/catalog-settings.d.ts +2 -0
- package/build/tools/bing/catalog-settings.js +51 -0
- package/build/tools/bing/catalog-site.d.ts +2 -0
- package/build/tools/bing/catalog-site.js +70 -0
- package/build/tools/bing/catalog-traffic.d.ts +2 -0
- package/build/tools/bing/catalog-traffic.js +88 -0
- package/build/tools/bing/index.d.ts +6 -0
- package/build/tools/bing/index.js +26 -0
- package/build/tools/bing/inputs.d.ts +21 -0
- package/build/tools/bing/inputs.js +34 -0
- package/build/tools/bing/read-tool.d.ts +23 -0
- package/build/tools/bing/read-tool.js +71 -0
- package/build/tools/bing/render.d.ts +8 -0
- package/build/tools/bing/render.js +50 -0
- package/build/tools/bing/write-tool.d.ts +25 -0
- package/build/tools/bing/write-tool.js +127 -0
- package/build/tools/bing/writes-settings.d.ts +2 -0
- package/build/tools/bing/writes-settings.js +227 -0
- package/build/tools/bing/writes-sites.d.ts +2 -0
- package/build/tools/bing/writes-sites.js +172 -0
- package/build/tools/engine-status.d.ts +14 -0
- package/build/tools/engine-status.js +81 -0
- package/build/tools/get-sitemap.d.ts +4 -0
- package/build/tools/get-sitemap.js +46 -0
- package/build/tools/index.d.ts +6 -0
- package/build/tools/index.js +43 -0
- package/build/tools/insights/bing-crawl-overview.d.ts +2 -0
- package/build/tools/insights/bing-crawl-overview.js +46 -0
- package/build/tools/insights/bing-link-evidence.d.ts +2 -0
- package/build/tools/insights/bing-link-evidence.js +65 -0
- package/build/tools/insights/declining-pages.d.ts +2 -0
- package/build/tools/insights/declining-pages.js +59 -0
- package/build/tools/insights/performance-overview.d.ts +2 -0
- package/build/tools/insights/performance-overview.js +39 -0
- package/build/tools/insights/report.d.ts +50 -0
- package/build/tools/insights/report.js +86 -0
- package/build/tools/insights/search-opportunities.d.ts +2 -0
- package/build/tools/insights/search-opportunities.js +30 -0
- package/build/tools/insights/shared.d.ts +44 -0
- package/build/tools/insights/shared.js +90 -0
- package/build/tools/inspect-url.d.ts +4 -0
- package/build/tools/inspect-url.js +104 -0
- package/build/tools/list-sitemaps.d.ts +4 -0
- package/build/tools/list-sitemaps.js +37 -0
- package/build/tools/list-sites.d.ts +4 -0
- package/build/tools/list-sites.js +56 -0
- package/build/tools/search-analytics.d.ts +4 -0
- package/build/tools/search-analytics.js +108 -0
- package/build/tools/shared.d.ts +29 -0
- package/build/tools/shared.js +63 -0
- package/build/tools/sitemaps.d.ts +2 -0
- package/build/tools/sitemaps.js +140 -0
- package/build/tools/submit-google.d.ts +4 -0
- package/build/tools/submit-google.js +68 -0
- package/build/tools/submit-urls.d.ts +4 -0
- package/build/tools/submit-urls.js +65 -0
- package/package.json +66 -4
- package/server.json +58 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { getErrorMessage } from "../../core/errors.js";
|
|
2
|
+
import { CLIENT_LABELS, configPathOf, findClients, } from "./clients.js";
|
|
3
|
+
import { describeCommand, SERVER_ENTRY_NAME } from "./command.js";
|
|
4
|
+
import { applyJsonInstall, entryOf, InstallFileError, planJsonInstall } from "./json-config.js";
|
|
5
|
+
const EXIT_OK = 0;
|
|
6
|
+
const EXIT_FAILURE = 1;
|
|
7
|
+
function claudeAddArgs(command) {
|
|
8
|
+
return [
|
|
9
|
+
"mcp",
|
|
10
|
+
"add",
|
|
11
|
+
"--scope",
|
|
12
|
+
"user",
|
|
13
|
+
SERVER_ENTRY_NAME,
|
|
14
|
+
"--",
|
|
15
|
+
command.command,
|
|
16
|
+
...command.args,
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
async function planFor(client, ctx) {
|
|
20
|
+
if (client === "claude-code") {
|
|
21
|
+
const known = await ctx.install.run("claude", ["mcp", "get", SERVER_ENTRY_NAME]);
|
|
22
|
+
return known.code === 0
|
|
23
|
+
? { kind: "already" }
|
|
24
|
+
: { kind: "claude-code", args: claudeAddArgs(ctx.command) };
|
|
25
|
+
}
|
|
26
|
+
const path = configPathOf(client, ctx.install);
|
|
27
|
+
if (path === undefined) {
|
|
28
|
+
throw new Error(`The client ${client} has no configuration file.`);
|
|
29
|
+
}
|
|
30
|
+
const change = planJsonInstall(path, ctx.command);
|
|
31
|
+
return change.kind === "already" ? { kind: "already" } : { kind: "json", change };
|
|
32
|
+
}
|
|
33
|
+
/** The clients that already have the server. */
|
|
34
|
+
export async function findInstalled(ctx) {
|
|
35
|
+
const clients = await findClients(ctx.install);
|
|
36
|
+
const plans = await Promise.all(clients.map(async (client) => [client, await planFor(client, ctx).catch(() => undefined)]));
|
|
37
|
+
return plans.filter(([, plan]) => plan?.kind === "already").map(([client]) => client);
|
|
38
|
+
}
|
|
39
|
+
function showChange(client, plan, ctx) {
|
|
40
|
+
const { prompt } = ctx;
|
|
41
|
+
prompt.say(`This changes ${CLIENT_LABELS[client]}:`);
|
|
42
|
+
if (plan.kind === "claude-code") {
|
|
43
|
+
prompt.say(` claude ${plan.args.join(" ")}`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const entry = JSON.stringify({ [SERVER_ENTRY_NAME]: entryOf(ctx.command) }, null, 2);
|
|
47
|
+
if (plan.change.kind === "change") {
|
|
48
|
+
prompt.say(` File: ${plan.change.path}\n The install adds this entry and keeps all other entries:\n${entry}`);
|
|
49
|
+
}
|
|
50
|
+
if (client === "claude-desktop") {
|
|
51
|
+
prompt.say("Quit Claude Desktop before you continue.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function apply(plan, ctx) {
|
|
55
|
+
if (plan.kind === "claude-code") {
|
|
56
|
+
const result = await ctx.install.run("claude", plan.args);
|
|
57
|
+
if (result.code !== 0) {
|
|
58
|
+
ctx.prompt.say(`The command failed: ${result.output}`);
|
|
59
|
+
return EXIT_FAILURE;
|
|
60
|
+
}
|
|
61
|
+
return EXIT_OK;
|
|
62
|
+
}
|
|
63
|
+
if (plan.change.kind !== "change") {
|
|
64
|
+
return EXIT_OK;
|
|
65
|
+
}
|
|
66
|
+
const backup = applyJsonInstall(plan.change);
|
|
67
|
+
ctx.prompt.say(backup ? `Backup of the old file: ${backup}` : "The install created the file.");
|
|
68
|
+
return EXIT_OK;
|
|
69
|
+
}
|
|
70
|
+
async function installInto(client, ctx) {
|
|
71
|
+
const plan = await planFor(client, ctx);
|
|
72
|
+
if (plan.kind === "already") {
|
|
73
|
+
ctx.prompt.say(`The server is already in ${CLIENT_LABELS[client]}. The install changed nothing.`);
|
|
74
|
+
return EXIT_OK;
|
|
75
|
+
}
|
|
76
|
+
ctx.prompt.say(`Command that the client will run: ${describeCommand(ctx.command)}`);
|
|
77
|
+
showChange(client, plan, ctx);
|
|
78
|
+
if (!(await ctx.prompt.confirm("Make this change?", false))) {
|
|
79
|
+
ctx.prompt.say("Cancelled. The install changed nothing.");
|
|
80
|
+
return EXIT_OK;
|
|
81
|
+
}
|
|
82
|
+
const code = await apply(plan, ctx);
|
|
83
|
+
if (code === EXIT_OK) {
|
|
84
|
+
ctx.prompt.say(`Done. Restart ${CLIENT_LABELS[client]} to load the server.`);
|
|
85
|
+
}
|
|
86
|
+
return code;
|
|
87
|
+
}
|
|
88
|
+
/** Adds the server to one client that the user picks. */
|
|
89
|
+
export async function runInstall(ctx) {
|
|
90
|
+
const clients = await findClients(ctx.install);
|
|
91
|
+
if (clients.length === 0) {
|
|
92
|
+
ctx.prompt.say("The install found no supported client: Claude Code, Claude Desktop or Cursor.");
|
|
93
|
+
return EXIT_FAILURE;
|
|
94
|
+
}
|
|
95
|
+
const client = await ctx.prompt.choose("Add the server to which client?", clients.map((id) => ({ value: id, label: CLIENT_LABELS[id] })));
|
|
96
|
+
try {
|
|
97
|
+
return await installInto(client, ctx);
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
ctx.prompt.say(err instanceof InstallFileError ? err.message : getErrorMessage(err));
|
|
101
|
+
return EXIT_FAILURE;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Asks to install when no found client has the server yet. */
|
|
105
|
+
export async function offerInstall(ctx) {
|
|
106
|
+
const [clients, installed] = await Promise.all([findClients(ctx.install), findInstalled(ctx)]);
|
|
107
|
+
if (clients.length === 0 || installed.length > 0) {
|
|
108
|
+
return EXIT_OK;
|
|
109
|
+
}
|
|
110
|
+
if (!(await ctx.prompt.confirm("Add this server to a client now?", false))) {
|
|
111
|
+
return EXIT_OK;
|
|
112
|
+
}
|
|
113
|
+
return runInstall(ctx);
|
|
114
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ServerCommand } from "./command.js";
|
|
2
|
+
export type JsonPlan = {
|
|
3
|
+
readonly kind: "already";
|
|
4
|
+
} | {
|
|
5
|
+
readonly kind: "change";
|
|
6
|
+
readonly path: string;
|
|
7
|
+
/** The new content of the whole file. */
|
|
8
|
+
readonly next: string;
|
|
9
|
+
readonly exists: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** The file cannot be used. The message shows the base name and never the content. */
|
|
12
|
+
export declare class InstallFileError extends Error {
|
|
13
|
+
constructor(message: string, options?: ErrorOptions);
|
|
14
|
+
}
|
|
15
|
+
export declare function entryOf(command: ServerCommand): {
|
|
16
|
+
command: string;
|
|
17
|
+
args: string[];
|
|
18
|
+
};
|
|
19
|
+
/** Plans the change. It keeps all other entries. It writes nothing. */
|
|
20
|
+
export declare function planJsonInstall(path: string, command: ServerCommand): JsonPlan;
|
|
21
|
+
/** Writes a backup of the old file, then the new file through a temporary file and a rename. */
|
|
22
|
+
export declare function applyJsonInstall(plan: Extract<JsonPlan, {
|
|
23
|
+
kind: "change";
|
|
24
|
+
}>): string | undefined;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync, } from "node:fs";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
import { isRecord } from "../../core/guards.js";
|
|
4
|
+
import { SERVER_ENTRY_NAME } from "./command.js";
|
|
5
|
+
/** The file cannot be used. The message shows the base name and never the content. */
|
|
6
|
+
export class InstallFileError extends Error {
|
|
7
|
+
constructor(message, options) {
|
|
8
|
+
super(message, options);
|
|
9
|
+
this.name = "InstallFileError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function entryOf(command) {
|
|
13
|
+
return { command: command.command, args: [...command.args] };
|
|
14
|
+
}
|
|
15
|
+
function parseExisting(path) {
|
|
16
|
+
const name = basename(path);
|
|
17
|
+
let json;
|
|
18
|
+
try {
|
|
19
|
+
json = JSON.parse(readFileSync(path, "utf8"));
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
// The parser message can quote the file, so the error does not copy it.
|
|
23
|
+
throw new InstallFileError(`"${name}" is not valid JSON. The install changed nothing.`, {
|
|
24
|
+
cause: err,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (!isRecord(json)) {
|
|
28
|
+
throw new InstallFileError(`"${name}" is not a JSON object. The install changed nothing.`);
|
|
29
|
+
}
|
|
30
|
+
return json;
|
|
31
|
+
}
|
|
32
|
+
function serversOf(path, config) {
|
|
33
|
+
const servers = config.mcpServers;
|
|
34
|
+
if (servers === undefined) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
if (!isRecord(servers)) {
|
|
38
|
+
throw new InstallFileError(`"${basename(path)}" has an mcpServers value that is not an object. The install changed nothing.`);
|
|
39
|
+
}
|
|
40
|
+
return servers;
|
|
41
|
+
}
|
|
42
|
+
/** Plans the change. It keeps all other entries. It writes nothing. */
|
|
43
|
+
export function planJsonInstall(path, command) {
|
|
44
|
+
const exists = existsSync(path);
|
|
45
|
+
const config = exists ? parseExisting(path) : {};
|
|
46
|
+
const servers = serversOf(path, config);
|
|
47
|
+
if (SERVER_ENTRY_NAME in servers) {
|
|
48
|
+
return { kind: "already" };
|
|
49
|
+
}
|
|
50
|
+
const next = {
|
|
51
|
+
...config,
|
|
52
|
+
mcpServers: { ...servers, [SERVER_ENTRY_NAME]: entryOf(command) },
|
|
53
|
+
};
|
|
54
|
+
return { kind: "change", path, next: `${JSON.stringify(next, null, 2)}\n`, exists };
|
|
55
|
+
}
|
|
56
|
+
/** Writes a backup of the old file, then the new file through a temporary file and a rename. */
|
|
57
|
+
export function applyJsonInstall(plan) {
|
|
58
|
+
const { path, next, exists } = plan;
|
|
59
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
60
|
+
const backup = exists ? `${path}.backup-${Date.now()}` : undefined;
|
|
61
|
+
if (backup) {
|
|
62
|
+
copyFileSync(path, backup);
|
|
63
|
+
}
|
|
64
|
+
const mode = exists ? statSync(path).mode & 0o777 : 0o600;
|
|
65
|
+
const temp = join(dirname(path), `.${basename(path)}.${process.pid}.tmp`);
|
|
66
|
+
writeFileSync(temp, next, { mode, flag: "w" });
|
|
67
|
+
chmodSync(temp, mode);
|
|
68
|
+
renameSync(temp, path);
|
|
69
|
+
return backup;
|
|
70
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CheckboxItem, CheckboxOutcome, MenuOption } from "./screens.js";
|
|
2
|
+
/** The user pressed Ctrl+C, or chose Cancel. */
|
|
3
|
+
export declare class SetupCancelled extends Error {
|
|
4
|
+
constructor(options?: ErrorOptions);
|
|
5
|
+
}
|
|
6
|
+
export interface CheckboxResult {
|
|
7
|
+
readonly outcome: CheckboxOutcome;
|
|
8
|
+
readonly checked: Readonly<Record<string, boolean>>;
|
|
9
|
+
}
|
|
10
|
+
/** All terminal input and output of the setup. Tests replace it with a scripted version. */
|
|
11
|
+
export interface Prompter {
|
|
12
|
+
say(text: string): void;
|
|
13
|
+
line(question: string): Promise<string>;
|
|
14
|
+
/** Reads text without echo. Use it for every key. */
|
|
15
|
+
secret(question: string): Promise<string>;
|
|
16
|
+
choose<T extends string>(title: string, options: readonly MenuOption<T>[]): Promise<T>;
|
|
17
|
+
confirm(question: string, defaultYes?: boolean): Promise<boolean>;
|
|
18
|
+
checkbox(title: string, items: readonly CheckboxItem[]): Promise<CheckboxResult>;
|
|
19
|
+
}
|
|
20
|
+
/** Reads a yes or no. An empty answer gives the default. */
|
|
21
|
+
export declare function parseYesNo(answer: string, defaultYes: boolean): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The user pressed Ctrl+C, or chose Cancel. */
|
|
2
|
+
export class SetupCancelled extends Error {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
super("Setup cancelled.", options);
|
|
5
|
+
this.name = "SetupCancelled";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Reads a yes or no. An empty answer gives the default. */
|
|
9
|
+
export function parseYesNo(answer, defaultYes) {
|
|
10
|
+
const text = answer.trim().toLowerCase();
|
|
11
|
+
if (text === "") {
|
|
12
|
+
return defaultYes;
|
|
13
|
+
}
|
|
14
|
+
return text === "y" || text === "yes";
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CommandName } from "./args.js";
|
|
2
|
+
export declare const EXIT_OK = 0;
|
|
3
|
+
export declare const EXIT_FAILURE = 1;
|
|
4
|
+
export declare const EXIT_USAGE = 2;
|
|
5
|
+
export interface CliContext {
|
|
6
|
+
readonly stdinIsTerminal: boolean;
|
|
7
|
+
readonly anyEngineConfigured: () => boolean;
|
|
8
|
+
readonly out: (text: string) => void;
|
|
9
|
+
readonly err: (text: string) => void;
|
|
10
|
+
readonly commands: Readonly<Record<CommandName, () => Promise<number>>>;
|
|
11
|
+
/** Runs after the help text on a terminal, when no client has the server yet. */
|
|
12
|
+
readonly offerInstall?: () => Promise<number>;
|
|
13
|
+
}
|
|
14
|
+
/** The commands that need no terminal. */
|
|
15
|
+
export declare function baseCommands(serve: () => Promise<void>, out: (text: string) => void): Pick<Record<CommandName, () => Promise<number>>, "serve" | "status">;
|
|
16
|
+
/** Runs one command line. Returns the exit code. */
|
|
17
|
+
export declare function runCli(argv: readonly string[], context: CliContext): Promise<number>;
|
package/build/cli/run.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SERVER_VERSION } from "../core/constants.js";
|
|
2
|
+
import { parseCliArguments } from "./args.js";
|
|
3
|
+
import { renderHelp } from "./help.js";
|
|
4
|
+
import { collectStatus, renderStatus } from "./status.js";
|
|
5
|
+
export const EXIT_OK = 0;
|
|
6
|
+
export const EXIT_FAILURE = 1;
|
|
7
|
+
export const EXIT_USAGE = 2;
|
|
8
|
+
/** The commands that need no terminal. */
|
|
9
|
+
export function baseCommands(serve, out) {
|
|
10
|
+
return {
|
|
11
|
+
serve: async () => {
|
|
12
|
+
await serve();
|
|
13
|
+
return EXIT_OK;
|
|
14
|
+
},
|
|
15
|
+
status: () => {
|
|
16
|
+
out(renderStatus(collectStatus()));
|
|
17
|
+
return Promise.resolve(EXIT_OK);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Runs one command line. Returns the exit code. */
|
|
22
|
+
export async function runCli(argv, context) {
|
|
23
|
+
const request = parseCliArguments(argv);
|
|
24
|
+
const help = () => renderHelp(context.anyEngineConfigured());
|
|
25
|
+
switch (request.kind) {
|
|
26
|
+
case "help":
|
|
27
|
+
context.out(help());
|
|
28
|
+
return EXIT_OK;
|
|
29
|
+
case "version":
|
|
30
|
+
context.out(SERVER_VERSION);
|
|
31
|
+
return EXIT_OK;
|
|
32
|
+
case "command":
|
|
33
|
+
return context.commands[request.command]();
|
|
34
|
+
case "bare":
|
|
35
|
+
return runBare(context, help);
|
|
36
|
+
default:
|
|
37
|
+
context.err(`Unknown input: ${request.input}\n\n${help()}`);
|
|
38
|
+
return EXIT_USAGE;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function runBare(context, help) {
|
|
42
|
+
// A client starts the server with a pipe on stdin. Old setups keep working.
|
|
43
|
+
if (!context.stdinIsTerminal) {
|
|
44
|
+
return context.commands.serve();
|
|
45
|
+
}
|
|
46
|
+
context.out(help());
|
|
47
|
+
return (await context.offerInstall?.()) ?? EXIT_OK;
|
|
48
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Pure state logic for the menu and checkbox screens. No terminal code is in this file. */
|
|
2
|
+
export type KeyName = "up" | "down" | "space" | "enter" | "other";
|
|
3
|
+
export interface MenuOption<T extends string> {
|
|
4
|
+
readonly value: T;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CheckboxItem {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly label: string;
|
|
10
|
+
readonly note: string;
|
|
11
|
+
readonly checked: boolean;
|
|
12
|
+
/** A locked item shows its state and cannot change. */
|
|
13
|
+
readonly locked?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CheckboxState {
|
|
16
|
+
readonly items: readonly CheckboxItem[];
|
|
17
|
+
readonly cursor: number;
|
|
18
|
+
}
|
|
19
|
+
export type CheckboxOutcome = "submit" | "cancel";
|
|
20
|
+
/** Moves the cursor one row and wraps at both ends. */
|
|
21
|
+
export declare function moveCursor(cursor: number, rows: number, key: KeyName): number;
|
|
22
|
+
/** The result of one key in a menu: the new cursor, and the chosen row after Enter. */
|
|
23
|
+
export declare function stepMenu(cursor: number, rows: number, key: KeyName): {
|
|
24
|
+
cursor: number;
|
|
25
|
+
chosen?: number;
|
|
26
|
+
};
|
|
27
|
+
export declare function renderMenu(title: string, labels: readonly string[], cursor: number): string[];
|
|
28
|
+
/** Rows: the items, then Submit, then Cancel. Space toggles an item. Enter acts on the row. */
|
|
29
|
+
export declare function stepCheckbox(state: CheckboxState, key: KeyName): {
|
|
30
|
+
state: CheckboxState;
|
|
31
|
+
outcome?: CheckboxOutcome;
|
|
32
|
+
};
|
|
33
|
+
export declare function renderCheckbox(title: string, state: CheckboxState): string[];
|
|
34
|
+
export interface KeyPress {
|
|
35
|
+
readonly name?: string;
|
|
36
|
+
readonly ctrl?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Maps a keypress event of Node to a key name. Ctrl+C is not handled here. */
|
|
39
|
+
export declare function toKeyName(key: KeyPress): KeyName;
|
|
40
|
+
/** Applies one chunk of typed input to a hidden prompt. */
|
|
41
|
+
export declare function applyHiddenInput(buffer: string, chunk: string): {
|
|
42
|
+
buffer: string;
|
|
43
|
+
done: boolean;
|
|
44
|
+
cancelled: boolean;
|
|
45
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** Pure state logic for the menu and checkbox screens. No terminal code is in this file. */
|
|
2
|
+
/** Moves the cursor one row and wraps at both ends. */
|
|
3
|
+
export function moveCursor(cursor, rows, key) {
|
|
4
|
+
if (key === "up") {
|
|
5
|
+
return (cursor - 1 + rows) % rows;
|
|
6
|
+
}
|
|
7
|
+
return key === "down" ? (cursor + 1) % rows : cursor;
|
|
8
|
+
}
|
|
9
|
+
/** The result of one key in a menu: the new cursor, and the chosen row after Enter. */
|
|
10
|
+
export function stepMenu(cursor, rows, key) {
|
|
11
|
+
return key === "enter" ? { cursor, chosen: cursor } : { cursor: moveCursor(cursor, rows, key) };
|
|
12
|
+
}
|
|
13
|
+
export function renderMenu(title, labels, cursor) {
|
|
14
|
+
return [title, ...labels.map((label, index) => `${index === cursor ? ">" : " "} ${label}`)];
|
|
15
|
+
}
|
|
16
|
+
function toggleAt(state) {
|
|
17
|
+
const item = state.items[state.cursor];
|
|
18
|
+
if (!item || item.locked) {
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
21
|
+
const items = state.items.map((entry, index) => index === state.cursor ? { ...entry, checked: !entry.checked } : entry);
|
|
22
|
+
return { ...state, items };
|
|
23
|
+
}
|
|
24
|
+
/** Rows: the items, then Submit, then Cancel. Space toggles an item. Enter acts on the row. */
|
|
25
|
+
export function stepCheckbox(state, key) {
|
|
26
|
+
const rows = state.items.length + 2;
|
|
27
|
+
if (key === "up" || key === "down") {
|
|
28
|
+
return { state: { ...state, cursor: moveCursor(state.cursor, rows, key) } };
|
|
29
|
+
}
|
|
30
|
+
const onSubmit = state.cursor === state.items.length;
|
|
31
|
+
const onCancel = state.cursor === state.items.length + 1;
|
|
32
|
+
if (key === "enter" && (onSubmit || onCancel)) {
|
|
33
|
+
return { state, outcome: onSubmit ? "submit" : "cancel" };
|
|
34
|
+
}
|
|
35
|
+
return key === "space" || key === "enter" ? { state: toggleAt(state) } : { state };
|
|
36
|
+
}
|
|
37
|
+
export function renderCheckbox(title, state) {
|
|
38
|
+
const mark = (index) => (index === state.cursor ? ">" : " ");
|
|
39
|
+
const items = state.items.map((item, index) => `${mark(index)} [${item.checked ? "x" : " "}] ${item.label} ${item.note}`.trimEnd());
|
|
40
|
+
const count = state.items.length;
|
|
41
|
+
return [
|
|
42
|
+
title,
|
|
43
|
+
...items,
|
|
44
|
+
`${mark(count)} Submit`,
|
|
45
|
+
`${mark(count + 1)} Cancel`,
|
|
46
|
+
"(Up and Down move. Space selects. Enter confirms.)",
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
/** Maps a keypress event of Node to a key name. Ctrl+C is not handled here. */
|
|
50
|
+
export function toKeyName(key) {
|
|
51
|
+
const names = {
|
|
52
|
+
up: "up",
|
|
53
|
+
k: "up",
|
|
54
|
+
down: "down",
|
|
55
|
+
j: "down",
|
|
56
|
+
space: "space",
|
|
57
|
+
return: "enter",
|
|
58
|
+
enter: "enter",
|
|
59
|
+
};
|
|
60
|
+
return (key.name !== undefined ? names[key.name] : undefined) ?? "other";
|
|
61
|
+
}
|
|
62
|
+
/** Applies one chunk of typed input to a hidden prompt. */
|
|
63
|
+
export function applyHiddenInput(buffer, chunk) {
|
|
64
|
+
// An arrow key or another key sequence arrives as one chunk that starts with Escape.
|
|
65
|
+
if (chunk.startsWith("\u001b")) {
|
|
66
|
+
return { buffer, done: false, cancelled: false };
|
|
67
|
+
}
|
|
68
|
+
let next = buffer;
|
|
69
|
+
for (const char of chunk) {
|
|
70
|
+
if (char === "\u0003") {
|
|
71
|
+
return { buffer: "", done: false, cancelled: true };
|
|
72
|
+
}
|
|
73
|
+
if (char === "\r" || char === "\n") {
|
|
74
|
+
return { buffer: next, done: true, cancelled: false };
|
|
75
|
+
}
|
|
76
|
+
next = char === "\u007f" || char === "\b" ? next.slice(0, -1) : appendPrintable(next, char);
|
|
77
|
+
}
|
|
78
|
+
return { buffer: next, done: false, cancelled: false };
|
|
79
|
+
}
|
|
80
|
+
function appendPrintable(buffer, char) {
|
|
81
|
+
// Control characters are not part of a key.
|
|
82
|
+
return (char.codePointAt(0) ?? 0) < 0x20 ? buffer : `${buffer}${char}`;
|
|
83
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CONFIGURABLE_GROUPS, } from "../../config/file.js";
|
|
2
|
+
import { APPROVAL_NOTE } from "./text.js";
|
|
3
|
+
const ITEM_TEXT = {
|
|
4
|
+
submit: ["Submit URLs and sitemaps", "uses daily quota"],
|
|
5
|
+
visibility: ["Change visibility", "can remove pages from search"],
|
|
6
|
+
access: ["Manage site access", "can give control to another person"],
|
|
7
|
+
};
|
|
8
|
+
/** These groups need the user to type the group name before "run without asking". */
|
|
9
|
+
const TYPED_CONFIRMATION = ["visibility", "access"];
|
|
10
|
+
function buildItems(ctx) {
|
|
11
|
+
const approvals = ctx.draft.config.approvals ?? {};
|
|
12
|
+
const groups = CONFIGURABLE_GROUPS.map((group) => ({
|
|
13
|
+
id: group,
|
|
14
|
+
label: ITEM_TEXT[group][0],
|
|
15
|
+
note: ITEM_TEXT[group][1],
|
|
16
|
+
checked: approvals[group] === "run",
|
|
17
|
+
}));
|
|
18
|
+
return [
|
|
19
|
+
{ id: "read", label: "Read reports and data", note: "always on", checked: true, locked: true },
|
|
20
|
+
...groups,
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
async function confirmGroup(ctx, group) {
|
|
24
|
+
const typed = await ctx.prompt.line(`To run "${group}" tools without asking, type the word ${group}: `);
|
|
25
|
+
if (typed.trim() === group) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
ctx.prompt.say(`The word did not match. The setup keeps "ask first" for ${group}.`);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
async function wantsRun(ctx, group, checked) {
|
|
32
|
+
const wasRun = ctx.draft.config.approvals?.[group] === "run";
|
|
33
|
+
if (checked[group] !== true) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return wasRun || !TYPED_CONFIRMATION.includes(group) || (await confirmGroup(ctx, group));
|
|
37
|
+
}
|
|
38
|
+
async function chosenChoices(ctx, checked) {
|
|
39
|
+
const choices = {
|
|
40
|
+
submit: "ask",
|
|
41
|
+
visibility: "ask",
|
|
42
|
+
access: "ask",
|
|
43
|
+
};
|
|
44
|
+
for (const group of CONFIGURABLE_GROUPS) {
|
|
45
|
+
// oxlint-disable-next-line no-await-in-loop -- the user answers one question at a time.
|
|
46
|
+
choices[group] = (await wantsRun(ctx, group, checked)) ? "run" : "ask";
|
|
47
|
+
}
|
|
48
|
+
return choices;
|
|
49
|
+
}
|
|
50
|
+
export async function setupApprovals(ctx) {
|
|
51
|
+
ctx.prompt.say(APPROVAL_NOTE);
|
|
52
|
+
const result = await ctx.prompt.checkbox("Run without asking:", buildItems(ctx));
|
|
53
|
+
if (result.outcome === "cancel") {
|
|
54
|
+
ctx.prompt.say("Cancelled. The earlier approval choices stay.");
|
|
55
|
+
return "back";
|
|
56
|
+
}
|
|
57
|
+
ctx.draft.config = { ...ctx.draft.config, approvals: await chosenChoices(ctx, result.checked) };
|
|
58
|
+
return "done";
|
|
59
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { runTest, sayEnvNote } from "./helpers.js";
|
|
2
|
+
import { BING_STEPS } from "./text.js";
|
|
3
|
+
async function setKey(ctx) {
|
|
4
|
+
const { prompt, services, draft } = ctx;
|
|
5
|
+
prompt.say(BING_STEPS);
|
|
6
|
+
const apiKey = await prompt.secret("Paste the Bing API key (the input is hidden): ");
|
|
7
|
+
if (apiKey === "") {
|
|
8
|
+
prompt.say("No key was given. Nothing changed.");
|
|
9
|
+
return "back";
|
|
10
|
+
}
|
|
11
|
+
const outcome = await runTest(ctx, async () => `Bing accepted the key. It lists ${await services.countBingSites(apiKey)} site(s).`, [apiKey]);
|
|
12
|
+
if (outcome === "back") {
|
|
13
|
+
return "back";
|
|
14
|
+
}
|
|
15
|
+
draft.config = { ...draft.config, bing: { apiKey } };
|
|
16
|
+
sayEnvNote(ctx, "bingApiKey");
|
|
17
|
+
return "done";
|
|
18
|
+
}
|
|
19
|
+
export async function setupBing(ctx) {
|
|
20
|
+
const choice = await ctx.prompt.choose("Bing", [
|
|
21
|
+
{ value: "set", label: "Add or replace the key" },
|
|
22
|
+
{ value: "remove", label: "Remove the key" },
|
|
23
|
+
{ value: "back", label: "Back" },
|
|
24
|
+
]);
|
|
25
|
+
if (choice === "set") {
|
|
26
|
+
return setKey(ctx);
|
|
27
|
+
}
|
|
28
|
+
if (choice === "remove") {
|
|
29
|
+
const { bing: _removed, ...rest } = ctx.draft.config;
|
|
30
|
+
ctx.draft.config = rest;
|
|
31
|
+
ctx.prompt.say("The Bing key will be removed when you save.");
|
|
32
|
+
return "done";
|
|
33
|
+
}
|
|
34
|
+
return "back";
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ConfigFile } from "../../config/file.js";
|
|
2
|
+
import type { SetupContext } from "./types.js";
|
|
3
|
+
/** A summary of the draft. It never shows a key. */
|
|
4
|
+
export declare function renderSummary(config: ConfigFile): string;
|
|
5
|
+
/** The main menu. It returns after a save or a cancel. Ctrl+C throws `SetupCancelled`. */
|
|
6
|
+
export declare function runMainMenu(ctx: SetupContext): Promise<"saved" | "cancelled">;
|
|
7
|
+
/** Runs the setup. Cancel and Ctrl+C change nothing on the disk. */
|
|
8
|
+
export declare function runSetup(ctx: SetupContext): Promise<number>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { CONFIGURABLE_GROUPS } from "../../config/file.js";
|
|
2
|
+
import { describeSource, resolveSetting } from "../../config/index.js";
|
|
3
|
+
import { SetupCancelled } from "../prompter.js";
|
|
4
|
+
import { setupApprovals } from "./approvals.js";
|
|
5
|
+
import { setupBing } from "./bing.js";
|
|
6
|
+
import { maskKey } from "./helpers.js";
|
|
7
|
+
import { setupGoogle } from "./google.js";
|
|
8
|
+
import { setupIndexNow } from "./indexnow.js";
|
|
9
|
+
import { PLAIN_TEXT_NOTE, RESTART_NOTE } from "./text.js";
|
|
10
|
+
function status(config, key) {
|
|
11
|
+
const labels = {
|
|
12
|
+
google: config.google ? "key file set" : undefined,
|
|
13
|
+
bing: config.bing ? `configured (${maskKey(config.bing.apiKey)})` : undefined,
|
|
14
|
+
indexnow: config.indexnow ? `configured (${maskKey(config.indexnow.key)})` : undefined,
|
|
15
|
+
};
|
|
16
|
+
return labels[key] ?? "not configured";
|
|
17
|
+
}
|
|
18
|
+
function envLine(label, name) {
|
|
19
|
+
const setting = resolveSetting(name);
|
|
20
|
+
return setting.source === "environment" ? [` ${label}: ${describeSource(setting)}`] : [];
|
|
21
|
+
}
|
|
22
|
+
/** A summary of the draft. It never shows a key. */
|
|
23
|
+
export function renderSummary(config) {
|
|
24
|
+
const approvals = CONFIGURABLE_GROUPS.map((group) => ` ${group}: ${config.approvals?.[group] === "run" ? "run without asking" : "ask first"}`);
|
|
25
|
+
return [
|
|
26
|
+
"Summary:",
|
|
27
|
+
` Google: ${status(config, "google")}${config.google ? ` (${config.google.keyFile})` : ""}`,
|
|
28
|
+
` Bing: ${status(config, "bing")}`,
|
|
29
|
+
` IndexNow: ${status(config, "indexnow")}`,
|
|
30
|
+
" Approvals (read always runs):",
|
|
31
|
+
...approvals,
|
|
32
|
+
...envLine("Google key file", "googleKeyFile"),
|
|
33
|
+
...envLine("Bing", "bingApiKey"),
|
|
34
|
+
...envLine("IndexNow", "indexNowKey"),
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
|
37
|
+
function mainOptions(config) {
|
|
38
|
+
return [
|
|
39
|
+
{ value: "google", label: `Google ${status(config, "google")}` },
|
|
40
|
+
{ value: "bing", label: `Bing ${status(config, "bing")}` },
|
|
41
|
+
{ value: "indexnow", label: `IndexNow ${status(config, "indexnow")}` },
|
|
42
|
+
{ value: "approvals", label: "Approvals" },
|
|
43
|
+
{ value: "save", label: "Save and exit" },
|
|
44
|
+
{ value: "cancel", label: "Cancel" },
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
async function save(ctx) {
|
|
48
|
+
const { prompt, draft, configPath } = ctx;
|
|
49
|
+
prompt.say(renderSummary(draft.config));
|
|
50
|
+
prompt.say(`${PLAIN_TEXT_NOTE}\nFile: ${configPath}`);
|
|
51
|
+
if (!(await prompt.confirm("Write the file now?"))) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
ctx.services.saveConfig(draft.config);
|
|
55
|
+
prompt.say(`Saved. ${RESTART_NOTE}`);
|
|
56
|
+
await ctx.offerInstall?.();
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
const SECTIONS = {
|
|
60
|
+
google: setupGoogle,
|
|
61
|
+
bing: setupBing,
|
|
62
|
+
indexnow: setupIndexNow,
|
|
63
|
+
approvals: setupApprovals,
|
|
64
|
+
};
|
|
65
|
+
/** The main menu. It returns after a save or a cancel. Ctrl+C throws `SetupCancelled`. */
|
|
66
|
+
export async function runMainMenu(ctx) {
|
|
67
|
+
const choice = await ctx.prompt.choose("Search engine:", mainOptions(ctx.draft.config));
|
|
68
|
+
if (choice === "cancel") {
|
|
69
|
+
ctx.prompt.say("Cancelled. Nothing was saved.");
|
|
70
|
+
return "cancelled";
|
|
71
|
+
}
|
|
72
|
+
if (choice === "save") {
|
|
73
|
+
return (await save(ctx)) ? "saved" : runMainMenu(ctx);
|
|
74
|
+
}
|
|
75
|
+
await SECTIONS[choice](ctx);
|
|
76
|
+
return runMainMenu(ctx);
|
|
77
|
+
}
|
|
78
|
+
/** Runs the setup. Cancel and Ctrl+C change nothing on the disk. */
|
|
79
|
+
export async function runSetup(ctx) {
|
|
80
|
+
try {
|
|
81
|
+
await runMainMenu(ctx);
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
if (err instanceof SetupCancelled) {
|
|
86
|
+
ctx.prompt.say("Cancelled. Nothing was saved.");
|
|
87
|
+
return 130;
|
|
88
|
+
}
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
}
|