@todoforai/cli 0.1.36 → 0.1.37
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/todoforai-cli.js +85 -30
- package/package.json +1 -1
package/dist/todoforai-cli.js
CHANGED
|
@@ -42893,8 +42893,8 @@ class ApiClient {
|
|
|
42893
42893
|
form.append("file", file, filename);
|
|
42894
42894
|
form.append("todoId", todoId);
|
|
42895
42895
|
for (const [k, v] of Object.entries(opts))
|
|
42896
|
-
if (v)
|
|
42897
|
-
form.append(k, v);
|
|
42896
|
+
if (v !== undefined && v !== "")
|
|
42897
|
+
form.append(k, String(v));
|
|
42898
42898
|
const url = `${this.apiUrl}${restBasePath(this.apiKey)}/resources/show`;
|
|
42899
42899
|
const res = await fetch(url, {
|
|
42900
42900
|
method: "POST",
|
|
@@ -42932,6 +42932,61 @@ class ApiClient {
|
|
|
42932
42932
|
throw new Error(`API GET /resources/show failed: ${res.status} ${await res.text()}`);
|
|
42933
42933
|
return res.json();
|
|
42934
42934
|
}
|
|
42935
|
+
async pushSite(file, filename, opts = {}) {
|
|
42936
|
+
const form = new FormData;
|
|
42937
|
+
form.append("file", file, filename);
|
|
42938
|
+
for (const [k, v] of Object.entries(opts))
|
|
42939
|
+
if (v !== undefined && v !== "")
|
|
42940
|
+
form.append(k, String(v));
|
|
42941
|
+
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites`, {
|
|
42942
|
+
method: "POST",
|
|
42943
|
+
headers: { "x-api-key": this.apiKey },
|
|
42944
|
+
body: form,
|
|
42945
|
+
signal: AbortSignal.timeout(120000)
|
|
42946
|
+
});
|
|
42947
|
+
if (!res.ok)
|
|
42948
|
+
throw new Error(`API POST /resources/sites failed: ${res.status} ${await res.text()}`);
|
|
42949
|
+
return res.json();
|
|
42950
|
+
}
|
|
42951
|
+
async listSites() {
|
|
42952
|
+
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites`, {
|
|
42953
|
+
headers: { "x-api-key": this.apiKey },
|
|
42954
|
+
signal: AbortSignal.timeout(30000)
|
|
42955
|
+
});
|
|
42956
|
+
if (!res.ok)
|
|
42957
|
+
throw new Error(`API GET /resources/sites failed: ${res.status} ${await res.text()}`);
|
|
42958
|
+
return res.json();
|
|
42959
|
+
}
|
|
42960
|
+
async getSiteBytes(siteId, version) {
|
|
42961
|
+
const qs = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
42962
|
+
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites/${siteId}/bytes${qs}`, {
|
|
42963
|
+
headers: { "x-api-key": this.apiKey },
|
|
42964
|
+
signal: AbortSignal.timeout(120000)
|
|
42965
|
+
});
|
|
42966
|
+
if (!res.ok)
|
|
42967
|
+
throw new Error(`API GET site bytes failed: ${res.status} ${await res.text()}`);
|
|
42968
|
+
return res.arrayBuffer();
|
|
42969
|
+
}
|
|
42970
|
+
async patchSite(siteId, body) {
|
|
42971
|
+
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites/${siteId}`, {
|
|
42972
|
+
method: "PATCH",
|
|
42973
|
+
headers: { "x-api-key": this.apiKey, "Content-Type": "application/json" },
|
|
42974
|
+
body: JSON.stringify(body),
|
|
42975
|
+
signal: AbortSignal.timeout(30000)
|
|
42976
|
+
});
|
|
42977
|
+
if (!res.ok)
|
|
42978
|
+
throw new Error(`API PATCH site failed: ${res.status} ${await res.text()}`);
|
|
42979
|
+
return res.json();
|
|
42980
|
+
}
|
|
42981
|
+
async deleteSite(siteId) {
|
|
42982
|
+
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites/${siteId}`, {
|
|
42983
|
+
method: "DELETE",
|
|
42984
|
+
headers: { "x-api-key": this.apiKey },
|
|
42985
|
+
signal: AbortSignal.timeout(30000)
|
|
42986
|
+
});
|
|
42987
|
+
if (!res.ok)
|
|
42988
|
+
throw new Error(`API DELETE site failed: ${res.status} ${await res.text()}`);
|
|
42989
|
+
}
|
|
42935
42990
|
async upsertCard(projectId, name, html, opts = {}) {
|
|
42936
42991
|
const form = new FormData;
|
|
42937
42992
|
form.append("file", html, `${name}.html`);
|
|
@@ -44303,7 +44358,7 @@ import { parseArgs } from "util";
|
|
|
44303
44358
|
// package.json
|
|
44304
44359
|
var package_default = {
|
|
44305
44360
|
name: "@todoforai/cli",
|
|
44306
|
-
version: "0.1.
|
|
44361
|
+
version: "0.1.37",
|
|
44307
44362
|
type: "module",
|
|
44308
44363
|
bin: {
|
|
44309
44364
|
"todoforai-cli": "bin/todoforai-cli.js",
|
|
@@ -47650,6 +47705,33 @@ Cancelled by user (Ctrl+C)
|
|
|
47650
47705
|
}
|
|
47651
47706
|
return;
|
|
47652
47707
|
}
|
|
47708
|
+
if (positionals[0] === "show" && ["public", "get", "rm"].includes(positionals[1] ?? "")) {
|
|
47709
|
+
const sub = positionals[1];
|
|
47710
|
+
const id = positionals[2];
|
|
47711
|
+
if (!id) {
|
|
47712
|
+
process.stderr.write(`${RED}Usage: tfa-cli show public <site-id> [--off] | get <site-id> [out] [--rev <att>] | rm <site-id>${RESET}
|
|
47713
|
+
`);
|
|
47714
|
+
process.exit(2);
|
|
47715
|
+
}
|
|
47716
|
+
if (sub === "public") {
|
|
47717
|
+
const site = await api.patchSite(id, { isPublic: !args.off });
|
|
47718
|
+
console.log(site.url ?? `${site.id} (private)`);
|
|
47719
|
+
} else if (sub === "rm") {
|
|
47720
|
+
await api.deleteSite(id);
|
|
47721
|
+
process.stderr.write(`${GREEN}\u2705 deleted ${id}${RESET}
|
|
47722
|
+
`);
|
|
47723
|
+
} else {
|
|
47724
|
+
const bytes = await api.getSiteBytes(id, args.rev);
|
|
47725
|
+
const out = positionals[3];
|
|
47726
|
+
if (out && out !== "-") {
|
|
47727
|
+
await Bun.write(resolve3(out), bytes);
|
|
47728
|
+
process.stderr.write(`${GREEN}\u2705 ${out}${RESET}
|
|
47729
|
+
`);
|
|
47730
|
+
} else
|
|
47731
|
+
process.stdout.write(new Uint8Array(bytes));
|
|
47732
|
+
}
|
|
47733
|
+
return;
|
|
47734
|
+
}
|
|
47653
47735
|
if (positionals[0] === "show") {
|
|
47654
47736
|
const [, filePath, todoArg] = positionals;
|
|
47655
47737
|
const todoId = todoArg || getEnv("TODO_ID") || cfgScope.data.last_todo_id;
|
|
@@ -47692,33 +47774,6 @@ Cancelled by user (Ctrl+C)
|
|
|
47692
47774
|
console.log(res.siteUrl ? `${res.ref} site=${res.siteId} ${res.siteUrl}` : `${res.ref} site=${res.siteId}`);
|
|
47693
47775
|
return;
|
|
47694
47776
|
}
|
|
47695
|
-
if (positionals[0] === "show" && ["public", "get", "rm"].includes(positionals[1] ?? "")) {
|
|
47696
|
-
const sub = positionals[1];
|
|
47697
|
-
const id = positionals[2];
|
|
47698
|
-
if (!id) {
|
|
47699
|
-
process.stderr.write(`${RED}Usage: tfa-cli show public <site-id> [--off] | get <site-id> [out] [--rev <att>] | rm <site-id>${RESET}
|
|
47700
|
-
`);
|
|
47701
|
-
process.exit(2);
|
|
47702
|
-
}
|
|
47703
|
-
if (sub === "public") {
|
|
47704
|
-
const site = await api.patchSite(id, { isPublic: !args.off });
|
|
47705
|
-
console.log(site.url ?? `${site.id} (private)`);
|
|
47706
|
-
} else if (sub === "rm") {
|
|
47707
|
-
await api.deleteSite(id);
|
|
47708
|
-
process.stderr.write(`${GREEN}\u2705 deleted ${id}${RESET}
|
|
47709
|
-
`);
|
|
47710
|
-
} else {
|
|
47711
|
-
const bytes = await api.getSiteBytes(id, args.rev);
|
|
47712
|
-
const out = positionals[3];
|
|
47713
|
-
if (out && out !== "-") {
|
|
47714
|
-
await Bun.write(resolve3(out), bytes);
|
|
47715
|
-
process.stderr.write(`${GREEN}\u2705 ${out}${RESET}
|
|
47716
|
-
`);
|
|
47717
|
-
} else
|
|
47718
|
-
process.stdout.write(new Uint8Array(bytes));
|
|
47719
|
-
}
|
|
47720
|
-
return;
|
|
47721
|
-
}
|
|
47722
47777
|
if (positionals[0] === "open") {
|
|
47723
47778
|
const [, url, todoArg] = positionals;
|
|
47724
47779
|
const todoId = todoArg || getEnv("TODO_ID") || cfgScope.data.last_todo_id;
|