seo-supervisor 1.2.0 → 2.0.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/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +16 -3
- package/CHANGELOG.md +430 -0
- package/NOTICE +7 -0
- package/README.md +230 -25
- package/agents/seo-auditor.md +16 -0
- package/agents/seo-reviewer.md +16 -0
- package/bin/agents.mjs +194 -29
- package/bin/extras.mjs +422 -0
- package/bin/prompt.mjs +34 -14
- package/bin/seo-supervisor.mjs +386 -53
- package/commands/seo-audit.md +29 -3
- package/commands/seo-brief.md +28 -0
- package/commands/seo-connect.md +27 -0
- package/commands/seo-fix.md +24 -3
- package/commands/seo-grow.md +26 -0
- package/commands/seo-launch.md +17 -3
- package/commands/seo-review.md +13 -1
- package/commands/seo-rewrite.md +25 -0
- package/commands/seo-setup.md +17 -1
- package/commands/seo-watch.md +28 -0
- package/hooks/hooks.json +117 -0
- package/package.json +20 -7
- package/skills/seo-supervisor/NOTICE +7 -0
- package/skills/seo-supervisor/SKILL.md +302 -21
- package/skills/seo-supervisor/audience.md +61 -0
- package/skills/seo-supervisor/examples/drafts/security.md +41 -0
- package/skills/seo-supervisor/examples/hooks/README.md +28 -0
- package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
- package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
- package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
- package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
- package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
- package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
- package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
- package/skills/seo-supervisor/examples/sample-audit.json +94 -2
- package/skills/seo-supervisor/examples/sample-report.html +111 -61
- package/skills/seo-supervisor/examples/sample-report.md +147 -44
- package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
- package/skills/seo-supervisor/examples/snippets.md +648 -1
- package/skills/seo-supervisor/grow.md +342 -0
- package/skills/seo-supervisor/og-images.md +85 -0
- package/skills/seo-supervisor/page-types.md +124 -0
- package/skills/seo-supervisor/planning.md +19 -7
- package/skills/seo-supervisor/profile-template.md +41 -0
- package/skills/seo-supervisor/report-format.md +177 -10
- package/skills/seo-supervisor/rewrite.md +59 -0
- package/skills/seo-supervisor/rules/ai-search.md +65 -12
- package/skills/seo-supervisor/rules/content.md +33 -9
- package/skills/seo-supervisor/rules/crawl-index.md +33 -6
- package/skills/seo-supervisor/rules/internal-linking.md +49 -6
- package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
- package/skills/seo-supervisor/rules/media.md +13 -1
- package/skills/seo-supervisor/rules/metadata.md +41 -9
- package/skills/seo-supervisor/rules/performance.md +50 -5
- package/skills/seo-supervisor/rules/rendering.md +39 -2
- package/skills/seo-supervisor/rules/search-intent.md +32 -0
- package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
- package/skills/seo-supervisor/rules/structured-data.md +37 -14
- package/skills/seo-supervisor/rules/trust-security.md +25 -2
- package/skills/seo-supervisor/rules/urls.md +10 -2
- package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
- package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
- package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
- package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
- package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
- package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
- package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
- package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
- package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
- package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
- package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
- package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
- package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
- package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
- package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
- package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
- package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
- package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
- package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
- package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
- package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
- package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
- package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
- package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
- package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
- package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
- package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
- package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
- package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
- package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
- package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
- package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
- package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
- package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
- package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
- package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
- package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
- package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
- package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
- package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
- package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
- package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
- package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
- package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
- package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
- package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
- package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
- package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
- package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
- package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
- package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
- package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
- package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
- package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
- package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
- package/skills/seo-supervisor/scripts/google.mjs +1341 -0
- package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
- package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
- package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
- package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
- package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
- package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
- package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
- package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
- package/skills/seo-supervisor/scripts/guard.mjs +74 -0
- package/skills/seo-supervisor/scripts/images.mjs +408 -0
- package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
- package/skills/seo-supervisor/scripts/issues.mjs +217 -0
- package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
- package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
- package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
- package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
- package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
- package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
- package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
- package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
- package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
- package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
- package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
- package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
- package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
- package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
- package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
- package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
- package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
- package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
- package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
- package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
- package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
- package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
- package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
- package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
- package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
- package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
- package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
- package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
- package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
- package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
- package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
- package/skills/seo-supervisor/scripts/osm.mjs +359 -0
- package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
- package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
- package/skills/seo-supervisor/scripts/report/client.js +37 -0
- package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
- package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
- package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
- package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
- package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
- package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
- package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
- package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
- package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
- package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
- package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
- package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
- package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
- package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
- package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
- package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
- package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
- package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
- package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
- package/skills/seo-supervisor/scripts/report/styles.css +223 -0
- package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
- package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
- package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
- package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
- package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
- package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
- package/skills/seo-supervisor/site-types/content.md +34 -1
- package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
- package/skills/seo-supervisor/site-types/local-business.md +96 -6
- package/skills/seo-supervisor/site-types/services.md +46 -0
- package/skills/seo-supervisor/site-types/tools.md +3 -3
- package/skills/seo-supervisor/strategy.md +232 -0
- package/skills/seo-supervisor/troubleshooting.md +56 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
3
|
+
// Checks this machine is ready for an audit. Read-only and offline; it reports whether a key or token is there, never
|
|
4
|
+
// its value.
|
|
5
|
+
import { accessSync, constants, existsSync, readFileSync } from "node:fs";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { findBrowser } from "./checks/render.mjs";
|
|
8
|
+
import { findLighthouse } from "./checks/lighthouse.mjs";
|
|
9
|
+
import { SERVICES, savedKeys } from "./connect-keys.mjs";
|
|
10
|
+
import { googleFile, installedBrowser, loginDir, settingsDir, toolsDir } from "./lib/settings-dir.mjs";
|
|
11
|
+
import { proxyNote } from "./lib/proxy.mjs";
|
|
12
|
+
import { isMain } from "./lib/is-main.mjs";
|
|
13
|
+
import { runMain } from "./lib/cli.mjs";
|
|
14
|
+
import { parseArgs } from "./lib/args.mjs";
|
|
15
|
+
|
|
16
|
+
const writable = p => {
|
|
17
|
+
try {
|
|
18
|
+
accessSync(p, constants.W_OK);
|
|
19
|
+
return true;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
// The folder itself, or the nearest folder above it that exists (where it would be made).
|
|
25
|
+
const canWrite = p => {
|
|
26
|
+
while (!existsSync(p) && dirname(p) !== p) p = dirname(p);
|
|
27
|
+
return writable(p);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function doctor({ env = process.env, cwd = process.cwd(), version = process.versions.node } = {}) {
|
|
31
|
+
// bad means the audit can't run; warn is something to fix that doesn't stop it.
|
|
32
|
+
let ready = true;
|
|
33
|
+
const lines = [],
|
|
34
|
+
add = (state, text) => {
|
|
35
|
+
lines.push(`${{ ok: "ok", off: "--", bad: "!!", warn: "!!" }[state]} ${text}`);
|
|
36
|
+
if (state === "bad") ready = false;
|
|
37
|
+
};
|
|
38
|
+
const [major, minor] = version.split(".").map(Number);
|
|
39
|
+
add(
|
|
40
|
+
major >= 22 ? "ok" : "bad",
|
|
41
|
+
`Node ${version}${major >= 22 ? "" : ": SEO Supervisor needs Node 22 or later. Install it from https://nodejs.org"}`,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
let browser = null,
|
|
45
|
+
badPath = "";
|
|
46
|
+
try {
|
|
47
|
+
browser = findBrowser(env) || installedBrowser(env);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
badPath = e.message;
|
|
50
|
+
} // CHROME_PATH set to a missing file
|
|
51
|
+
if (badPath) add("bad", badPath);
|
|
52
|
+
else
|
|
53
|
+
add(
|
|
54
|
+
browser ? "ok" : "off",
|
|
55
|
+
browser
|
|
56
|
+
? `Chrome or Edge: ${browser}`
|
|
57
|
+
: "Chrome or Edge: not found. The render, phone and lab-speed checks, screenshots, share cards and the PDF report need one. Install Chrome or Edge, set CHROME_PATH to it, or in a container or CI run: npx seo-supervisor --with-browser",
|
|
58
|
+
);
|
|
59
|
+
const lh = findLighthouse(env);
|
|
60
|
+
const lhNode = major > 22 || (major === 22 && minor >= 19);
|
|
61
|
+
add(
|
|
62
|
+
lh ? "ok" : "off",
|
|
63
|
+
lh
|
|
64
|
+
? `Lighthouse: ${lh}`
|
|
65
|
+
: `Lighthouse: not installed (optional). Add it with: npx seo-supervisor --with-lighthouse (about 170 MB${lhNode ? "" : `; it needs Node 22.19 or later, this is ${version}`})`,
|
|
66
|
+
);
|
|
67
|
+
let tools = null;
|
|
68
|
+
try {
|
|
69
|
+
tools = toolsDir(env);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
add("bad", e.message);
|
|
72
|
+
}
|
|
73
|
+
const sharp = !!tools && existsSync(join(tools, "node_modules", "sharp"));
|
|
74
|
+
add(
|
|
75
|
+
sharp ? "ok" : "off",
|
|
76
|
+
sharp
|
|
77
|
+
? "Image add-on (sharp): installed"
|
|
78
|
+
: "Image add-on (sharp): not installed (optional). Add it with: npx seo-supervisor --with-image-tools (about 20 MB)",
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const dir = tools && settingsDir(env);
|
|
82
|
+
if (dir)
|
|
83
|
+
add(
|
|
84
|
+
canWrite(dir) ? "ok" : "warn",
|
|
85
|
+
`Settings folder: ${dir}${existsSync(dir) ? "" : " (not made yet; it's made the first time a login or key is saved)"}${canWrite(dir) ? "" : ". It can't be written to, so logins and keys can't be saved. Choose another folder with SEO_SUPERVISOR_HOME"}`,
|
|
86
|
+
);
|
|
87
|
+
let logins = null;
|
|
88
|
+
try {
|
|
89
|
+
logins = loginDir(env);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
add("bad", e.message);
|
|
92
|
+
}
|
|
93
|
+
if (logins && env.SEO_SUPERVISOR_CLIENT)
|
|
94
|
+
add("ok", `Client: ${env.SEO_SUPERVISOR_CLIENT}, with its own logins and keys in ${logins}`);
|
|
95
|
+
|
|
96
|
+
if (logins) {
|
|
97
|
+
let g = null;
|
|
98
|
+
const gFile = googleFile(env);
|
|
99
|
+
try {
|
|
100
|
+
g = JSON.parse(readFileSync(gFile, "utf8"));
|
|
101
|
+
} catch {}
|
|
102
|
+
const how =
|
|
103
|
+
{
|
|
104
|
+
shared: "SEO Supervisor's shared sign-in",
|
|
105
|
+
"own-client": "your own Google Cloud client",
|
|
106
|
+
"service-account": "a service account",
|
|
107
|
+
}[g?.method] || "a saved sign-in";
|
|
108
|
+
add(
|
|
109
|
+
g ? "ok" : "off",
|
|
110
|
+
g
|
|
111
|
+
? `Google: connected with ${how}${/^\d{4}-\d{2}-\d{2}/.test(g.connected_at || "") ? ` on ${g.connected_at.slice(0, 10)}` : ""}. To test it: node google.mjs status`
|
|
112
|
+
: existsSync(gFile)
|
|
113
|
+
? "Google: the saved sign-in can't be read. Connect again: node google.mjs connect"
|
|
114
|
+
: "Google: not connected (optional). Connect Search Console and Analytics with: node google.mjs connect",
|
|
115
|
+
);
|
|
116
|
+
let saved = {};
|
|
117
|
+
try {
|
|
118
|
+
saved = savedKeys();
|
|
119
|
+
} catch {
|
|
120
|
+
add(
|
|
121
|
+
"warn",
|
|
122
|
+
`Saved keys: ${join(logins, "keys.json")} can't be read. Fix it or delete it, then set the keys again`,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const names = Object.keys(saved)
|
|
126
|
+
.filter(k => SERVICES[k])
|
|
127
|
+
.map(k => SERVICES[k].name);
|
|
128
|
+
add(
|
|
129
|
+
names.length ? "ok" : "off",
|
|
130
|
+
names.length
|
|
131
|
+
? `Saved keys: ${names.join(", ")}`
|
|
132
|
+
: "Saved keys: none (optional). See: node connect-keys.mjs guide <service>",
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
const envKeys = ["PSI_API_KEY", "CRUX_API_KEY", ...Object.values(SERVICES).map(s => s.env)].filter(k => env[k]);
|
|
136
|
+
add(
|
|
137
|
+
envKeys.length ? "ok" : "off",
|
|
138
|
+
envKeys.length ? `Keys set in the environment: ${envKeys.join(", ")}` : "Keys set in the environment: none",
|
|
139
|
+
);
|
|
140
|
+
if (!env.PSI_API_KEY)
|
|
141
|
+
add(
|
|
142
|
+
"off",
|
|
143
|
+
"Real-user speed needs a free PageSpeed Insights key in PSI_API_KEY; without one, PERF-01 goes under Limits",
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const audit = join(cwd, "seo-audit");
|
|
147
|
+
add(
|
|
148
|
+
canWrite(audit) ? "ok" : "bad",
|
|
149
|
+
canWrite(audit)
|
|
150
|
+
? `This folder can be written to (the audit writes ${audit})`
|
|
151
|
+
: `This folder can't be written to, so the audit can't save ${audit}. Run it from a folder you can write to`,
|
|
152
|
+
);
|
|
153
|
+
const proxy = proxyNote(env);
|
|
154
|
+
if (proxy) add("warn", proxy);
|
|
155
|
+
return {
|
|
156
|
+
ready,
|
|
157
|
+
text: `SEO Supervisor readiness check (read-only: nothing was changed)\n\n${lines.join("\n")}\n\nok = ready · -- = optional, not set up · !! = needs fixing`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const USAGE = `usage: node doctor.mjs (or: npx seo-supervisor doctor)
|
|
162
|
+
|
|
163
|
+
Checks this computer is ready for an audit: Node, Chrome or Edge, the optional add-ons, the settings
|
|
164
|
+
folder, the connections and write access to this folder. Read-only: it changes and contacts nothing.
|
|
165
|
+
Exits 1 when the audit can't run here, else 0.
|
|
166
|
+
--help, -h show this help`;
|
|
167
|
+
|
|
168
|
+
if (isMain(import.meta.url))
|
|
169
|
+
await runMain(() => {
|
|
170
|
+
parseArgs(process.argv.slice(2), { flags: [], positionals: 0, usage: USAGE });
|
|
171
|
+
const r = doctor();
|
|
172
|
+
console.log(r.text);
|
|
173
|
+
return r.ready ? 0 : 1;
|
|
174
|
+
});
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
3
|
+
// Local rank grid: where a business's place ID ranks in Places text search at each point around it.
|
|
4
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { createInterface } from "node:readline/promises";
|
|
7
|
+
import { isMain } from "./lib/is-main.mjs";
|
|
8
|
+
import { parseArgs } from "./lib/args.mjs";
|
|
9
|
+
import { Fail, runMain, warnProxy } from "./lib/cli.mjs";
|
|
10
|
+
import { SERVICES, activeKeys, keyFile, call, Refused } from "./connect-keys.mjs";
|
|
11
|
+
|
|
12
|
+
const SIZES = [5, 7, 9],
|
|
13
|
+
SIZE = 7,
|
|
14
|
+
SPACING = 1,
|
|
15
|
+
MIN_SPACING = 0.1,
|
|
16
|
+
MAX_SPACING = 20,
|
|
17
|
+
MAX_KEYWORDS = 3,
|
|
18
|
+
TOP = 20,
|
|
19
|
+
FIND_MAX = 5; // local caps, not API limits
|
|
20
|
+
// IDs only keeps grid searches on the free Text Search Essentials IDs Only SKU.
|
|
21
|
+
// https://developers.google.com/maps/billing-and-pricing/pricing
|
|
22
|
+
const GRID_MASK = "places.id,places.attributions",
|
|
23
|
+
FIND_MASK = "places.id,places.displayName,places.formattedAddress";
|
|
24
|
+
const FINDER = "https://developers.google.com/maps/documentation/javascript/examples/places-placeid-finder";
|
|
25
|
+
const READ = "22 Nov 2026"; // when the prices quoted in the dry run were checked
|
|
26
|
+
export const LABEL =
|
|
27
|
+
"Where your business appears in the list Google's Places API returns near each point: an approximation of Google Maps results, not a copy.";
|
|
28
|
+
const USAGE = `usage: node geo-grid.mjs --place-id <id> --keywords "plumber, boiler repair" [--center lat,lng] [--size 5|7|9] [--spacing 1] [--out seo-audit/geo-grid.json] [--yes]
|
|
29
|
+
node geo-grid.mjs --find "Business name, town" [--yes]
|
|
30
|
+
--place-id your business's Google place ID. Find it on Google's Place ID Finder: ${FINDER}
|
|
31
|
+
or with --find, which shows Google's matches and saves the one you pick.
|
|
32
|
+
--keywords 1 to 3, each on its own, like plumber: not "plumber Leeds" or "plumber near me". A place name makes Google ignore each point.
|
|
33
|
+
--size points a side (default 7). --spacing: km between points (default 1). In the countryside, where businesses
|
|
34
|
+
are far apart, try --spacing 3 to 5.
|
|
35
|
+
--center the grid's middle, as latitude,longitude. Without it, Google is asked where your business is.`;
|
|
36
|
+
const fail = msg => {
|
|
37
|
+
throw new Fail("geo-grid: " + msg);
|
|
38
|
+
};
|
|
39
|
+
const PLACE_ID = /^[\w-]{10,}$/;
|
|
40
|
+
const r5 = x => Math.round(x * 1e5) / 1e5;
|
|
41
|
+
const KM_PER_DEG = (6371.0088 * Math.PI) / 180; // mean Earth radius, as in osm.mjs
|
|
42
|
+
// https://developers.google.com/maps/documentation/urls/get-started
|
|
43
|
+
const mapsLink = id =>
|
|
44
|
+
`https://www.google.com/maps/search/?api=1&query=business&query_place_id=${encodeURIComponent(id)}`;
|
|
45
|
+
// Google's text goes to a terminal, so control characters are stripped first.
|
|
46
|
+
const clean = s =>
|
|
47
|
+
String(s ?? "")
|
|
48
|
+
.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ")
|
|
49
|
+
.trim();
|
|
50
|
+
|
|
51
|
+
// Points row by row from the north-west corner; the centre is at floor(size / 2) both ways. Flat steps are fine
|
|
52
|
+
// for a few dozen km. Use a geodesic if grids ever span hundreds.
|
|
53
|
+
export function gridPoints({ lat, lng }, size, spacingKm) {
|
|
54
|
+
const half = Math.floor(size / 2),
|
|
55
|
+
step = spacingKm / KM_PER_DEG,
|
|
56
|
+
cells = [];
|
|
57
|
+
for (let row = 0; row < size; row++) {
|
|
58
|
+
// A km east spans more degrees of longitude the further the row is from the equator.
|
|
59
|
+
const y = lat + (half - row) * step,
|
|
60
|
+
east = step / Math.cos((y * Math.PI) / 180);
|
|
61
|
+
for (let col = 0; col < size; col++)
|
|
62
|
+
cells.push({ row, col, lat: r5(y), lng: r5(((((lng + (col - half) * east) % 360) + 540) % 360) - 180) });
|
|
63
|
+
}
|
|
64
|
+
return cells;
|
|
65
|
+
}
|
|
66
|
+
const counts = cells => {
|
|
67
|
+
const n = f => cells.filter(c => f(c.rank)).length,
|
|
68
|
+
found = r => typeof r === "number";
|
|
69
|
+
return {
|
|
70
|
+
top3: n(r => found(r) && r <= 3),
|
|
71
|
+
top10: n(r => found(r) && r <= 10),
|
|
72
|
+
top20: n(found),
|
|
73
|
+
notFound: n(r => r === null),
|
|
74
|
+
failed: n(r => r === "error"),
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const request = (key, mask, body) => ({
|
|
78
|
+
method: body ? "POST" : "GET",
|
|
79
|
+
redirect: "manual",
|
|
80
|
+
headers: { "x-goog-api-key": key, "x-goog-fieldmask": mask, "content-type": "application/json" },
|
|
81
|
+
...(body && { body: JSON.stringify(body) }),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// The first refusal (bad key, API off, no billing, rate limit) stops the run and marks the remaining points "error".
|
|
85
|
+
// Lone 5xx answers aren't retried; add that if Google proves flaky.
|
|
86
|
+
async function runGrid({
|
|
87
|
+
placeId,
|
|
88
|
+
keywords,
|
|
89
|
+
center = null,
|
|
90
|
+
size = SIZE,
|
|
91
|
+
spacingKm = SPACING,
|
|
92
|
+
key,
|
|
93
|
+
endpoint,
|
|
94
|
+
log = s => {},
|
|
95
|
+
}) {
|
|
96
|
+
const notes = [],
|
|
97
|
+
date = new Date().toISOString().slice(0, 10);
|
|
98
|
+
const d = await call(
|
|
99
|
+
"googleplaces",
|
|
100
|
+
`${endpoint}/places/${encodeURIComponent(placeId)}`,
|
|
101
|
+
request(key, center ? "id" : "id,location"),
|
|
102
|
+
);
|
|
103
|
+
const ids = new Set([placeId, d?.id].filter(x => typeof x === "string")); // Google may answer with a newer ID
|
|
104
|
+
if (!center) {
|
|
105
|
+
const at = d?.location;
|
|
106
|
+
if (!Number.isFinite(at?.latitude) || !Number.isFinite(at?.longitude))
|
|
107
|
+
throw new Refused(
|
|
108
|
+
"Google has no map position for this business: a business that hides its address (a service-area business) has none. Pass --center latitude,longitude, the middle of the area you serve.",
|
|
109
|
+
);
|
|
110
|
+
// Places coordinates may be cached for 30 days at most (Service Specific Terms 14.3).
|
|
111
|
+
// https://cloud.google.com/maps-platform/terms/maps-service-terms
|
|
112
|
+
center = { lat: at.latitude, lng: at.longitude };
|
|
113
|
+
notes.push(
|
|
114
|
+
`The grid's centre came from Google's Places API, and Google's terms let you keep those coordinates for 30 days at most (Service Specific Terms 14.3). Delete this file by ${new Date(Date.now() + 30 * 864e5).toISOString().slice(0, 10)}, or run again with --center.`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
// The bias circle is the largest that fits each point's square, so neighbouring circles touch without overlapping.
|
|
118
|
+
const cells = gridPoints(center, size, spacingKm),
|
|
119
|
+
biasRadiusM = Math.round(spacingKm * 500),
|
|
120
|
+
credits = new Map();
|
|
121
|
+
let stop = null,
|
|
122
|
+
sent = 0;
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const keyword of keywords) {
|
|
125
|
+
const done = [];
|
|
126
|
+
for (const c of cells) {
|
|
127
|
+
let rank = "error";
|
|
128
|
+
if (!stop) {
|
|
129
|
+
try {
|
|
130
|
+
// Without a bias Google ranks for the caller's IP, and a place name in the query overrides the bias, so the
|
|
131
|
+
// query is the bare keyword. Service-area businesses have no address and are only found with the flag set.
|
|
132
|
+
// https://developers.google.com/maps/documentation/places/web-service/text-search
|
|
133
|
+
const b = await call(
|
|
134
|
+
"googleplaces",
|
|
135
|
+
`${endpoint}/places:searchText`,
|
|
136
|
+
request(key, GRID_MASK, {
|
|
137
|
+
textQuery: keyword,
|
|
138
|
+
locationBias: { circle: { center: { latitude: c.lat, longitude: c.lng }, radius: biasRadiusM } },
|
|
139
|
+
includePureServiceAreaBusinesses: true,
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
if (!b || typeof b !== "object")
|
|
143
|
+
throw new Refused(
|
|
144
|
+
"Google Places API's answer isn't the list of places it used to send, so the run stopped. Google may have changed the API.",
|
|
145
|
+
);
|
|
146
|
+
const places = Array.isArray(b.places) ? b.places : []; // Google leaves `places` out when nothing matches
|
|
147
|
+
for (const p of places)
|
|
148
|
+
for (const a of Array.isArray(p?.attributions) ? p.attributions : [])
|
|
149
|
+
if (typeof a?.provider === "string" && a.provider) credits.set(clean(a.provider), clean(a.providerUri));
|
|
150
|
+
// The position is Google's order as returned: the terms forbid re-sorting results (3.2.3(g)).
|
|
151
|
+
const i = places.findIndex(p => ids.has(p?.id));
|
|
152
|
+
rank = i >= 0 && i < TOP ? i + 1 : null;
|
|
153
|
+
sent++;
|
|
154
|
+
} catch (e) {
|
|
155
|
+
if (!(e instanceof Refused)) throw e;
|
|
156
|
+
stop = e.message;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
done.push({ ...c, rank });
|
|
160
|
+
}
|
|
161
|
+
out.push({ keyword, cells: done, ...counts(done) });
|
|
162
|
+
log(`"${keyword}": ${done.filter(c => c.rank !== "error").length} of ${cells.length} points checked`);
|
|
163
|
+
}
|
|
164
|
+
// Places content must carry Google's attribution, plus any third-party credit it sends (3.2.2(b)).
|
|
165
|
+
if (credits.size)
|
|
166
|
+
notes.push(
|
|
167
|
+
`Google's results include data from ${[...credits].map(([p, u]) => (u ? `${p} (${u})` : p)).join(", ")}. Show this credit next to "Google Maps" wherever the grid is shown.`,
|
|
168
|
+
);
|
|
169
|
+
if (stop)
|
|
170
|
+
notes.push(
|
|
171
|
+
`Stopped after ${sent} of ${cells.length * keywords.length} searches: ${stop} The points not checked are marked as errors.`,
|
|
172
|
+
);
|
|
173
|
+
return {
|
|
174
|
+
result: {
|
|
175
|
+
source: "geo-grid",
|
|
176
|
+
date,
|
|
177
|
+
placeId,
|
|
178
|
+
center: { lat: r5(center.lat), lng: r5(center.lng) },
|
|
179
|
+
size,
|
|
180
|
+
spacingKm,
|
|
181
|
+
biasRadiusM,
|
|
182
|
+
attribution: "Google Maps",
|
|
183
|
+
label: LABEL,
|
|
184
|
+
keywords: out,
|
|
185
|
+
notes,
|
|
186
|
+
},
|
|
187
|
+
stop,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// One line from the terminal, or the first line piped in.
|
|
192
|
+
async function answer(prompt) {
|
|
193
|
+
const { stdin, stderr } = process;
|
|
194
|
+
if (stdin.isTTY) {
|
|
195
|
+
const rl = createInterface({ input: stdin, output: stderr });
|
|
196
|
+
try {
|
|
197
|
+
return await rl.question(prompt);
|
|
198
|
+
} catch {
|
|
199
|
+
return "";
|
|
200
|
+
} finally {
|
|
201
|
+
rl.close();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
let text = "";
|
|
205
|
+
for await (const c of stdin) {
|
|
206
|
+
text += c;
|
|
207
|
+
if (text.includes("\n")) break;
|
|
208
|
+
}
|
|
209
|
+
return text.split(/\r?\n/)[0];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function find({ text, key, from, endpoint, placeFile, yes }) {
|
|
213
|
+
if (!yes) {
|
|
214
|
+
console.log(
|
|
215
|
+
[
|
|
216
|
+
`geo-grid: dry run, nothing sent. With --yes it would send "${text}" to Google's Places API (New) at ${new URL(endpoint).host} once, ${from}, and ask for up to ${FIND_MAX} matches with their place ID, name and address.`,
|
|
217
|
+
`That request is billed as Text Search Pro: on ${READ} Google's price list showed 5,000 free a month, then $32.00 per 1,000 (developers.google.com/maps/billing-and-pricing/pricing).`,
|
|
218
|
+
"You pick your business from the list. Only its place ID is saved: Google's terms don't allow saving names or addresses.",
|
|
219
|
+
"Re-run with --yes once the owner agrees.",
|
|
220
|
+
].join("\n"),
|
|
221
|
+
);
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
const b = await call(
|
|
225
|
+
"googleplaces",
|
|
226
|
+
`${endpoint}/places:searchText`,
|
|
227
|
+
request(key, FIND_MASK, { textQuery: text, pageSize: FIND_MAX }),
|
|
228
|
+
);
|
|
229
|
+
const found = (Array.isArray(b?.places) ? b.places : [])
|
|
230
|
+
.filter(p => typeof p?.id === "string" && PLACE_ID.test(p.id))
|
|
231
|
+
.slice(0, FIND_MAX);
|
|
232
|
+
if (!found.length) {
|
|
233
|
+
console.log(
|
|
234
|
+
`geo-grid: Google found no match for "${text}". Try the name as it shows on Google Maps, with the town.`,
|
|
235
|
+
);
|
|
236
|
+
return 1;
|
|
237
|
+
}
|
|
238
|
+
console.log(
|
|
239
|
+
`geo-grid: Google's matches for "${text}" (shown here, not saved):\n${found.map((p, i) => ` ${i + 1}. ${[clean(p.displayName?.text), clean(p.formattedAddress)].filter(Boolean).join(", ")}\n place ID ${p.id}`).join("\n")}\nResults: Google Maps`,
|
|
240
|
+
);
|
|
241
|
+
const n = Number(
|
|
242
|
+
(await answer(`Which one is your business? Type its number and press Enter (just Enter for none): `)).trim(),
|
|
243
|
+
);
|
|
244
|
+
if (!(Number.isInteger(n) && n >= 1 && n <= found.length)) {
|
|
245
|
+
console.log(`geo-grid: Nothing saved. Run again and type a number, or pass --place-id to geo-grid.mjs.`);
|
|
246
|
+
return 0;
|
|
247
|
+
}
|
|
248
|
+
// Only place_id may be cached; names and addresses are shown, never saved (Service Specific Terms 3).
|
|
249
|
+
mkdirSync(dirname(placeFile), { recursive: true });
|
|
250
|
+
writeFileSync(placeFile, JSON.stringify({ placeId: found[n - 1].id }, null, 2) + "\n");
|
|
251
|
+
console.log(
|
|
252
|
+
`geo-grid: saved place ID ${found[n - 1].id} in ${placeFile} (only the ID). Check it's yours: ${mapsLink(found[n - 1].id)}\nNext: node geo-grid.mjs --keywords "your keyword" reads it from there.`,
|
|
253
|
+
);
|
|
254
|
+
return 0;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async function main(argv) {
|
|
258
|
+
const args = parseArgs(argv, {
|
|
259
|
+
flags: ["place-id", "keywords", "center", "size", "spacing", "out", "find"],
|
|
260
|
+
booleans: ["yes"],
|
|
261
|
+
positionals: 0,
|
|
262
|
+
usage: USAGE,
|
|
263
|
+
});
|
|
264
|
+
const str = k => (typeof args[k] === "string" ? args[k].trim() : null),
|
|
265
|
+
yes = args.yes === true;
|
|
266
|
+
const out = resolve(str("out") || "seo-audit/geo-grid.json"),
|
|
267
|
+
placeFile = join(dirname(out), "geo-grid-place.json");
|
|
268
|
+
const k = activeKeys().googleplaces,
|
|
269
|
+
s = SERVICES.googleplaces,
|
|
270
|
+
endpoint = (process.env[s.endpointEnv] || s.endpoint).replace(/\/+$/, "");
|
|
271
|
+
const from = k ? `with your key ${k.from === s.env ? `from ${s.env}` : `saved in ${keyFile()}`}` : "with your key";
|
|
272
|
+
const needKey = () =>
|
|
273
|
+
k?.key || fail("no Google Places key is set. To add one: node connect-keys.mjs guide googleplaces");
|
|
274
|
+
if (str("find")) return find({ text: str("find"), key: yes && needKey(), from, endpoint, placeFile, yes });
|
|
275
|
+
|
|
276
|
+
let saved = null;
|
|
277
|
+
if (!str("place-id"))
|
|
278
|
+
try {
|
|
279
|
+
saved = JSON.parse(readFileSync(placeFile, "utf8")).placeId;
|
|
280
|
+
} catch {}
|
|
281
|
+
const placeId = str("place-id") || (typeof saved === "string" ? saved : null);
|
|
282
|
+
if (!placeId && !str("keywords")) throw new Fail(USAGE);
|
|
283
|
+
if (!placeId)
|
|
284
|
+
fail(
|
|
285
|
+
`no place ID. Pass --place-id <id> (Google's Place ID Finder: ${FINDER}), or find it with --find "Business name, town".`,
|
|
286
|
+
);
|
|
287
|
+
if (!PLACE_ID.test(placeId))
|
|
288
|
+
fail(
|
|
289
|
+
`"${placeId}" isn't a place ID: those are long codes of letters, digits, - and _, like ChIJN1t_tDeuEmsRUsoyG83frY4. Find yours on Google's Place ID Finder: ${FINDER}`,
|
|
290
|
+
);
|
|
291
|
+
const keywords = [
|
|
292
|
+
...new Set(
|
|
293
|
+
(str("keywords") || "")
|
|
294
|
+
.split(",")
|
|
295
|
+
.map(x => x.trim().replace(/\s+/g, " "))
|
|
296
|
+
.filter(Boolean),
|
|
297
|
+
),
|
|
298
|
+
];
|
|
299
|
+
if (!keywords.length)
|
|
300
|
+
fail(
|
|
301
|
+
`--keywords needs 1 to ${MAX_KEYWORDS} keywords, separated by commas, like --keywords "plumber, boiler repair".`,
|
|
302
|
+
);
|
|
303
|
+
if (keywords.length > MAX_KEYWORDS)
|
|
304
|
+
fail(
|
|
305
|
+
`${keywords.length} keywords, but a run takes at most ${MAX_KEYWORDS} (our own cap, to keep it small). Keep the ones that matter most.`,
|
|
306
|
+
);
|
|
307
|
+
const size = args.size === undefined ? SIZE : Number(str("size"));
|
|
308
|
+
if (!SIZES.includes(size)) fail(`--size must be 5, 7 or 9 points a side (got ${args.size}).`);
|
|
309
|
+
const spacingKm = args.spacing === undefined ? SPACING : Number(str("spacing"));
|
|
310
|
+
if (!(spacingKm >= MIN_SPACING && spacingKm <= MAX_SPACING))
|
|
311
|
+
fail(`--spacing must be from ${MIN_SPACING} to ${MAX_SPACING} km (our own limits; got ${args.spacing}).`);
|
|
312
|
+
let center = null;
|
|
313
|
+
if (args.center !== undefined) {
|
|
314
|
+
const [lat, lng] = String(args.center)
|
|
315
|
+
.split(",")
|
|
316
|
+
.map(x => (x.trim() ? Number(x) : NaN));
|
|
317
|
+
if (!(Math.abs(lat) <= 90 && Math.abs(lng) <= 180))
|
|
318
|
+
fail(`--center must be latitude,longitude, like 53.7976,-1.5453 (got ${args.center}).`);
|
|
319
|
+
center = { lat, lng };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const searches = size * size * keywords.length,
|
|
323
|
+
across = Number(((size - 1) * spacingKm).toFixed(2));
|
|
324
|
+
if (!yes) {
|
|
325
|
+
console.log(
|
|
326
|
+
[
|
|
327
|
+
`geo-grid: dry run, nothing sent. With --yes it would ask Google's Places API (New) at ${new URL(endpoint).host}, ${from}:`,
|
|
328
|
+
center
|
|
329
|
+
? ` 1 check that the place ID ${placeId} is still current (Place Details, the ID only).`
|
|
330
|
+
: ` 1 lookup of where your business is on the map (Place Details for place ID ${placeId}, the location field only).`,
|
|
331
|
+
` ${searches} searches: one at each point of a ${size} × ${size} grid, ${spacingKm} km apart (${across} km across), ${keywords.length === 1 ? "for the keyword" : `for each of ${keywords.length} keywords`} (${keywords.map(w => `"${w}"`).join(", ")}), centred on ${center ? `${center.lat}, ${center.lng}` : "your business"}.`,
|
|
332
|
+
` ${searches + 1} requests in all.`,
|
|
333
|
+
`Each search sends the keyword alone, one point's latitude and longitude, a ${Math.round(spacingKm * 500)} m circle around it that Google favours, and a request for place IDs only. Nothing about your site goes.`,
|
|
334
|
+
`Cost: on ${READ} Google's price list (developers.google.com/maps/billing-and-pricing/pricing) listed searches for place IDs only (Text Search Essentials IDs Only) as free without limit, and ${center ? "the place ID check (Place Details Essentials IDs Only) as free without limit too" : "the location lookup (Place Details Essentials) at 10,000 free a month, then $5.00 per 1,000"}. Google still requires billing to be turned on in the key's project.`,
|
|
335
|
+
`Check the place ID is yours: ${mapsLink(placeId)}`,
|
|
336
|
+
"If your Google billing address is in the European Economic Area (EEA), Google's EEA terms apply. Their list of allowed uses for Places API results doesn't include rank tracking, though place IDs are left out of that limit. Whether to run this is your decision (cloud.google.com/terms/maps-platform/eea-places-api-permitted-uses).",
|
|
337
|
+
...(k
|
|
338
|
+
? []
|
|
339
|
+
: [
|
|
340
|
+
"No Google Places key is set yet, so nothing could be sent. To add one: node connect-keys.mjs guide googleplaces",
|
|
341
|
+
]),
|
|
342
|
+
"The keywords and the points go to Google with your key, so re-run with --yes once the owner agrees.",
|
|
343
|
+
].join("\n"),
|
|
344
|
+
);
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
const r = await runGrid({
|
|
348
|
+
placeId,
|
|
349
|
+
keywords,
|
|
350
|
+
center,
|
|
351
|
+
size,
|
|
352
|
+
spacingKm,
|
|
353
|
+
key: needKey(),
|
|
354
|
+
endpoint,
|
|
355
|
+
log: x => console.error("geo-grid: " + x),
|
|
356
|
+
});
|
|
357
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
358
|
+
writeFileSync(out, JSON.stringify(r.result, null, 2));
|
|
359
|
+
for (const w of r.result.keywords)
|
|
360
|
+
console.log(
|
|
361
|
+
`geo-grid: "${w.keyword}": in the top 3 at ${w.top3} of ${w.cells.length} points · top 10 at ${w.top10} · not in the top ${TOP} at ${w.notFound}${w.failed ? ` · errors at ${w.failed}` : ""}`,
|
|
362
|
+
);
|
|
363
|
+
for (const n of r.result.notes) console.log("geo-grid: " + n);
|
|
364
|
+
console.log(`geo-grid: ${LABEL}\ngeo-grid: Results: Google Maps\ngeo-grid: wrote ${out}`);
|
|
365
|
+
return r.stop ? 1 : 0;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (isMain(import.meta.url)) {
|
|
369
|
+
warnProxy();
|
|
370
|
+
await runMain(() => main(process.argv.slice(2)));
|
|
371
|
+
}
|