bikeshed-now 0.1.0 → 0.2.0
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 +2 -2
- package/src/client.mjs +1 -1
- package/src/index.mjs +25 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bikeshed-now",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Publish and revise documents on a Bikeshed deployment from the terminal.",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"url": "https://github.com/DeputyHumans/bikeshed-now/issues"
|
|
24
24
|
},
|
|
25
25
|
"bin": {
|
|
26
|
-
"bikeshed": "
|
|
26
|
+
"bikeshed": "src/index.mjs"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=20"
|
package/src/client.mjs
CHANGED
package/src/index.mjs
CHANGED
|
@@ -51,6 +51,9 @@ Options
|
|
|
51
51
|
--title <text> title for publish
|
|
52
52
|
--folder <id> destination folder for publish
|
|
53
53
|
--parent <id> parent folder for mkdir
|
|
54
|
+
--limit <n> with list: rows per page (default 20, max 50)
|
|
55
|
+
--cursor <id> with list: the page after the one that printed it
|
|
56
|
+
--all with list: every page; with comments: resolved too
|
|
54
57
|
--watch with publish/update: republish on every save
|
|
55
58
|
--origin <url> the deployment (default: the one you logged in to)
|
|
56
59
|
--token <token> override the stored token
|
|
@@ -104,9 +107,28 @@ async function login(flags) {
|
|
|
104
107
|
|
|
105
108
|
async function list(flags) {
|
|
106
109
|
const { origin, token } = resolveAuth(flags);
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
const page = (limit, cursor) => {
|
|
111
|
+
const args = { limit };
|
|
112
|
+
if (cursor) args.cursor = cursor;
|
|
113
|
+
return callTool(origin, token, "list_documents", args);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
let result;
|
|
117
|
+
if (flags.all) {
|
|
118
|
+
// Pages at the server's cap (LIST_LIMIT), which is the fewest round trips.
|
|
119
|
+
// The result keeps one page's shape, so `--json` needs no second parser.
|
|
120
|
+
const documents = [];
|
|
121
|
+
let cursor = flags.cursor;
|
|
122
|
+
do {
|
|
123
|
+
const next = await page(50, cursor);
|
|
124
|
+
documents.push(...next.documents);
|
|
125
|
+
cursor = next.nextCursor;
|
|
126
|
+
} while (cursor);
|
|
127
|
+
result = { documents, nextCursor: null };
|
|
128
|
+
} else {
|
|
129
|
+
result = await page(Number(flags.limit) || 20, flags.cursor);
|
|
130
|
+
}
|
|
131
|
+
|
|
110
132
|
out(flags.json, result, () => {
|
|
111
133
|
if (result.documents.length === 0) {
|
|
112
134
|
console.log("Nothing yet. `bikeshed publish <file>` to start.");
|