@graphprotocol/graph-cli
Version:
CLI for building for and deploying to The Graph
40 lines (39 loc) • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const gluegun_1 = require("gluegun");
const core_1 = require("@oclif/core");
const auth_1 = require("../command-helpers/auth");
const node_1 = require("../command-helpers/node");
class AuthCommand extends core_1.Command {
async run() {
let { args: { 'deploy-key': deployKey }, } = await this.parse(AuthCommand);
const { node } = (0, node_1.chooseNodeUrl)({});
// eslint-disable-next-line -- prettier has problems with ||=
deployKey =
deployKey ||
(await core_1.ux.prompt('What is the deploy key?', {
required: true,
type: 'mask',
}));
if (deployKey.length > 200) {
this.error('✖ Deploy key must not exceed 200 characters', { exit: 1 });
}
try {
await (0, auth_1.saveDeployKey)(node, deployKey);
gluegun_1.print.success(`Deploy key set for ${node}`);
}
catch (e) {
this.error(e, { exit: 1 });
}
}
}
AuthCommand.description = 'Sets the deploy key to use when deploying to a Graph node.';
AuthCommand.args = {
'deploy-key': core_1.Args.string(),
};
AuthCommand.flags = {
help: core_1.Flags.help({
char: 'h',
}),
};
exports.default = AuthCommand;