cloudtifact 0.3.1 → 0.3.2
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 +37 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6767,6 +6767,7 @@ const commentSchema = object({
|
|
|
6767
6767
|
resolvedAt: number$1().nullable(),
|
|
6768
6768
|
resolvedBy: userSchema.nullable(),
|
|
6769
6769
|
resolvedVia: string().nullable(),
|
|
6770
|
+
resolvedVersion: number$1().nullable().default(null),
|
|
6770
6771
|
editedAt: number$1().nullable(),
|
|
6771
6772
|
editedBy: userSchema.nullable(),
|
|
6772
6773
|
editedVia: string().nullable(),
|
|
@@ -12780,8 +12781,12 @@ function commentsUrl(shareUrl) {
|
|
|
12780
12781
|
*/
|
|
12781
12782
|
function linkLines(space, prefix) {
|
|
12782
12783
|
const share = space.shareUrl && prefix ? space.shareUrl + prefix : space.shareUrl;
|
|
12783
|
-
if (share) return [
|
|
12784
|
-
|
|
12784
|
+
if (share) return [
|
|
12785
|
+
`Page: ${share}`,
|
|
12786
|
+
`With comments: ${commentsUrl(share)}`,
|
|
12787
|
+
`Public: anyone with the link can open it. To make it private: cloudy settings --space ${space.id} --visibility private`
|
|
12788
|
+
];
|
|
12789
|
+
return [`Link: ${prefix ? `${space.url}/${prefix}index.html` : space.url}`, `Private: only members of the ${space.workspace.slug} workspace can open it. To make it public: cloudy settings --space ${space.id} --visibility public (space admins), or the space's Settings on the website.`];
|
|
12785
12790
|
}
|
|
12786
12791
|
/** A local, relative reference, or null for absolute URLs, data:, anchors, etc. Drops ?query and #hash. */
|
|
12787
12792
|
function localRef(raw) {
|
|
@@ -13043,7 +13048,7 @@ function tokenSpace(token) {
|
|
|
13043
13048
|
//#endregion
|
|
13044
13049
|
//#region src/version.ts
|
|
13045
13050
|
/** This CLI's version, from package.json at build time (tsdown.config.ts). Unbuilt (tests, tsx): "0.0.0-dev". */
|
|
13046
|
-
const VERSION = "0.3.
|
|
13051
|
+
const VERSION = "0.3.2";
|
|
13047
13052
|
/**
|
|
13048
13053
|
* Sent on every API request, so the API can tell which CLI version is calling (and one day tell an old one to
|
|
13049
13054
|
* upgrade). Without it Node sends just "node", which is what 0.2.2 and older send. The sign-in page shows it too.
|
|
@@ -14307,6 +14312,17 @@ const SETTINGS = [
|
|
|
14307
14312
|
get: (s) => s.guestComments
|
|
14308
14313
|
}
|
|
14309
14314
|
];
|
|
14315
|
+
/**
|
|
14316
|
+
* `--visibility`: who can open the space. private (members of its workspace) or public (anyone with the link); the
|
|
14317
|
+
* API calls private "members", and members stays an alias, as in `gh repo edit --visibility`.
|
|
14318
|
+
*/
|
|
14319
|
+
const VISIBILITY_OPTION = "--visibility <private|public>";
|
|
14320
|
+
function visibilityOf(value) {
|
|
14321
|
+
const v = value.trim().toLowerCase();
|
|
14322
|
+
if (v === "private" || v === "members") return "members";
|
|
14323
|
+
if (v === "public") return "public";
|
|
14324
|
+
throw new CliError(`--visibility takes private or public, not ${value}.`);
|
|
14325
|
+
}
|
|
14310
14326
|
function onOff(value, option) {
|
|
14311
14327
|
const v = value.trim().toLowerCase();
|
|
14312
14328
|
if (v === "on" || v === "true" || v === "yes") return true;
|
|
@@ -14316,6 +14332,7 @@ function onOff(value, option) {
|
|
|
14316
14332
|
/** The PATCH /v1/spaces/:id body for the flags given; null when there are none. */
|
|
14317
14333
|
function settingsPatch(opts) {
|
|
14318
14334
|
const patch = {};
|
|
14335
|
+
if (opts.visibility !== void 0) patch.visibility = visibilityOf(opts.visibility);
|
|
14319
14336
|
for (const s of SETTINGS) {
|
|
14320
14337
|
const value = opts[s.flag];
|
|
14321
14338
|
if (value === void 0) continue;
|
|
@@ -14347,7 +14364,7 @@ function settingsData(space) {
|
|
|
14347
14364
|
};
|
|
14348
14365
|
}
|
|
14349
14366
|
function settingsText(space) {
|
|
14350
|
-
const lines = [`${space.name} (${space.id}) · ${space.visibility === "public" ? "public" : "members only"}`];
|
|
14367
|
+
const lines = [`${space.name} (${space.id}) · ${space.visibility === "public" ? "public" : "private (members only)"}`];
|
|
14351
14368
|
for (const s of SETTINGS) lines.push(` ${s.get(space) ? "on " : "off"} ${s.label} (${s.option.split(" ")[0]})`);
|
|
14352
14369
|
if (space.shareUrl) {
|
|
14353
14370
|
lines.push(` Public link ${space.shareUrl}`);
|
|
@@ -14357,7 +14374,7 @@ function settingsText(space) {
|
|
|
14357
14374
|
lines.push(` Always works ${always.href}`);
|
|
14358
14375
|
}
|
|
14359
14376
|
}
|
|
14360
|
-
if (space.visibility !== "public") lines.push("Guest writes and guest comments need a public space.");
|
|
14377
|
+
if (space.visibility !== "public") lines.push("Guest writes and guest comments need a public space (--visibility public, space admins).");
|
|
14361
14378
|
return `${lines.join("\n")}\n`;
|
|
14362
14379
|
}
|
|
14363
14380
|
//#endregion
|
|
@@ -14429,13 +14446,13 @@ When you make an HTML page for the user, run \`cloudy publish <file.html>\` and
|
|
|
14429
14446
|
|
|
14430
14447
|
- To update it, edit the same file and publish it again: new version, same link.
|
|
14431
14448
|
- Keep supporting files next to the HTML (or in subfolders) and reference them with relative paths (\`style.css\`, \`img/logo.png\`). Absolute paths and files outside the page's folder aren't included.
|
|
14432
|
-
-
|
|
14449
|
+
- Spaces are private. Never add \`--public\` unless the user asks for a public link in this conversation, or it's a PR screenshot page. \`--public\` only works on the first publish. To switch a space later, a space admin runs \`cloudy settings --space <id> --visibility private\` (members of the workspace only) or \`--visibility public\` (anyone with the link, same rule as \`--public\`). Going public turns guest comments on; going private turns guest comments and guest writes off, and the public link stops working. \`cloudy artifacts\` lists what you've published.
|
|
14433
14450
|
- New work joins the space already about the same topic, as a page, instead of making another space: \`publish\` finds it (same workspace, same who-can-see) and prints \`Looks like "<space>"\`. Tell the user where it went. To check first, run \`cloudy find "<title>" --toon\`; \`--add-to <id>\` adds the page to a space you pick, \`--new\` makes a separate space when the user wants one.
|
|
14434
14451
|
- A page that stores something needs the space to allow it: read "What a space can't do" first.
|
|
14435
14452
|
|
|
14436
14453
|
## Copying a page someone sent you
|
|
14437
14454
|
|
|
14438
|
-
When the user is sent a Cloudy link and wants their own copy, run \`cloudy copy <url>\`. It publishes the files into a new space in their workspace and prints the new link.
|
|
14455
|
+
When the user is sent a Cloudy link and wants their own copy, run \`cloudy copy <url>\`. It publishes the files into a new space in their workspace and prints the new link. It's private; add \`--public\` only if the user asks for a link anyone can open. \`-o <dir>\` also writes the files locally; \`--no-publish -o <dir>\` writes them without making a space.
|
|
14439
14456
|
|
|
14440
14457
|
## Space files
|
|
14441
14458
|
|
|
@@ -14478,7 +14495,7 @@ Put the SQL a page needs in \`db/NNN_name.sql\` files next to it (the page's fol
|
|
|
14478
14495
|
|
|
14479
14496
|
## Guest writes
|
|
14480
14497
|
|
|
14481
|
-
For visitors who aren't signed in to add data (a sign-up sheet, a vote, feedback, a high score), the page runs named writes you publish, never its own SQL. The space must be public, and an admin turns on "Pages can save data for people who are not signed in": in the space's Settings, or \`cloudy settings --guest-writes on\` (admins only). If the pages shouldn't show what guests saved (answers, sign-ups), also turn off "Pages can show saved data" (\`--pages-show-data off\`) first. \`cloudy settings\` shows both. \`cloudy settings --link homeideas\` sets the public link (\`--link off\` clears it). Ask the user before you turn guest writes on.
|
|
14498
|
+
For visitors who aren't signed in to add data (a sign-up sheet, a vote, feedback, a high score), the page runs named writes you publish, never its own SQL. The space must be public (ask the user first: spaces are private), and an admin turns on "Pages can save data for people who are not signed in": in the space's Settings, or \`cloudy settings --guest-writes on\` (admins only). If the pages shouldn't show what guests saved (answers, sign-ups), also turn off "Pages can show saved data" (\`--pages-show-data off\`) first. \`cloudy settings\` shows both. \`cloudy settings --link homeideas\` sets the public link (\`--link off\` clears it). Ask the user before you turn guest writes on.
|
|
14482
14499
|
|
|
14483
14500
|
- Put the statements in \`db/guest-writes.sql\` next to the page: \`-- name: vote\` on its own line, then exactly one INSERT, UPDATE or DELETE. \`?\` placeholders take the page's params; \`$guest\` is the name the visitor gave and \`$guest_id\` a stable id for their browser, both filled in by the server. Publish and push upload the whole set (replacing the old one) after the migrations; \`cloudy db guest-writes\` shows what's live.
|
|
14484
14501
|
- In the page: \`await window.cloudtifact.guest.set(name)\` once (it remembers the name), then \`await window.cloudtifact.db.run("vote", [choice])\`. Without a name it rejects with code \`no_guest\`.
|
|
@@ -14551,7 +14568,7 @@ async function skillCopies(home, version = VERSION) {
|
|
|
14551
14568
|
* somebody edited by hand survives until the CLI changes. `check` reports and writes nothing.
|
|
14552
14569
|
*/
|
|
14553
14570
|
async function installSkill(home, opts = {}) {
|
|
14554
|
-
const version = opts.version ?? "0.3.
|
|
14571
|
+
const version = opts.version ?? "0.3.2";
|
|
14555
14572
|
const markdown = skillMarkdown(version);
|
|
14556
14573
|
const copies = await skillCopies(home, version);
|
|
14557
14574
|
const written = [];
|
|
@@ -14868,7 +14885,7 @@ async function runUpdateCheck(source, deps = {}) {
|
|
|
14868
14885
|
source,
|
|
14869
14886
|
...latest ? { latest } : before?.latest ? { latest: before.latest } : {}
|
|
14870
14887
|
}, env);
|
|
14871
|
-
await refreshSkillCopies(homeDir(env), deps.version ?? "0.3.
|
|
14888
|
+
await refreshSkillCopies(homeDir(env), deps.version ?? "0.3.2");
|
|
14872
14889
|
}
|
|
14873
14890
|
/** Starts the check in a detached process that outlives this one and is never waited for. */
|
|
14874
14891
|
function spawnUpdateCheck(entry, source) {
|
|
@@ -15072,7 +15089,7 @@ const program = new Command().name("cloudy").description("Publish pages and docs
|
|
|
15072
15089
|
const tty = !!process.stdout.isTTY && !!process.stderr.isTTY;
|
|
15073
15090
|
if (updateNoticeOff({
|
|
15074
15091
|
env: process.env,
|
|
15075
|
-
current: "0.3.
|
|
15092
|
+
current: "0.3.2",
|
|
15076
15093
|
command: cmd.name()
|
|
15077
15094
|
})) return;
|
|
15078
15095
|
const entry = fileURLToPath(import.meta.url);
|
|
@@ -15309,7 +15326,11 @@ async function workspaceForNewSpace(client, flag, saved) {
|
|
|
15309
15326
|
if (cur.note) console.error(`note: ${cur.note}`);
|
|
15310
15327
|
return cur;
|
|
15311
15328
|
}
|
|
15312
|
-
program.command("init").description("Link this repo to a space (creating one in the current workspace if needed) and write .cloudtifact.json").option("--dir <dir>", "folder to publish, relative to the repo root").option("--workspace <slug>", "workspace for a new space (default: the current one, see `workspace list`)").addOption(new Option("--visibility <v>", "who can view a new space (default:
|
|
15329
|
+
program.command("init").description("Link this repo to a space (creating one in the current workspace if needed) and write .cloudtifact.json").option("--dir <dir>", "folder to publish, relative to the repo root").option("--workspace <slug>", "workspace for a new space (default: the current one, see `workspace list`)").addOption(new Option("--visibility <v>", "who can view a new space (default: private)").choices([
|
|
15330
|
+
"private",
|
|
15331
|
+
"public",
|
|
15332
|
+
"members"
|
|
15333
|
+
])).option("--space <id>", "link an existing space (id or link) instead of creating one").option("--name <name>", "name for a new space (default: the repo folder name)").option("-y, --yes", "accept defaults, no prompts").option("--hooks", "also install agent hooks (see `hooks install`)").action(run(async (opts) => {
|
|
15313
15334
|
const { client, config } = await getClient();
|
|
15314
15335
|
const root = findInitRoot();
|
|
15315
15336
|
const configFile = path.join(root, REPO_CONFIG_FILE);
|
|
@@ -15332,7 +15353,7 @@ program.command("init").description("Link this repo to a space (creating one in
|
|
|
15332
15353
|
} else {
|
|
15333
15354
|
const cur = await workspaceForNewSpace(client, opts.workspace, config.workspace);
|
|
15334
15355
|
console.log(workspaceLine(cur));
|
|
15335
|
-
let visibility = opts.visibility;
|
|
15356
|
+
let visibility = opts.visibility ? visibilityOf(opts.visibility) : void 0;
|
|
15336
15357
|
if (!visibility && prompt) visibility = await choose("Who can view it?", [`members of ${cur.workspace.slug} only`, "anyone with the link"]) ? "public" : "members";
|
|
15337
15358
|
const defaultName = path.basename(root);
|
|
15338
15359
|
const name = opts.name ?? (prompt ? await ask("Space name:", defaultName) : defaultName);
|
|
@@ -15588,7 +15609,7 @@ for (const [name, verb] of [["resolve", "Resolved"], ["unresolve", "Reopened"]])
|
|
|
15588
15609
|
const c = await (name === "resolve" ? client.resolveComment(commentId) : client.unresolveComment(commentId));
|
|
15589
15610
|
console.log(`${verb} ${c.id} on ${c.path}.`);
|
|
15590
15611
|
}));
|
|
15591
|
-
program.command("publish").description("Publish an HTML page (with the files it references) or a folder; prints its link").argument("<path>", "an .html file or a folder with index.html").option("--public", "anyone with the link can view (only when first published; default: private)").option("--name <name>", "space name (default: the page's <title>, else the file name)").option("--workspace <slug>", "workspace for a new space (default: the current one, see `workspace list`)").option("--space <id>", "publish as this existing space's main page (id or link), replacing its files").option("--add-to <id>", "add it as a page in this existing space (id or link), keeping the space's other pages").option("--new", "make a new space, even when an existing one looks like the same topic").option("--folder <path>", "file a new space in this folder, like \"Deals/Enterprise\" (see `cloudy folders`)").option("--project <name>", "the project this work belongs to (default: the git repo it's in)").option("--entry <file>", "folder only: the page to publish as index.html").option("-m, --message <message>", "version message").option("--no-db", "don't run the db/*.sql files next to the page").option("--strict", "make a page the space can't back an error, so nothing is published").action(run(async (target, opts) => {
|
|
15612
|
+
program.command("publish").description("Publish an HTML page (with the files it references) or a folder; prints its link").argument("<path>", "an .html file or a folder with index.html").option("--public", "anyone with the link can view (only when first published; default: private). Agents: only when the user asks").option("--name <name>", "space name (default: the page's <title>, else the file name)").option("--workspace <slug>", "workspace for a new space (default: the current one, see `workspace list`)").option("--space <id>", "publish as this existing space's main page (id or link), replacing its files").option("--add-to <id>", "add it as a page in this existing space (id or link), keeping the space's other pages").option("--new", "make a new space, even when an existing one looks like the same topic").option("--folder <path>", "file a new space in this folder, like \"Deals/Enterprise\" (see `cloudy folders`)").option("--project <name>", "the project this work belongs to (default: the git repo it's in)").option("--entry <file>", "folder only: the page to publish as index.html").option("-m, --message <message>", "version message").option("--no-db", "don't run the db/*.sql files next to the page").option("--strict", "make a page the space can't back an error, so nothing is published").action(run(async (target, opts) => {
|
|
15592
15613
|
if (opts.space && opts.addTo) throw new CliError("Pass --space or --add-to, not both.");
|
|
15593
15614
|
if ((opts.space || opts.addTo) && opts.new) throw new CliError("--new makes a new space; drop --space/--add-to.");
|
|
15594
15615
|
const abs = path.resolve(target);
|
|
@@ -15704,7 +15725,7 @@ program.command("publish").description("Publish an HTML page (with the files it
|
|
|
15704
15725
|
else console.log(`No changes since v${space.latestVersion}: "${space.name}"`);
|
|
15705
15726
|
for (const line of linkLines(space, prefix)) console.log(line);
|
|
15706
15727
|
}));
|
|
15707
|
-
program.command("copy").description("Make your own copy of a Cloudy page someone sent you: a new space in your workspace").argument("<url>", "a Cloudy page link, space id, or public link").option("--at <n>", "the version to copy (default: the one in the URL, else latest)").option("--name <name>", "name for the new space (default: the original's name)").option("--workspace <slug>", "workspace for the new space (default: the current one, see `workspace list`)").option("--public", "anyone with the link can view (default: private)").option("-o, --output <dir>", "also write the files into this folder").option("--force", "overwrite files in -o").option("--no-publish", "write files with -o and don't make a new space").option("-m, --message <message>", "version message on the new space").option("--strict", "make a page the space can't back an error, so nothing is published").option("--toon", "print TOON (compact, for agents)").option("--json", "print JSON").action(run(async (url, opts) => {
|
|
15728
|
+
program.command("copy").description("Make your own copy of a Cloudy page someone sent you: a new space in your workspace").argument("<url>", "a Cloudy page link, space id, or public link").option("--at <n>", "the version to copy (default: the one in the URL, else latest)").option("--name <name>", "name for the new space (default: the original's name)").option("--workspace <slug>", "workspace for the new space (default: the current one, see `workspace list`)").option("--public", "anyone with the link can view (default: private). Agents: only when the user asks").option("-o, --output <dir>", "also write the files into this folder").option("--force", "overwrite files in -o").option("--no-publish", "write files with -o and don't make a new space").option("-m, --message <message>", "version message on the new space").option("--strict", "make a page the space can't back an error, so nothing is published").option("--toon", "print TOON (compact, for agents)").option("--json", "print JSON").action(run(async (url, opts) => {
|
|
15708
15729
|
const publish = opts.publish !== false;
|
|
15709
15730
|
if (!publish && !opts.output) throw new CliError("--no-publish needs -o <dir> to write the files.");
|
|
15710
15731
|
if (opts.force && !opts.output) throw new CliError("--force only applies with -o.");
|
|
@@ -15841,7 +15862,7 @@ program.command("versions").description("List a space's versions, newest first")
|
|
|
15841
15862
|
if (!rows.length) return console.log("Nothing pushed yet.");
|
|
15842
15863
|
for (const v of rows) console.log(`v${v.version} ${v.at} UTC ${byPerson(`@${v.by}`, v.via)}${v.project ? ` · ${v.project}` : ""} +${v.added} ~${v.changed} -${v.removed}${v.message ? ` ${v.message}` : ""}`);
|
|
15843
15864
|
}));
|
|
15844
|
-
program.command("settings").description("Show a space
|
|
15865
|
+
program.command("settings").description("Show who can open a space and its guest and visitor switches, or change them (space admins; the same switches as in the app)").option("--space <id>", "space id, public link, or copied URL (default: the first target in .cloudtifact.json)").option(VISIBILITY_OPTION, "who can open it: private (only members of its workspace; members also works) or public (anyone with the link). Going public turns guest comments on; going private turns guest comments and guest writes off").option(SETTINGS[0].option, SETTINGS[0].label).option(SETTINGS[1].option, `${SETTINGS[1].label} (off keeps the database private from visitors)`).option(SETTINGS[2].option, SETTINGS[2].label).option("--link <name>", "set the public link (letters and numbers, or off to clear it)").option("--toon", "print TOON (compact, for agents)").option("--json", "print JSON").action(run(async (opts) => {
|
|
15845
15866
|
const { spaceId } = await pickSpace(opts.space);
|
|
15846
15867
|
const patch = settingsPatch(opts);
|
|
15847
15868
|
const { client } = await getClient();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudtifact",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Publish pages and docs to Cloudy as links people comment on, with every version kept and the comments handed back to your agent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "The Cloudy authors",
|