frontpage-host 0.1.11 → 0.1.13
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/AGENTS.md +3 -2
- package/dist/commands/help.js +9 -1
- package/dist/commands/modules.js +67 -22
- package/dist/commands/push.js +7 -0
- package/dist/completions/generate.js +16 -3
- package/dist/http/client.d.ts +8 -2
- package/dist/http/client.js +16 -6
- package/dist/modules/commands.d.ts +25 -0
- package/dist/modules/commands.js +276 -0
- package/dist/modules/google_reviews.d.ts +1 -0
- package/dist/modules/google_reviews.js +228 -0
- package/dist/registry.js +27 -7
- package/llms.txt +2 -2
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -101,7 +101,7 @@ Sites are Astro 6 + Tailwind v4. More detail: `frontpage help site-building` or
|
|
|
101
101
|
2. **`src/config/site.ts`** — keep `pages` (path registry) and `nav` in sync when adding/renaming/deleting page files. Tab title comes from BaseLayout, not the `pages` map label.
|
|
102
102
|
3. **One file per URL** for similar page sets (services, guides, …). Do not default to `getStaticPaths()` over `src/data/*.ts`. Blog/news → `frontpage articles`, not a hand-rolled catalog.
|
|
103
103
|
4. **No backends / databases / fake forms or checkout.** Real forms use `<form data-fp-form="slug">` + `frontpage modules`. Refuse or use modules for payments.
|
|
104
|
-
5. **Tokens** in `src/config/tokens.ts` — keep required color/font/spacing/radii keys; style via CSS variables / token Tailwind.
|
|
104
|
+
5. **Tokens** in `src/config/tokens.ts` — keep required color/font/spacing/radii keys; style via CSS variables / token Tailwind. **Fonts load rule:** the build bundles catalog faces when the family string appears in `tokens.ts` and/or in a real CSS `font-family` / `fontFamily` / `font-['…']` context under `src/pages|components|styles` — not from prose alone. Preferred path: `frontpage fonts` → exact `value` → `frontpage tokens set --group fonts --key <role> --value "…"` → **APPLY** `font-sans` / `font-serif` / `font-mono` / `font-display` (or `var(--font-*)`) on elements. Inline catalog `font-family` accents can bundle after rebuild, but brand roles still prefer tokens + utilities. Off-catalog families silently fall back to system fonts (push may warn). Module how-tos: `frontpage modules docs <key>` / `frontpage extensions docs <key>`.
|
|
105
105
|
6. **Shared chrome** — prefer `src/components/Header.astro` + `Footer.astro` (or `chrome: { managed: true }` in `site.ts`).
|
|
106
106
|
7. **404** — customize `src/pages/404.astro` if needed; keep `frontpage:404` meta; never register `/404` in `nav`/`pages`.
|
|
107
107
|
8. **Platform-owned paths** stay off-limits (BaseLayout overlay, module/extension shells, `package.json`, …). Customer layouts like `DocsLayout` / `GuideLayout` are OK.
|
|
@@ -109,7 +109,8 @@ Sites are Astro 6 + Tailwind v4. More detail: `frontpage help site-building` or
|
|
|
109
109
|
## Modules & articles
|
|
110
110
|
|
|
111
111
|
- Forms: `data-fp-form` markup in pages + `frontpage modules` for enable/config. No submit JS / honeypot / `action`.
|
|
112
|
-
- Wizard modules (payments/shop/ordering/
|
|
112
|
+
- Wizard / connect-once modules (payments/shop/ordering/google_reviews): after building gated markup, `frontpage modules request-setup <key> --reason "…"` once — owner finishes in the **editor status bar** (CLI cannot show it). Auto-active modules (forms/callbar/…) need markup, not request-setup. `frontpage modules <key>` prints that key's CLI usage (exit 2). Index: https://frontpage.host/developers/modules
|
|
113
|
+
- Google reviews: platform nodes only (`data-fp-google-reviews` / `data-fp-google-ask` + required `data-fp-requires="google_reviews"`). `data-layout` is `feed` (default), `badge`, or `link`. Never invent stars, quotes, a 1–10, or a Maps URL. Do not pick a Place ID via Autocomplete and do not write `placeId` through `modules config`. Owner-supplied Place ID / Maps URL: `frontpage modules google_reviews connect --place-id …` or `--maps-url …` (server resolves + seeds). Curation: `list-reviews`, `hide --id`, `show --id`, `set-stars`, `set-sort`, `set-weight`, `reset-weights`, `refresh`, `disconnect`. Usage: `frontpage modules google_reviews`. Docs: https://frontpage.host/developers/modules/google-reviews. Ask-widget scores: `frontpage inbox google_reviews`.
|
|
113
114
|
- Articles: `frontpage articles …` for lifecycle; bodies via sync under `content/` or `articles content get|set`. Section landing is an owned `src/pages/<section>/index.astro`.
|
|
114
115
|
- Migrate a folder into Articles: prefer `frontpage prompt "migrate … into articles"` — do not invent a mass delete+write migration.
|
|
115
116
|
- Extensions: `frontpage extensions`; if LOCKED on plan, do not fake charts/etc.
|
package/dist/commands/help.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { COMMANDS, TOPIC_NAMES, TOPICS, findCommand } from "../registry.js";
|
|
2
|
+
import { MODULE_COMMANDS, formatModulesIndex } from "../modules/commands.js";
|
|
2
3
|
import { isJson, emitOk } from "../runtime.js";
|
|
3
4
|
function printCommandHelp(cmd) {
|
|
4
5
|
console.log(`${cmd.name} — ${cmd.summary}`);
|
|
@@ -41,6 +42,7 @@ export function runHelp(args) {
|
|
|
41
42
|
})),
|
|
42
43
|
topics: TOPIC_NAMES,
|
|
43
44
|
topicBodies: TOPICS,
|
|
45
|
+
moduleCommands: MODULE_COMMANDS,
|
|
44
46
|
});
|
|
45
47
|
return 0;
|
|
46
48
|
}
|
|
@@ -50,7 +52,10 @@ export function runHelp(args) {
|
|
|
50
52
|
}
|
|
51
53
|
const cmd = findCommand(topic);
|
|
52
54
|
if (cmd) {
|
|
53
|
-
emitOk("help", {
|
|
55
|
+
emitOk("help", {
|
|
56
|
+
command: cmd,
|
|
57
|
+
...(cmd.name === "modules" ? { moduleCommands: MODULE_COMMANDS } : {}),
|
|
58
|
+
});
|
|
54
59
|
return 0;
|
|
55
60
|
}
|
|
56
61
|
console.log(JSON.stringify({
|
|
@@ -81,6 +86,9 @@ export function runHelp(args) {
|
|
|
81
86
|
const cmd = findCommand(topic);
|
|
82
87
|
if (cmd) {
|
|
83
88
|
printCommandHelp(cmd);
|
|
89
|
+
if (cmd.name === "modules") {
|
|
90
|
+
console.log(`\n${formatModulesIndex()}`);
|
|
91
|
+
}
|
|
84
92
|
return 0;
|
|
85
93
|
}
|
|
86
94
|
console.error(`Unknown help topic: ${topic}`);
|
package/dist/commands/modules.js
CHANGED
|
@@ -1,9 +1,52 @@
|
|
|
1
1
|
import { resolveSlug } from "../site.js";
|
|
2
|
-
import { EXIT_OK,
|
|
2
|
+
import { EXIT_OK, exitCodeForError, v1Get, v1Post } from "../http/client.js";
|
|
3
3
|
import { takeFlag } from "../argv.js";
|
|
4
|
+
import { emitUsage } from "../runtime.js";
|
|
5
|
+
import { formatModuleUsage, formatModulesIndex, isCliModuleAction, isDocumentedModuleKey, isGenericModuleVerb, } from "../modules/commands.js";
|
|
6
|
+
import { runGoogleReviews } from "../modules/google_reviews.js";
|
|
7
|
+
/** Drop --site so we can print local usage without resolving a checkout. */
|
|
8
|
+
function positionalArgs(args) {
|
|
9
|
+
const rest = [];
|
|
10
|
+
for (let i = 0; i < args.length; i++) {
|
|
11
|
+
const a = args[i];
|
|
12
|
+
if (a === "--site" || a === "-s") {
|
|
13
|
+
i += 1;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (a.startsWith("--site="))
|
|
17
|
+
continue;
|
|
18
|
+
rest.push(a);
|
|
19
|
+
}
|
|
20
|
+
return rest;
|
|
21
|
+
}
|
|
22
|
+
function rewriteKeyFirst(rest) {
|
|
23
|
+
const key = rest[0];
|
|
24
|
+
const action = rest[1];
|
|
25
|
+
if (key && action && isDocumentedModuleKey(key) && isGenericModuleVerb(action)) {
|
|
26
|
+
return [action, key, ...rest.slice(2)];
|
|
27
|
+
}
|
|
28
|
+
return rest;
|
|
29
|
+
}
|
|
4
30
|
export async function runModules(args) {
|
|
5
31
|
try {
|
|
6
|
-
const
|
|
32
|
+
const peeked = positionalArgs(args);
|
|
33
|
+
const peekedKey = peeked[0];
|
|
34
|
+
const peekedAction = peeked[1];
|
|
35
|
+
if (peekedKey && isDocumentedModuleKey(peekedKey)) {
|
|
36
|
+
if (!peekedAction) {
|
|
37
|
+
return emitUsage("modules", formatModuleUsage(peekedKey));
|
|
38
|
+
}
|
|
39
|
+
if (isCliModuleAction(peekedKey, peekedAction)) {
|
|
40
|
+
const { slug } = await resolveSlug(args);
|
|
41
|
+
return await runGoogleReviews(slug, peekedAction, positionalArgs(args).slice(2));
|
|
42
|
+
}
|
|
43
|
+
if (!isGenericModuleVerb(peekedAction)) {
|
|
44
|
+
return emitUsage("modules", `${formatModuleUsage(peekedKey)}\n\nUnknown action "${peekedAction}". Not in this CLI yet — use Modules or the editor.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const resolved = await resolveSlug(args);
|
|
48
|
+
const slug = resolved.slug;
|
|
49
|
+
const rest = rewriteKeyFirst(resolved.rest);
|
|
7
50
|
const sub = rest[0];
|
|
8
51
|
if (!sub || sub === "list" || sub === "ls") {
|
|
9
52
|
const data = await v1Get(`/api/v1/sites/${encodeURIComponent(slug)}/modules`);
|
|
@@ -16,12 +59,16 @@ export async function runModules(args) {
|
|
|
16
59
|
const key = rest[1];
|
|
17
60
|
if (!key) {
|
|
18
61
|
const data = await v1Get(`/api/v1/sites/${encodeURIComponent(slug)}/modules`);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
62
|
+
const known = data.modules
|
|
63
|
+
.map((m) => ` ${m.key.padEnd(16)} ${m.name}`)
|
|
64
|
+
.join("\n");
|
|
65
|
+
return emitUsage("modules", [
|
|
66
|
+
"Usage: frontpage modules docs <key> [--instance <id>] [--site <slug>]",
|
|
67
|
+
"Known modules (run: frontpage modules docs <key>):",
|
|
68
|
+
known,
|
|
69
|
+
"",
|
|
70
|
+
formatModulesIndex(),
|
|
71
|
+
].join("\n"));
|
|
25
72
|
}
|
|
26
73
|
const work = rest.slice(2);
|
|
27
74
|
const instanceId = takeFlag(work, "--instance");
|
|
@@ -37,16 +84,14 @@ export async function runModules(args) {
|
|
|
37
84
|
if (sub === "request-setup" || sub === "request_setup") {
|
|
38
85
|
const key = rest[1];
|
|
39
86
|
if (!key) {
|
|
40
|
-
|
|
41
|
-
return EXIT_USAGE;
|
|
87
|
+
return emitUsage("modules", 'Usage: frontpage modules request-setup <key> --reason "…" [--prefill \'{…}\'] [--instance <id>] [--site <slug>]');
|
|
42
88
|
}
|
|
43
89
|
const work = rest.slice(2);
|
|
44
90
|
const instanceId = takeFlag(work, "--instance");
|
|
45
91
|
const reason = takeFlag(work, "--reason");
|
|
46
92
|
const prefillRaw = takeFlag(work, "--prefill");
|
|
47
93
|
if (!reason) {
|
|
48
|
-
|
|
49
|
-
return EXIT_USAGE;
|
|
94
|
+
return emitUsage("modules", 'Usage: frontpage modules request-setup <key> --reason "…" [--prefill \'{…}\']');
|
|
50
95
|
}
|
|
51
96
|
let prefill;
|
|
52
97
|
if (prefillRaw) {
|
|
@@ -54,8 +99,7 @@ export async function runModules(args) {
|
|
|
54
99
|
prefill = JSON.parse(prefillRaw);
|
|
55
100
|
}
|
|
56
101
|
catch {
|
|
57
|
-
|
|
58
|
-
return EXIT_USAGE;
|
|
102
|
+
return emitUsage("modules", "--prefill must be valid JSON");
|
|
59
103
|
}
|
|
60
104
|
}
|
|
61
105
|
const data = await v1Post(`/api/v1/sites/${encodeURIComponent(slug)}/modules/${encodeURIComponent(key)}`, { action: "request-setup", reason, prefill, instanceId });
|
|
@@ -65,8 +109,7 @@ export async function runModules(args) {
|
|
|
65
109
|
if (sub === "enable" || sub === "disable" || sub === "archive" || sub === "config") {
|
|
66
110
|
const key = rest[1];
|
|
67
111
|
if (!key) {
|
|
68
|
-
|
|
69
|
-
return EXIT_USAGE;
|
|
112
|
+
return emitUsage("modules", `Usage: frontpage modules ${sub} <key> [--instance <id>] [--config '{…}']`);
|
|
70
113
|
}
|
|
71
114
|
const work = rest.slice(2);
|
|
72
115
|
const instanceId = takeFlag(work, "--instance");
|
|
@@ -74,23 +117,25 @@ export async function runModules(args) {
|
|
|
74
117
|
if (sub === "config") {
|
|
75
118
|
const raw = takeFlag(work, "--config") ?? work[0];
|
|
76
119
|
if (!raw) {
|
|
77
|
-
|
|
78
|
-
return EXIT_USAGE;
|
|
120
|
+
return emitUsage("modules", "Usage: frontpage modules config <key> --config '{…json…}'");
|
|
79
121
|
}
|
|
80
122
|
try {
|
|
81
123
|
config = JSON.parse(raw);
|
|
82
124
|
}
|
|
83
125
|
catch {
|
|
84
|
-
|
|
85
|
-
return EXIT_USAGE;
|
|
126
|
+
return emitUsage("modules", "--config must be valid JSON");
|
|
86
127
|
}
|
|
87
128
|
}
|
|
88
129
|
const data = await v1Post(`/api/v1/sites/${encodeURIComponent(slug)}/modules/${encodeURIComponent(key)}`, { action: sub, config, instanceId });
|
|
89
130
|
console.log(JSON.stringify(data, null, 2));
|
|
90
131
|
return EXIT_OK;
|
|
91
132
|
}
|
|
92
|
-
|
|
93
|
-
|
|
133
|
+
return emitUsage("modules", [
|
|
134
|
+
"Usage: frontpage modules [list|docs|request-setup|enable|disable|archive|config] …",
|
|
135
|
+
" frontpage modules <key> # that key's CLI usage",
|
|
136
|
+
"",
|
|
137
|
+
formatModulesIndex(),
|
|
138
|
+
].join("\n"));
|
|
94
139
|
}
|
|
95
140
|
catch (err) {
|
|
96
141
|
console.error(err instanceof Error ? err.message : String(err));
|
package/dist/commands/push.js
CHANGED
|
@@ -115,6 +115,7 @@ export async function runPush(args) {
|
|
|
115
115
|
commitSha: data.commitSha,
|
|
116
116
|
baseCommitSha: data.baseCommitSha,
|
|
117
117
|
filesChanged: data.filesChanged,
|
|
118
|
+
...(data.warnings?.length ? { warnings: data.warnings } : {}),
|
|
118
119
|
};
|
|
119
120
|
if (!wait) {
|
|
120
121
|
if (isJson()) {
|
|
@@ -123,12 +124,16 @@ export async function runPush(args) {
|
|
|
123
124
|
}
|
|
124
125
|
if (!data.changed) {
|
|
125
126
|
console.log("Nothing to commit (remote already matches).");
|
|
127
|
+
for (const w of data.warnings ?? [])
|
|
128
|
+
console.error(`Warning: ${w}`);
|
|
126
129
|
return EXIT_OK;
|
|
127
130
|
}
|
|
128
131
|
console.log(`Pushed ${data.filesChanged.length} file(s) → ${data.commitSha}`);
|
|
129
132
|
console.log("Updated .frontpage/state.json baseCommitSha");
|
|
130
133
|
console.log("Note: module markup may auto-activate modules (same as the editor agent).");
|
|
131
134
|
console.log("tokens.ts may be auto-repaired at commit if it would break the build.");
|
|
135
|
+
for (const w of data.warnings ?? [])
|
|
136
|
+
console.error(`Warning: ${w}`);
|
|
132
137
|
return EXIT_OK;
|
|
133
138
|
}
|
|
134
139
|
// --wait: after push, wait for agent-run busy to clear (same statuses as deploy wait).
|
|
@@ -141,6 +146,8 @@ export async function runPush(args) {
|
|
|
141
146
|
console.log(`Pushed ${data.filesChanged.length} file(s) → ${data.commitSha}`);
|
|
142
147
|
console.log("Updated .frontpage/state.json baseCommitSha");
|
|
143
148
|
}
|
|
149
|
+
for (const w of data.warnings ?? [])
|
|
150
|
+
console.error(`Warning: ${w}`);
|
|
144
151
|
console.error("Waiting for agent run / deploy idle…");
|
|
145
152
|
}
|
|
146
153
|
const result = await waitForAgentIdle({
|
|
@@ -24,7 +24,13 @@ _frontpage_completions() {
|
|
|
24
24
|
seo|settings) COMPREPLY=( $(compgen -W "get set" -- "\${cur}") ) ;;
|
|
25
25
|
articles) COMPREPLY=( $(compgen -W "list content create-section create-article set-draft" -- "\${cur}") ) ;;
|
|
26
26
|
analytics) COMPREPLY=( $(compgen -W "dashboard summary query funnel timeseries compare sql" -- "\${cur}") ) ;;
|
|
27
|
-
modules)
|
|
27
|
+
modules)
|
|
28
|
+
if [[ \${COMP_CWORD} -ge 3 && \${COMP_WORDS[2]} == google_reviews ]]; then
|
|
29
|
+
COMPREPLY=( $(compgen -W "docs request-setup enable disable archive config connect resolve status list-reviews hide show set-stars set-sort set-weight reset-weights write-review-url refresh disconnect" -- "\${cur}") )
|
|
30
|
+
else
|
|
31
|
+
COMPREPLY=( $(compgen -W "list docs request-setup enable disable archive config callbar forms booking signups payments shop ordering articles google_reviews" -- "\${cur}") )
|
|
32
|
+
fi
|
|
33
|
+
;;
|
|
28
34
|
extensions) COMPREPLY=( $(compgen -W "list docs enable disable config" -- "\${cur}") ) ;;
|
|
29
35
|
prompt) COMPREPLY=( $(compgen -W "--path --attach --asset-url --site --json --help" -- "\${cur}") ) ;;
|
|
30
36
|
*) COMPREPLY=( $(compgen -W "--site --help --json --quiet --yes" -- "\${cur}") ) ;;
|
|
@@ -53,7 +59,13 @@ _frontpage() {
|
|
|
53
59
|
tokens) _values 'subcommand' set ;;
|
|
54
60
|
seo|settings) _values 'subcommand' get set ;;
|
|
55
61
|
analytics) _values 'subcommand' dashboard summary query funnel timeseries compare sql ;;
|
|
56
|
-
modules)
|
|
62
|
+
modules)
|
|
63
|
+
if [[ $words[2] == google_reviews ]]; then
|
|
64
|
+
_values 'subcommand' docs request-setup enable disable archive config connect resolve status list-reviews hide show set-stars set-sort set-weight reset-weights write-review-url refresh disconnect
|
|
65
|
+
else
|
|
66
|
+
_values 'subcommand' list docs request-setup enable disable archive config callbar forms booking signups payments shop ordering articles google_reviews
|
|
67
|
+
fi
|
|
68
|
+
;;
|
|
57
69
|
extensions) _values 'subcommand' list docs enable disable config ;;
|
|
58
70
|
esac
|
|
59
71
|
;;
|
|
@@ -75,7 +87,8 @@ export function generateFishCompletion() {
|
|
|
75
87
|
`complete -c frontpage -n "__fish_seen_subcommand_from tokens" -a "set"`,
|
|
76
88
|
`complete -c frontpage -n "__fish_seen_subcommand_from seo settings" -a "get set"`,
|
|
77
89
|
`complete -c frontpage -n "__fish_seen_subcommand_from analytics" -a "dashboard summary query funnel timeseries compare sql"`,
|
|
78
|
-
`complete -c frontpage -n "__fish_seen_subcommand_from modules" -a "list docs request-setup enable disable archive config"`,
|
|
90
|
+
`complete -c frontpage -n "__fish_seen_subcommand_from modules" -a "list docs request-setup enable disable archive config callbar forms booking signups payments shop ordering articles google_reviews"`,
|
|
91
|
+
`complete -c frontpage -n "__fish_seen_subcommand_from modules; and __fish_seen_subcommand_from google_reviews" -a "connect resolve status list-reviews hide show set-stars set-sort set-weight reset-weights write-review-url refresh disconnect"`,
|
|
79
92
|
`complete -c frontpage -n "__fish_seen_subcommand_from extensions" -a "list docs enable disable config"`,
|
|
80
93
|
`complete -c frontpage -l site -d "Site subdomain slug"`,
|
|
81
94
|
];
|
package/dist/http/client.d.ts
CHANGED
|
@@ -23,8 +23,14 @@ export declare function httpErrorFromV1(status: number, parsed: V1Envelope, fall
|
|
|
23
23
|
export declare function apiBase(): string;
|
|
24
24
|
/** Bearer header for raw fetch (e.g. Blob client-token exchange). */
|
|
25
25
|
export declare function getBearerAuthHeader(): Promise<Record<string, string>>;
|
|
26
|
-
|
|
27
|
-
export declare
|
|
26
|
+
/** Connect / refresh can seed up to ~300s. Other calls stay on the default fetch timeout. */
|
|
27
|
+
export declare const LONG_MODULE_TIMEOUT_MS = 310000;
|
|
28
|
+
export declare function v1Get<T>(path: string, opts?: {
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
}): Promise<T>;
|
|
31
|
+
export declare function v1Post<T>(path: string, body?: unknown, opts?: {
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
}): Promise<T>;
|
|
28
34
|
export declare function v1Put<T>(path: string, body?: unknown): Promise<T>;
|
|
29
35
|
export declare function v1Delete<T>(path: string): Promise<T>;
|
|
30
36
|
export declare function v1Patch<T>(path: string, body?: unknown): Promise<T>;
|
package/dist/http/client.js
CHANGED
|
@@ -69,7 +69,9 @@ export async function getBearerAuthHeader() {
|
|
|
69
69
|
}
|
|
70
70
|
return { Authorization: `Bearer ${key}` };
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
/** Connect / refresh can seed up to ~300s. Other calls stay on the default fetch timeout. */
|
|
73
|
+
export const LONG_MODULE_TIMEOUT_MS = 310_000;
|
|
74
|
+
async function v1Request(method, path, body, opts) {
|
|
73
75
|
const key = await getApiKey();
|
|
74
76
|
if (!key) {
|
|
75
77
|
throw new CliHttpError("Not logged in. Run: frontpage login", EXIT_AUTH, 401);
|
|
@@ -84,11 +86,19 @@ async function v1Request(method, path, body) {
|
|
|
84
86
|
headers["Content-Type"] = "application/json";
|
|
85
87
|
payload = JSON.stringify(body);
|
|
86
88
|
}
|
|
89
|
+
const init = { method, headers, body: payload };
|
|
90
|
+
if (opts?.timeoutMs && opts.timeoutMs > 0) {
|
|
91
|
+
init.signal = AbortSignal.timeout(opts.timeoutMs);
|
|
92
|
+
}
|
|
87
93
|
let res;
|
|
88
94
|
try {
|
|
89
|
-
res = await fetch(url,
|
|
95
|
+
res = await fetch(url, init);
|
|
90
96
|
}
|
|
91
97
|
catch (err) {
|
|
98
|
+
const name = err instanceof Error ? err.name : "";
|
|
99
|
+
if (name === "TimeoutError" || name === "AbortError") {
|
|
100
|
+
throw new CliHttpError("Request timed out.", EXIT_UNEXPECTED, 0);
|
|
101
|
+
}
|
|
92
102
|
throw new CliHttpError(`Network error: ${err instanceof Error ? err.message : String(err)}`, EXIT_UNEXPECTED, 0);
|
|
93
103
|
}
|
|
94
104
|
const text = await res.text();
|
|
@@ -103,11 +113,11 @@ async function v1Request(method, path, body) {
|
|
|
103
113
|
return parsed;
|
|
104
114
|
throw httpErrorFromV1(res.status, parsed);
|
|
105
115
|
}
|
|
106
|
-
export async function v1Get(path) {
|
|
107
|
-
return v1Request("GET", path);
|
|
116
|
+
export async function v1Get(path, opts) {
|
|
117
|
+
return v1Request("GET", path, undefined, opts);
|
|
108
118
|
}
|
|
109
|
-
export async function v1Post(path, body) {
|
|
110
|
-
return v1Request("POST", path, body ?? {});
|
|
119
|
+
export async function v1Post(path, body, opts) {
|
|
120
|
+
return v1Request("POST", path, body ?? {}, opts);
|
|
111
121
|
}
|
|
112
122
|
export async function v1Put(path, body) {
|
|
113
123
|
return v1Request("PUT", path, body ?? {});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §CLI-MOD-FW — per-key CLI registry (usage printer + help --json).
|
|
3
|
+
* Instagram is not documented here. Google reviews extras ship in Phase 1.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DOCUMENTED_MODULE_KEYS: readonly ["callbar", "forms", "booking", "signups", "payments", "shop", "ordering", "articles", "google_reviews"];
|
|
6
|
+
export type DocumentedModuleKey = (typeof DOCUMENTED_MODULE_KEYS)[number];
|
|
7
|
+
export declare const GENERIC_MODULE_VERBS: readonly ["list", "ls", "docs", "doc", "request-setup", "request_setup", "enable", "disable", "archive", "config"];
|
|
8
|
+
export type ModuleCommandDef = {
|
|
9
|
+
key: DocumentedModuleKey;
|
|
10
|
+
name: string;
|
|
11
|
+
summary: string;
|
|
12
|
+
genericActions: readonly string[];
|
|
13
|
+
extraActions: readonly string[];
|
|
14
|
+
notYet: readonly string[];
|
|
15
|
+
examples: readonly string[];
|
|
16
|
+
notes: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
export declare const MODULE_COMMANDS: readonly ModuleCommandDef[];
|
|
19
|
+
export declare const GOOGLE_REVIEWS_CLI_ACTIONS: readonly ["connect", "resolve", "status", "list-reviews", "hide", "show", "set-stars", "set-sort", "set-weight", "reset-weights", "write-review-url", "refresh", "disconnect"];
|
|
20
|
+
export declare function isCliModuleAction(key: DocumentedModuleKey, action: string): boolean;
|
|
21
|
+
export declare function isDocumentedModuleKey(raw: string): raw is DocumentedModuleKey;
|
|
22
|
+
export declare function isGenericModuleVerb(raw: string): boolean;
|
|
23
|
+
export declare function moduleCommand(key: DocumentedModuleKey): ModuleCommandDef;
|
|
24
|
+
export declare function formatModuleUsage(key: DocumentedModuleKey): string;
|
|
25
|
+
export declare function formatModulesIndex(): string;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §CLI-MOD-FW — per-key CLI registry (usage printer + help --json).
|
|
3
|
+
* Instagram is not documented here. Google reviews extras ship in Phase 1.
|
|
4
|
+
*/
|
|
5
|
+
export const DOCUMENTED_MODULE_KEYS = [
|
|
6
|
+
"callbar",
|
|
7
|
+
"forms",
|
|
8
|
+
"booking",
|
|
9
|
+
"signups",
|
|
10
|
+
"payments",
|
|
11
|
+
"shop",
|
|
12
|
+
"ordering",
|
|
13
|
+
"articles",
|
|
14
|
+
"google_reviews",
|
|
15
|
+
];
|
|
16
|
+
export const GENERIC_MODULE_VERBS = [
|
|
17
|
+
"list",
|
|
18
|
+
"ls",
|
|
19
|
+
"docs",
|
|
20
|
+
"doc",
|
|
21
|
+
"request-setup",
|
|
22
|
+
"request_setup",
|
|
23
|
+
"enable",
|
|
24
|
+
"disable",
|
|
25
|
+
"archive",
|
|
26
|
+
"config",
|
|
27
|
+
];
|
|
28
|
+
const GENERIC_ACTIONS = [
|
|
29
|
+
"docs",
|
|
30
|
+
"request-setup",
|
|
31
|
+
"enable",
|
|
32
|
+
"disable",
|
|
33
|
+
"archive",
|
|
34
|
+
"config",
|
|
35
|
+
];
|
|
36
|
+
export const MODULE_COMMANDS = [
|
|
37
|
+
{
|
|
38
|
+
key: "callbar",
|
|
39
|
+
name: "Call bar",
|
|
40
|
+
summary: "Phone / SMS bar. Generic enable and JSON config only in this CLI.",
|
|
41
|
+
genericActions: GENERIC_ACTIONS,
|
|
42
|
+
extraActions: [],
|
|
43
|
+
notYet: ["get", "set --phone"],
|
|
44
|
+
examples: [
|
|
45
|
+
"frontpage modules callbar",
|
|
46
|
+
"frontpage modules callbar docs",
|
|
47
|
+
"frontpage modules callbar enable",
|
|
48
|
+
`frontpage modules config callbar --config '{"phone":"+1…"}'`,
|
|
49
|
+
],
|
|
50
|
+
notes: [
|
|
51
|
+
"Typed get/set flags are not in this CLI yet — use Modules or `modules config`.",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: "forms",
|
|
56
|
+
name: "Forms",
|
|
57
|
+
summary: "Lead forms. Multi-instance; use --instance for one form.",
|
|
58
|
+
genericActions: GENERIC_ACTIONS,
|
|
59
|
+
extraActions: [],
|
|
60
|
+
notYet: ["get", "set --notify-email"],
|
|
61
|
+
examples: [
|
|
62
|
+
"frontpage modules forms",
|
|
63
|
+
"frontpage modules forms docs",
|
|
64
|
+
"frontpage modules forms enable --instance lead-gen",
|
|
65
|
+
`frontpage modules config forms --instance lead-gen --config '{"notifyEmail":"hi@example.com"}'`,
|
|
66
|
+
],
|
|
67
|
+
notes: [
|
|
68
|
+
"Typed get/set flags are not in this CLI yet — use Modules or `modules config`.",
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
key: "booking",
|
|
73
|
+
name: "Booking",
|
|
74
|
+
summary: "Booking requests. Generic enable and JSON config only in this CLI.",
|
|
75
|
+
genericActions: GENERIC_ACTIONS,
|
|
76
|
+
extraActions: [],
|
|
77
|
+
notYet: ["get", "set --notify-email"],
|
|
78
|
+
examples: [
|
|
79
|
+
"frontpage modules booking",
|
|
80
|
+
"frontpage modules booking docs",
|
|
81
|
+
"frontpage modules booking enable",
|
|
82
|
+
],
|
|
83
|
+
notes: [
|
|
84
|
+
"Typed get/set flags are not in this CLI yet — use Modules or `modules config`.",
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
key: "signups",
|
|
89
|
+
name: "Mailing list",
|
|
90
|
+
summary: "Email signups. Generic enable and JSON config only in this CLI.",
|
|
91
|
+
genericActions: GENERIC_ACTIONS,
|
|
92
|
+
extraActions: [],
|
|
93
|
+
notYet: ["get", "set --notify-email"],
|
|
94
|
+
examples: [
|
|
95
|
+
"frontpage modules signups",
|
|
96
|
+
"frontpage modules signups docs",
|
|
97
|
+
"frontpage modules signups enable",
|
|
98
|
+
],
|
|
99
|
+
notes: [
|
|
100
|
+
"Typed get/set flags are not in this CLI yet — use Modules or `modules config`.",
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
key: "payments",
|
|
105
|
+
name: "Payments",
|
|
106
|
+
summary: "Stripe payments. Connect finishes in the browser, not the terminal.",
|
|
107
|
+
genericActions: GENERIC_ACTIONS,
|
|
108
|
+
extraActions: [],
|
|
109
|
+
notYet: ["connect", "disconnect", "status"],
|
|
110
|
+
examples: [
|
|
111
|
+
"frontpage modules payments",
|
|
112
|
+
"frontpage modules payments docs",
|
|
113
|
+
'frontpage modules payments request-setup --reason "Deposit button needs Stripe"',
|
|
114
|
+
],
|
|
115
|
+
notes: [
|
|
116
|
+
"OAuth cannot finish in this CLI. Use request-setup (editor amber bar) or the Modules hub.",
|
|
117
|
+
"payments and shop share one Stripe account.",
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
key: "shop",
|
|
122
|
+
name: "Online store",
|
|
123
|
+
summary: "Stripe shop. Shares the payments Stripe account.",
|
|
124
|
+
genericActions: GENERIC_ACTIONS,
|
|
125
|
+
extraActions: [],
|
|
126
|
+
notYet: ["connect", "disconnect", "status"],
|
|
127
|
+
examples: [
|
|
128
|
+
"frontpage modules shop",
|
|
129
|
+
"frontpage modules shop docs",
|
|
130
|
+
'frontpage modules shop request-setup --reason "You asked for a store — Stripe setup makes checkout live"',
|
|
131
|
+
],
|
|
132
|
+
notes: [
|
|
133
|
+
"OAuth cannot finish in this CLI. Use request-setup (editor amber bar) or the Modules hub.",
|
|
134
|
+
"payments and shop share one Stripe account.",
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
key: "ordering",
|
|
139
|
+
name: "Online ordering",
|
|
140
|
+
summary: "Square ordering. Connect finishes in the browser, not the terminal.",
|
|
141
|
+
genericActions: GENERIC_ACTIONS,
|
|
142
|
+
extraActions: [],
|
|
143
|
+
notYet: ["connect", "disconnect", "sync", "status"],
|
|
144
|
+
examples: [
|
|
145
|
+
"frontpage modules ordering",
|
|
146
|
+
"frontpage modules ordering docs",
|
|
147
|
+
'frontpage modules ordering request-setup --reason "You asked for online ordering — Square setup makes it live"',
|
|
148
|
+
],
|
|
149
|
+
notes: [
|
|
150
|
+
"OAuth cannot finish in this CLI. Use request-setup (editor amber bar) or the Modules hub.",
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
key: "articles",
|
|
155
|
+
name: "Articles",
|
|
156
|
+
summary: "Content hub. Lifecycle lives on `frontpage articles`, not under modules.",
|
|
157
|
+
genericActions: GENERIC_ACTIONS,
|
|
158
|
+
extraActions: [],
|
|
159
|
+
notYet: [],
|
|
160
|
+
examples: [
|
|
161
|
+
"frontpage modules articles",
|
|
162
|
+
"frontpage modules docs articles",
|
|
163
|
+
"frontpage articles list",
|
|
164
|
+
],
|
|
165
|
+
notes: [
|
|
166
|
+
"Do not fold article create/edit under `modules articles`. Use `frontpage articles …`.",
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
key: "google_reviews",
|
|
171
|
+
name: "Google reviews",
|
|
172
|
+
summary: "Connect a listing, list cached reviews, and curate what the site shows.",
|
|
173
|
+
genericActions: GENERIC_ACTIONS,
|
|
174
|
+
extraActions: [
|
|
175
|
+
"connect --place-id <id> | --maps-url <url>",
|
|
176
|
+
"resolve --place-id <id> | --maps-url <url>",
|
|
177
|
+
"status",
|
|
178
|
+
"list-reviews [--limit 20] [--offset 0] [--stars 4,5] [--hidden]",
|
|
179
|
+
"hide --id <reviewId>",
|
|
180
|
+
"show --id <reviewId>",
|
|
181
|
+
"set-stars 4,5",
|
|
182
|
+
"set-sort newest|highest|lowest",
|
|
183
|
+
"set-weight --id <reviewId> --weight 1-1000",
|
|
184
|
+
"reset-weights",
|
|
185
|
+
"write-review-url",
|
|
186
|
+
"refresh",
|
|
187
|
+
"disconnect [--yes]",
|
|
188
|
+
],
|
|
189
|
+
notYet: [],
|
|
190
|
+
examples: [
|
|
191
|
+
"frontpage modules google_reviews",
|
|
192
|
+
"frontpage modules google_reviews connect --place-id ChIJ…",
|
|
193
|
+
"frontpage modules google_reviews list-reviews --stars 4,5",
|
|
194
|
+
"frontpage modules google_reviews hide --id author:123",
|
|
195
|
+
"frontpage modules google_reviews set-stars 4,5",
|
|
196
|
+
"frontpage modules google_reviews docs",
|
|
197
|
+
'frontpage modules google_reviews request-setup --reason "You asked for Google reviews — pick your listing so we show the right ones"',
|
|
198
|
+
"frontpage inbox google_reviews",
|
|
199
|
+
],
|
|
200
|
+
notes: [
|
|
201
|
+
"Owner supplies a Place ID or Maps URL. The server resolves it. No Autocomplete, no Places key in the CLI.",
|
|
202
|
+
"Do not write placeId through `modules config` — that skips resolve + seed.",
|
|
203
|
+
"Disconnect deletes the listing connection, not the review cache.",
|
|
204
|
+
"Ask-widget scores: frontpage inbox google_reviews.",
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
export const GOOGLE_REVIEWS_CLI_ACTIONS = [
|
|
209
|
+
"connect",
|
|
210
|
+
"resolve",
|
|
211
|
+
"status",
|
|
212
|
+
"list-reviews",
|
|
213
|
+
"hide",
|
|
214
|
+
"show",
|
|
215
|
+
"set-stars",
|
|
216
|
+
"set-sort",
|
|
217
|
+
"set-weight",
|
|
218
|
+
"reset-weights",
|
|
219
|
+
"write-review-url",
|
|
220
|
+
"refresh",
|
|
221
|
+
"disconnect",
|
|
222
|
+
];
|
|
223
|
+
export function isCliModuleAction(key, action) {
|
|
224
|
+
if (key === "google_reviews") {
|
|
225
|
+
return GOOGLE_REVIEWS_CLI_ACTIONS.includes(action);
|
|
226
|
+
}
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
export function isDocumentedModuleKey(raw) {
|
|
230
|
+
return DOCUMENTED_MODULE_KEYS.includes(raw);
|
|
231
|
+
}
|
|
232
|
+
export function isGenericModuleVerb(raw) {
|
|
233
|
+
return GENERIC_MODULE_VERBS.includes(raw);
|
|
234
|
+
}
|
|
235
|
+
export function moduleCommand(key) {
|
|
236
|
+
return MODULE_COMMANDS.find((c) => c.key === key);
|
|
237
|
+
}
|
|
238
|
+
export function formatModuleUsage(key) {
|
|
239
|
+
const def = moduleCommand(key);
|
|
240
|
+
const lines = [
|
|
241
|
+
`${def.key} — ${def.name}`,
|
|
242
|
+
def.summary,
|
|
243
|
+
"",
|
|
244
|
+
`Usage: frontpage modules ${def.key} <action> [flags] [--site <slug>] [--json]`,
|
|
245
|
+
` frontpage modules <generic> ${def.key} …`,
|
|
246
|
+
"",
|
|
247
|
+
"Actions (generic):",
|
|
248
|
+
" docs Markup / agent how-to",
|
|
249
|
+
" request-setup Amber bar in the editor (CLI cannot show it)",
|
|
250
|
+
" enable|disable|archive",
|
|
251
|
+
" config --config '{…}' Whitelisted JSON only",
|
|
252
|
+
];
|
|
253
|
+
if (def.extraActions.length) {
|
|
254
|
+
lines.push("", "Actions (this module):", ...def.extraActions.map((a) => ` ${a}`));
|
|
255
|
+
}
|
|
256
|
+
if (def.notYet.length) {
|
|
257
|
+
lines.push("", "Not in this CLI yet (use Modules or the editor):", ` ${def.notYet.join(", ")}`);
|
|
258
|
+
}
|
|
259
|
+
if (def.notes.length) {
|
|
260
|
+
lines.push("", ...def.notes);
|
|
261
|
+
}
|
|
262
|
+
lines.push("", "Examples:", ...def.examples.map((e) => ` ${e}`));
|
|
263
|
+
lines.push("", "See also: https://frontpage.host/developers/modules");
|
|
264
|
+
return lines.join("\n");
|
|
265
|
+
}
|
|
266
|
+
export function formatModulesIndex() {
|
|
267
|
+
const rows = MODULE_COMMANDS.map((c) => ` ${c.key.padEnd(16)} ${c.summary}`);
|
|
268
|
+
return [
|
|
269
|
+
"Module keys (see `frontpage modules <key>` for that key's CLI usage):",
|
|
270
|
+
...rows,
|
|
271
|
+
"",
|
|
272
|
+
"Generic: frontpage modules list|docs|request-setup|enable|disable|archive|config …",
|
|
273
|
+
"Articles content: frontpage articles …",
|
|
274
|
+
"Index: https://frontpage.host/developers/modules",
|
|
275
|
+
].join("\n");
|
|
276
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runGoogleReviews(slug: string, action: string, flags: string[]): Promise<number>;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §CLI-MOD-GR — google_reviews extra verbs.
|
|
3
|
+
*/
|
|
4
|
+
import { assertNoUnknownFlags, hasFlag, takeFlag } from "../argv.js";
|
|
5
|
+
import { EXIT_OK, LONG_MODULE_TIMEOUT_MS, v1Get, v1Post, } from "../http/client.js";
|
|
6
|
+
import { emitOk, emitUsage, isJson, requireYesOrTty } from "../runtime.js";
|
|
7
|
+
import { formatModuleUsage } from "./commands.js";
|
|
8
|
+
const USAGE = formatModuleUsage("google_reviews");
|
|
9
|
+
function pathFor(slug) {
|
|
10
|
+
return `/api/v1/sites/${encodeURIComponent(slug)}/modules/google_reviews`;
|
|
11
|
+
}
|
|
12
|
+
function takePlaceBody(work) {
|
|
13
|
+
const placeId = takeFlag(work, "--place-id");
|
|
14
|
+
const mapsUrl = takeFlag(work, "--maps-url");
|
|
15
|
+
assertNoUnknownFlags(work, "modules");
|
|
16
|
+
if (placeId && mapsUrl) {
|
|
17
|
+
return emitUsage("modules", "Pass --place-id or --maps-url, not both.\n\n" + USAGE);
|
|
18
|
+
}
|
|
19
|
+
if (!placeId && !mapsUrl) {
|
|
20
|
+
return emitUsage("modules", "Usage: frontpage modules google_reviews connect|resolve --place-id <id> | --maps-url <url>\n\n" + USAGE);
|
|
21
|
+
}
|
|
22
|
+
return { ...(placeId ? { placeId } : {}), ...(mapsUrl ? { mapsUrl } : {}) };
|
|
23
|
+
}
|
|
24
|
+
function clip(text, max = 80) {
|
|
25
|
+
const one = text.replace(/\s+/g, " ").trim();
|
|
26
|
+
if (one.length <= max)
|
|
27
|
+
return one;
|
|
28
|
+
return `${one.slice(0, max - 1)}…`;
|
|
29
|
+
}
|
|
30
|
+
function printReviews(rows) {
|
|
31
|
+
if (!rows.length) {
|
|
32
|
+
console.log("(no reviews)");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
for (const r of rows) {
|
|
36
|
+
const vis = r.visibility.padEnd(12);
|
|
37
|
+
const stars = `${Math.round(r.rating)}★`;
|
|
38
|
+
const quote = r.text ? ` “${clip(r.text)}”` : "";
|
|
39
|
+
console.log(`${vis} ${stars} ${r.authorName}${quote}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export async function runGoogleReviews(slug, action, flags) {
|
|
43
|
+
const work = [...flags];
|
|
44
|
+
if (action === "status" || action === "write-review-url") {
|
|
45
|
+
assertNoUnknownFlags(work, "modules");
|
|
46
|
+
const data = await v1Get(pathFor(slug));
|
|
47
|
+
if (isJson()) {
|
|
48
|
+
emitOk("modules", data);
|
|
49
|
+
return EXIT_OK;
|
|
50
|
+
}
|
|
51
|
+
const url = data.listing?.writeReviewUrl;
|
|
52
|
+
if (action === "write-review-url") {
|
|
53
|
+
if (!url)
|
|
54
|
+
return emitUsage("modules", "Connect a Google listing first.");
|
|
55
|
+
console.log(url);
|
|
56
|
+
return EXIT_OK;
|
|
57
|
+
}
|
|
58
|
+
const name = String(data.connection?.display?.businessName ?? "(not connected)");
|
|
59
|
+
const address = data.connection?.display?.address;
|
|
60
|
+
console.log(name);
|
|
61
|
+
if (address)
|
|
62
|
+
console.log(String(address));
|
|
63
|
+
console.log(`ready ${data.connection?.ready ? "yes" : "no"}`);
|
|
64
|
+
if (data.listing) {
|
|
65
|
+
console.log(`rating ${data.listing.rating ?? "—"} (${data.listing.reviewCount ?? 0} listing)`);
|
|
66
|
+
console.log(`cached ${data.listing.cachedCount ?? 0}`);
|
|
67
|
+
if (data.listing.newestReviewAt)
|
|
68
|
+
console.log(`newest ${data.listing.newestReviewAt}`);
|
|
69
|
+
}
|
|
70
|
+
if (data.curation) {
|
|
71
|
+
console.log(`stars ${(data.curation.stars ?? []).join(",")}`);
|
|
72
|
+
console.log(`sort ${data.curation.sort ?? "newest"}`);
|
|
73
|
+
console.log(`hidden ${data.curation.hiddenCount ?? 0}`);
|
|
74
|
+
}
|
|
75
|
+
if (url)
|
|
76
|
+
console.log(`write ${url}`);
|
|
77
|
+
return EXIT_OK;
|
|
78
|
+
}
|
|
79
|
+
if (action === "list-reviews") {
|
|
80
|
+
const limit = takeFlag(work, "--limit");
|
|
81
|
+
const offset = takeFlag(work, "--offset");
|
|
82
|
+
const stars = takeFlag(work, "--stars");
|
|
83
|
+
const hidden = hasFlag(work, "--hidden");
|
|
84
|
+
assertNoUnknownFlags(work, "modules");
|
|
85
|
+
const q = new URLSearchParams();
|
|
86
|
+
if (limit)
|
|
87
|
+
q.set("limit", limit);
|
|
88
|
+
if (offset)
|
|
89
|
+
q.set("offset", offset);
|
|
90
|
+
if (stars)
|
|
91
|
+
q.set("stars", stars);
|
|
92
|
+
if (hidden)
|
|
93
|
+
q.set("hidden", "1");
|
|
94
|
+
const qs = q.toString() ? `?${q.toString()}` : "";
|
|
95
|
+
const data = await v1Get(`${pathFor(slug)}/reviews${qs}`);
|
|
96
|
+
if (isJson()) {
|
|
97
|
+
emitOk("modules", data);
|
|
98
|
+
return EXIT_OK;
|
|
99
|
+
}
|
|
100
|
+
console.log(`${data.reviews.length} of ${data.total} (offset ${data.offset})`);
|
|
101
|
+
printReviews(data.reviews);
|
|
102
|
+
return EXIT_OK;
|
|
103
|
+
}
|
|
104
|
+
if (action === "connect" || action === "resolve") {
|
|
105
|
+
const body = takePlaceBody(work);
|
|
106
|
+
if (typeof body === "number")
|
|
107
|
+
return body;
|
|
108
|
+
const data = await v1Post(pathFor(slug), { action, ...body }, action === "connect" ? { timeoutMs: LONG_MODULE_TIMEOUT_MS } : undefined);
|
|
109
|
+
if (isJson()) {
|
|
110
|
+
emitOk("modules", data);
|
|
111
|
+
return EXIT_OK;
|
|
112
|
+
}
|
|
113
|
+
if (action === "resolve") {
|
|
114
|
+
console.log(`${data.businessName} — ${data.address} — ${data.placeId}`);
|
|
115
|
+
return EXIT_OK;
|
|
116
|
+
}
|
|
117
|
+
const name = String(data.businessName ?? "listing");
|
|
118
|
+
const n = data.reviewCountCached ?? 0;
|
|
119
|
+
const url = data.writeReviewUrl ? ` Write-a-review: ${data.writeReviewUrl}` : "";
|
|
120
|
+
console.log(`Connected ${name} — ${n} reviews cached.${url}`);
|
|
121
|
+
return EXIT_OK;
|
|
122
|
+
}
|
|
123
|
+
if (action === "refresh") {
|
|
124
|
+
assertNoUnknownFlags(work, "modules");
|
|
125
|
+
const data = await v1Post(pathFor(slug), { action: "refresh" }, { timeoutMs: LONG_MODULE_TIMEOUT_MS });
|
|
126
|
+
if (isJson()) {
|
|
127
|
+
emitOk("modules", data);
|
|
128
|
+
return EXIT_OK;
|
|
129
|
+
}
|
|
130
|
+
console.log(`Refreshed — ${data.reviewCount ?? 0} reviews cached.`);
|
|
131
|
+
return EXIT_OK;
|
|
132
|
+
}
|
|
133
|
+
if (action === "disconnect") {
|
|
134
|
+
assertNoUnknownFlags(work, "modules");
|
|
135
|
+
const refuse = requireYesOrTty("disconnect Google reviews");
|
|
136
|
+
if (refuse)
|
|
137
|
+
return emitUsage("modules", refuse);
|
|
138
|
+
const data = await v1Post(pathFor(slug), { action: "disconnect" });
|
|
139
|
+
if (isJson()) {
|
|
140
|
+
emitOk("modules", data);
|
|
141
|
+
return EXIT_OK;
|
|
142
|
+
}
|
|
143
|
+
console.log("Disconnected. Cached reviews were kept.");
|
|
144
|
+
return EXIT_OK;
|
|
145
|
+
}
|
|
146
|
+
if (action === "hide" || action === "show") {
|
|
147
|
+
const id = takeFlag(work, "--id");
|
|
148
|
+
assertNoUnknownFlags(work, "modules");
|
|
149
|
+
if (!id)
|
|
150
|
+
return emitUsage("modules", `Usage: frontpage modules google_reviews ${action} --id <reviewId>\n\n${USAGE}`);
|
|
151
|
+
const data = await v1Post(pathFor(slug), {
|
|
152
|
+
action: action === "hide" ? "hide_review" : "show_review",
|
|
153
|
+
reviewId: id,
|
|
154
|
+
});
|
|
155
|
+
if (isJson()) {
|
|
156
|
+
emitOk("modules", data);
|
|
157
|
+
return EXIT_OK;
|
|
158
|
+
}
|
|
159
|
+
console.log(action === "hide" ? `Hidden ${id}.` : `Shown ${id}.`);
|
|
160
|
+
return EXIT_OK;
|
|
161
|
+
}
|
|
162
|
+
if (action === "set-stars") {
|
|
163
|
+
const fromFlag = takeFlag(work, "--stars");
|
|
164
|
+
const raw = fromFlag ?? work.shift();
|
|
165
|
+
assertNoUnknownFlags(work, "modules");
|
|
166
|
+
if (!raw)
|
|
167
|
+
return emitUsage("modules", `Usage: frontpage modules google_reviews set-stars 4,5\n\n${USAGE}`);
|
|
168
|
+
const stars = raw.split(",").map((s) => Number(s.trim())).filter((n) => Number.isInteger(n));
|
|
169
|
+
const data = await v1Post(pathFor(slug), {
|
|
170
|
+
action: "set_star_filter",
|
|
171
|
+
stars,
|
|
172
|
+
});
|
|
173
|
+
if (isJson()) {
|
|
174
|
+
emitOk("modules", data);
|
|
175
|
+
return EXIT_OK;
|
|
176
|
+
}
|
|
177
|
+
console.log(`Star filter: ${stars.join(",")}`);
|
|
178
|
+
return EXIT_OK;
|
|
179
|
+
}
|
|
180
|
+
if (action === "set-sort") {
|
|
181
|
+
const sort = takeFlag(work, "--sort") ?? work.shift();
|
|
182
|
+
assertNoUnknownFlags(work, "modules");
|
|
183
|
+
if (!sort || !["newest", "highest", "lowest"].includes(sort)) {
|
|
184
|
+
return emitUsage("modules", `Usage: frontpage modules google_reviews set-sort newest|highest|lowest\n\n${USAGE}`);
|
|
185
|
+
}
|
|
186
|
+
const data = await v1Post(pathFor(slug), {
|
|
187
|
+
action: "set_review_sort",
|
|
188
|
+
sort,
|
|
189
|
+
});
|
|
190
|
+
if (isJson()) {
|
|
191
|
+
emitOk("modules", data);
|
|
192
|
+
return EXIT_OK;
|
|
193
|
+
}
|
|
194
|
+
console.log(`Sort: ${sort}`);
|
|
195
|
+
return EXIT_OK;
|
|
196
|
+
}
|
|
197
|
+
if (action === "set-weight") {
|
|
198
|
+
const id = takeFlag(work, "--id");
|
|
199
|
+
const weightRaw = takeFlag(work, "--weight");
|
|
200
|
+
assertNoUnknownFlags(work, "modules");
|
|
201
|
+
if (!id || weightRaw == null) {
|
|
202
|
+
return emitUsage("modules", `Usage: frontpage modules google_reviews set-weight --id <reviewId> --weight 1-1000\n\n${USAGE}`);
|
|
203
|
+
}
|
|
204
|
+
const weight = Number(weightRaw);
|
|
205
|
+
const data = await v1Post(pathFor(slug), {
|
|
206
|
+
action: "set_review_weight",
|
|
207
|
+
reviewId: id,
|
|
208
|
+
weight,
|
|
209
|
+
});
|
|
210
|
+
if (isJson()) {
|
|
211
|
+
emitOk("modules", data);
|
|
212
|
+
return EXIT_OK;
|
|
213
|
+
}
|
|
214
|
+
console.log(weight === 1 ? `Weight cleared for ${id}.` : `Weight ${weight} for ${id}.`);
|
|
215
|
+
return EXIT_OK;
|
|
216
|
+
}
|
|
217
|
+
if (action === "reset-weights") {
|
|
218
|
+
assertNoUnknownFlags(work, "modules");
|
|
219
|
+
const data = await v1Post(pathFor(slug), { action: "reset_review_weights" });
|
|
220
|
+
if (isJson()) {
|
|
221
|
+
emitOk("modules", data);
|
|
222
|
+
return EXIT_OK;
|
|
223
|
+
}
|
|
224
|
+
console.log("Weights reset.");
|
|
225
|
+
return EXIT_OK;
|
|
226
|
+
}
|
|
227
|
+
return emitUsage("modules", `${USAGE}\n\nUnknown action "${action}".`);
|
|
228
|
+
}
|
package/dist/registry.js
CHANGED
|
@@ -168,7 +168,8 @@ export const COMMANDS = [
|
|
|
168
168
|
"frontpage fonts --query Cinzel --json",
|
|
169
169
|
],
|
|
170
170
|
flags: [
|
|
171
|
-
"Use the exact `value` string in tokens.fonts.* (via frontpage tokens set or push)",
|
|
171
|
+
"Use the exact `value` string in tokens.fonts.* (via frontpage tokens set or push), then APPLY font-* utilities",
|
|
172
|
+
"Build bundles catalog faces from tokens.ts and/or CSS font-family contexts (not prose mentions)",
|
|
172
173
|
"No --site required — catalog is account/platform scoped",
|
|
173
174
|
],
|
|
174
175
|
},
|
|
@@ -316,18 +317,32 @@ export const COMMANDS = [
|
|
|
316
317
|
{
|
|
317
318
|
name: "modules",
|
|
318
319
|
summary: "List, read docs, or mutate modules (secret masks only)",
|
|
319
|
-
usage: "frontpage modules [list|docs|request-setup|enable|disable|archive|config] <key> [--instance <id>] [--config '{…}'] [--site <slug>]",
|
|
320
|
+
usage: "frontpage modules [list|docs|request-setup|enable|disable|archive|config] <key> | frontpage modules <key> [action] [--instance <id>] [--config '{…}'] [--site <slug>]",
|
|
320
321
|
topics: ["agent", "content"],
|
|
321
322
|
examples: [
|
|
323
|
+
"frontpage modules google_reviews",
|
|
324
|
+
"frontpage modules google_reviews connect --place-id ChIJ…",
|
|
325
|
+
"frontpage modules google_reviews list-reviews --stars 4,5",
|
|
326
|
+
"frontpage modules google_reviews enable",
|
|
322
327
|
"frontpage modules docs forms",
|
|
328
|
+
"frontpage modules docs google_reviews",
|
|
323
329
|
"frontpage modules docs signups",
|
|
324
330
|
"frontpage modules list",
|
|
325
331
|
'frontpage modules request-setup payments --reason "You asked for a $50 deposit button — Stripe setup makes it live"',
|
|
332
|
+
'frontpage modules request-setup google_reviews --reason "You asked for Google reviews — pick your listing so we show the right ones"',
|
|
333
|
+
],
|
|
334
|
+
flags: [
|
|
335
|
+
"Bare `frontpage modules <key>` prints that key's CLI usage (exit 2) — not agentDocs",
|
|
336
|
+
"Key-first and verb-first both work: `modules google_reviews enable` = `modules enable google_reviews`",
|
|
337
|
+
"google_reviews extras: connect / resolve / status / list-reviews / hide / show / set-stars / set-sort / set-weight / reset-weights / refresh / disconnect / write-review-url",
|
|
338
|
+
"See https://frontpage.host/developers/modules and /developers/modules/google-reviews",
|
|
326
339
|
],
|
|
327
340
|
dangers: [
|
|
328
341
|
"Secret values are never returned — masks only",
|
|
329
342
|
"request-setup surfaces an owner prompt in the editor status bar (CLI cannot show it)",
|
|
343
|
+
"Do not write placeId through generic config — that skips listing resolve + seed",
|
|
330
344
|
],
|
|
345
|
+
seeAlso: ["articles", "inbox"],
|
|
331
346
|
},
|
|
332
347
|
{
|
|
333
348
|
name: "extensions",
|
|
@@ -359,7 +374,7 @@ export const COMMANDS = [
|
|
|
359
374
|
{
|
|
360
375
|
name: "inbox",
|
|
361
376
|
summary: "List leads / subscribers / orders",
|
|
362
|
-
usage: "frontpage inbox [leads|subscribers|orders|…] [--mark-read] [--csv] [--site <slug>]",
|
|
377
|
+
usage: "frontpage inbox [leads|subscribers|orders|google_reviews|…] [--mark-read] [--csv] [--site <slug>]",
|
|
363
378
|
topics: ["content"],
|
|
364
379
|
dangers: ["--mark-read is side-effecting with no confirm"],
|
|
365
380
|
},
|
|
@@ -517,8 +532,10 @@ export const TOPICS = {
|
|
|
517
532
|
|
|
518
533
|
Tokens & fonts:
|
|
519
534
|
- Keep required colors/fonts/spacing/radii keys; style via CSS variables / token Tailwind.
|
|
520
|
-
-
|
|
521
|
-
-
|
|
535
|
+
- Load rule: catalog faces bundle when the family string is in tokens.ts and/or a real CSS font-family / fontFamily / font-['…'] context under src/pages|components|styles — not from prose alone.
|
|
536
|
+
- Preferred path: frontpage fonts → exact value → tokens set fonts.<role> → APPLY font-sans|serif|mono|display (or var(--font-*)).
|
|
537
|
+
- Inline catalog font-family accents can load after rebuild; brand roles still prefer tokens + utilities.
|
|
538
|
+
- Setting fonts.sans alone is not enough — apply the utility on elements.
|
|
522
539
|
- Surgical token edit: frontpage tokens set --group fonts --key sans --value "…" (CAS like push).
|
|
523
540
|
|
|
524
541
|
Chrome / SEO / 404:
|
|
@@ -549,6 +566,7 @@ export const TOPICS = {
|
|
|
549
566
|
frontpage analytics summary|query|funnel|timeseries|compare|sql …
|
|
550
567
|
frontpage pages
|
|
551
568
|
frontpage modules
|
|
569
|
+
frontpage modules <key> # that key's CLI usage
|
|
552
570
|
frontpage modules request-setup <key> --reason "…"
|
|
553
571
|
frontpage extensions
|
|
554
572
|
|
|
@@ -561,12 +579,14 @@ export const TOPICS = {
|
|
|
561
579
|
Do not publish unless asked.`,
|
|
562
580
|
content: `Content
|
|
563
581
|
frontpage media list|upload <file> # images/PDF/video; text/CSV = inline not library; sitePath first when stored
|
|
564
|
-
frontpage inbox [leads|subscribers|orders|…] [--mark-read] [--csv]
|
|
582
|
+
frontpage inbox [leads|subscribers|orders|google_reviews|…] [--mark-read] [--csv]
|
|
565
583
|
frontpage seo get [/path|--path /path] | seo set --path /
|
|
566
584
|
frontpage articles list|content|create-section|create-article|set-draft|…
|
|
567
585
|
frontpage fonts [list|search] [--slot …] [--query …]
|
|
568
586
|
frontpage tokens set --group … --key … --value …
|
|
569
|
-
frontpage modules list|docs|request-setup|enable|disable|archive|config <key>
|
|
587
|
+
frontpage modules list|docs|request-setup|enable|disable|archive|config <key>
|
|
588
|
+
frontpage modules <key> # that key's CLI usage (generic only in this phase)
|
|
589
|
+
# mailing list key: signups. Index: https://frontpage.host/developers/modules
|
|
570
590
|
frontpage extensions list|docs|enable|disable|config <key>
|
|
571
591
|
frontpage settings get|set
|
|
572
592
|
frontpage edit --path / --old "…" --new "…"
|
package/llms.txt
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
- Introspect: frontpage help | frontpage help --json | frontpage help <topic|command>
|
|
6
6
|
- Topics: quickstart, auth, sync, site-building, agent, content, history, isolation, exit-codes
|
|
7
7
|
- Site building: frontpage help site-building — Astro pages map, BaseLayout, tokens, no backends/fake forms
|
|
8
|
-
- Fonts: frontpage fonts [--slot] [--query]
|
|
8
|
+
- Fonts: frontpage fonts [--slot] [--query] → exact value → tokens set fonts.<role> → APPLY font-sans|serif|mono|display. Build bundles catalog faces from tokens.ts and/or CSS font-family contexts (not prose). Inline-only without tokens works for catalog faces after rebuild; prefer tokens+utilities for brand roles.
|
|
9
9
|
- Module/extension docs: frontpage modules docs <key> | frontpage extensions docs <key>
|
|
10
10
|
- Search flags: --regex --case-sensitive --whole-word --files-only --context-lines --max-results
|
|
11
|
-
- Modules setup: frontpage modules request-setup <key> --reason "…" (owner status bar; CLI cannot show it)
|
|
11
|
+
- Modules setup: frontpage modules request-setup <key> --reason "…" (owner status bar; CLI cannot show it). frontpage modules <key> prints that key's CLI usage. Index: https://frontpage.host/developers/modules. google_reviews: frontpage modules google_reviews connect --place-id | --maps-url (server resolve + seed; no Autocomplete; do not write placeId via config). Also status, list-reviews, hide/show, set-stars, set-sort, set-weight, reset-weights, refresh, disconnect. Docs: https://frontpage.host/developers/modules/google-reviews. Markup: data-fp-google-reviews / data-fp-google-ask + required data-fp-requires="google_reviews". Ask scores: frontpage inbox google_reviews.
|
|
12
12
|
- Analytics ops: frontpage analytics summary|query|funnel|timeseries|compare|sql (bare analytics = dashboard)
|
|
13
13
|
- Media: frontpage media upload <file> (images/PDF ≤25 MB, video ≤50 MB, SVG/text ≤4 MB); human prints sitePath first — use /__media/uploads/<slug>/… in markup. Text/CSV is inline only (not media library; --json omits full content).
|
|
14
14
|
- Prompt attachments: frontpage prompt "…" --attach <file|/__media/…|https://…> [--asset-url https://…] (same media caps as media upload)
|