@graphprotocol/graph-cli 0.38.1-alpha-20230207152800-4428ad7 → 0.38.1-alpha-20230208030436-e93ce80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
- ## 0.38.1-alpha-20230207152800-4428ad7
3
+ ## 0.38.1-alpha-20230208030436-e93ce80
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -8,15 +8,17 @@ const path_1 = __importDefault(require("path"));
8
8
  const gluegun_1 = require("gluegun");
9
9
  const yaml_1 = __importDefault(require("yaml"));
10
10
  const spinner_1 = require("./spinner");
11
- const updateSubgraphNetwork = async (toolbox, manifest, network, networksFile, identifierName) => await (0, spinner_1.withSpinner)(`Update sources network`, `Failed to update sources network`, `Warnings while updating sources network`, async (spinner) => {
11
+ const updateSubgraphNetwork = async (manifest, network, networksFile, identifierName) =>
12
+ // TODO: use useSpinner
13
+ await (0, spinner_1.withSpinner)(`Update sources network`, `Failed to update sources network`, `Warnings while updating sources network`, async (spinner) => {
12
14
  (0, spinner_1.step)(spinner, `Reading networks config`);
13
- const allNetworks = await toolbox.filesystem.read(networksFile, 'json');
15
+ const allNetworks = await gluegun_1.filesystem.read(networksFile, 'json');
14
16
  const networkConfig = allNetworks[network];
15
17
  // Exit if the network passed with --network does not exits in networks.json
16
18
  if (!networkConfig) {
17
19
  throw new Error(`Network '${network}' was not found in '${networksFile}'`);
18
20
  }
19
- await toolbox.patching.update(manifest, content => {
21
+ await gluegun_1.patching.update(manifest, content => {
20
22
  const subgraph = yaml_1.default.parse(content);
21
23
  const networkSources = Object.keys(networkConfig);
22
24
  const subgraphSources = subgraph.dataSources.map((value) => value.name);
@@ -54,8 +56,10 @@ const updateSubgraphNetwork = async (toolbox, manifest, network, networksFile, i
54
56
  });
55
57
  });
56
58
  exports.updateSubgraphNetwork = updateSubgraphNetwork;
57
- const initNetworksConfig = async (toolbox, directory, identifierName) => await (0, spinner_1.withSpinner)(`Initialize networks config`, `Failed to initialize networks config`, `Warnings while initializing networks config`, async () => {
58
- const subgraphStr = toolbox.filesystem.read(path_1.default.join(directory, 'subgraph.yaml'));
59
+ const initNetworksConfig = async (directory, identifierName) =>
60
+ // TODO: use useSpinner
61
+ await (0, spinner_1.withSpinner)(`Initialize networks config`, `Failed to initialize networks config`, `Warnings while initializing networks config`, async () => {
62
+ const subgraphStr = gluegun_1.filesystem.read(path_1.default.join(directory, 'subgraph.yaml'));
59
63
  const subgraph = yaml_1.default.parse(subgraphStr);
60
64
  const networks = subgraph.dataSources.reduce((acc, source) => Object.assign(acc, {
61
65
  [source.network]: {
@@ -65,7 +69,7 @@ const initNetworksConfig = async (toolbox, directory, identifierName) => await (
65
69
  },
66
70
  },
67
71
  }), {});
68
- toolbox.filesystem.write(`${directory}/networks.json`, networks);
72
+ gluegun_1.filesystem.write(`${directory}/networks.json`, networks);
69
73
  return true;
70
74
  });
71
75
  exports.initNetworksConfig = initNetworksConfig;
@@ -33,7 +33,7 @@ const network_1 = require("./network");
33
33
  const SUBGRAPH_PATH_BASE = path_1.default.join(__dirname, '..', '..', '..', '..', 'examples', 'example-subgraph');
34
34
  describe('initNetworksConfig', () => {
35
35
  beforeAll(async () => {
36
- await (0, network_1.initNetworksConfig)(toolbox, SUBGRAPH_PATH_BASE, 'address');
36
+ await (0, network_1.initNetworksConfig)(SUBGRAPH_PATH_BASE, 'address');
37
37
  });
38
38
  afterAll(async () => {
39
39
  toolbox.filesystem.remove(`${SUBGRAPH_PATH_BASE}/networks.json`);
@@ -75,7 +75,7 @@ describe('updateSubgraphNetwork', () => {
75
75
  let address = subgraphObj.dataSources[0].source.address;
76
76
  expect(network).toBe('mainnet');
77
77
  expect(address).toBe('0x22843e74c59580b3eaf6c233fa67d8b7c561a835');
78
- await (0, network_1.updateSubgraphNetwork)(toolbox, manifest, 'optimism', networksFie, 'address');
78
+ await (0, network_1.updateSubgraphNetwork)(manifest, 'optimism', networksFie, 'address');
79
79
  subgraph = toolbox.filesystem.read(manifest);
80
80
  subgraphObj = yaml_1.default.parse(subgraph);
81
81
  network = subgraphObj.dataSources[0].network;
@@ -38,9 +38,9 @@ const spinner_1 = require("../command-helpers/spinner");
38
38
  const protocols_1 = __importDefault(require("../protocols"));
39
39
  const abi_2 = __importDefault(require("../protocols/ethereum/abi"));
40
40
  const subgraph_1 = __importDefault(require("../subgraph"));
41
- class Add extends core_1.Command {
41
+ class AddCommand extends core_1.Command {
42
42
  async run() {
43
- const { args: { address, subgraphManifest: manifestPath }, flags: { abi, contractName, mergeEntities, networkFile: networksFile }, } = await this.parse(Add);
43
+ const { args: { address, subgraphManifest: manifestPath }, flags: { abi, contractName, mergeEntities, networkFile: networksFile }, } = await this.parse(AddCommand);
44
44
  const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifestPath);
45
45
  const protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
46
46
  const manifest = await subgraph_1.default.load(manifestPath, { protocol });
@@ -49,7 +49,7 @@ class Add extends core_1.Command {
49
49
  const entities = getEntities(manifest);
50
50
  const contractNames = getContractNames(manifest);
51
51
  if (contractNames.includes(contractName)) {
52
- throw new errors_1.CLIError(`Datasource or template with name ${contractName} already exists, please choose a different name.`, { exit: 1 });
52
+ this.error(`Datasource or template with name ${contractName} already exists, please choose a different name.`, { exit: 1 });
53
53
  }
54
54
  let ethabi = null;
55
55
  if (abi) {
@@ -87,14 +87,16 @@ class Add extends core_1.Command {
87
87
  const yarn = gluegun_1.system.which('yarn');
88
88
  const npm = gluegun_1.system.which('npm');
89
89
  if (!yarn && !npm) {
90
- throw new errors_1.CLIError('Neither Yarn nor NPM were found on your system. Please install one of them.', { exit: 1 });
90
+ this.error('Neither Yarn nor NPM were found on your system. Please install one of them.', {
91
+ exit: 1,
92
+ });
91
93
  }
92
94
  await (0, spinner_1.useSpinner)('Running codegen', 'Failed to run codegen', 'Warning during codegen', () => gluegun_1.system.run(yarn ? 'yarn codegen' : 'npm run codegen'));
93
95
  }
94
96
  }
95
- exports.default = Add;
96
- Add.description = 'Adds a new datasource to a subgraph.';
97
- Add.args = {
97
+ exports.default = AddCommand;
98
+ AddCommand.description = 'Adds a new datasource to a subgraph.';
99
+ AddCommand.args = {
98
100
  address: core_1.Args.string({
99
101
  description: 'The contract address',
100
102
  required: true,
@@ -103,7 +105,7 @@ Add.args = {
103
105
  default: 'subgraph.yaml',
104
106
  }),
105
107
  };
106
- Add.flags = {
108
+ AddCommand.flags = {
107
109
  abi: core_1.Flags.string({
108
110
  summary: 'Path to the contract ABI.',
109
111
  default: '*Download from Etherscan*',
@@ -116,7 +118,7 @@ Add.flags = {
116
118
  summary: 'Whether to merge entities with the same name.',
117
119
  default: false,
118
120
  }),
119
- // TODO: should be networksFile (with an "s")
121
+ // TODO: should be networksFile (with an "s"), or?
120
122
  networkFile: core_1.Flags.string({
121
123
  summary: 'Networks config file path.',
122
124
  default: 'networks.json',
@@ -144,8 +146,7 @@ const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntiti
144
146
  if (dataRow.get('type') === 'event') {
145
147
  if (entities.includes(dataRow.get('name'))) {
146
148
  if (entities.includes(`${contractName}${dataRow.get('name')}`)) {
147
- throw new errors_1.CLIError(`Contract name ('${contractName}')
148
- + event name ('${dataRow.get('name')}') entity already exists.`, { exit: 1 });
149
+ throw new errors_1.CLIError(`Contract name ('${contractName}') + event name ('${dataRow.get('name')}') entity already exists.`, { exit: 1 });
149
150
  }
150
151
  if (mergeEntities) {
151
152
  collisionEntities.push(dataRow.get('name'));
@@ -26,88 +26,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const chalk_1 = __importDefault(require("chalk"));
29
+ const core_1 = require("@oclif/core");
30
+ const gluegun_1 = require("gluegun");
30
31
  const compiler_1 = require("../command-helpers/compiler");
31
32
  const DataSourcesExtractor = __importStar(require("../command-helpers/data-sources"));
32
- const gluegun_1 = require("../command-helpers/gluegun");
33
33
  const network_1 = require("../command-helpers/network");
34
34
  const debug_1 = __importDefault(require("../debug"));
35
35
  const protocols_1 = __importDefault(require("../protocols"));
36
36
  const buildDebug = (0, debug_1.default)('graph-cli:build');
37
- const HELP = `
38
- ${chalk_1.default.bold('graph build')} [options] ${chalk_1.default.bold('[<subgraph-manifest>]')}
39
-
40
- Options:
41
-
42
- -h, --help Show usage information
43
- -i, --ipfs <node> Upload build results to an IPFS node
44
- -o, --output-dir <path> Output directory for build results (default: build/)
45
- -t, --output-format <format> Output format for mappings (wasm, wast) (default: wasm)
46
- --skip-migrations Skip subgraph migrations (default: false)
47
- -w, --watch Regenerate types when subgraph files change (default: false)
48
- --network <name> Network configuration to use from the networks config file
49
- --network-file <path> Networks config file path (default: "./networks.json")
50
- `;
51
- exports.default = {
52
- description: 'Builds a subgraph and (optionally) uploads it to IPFS',
53
- run: async (toolbox) => {
54
- // Obtain tools
55
- const { filesystem, print } = toolbox;
56
- // Parse CLI parameters
57
- let { i, h, help, ipfs, o, outputDir, outputFormat, skipMigrations, t, w, watch, network, networkFile, } = toolbox.parameters.options;
58
- // Support both short and long option variants
59
- help || (help = h);
60
- ipfs || (ipfs = i);
61
- outputDir || (outputDir = o);
62
- outputFormat || (outputFormat = t);
63
- watch || (watch = w);
64
- let manifest;
65
- try {
66
- [manifest] = (0, gluegun_1.fixParameters)(toolbox.parameters, {
67
- h,
68
- help,
69
- w,
70
- watch,
71
- });
72
- }
73
- catch (e) {
74
- print.error(e.message);
75
- process.exitCode = 1;
76
- return;
77
- }
78
- // Fall back to default values for options / parameters
79
- outputFormat = outputFormat && ['wasm', 'wast'].includes(outputFormat) ? outputFormat : 'wasm';
80
- outputDir = outputDir && outputDir !== '' ? outputDir : filesystem.path('build');
81
- manifest =
82
- manifest !== undefined && manifest !== '' ? manifest : filesystem.resolve('subgraph.yaml');
83
- networkFile =
84
- networkFile !== undefined && networkFile !== ''
85
- ? networkFile
86
- : filesystem.resolve('networks.json');
87
- // Show help text if requested
88
- if (help) {
89
- print.info(HELP);
90
- return;
91
- }
37
+ class BuildCommand extends core_1.Command {
38
+ async run() {
39
+ const { args: { 'subgraph-manifest': manifest }, flags: { ipfs, 'output-dir': outputDir, 'output-format': outputFormat, 'skip-migrations': skipMigrations, watch, network, 'network-file': networkFile, }, } = await this.parse(BuildCommand);
92
40
  let protocol;
93
41
  try {
94
42
  const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest);
95
43
  protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
96
44
  }
97
45
  catch (e) {
98
- print.error(e.message);
99
- process.exitCode = 1;
100
- return;
46
+ this.error(e, { exit: 1 });
101
47
  }
102
48
  buildDebug('Detected protocol "%s" (%o)', protocol.name, protocol);
103
- if (network && filesystem.exists(networkFile) !== 'file') {
104
- print.error(`Network file '${networkFile}' does not exists or is not a file!`);
105
- process.exitCode = 1;
106
- return;
49
+ if (network && gluegun_1.filesystem.exists(networkFile) !== 'file') {
50
+ this.error(`Network file '${networkFile}' does not exists or is not a file!`, { exit: 1 });
107
51
  }
108
52
  if (network) {
109
53
  const identifierName = protocol.getContract().identifierName();
110
- await (0, network_1.updateSubgraphNetwork)(toolbox, manifest, network, networkFile, identifierName);
54
+ await (0, network_1.updateSubgraphNetwork)(manifest, network, networkFile, identifierName);
111
55
  }
112
56
  const compiler = (0, compiler_1.createCompiler)(manifest, {
113
57
  ipfs,
@@ -118,7 +62,7 @@ exports.default = {
118
62
  });
119
63
  // Exit with an error code if the compiler couldn't be created
120
64
  if (!compiler) {
121
- process.exitCode = 1;
65
+ this.exit(1);
122
66
  return;
123
67
  }
124
68
  // Watch subgraph files for changes or additions, trigger
@@ -129,8 +73,47 @@ exports.default = {
129
73
  else {
130
74
  const result = await compiler.compile();
131
75
  if (result === false) {
132
- process.exitCode = 1;
76
+ this.exit(1);
133
77
  }
134
78
  }
135
- },
79
+ }
80
+ }
81
+ exports.default = BuildCommand;
82
+ BuildCommand.description = 'Builds a subgraph and (optionally) uploads it to IPFS.';
83
+ BuildCommand.args = {
84
+ 'subgraph-manifest': core_1.Args.string({
85
+ default: 'subgraph.yaml',
86
+ }),
87
+ };
88
+ BuildCommand.flags = {
89
+ ipfs: core_1.Flags.string({
90
+ summary: 'Upload build results to an IPFS node.',
91
+ char: 'i',
92
+ }),
93
+ 'output-dir': core_1.Flags.string({
94
+ summary: 'Output directory for build results.',
95
+ char: 'o',
96
+ default: 'build/',
97
+ }),
98
+ 'output-format': core_1.Flags.string({
99
+ summary: 'Output format for mappings.',
100
+ char: 't',
101
+ options: ['wasm', 'wast'],
102
+ default: 'wasm',
103
+ }),
104
+ 'skip-migrations': core_1.Flags.boolean({
105
+ summary: 'Skip subgraph migrations.',
106
+ }),
107
+ watch: core_1.Flags.boolean({
108
+ summary: 'Regenerate types when subgraph files change.',
109
+ char: 'w',
110
+ }),
111
+ network: core_1.Flags.string({
112
+ summary: 'Network configuration to use from the networks config file.',
113
+ }),
114
+ // TODO: should be networksFile (with an "s"), or?
115
+ 'network-file': core_1.Flags.string({
116
+ summary: 'Networks config file path.',
117
+ default: 'networks.json',
118
+ }),
136
119
  };
@@ -209,7 +209,7 @@ exports.default = {
209
209
  }
210
210
  if (network) {
211
211
  const identifierName = protocol.getContract().identifierName();
212
- await (0, network_1.updateSubgraphNetwork)(toolbox, manifest, network, networkFile, identifierName);
212
+ await (0, network_1.updateSubgraphNetwork)(manifest, network, networkFile, identifierName);
213
213
  }
214
214
  const isStudio = node.match(/studio/);
215
215
  const isHostedService = node.match(/thegraph.com/) && !isStudio;
@@ -26,9 +26,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.comm = void 0;
29
30
  const fs_1 = __importDefault(require("fs"));
30
31
  const os_1 = __importDefault(require("os"));
31
32
  const path_1 = __importDefault(require("path"));
33
+ const core_1 = require("@oclif/core");
32
34
  const chalk_1 = __importDefault(require("chalk"));
33
35
  const abi_1 = require("../command-helpers/abi");
34
36
  const DataSourcesExtractor = __importStar(require("../command-helpers/data-sources"));
@@ -48,6 +50,80 @@ const protocolChoices = Array.from(protocols_1.default.availableProtocols().keys
48
50
  const availableNetworks = protocols_1.default.availableNetworks();
49
51
  const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum/gravatar';
50
52
  const initDebug = (0, debug_1.default)('graph-cli:init');
53
+ class InitCommand extends core_1.Command {
54
+ async run() {
55
+ const { flags } = await this.parse(InitCommand);
56
+ console.log(flags);
57
+ }
58
+ }
59
+ exports.default = InitCommand;
60
+ InitCommand.args = {
61
+ subgraphName: core_1.Args.string({
62
+ required: true,
63
+ }),
64
+ directory: core_1.Args.string({
65
+ required: true,
66
+ }),
67
+ };
68
+ InitCommand.flags = {
69
+ protocol: core_1.Flags.string({
70
+ required: true,
71
+ options: protocolChoices,
72
+ }),
73
+ product: core_1.Flags.string({
74
+ summary: 'Selects the product for which to initialize.',
75
+ required: true,
76
+ options: ['subgraph-studio', 'hosted-service'],
77
+ }),
78
+ studio: core_1.Flags.boolean({
79
+ summary: 'Shortcut for "--product subgraph-studio".',
80
+ exclusive: ['product'],
81
+ }),
82
+ node: core_1.Flags.string({
83
+ summary: 'Graph node for which to initialize.',
84
+ char: 'g',
85
+ required: true,
86
+ }),
87
+ 'allow-simple-name': core_1.Flags.boolean({
88
+ description: 'Use a subgraph name without a prefix.',
89
+ default: false,
90
+ }),
91
+ 'from-contract': core_1.Flags.string({
92
+ helpGroup: 'Scaffold',
93
+ description: 'Creates a scaffold based on an existing contract.',
94
+ required: true,
95
+ exclusive: ['from-example'],
96
+ }),
97
+ 'from-example': core_1.Flags.string({
98
+ helpGroup: 'Scaffold',
99
+ description: 'Creates a scaffold based on an example subgraph.',
100
+ default: 'Contract',
101
+ exclusive: ['from-contract'],
102
+ }),
103
+ 'contract-name': core_1.Flags.string({
104
+ helpGroup: 'Scaffold from contract',
105
+ description: 'Name of the contract.',
106
+ required: true,
107
+ dependsOn: ['from-contract'],
108
+ }),
109
+ 'index-events': core_1.Flags.boolean({
110
+ helpGroup: 'Scaffold from contract',
111
+ description: 'Index contract events as entities.',
112
+ dependsOn: ['from-contract'],
113
+ }),
114
+ 'start-block': core_1.Flags.integer({
115
+ helpGroup: 'Scaffold from contract',
116
+ description: 'Block number to start indexing from.',
117
+ default: 0,
118
+ dependsOn: ['from-contract'],
119
+ }),
120
+ abi: core_1.Flags.string({
121
+ helpGroup: 'Ethereum',
122
+ }),
123
+ network: core_1.Flags.string({
124
+ helpGroup: 'Ethereum',
125
+ }),
126
+ };
51
127
  const HELP = `
52
128
  ${chalk_1.default.bold('graph init')} [options] [subgraph-name] [directory]
53
129
 
@@ -102,7 +178,8 @@ const processInitForm = async (toolbox, { protocol, product, studio, node, abi,
102
178
  choices: protocolChoices,
103
179
  skip: protocolChoices.includes(protocol),
104
180
  result: (value) => {
105
- protocol || (protocol = value);
181
+ // eslint-disable-next-line -- prettier has problems with ||=
182
+ protocol = protocol || value;
106
183
  protocolInstance = new protocols_1.default(protocol);
107
184
  return protocol;
108
185
  },
@@ -315,14 +392,15 @@ const loadAbiFromFile = (toolbox, ABI, filename) => {
315
392
  return ABI.load('Contract', filename);
316
393
  }
317
394
  };
318
- exports.default = {
395
+ exports.comm = {
319
396
  description: 'Creates a new subgraph with basic scaffolding',
320
397
  run: async (toolbox) => {
321
398
  // Obtain tools
322
399
  const { print, system } = toolbox;
323
400
  // Read CLI parameters
324
401
  let { protocol, product, studio, node, g, abi, allowSimpleName, fromContract, contractName, fromExample, h, help, indexEvents, network, startBlock, } = toolbox.parameters.options;
325
- node || (node = g);
402
+ // eslint-disable-next-line -- prettier has problems with ||=
403
+ node = node || g;
326
404
  ({ node, allowSimpleName } = (0, node_1.chooseNodeUrl)({
327
405
  product,
328
406
  studio,
@@ -606,7 +684,7 @@ const initSubgraphFromExample = async (toolbox, { fromExample, allowSimpleName,
606
684
  process.exitCode = 1;
607
685
  return;
608
686
  }
609
- const networkConf = await (0, network_1.initNetworksConfig)(toolbox, directory, 'address');
687
+ const networkConf = await (0, network_1.initNetworksConfig)(directory, 'address');
610
688
  if (networkConf !== true) {
611
689
  process.exitCode = 1;
612
690
  return;
@@ -716,7 +794,7 @@ const initSubgraphFromContract = async (toolbox, { protocolInstance, allowSimple
716
794
  }
717
795
  if (protocolInstance.hasContract()) {
718
796
  const identifierName = protocolInstance.getContract().identifierName();
719
- const networkConf = await (0, network_1.initNetworksConfig)(toolbox, directory, identifierName);
797
+ const networkConf = await (0, network_1.initNetworksConfig)(directory, identifierName);
720
798
  if (networkConf !== true) {
721
799
  process.exitCode = 1;
722
800
  return;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.38.1-alpha-20230207152800-4428ad7",
2
+ "version": "0.38.1-alpha-20230208030436-e93ce80",
3
3
  "commands": {
4
4
  "add": {
5
5
  "id": "add",
@@ -62,13 +62,73 @@
62
62
  },
63
63
  "build": {
64
64
  "id": "build",
65
- "description": "Builds a subgraph and (optionally) uploads it to IPFS",
65
+ "description": "Builds a subgraph and (optionally) uploads it to IPFS.",
66
+ "strict": true,
66
67
  "pluginName": "@graphprotocol/graph-cli",
67
68
  "pluginAlias": "@graphprotocol/graph-cli",
68
69
  "pluginType": "core",
69
70
  "aliases": [],
70
- "flags": {},
71
- "args": {}
71
+ "flags": {
72
+ "ipfs": {
73
+ "name": "ipfs",
74
+ "type": "option",
75
+ "char": "i",
76
+ "summary": "Upload build results to an IPFS node.",
77
+ "multiple": false
78
+ },
79
+ "output-dir": {
80
+ "name": "output-dir",
81
+ "type": "option",
82
+ "char": "o",
83
+ "summary": "Output directory for build results.",
84
+ "multiple": false,
85
+ "default": "build/"
86
+ },
87
+ "output-format": {
88
+ "name": "output-format",
89
+ "type": "option",
90
+ "char": "t",
91
+ "summary": "Output format for mappings.",
92
+ "multiple": false,
93
+ "options": [
94
+ "wasm",
95
+ "wast"
96
+ ],
97
+ "default": "wasm"
98
+ },
99
+ "skip-migrations": {
100
+ "name": "skip-migrations",
101
+ "type": "boolean",
102
+ "summary": "Skip subgraph migrations.",
103
+ "allowNo": false
104
+ },
105
+ "watch": {
106
+ "name": "watch",
107
+ "type": "boolean",
108
+ "char": "w",
109
+ "summary": "Regenerate types when subgraph files change.",
110
+ "allowNo": false
111
+ },
112
+ "network": {
113
+ "name": "network",
114
+ "type": "option",
115
+ "summary": "Network configuration to use from the networks config file.",
116
+ "multiple": false
117
+ },
118
+ "network-file": {
119
+ "name": "network-file",
120
+ "type": "option",
121
+ "summary": "Networks config file path.",
122
+ "multiple": false,
123
+ "default": "networks.json"
124
+ }
125
+ },
126
+ "args": {
127
+ "subgraph-manifest": {
128
+ "name": "subgraph-manifest",
129
+ "default": "subgraph.yaml"
130
+ }
131
+ }
72
132
  },
73
133
  "codegen": {
74
134
  "id": "codegen",
@@ -102,13 +162,136 @@
102
162
  },
103
163
  "init": {
104
164
  "id": "init",
105
- "description": "Creates a new subgraph with basic scaffolding",
165
+ "strict": true,
106
166
  "pluginName": "@graphprotocol/graph-cli",
107
167
  "pluginAlias": "@graphprotocol/graph-cli",
108
168
  "pluginType": "core",
109
169
  "aliases": [],
110
- "flags": {},
111
- "args": {}
170
+ "flags": {
171
+ "protocol": {
172
+ "name": "protocol",
173
+ "type": "option",
174
+ "required": true,
175
+ "multiple": false,
176
+ "options": [
177
+ "arweave",
178
+ "ethereum",
179
+ "near",
180
+ "cosmos",
181
+ "substreams"
182
+ ]
183
+ },
184
+ "product": {
185
+ "name": "product",
186
+ "type": "option",
187
+ "summary": "Selects the product for which to initialize.",
188
+ "required": true,
189
+ "multiple": false,
190
+ "options": [
191
+ "subgraph-studio",
192
+ "hosted-service"
193
+ ]
194
+ },
195
+ "studio": {
196
+ "name": "studio",
197
+ "type": "boolean",
198
+ "summary": "Shortcut for \"--product subgraph-studio\".",
199
+ "allowNo": false,
200
+ "exclusive": [
201
+ "product"
202
+ ]
203
+ },
204
+ "node": {
205
+ "name": "node",
206
+ "type": "option",
207
+ "char": "g",
208
+ "summary": "Graph node for which to initialize.",
209
+ "required": true,
210
+ "multiple": false
211
+ },
212
+ "allow-simple-name": {
213
+ "name": "allow-simple-name",
214
+ "type": "boolean",
215
+ "description": "Use a subgraph name without a prefix.",
216
+ "allowNo": false
217
+ },
218
+ "from-contract": {
219
+ "name": "from-contract",
220
+ "type": "option",
221
+ "description": "Creates a scaffold based on an existing contract.",
222
+ "required": true,
223
+ "helpGroup": "Scaffold",
224
+ "multiple": false,
225
+ "exclusive": [
226
+ "from-example"
227
+ ]
228
+ },
229
+ "from-example": {
230
+ "name": "from-example",
231
+ "type": "option",
232
+ "description": "Creates a scaffold based on an example subgraph.",
233
+ "helpGroup": "Scaffold",
234
+ "multiple": false,
235
+ "exclusive": [
236
+ "from-contract"
237
+ ],
238
+ "default": "Contract"
239
+ },
240
+ "contract-name": {
241
+ "name": "contract-name",
242
+ "type": "option",
243
+ "description": "Name of the contract.",
244
+ "required": true,
245
+ "helpGroup": "Scaffold from contract",
246
+ "multiple": false,
247
+ "dependsOn": [
248
+ "from-contract"
249
+ ]
250
+ },
251
+ "index-events": {
252
+ "name": "index-events",
253
+ "type": "boolean",
254
+ "description": "Index contract events as entities.",
255
+ "helpGroup": "Scaffold from contract",
256
+ "allowNo": false,
257
+ "dependsOn": [
258
+ "from-contract"
259
+ ]
260
+ },
261
+ "start-block": {
262
+ "name": "start-block",
263
+ "type": "option",
264
+ "description": "Block number to start indexing from.",
265
+ "helpGroup": "Scaffold from contract",
266
+ "multiple": false,
267
+ "dependsOn": [
268
+ "from-contract"
269
+ ],
270
+ "default": 0
271
+ },
272
+ "abi": {
273
+ "name": "abi",
274
+ "type": "option",
275
+ "helpGroup": "Ethereum",
276
+ "multiple": false
277
+ },
278
+ "network": {
279
+ "name": "network",
280
+ "type": "option",
281
+ "helpGroup": "Ethereum",
282
+ "multiple": false
283
+ }
284
+ },
285
+ "args": {
286
+ "subgraphName": {
287
+ "name": "subgraphName",
288
+ "required": true
289
+ },
290
+ "directory": {
291
+ "name": "directory",
292
+ "required": true
293
+ }
294
+ }
112
295
  },
113
296
  "local": {
114
297
  "id": "local",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.38.1-alpha-20230207152800-4428ad7",
3
+ "version": "0.38.1-alpha-20230208030436-e93ce80",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "license": "(Apache-2.0 OR MIT)",
6
6
  "engines": {