From f474dcfb77b7ff702f01a354d2ed6ffdd8b59527 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 14 Apr 2023 01:24:54 +0200 Subject: [PATCH 1/3] prompt for subgraph name --- packages/cli/src/commands/deploy.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/deploy.ts b/packages/cli/src/commands/deploy.ts index b05cd628f..d14be2f69 100644 --- a/packages/cli/src/commands/deploy.ts +++ b/packages/cli/src/commands/deploy.ts @@ -24,9 +24,7 @@ export default class DeployCommand extends Command { static description = 'Deploys a subgraph to a Graph node.'; static args = { - 'subgraph-name': Args.string({ - required: true, - }), + 'subgraph-name': Args.string({}), 'subgraph-manifest': Args.string({ default: 'subgraph.yaml', }), @@ -95,7 +93,7 @@ export default class DeployCommand extends Command { async run() { const { - args: { 'subgraph-name': subgraphName, 'subgraph-manifest': manifest }, + args: { 'subgraph-name': subgraphNameArg, 'subgraph-manifest': manifest }, flags: { product: productFlag, studio, @@ -114,6 +112,12 @@ export default class DeployCommand extends Command { }, } = await this.parse(DeployCommand); + const subgraphName = + subgraphNameArg || + (await ux.prompt('What is the subgraph name?', { + required: true, + })); + // We are given a node URL, so we prioritize that over the product flag const product = nodeFlag ? productFlag From f620211449e63db8fadd3f8acb2022bade6e27a4 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 14 Apr 2023 01:37:38 +0200 Subject: [PATCH 2/3] select prompt for product --- packages/cli/src/commands/deploy.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/deploy.ts b/packages/cli/src/commands/deploy.ts index d14be2f69..f542dc348 100644 --- a/packages/cli/src/commands/deploy.ts +++ b/packages/cli/src/commands/deploy.ts @@ -1,7 +1,7 @@ import path from 'path'; import { URL } from 'url'; import { Args, Command, Flags, ux } from '@oclif/core'; -import { print } from 'gluegun'; +import { print, prompt } from 'gluegun'; import { identifyDeployKey } from '../command-helpers/auth'; import { createCompiler } from '../command-helpers/compiler'; import * as DataSourcesExtractor from '../command-helpers/data-sources'; @@ -20,6 +20,8 @@ const headersFlag = Flags.custom>({ default: {}, }); +const productOptions = ['subgraph-studio', 'hosted-service']; + export default class DeployCommand extends Command { static description = 'Deploys a subgraph to a Graph node.'; @@ -37,7 +39,7 @@ export default class DeployCommand extends Command { product: Flags.string({ summary: 'Select a product for which to authenticate.', - options: ['subgraph-studio', 'hosted-service'], + options: productOptions, }), studio: Flags.boolean({ summary: 'Shortcut for "--product subgraph-studio".', @@ -124,9 +126,17 @@ export default class DeployCommand extends Command { : studio ? 'subgraph-studio' : productFlag || - (await ux.prompt('Which product to deploy for?', { - required: true, - })); + (await prompt + .ask([ + { + name: 'product', + message: 'Which product to deploy for?', + required: true, + type: 'select', + choices: productOptions, + }, + ]) + .then(({ product }) => product as string)); try { const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest); From 34578ddd1938e44fc0760b7e5c3d1eadc94d4c33 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 14 Apr 2023 01:38:49 +0200 Subject: [PATCH 3/3] changeset --- .changeset/sixty-buckets-laugh.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sixty-buckets-laugh.md diff --git a/.changeset/sixty-buckets-laugh.md b/.changeset/sixty-buckets-laugh.md new file mode 100644 index 000000000..36ef0596b --- /dev/null +++ b/.changeset/sixty-buckets-laugh.md @@ -0,0 +1,5 @@ +--- +'@graphprotocol/graph-cli': minor +--- + +Prompt deploy command for subgraph name and select product