@letterstory/cli 0.177.50 → 0.177.51
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/lib/cli.mjs +1 -1
- package/lib/commands/usage.mjs +37 -0
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -90,7 +90,7 @@ import {
|
|
|
90
90
|
import { fetchParkedSections, withoutParked } from "./parked.mjs";
|
|
91
91
|
|
|
92
92
|
// Matches cli/package.json; publish-cli.yml rewrites both to the published version.
|
|
93
|
-
export const VERSION = "0.177.
|
|
93
|
+
export const VERSION = "0.177.51";
|
|
94
94
|
|
|
95
95
|
/** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
|
|
96
96
|
export const EXIT_PAYMENT_REQUIRED = 3;
|
package/lib/commands/usage.mjs
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
//
|
|
4
4
|
// letterstory usage [--days 7|30|90] [--site <id>] [--limit <n>] people, companies, features
|
|
5
5
|
// letterstory usage --host app.acme.com what to add to the app before anyone signed in
|
|
6
|
+
// letterstory usage import-posthog --project <id> --key <phx_…> [--days 90] [--host app.acme.com]
|
|
7
|
+
// [--feature-urls map.json] [--dry-run] history from your PostHog (import_posthog_usage)
|
|
6
8
|
|
|
7
9
|
import { CliError } from "../client.mjs";
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
8
11
|
import { argsFromFlags, printResult } from "./shared.mjs";
|
|
9
12
|
|
|
10
13
|
export const ARGS = {
|
|
@@ -21,6 +24,26 @@ export const ARGS = {
|
|
|
21
24
|
host: { flag: "host" },
|
|
22
25
|
limit: { flag: "limit", type: "num" },
|
|
23
26
|
},
|
|
27
|
+
import_posthog_usage: {
|
|
28
|
+
project_id: { flag: "project" },
|
|
29
|
+
personal_api_key: { flag: "key" },
|
|
30
|
+
posthog_host: { flag: "posthog-host" },
|
|
31
|
+
days: { flag: "days", type: "num" },
|
|
32
|
+
site_id: { flag: "site" },
|
|
33
|
+
host: { flag: "host" },
|
|
34
|
+
feature_urls: {
|
|
35
|
+
// A JSON file: [{ "url_contains": "view=plan", "feature": "Ideas" }, …]
|
|
36
|
+
value: (flags) => {
|
|
37
|
+
if (flags["feature-urls"] === undefined) return undefined;
|
|
38
|
+
try {
|
|
39
|
+
return JSON.parse(readFileSync(String(flags["feature-urls"]), "utf8"));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
throw new CliError(`--feature-urls: ${e instanceof Error ? e.message : String(e)}`);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
dry_run: { flag: "dry-run", type: "bool" },
|
|
46
|
+
},
|
|
24
47
|
};
|
|
25
48
|
|
|
26
49
|
const STEP = {
|
|
@@ -32,6 +55,20 @@ const STEP = {
|
|
|
32
55
|
|
|
33
56
|
export async function cmdUsage(ctx) {
|
|
34
57
|
const { client, flags, io } = ctx;
|
|
58
|
+
if (ctx.positionals[0] === "import-posthog") {
|
|
59
|
+
if (!flags.project || !flags.key) throw new CliError("import-posthog needs --project and --key.");
|
|
60
|
+
const result = await client.callTool(
|
|
61
|
+
"import_posthog_usage",
|
|
62
|
+
argsFromFlags(ARGS.import_posthog_usage, flags, [])
|
|
63
|
+
);
|
|
64
|
+
printResult(io, flags, result, (r) =>
|
|
65
|
+
[
|
|
66
|
+
`${r.dry_run ? "Would import" : "Imported"} from PostHog (${r.host}, since ${r.since}):`,
|
|
67
|
+
` ${r.people} people, ${r.companies} companies, ${r.pages} pages, ${r.features} features`,
|
|
68
|
+
].join("\n")
|
|
69
|
+
);
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
35
72
|
const result = await client.callTool("get_usage_data", argsFromFlags(ARGS.get_usage_data, flags, ctx.positionals));
|
|
36
73
|
printResult(io, flags, result, (r) => {
|
|
37
74
|
if (r.step !== "collecting") {
|