@gscdump/cli 0.8.0 → 0.8.2

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/README.md CHANGED
@@ -40,22 +40,54 @@ gscdump mcp
40
40
 
41
41
  | Command | Description |
42
42
  |---|---|
43
- | `init` | Set up GSCDump authentication |
44
- | `auth` | Manage authentication (`status`, `logout`) |
45
- | `config` | Manage CLI configuration (`show`, `set`, `unset`, `path`) |
46
- | `sites` | List available GSC sites |
47
- | `sitemaps` | List/manage sitemaps for a site |
48
- | `inspect` | Inspect a URL's indexing status |
49
- | `sync` | Sync GSC data to the local Parquet store |
50
- | `query` | Run a search analytics query (local store by default; `--live` hits GSC API) |
51
- | `dump` | Export live Parquet files from the store to a directory |
43
+ | `init` | Full setup (OAuth + dataDir; offers to write a `.env` for portability) |
44
+ | `auth` | Manage authentication (`status`, `login`, `logout`, `refresh`) |
45
+ | `config` | Manage CLI configuration (`show`, `set`, `unset`, `path`, `validate`) |
46
+ | `doctor` | Health checks: auth, scopes, dataDir writability, API reachability |
47
+ | `sites [--owner-only] [--with-sitemaps]` | List available GSC sites |
48
+ | `sites add <url>` / `sites delete <url> [--yes]` | Register / remove a property in Search Console (add registers in unverified state) |
49
+ | `sites verify-token <url> [--method]` / `sites verify <url> [--method]` | Get a verification token, then trigger ownership verification (META/FILE/DNS_TXT/DNS_CNAME/ANALYTICS/TAG_MANAGER) |
50
+ | `sitemaps` | Sitemap CRUD (`list [--pending] [--errored]`, `get`, `submit`, `delete`) |
51
+ | `inspect <url>` / `inspect batch [--concurrency]` | URL inspection (single URL or batch from file/stdin); renders index status, rich results, AMP, mobile usability |
52
+ | `indexing` | Notify Google about URL changes (`submit`, `remove`, `status`, `batch [--concurrency] [--yes]`); supports `--retries` |
53
+ | `sync` | Sync GSC data to the local Parquet store; `--retry-failed`, `--dry-run` |
54
+ | `query` | Run a search analytics query (local store by default; `--live` hits GSC API). Filters: `--query`, `--page`, `--country`, `--device`, `--search-appearance`, `--type`, `--data-state`, `--aggregation-type`. `--explain` previews the request body; `--output -` writes to stdout. |
55
+ | `dump` | Export from the store to a directory (`--format parquet\|json\|ndjson\|csv`, `--tables`, `--all-sites`) |
52
56
  | `analyze <tool>` | Run an SEO analyzer against the store (`--live` for row-based against fresh API) |
57
+ | `entities` | Snapshot URL inspections / sitemaps / indexing metadata into the local entity store |
53
58
  | `store stats` | Show row/byte counts per table and on-disk footprint |
54
- | `store compact` | Roll daily partitions older than N days into monthly files |
55
- | `store gc` | Delete orphaned objects past the grace window |
56
- | `store export` | Export raw Parquet files |
59
+ | `store compact` | Roll daily partitions older than N days into monthly files (`--dry-run`) |
60
+ | `store gc` | Delete orphaned objects past the grace window (`--dry-run`) |
61
+ | `store export` | Export the live store to a single `.duckdb` file |
62
+ | `store rollups rebuild` | Rebuild post-sync rollup tables |
57
63
  | `mcp` | Start the MCP server for AI assistants |
58
64
 
