@anaella/cli 0.4.1 → 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 +21 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,6 +5,9 @@ import { readFileSync as readFileSync3 } from "fs";
|
|
|
5
5
|
import { AnaellaClient } from "@anaella/client";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
|
|
8
|
+
// package.json
|
|
9
|
+
var version = "0.5.1";
|
|
10
|
+
|
|
8
11
|
// src/browser-login.ts
|
|
9
12
|
import { spawn } from "child_process";
|
|
10
13
|
import crypto from "crypto";
|
|
@@ -130,6 +133,20 @@ var cmdPosts = (client, o) => client.listPosts({
|
|
|
130
133
|
limit: o.limit === void 0 ? void 0 : Number(o.limit),
|
|
131
134
|
cursor: o.cursor === void 0 ? void 0 : Number(o.cursor)
|
|
132
135
|
});
|
|
136
|
+
function cmdUpdate(client, id, o) {
|
|
137
|
+
return client.updatePost(id, {
|
|
138
|
+
channels: o.channel?.length ? o.channel : void 0,
|
|
139
|
+
text: o.text,
|
|
140
|
+
when: o.when,
|
|
141
|
+
media: o.media?.length ? o.media.map((url) => ({ url })) : void 0,
|
|
142
|
+
firstComment: o.firstComment,
|
|
143
|
+
title: o.title,
|
|
144
|
+
markdown: o.markdown,
|
|
145
|
+
excerpt: o.excerpt,
|
|
146
|
+
tags: o.tag?.length ? o.tag : void 0,
|
|
147
|
+
canonicalUrl: o.canonicalUrl
|
|
148
|
+
});
|
|
149
|
+
}
|
|
133
150
|
var cmdGet = (client, id) => client.getPost(id);
|
|
134
151
|
var cmdDelete = (client, id) => client.deletePost(id);
|
|
135
152
|
var cmdAnalytics = (client, o) => o.post ? client.getPostAnalytics(o.post, { period: o.period }) : client.getAnalytics({ period: o.period });
|
|
@@ -264,7 +281,7 @@ var collect = (val, acc) => {
|
|
|
264
281
|
var program = new Command();
|
|
265
282
|
program.name("anaella").description(
|
|
266
283
|
"CLI for anaella.com \u2014 find and run tools, schedule and publish posts via the /v1 API."
|
|
267
|
-
).version(
|
|
284
|
+
).version(version).option("--api-key <key>", "ana_ API key (overrides env + config)").option("--api-url <url>", "API base URL").option("--json", "output raw JSON");
|
|
268
285
|
async function withClient(command, fn, columns) {
|
|
269
286
|
const opts = command.optsWithGlobals();
|
|
270
287
|
const cfg = resolveConfig({ apiKey: opts.apiKey, apiUrl: opts.apiUrl }, process.env);
|
|
@@ -336,6 +353,9 @@ program.command("connect <platform>").description("Create a connect link for an
|
|
|
336
353
|
(platform, opts, command) => withClient(command, (c) => cmdConnect(c, platform, opts))
|
|
337
354
|
);
|
|
338
355
|
program.command("post").description("Create/schedule/publish a post").requiredOption("-c, --channel <id>", "channel id (repeatable)", collect, []).option("-t, --text <text>", "post text").option("-w, --when <when>", '"now" | "draft" | ISO-8601', "draft").option("-m, --media <url>", "public media URL (repeatable)", collect, []).option("--type <type>", "post | reel | thread | story | article").option("--first-comment <text>", "first comment").option("--title <title>", "article title (--type article)").option("--markdown <md>", 'article body in Markdown, e.g. "$(cat post.md)" (--type article)').option("--excerpt <text>", "article excerpt (--type article)").option("--tag <tag>", "article tag (repeatable, --type article)", collect, []).option("--canonical-url <url>", "article canonical URL (--type article)").action((opts, command) => withClient(command, (c) => cmdPost(c, opts)));
|
|
356
|
+
program.command("update <id>").description("Edit a draft or scheduled post (only the options given change)").option("-c, --channel <id>", "channel id (repeatable; replaces the channel list)", collect, []).option("-t, --text <text>", "post text").option("-w, --when <when>", '"now" | "draft" | ISO-8601 (omit: keep the schedule)').option("-m, --media <url>", "public media URL (repeatable; replaces the media)", collect, []).option("--first-comment <text>", "first comment").option("--title <title>", "article title").option("--markdown <md>", "article body in Markdown").option("--excerpt <text>", "article excerpt").option("--tag <tag>", "article tag (repeatable; replaces the tags)", collect, []).option("--canonical-url <url>", "article canonical URL").action(
|
|
357
|
+
(id, opts, command) => withClient(command, (c) => cmdUpdate(c, id, opts))
|
|
358
|
+
);
|
|
339
359
|
program.command("posts").description("List recent posts").option("--limit <n>", "max results (1-100)").option("--cursor <n>", "offset").action(
|
|
340
360
|
(opts, command) => withClient(command, (c) => cmdPosts(c, opts), ["id", "type", "status", "scheduledAt"])
|
|
341
361
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anaella/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Command-line tool for anaella.com — schedule and publish social posts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test": "bun test"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@anaella/client": "^0.
|
|
21
|
+
"@anaella/client": "^0.5.0",
|
|
22
22
|
"commander": "^12.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|