recess-cli 3.44.0 → 3.46.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/dist/cli.js +4 -0
- package/dist/commands/changelog.js +92 -0
- package/dist/help.js +11 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ import { runChallengeOfTheWeekCommand } from "./commands/challenge-of-the-week.j
|
|
|
19
19
|
import { runDbCommand } from "./commands/db.js";
|
|
20
20
|
import { runRoomsCommand } from "./commands/rooms.js";
|
|
21
21
|
import { runDmsCommand } from "./commands/dms.js";
|
|
22
|
+
import { runChangelogCommand } from "./commands/changelog.js";
|
|
22
23
|
import { runFeedCommand } from "./commands/feed.js";
|
|
23
24
|
import { runFamiliesCommand } from "./commands/families.js";
|
|
24
25
|
import { runFamilyCommand, runKidCommand, runMeCommand, } from "./commands/family.js";
|
|
@@ -6330,6 +6331,9 @@ export async function executeRecessCommand(argv, options = {}) {
|
|
|
6330
6331
|
if (noun === "feed") {
|
|
6331
6332
|
return runFeedCommand({ parsed, api, writeCommand });
|
|
6332
6333
|
}
|
|
6334
|
+
if (noun === "changelog") {
|
|
6335
|
+
return runChangelogCommand({ parsed, api, writeCommand });
|
|
6336
|
+
}
|
|
6333
6337
|
if (noun === "dms") {
|
|
6334
6338
|
return runDmsCommand({ parsed, api, writeCommand });
|
|
6335
6339
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { unwrap } from "../api.js";
|
|
4
|
+
import { flagString } from "../args.js";
|
|
5
|
+
import { CliError } from "../errors.js";
|
|
6
|
+
import { assertChoice, positional } from "./shared.js";
|
|
7
|
+
async function readSend(parsed) {
|
|
8
|
+
const file = path.resolve(flagString(parsed, "file", { required: true }));
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(await fs.readFile(file, "utf8"));
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
throw new CliError("invalid_arguments", `Can't read JSON from ${file}.`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `changelog preview|test|send|history|show` — the blast for a live post. Claude writes
|
|
18
|
+
* the send file (`changelog-post` skill); the server renders it, picks recipients,
|
|
19
|
+
* sends once, and keeps the copy with the record.
|
|
20
|
+
*/
|
|
21
|
+
export async function runChangelogCommand({ parsed, api, writeCommand, }) {
|
|
22
|
+
const action = positional(parsed, 1, "changelog action");
|
|
23
|
+
if (action === "history") {
|
|
24
|
+
return unwrap(await api.client.GET("/admin/changelog-sends/"));
|
|
25
|
+
}
|
|
26
|
+
if (action === "show") {
|
|
27
|
+
const slug = positional(parsed, 2, "post slug");
|
|
28
|
+
return unwrap(await api.client.GET("/admin/changelog-sends/{slug}/", {
|
|
29
|
+
params: { path: { slug } },
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
if (action !== "preview" && action !== "test" && action !== "send") {
|
|
33
|
+
throw new CliError("invalid_arguments", "Use changelog preview|test|send|history|show.");
|
|
34
|
+
}
|
|
35
|
+
const send = await readSend(parsed);
|
|
36
|
+
if (action === "test") {
|
|
37
|
+
const audience = assertChoice(flagString(parsed, "audience", { required: true }), ["kids", "parents", "tutors"], "--audience");
|
|
38
|
+
return unwrap(await api.client.POST("/admin/changelog-sends/test/", {
|
|
39
|
+
body: { send, audience },
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
const preview = unwrap(await api.client.POST("/admin/changelog-sends/preview/", { body: send }));
|
|
43
|
+
if (action === "preview") {
|
|
44
|
+
const dir = flagString(parsed, "html-dir");
|
|
45
|
+
if (!dir)
|
|
46
|
+
return preview;
|
|
47
|
+
await fs.mkdir(dir, { recursive: true });
|
|
48
|
+
const files = {};
|
|
49
|
+
for (const { audience, email } of preview.audiences) {
|
|
50
|
+
if (!email)
|
|
51
|
+
continue;
|
|
52
|
+
files[audience] = path.resolve(dir, `${audience}.html`);
|
|
53
|
+
await fs.writeFile(files[audience], email.html);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...preview,
|
|
57
|
+
audiences: preview.audiences.map(({ email, ...rest }) => ({
|
|
58
|
+
...rest,
|
|
59
|
+
email: email && {
|
|
60
|
+
subject: email.subject,
|
|
61
|
+
count: email.count,
|
|
62
|
+
file: files[rest.audience],
|
|
63
|
+
},
|
|
64
|
+
})),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (preview.alreadySent) {
|
|
68
|
+
throw new CliError("invalid_arguments", "This post was already sent.");
|
|
69
|
+
}
|
|
70
|
+
if (!preview.live) {
|
|
71
|
+
throw new CliError("invalid_arguments", "This post isn't live yet.");
|
|
72
|
+
}
|
|
73
|
+
if (preview.problems.length > 0) {
|
|
74
|
+
throw new CliError("invalid_arguments", preview.problems.join("; "));
|
|
75
|
+
}
|
|
76
|
+
const reach = {
|
|
77
|
+
feed: preview.feed?.count ?? 0,
|
|
78
|
+
byAudience: preview.audiences.map((a) => ({
|
|
79
|
+
audience: a.audience,
|
|
80
|
+
email: a.email?.count ?? 0,
|
|
81
|
+
sms: a.sms?.count ?? 0,
|
|
82
|
+
slack: !!a.slack,
|
|
83
|
+
})),
|
|
84
|
+
};
|
|
85
|
+
return writeCommand(parsed, {
|
|
86
|
+
action: `send the "${send.slug}" changelog post to its audience${preview.dryRun ? " (test environment: nothing leaves)" : ""}. This can't be undone or sent twice.`,
|
|
87
|
+
target: { slug: send.slug },
|
|
88
|
+
request: send,
|
|
89
|
+
details: { reach },
|
|
90
|
+
}, async () => unwrap(await api.client.POST("/admin/changelog-sends/send/", { body: send })));
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=changelog.js.map
|
package/dist/help.js
CHANGED
|
@@ -418,6 +418,11 @@ Usage:
|
|
|
418
418
|
recess [--json] cohorts email <cohort-id> --target ALL_PARENTS|ALL_PARENTS_GUIDES
|
|
419
419
|
--content TEXT [--confirm]
|
|
420
420
|
recess [--json] feed post --users <id,id,...> --text TEXT [--send-email] [--confirm]
|
|
421
|
+
recess [--json] changelog preview --file <send.json> [--html-dir <dir>]
|
|
422
|
+
recess [--json] changelog test --file <send.json> --audience kids|parents|tutors
|
|
423
|
+
recess [--json] changelog send --file <send.json> [--confirm]
|
|
424
|
+
recess [--json] changelog history
|
|
425
|
+
recess [--json] changelog show <slug>
|
|
421
426
|
recess [--json] dms send --users <id,id,...> --text TEXT [--confirm]
|
|
422
427
|
recess [--json] events get <event-id>
|
|
423
428
|
recess [--json] events list --date YYYY-MM-DD [--timezone <iana>] [--search TEXT]
|
|
@@ -1512,6 +1517,11 @@ export const COMMAND_SUMMARIES = {
|
|
|
1512
1517
|
"cohorts resume-billing": "Resume billing for a cohort.",
|
|
1513
1518
|
"cohorts email": "Email a cohort's parents (and guides).",
|
|
1514
1519
|
"feed post": "Post a message to users' feeds (optionally email).",
|
|
1520
|
+
"changelog preview": "Render a changelog blast and count who it reaches, sending nothing.",
|
|
1521
|
+
"changelog test": "Send yourself one audience's email and text.",
|
|
1522
|
+
"changelog send": "Send a live changelog post to its audience, once.",
|
|
1523
|
+
"changelog history": "List every changelog send.",
|
|
1524
|
+
"changelog show": "One changelog send and its exact copy.",
|
|
1515
1525
|
"dms send": "Send a Recess chat DM as yourself to each user (1:1).",
|
|
1516
1526
|
"events get": "Read one class event.",
|
|
1517
1527
|
"events list": "List class events on a date.",
|
|
@@ -1769,6 +1779,7 @@ export const NOUN_SUMMARIES = {
|
|
|
1769
1779
|
"tuition-plans": "Compute tuition plan sheets (stores nothing).",
|
|
1770
1780
|
placement: "Give placement quests, one kid's results, results vs MAP, question bank, mastery sync.",
|
|
1771
1781
|
feed: "Post messages to users' feeds.",
|
|
1782
|
+
changelog: "Preview, test and send changelog posts, and read past sends.",
|
|
1772
1783
|
dms: "Send Recess chat DMs as yourself.",
|
|
1773
1784
|
events: "Class events: list, attendance, cancel, reschedule, add.",
|
|
1774
1785
|
registrations: "Approve or deny cohort registrations.",
|