notusci 0.1.9 → 0.1.10
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/package.json +1 -1
- package/src/cli.mjs +5 -0
- package/src/core.mjs +8 -2
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -347,6 +347,11 @@ async function main(s, input) {
|
|
|
347
347
|
case "doctor": return doctor(s);
|
|
348
348
|
case "login": return login(s, input);
|
|
349
349
|
case "billing": return billing(s, input);
|
|
350
|
+
case "usage": {
|
|
351
|
+
const repo = repoOrOrigin(input.repo);
|
|
352
|
+
return print(input.capUsd === undefined ? await api(s, "/api/usage", { query: { repo } })
|
|
353
|
+
: await api(s, "/api/usage/cap", { method: "POST", body: { repo, capUsd: input.capUsd } }));
|
|
354
|
+
}
|
|
350
355
|
case "logout": return logout(s);
|
|
351
356
|
case "whoami": {
|
|
352
357
|
const { user, scopes, repos, installUrl } = await api(s, "/api/whoami");
|
package/src/core.mjs
CHANGED
|
@@ -44,12 +44,13 @@ const OPTIONS = {
|
|
|
44
44
|
repo: { repo: { type: "string" }, settings: { type: "string" }, "push-workflow": { type: "string" }, off: { type: "boolean" }, "image-from-workspace": { type: "string" }, "image-from-dockerfile": { type: "boolean" } },
|
|
45
45
|
migrations: { repo: { type: "string" }, push: { type: "string" }, reason: { type: "string" }, "force-destructive": { type: "boolean" } },
|
|
46
46
|
billing: { repo: { type: "string" }, timeout: { type: "string" } },
|
|
47
|
+
usage: { repo: { type: "string" }, cap: { type: "string" } },
|
|
47
48
|
api: { data: { type: "string" } },
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
export const HELP = {
|
|
51
52
|
commands: [
|
|
52
|
-
"init [--scope SCOPES] [--no-mcp] [--billing]", "billing [--repo OWNER/REPO] [--timeout SECONDS]", "doctor",
|
|
53
|
+
"init [--scope SCOPES] [--no-mcp] [--billing]", "billing [--repo OWNER/REPO] [--timeout SECONDS]", "usage [--repo OWNER/REPO] [--cap USD]", "doctor",
|
|
53
54
|
"login [--scope SCOPES]", "logout", "whoami", "repos", "token list", "token revoke ID",
|
|
54
55
|
"target set [--repo OWNER/REPO] [--file TARGET.json] [--auto-promote on|off] [--auto-release on|off]",
|
|
55
56
|
"secret set NAME [--repo OWNER/REPO] (value on stdin)", "secret list [--repo OWNER/REPO]", "secret rm NAME [--repo OWNER/REPO]",
|
|
@@ -179,6 +180,11 @@ export function parseCommand(args) {
|
|
|
179
180
|
return { command, workflow: values.workflow, timeoutSeconds: timeoutSeconds ?? 540, ...(values["no-reuse"] ? { reuse: false } : {}) };
|
|
180
181
|
}
|
|
181
182
|
if (command === "billing") { expect(); return { command, repo: values.repo, timeoutSeconds: timeoutSeconds ?? 90 }; }
|
|
183
|
+
if (command === "usage") {
|
|
184
|
+
expect(); const capUsd = values.cap === undefined ? undefined : Number(values.cap);
|
|
185
|
+
if (capUsd !== undefined && !(capUsd >= 0)) throw usage("--cap must be a number of dollars, 0 or more");
|
|
186
|
+
return { command, repo: values.repo, ...(capUsd !== undefined ? { capUsd } : {}) };
|
|
187
|
+
}
|
|
182
188
|
if (command === "search-logs") {
|
|
183
189
|
expect("*"); const runId = /^[1-9]\d*$/.test(positionals[0]) ? Number(positionals[0]) : positionals[0].toLowerCase();
|
|
184
190
|
if ((typeof runId === "number" ? !Number.isSafeInteger(runId) : !isPushRunId(runId)) || !values.query) throw usage("search-logs requires a valid ID and --query");
|
|
@@ -236,7 +242,7 @@ export function renderError({ error = "", code, next, ...extra }, now = Date.now
|
|
|
236
242
|
next: `Tell the human the monthly limit is reached and resets on ${resetsOn}. Do not retry.`, ...extra, resetsOn };
|
|
237
243
|
}
|
|
238
244
|
if (code === "payment_required") {
|
|
239
|
-
return { error: "
|
|
245
|
+
return { error: "This account's NotusCI minutes are used up (Free: 1,000 a month; the Pro trial: 3,000). Upgrade to Pro to continue.", code,
|
|
240
246
|
next: `${NPX} billing`, ...extra };
|
|
241
247
|
}
|
|
242
248
|
if (code === "missing_scope") return { error, code, next: `${NPX} login --scope ${String(extra.scopes)}`, ...extra };
|