@coderook/cli 0.34.2 → 0.34.4
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/.claude-plugin/plugin.json +1 -1
- package/dist/cbx/src/core/upload.js +158 -121
- package/dist/cli/src/api.js +8 -2
- package/dist/cli/src/attach_command.js +18 -22
- package/dist/cli/src/cli.js +48 -12
- package/dist/cli/src/colour.js +16 -0
- package/dist/cli/src/help.js +12 -14
- package/dist/cli/src/licence_commands.js +34 -38
- package/dist/cli/src/network.js +25 -5
- package/dist/cli/src/project_commands.js +43 -47
- package/dist/cli/src/service_commands.js +169 -120
- package/dist/cli/src/track_commands.js +21 -25
- package/dist/cli/src/transfer_command.js +28 -32
- package/dist/cli/src/version_commands.js +66 -70
- package/package.json +1 -1
package/dist/cli/src/help.js
CHANGED
|
@@ -19,9 +19,7 @@ exports.renderHelp = renderHelp;
|
|
|
19
19
|
exports.renderCommandHelp = renderCommandHelp;
|
|
20
20
|
exports.renderUnknown = renderUnknown;
|
|
21
21
|
const registry_js_1 = require("./registry.js");
|
|
22
|
-
const
|
|
23
|
-
const dim = (value) => `[2m${value}[0m`;
|
|
24
|
-
const accent = (value) => `[33m${value}[0m`;
|
|
22
|
+
const colour_js_1 = require("./colour.js");
|
|
25
23
|
/** Longest visible name, so the summary column lines up across every group. */
|
|
26
24
|
function nameColumn(specs) {
|
|
27
25
|
return specs.reduce((widest, spec) => Math.max(widest, spec.usage.length), 0);
|
|
@@ -30,46 +28,46 @@ function renderHelp(registry, version) {
|
|
|
30
28
|
const listed = registry.specs.filter((spec) => !spec.deprecatedBy);
|
|
31
29
|
const column = Math.min(nameColumn(listed), 34);
|
|
32
30
|
const lines = [
|
|
33
|
-
`${bold("cbx")} ${dim(version)} — the CodeBox engine, for CodeRook`,
|
|
31
|
+
`${(0, colour_js_1.bold)("cbx")} ${(0, colour_js_1.dim)(version)} — the CodeBox engine, for CodeRook`,
|
|
34
32
|
"",
|
|
35
33
|
];
|
|
36
34
|
for (const group of registry_js_1.GROUP_ORDER) {
|
|
37
35
|
const inGroup = listed.filter((spec) => spec.group === group);
|
|
38
36
|
if (!inGroup.length)
|
|
39
37
|
continue;
|
|
40
|
-
lines.push(bold(group));
|
|
38
|
+
lines.push((0, colour_js_1.bold)(group));
|
|
41
39
|
for (const spec of inGroup) {
|
|
42
40
|
lines.push(` ${spec.usage.padEnd(column)} ${spec.summary}`);
|
|
43
41
|
}
|
|
44
42
|
lines.push("");
|
|
45
43
|
}
|
|
46
|
-
lines.push(dim("cbx help <command> what one command does, in full"), dim("CODEROOK_TOKEN is used when set, so automated runs need nothing on disk."), dim("CODEROOK_API_URL points at another service."));
|
|
44
|
+
lines.push((0, colour_js_1.dim)("cbx help <command> what one command does, in full"), (0, colour_js_1.dim)("CODEROOK_TOKEN is used when set, so automated runs need nothing on disk."), (0, colour_js_1.dim)("CODEROOK_API_URL points at another service."));
|
|
47
45
|
return lines.join("\n");
|
|
48
46
|
}
|
|
49
47
|
function renderCommandHelp(spec) {
|
|
50
48
|
const lines = [
|
|
51
|
-
`${bold("cbx " + spec.name)} — ${spec.summary}`,
|
|
49
|
+
`${(0, colour_js_1.bold)("cbx " + spec.name)} — ${spec.summary}`,
|
|
52
50
|
"",
|
|
53
|
-
bold("Usage"),
|
|
51
|
+
(0, colour_js_1.bold)("Usage"),
|
|
54
52
|
` cbx ${spec.usage}`,
|
|
55
53
|
];
|
|
56
54
|
if (spec.aliases?.length) {
|
|
57
|
-
lines.push("", bold("Also"), ` ${spec.aliases.map((alias) => `cbx ${alias}`).join(" ")}`);
|
|
55
|
+
lines.push("", (0, colour_js_1.bold)("Also"), ` ${spec.aliases.map((alias) => `cbx ${alias}`).join(" ")}`);
|
|
58
56
|
}
|
|
59
57
|
if (spec.detail) {
|
|
60
58
|
lines.push("", spec.detail.trim());
|
|
61
59
|
}
|
|
62
60
|
if (spec.options?.length) {
|
|
63
61
|
const width = spec.options.reduce((widest, option) => Math.max(widest, option.flags.length), 0);
|
|
64
|
-
lines.push("", bold("Options"));
|
|
62
|
+
lines.push("", (0, colour_js_1.bold)("Options"));
|
|
65
63
|
for (const option of spec.options) {
|
|
66
64
|
lines.push(` ${option.flags.padEnd(width)} ${option.description}`);
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
if (spec.examples?.length) {
|
|
70
|
-
lines.push("", bold("Examples"));
|
|
68
|
+
lines.push("", (0, colour_js_1.bold)("Examples"));
|
|
71
69
|
for (const example of spec.examples)
|
|
72
|
-
lines.push(` ${accent(example)}`);
|
|
70
|
+
lines.push(` ${(0, colour_js_1.accent)(example)}`);
|
|
73
71
|
}
|
|
74
72
|
return lines.join("\n");
|
|
75
73
|
}
|
|
@@ -82,7 +80,7 @@ function renderCommandHelp(spec) {
|
|
|
82
80
|
function renderUnknown(typed, suggestion) {
|
|
83
81
|
const lines = [`Unknown command: ${typed}`];
|
|
84
82
|
if (suggestion)
|
|
85
|
-
lines.push(`Did you mean ${accent("cbx " + suggestion)}?`);
|
|
86
|
-
lines.push(dim("Run cbx help to see everything."));
|
|
83
|
+
lines.push(`Did you mean ${(0, colour_js_1.accent)("cbx " + suggestion)}?`);
|
|
84
|
+
lines.push((0, colour_js_1.dim)("Run cbx help to see everything."));
|
|
87
85
|
return lines.join("\n");
|
|
88
86
|
}
|
|
@@ -26,11 +26,7 @@ Object.defineProperty(exports, "licenceNewProject", { enumerable: true, get: fun
|
|
|
26
26
|
const ignore_templates_js_1 = require("../../cbx/src/core/ignore_templates.js");
|
|
27
27
|
const worktree_js_1 = require("../../cbx/src/core/worktree.js");
|
|
28
28
|
const api_js_1 = require("./api.js");
|
|
29
|
-
const
|
|
30
|
-
const bold = (value) => `[1m${value}[0m`;
|
|
31
|
-
const red = (value) => `[31m${value}[0m`;
|
|
32
|
-
const green = (value) => `[32m${value}[0m`;
|
|
33
|
-
const accent = (value) => `[33m${value}[0m`;
|
|
29
|
+
const colour_js_1 = require("./colour.js");
|
|
34
30
|
const SHAPES = {
|
|
35
31
|
permissive: "Do what you like, keep the notice",
|
|
36
32
|
"weak-copyleft": "Changes to these files come back",
|
|
@@ -56,25 +52,25 @@ async function commandLicence(parsed) {
|
|
|
56
52
|
.then((text) => text.split("\n")[0]?.trim() ?? "")
|
|
57
53
|
.catch(() => null);
|
|
58
54
|
if (existing !== null) {
|
|
59
|
-
console.log(`${bold("This folder has a licence")} — ${existing}`);
|
|
60
|
-
console.log(dim(` ${node_path_1.default.join(folder, licences_js_1.LICENCE_FILE)}`));
|
|
55
|
+
console.log(`${(0, colour_js_1.bold)("This folder has a licence")} — ${existing}`);
|
|
56
|
+
console.log((0, colour_js_1.dim)(` ${node_path_1.default.join(folder, licences_js_1.LICENCE_FILE)}`));
|
|
61
57
|
console.log("");
|
|
62
58
|
}
|
|
63
|
-
console.log(bold("Licences you can put on this project"));
|
|
59
|
+
console.log((0, colour_js_1.bold)("Licences you can put on this project"));
|
|
64
60
|
let shape = null;
|
|
65
61
|
for (const licence of licences_js_1.LICENCES) {
|
|
66
62
|
if (licence.shape !== shape) {
|
|
67
63
|
shape = licence.shape;
|
|
68
64
|
console.log("");
|
|
69
|
-
console.log(dim(` ${SHAPES[shape].toUpperCase()}`));
|
|
65
|
+
console.log((0, colour_js_1.dim)(` ${SHAPES[shape].toUpperCase()}`));
|
|
70
66
|
}
|
|
71
|
-
const mark = licence.id === licences_js_1.DEFAULT_LICENCE ? accent(" ·") : " ";
|
|
72
|
-
console.log(`${mark} ${bold(licence.id.padEnd(20))} ${licence.name}`);
|
|
73
|
-
console.log(` ${dim(licence.summary)}`);
|
|
67
|
+
const mark = licence.id === licences_js_1.DEFAULT_LICENCE ? (0, colour_js_1.accent)(" ·") : " ";
|
|
68
|
+
console.log(`${mark} ${(0, colour_js_1.bold)(licence.id.padEnd(20))} ${licence.name}`);
|
|
69
|
+
console.log(` ${(0, colour_js_1.dim)(licence.summary)}`);
|
|
74
70
|
}
|
|
75
71
|
console.log("");
|
|
76
|
-
console.log(`Add one with ${accent("cbx licence MIT")}. ` +
|
|
77
|
-
dim(`Nothing is written until you name one.`));
|
|
72
|
+
console.log(`Add one with ${(0, colour_js_1.accent)("cbx licence MIT")}. ` +
|
|
73
|
+
(0, colour_js_1.dim)(`Nothing is written until you name one.`));
|
|
78
74
|
return 0;
|
|
79
75
|
}
|
|
80
76
|
/*
|
|
@@ -90,15 +86,15 @@ async function commandLicence(parsed) {
|
|
|
90
86
|
return 0;
|
|
91
87
|
}
|
|
92
88
|
await (0, promises_1.rm)(target);
|
|
93
|
-
console.log(green(`Removed ${licences_js_1.LICENCE_FILE}.`));
|
|
94
|
-
console.log(dim("With no licence, nobody else may legally use this — which is a"));
|
|
95
|
-
console.log(dim("position you can hold, as long as you are holding it on purpose."));
|
|
89
|
+
console.log((0, colour_js_1.green)(`Removed ${licences_js_1.LICENCE_FILE}.`));
|
|
90
|
+
console.log((0, colour_js_1.dim)("With no licence, nobody else may legally use this — which is a"));
|
|
91
|
+
console.log((0, colour_js_1.dim)("position you can hold, as long as you are holding it on purpose."));
|
|
96
92
|
return 0;
|
|
97
93
|
}
|
|
98
94
|
const licence = (0, licences_js_1.licenceById)(wanted);
|
|
99
95
|
if (!licence) {
|
|
100
|
-
console.error(red(`No licence called ${wanted}.`));
|
|
101
|
-
console.error(`Run ${accent("cbx licence")} to see the list.`);
|
|
96
|
+
console.error((0, colour_js_1.red)(`No licence called ${wanted}.`));
|
|
97
|
+
console.error(`Run ${(0, colour_js_1.accent)("cbx licence")} to see the list.`);
|
|
102
98
|
return 1;
|
|
103
99
|
}
|
|
104
100
|
/*
|
|
@@ -125,13 +121,13 @@ async function commandLicence(parsed) {
|
|
|
125
121
|
});
|
|
126
122
|
if (!holder) {
|
|
127
123
|
const reason = failure instanceof Error ? failure.message : "";
|
|
128
|
-
console.error(red("Could not work out whose name goes on the licence."));
|
|
124
|
+
console.error((0, colour_js_1.red)("Could not work out whose name goes on the licence."));
|
|
129
125
|
if (/sign-in|not signed in|not accepted/i.test(reason) || !failure) {
|
|
130
|
-
console.error(`Sign in, or pass ${accent('--holder "Your Name"')} to say directly.`);
|
|
126
|
+
console.error(`Sign in, or pass ${(0, colour_js_1.accent)('--holder "Your Name"')} to say directly.`);
|
|
131
127
|
}
|
|
132
128
|
else {
|
|
133
|
-
console.error(dim(reason));
|
|
134
|
-
console.error(`Try again, or pass ${accent('--holder "Your Name"')} to say directly.`);
|
|
129
|
+
console.error((0, colour_js_1.dim)(reason));
|
|
130
|
+
console.error(`Try again, or pass ${(0, colour_js_1.accent)('--holder "Your Name"')} to say directly.`);
|
|
135
131
|
}
|
|
136
132
|
return 1;
|
|
137
133
|
}
|
|
@@ -139,19 +135,19 @@ async function commandLicence(parsed) {
|
|
|
139
135
|
const target = node_path_1.default.join(folder, licences_js_1.LICENCE_FILE);
|
|
140
136
|
const already = await (0, promises_1.readFile)(target, "utf8").catch(() => null);
|
|
141
137
|
if (already !== null && !parsed.flags.has("force")) {
|
|
142
|
-
console.error(red("This folder already has a LICENSE."));
|
|
143
|
-
console.error(dim(` ${already.split("\n")[0]?.trim() ?? ""}`));
|
|
138
|
+
console.error((0, colour_js_1.red)("This folder already has a LICENSE."));
|
|
139
|
+
console.error((0, colour_js_1.dim)(` ${already.split("\n")[0]?.trim() ?? ""}`));
|
|
144
140
|
console.error(`\nReplacing a licence changes the terms other people already received.` +
|
|
145
|
-
`\nPass ${accent("--force")} if that is what you mean.`);
|
|
141
|
+
`\nPass ${(0, colour_js_1.accent)("--force")} if that is what you mean.`);
|
|
146
142
|
return 1;
|
|
147
143
|
}
|
|
148
144
|
await (0, promises_1.writeFile)(target, (0, licences_js_1.licenceText)(licence.id, holder), "utf8");
|
|
149
|
-
console.log(green(`Wrote ${licence.name} to ${licences_js_1.LICENCE_FILE}.`));
|
|
145
|
+
console.log((0, colour_js_1.green)(`Wrote ${licence.name} to ${licences_js_1.LICENCE_FILE}.`));
|
|
150
146
|
if (licence.personalised)
|
|
151
|
-
console.log(dim(` in the name of ${holder}`));
|
|
152
|
-
console.log(dim(` ${licence.summary}`));
|
|
147
|
+
console.log((0, colour_js_1.dim)(` in the name of ${holder}`));
|
|
148
|
+
console.log((0, colour_js_1.dim)(` ${licence.summary}`));
|
|
153
149
|
console.log("");
|
|
154
|
-
console.log(dim("It is a file like any other, so it goes up with your next save."));
|
|
150
|
+
console.log((0, colour_js_1.dim)("It is a file like any other, so it goes up with your next save."));
|
|
155
151
|
return 0;
|
|
156
152
|
}
|
|
157
153
|
/**
|
|
@@ -169,7 +165,7 @@ async function commandIgnoreTemplate(parsed) {
|
|
|
169
165
|
const names = Object.values(ignore_templates_js_1.IGNORE_TEMPLATES)
|
|
170
166
|
.map((template) => template.name)
|
|
171
167
|
.sort((left, right) => left.localeCompare(right));
|
|
172
|
-
console.log(bold(`${names.length} sets of ignore rules`));
|
|
168
|
+
console.log((0, colour_js_1.bold)(`${names.length} sets of ignore rules`));
|
|
173
169
|
console.log("");
|
|
174
170
|
/* Four columns, because a list this long as one column is unreadable. */
|
|
175
171
|
const width = Math.max(...names.map((name) => name.length)) + 2;
|
|
@@ -178,14 +174,14 @@ async function commandIgnoreTemplate(parsed) {
|
|
|
178
174
|
console.log(" " + names.slice(at, at + perRow).map((name) => name.padEnd(width)).join(""));
|
|
179
175
|
}
|
|
180
176
|
console.log("");
|
|
181
|
-
console.log(`Add one with ${accent("cbx ignore --template Python")}. ` +
|
|
182
|
-
dim("Several is normal — a language, an editor, an operating system."));
|
|
177
|
+
console.log(`Add one with ${(0, colour_js_1.accent)("cbx ignore --template Python")}. ` +
|
|
178
|
+
(0, colour_js_1.dim)("Several is normal — a language, an editor, an operating system."));
|
|
183
179
|
return 0;
|
|
184
180
|
}
|
|
185
181
|
const template = ignore_templates_js_1.IGNORE_TEMPLATES[wanted.toLowerCase()];
|
|
186
182
|
if (!template) {
|
|
187
|
-
console.error(red(`No rules called ${wanted}.`));
|
|
188
|
-
console.error(`Run ${accent("cbx ignore --template list")} to see what there is.`);
|
|
183
|
+
console.error((0, colour_js_1.red)(`No rules called ${wanted}.`));
|
|
184
|
+
console.error(`Run ${(0, colour_js_1.accent)("cbx ignore --template list")} to see what there is.`);
|
|
189
185
|
return 1;
|
|
190
186
|
}
|
|
191
187
|
const rules = await (0, worktree_js_1.readRules)(folder);
|
|
@@ -198,10 +194,10 @@ async function commandIgnoreTemplate(parsed) {
|
|
|
198
194
|
const shared = `${body ? `${body}\n\n` : ""}${heading}\n${template.body}`;
|
|
199
195
|
await (0, worktree_js_1.writeRules)(folder, { ...rules, shared });
|
|
200
196
|
const lines = template.body.split("\n").filter((line) => line.trim() && !line.startsWith("#"));
|
|
201
|
-
console.log(green(`Added ${template.name} — ${lines.length} rules.`));
|
|
202
|
-
console.log(dim(` ${node_path_1.default.join(folder, ".gitignore")}`));
|
|
197
|
+
console.log((0, colour_js_1.green)(`Added ${template.name} — ${lines.length} rules.`));
|
|
198
|
+
console.log((0, colour_js_1.dim)(` ${node_path_1.default.join(folder, ".gitignore")}`));
|
|
203
199
|
console.log("");
|
|
204
|
-
console.log(dim(`See what it leaves behind with `) + accent("cbx status"));
|
|
200
|
+
console.log((0, colour_js_1.dim)(`See what it leaves behind with `) + (0, colour_js_1.accent)("cbx status"));
|
|
205
201
|
return 0;
|
|
206
202
|
}
|
|
207
203
|
function flagValue(parsed, name) {
|
package/dist/cli/src/network.js
CHANGED
|
@@ -60,17 +60,37 @@ function describeError(error) {
|
|
|
60
60
|
return "CodeRook did not answer in time. Check the connection, then try again.";
|
|
61
61
|
}
|
|
62
62
|
const cause = error.cause;
|
|
63
|
-
if (error.message === "fetch failed"
|
|
64
|
-
|
|
63
|
+
if (error.message === "fetch failed") {
|
|
64
|
+
/*
|
|
65
|
+
Said in words first, with the code after for whoever needs it. The most
|
|
66
|
+
common one, ENOTFOUND, is simply being offline: the name could not be
|
|
67
|
+
looked up. And a failure that carries no code at all used to fall
|
|
68
|
+
through to the bare "fetch failed" it exists to replace.
|
|
69
|
+
*/
|
|
70
|
+
const attempts = cause?.errors?.length ? cause.errors : cause ? [cause] : [];
|
|
71
|
+
const codes = [...new Set(attempts.map((one) => one.code).filter(Boolean))];
|
|
72
|
+
const said = codes.map((code) => PLAIN[code]).find(Boolean);
|
|
65
73
|
const named = attempts
|
|
66
74
|
.map((one) => [one.code, one.address].filter(Boolean).join(" "))
|
|
67
75
|
.filter(Boolean);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
const detail = named.length ? [...new Set(named)].join(", ") : cause?.message ?? "";
|
|
77
|
+
return (`Could not reach CodeRook${said ? `: ${said}` : ""}` +
|
|
78
|
+
(detail ? ` (${detail})` : "") +
|
|
79
|
+
". Check the connection, then try again.");
|
|
71
80
|
}
|
|
72
81
|
return error.message;
|
|
73
82
|
}
|
|
83
|
+
/** What each network failure means, for somebody who has not met the code. */
|
|
84
|
+
const PLAIN = {
|
|
85
|
+
ENOTFOUND: "its address could not be looked up, which usually means this computer is offline",
|
|
86
|
+
EAI_AGAIN: "its address could not be looked up, which usually means this computer is offline",
|
|
87
|
+
ECONNREFUSED: "the connection was refused",
|
|
88
|
+
ECONNRESET: "the connection was dropped",
|
|
89
|
+
ETIMEDOUT: "the connection timed out",
|
|
90
|
+
ENETUNREACH: "there is no route to the internet from here",
|
|
91
|
+
EHOSTUNREACH: "there is no route to the internet from here",
|
|
92
|
+
UND_ERR_CONNECT_TIMEOUT: "the connection timed out",
|
|
93
|
+
};
|
|
74
94
|
/** Wait, for a retry. */
|
|
75
95
|
function pause(milliseconds) {
|
|
76
96
|
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
@@ -24,11 +24,7 @@ const node_process_1 = __importDefault(require("node:process"));
|
|
|
24
24
|
const promises_1 = require("node:readline/promises");
|
|
25
25
|
const api_js_1 = require("./api.js");
|
|
26
26
|
const config_js_1 = require("./config.js");
|
|
27
|
-
const
|
|
28
|
-
const bold = (value) => `[1m${value}[0m`;
|
|
29
|
-
const red = (value) => `[31m${value}[0m`;
|
|
30
|
-
const green = (value) => `[32m${value}[0m`;
|
|
31
|
-
const accent = (value) => `[33m${value}[0m`;
|
|
27
|
+
const colour_js_1 = require("./colour.js");
|
|
32
28
|
function bytes(value) {
|
|
33
29
|
if (value >= 1024 ** 3)
|
|
34
30
|
return `${(value / 1024 ** 3).toFixed(2)} GB`;
|
|
@@ -48,12 +44,12 @@ function bytes(value) {
|
|
|
48
44
|
async function resolveProject(reference) {
|
|
49
45
|
const wanted = reference ?? (await (0, config_js_1.readLink)(node_process_1.default.cwd()))?.slug;
|
|
50
46
|
if (!wanted) {
|
|
51
|
-
console.error(red("Which project? Name one, or run this inside a linked folder."));
|
|
47
|
+
console.error((0, colour_js_1.red)("Which project? Name one, or run this inside a linked folder."));
|
|
52
48
|
return null;
|
|
53
49
|
}
|
|
54
50
|
const project = await (0, api_js_1.findProject)(wanted);
|
|
55
51
|
if (!project) {
|
|
56
|
-
console.error(red(`No project matching "${wanted}" on your account.`));
|
|
52
|
+
console.error((0, colour_js_1.red)(`No project matching "${wanted}" on your account.`));
|
|
57
53
|
return null;
|
|
58
54
|
}
|
|
59
55
|
return project;
|
|
@@ -112,19 +108,19 @@ async function commandAi(parsed) {
|
|
|
112
108
|
}
|
|
113
109
|
if (Object.keys(change).length) {
|
|
114
110
|
await (0, api_js_1.setAiAccess)(project.id, change);
|
|
115
|
-
console.log(green(`Updated ${project.name}.`));
|
|
111
|
+
console.log((0, colour_js_1.green)(`Updated ${project.name}.`));
|
|
116
112
|
}
|
|
117
113
|
const access = await (0, api_js_1.aiAccess)(project.id);
|
|
118
114
|
console.log("");
|
|
119
|
-
console.log(bold(project.name));
|
|
115
|
+
console.log((0, colour_js_1.bold)(project.name));
|
|
120
116
|
for (const [name, field, question, meaning] of AI_SWITCHES) {
|
|
121
|
-
const mark = access[field] ? green("allowed") : red("refused");
|
|
122
|
-
console.log(` ${question.padEnd(30)} ${mark} ${dim("--" + name)}`);
|
|
123
|
-
console.log(` ${dim(meaning)}`);
|
|
117
|
+
const mark = access[field] ? (0, colour_js_1.green)("allowed") : (0, colour_js_1.red)("refused");
|
|
118
|
+
console.log(` ${question.padEnd(30)} ${mark} ${(0, colour_js_1.dim)("--" + name)}`);
|
|
119
|
+
console.log(` ${(0, colour_js_1.dim)(meaning)}`);
|
|
124
120
|
}
|
|
125
121
|
console.log("");
|
|
126
|
-
console.log(dim("Everything is allowed until you say otherwise. Turning reading off is the"));
|
|
127
|
-
console.log(dim("one that refuses model training."));
|
|
122
|
+
console.log((0, colour_js_1.dim)("Everything is allowed until you say otherwise. Turning reading off is the"));
|
|
123
|
+
console.log((0, colour_js_1.dim)("one that refuses model training."));
|
|
128
124
|
return 0;
|
|
129
125
|
}
|
|
130
126
|
/**
|
|
@@ -230,7 +226,7 @@ async function agreed(question) {
|
|
|
230
226
|
async function commandVisibility(parsed) {
|
|
231
227
|
const asked = splitVisibility(parsed.positional);
|
|
232
228
|
if (asked.error) {
|
|
233
|
-
console.error(red(asked.error));
|
|
229
|
+
console.error((0, colour_js_1.red)(asked.error));
|
|
234
230
|
return 1;
|
|
235
231
|
}
|
|
236
232
|
const project = await resolveProject(asked.project);
|
|
@@ -238,10 +234,10 @@ async function commandVisibility(parsed) {
|
|
|
238
234
|
return 1;
|
|
239
235
|
const current = readLevel(project.visibility) ?? "private";
|
|
240
236
|
if (!asked.level) {
|
|
241
|
-
console.log(`${bold(project.name)} is ${accent(wordFor(current))}.`);
|
|
237
|
+
console.log(`${(0, colour_js_1.bold)(project.name)} is ${(0, colour_js_1.accent)(wordFor(current))}.`);
|
|
242
238
|
for (const [level, , meaning] of LEVELS) {
|
|
243
|
-
const mark = level === current ? accent("›") : " ";
|
|
244
|
-
console.log(` ${mark} ${level.padEnd(9)} ${dim(meaning)}`);
|
|
239
|
+
const mark = level === current ? (0, colour_js_1.accent)("›") : " ";
|
|
240
|
+
console.log(` ${mark} ${level.padEnd(9)} ${(0, colour_js_1.dim)(meaning)}`);
|
|
245
241
|
}
|
|
246
242
|
if (current === "public") {
|
|
247
243
|
const address = await publicAddress(project);
|
|
@@ -249,7 +245,7 @@ async function commandVisibility(parsed) {
|
|
|
249
245
|
console.log(`\n ${address}`);
|
|
250
246
|
}
|
|
251
247
|
console.log("");
|
|
252
|
-
console.log(dim(`Change it with: cbx visibility <level>` +
|
|
248
|
+
console.log((0, colour_js_1.dim)(`Change it with: cbx visibility <level>` +
|
|
253
249
|
(asked.project ? ` ${asked.project}` : "")));
|
|
254
250
|
return 0;
|
|
255
251
|
}
|
|
@@ -268,14 +264,14 @@ async function commandVisibility(parsed) {
|
|
|
268
264
|
tells whoever wrote the script what to do about it.
|
|
269
265
|
*/
|
|
270
266
|
if (asking && !node_process_1.default.stdin.isTTY) {
|
|
271
|
-
console.error(red(`Making ${project.name} ${wordFor(target)} needs a yes, and nobody is here to give one.`));
|
|
272
|
-
console.error(dim(" Run it in a terminal to be asked, or add --yes."));
|
|
267
|
+
console.error((0, colour_js_1.red)(`Making ${project.name} ${wordFor(target)} needs a yes, and nobody is here to give one.`));
|
|
268
|
+
console.error((0, colour_js_1.dim)(" Run it in a terminal to be asked, or add --yes."));
|
|
273
269
|
return 1;
|
|
274
270
|
}
|
|
275
271
|
const offered = target === "public" ? offeredPublicly(await (0, api_js_1.versions)(project.id)) : [];
|
|
276
272
|
if (asking) {
|
|
277
273
|
if (target === "public") {
|
|
278
|
-
console.log(`Making ${bold(project.name)} public lists it on your profile and in search.`);
|
|
274
|
+
console.log(`Making ${(0, colour_js_1.bold)(project.name)} public lists it on your profile and in search.`);
|
|
279
275
|
if (offered.length) {
|
|
280
276
|
const names = offered.slice(0, 5).map((one) => one.name).join(", ");
|
|
281
277
|
const more = offered.length > 5 ? ` and ${offered.length - 5} more` : "";
|
|
@@ -284,13 +280,13 @@ async function commandVisibility(parsed) {
|
|
|
284
280
|
else {
|
|
285
281
|
console.log(" Its page will be empty until a save is named — cbx promote does that.");
|
|
286
282
|
}
|
|
287
|
-
console.log(dim(" Saves nobody named, and versions you hid, are not on the page."));
|
|
283
|
+
console.log((0, colour_js_1.dim)(" Saves nobody named, and versions you hid, are not on the page."));
|
|
288
284
|
}
|
|
289
285
|
else {
|
|
290
|
-
console.log(`Making ${bold(project.name)} link only keeps it off your profile and out of search.`);
|
|
286
|
+
console.log(`Making ${(0, colour_js_1.bold)(project.name)} link only keeps it off your profile and out of search.`);
|
|
291
287
|
}
|
|
292
288
|
if (!(await agreed(`Make ${project.name} ${wordFor(target)}? [y/N] `))) {
|
|
293
|
-
console.log(dim(`Nothing changed. ${project.name} is still ${wordFor(current)}.`));
|
|
289
|
+
console.log((0, colour_js_1.dim)(`Nothing changed. ${project.name} is still ${wordFor(current)}.`));
|
|
294
290
|
return 1;
|
|
295
291
|
}
|
|
296
292
|
}
|
|
@@ -298,23 +294,23 @@ async function commandVisibility(parsed) {
|
|
|
298
294
|
await (0, api_js_1.updateProject)(project.id, { visibility: target });
|
|
299
295
|
}
|
|
300
296
|
catch (error) {
|
|
301
|
-
console.error(red(error instanceof Error ? error.message : String(error)));
|
|
297
|
+
console.error((0, colour_js_1.red)(error instanceof Error ? error.message : String(error)));
|
|
302
298
|
return 1;
|
|
303
299
|
}
|
|
304
300
|
if (target === "public") {
|
|
305
301
|
const address = await publicAddress(project);
|
|
306
|
-
console.log(green(`${project.name} is now public`) + (address ? `: ${address}` : "."));
|
|
307
|
-
console.log(dim(offered.length
|
|
302
|
+
console.log((0, colour_js_1.green)(`${project.name} is now public`) + (address ? `: ${address}` : "."));
|
|
303
|
+
console.log((0, colour_js_1.dim)(offered.length
|
|
308
304
|
? ` Its page offers ${offered.length} named version${offered.length === 1 ? "" : "s"}.`
|
|
309
305
|
: " Its page is empty until a save is named — cbx promote does that."));
|
|
310
306
|
}
|
|
311
307
|
else if (target === "unlisted") {
|
|
312
|
-
console.log(green(`${project.name} is now link only.`));
|
|
313
|
-
console.log(dim(" It is not listed anywhere; any account signed in with its link can read it."));
|
|
308
|
+
console.log((0, colour_js_1.green)(`${project.name} is now link only.`));
|
|
309
|
+
console.log((0, colour_js_1.dim)(" It is not listed anywhere; any account signed in with its link can read it."));
|
|
314
310
|
}
|
|
315
311
|
else {
|
|
316
|
-
console.log(green(`${project.name} is now private.`));
|
|
317
|
-
console.log(dim(" Only you and the people you invite can reach it."));
|
|
312
|
+
console.log((0, colour_js_1.green)(`${project.name} is now private.`));
|
|
313
|
+
console.log((0, colour_js_1.dim)(" Only you and the people you invite can reach it."));
|
|
318
314
|
}
|
|
319
315
|
return 0;
|
|
320
316
|
}
|
|
@@ -325,7 +321,7 @@ async function commandVersions(parsed) {
|
|
|
325
321
|
return 1;
|
|
326
322
|
const saved = await (0, api_js_1.versions)(project.id);
|
|
327
323
|
if (!saved.length) {
|
|
328
|
-
console.log(dim("Nothing has been saved to this project yet."));
|
|
324
|
+
console.log((0, colour_js_1.dim)("Nothing has been saved to this project yet."));
|
|
329
325
|
return 0;
|
|
330
326
|
}
|
|
331
327
|
/*
|
|
@@ -340,7 +336,7 @@ async function commandVersions(parsed) {
|
|
|
340
336
|
const onlyVersions = parsed.flags.get("versions") === true;
|
|
341
337
|
const onlyCommits = parsed.flags.get("commits") === true;
|
|
342
338
|
if (onlyVersions && onlyCommits) {
|
|
343
|
-
console.error(red("Pick one: --versions or --commits, or neither for both."));
|
|
339
|
+
console.error((0, colour_js_1.red)("Pick one: --versions or --commits, or neither for both."));
|
|
344
340
|
return 1;
|
|
345
341
|
}
|
|
346
342
|
const lane = saved.filter((version) => {
|
|
@@ -351,7 +347,7 @@ async function commandVersions(parsed) {
|
|
|
351
347
|
return true;
|
|
352
348
|
});
|
|
353
349
|
if (!lane.length) {
|
|
354
|
-
console.log(dim(onlyVersions
|
|
350
|
+
console.log((0, colour_js_1.dim)(onlyVersions
|
|
355
351
|
? "Nothing has been made a version yet."
|
|
356
352
|
: "Every save here has been made a version."));
|
|
357
353
|
return 0;
|
|
@@ -359,7 +355,7 @@ async function commandVersions(parsed) {
|
|
|
359
355
|
const withNotes = parsed.flags.get("notes") === true;
|
|
360
356
|
const asked = Number(parsed.flags.get("limit") ?? 20);
|
|
361
357
|
const limit = Number.isFinite(asked) && asked > 0 ? asked : 20;
|
|
362
|
-
console.log(bold(project.name));
|
|
358
|
+
console.log((0, colour_js_1.bold)(project.name));
|
|
363
359
|
for (const version of lane.slice(0, limit)) {
|
|
364
360
|
const when = version.createdAt
|
|
365
361
|
? new Date(version.createdAt).toLocaleString()
|
|
@@ -375,24 +371,24 @@ async function commandVersions(parsed) {
|
|
|
375
371
|
const marks = [
|
|
376
372
|
/* Which one the project is standing on, which is not the same as which
|
|
377
373
|
one is at the top once somebody has pinned something. */
|
|
378
|
-
version.head ? green("current") : "",
|
|
379
|
-
version.pinned ? accent("pinned") : "",
|
|
380
|
-
version.name ? bold(version.name) : "",
|
|
381
|
-
version.state === "held" ? red("held") : "",
|
|
382
|
-
version.state === "declined" ? dim("declined") : "",
|
|
383
|
-
version.removedAt ? dim("taken down") : "",
|
|
374
|
+
version.head ? (0, colour_js_1.green)("current") : "",
|
|
375
|
+
version.pinned ? (0, colour_js_1.accent)("pinned") : "",
|
|
376
|
+
version.name ? (0, colour_js_1.bold)(version.name) : "",
|
|
377
|
+
version.state === "held" ? (0, colour_js_1.red)("held") : "",
|
|
378
|
+
version.state === "declined" ? (0, colour_js_1.dim)("declined") : "",
|
|
379
|
+
version.removedAt ? (0, colour_js_1.dim)("taken down") : "",
|
|
384
380
|
/*
|
|
385
381
|
Said only of a version, because only a version is offered to anybody.
|
|
386
382
|
A commit nobody has promoted is not hidden — it was never on offer.
|
|
387
383
|
*/
|
|
388
|
-
version.name && version.visibility === "private" ? dim("hidden") : "",
|
|
389
|
-
...version.labels.map((label) => accent(label.name)),
|
|
384
|
+
version.name && version.visibility === "private" ? (0, colour_js_1.dim)("hidden") : "",
|
|
385
|
+
...version.labels.map((label) => (0, colour_js_1.accent)(label.name)),
|
|
390
386
|
].filter(Boolean);
|
|
391
|
-
console.log(` ${accent(`v${version.sequence}`).padEnd(16)} ${when.padEnd(22)}` +
|
|
387
|
+
console.log(` ${(0, colour_js_1.accent)(`v${version.sequence}`).padEnd(16)} ${when.padEnd(22)}` +
|
|
392
388
|
`${String(version.fileCount).padStart(5)} files ${bytes(version.storedSize)}` +
|
|
393
389
|
(marks.length ? ` ${marks.join(" ")}` : ""));
|
|
394
390
|
if (version.message)
|
|
395
|
-
console.log(` ${dim(version.message)}`);
|
|
391
|
+
console.log(` ${(0, colour_js_1.dim)(version.message)}`);
|
|
396
392
|
/*
|
|
397
393
|
Indented under the save it belongs to rather than printed flat, so a
|
|
398
394
|
note of several paragraphs still reads as part of one row.
|
|
@@ -404,7 +400,7 @@ async function commandVersions(parsed) {
|
|
|
404
400
|
}
|
|
405
401
|
}
|
|
406
402
|
if (lane.length > limit) {
|
|
407
|
-
console.log(dim(` … ${lane.length - limit} older. Use --limit to see more.`));
|
|
403
|
+
console.log((0, colour_js_1.dim)(` … ${lane.length - limit} older. Use --limit to see more.`));
|
|
408
404
|
}
|
|
409
405
|
return 0;
|
|
410
406
|
}
|