@somewhere-cloud/cli 0.38.158 → 0.38.160
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/CHANGELOG.md +8 -0
- package/dist/lib/bundle.js +94 -18
- package/dist/lib/bundle.js.map +2 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.38.160
|
|
4
|
+
|
|
5
|
+
- Find complete examples with `somewhere docs example`. Search returns an outline and the best matching section in full. Add `--include-api` to include API reference topics.
|
|
6
|
+
|
|
7
|
+
## 0.38.159
|
|
8
|
+
|
|
9
|
+
- Docs summaries show how much of the topic you received and give commands for the remaining sections, the whole topic, and search. The same summary goes to a terminal, pipe or file. Use `somewhere docs <topic> --full` when you need the complete topic.
|
|
10
|
+
|
|
3
11
|
## 0.38.158
|
|
4
12
|
|
|
5
13
|
- `somewhere cron run <name> --wait` reports job completion sooner.
|
package/dist/lib/bundle.js
CHANGED
|
@@ -88055,13 +88055,15 @@ function renderDocsIndex(pages, groups) {
|
|
|
88055
88055
|
lines.push("", "Quick links:");
|
|
88056
88056
|
for (const [name, entry] of Object.entries(TOPICS))
|
|
88057
88057
|
lines.push(` ${name.padEnd(10)} ${entry.blurb}`);
|
|
88058
|
-
lines.push("", `Open a topic: ${cliInvocation()} docs <topic>
|
|
88058
|
+
lines.push("", `Open a topic: ${cliInvocation()} docs <topic> `, `Open a section: ${cliInvocation()} docs <topic> --section <id>`, `Whole topic: ${cliInvocation()} docs <topic> --full`, `Search all docs: ${cliInvocation()} docs --search "<words>" [--include-api]`, `Examples: ${cliInvocation()} docs example [slug]`, `Download Markdown: ${cliInvocation()} docs pull`, `Full manual: ${cliInvocation()} docs --full (very large)`);
|
|
88059
88059
|
return lines.join("\n") + "\n";
|
|
88060
88060
|
}
|
|
88061
|
-
async function fetchDocsSearch(query, topic) {
|
|
88061
|
+
async function fetchDocsSearch(query, topic, includeApi) {
|
|
88062
88062
|
const params = new URLSearchParams({ q: query });
|
|
88063
88063
|
if (topic)
|
|
88064
88064
|
params.set("topic", topic);
|
|
88065
|
+
if (includeApi)
|
|
88066
|
+
params.set("include_api", "true");
|
|
88065
88067
|
const res = await fetchWithProxy(`${DOCS_BASE2}${DOCS_SEARCH_PATH}?${params}`, {
|
|
88066
88068
|
headers: { "User-Agent": "somewhere-cli" }
|
|
88067
88069
|
});
|
|
@@ -88116,21 +88118,51 @@ async function writeResponseBodyToStdout(res) {
|
|
|
88116
88118
|
}
|
|
88117
88119
|
}
|
|
88118
88120
|
function topicSummary(content, topic, full) {
|
|
88121
|
+
if (hasViewNotice(content))
|
|
88122
|
+
return withNewline(content);
|
|
88119
88123
|
const command = `${cliInvocation()} docs ${commandArg(topic)}`;
|
|
88120
88124
|
return `${content.trimEnd()}
|
|
88121
88125
|
|
|
88122
88126
|
Full topic (${full} characters): ${command} --full
|
|
88123
88127
|
`;
|
|
88124
88128
|
}
|
|
88129
|
+
async function fetchPublishedDocsView(topic, view) {
|
|
88130
|
+
if (!/^[a-z0-9_.-]+$/i.test(topic))
|
|
88131
|
+
return null;
|
|
88132
|
+
const params = new URLSearchParams({ view: view.kind === "default" ? "summary" : view.kind });
|
|
88133
|
+
if (view.kind === "section")
|
|
88134
|
+
params.set("section", view.id);
|
|
88135
|
+
if (view.kind === "example" && view.slug)
|
|
88136
|
+
params.set("slug", view.slug);
|
|
88137
|
+
const response = await fetchWithProxy(`${DOCS_BASE2}/docs/${encodeURIComponent(topic.toLowerCase())}.txt?${params}`);
|
|
88138
|
+
if (!response.ok || !response.headers.get("content-type")?.includes("application/json"))
|
|
88139
|
+
return null;
|
|
88140
|
+
const value = await response.json();
|
|
88141
|
+
if (!value || typeof value !== "object")
|
|
88142
|
+
return null;
|
|
88143
|
+
const result = value;
|
|
88144
|
+
if (typeof result.topic !== "string" || typeof result.text !== "string" || typeof result.view !== "string" || typeof result.complete !== "boolean" || /(?:^|\n)No section "/.test(result.text))
|
|
88145
|
+
return null;
|
|
88146
|
+
return { topic: result.topic, content: result.text, view: result.view, complete: result.complete, version: docsVersion(result.version) };
|
|
88147
|
+
}
|
|
88148
|
+
function hasViewNotice(content) {
|
|
88149
|
+
return /^Showing (?:the whole topic \(|[^\n]+ of this topic \()/m.test(content);
|
|
88150
|
+
}
|
|
88151
|
+
function displayDocs(content) {
|
|
88152
|
+
return withNewline(hasViewNotice(content) ? content.replace(/^\[docs\][^\n]*\n/, "") : content);
|
|
88153
|
+
}
|
|
88125
88154
|
function registerDocs(program2) {
|
|
88126
|
-
program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs --search "<words>"\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", `List available topics (the same index bare \`${cliInvocation()} docs\` prints)`).option("--full", "Print the complete topic
|
|
88155
|
+
program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs --search "<words>"\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", `List available topics (the same index bare \`${cliInvocation()} docs\` prints)`).option("--full", "Print the complete topic; with no topic, print the full manual").option("--search <words>", "Find matching builder docs and read the top section whole").option("--include-api", "Include the HTTP API catalog and developer tool reference in search").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
|
|
88127
88156
|
Examples:
|
|
88128
88157
|
${cliInvocation()} docs # topic index
|
|
88129
|
-
${cliInvocation()} docs --search "magic link" # matching
|
|
88158
|
+
${cliInvocation()} docs --search "magic link" # matching builder docs
|
|
88130
88159
|
${cliInvocation()} docs pull # download Markdown into .somewhere/docs/
|
|
88131
|
-
${cliInvocation()} docs sw.auth #
|
|
88160
|
+
${cliInvocation()} docs sw.auth # topic summary when the whole topic is long
|
|
88161
|
+
${cliInvocation()} docs sw.auth --full # complete topic for a terminal, pipe or file
|
|
88132
88162
|
${cliInvocation()} docs sw.auth setRoles # search within this topic
|
|
88133
88163
|
${cliInvocation()} docs sw.auth --section <id> # one section
|
|
88164
|
+
${cliInvocation()} docs example team-board # one complete example
|
|
88165
|
+
${cliInvocation()} docs example # list available examples
|
|
88134
88166
|
${cliInvocation()} docs --full # the whole manual (very large)
|
|
88135
88167
|
|
|
88136
88168
|
\`${cliInvocation()} docs search\` with no term opens the search primitive topic.
|
|
@@ -88141,8 +88173,33 @@ Examples:
|
|
|
88141
88173
|
return;
|
|
88142
88174
|
}
|
|
88143
88175
|
warnIfDocsNewerThanCli();
|
|
88176
|
+
if (topic === "example" && opts.search === void 0) {
|
|
88177
|
+
if (terms.length > 1 || opts.list || opts.section !== void 0 || opts.includeApi || opts.full) {
|
|
88178
|
+
error(`Use docs ${topic} [slug] with optional --json.`);
|
|
88179
|
+
process.exitCode = 1;
|
|
88180
|
+
return;
|
|
88181
|
+
}
|
|
88182
|
+
try {
|
|
88183
|
+
const result = await fetchPublishedDocsView(topic, { kind: topic, slug: terms[0] });
|
|
88184
|
+
if (!result || result.view !== topic) {
|
|
88185
|
+
throw new Error(`Could not read docs ${topic} at ${DOCS_BASE2}.`);
|
|
88186
|
+
}
|
|
88187
|
+
await warnIfLocalDocsOlder(result.version);
|
|
88188
|
+
const content = withNewline(result.content);
|
|
88189
|
+
if (opts.json)
|
|
88190
|
+
printJson({ topic: result.topic, view: result.view, complete: result.complete, content });
|
|
88191
|
+
else
|
|
88192
|
+
process.stdout.write(content);
|
|
88193
|
+
if (!result.complete)
|
|
88194
|
+
process.exitCode = 1;
|
|
88195
|
+
} catch (cause) {
|
|
88196
|
+
error(cause instanceof Error ? cause.message : String(cause), cause);
|
|
88197
|
+
process.exitCode = 1;
|
|
88198
|
+
}
|
|
88199
|
+
return;
|
|
88200
|
+
}
|
|
88144
88201
|
if (topic === "pull") {
|
|
88145
|
-
if (terms.length || opts.list || opts.full || opts.section !== void 0 || opts.search !== void 0) {
|
|
88202
|
+
if (terms.length || opts.list || opts.full || opts.section !== void 0 || opts.search !== void 0 || opts.includeApi) {
|
|
88146
88203
|
error("docs pull accepts only --json.");
|
|
88147
88204
|
process.exitCode = 1;
|
|
88148
88205
|
return;
|
|
@@ -88174,9 +88231,14 @@ Examples:
|
|
|
88174
88231
|
}
|
|
88175
88232
|
const searching = opts.search !== void 0 || terms.length > 0;
|
|
88176
88233
|
const within = topic && topic !== "search" ? ALIASES[topic] ?? topic : void 0;
|
|
88234
|
+
if (opts.includeApi && !searching) {
|
|
88235
|
+
error("--include-api requires a docs search.");
|
|
88236
|
+
process.exitCode = 1;
|
|
88237
|
+
return;
|
|
88238
|
+
}
|
|
88177
88239
|
if (searching) {
|
|
88178
88240
|
if (opts.full || opts.section !== void 0 || opts.list || opts.search !== void 0 && topic !== void 0) {
|
|
88179
|
-
error('Use docs --search "<words>" with optional --json.');
|
|
88241
|
+
error('Use docs --search "<words>" with optional --include-api and --json.');
|
|
88180
88242
|
process.exitCode = 1;
|
|
88181
88243
|
return;
|
|
88182
88244
|
}
|
|
@@ -88187,7 +88249,7 @@ Examples:
|
|
|
88187
88249
|
return;
|
|
88188
88250
|
}
|
|
88189
88251
|
try {
|
|
88190
|
-
const { results, total, version: version2 } = await fetchDocsSearch(query, within);
|
|
88252
|
+
const { results, total, version: version2 } = await fetchDocsSearch(query, within, opts.includeApi);
|
|
88191
88253
|
await warnIfLocalDocsOlder(version2);
|
|
88192
88254
|
if (opts.json) {
|
|
88193
88255
|
printJson({ query, ...within ? { topic: within } : {}, count: results.length, total, results });
|
|
@@ -88199,12 +88261,11 @@ Examples:
|
|
|
88199
88261
|
}
|
|
88200
88262
|
for (const result of results) {
|
|
88201
88263
|
console.log(`${result.topic}${result.section ? ` \u203A ${result.section}` : ""} ${dim(result.heading ?? result.title)}`);
|
|
88202
|
-
console.log(
|
|
88203
|
-
${result.snippet}
|
|
88204
|
-
|
|
88205
|
-
${dim(result.open)}
|
|
88206
|
-
`);
|
|
88264
|
+
console.log(dim(result.open));
|
|
88207
88265
|
}
|
|
88266
|
+
if (results[0].snippet)
|
|
88267
|
+
console.log(`
|
|
88268
|
+
${results[0].snippet}`);
|
|
88208
88269
|
if (results.length < total) {
|
|
88209
88270
|
console.log(dim(`Showing ${results.length} of ${total} matches. Add a word to narrow the search.`));
|
|
88210
88271
|
}
|
|
@@ -88214,7 +88275,7 @@ ${dim(result.open)}
|
|
|
88214
88275
|
}
|
|
88215
88276
|
return;
|
|
88216
88277
|
}
|
|
88217
|
-
const view = opts.section !== void 0 ? { kind: "section", id: opts.section } : opts.full
|
|
88278
|
+
const view = opts.section !== void 0 ? { kind: "section", id: opts.section } : opts.full ? { kind: "full" } : { kind: "default" };
|
|
88218
88279
|
if (opts.list || topic === void 0 && view.kind === "default") {
|
|
88219
88280
|
try {
|
|
88220
88281
|
const { pages, groups, version: version2 } = await fetchPublicManifestWithGroups();
|
|
@@ -88274,19 +88335,30 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88274
88335
|
if (/^Topic "[^\n]*" not found\./.test(content) || view.kind === "full" && status.complete === false || status.view === "summary" && status.complete === false && !full || view.kind === "section" && (status.view !== "section" || /(?:^|\n)No section "/.test(content))) {
|
|
88275
88336
|
throw new Error("Authenticated docs did not return the requested view; trying the public index.");
|
|
88276
88337
|
}
|
|
88277
|
-
if (status.view === "summary" && status.complete === false)
|
|
88338
|
+
if (status.view === "summary" && status.complete === false) {
|
|
88278
88339
|
content = topicSummary(content, resolvedTopic, Number(full));
|
|
88340
|
+
}
|
|
88279
88341
|
await warnIfLocalDocsOlder();
|
|
88280
88342
|
if (opts.json)
|
|
88281
88343
|
printJson({ topic: requestedTopic, ...status, content });
|
|
88282
88344
|
else
|
|
88283
|
-
process.stdout.write(
|
|
88345
|
+
process.stdout.write(displayDocs(content));
|
|
88284
88346
|
return;
|
|
88285
88347
|
} catch (e) {
|
|
88286
88348
|
authenticatedFailure = e instanceof Error ? e.message : String(e);
|
|
88287
88349
|
}
|
|
88288
88350
|
}
|
|
88289
88351
|
try {
|
|
88352
|
+
const published = await fetchPublishedDocsView(resolvedTopic, view).catch(() => null);
|
|
88353
|
+
if (published) {
|
|
88354
|
+
await warnIfLocalDocsOlder(published.version);
|
|
88355
|
+
const { topic: topic2, content, view: view2, complete } = published;
|
|
88356
|
+
if (opts.json)
|
|
88357
|
+
printJson({ topic: topic2, url: DOCS_BASE2 + PUBLIC_MANIFEST_PATH, source: "public", view: view2, complete, content });
|
|
88358
|
+
else
|
|
88359
|
+
process.stdout.write(displayDocs(content));
|
|
88360
|
+
return;
|
|
88361
|
+
}
|
|
88290
88362
|
const { pages, aliases, version: version2 } = await fetchPublicManifestWithGroups();
|
|
88291
88363
|
await warnIfLocalDocsOlder(version2);
|
|
88292
88364
|
const page = findPublicDocsPage(pages, aliases, resolvedTopic);
|
|
@@ -88301,11 +88373,12 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
|
|
|
88301
88373
|
topic: page.id,
|
|
88302
88374
|
url: DOCS_BASE2 + PUBLIC_MANIFEST_PATH,
|
|
88303
88375
|
source: "public",
|
|
88304
|
-
|
|
88376
|
+
view: rendered.view,
|
|
88377
|
+
complete: rendered.complete,
|
|
88305
88378
|
content: rendered.content
|
|
88306
88379
|
});
|
|
88307
88380
|
} else {
|
|
88308
|
-
process.stdout.write(rendered.content);
|
|
88381
|
+
process.stdout.write(displayDocs(rendered.content));
|
|
88309
88382
|
}
|
|
88310
88383
|
return;
|
|
88311
88384
|
}
|
|
@@ -88419,6 +88492,9 @@ var init_docs = __esm({
|
|
|
88419
88492
|
__name(renderPublicPage, "renderPublicPage");
|
|
88420
88493
|
__name(writeResponseBodyToStdout, "writeResponseBodyToStdout");
|
|
88421
88494
|
__name(topicSummary, "topicSummary");
|
|
88495
|
+
__name(fetchPublishedDocsView, "fetchPublishedDocsView");
|
|
88496
|
+
__name(hasViewNotice, "hasViewNotice");
|
|
88497
|
+
__name(displayDocs, "displayDocs");
|
|
88422
88498
|
__name(registerDocs, "registerDocs");
|
|
88423
88499
|
}
|
|
88424
88500
|
});
|