Skip to content

Commit 71c8405

Browse files
graph auth bug fix (#1859)
fixes #1858
1 parent a6f6f11 commit 71c8405

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

.changeset/unlucky-queens-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphprotocol/graph-cli': patch
3+
---
4+
5+
`graph auth`: fix bug with setting deploy key

packages/cli/src/commands/auth.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { print, prompt } from 'gluegun';
2-
import { Args, Command, Flags, ux } from '@oclif/core';
2+
import { Args, Command, Flags } from '@oclif/core';
33
import { saveDeployKey } from '../command-helpers/auth.js';
44
import { chooseNodeUrl } from '../command-helpers/node.js';
55

@@ -16,6 +16,11 @@ export default class AuthCommand extends Command {
1616
}),
1717
};
1818

19+
private validateStudioDeployKey(value: string | undefined): boolean {
20+
if (!value) return false;
21+
return /^[0-9a-fA-F]{32}$/.test(value);
22+
}
23+
1924
async run() {
2025
const {
2126
args: { 'deploy-key': initialDeployKey },
@@ -25,23 +30,22 @@ export default class AuthCommand extends Command {
2530

2631
const { deployKey } = await prompt.ask<{ deployKey: string }>([
2732
{
28-
type: 'invisible',
33+
type: 'input',
2934
name: 'deployKey',
30-
message: () => 'What is the deploy key?',
31-
initial: initialDeployKey,
35+
message: () => 'What is your Subgraph Studio deploy key?',
3236
required: true,
37+
initial: initialDeployKey,
38+
skip: this.validateStudioDeployKey(initialDeployKey),
3339
validate: value =>
34-
value.length > 200
35-
? ux.error('✖ Deploy key must not exceed 200 characters', { exit: 1 })
36-
: value,
40+
this.validateStudioDeployKey(value) || `Invalid Subgraph Studio deploy key: ${value}`,
3741
},
3842
]);
3943

4044
try {
4145
await saveDeployKey(node!, deployKey);
4246
print.success(`Deploy key set for ${node}`);
4347
} catch (e) {
44-
this.error(e, { exit: 1 });
48+
this.error(`Failed to set deploy key: ${e.message}`, { exit: 1 });
4549
}
4650
}
4751
}

0 commit comments

Comments
 (0)