65
+ ### Filter expressions
66
+
67
+ `query` accepts prefix-encoded filter expressions for `--query`, `--page`, `--country`, `--device`, `--search-appearance`:
68
+
69
+ | Prefix | Operator |
70
+ |---|---|
71
+ | (bare) | equals |
72
+ | `~foo` | contains |
73
+ | `!~foo` | not contains |
74
+ | `re:foo` | regex |
75
+ | `!re:foo` | not regex |
76
+ | `!foo` | not equals |
77
+
78
+ ```bash
79
+ # pages under /blog/ with brand mentions in the query
80
+ gscdump query --live --site sc-domain:example.com \
81
+ --page '~/blog/' --query '~brand' --dimensions page,query
82
+ ```
83
+
84
+ ### Global flags
85
+
86
+ - `--no-color` / `NO_COLOR` env: strip ANSI from stdout (stderr keeps colour for interactive use).
87
+ - `--config-dir <path>` / `GSCDUMP_CONFIG_DIR`: override `~/.config/gscdump`.
88
+ - `--profile <name>` / `GSCDUMP_PROFILE`: scope tokens + config to a profile under `~/.config/gscdump/profiles/<name>` (juggle multiple GSC accounts).
89
+ - Most commands accept `--quiet` and `--json` for scripted use; `logger` writes to stderr so `--json` output is safe to pipe.
90
+
59
91
  ## Analyzers
60
92
 
61
93
  `gscdump analyze <tool>` dispatches to `@gscdump/analysis`. 21 tools available:
@@ -119,14 +151,49 @@ Then ask questions like:
119
151
 
120
152
  ## Auth
121
153
 
122
- `gscdump init` walks you through OAuth2 with Google. Credentials are stored locally under `~/.config/gscdump/` (XDG) or equivalent.
154
+ `gscdump init` walks you through full setup (OAuth + data dir). Credentials are stored locally under `~/.config/gscdump/` (XDG) or equivalent. Use `gscdump auth login` if you only want to refresh OAuth tokens without touching config.
123
155
 
124
156
  For manual setup:
125
157
 
126
158
  1. Create a Google Cloud project.
127
159
  2. Enable **Search Console API** and **Web Search Indexing API**.
128
160
  3. Create OAuth2 credentials (Desktop app).
129
- 4. Run `gscdump init`.
161
+ 4. Run `gscdump init` (or `gscdump auth login`).
162
+
163
+ ### BYOK (Bring Your Own Key)
164
+
165
+ Skip `init` entirely by setting env vars. Either path works (`GSC_*` preferred, `GOOGLE_*` accepted):
166
+
167
+ ```bash
168
+ # Option A: raw bearer token (e.g., from gcloud or another OAuth flow)
169
+ export GSC_ACCESS_TOKEN=ya29...
170
+
171
+ # Option B: refresh-token flow (no google-auth-library dep used)
172
+ export GSC_CLIENT_ID=...
173
+ export GSC_CLIENT_SECRET=...
174
+ export GSC_REFRESH_TOKEN=...
175
+ ```
176
+
177
+ When BYOK is detected, `gscdump auth status` reports `byok` as the source and `gscdump auth login` is a no-op.
178
+
179
+ ### Service account
180
+
181
+ For CI / headless usage, point `gscdump` at a service-account JSON key. The service account must be granted access to each property in Search Console (Settings → Users and permissions).
182
+
183
+ ```bash
184
+ gscdump auth login --service-account ./gsc-sa.json # smoke-test the key
185
+ export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ./gsc-sa.json)
186
+ gscdump sites
187
+ ```
188
+
189
+ ### Headless OAuth
190
+
191
+ When the loopback flow can't open a browser (servers, containers, WSL2 without forwarding), use the device-code flow:
192
+
193
+ ```bash
194
+ gscdump auth login --no-browser
195
+ # → opens a verification URL on any device; type the displayed user code
196
+ ```
130
197
 
131
198
  ## Related
132
199
 
