@gscdump/cli 2.1.0 → 2.1.1

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.
@@ -69,7 +69,6 @@ function printPlacementInstructions(method, siteUrl, token) {
69
69
  console.log(` Expected container ID:`);
70
70
  console.log();
71
71
  console.log(` \x1B[2m${token}\x1B[0m`);
72
- break;
73
72
  }
74
73
  console.log();
75
74
  console.log(` \x1B[90mThen run:\x1B[0m gscdump sites verify ${siteUrl} --method ${method}`);
@@ -181,7 +180,8 @@ const deleteCommand = defineCommand({
181
180
  process.exit(0);
182
181
  }
183
182
  }
184
- await deleteSite((await createCommandContext({ needsAuth: true })).client, args.url).catch(gscErrorHandler);
183
+ const ctx = await createCommandContext({ needsAuth: true });
184
+ await deleteSite(ctx.client, args.url).catch(gscErrorHandler);
185
185
  if (args.json) {
186
186
  console.log(JSON.stringify({
187
187
  siteUrl: args.url,
@@ -213,7 +213,8 @@ const verifyTokenCommand = defineCommand({
213
213
  async run({ args }) {
214
214
  applyOutputMode(args);
215
215
  const method = validateMethod(args.url, args.method ?? pickDefaultMethod(args.url));
216
- const result = await getVerificationToken((await createCommandContext({ needsAuth: true })).client, args.url, method).catch(gscErrorHandler);
216
+ const ctx = await createCommandContext({ needsAuth: true });
217
+ const result = await getVerificationToken(ctx.client, args.url, method).catch(gscErrorHandler);
217
218
  if (args.json) {
218
219
  console.log(JSON.stringify({
219
220
  siteUrl: args.url,
@@ -247,7 +248,8 @@ const verifyCommand = defineCommand({
247
248
  async run({ args }) {
248
249
  applyOutputMode(args);
249
250
  const method = validateMethod(args.url, args.method ?? pickDefaultMethod(args.url));
250
- const resource = await verifySite((await createCommandContext({ needsAuth: true })).client, args.url, method).catch(gscErrorHandler);
251
+ const ctx = await createCommandContext({ needsAuth: true });
252
+ const resource = await verifySite(ctx.client, args.url, method).catch(gscErrorHandler);
251
253
  if (args.json) {
252
254
  console.log(JSON.stringify({
253
255
  siteUrl: args.url,
@@ -279,7 +281,8 @@ const verifyGetCommand = defineCommand({
279
281
  },
280
282
  async run({ args }) {
281
283
  applyOutputMode(args);
282
- const resource = await getVerifiedSite((await createCommandContext({ needsAuth: true })).client, args.id).catch(gscErrorHandler);
284
+ const ctx = await createCommandContext({ needsAuth: true });
285
+ const resource = await getVerifiedSite(ctx.client, args.id).catch(gscErrorHandler);
283
286
  if (args.json) {
284
287
  console.log(JSON.stringify(resource, null, 2));
285
288
  return;
@@ -327,7 +330,8 @@ const unverifyCommand = defineCommand({
327
330
  process.exit(0);
328
331
  }
329
332
  }
330
- await unverifySite((await createCommandContext({ needsAuth: true })).client, args.id).catch(gscErrorHandler);
333
+ const ctx = await createCommandContext({ needsAuth: true });
334
+ await unverifySite(ctx.client, args.id).catch(gscErrorHandler);
331
335
  if (args.json) {
332
336
  console.log(JSON.stringify({
333
337
  id: args.id,
@@ -346,7 +350,8 @@ const verifyListCommand = defineCommand({
346
350
  args: { ...OUTPUT_ARGS },
347
351
  async run({ args }) {
348
352
  applyOutputMode(args);
349
- const resources = await listVerifiedSites((await createCommandContext({ needsAuth: true })).client).catch(gscErrorHandler);
353
+ const ctx = await createCommandContext({ needsAuth: true });
354
+ const resources = await listVerifiedSites(ctx.client).catch(gscErrorHandler);
350
355
  if (args.json) {
351
356
  console.log(JSON.stringify(resources, null, 2));
352
357
  return;
@@ -467,6 +472,16 @@ async function runListSites(args) {
467
472
  console.log(` ${site.siteUrl} ${perm}(${site.permissionLevel})\x1B[0m`);
468
473
  }
469
474
  }
475
+ const listCommand = defineCommand({
476
+ meta: {
477
+ name: "list",
478
+ description: "List GSC sites (alias of bare `sites`)"
479
+ },
480
+ args: LIST_ARGS,
481
+ async run({ args }) {
482
+ await runListSites(args);
483
+ }
484
+ });
470
485
  const sitesCommand = defineCommand({
471
486
  meta: {
472
487
  name: "sites",
@@ -474,16 +489,7 @@ const sitesCommand = defineCommand({
474
489
  },
475
490
  args: LIST_ARGS,
476
491
  subCommands: {
477
- "list": defineCommand({
478
- meta: {
479
- name: "list",
480
- description: "List GSC sites (alias of bare `sites`)"
481
- },
482
- args: LIST_ARGS,
483
- async run({ args }) {
484
- await runListSites(args);
485
- }
486
- }),
492
+ "list": listCommand,
487
493
  "add": addCommand,
488
494
  "delete": deleteCommand,
489
495
  "get": getCommand,
@@ -111,8 +111,8 @@ function sumBytes(entries) {
111
111
  }
112
112
  function formatBytes(n) {
113
113
  if (n < 1024) return `${n} B`;
114
- if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
115
- if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;
114
+ if (n < 1048576) return `${(n / 1024).toFixed(1)} KB`;
115
+ if (n < 1073741824) return `${(n / 1024 / 1024).toFixed(1)} MB`;
116
116
  return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`;
117
117
  }
118
118
  export { statsCommand };
@@ -6,7 +6,7 @@ const REQUIRED_SCOPES = [
6
6
  "https://www.googleapis.com/auth/siteverification"
7
7
  ];
8
8
  const FETCH_TIMEOUT_MS = 5e3;
9
- const TIME_SKEW_WARN_MS = 5 * 6e4;
9
+ const TIME_SKEW_WARN_MS = 3e5;
10
10
  function hasGoogleScope(scopes, scope) {
11
11
  const suffix = scope.replace("https://www.googleapis.com/auth/", "");
12
12
  return scopes.includes(scope) || scopes.includes(suffix);
@@ -50,18 +50,20 @@ async function runReportHandlerResult(input, ctx) {
50
50
  };
51
51
  const params = {};
52
52
  if (input.maxFindings != null) params.maxFindings = input.maxFindings;
53
+ const source = createGscApiQuerySource({
54
+ client: ctx.client,
55
+ siteUrl: input.siteUrl
56
+ });
57
+ const reportCtx = {
58
+ site: input.siteUrl,
59
+ window,
60
+ params,
61
+ registryVersion: defaultReportRegistry.version
62
+ };
53
63
  return ok(await runReport(report, {
54
- source: createGscApiQuerySource({
55
- client: ctx.client,
56
- siteUrl: input.siteUrl
57
- }),
64
+ source,
58
65
  analyzers: defaultAnalyzerRegistry,
59
- ctx: {
60
- site: input.siteUrl,
61
- window,
62
- params,
63
- registryVersion: defaultReportRegistry.version
64
- }
66
+ ctx: reportCtx
65
67
  }));
66
68
  }
67
69
  async function runReportHandler(input, ctx) {
@@ -282,7 +282,8 @@ function createGscMcpServer(options) {
282
282
  description: "Register a property in Search Console (unverified). Verify ownership separately.",
283
283
  inputSchema: z.object({ siteUrl: z.string().describe("Property URL (https://example.com/ or sc-domain:example.com)") }).shape
284
284
  }, async ({ siteUrl }) => {
285
- await addSite(await getClient(), siteUrl);
285
+ const client = await getClient();
286
+ await addSite(client, siteUrl);
286
287
  return { content: [{
287
288
  type: "text",
288
289
  text: JSON.stringify({
@@ -296,7 +297,8 @@ function createGscMcpServer(options) {
296
297
  description: "Remove a property from Search Console.",
297
298
  inputSchema: z.object({ siteUrl: z.string().describe("Property URL") }).shape
298
299
  }, async ({ siteUrl }) => {
299
- await deleteSite(await getClient(), siteUrl);
300
+ const client = await getClient();
301
+ await deleteSite(client, siteUrl);
300
302
  return { content: [{
301
303
  type: "text",
302
304
  text: JSON.stringify({
@@ -320,7 +322,8 @@ function createGscMcpServer(options) {
320
322
  method: verificationMethodSchema
321
323
  }).shape
322
324
  }, async ({ siteUrl, method }) => {
323
- const result = await getVerificationToken(await getClient(), siteUrl, method);
325
+ const client = await getClient();
326
+ const result = await getVerificationToken(client, siteUrl, method);
324
327
  return { content: [{
325
328
  type: "text",
326
329
  text: JSON.stringify({
@@ -338,7 +341,8 @@ function createGscMcpServer(options) {
338
341
  method: verificationMethodSchema
339
342
  }).shape
340
343
  }, async ({ siteUrl, method }) => {
341
- const resource = await verifySite(await getClient(), siteUrl, method);
344
+ const client = await getClient();
345
+ const resource = await verifySite(client, siteUrl, method);
342
346
  return { content: [{
343
347
  type: "text",
344
348
  text: JSON.stringify({
@@ -352,7 +356,8 @@ function createGscMcpServer(options) {
352
356
  description: "List verified WebResources from the Site Verification API.",
353
357
  inputSchema: z.object({}).shape
354
358
  }, async () => {
355
- const resources = await listVerifiedSites(await getClient());
359
+ const client = await getClient();
360
+ const resources = await listVerifiedSites(client);
356
361
  return { content: [{
357
362
  type: "text",
358
363
  text: JSON.stringify(resources, null, 2)
@@ -362,7 +367,8 @@ function createGscMcpServer(options) {
362
367
  description: "Fetch a single verified WebResource by id.",
363
368
  inputSchema: z.object({ id: z.string().describe("WebResource id (from list-verified-sites)") }).shape
364
369
  }, async ({ id }) => {
365
- const resource = await getVerifiedSite(await getClient(), id);
370
+ const client = await getClient();
371
+ const resource = await getVerifiedSite(client, id);
366
372
  return { content: [{
367
373
  type: "text",
368
374
  text: JSON.stringify(resource, null, 2)
@@ -372,7 +378,8 @@ function createGscMcpServer(options) {
372
378
  description: "Drop the calling user's verified ownership of a WebResource. Remove the placed token first or Google may re-verify.",
373
379
  inputSchema: z.object({ id: z.string().describe("WebResource id (from list-verified-sites)") }).shape
374
380
  }, async ({ id }) => {
375
- await unverifySite(await getClient(), id);
381
+ const client = await getClient();
382
+ await unverifySite(client, id);
376
383
  return { content: [{
377
384
  type: "text",
378
385
  text: JSON.stringify({
package/dist/package.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var version = "2.1.0";
1
+ var version = "2.1.1";
2
2
  export { version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/cli",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "description": "CLI for Google Search Console - dump, query, and run MCP server",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -51,11 +51,11 @@
51
51
  "open": "^11.0.0",
52
52
  "sitemapd": "^0.2.0",
53
53
  "zod": "^4.4.3",
54
- "@gscdump/analysis": "^2.1.0",
55
- "@gscdump/engine": "^2.1.0",
56
- "@gscdump/engine-gsc-api": "^2.1.0",
57
- "gscdump": "^2.1.0",
58
- "@gscdump/sdk": "^2.1.0"
54
+ "@gscdump/analysis": "^2.1.1",
55
+ "@gscdump/engine-gsc-api": "^2.1.1",
56
+ "@gscdump/engine": "^2.1.1",
57
+ "gscdump": "^2.1.1",
58
+ "@gscdump/sdk": "^2.1.1"
59
59
  },
60
60
  "devDependencies": {
61
61
  "vitest": "^4.1.10"