@gscdump/cli 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +29 -25
- package/package.json +6 -7
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { defineCommand, runMain } from "citty";
|
|
|
7
7
|
import { defaultAnalyzerRegistry } from "@gscdump/analysis/registry";
|
|
8
8
|
import fs, { readFile, readdir, rm } from "node:fs/promises";
|
|
9
9
|
import path, { join } from "node:path";
|
|
10
|
-
import { AnalyzerCapabilityError,
|
|
10
|
+
import { AnalyzerCapabilityError, createEngineQuerySource, runAnalyzerFromSource } from "@gscdump/analysis";
|
|
11
11
|
import { createGscApiQuerySource } from "@gscdump/engine-gsc-api";
|
|
12
12
|
import { decodeSiteId, normalizeSiteUrl } from "gscdump/tenant";
|
|
13
13
|
import os from "node:os";
|
|
@@ -18,7 +18,7 @@ import { JWT, OAuth2Client } from "google-auth-library";
|
|
|
18
18
|
import { Buffer } from "node:buffer";
|
|
19
19
|
import fs$1 from "node:fs";
|
|
20
20
|
import { createConsola } from "consola";
|
|
21
|
-
import { createNodeHarness } from "@gscdump/engine
|
|
21
|
+
import { createNodeHarness } from "@gscdump/engine/node";
|
|
22
22
|
import { TABLE_DIMS, transformGscRow } from "@gscdump/engine/ingest";
|
|
23
23
|
import { allTables, inferTable } from "@gscdump/engine/schema";
|
|
24
24
|
import { DuckDBInstance } from "@duckdb/node-api";
|
|
@@ -30,7 +30,7 @@ import { SearchTypes, and, between, contains, country, date, device, eq, gsc, no
|
|
|
30
30
|
import { defaultReportRegistry, dryRunReport, formatReport, runReport } from "@gscdump/analysis/report";
|
|
31
31
|
import { resolveWindow } from "@gscdump/engine/period";
|
|
32
32
|
import { inferLegacyTier } from "@gscdump/engine";
|
|
33
|
-
import { DEFAULT_ROLLUPS, rebuildRollups } from "@gscdump/
|
|
33
|
+
import { DEFAULT_ROLLUPS, rebuildRollups } from "@gscdump/engine/rollups";
|
|
34
34
|
import { filesystemStats } from "@gscdump/engine/filesystem";
|
|
35
35
|
const ENV_LINE_RE$1 = /^([^=]+)=(.*)$/;
|
|
36
36
|
function parseEnvFile(envPath) {
|
|
@@ -74,7 +74,7 @@ function loadEnvFromCwd() {
|
|
|
74
74
|
}
|
|
75
75
|
return applied;
|
|
76
76
|
}
|
|
77
|
-
const VERSION = "0.
|
|
77
|
+
const VERSION = "0.11.0";
|
|
78
78
|
const baseLogger = createConsola({
|
|
79
79
|
stdout: process.stderr,
|
|
80
80
|
stderr: process.stderr
|
|
@@ -689,8 +689,24 @@ async function createCommandContext(opts = {}) {
|
|
|
689
689
|
resolveSite
|
|
690
690
|
};
|
|
691
691
|
}
|
|
692
|
+
var LocalStoreUnsupportedError = class extends Error {
|
|
693
|
+
tool;
|
|
694
|
+
mode;
|
|
695
|
+
constructor(tool, mode) {
|
|
696
|
+
super(`analysis "${tool}" has no implementation for the ${mode} source`);
|
|
697
|
+
this.name = "LocalStoreUnsupportedError";
|
|
698
|
+
this.tool = tool;
|
|
699
|
+
this.mode = mode;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
692
702
|
async function gscErrorHandler(error) {
|
|
693
703
|
console.error();
|
|
704
|
+
if (error instanceof LocalStoreUnsupportedError) {
|
|
705
|
+
console.error(formatErrorForCli(error));
|
|
706
|
+
if (error.mode === "local") console.error("Pass --live to run against the GSC API.");
|
|
707
|
+
console.error();
|
|
708
|
+
process.exit(1);
|
|
709
|
+
}
|
|
694
710
|
console.error(formatErrorForCli(error));
|
|
695
711
|
if (isAuthError(error)) {
|
|
696
712
|
console.error();
|
|
@@ -699,12 +715,6 @@ async function gscErrorHandler(error) {
|
|
|
699
715
|
console.error();
|
|
700
716
|
process.exit(1);
|
|
701
717
|
}
|
|
702
|
-
var LocalStoreUnsupportedError = class extends Error {
|
|
703
|
-
constructor(tool) {
|
|
704
|
-
super(`analysis "${tool}" is not yet implemented against the local Parquet store`);
|
|
705
|
-
this.name = "LocalStoreUnsupportedError";
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
718
|
async function hasLocalData(store, siteUrl) {
|
|
709
719
|
return (await store.engine.listLive({
|
|
710
720
|
userId: store.userId,
|
|
@@ -722,6 +732,12 @@ function pickLocalSite(siteUrls, hint) {
|
|
|
722
732
|
if (exact) return exact;
|
|
723
733
|
return siteUrls.find((s) => s.includes(hint) || hint.includes(s)) ?? null;
|
|
724
734
|
}
|
|
735
|
+
function makeRunAnalysis(source, mode) {
|
|
736
|
+
return (params) => runAnalyzerFromSource(source, params, defaultAnalyzerRegistry).catch((e) => {
|
|
737
|
+
if (e instanceof AnalyzerCapabilityError) throw new LocalStoreUnsupportedError(params.type, mode);
|
|
738
|
+
throw e;
|
|
739
|
+
});
|
|
740
|
+
}
|
|
725
741
|
async function resolveAnalysisSource(args) {
|
|
726
742
|
const isLive = !!args.live;
|
|
727
743
|
const format = args.json ? "json" : args.format ? String(args.format) : "table";
|
|
@@ -748,20 +764,12 @@ async function resolveAnalysisSource(args) {
|
|
|
748
764
|
siteId: store.siteIdFor(siteUrl)
|
|
749
765
|
}
|
|
750
766
|
});
|
|
751
|
-
const runAnalysis = (params) => analyzeFromSource(source, params, defaultAnalyzerRegistry).catch((e) => {
|
|
752
|
-
if (e instanceof AnalyzerCapabilityError) {
|
|
753
|
-
logger.error(`${new LocalStoreUnsupportedError(params.type).message}. Pass --live to run against the GSC API.`);
|
|
754
|
-
process.exit(1);
|
|
755
|
-
}
|
|
756
|
-
logger.error(`Local analysis failed: ${e.message}`);
|
|
757
|
-
process.exit(1);
|
|
758
|
-
});
|
|
759
767
|
return {
|
|
760
768
|
source,
|
|
761
769
|
siteUrl,
|
|
762
770
|
format,
|
|
763
771
|
isLive,
|
|
764
|
-
runAnalysis
|
|
772
|
+
runAnalysis: makeRunAnalysis(source, "local")
|
|
765
773
|
};
|
|
766
774
|
}
|
|
767
775
|
const ctx = await createCommandContext({
|
|
@@ -773,16 +781,12 @@ async function resolveAnalysisSource(args) {
|
|
|
773
781
|
client: ctx.client,
|
|
774
782
|
siteUrl
|
|
775
783
|
});
|
|
776
|
-
const runAnalysis = (params) => analyzeFromSource(source, params, defaultAnalyzerRegistry).catch((e) => {
|
|
777
|
-
if (e instanceof AnalyzerCapabilityError) throw new LocalStoreUnsupportedError(params.type);
|
|
778
|
-
return gscErrorHandler(e);
|
|
779
|
-
});
|
|
780
784
|
return {
|
|
781
785
|
source,
|
|
782
786
|
siteUrl,
|
|
783
787
|
format,
|
|
784
788
|
isLive,
|
|
785
|
-
runAnalysis
|
|
789
|
+
runAnalysis: makeRunAnalysis(source, "live")
|
|
786
790
|
};
|
|
787
791
|
}
|
|
788
792
|
const ANALYSIS_TOOLS = defaultAnalyzerRegistry.listAnalyzerIds();
|
|
@@ -908,7 +912,7 @@ function makeToolCommand(tool) {
|
|
|
908
912
|
format: args.format
|
|
909
913
|
});
|
|
910
914
|
logger.info(`Running ${tool} analysis...`);
|
|
911
|
-
const result = await runAnalysis(buildParams(tool, args));
|
|
915
|
+
const result = await runAnalysis(buildParams(tool, args)).catch(gscErrorHandler);
|
|
912
916
|
if (format === "json") {
|
|
913
917
|
console.log(JSON.stringify(result, null, 2));
|
|
914
918
|
return;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"description": "CLI for Google Search Console - dump, query, and run MCP server",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -41,12 +41,11 @@
|
|
|
41
41
|
"consola": "^3.4.2",
|
|
42
42
|
"google-auth-library": "^10.6.2",
|
|
43
43
|
"open": "^11.0.0",
|
|
44
|
-
"@gscdump/
|
|
45
|
-
"@gscdump/engine
|
|
46
|
-
"@gscdump/
|
|
47
|
-
"@gscdump/
|
|
48
|
-
"gscdump": "0.
|
|
49
|
-
"@gscdump/analysis": "0.9.2"
|
|
44
|
+
"@gscdump/analysis": "0.11.0",
|
|
45
|
+
"@gscdump/engine": "0.11.0",
|
|
46
|
+
"@gscdump/mcp": "0.11.0",
|
|
47
|
+
"@gscdump/engine-gsc-api": "0.11.0",
|
|
48
|
+
"gscdump": "0.11.0"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@duckdb/node-api": "1.5.1-r.2",
|