@@ -0,0 +1,155 @@
1
+ # Licenses of Bundled Dependencies
2
+
3
+ The published artifact additionally contains code with the following licenses:
4
+ MIT
5
+
6
+ # Bundled Dependencies
7
+
8
+ ## destr, ofetch, ufo
9
+
10
+ License: MIT
11
+ Repositories: https://github.com/unjs/destr, https://github.com/unjs/ofetch, https://github.com/unjs/ufo
12
+
13
+ > MIT License
14
+ >
15
+ > Copyright (c) Pooya Parsa <pooya@pi0.io>
16
+ >
17
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ > of this software and associated documentation files (the "Software"), to deal
19
+ > in the Software without restriction, including without limitation the rights
20
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ > copies of the Software, and to permit persons to whom the Software is
22
+ > furnished to do so, subject to the following conditions:
23
+ >
24
+ > The above copyright notice and this permission notice shall be included in all
25
+ > copies or substantial portions of the Software.
26
+ >
27
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ > SOFTWARE.
34
+
35
+ ---------------------------------------
36
+
37
+ ## node-fetch-native
38
+
39
+ License: MIT
40
+ Repository: https://github.com/unjs/node-fetch-native
41
+
42
+ > MIT License
43
+ >
44
+ > Copyright (c) Pooya Parsa <pooya@pi0.io>
45
+ >
46
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
47
+ > of this software and associated documentation files (the "Software"), to deal
48
+ > in the Software without restriction, including without limitation the rights
49
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
50
+ > copies of the Software, and to permit persons to whom the Software is
51
+ > furnished to do so, subject to the following conditions:
52
+ >
53
+ > The above copyright notice and this permission notice shall be included in all
54
+ > copies or substantial portions of the Software.
55
+ >
56
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
59
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
62
+ > SOFTWARE.
63
+ >
64
+ > ---
65
+ >
66
+ > https://github.com/node-fetch/node-fetch
67
+ >
68
+ > The MIT License (MIT)
69
+ >
70
+ > Copyright (c) 2016 - 2020 Node Fetch Team
71
+ >
72
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
73
+ >
74
+ > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
75
+ >
76
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77
+ >
78
+ > ---
79
+ >
80
+ > https://github.com/mysticatea/abort-controller
81
+ >
82
+ > MIT License
83
+ >
84
+ > Copyright (c) 2017 Toru Nagashima
85
+ >
86
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ > of this software and associated documentation files (the "Software"), to deal
88
+ > in the Software without restriction, including without limitation the rights
89
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
90
+ > copies of the Software, and to permit persons to whom the Software is
91
+ > furnished to do so, subject to the following conditions:
92
+ >
93
+ > The above copyright notice and this permission notice shall be included in all
94
+ > copies or substantial portions of the Software.
95
+ >
96
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
101
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
102
+ > SOFTWARE.
103
+ >
104
+ > ---
105
+ >
106
+ > https://github.com/TooTallNate/proxy-agents
107
+ >
108
+ > (The MIT License)
109
+ >
110
+ > Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
111
+ >
112
+ > Permission is hereby granted, free of charge, to any person obtaining
113
+ > a copy of this software and associated documentation files (the
114
+ > 'Software'), to deal in the Software without restriction, including
115
+ > without limitation the rights to use, copy, modify, merge, publish,
116
+ > distribute, sublicense, and/or sell copies of the Software, and to
117
+ > permit persons to whom the Software is furnished to do so, subject to
118
+ > the following conditions:
119
+ >
120
+ > The above copyright notice and this permission notice shall be
121
+ > included in all copies or substantial portions of the Software.
122
+ >
123
+ > THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
124
+ > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
125
+ > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
126
+ > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
127
+ > CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
128
+ > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
129
+ > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
130
+ >
131
+ > ---
132
+ >
133
+ > https://github.com/nodejs/undici
134
+ >
135
+ > MIT License
136
+ >
137
+ > Copyright (c) Matteo Collina and Undici contributors
138
+ >
139
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
140
+ > of this software and associated documentation files (the "Software"), to deal
141
+ > in the Software without restriction, including without limitation the rights
142
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
143
+ > copies of the Software, and to permit persons to whom the Software is
144
+ > furnished to do so, subject to the following conditions:
145
+ >
146
+ > The above copyright notice and this permission notice shall be included in all
147
+ > copies or substantial portions of the Software.
148
+ >
149
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
150
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
151
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
152
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
153
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
154
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
155
+ > SOFTWARE.
@@ -0,0 +1,45 @@
1
+ import { t as __exportAll } from "./rolldown-runtime.mjs";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import os from "node:os";
5
+ var config_exports = /* @__PURE__ */ __exportAll({
6
+ defaultDataDir: () => defaultDataDir,
7
+ getConfigDir: () => getConfigDir,
8
+ getConfigPath: () => getConfigPath,
9
+ loadConfig: () => loadConfig,
10
+ resolveDataDir: () => resolveDataDir,
11
+ saveConfig: () => saveConfig,
12
+ setConfigDir: () => setConfigDir
13
+ });
14
+ let configDir = path.join(os.homedir(), ".config", "gscdump");
15
+ function setConfigDir(dir) {
16
+ configDir = dir;
17
+ }
18
+ function getConfigDir() {
19
+ return configDir;
20
+ }
21
+ function defaultDataDir() {
22
+ return path.join(os.homedir(), ".gscdump", "data");
23
+ }
24
+ function resolveDataDir(config) {
25
+ return expandTilde(config.dataDir ?? defaultDataDir());
26
+ }
27
+ function expandTilde(p) {
28
+ if (p === "~") return os.homedir();
29
+ if (p.startsWith("~/")) return path.join(os.homedir(), p.slice(2));
30
+ return p;
31
+ }
32
+ async function loadConfig() {
33
+ return fs.readFile(path.join(configDir, "config.json"), "utf-8").then((data) => JSON.parse(data)).catch(() => ({}));
34
+ }
35
+ async function saveConfig(config) {
36
+ await fs.mkdir(configDir, {
37
+ recursive: true,
38
+ mode: 448
39
+ });
40
+ await fs.writeFile(path.join(configDir, "config.json"), JSON.stringify(config, null, 2), { mode: 384 });
41
+ }
42
+ function getConfigPath() {
43
+ return path.join(configDir, "config.json");
44
+ }
45
+ export { loadConfig as a, setConfigDir as c, getConfigPath as i, defaultDataDir as n, resolveDataDir as o, getConfigDir as r, saveConfig as s, config_exports as t };
@@ -0,0 +1,42 @@
1
+ const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
2
+ const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
3
+ const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
4
+ function jsonParseTransform(key, value) {
5
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
6
+ warnKeyDropped(key);
7
+ return;
8
+ }
9
+ return value;
10
+ }
11
+ function warnKeyDropped(key) {
12
+ console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
13
+ }
14
+ function destr(value, options = {}) {
15
+ if (typeof value !== "string") return value;
16
+ if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
17
+ const _value = value.trim();
18
+ if (_value.length <= 9) switch (_value.toLowerCase()) {
19
+ case "true": return true;
20
+ case "false": return false;
21
+ case "undefined": return;
22
+ case "null": return null;
23
+ case "nan": return NaN;
24
+ case "infinity": return Number.POSITIVE_INFINITY;
25
+ case "-infinity": return Number.NEGATIVE_INFINITY;
26
+ }
27
+ if (!JsonSigRx.test(value)) {
28
+ if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
29
+ return value;
30
+ }
31
+ try {
32
+ if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
33
+ if (options.strict) throw new Error("[destr] Possible prototype pollution");
34
+ return JSON.parse(value, jsonParseTransform);
35
+ }
36
+ return JSON.parse(value);
37
+ } catch (error) {
38
+ if (options.strict) throw error;
39
+ return value;
40
+ }
41
+ }
42
+ export { destr as t };