From 81adaf40b231ffbcd1f8547ab33e8259b78f834a Mon Sep 17 00:00:00 2001 From: YaroShkvorets Date: Wed, 18 Dec 2024 12:28:11 -0500 Subject: [PATCH 1/3] fix `graph auth` --- packages/cli/src/commands/auth.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/commands/auth.ts b/packages/cli/src/commands/auth.ts index 9e04cc63b..a2bfd7685 100644 --- a/packages/cli/src/commands/auth.ts +++ b/packages/cli/src/commands/auth.ts @@ -1,5 +1,5 @@ import { print, prompt } from 'gluegun'; -import { Args, Command, Flags, ux } from '@oclif/core'; +import { Args, Command, Flags } from '@oclif/core'; import { saveDeployKey } from '../command-helpers/auth.js'; import { chooseNodeUrl } from '../command-helpers/node.js'; @@ -16,6 +16,11 @@ export default class AuthCommand extends Command { }), }; + private validateStudioDeployKey(value: string | undefined): boolean { + if (!value) return false; + return /^[0-9a-fA-F]{32}$/.test(value); + } + async run() { const { args: { 'deploy-key': initialDeployKey }, @@ -25,15 +30,13 @@ export default class AuthCommand extends Command { const { deployKey } = await prompt.ask<{ deployKey: string }>([ { - type: 'invisible', + type: 'input', name: 'deployKey', - message: () => 'What is the deploy key?', - initial: initialDeployKey, + message: () => 'What is your Subgraph Studio deploy key?', required: true, + skip: this.validateStudioDeployKey(initialDeployKey), validate: value => - value.length > 200 - ? ux.error('✖ Deploy key must not exceed 200 characters', { exit: 1 }) - : value, + this.validateStudioDeployKey(value) || `Invalid Subgraph Studio deploy key: ${value}`, }, ]); @@ -41,7 +44,7 @@ export default class AuthCommand extends Command { await saveDeployKey(node!, deployKey); print.success(`Deploy key set for ${node}`); } catch (e) { - this.error(e, { exit: 1 }); + this.error(`Failed to set deploy key: ${e.message}`, { exit: 1 }); } } } From 1eb80f4bb4830a1adb0894087328b56e4fc6ee13 Mon Sep 17 00:00:00 2001 From: YaroShkvorets Date: Wed, 18 Dec 2024 12:29:22 -0500 Subject: [PATCH 2/3] changeset --- .changeset/unlucky-queens-divide.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/unlucky-queens-divide.md diff --git a/.changeset/unlucky-queens-divide.md b/.changeset/unlucky-queens-divide.md new file mode 100644 index 000000000..8935b8f06 --- /dev/null +++ b/.changeset/unlucky-queens-divide.md @@ -0,0 +1,5 @@ +--- +'@graphprotocol/graph-cli': patch +--- + +`graph auth`: fix bug with setting deploy key From 595e75e105c977ee9a4a2962ae00aca6fb51eebc Mon Sep 17 00:00:00 2001 From: YaroShkvorets Date: Wed, 18 Dec 2024 12:49:30 -0500 Subject: [PATCH 3/3] set initial deploy key --- packages/cli/src/commands/auth.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli/src/commands/auth.ts b/packages/cli/src/commands/auth.ts index a2bfd7685..a09a830ca 100644 --- a/packages/cli/src/commands/auth.ts +++ b/packages/cli/src/commands/auth.ts @@ -34,6 +34,7 @@ export default class AuthCommand extends Command { name: 'deployKey', message: () => 'What is your Subgraph Studio deploy key?', required: true, + initial: initialDeployKey, skip: this.validateStudioDeployKey(initialDeployKey), validate: value => this.validateStudioDeployKey(value) || `Invalid Subgraph Studio deploy key: ${value}`,