1
1
const fs = require ( 'fs-extra' )
2
2
const path = require ( 'path' )
3
3
const prettier = require ( 'prettier' )
4
- const pkginfo = require ( 'pkginfo' ) ( module )
5
4
6
- const { getSubgraphBasename } = require ( './command-helpers/subgraph' )
7
5
const { step } = require ( './command-helpers/spinner' )
8
6
const Scaffold = require ( './scaffold' )
9
7
10
- const graphCliVersion = process . env . GRAPH_CLI_TESTS
11
- // JSON.stringify should remove this key, we will install the local
12
- // graph-cli for the tests using `npm link` instead of fetching from npm.
13
- ? undefined
14
- // For scaffolding real subgraphs
15
- : `${ module . exports . version } `
16
-
17
- // package.json
18
-
19
- const generatePackageJson = ( { subgraphName, node } ) =>
20
- prettier . format (
21
- JSON . stringify ( {
22
- name : getSubgraphBasename ( subgraphName ) ,
23
- license : 'UNLICENSED' ,
24
- scripts : {
25
- codegen : 'graph codegen' ,
26
- build : 'graph build' ,
27
- deploy :
28
- `graph deploy ` +
29
- `--node ${ node } ` +
30
- subgraphName ,
31
- 'create-local' : `graph create --node http://localhost:8020/ ${ subgraphName } ` ,
32
- 'remove-local' : `graph remove --node http://localhost:8020/ ${ subgraphName } ` ,
33
- 'deploy-local' :
34
- `graph deploy ` +
35
- `--node http://localhost:8020/ ` +
36
- `--ipfs http://localhost:5001 ` +
37
- subgraphName ,
38
- } ,
39
- dependencies : {
40
- '@graphprotocol/graph-cli' : graphCliVersion ,
41
- '@graphprotocol/graph-ts' : `0.24.1` ,
42
- } ,
43
- } ) ,
44
- { parser : 'json' } ,
45
- )
46
-
47
8
const tsConfig = prettier . format (
48
9
JSON . stringify ( {
49
10
extends : '@graphprotocol/graph-ts/types/tsconfig.base.json' ,
@@ -67,8 +28,6 @@ const generateScaffold = async (
67
28
) => {
68
29
step ( spinner , 'Generate subgraph' )
69
30
70
- let packageJson = generatePackageJson ( { subgraphName, node } )
71
-
72
31
let scaffold = new Scaffold ( {
73
32
protocol : protocolInstance ,
74
33
abi,
@@ -77,8 +36,10 @@ const generateScaffold = async (
77
36
network,
78
37
contractName,
79
38
subgraphName,
39
+ node,
80
40
} )
81
41
42
+ let packageJson = scaffold . generatePackageJson ( )
82
43
let manifest = scaffold . generateManifest ( )
83
44
let schema = scaffold . generateSchema ( )
84
45
let mapping = scaffold . generateMapping ( )
0 commit comments