@@ -15,6 +15,7 @@ import { generateScaffold, writeScaffold } from '../command-helpers/scaffold';
15
15
import { withSpinner } from '../command-helpers/spinner' ;
16
16
import { validateStudioNetwork } from '../command-helpers/studio' ;
17
17
import { getSubgraphBasename , validateSubgraphName } from '../command-helpers/subgraph' ;
18
+ import debugFactory from '../debug' ;
18
19
import Protocol , { ProtocolName } from '../protocols' ;
19
20
import EthereumABI from '../protocols/ethereum/abi' ;
20
21
import { abiEvents } from '../scaffold/schema' ;
@@ -26,6 +27,8 @@ const availableNetworks = Protocol.availableNetworks();
26
27
27
28
const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum-gravatar' ;
28
29
30
+ const initDebugger = debugFactory ( 'graph-cli:commands:init' ) ;
31
+
29
32
export default class InitCommand extends Command {
30
33
static description = 'Creates a new subgraph with basic scaffolding.' ;
31
34
@@ -115,24 +118,27 @@ export default class InitCommand extends Command {
115
118
async run ( ) {
116
119
const {
117
120
args : { subgraphName, directory } ,
118
- flags : {
119
- protocol,
120
- product,
121
- studio,
122
- node : nodeFlag ,
123
- 'allow-simple-name' : allowSimpleNameFlag ,
124
- 'from-contract' : fromContract ,
125
- 'contract-name' : contractName ,
126
- 'from-example' : fromExample ,
127
- 'index-events' : indexEvents ,
128
- 'skip-install' : skipInstall ,
129
- network,
130
- abi : abiPath ,
131
- 'start-block' : startBlock ,
132
- spkg : spkgPath ,
133
- } ,
121
+ flags,
134
122
} = await this . parse ( InitCommand ) ;
135
123
124
+ const {
125
+ protocol,
126
+ product,
127
+ studio,
128
+ node : nodeFlag ,
129
+ 'allow-simple-name' : allowSimpleNameFlag ,
130
+ 'from-contract' : fromContract ,
131
+ 'contract-name' : contractName ,
132
+ 'from-example' : fromExample ,
133
+ 'index-events' : indexEvents ,
134
+ 'skip-install' : skipInstall ,
135
+ network,
136
+ abi : abiPath ,
137
+ 'start-block' : startBlock ,
138
+ spkg : spkgPath ,
139
+ } = flags ;
140
+
141
+ initDebugger ( 'Flags: %O' , flags ) ;
136
142
let { node, allowSimpleName } = chooseNodeUrl ( {
137
143
product,
138
144
// if we are loading example, we want to ensure we are using studio
@@ -480,10 +486,19 @@ async function processInitForm(
480
486
message : 'Protocol' ,
481
487
choices : protocolChoices ,
482
488
skip : protocolChoices . includes ( String ( initProtocol ) as ProtocolName ) ,
489
+ result : value => {
490
+ if ( initProtocol ) {
491
+ initDebugger . extend ( 'processInitForm' ) ( 'initProtocol: %O' , initProtocol ) ;
492
+ return initProtocol ;
493
+ }
494
+ initDebugger . extend ( 'processInitForm' ) ( 'protocol: %O' , value ) ;
495
+ return value ;
496
+ } ,
483
497
} ) ;
484
498
485
499
const protocolInstance = new Protocol ( protocol ) ;
486
500
const isSubstreams = protocol === 'substreams' ;
501
+ initDebugger . extend ( 'processInitForm' ) ( 'isSubstreams: %O' , isSubstreams ) ;
487
502
488
503
const { product } = await prompt . ask < {
489
504
product : 'subgraph-studio' | 'hosted-service' ;
@@ -563,9 +578,13 @@ async function processInitForm(
563
578
choices : availableNetworks
564
579
. get ( protocol as ProtocolName ) // Get networks related to the chosen protocol.
565
580
?. toArray ( ) || [ 'mainnet' ] ,
566
- skip : initFromExample !== undefined ,
581
+ skip : initNetwork !== undefined ,
567
582
result : value => {
568
- if ( initNetwork ) return initNetwork ;
583
+ if ( initNetwork ) {
584
+ initDebugger . extend ( 'processInitForm' ) ( 'initNetwork: %O' , initNetwork ) ;
585
+ return initNetwork ;
586
+ }
587
+ initDebugger . extend ( 'processInitForm' ) ( 'network: %O' , value ) ;
569
588
return value ;
570
589
} ,
571
590
} ,
0 commit comments