@erdoai/cli 0.5.0 → 0.5.1
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/index.js +32 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -966,6 +966,15 @@ function readMaybeFile(v) {
|
|
|
966
966
|
if (!v) return void 0;
|
|
967
967
|
return v.startsWith("@") ? readFileSync2(v.slice(1), "utf8") : v;
|
|
968
968
|
}
|
|
969
|
+
function grantList(v) {
|
|
970
|
+
if (v === void 0) return void 0;
|
|
971
|
+
if (v.trim() === "[]") return [];
|
|
972
|
+
const slugs = v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
973
|
+
if (slugs.length === 0) {
|
|
974
|
+
throw new Error(`expected comma-separated slugs, or "[]" to clear \u2014 got ${JSON.stringify(v)}`);
|
|
975
|
+
}
|
|
976
|
+
return slugs;
|
|
977
|
+
}
|
|
969
978
|
pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/--css accept @file").requiredOption("--title <title>", "page title").requiredOption("--html <htmlOr@file>", "HTML (or @path to a file)").option("--js <jsOr@file>", "JS/JSX (or @path)").option("--css <cssOr@file>", "CSS (or @path)").option("--runtime <runtime>", "react-tailwind (default) or none").option("--datasets <csv>", "dataset slugs the page reads").option("--writable-datasets <csv>", "dataset slugs the page may write via erdo.insertRows").option("--kv <csv>", "named KV-store slugs the page reads").option("--writable-kv <csv>", "named KV-store slugs the page may write").option("--public", "make the page publicly viewable").action(
|
|
970
979
|
async (opts) => {
|
|
971
980
|
try {
|
|
@@ -989,6 +998,29 @@ pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/
|
|
|
989
998
|
}
|
|
990
999
|
}
|
|
991
1000
|
);
|
|
1001
|
+
pagesCmd.command("update <id>").description(
|
|
1002
|
+
"Update an existing page by id; provided fields are merged (update just --js to keep html/css). --html/--js/--css accept @file"
|
|
1003
|
+
).option("--title <title>", "new title").option("--html <htmlOr@file>", "HTML (or @path to a file)").option("--js <jsOr@file>", "JS/JSX (or @path)").option("--css <cssOr@file>", "CSS (or @path)").option("--datasets <csv>", 'replacement read-dataset slugs ("[]" clears)').option("--writable-datasets <csv>", 'replacement writable-dataset slugs ("[]" clears)').option("--kv <csv>", 'replacement read KV-store slugs ("[]" clears)').option("--writable-kv <csv>", 'replacement writable KV-store slugs ("[]" clears)').option("--public", "make the page publicly viewable").option("--private", "make the page private").action(
|
|
1004
|
+
async (id, opts) => {
|
|
1005
|
+
try {
|
|
1006
|
+
const res = await new ErdoClient().updatePage(id, {
|
|
1007
|
+
title: opts.title,
|
|
1008
|
+
html: readMaybeFile(opts.html),
|
|
1009
|
+
js: readMaybeFile(opts.js),
|
|
1010
|
+
css: readMaybeFile(opts.css),
|
|
1011
|
+
dataset_slugs: grantList(opts.datasets),
|
|
1012
|
+
writable_dataset_slugs: grantList(opts.writableDatasets),
|
|
1013
|
+
kv_slugs: grantList(opts.kv),
|
|
1014
|
+
writable_kv_slugs: grantList(opts.writableKv),
|
|
1015
|
+
public: opts.public ? true : opts.private ? false : void 0
|
|
1016
|
+
});
|
|
1017
|
+
console.log(`${res.id} ${res.public_url || res.url}`);
|
|
1018
|
+
if (res.warning) console.error(`warning: ${res.warning}`);
|
|
1019
|
+
} catch (e) {
|
|
1020
|
+
fail(e);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
);
|
|
992
1024
|
pagesCmd.command("validate").description("Validate page content without deploying").requiredOption("--html <htmlOr@file>", "HTML (or @path)").option("--js <jsOr@file>", "JS/JSX (or @path)").option("--css <cssOr@file>", "CSS (or @path)").option("--runtime <runtime>", "react-tailwind (default) or none").action(async (opts) => {
|
|
993
1025
|
try {
|
|
994
1026
|
print(
|