@graphprotocol/graph-cli 0.38.0 → 0.38.1-alpha-20230207152800-4428ad7
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 +10 -0
- package/dist/bin.js +31 -3
- package/dist/command-helpers/network.js +10 -7
- package/dist/command-helpers/spinner.js +37 -1
- package/dist/commands/add.js +47 -67
- package/dist/commands/init.js +2 -2
- package/dist/index.js +5 -0
- package/oclif.manifest.json +144 -0
- package/package.json +10 -3
- package/dist/cli.js +0 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
+
## 0.38.1-alpha-20230207152800-4428ad7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1055](https://github.com/graphprotocol/graph-tooling/pull/1055)
|
|
8
|
+
[`9932c57`](https://github.com/graphprotocol/graph-tooling/commit/9932c579a0a3f569fc61712ed2e3f2e1538f25ed)
|
|
9
|
+
Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
|
|
10
|
+
- Added dependency [`@oclif/core@2.0.7` ↗︎](https://www.npmjs.com/package/@oclif/core/v/2.0.7) (to
|
|
11
|
+
`dependencies`)
|
|
12
|
+
|
|
3
13
|
## 0.38.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/bin.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
3
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
30
|
+
const oclif = __importStar(require("@oclif/core"));
|
|
31
|
+
const flush_1 = __importDefault(require("@oclif/core/flush"));
|
|
32
|
+
// @ts-expect-error Handle is a pure JS file
|
|
33
|
+
const handle_1 = __importDefault(require("@oclif/core/handle"));
|
|
34
|
+
oclif.run().then(flush_1.default).catch(handle_1.default);
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.updateNetworksFile = exports.initNetworksConfig = exports.updateSubgraphNetwork = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const gluegun_1 = require("gluegun");
|
|
8
9
|
const yaml_1 = __importDefault(require("yaml"));
|
|
9
10
|
const spinner_1 = require("./spinner");
|
|
10
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) => {
|
|
@@ -37,10 +38,12 @@ const updateSubgraphNetwork = async (toolbox, manifest, network, networksFile, i
|
|
|
37
38
|
});
|
|
38
39
|
// All data sources shoud be on the same network,
|
|
39
40
|
// so we have to update the network of all templates too.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
// eslint-disable-next-line -- prettier has problems with &&=
|
|
42
|
+
subgraph.templates &&
|
|
43
|
+
(subgraph.templates = subgraph.templates.map((template) => ({
|
|
44
|
+
...template,
|
|
45
|
+
network,
|
|
46
|
+
})));
|
|
44
47
|
const unsusedSources = networkSources.filter(x => !subgraphSources.includes(x));
|
|
45
48
|
unsusedSources.forEach(source => {
|
|
46
49
|
(0, spinner_1.step)(spinner, `dataSource '${source}' from '${networksFile}' not found in ${manifest}`);
|
|
@@ -76,8 +79,8 @@ function hasChanges(identifierName, network, networkConfig, dataSource) {
|
|
|
76
79
|
const startBlockChanged = networkConfig.startBlock !== dataSource.source.startBlock;
|
|
77
80
|
return networkChanged || addressChanged || startBlockChanged;
|
|
78
81
|
}
|
|
79
|
-
|
|
80
|
-
await
|
|
82
|
+
async function updateNetworksFile(network, dataSource, address, networksFile) {
|
|
83
|
+
await gluegun_1.patching.update(networksFile, config => {
|
|
81
84
|
if (Object.keys(config).includes(network)) {
|
|
82
85
|
Object.assign(config[network], { [dataSource]: { address } });
|
|
83
86
|
}
|
|
@@ -86,5 +89,5 @@ const updateNetworksFile = async (toolbox, network, dataSource, address, network
|
|
|
86
89
|
}
|
|
87
90
|
return config;
|
|
88
91
|
});
|
|
89
|
-
}
|
|
92
|
+
}
|
|
90
93
|
exports.updateNetworksFile = updateNetworksFile;
|
|
@@ -23,8 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.withSpinner = exports.step = void 0;
|
|
26
|
+
exports.useSpinner = exports.withSpinner = exports.step = void 0;
|
|
27
27
|
const toolbox = __importStar(require("gluegun"));
|
|
28
|
+
const core_1 = require("@oclif/core");
|
|
28
29
|
const step = (spinner, subject, text) => {
|
|
29
30
|
if (text) {
|
|
30
31
|
spinner.stopAndPersist({
|
|
@@ -47,6 +48,8 @@ exports.step = step;
|
|
|
47
48
|
// spinner stops with the warning message and returns the `result` value.
|
|
48
49
|
// Otherwise the spinner prints the in-progress message with a check mark
|
|
49
50
|
// and simply returns the value returned by `f`.
|
|
51
|
+
//
|
|
52
|
+
// @deprecated
|
|
50
53
|
const withSpinner = async (text, errorText, warningText, f) => {
|
|
51
54
|
const spinner = toolbox.print.spin(text);
|
|
52
55
|
try {
|
|
@@ -78,3 +81,36 @@ const withSpinner = async (text, errorText, warningText, f) => {
|
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
83
|
exports.withSpinner = withSpinner;
|
|
84
|
+
// Executes the function `f` while displaying a command-line spinner.
|
|
85
|
+
async function useSpinner(text, errorText, warningText, f) {
|
|
86
|
+
const { action } = core_1.ux;
|
|
87
|
+
action.start(text);
|
|
88
|
+
try {
|
|
89
|
+
const result = await f(action);
|
|
90
|
+
if (result && typeof result === 'object') {
|
|
91
|
+
const hasError = 'error' in result;
|
|
92
|
+
const hasWarning = 'warning' in result;
|
|
93
|
+
const hasResult = 'result' in result;
|
|
94
|
+
if (hasError) {
|
|
95
|
+
action.stop(`✖ ${errorText}: ${result.error}`);
|
|
96
|
+
return (hasResult ? result.result : result);
|
|
97
|
+
}
|
|
98
|
+
if (hasWarning && hasResult) {
|
|
99
|
+
if (result.warning !== null) {
|
|
100
|
+
action.stop(`⚠️ ${warningText}: ${result.warning}`);
|
|
101
|
+
}
|
|
102
|
+
action.stop('✔');
|
|
103
|
+
return result.result;
|
|
104
|
+
}
|
|
105
|
+
action.stop('✔');
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
action.stop('✔');
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
action.stop(`✖ ${errorText}: ${e.message}`);
|
|
113
|
+
throw e;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.useSpinner = useSpinner;
|
package/dist/commands/add.js
CHANGED
|
@@ -26,61 +26,21 @@ 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
|
|
29
|
+
const core_1 = require("@oclif/core");
|
|
30
|
+
const errors_1 = require("@oclif/core/lib/errors");
|
|
31
|
+
const gluegun_1 = require("gluegun");
|
|
30
32
|
const immutable_1 = __importDefault(require("immutable"));
|
|
31
33
|
const abi_1 = require("../command-helpers/abi");
|
|
32
34
|
const DataSourcesExtractor = __importStar(require("../command-helpers/data-sources"));
|
|
33
|
-
const gluegun_1 = require("../command-helpers/gluegun");
|
|
34
35
|
const network_1 = require("../command-helpers/network");
|
|
35
36
|
const scaffold_1 = require("../command-helpers/scaffold");
|
|
36
37
|
const spinner_1 = require("../command-helpers/spinner");
|
|
37
38
|
const protocols_1 = __importDefault(require("../protocols"));
|
|
38
39
|
const abi_2 = __importDefault(require("../protocols/ethereum/abi"));
|
|
39
40
|
const subgraph_1 = __importDefault(require("../subgraph"));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
${chalk_1.default.dim('Options:')}
|
|
44
|
-
|
|
45
|
-
--abi <path> Path to the contract ABI (default: download from Etherscan)
|
|
46
|
-
--contract-name Name of the contract (default: Contract)
|
|
47
|
-
--merge-entities Whether to merge entities with the same name (default: false)
|
|
48
|
-
--network-file <path> Networks config file path (default: "./networks.json")
|
|
49
|
-
-h, --help Show usage information
|
|
50
|
-
`;
|
|
51
|
-
exports.default = {
|
|
52
|
-
description: 'Adds a new datasource to a subgraph',
|
|
53
|
-
run: async (toolbox) => {
|
|
54
|
-
// Obtain tools
|
|
55
|
-
const { print, system } = toolbox;
|
|
56
|
-
// Read CLI parameters
|
|
57
|
-
let { abi, contractName, h, help, mergeEntities, networkFile } = toolbox.parameters.options;
|
|
58
|
-
contractName || (contractName = 'Contract');
|
|
59
|
-
try {
|
|
60
|
-
(0, gluegun_1.fixParameters)(toolbox.parameters, {
|
|
61
|
-
h,
|
|
62
|
-
help,
|
|
63
|
-
mergeEntities,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
print.error(e.message);
|
|
68
|
-
process.exitCode = 1;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const address = toolbox.parameters.first || toolbox.parameters.array?.[0];
|
|
72
|
-
const manifestPath = toolbox.parameters.second || toolbox.parameters.array?.[1] || './subgraph.yaml';
|
|
73
|
-
// Show help text if requested
|
|
74
|
-
if (help || h) {
|
|
75
|
-
print.info(HELP);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
// Validate the address
|
|
79
|
-
if (!address) {
|
|
80
|
-
print.error('No contract address provided');
|
|
81
|
-
process.exitCode = 1;
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
41
|
+
class Add extends core_1.Command {
|
|
42
|
+
async run() {
|
|
43
|
+
const { args: { address, subgraphManifest: manifestPath }, flags: { abi, contractName, mergeEntities, networkFile: networksFile }, } = await this.parse(Add);
|
|
84
44
|
const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifestPath);
|
|
85
45
|
const protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
|
|
86
46
|
const manifest = await subgraph_1.default.load(manifestPath, { protocol });
|
|
@@ -89,9 +49,7 @@ exports.default = {
|
|
|
89
49
|
const entities = getEntities(manifest);
|
|
90
50
|
const contractNames = getContractNames(manifest);
|
|
91
51
|
if (contractNames.includes(contractName)) {
|
|
92
|
-
|
|
93
|
-
process.exitCode = 1;
|
|
94
|
-
return;
|
|
52
|
+
throw new errors_1.CLIError(`Datasource or template with name ${contractName} already exists, please choose a different name.`, { exit: 1 });
|
|
95
53
|
}
|
|
96
54
|
let ethabi = null;
|
|
97
55
|
if (abi) {
|
|
@@ -103,7 +61,7 @@ exports.default = {
|
|
|
103
61
|
else {
|
|
104
62
|
ethabi = await (0, abi_1.loadAbiFromEtherscan)(abi_2.default, network, address);
|
|
105
63
|
}
|
|
106
|
-
const { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(
|
|
64
|
+
const { collisionEntities, onlyCollisions, abiData } = updateEventNamesOnCollision(ethabi, entities, contractName, mergeEntities);
|
|
107
65
|
ethabi.data = abiData;
|
|
108
66
|
await (0, scaffold_1.writeABI)(ethabi, contractName);
|
|
109
67
|
await (0, scaffold_1.writeSchema)(ethabi, protocol, result.getIn(['schema', 'file']), collisionEntities);
|
|
@@ -124,20 +82,45 @@ exports.default = {
|
|
|
124
82
|
result.set('dataSources', dataSources.push(dataSource));
|
|
125
83
|
await subgraph_1.default.write(result, manifestPath);
|
|
126
84
|
// Update networks.json
|
|
127
|
-
|
|
128
|
-
await (0, network_1.updateNetworksFile)(toolbox, network, contractName, address, networksFile);
|
|
85
|
+
await (0, network_1.updateNetworksFile)(network, contractName, address, networksFile);
|
|
129
86
|
// Detect Yarn and/or NPM
|
|
130
|
-
const yarn = system.which('yarn');
|
|
131
|
-
const npm = system.which('npm');
|
|
87
|
+
const yarn = gluegun_1.system.which('yarn');
|
|
88
|
+
const npm = gluegun_1.system.which('npm');
|
|
132
89
|
if (!yarn && !npm) {
|
|
133
|
-
|
|
134
|
-
process.exitCode = 1;
|
|
135
|
-
return;
|
|
90
|
+
throw new errors_1.CLIError('Neither Yarn nor NPM were found on your system. Please install one of them.', { exit: 1 });
|
|
136
91
|
}
|
|
137
|
-
await (0, spinner_1.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
92
|
+
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
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = Add;
|
|
96
|
+
Add.description = 'Adds a new datasource to a subgraph.';
|
|
97
|
+
Add.args = {
|
|
98
|
+
address: core_1.Args.string({
|
|
99
|
+
description: 'The contract address',
|
|
100
|
+
required: true,
|
|
101
|
+
}),
|
|
102
|
+
subgraphManifest: core_1.Args.string({
|
|
103
|
+
default: 'subgraph.yaml',
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
106
|
+
Add.flags = {
|
|
107
|
+
abi: core_1.Flags.string({
|
|
108
|
+
summary: 'Path to the contract ABI.',
|
|
109
|
+
default: '*Download from Etherscan*',
|
|
110
|
+
}),
|
|
111
|
+
contractName: core_1.Flags.string({
|
|
112
|
+
summary: 'Name of the contract.',
|
|
113
|
+
default: 'Contract',
|
|
114
|
+
}),
|
|
115
|
+
mergeEntities: core_1.Flags.boolean({
|
|
116
|
+
summary: 'Whether to merge entities with the same name.',
|
|
117
|
+
default: false,
|
|
118
|
+
}),
|
|
119
|
+
// TODO: should be networksFile (with an "s")
|
|
120
|
+
networkFile: core_1.Flags.string({
|
|
121
|
+
summary: 'Networks config file path.',
|
|
122
|
+
default: 'networks.json',
|
|
123
|
+
}),
|
|
141
124
|
};
|
|
142
125
|
const getEntities = (manifest) => {
|
|
143
126
|
const dataSources = manifest.result.get('dataSources', immutable_1.default.List());
|
|
@@ -152,9 +135,8 @@ const getContractNames = (manifest) => {
|
|
|
152
135
|
const templates = manifest.result.get('templates', immutable_1.default.List());
|
|
153
136
|
return dataSources.concat(templates).map((dataSource) => dataSource.get('name'));
|
|
154
137
|
};
|
|
155
|
-
const updateEventNamesOnCollision = (
|
|
138
|
+
const updateEventNamesOnCollision = (ethabi, entities, contractName, mergeEntities) => {
|
|
156
139
|
let abiData = ethabi.data;
|
|
157
|
-
const { print } = toolbox;
|
|
158
140
|
const collisionEntities = [];
|
|
159
141
|
let onlyCollisions = true;
|
|
160
142
|
for (let i = 0; i < abiData.size; i++) {
|
|
@@ -162,10 +144,8 @@ const updateEventNamesOnCollision = (toolbox, ethabi, entities, contractName, me
|
|
|
162
144
|
if (dataRow.get('type') === 'event') {
|
|
163
145
|
if (entities.includes(dataRow.get('name'))) {
|
|
164
146
|
if (entities.includes(`${contractName}${dataRow.get('name')}`)) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
process.exitCode = 1;
|
|
168
|
-
break;
|
|
147
|
+
throw new errors_1.CLIError(`Contract name ('${contractName}')
|
|
148
|
+
+ event name ('${dataRow.get('name')}') entity already exists.`, { exit: 1 });
|
|
169
149
|
}
|
|
170
150
|
if (mergeEntities) {
|
|
171
151
|
collisionEntities.push(dataRow.get('name'));
|
package/dist/commands/init.js
CHANGED
|
@@ -30,7 +30,6 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
30
30
|
const os_1 = __importDefault(require("os"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const chalk_1 = __importDefault(require("chalk"));
|
|
33
|
-
const graphCli = __importStar(require("../cli"));
|
|
34
33
|
const abi_1 = require("../command-helpers/abi");
|
|
35
34
|
const DataSourcesExtractor = __importStar(require("../command-helpers/data-sources"));
|
|
36
35
|
const gluegun_1 = require("../command-helpers/gluegun");
|
|
@@ -44,6 +43,7 @@ const debug_1 = __importDefault(require("../debug"));
|
|
|
44
43
|
const protocols_1 = __importDefault(require("../protocols"));
|
|
45
44
|
const schema_1 = require("../scaffold/schema");
|
|
46
45
|
const validation_1 = require("../validation");
|
|
46
|
+
const add_1 = __importDefault(require("./add"));
|
|
47
47
|
const protocolChoices = Array.from(protocols_1.default.availableProtocols().keys());
|
|
48
48
|
const availableNetworks = protocols_1.default.availableNetworks();
|
|
49
49
|
const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum/gravatar';
|
|
@@ -803,7 +803,7 @@ const addAnotherContract = async (toolbox, { protocolInstance, directory }) => {
|
|
|
803
803
|
commandLine.push('--abi', abi);
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
|
-
await
|
|
806
|
+
await add_1.default.run(commandLine);
|
|
807
807
|
}
|
|
808
808
|
catch (e) {
|
|
809
809
|
toolbox.print.error(e);
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.38.1-alpha-20230207152800-4428ad7",
|
|
3
|
+
"commands": {
|
|
4
|
+
"add": {
|
|
5
|
+
"id": "add",
|
|
6
|
+
"description": "Adds a new datasource to a subgraph.",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
9
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
10
|
+
"pluginType": "core",
|
|
11
|
+
"aliases": [],
|
|
12
|
+
"flags": {
|
|
13
|
+
"abi": {
|
|
14
|
+
"name": "abi",
|
|
15
|
+
"type": "option",
|
|
16
|
+
"summary": "Path to the contract ABI.",
|
|
17
|
+
"multiple": false,
|
|
18
|
+
"default": "*Download from Etherscan*"
|
|
19
|
+
},
|
|
20
|
+
"contractName": {
|
|
21
|
+
"name": "contractName",
|
|
22
|
+
"type": "option",
|
|
23
|
+
"summary": "Name of the contract.",
|
|
24
|
+
"multiple": false,
|
|
25
|
+
"default": "Contract"
|
|
26
|
+
},
|
|
27
|
+
"mergeEntities": {
|
|
28
|
+
"name": "mergeEntities",
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"summary": "Whether to merge entities with the same name.",
|
|
31
|
+
"allowNo": false
|
|
32
|
+
},
|
|
33
|
+
"networkFile": {
|
|
34
|
+
"name": "networkFile",
|
|
35
|
+
"type": "option",
|
|
36
|
+
"summary": "Networks config file path.",
|
|
37
|
+
"multiple": false,
|
|
38
|
+
"default": "networks.json"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"args": {
|
|
42
|
+
"address": {
|
|
43
|
+
"name": "address",
|
|
44
|
+
"description": "The contract address",
|
|
45
|
+
"required": true
|
|
46
|
+
},
|
|
47
|
+
"subgraphManifest": {
|
|
48
|
+
"name": "subgraphManifest",
|
|
49
|
+
"default": "subgraph.yaml"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"auth": {
|
|
54
|
+
"id": "auth",
|
|
55
|
+
"description": "Sets the deploy key to use when deploying to a Graph node",
|
|
56
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
57
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
58
|
+
"pluginType": "core",
|
|
59
|
+
"aliases": [],
|
|
60
|
+
"flags": {},
|
|
61
|
+
"args": {}
|
|
62
|
+
},
|
|
63
|
+
"build": {
|
|
64
|
+
"id": "build",
|
|
65
|
+
"description": "Builds a subgraph and (optionally) uploads it to IPFS",
|
|
66
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
67
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
68
|
+
"pluginType": "core",
|
|
69
|
+
"aliases": [],
|
|
70
|
+
"flags": {},
|
|
71
|
+
"args": {}
|
|
72
|
+
},
|
|
73
|
+
"codegen": {
|
|
74
|
+
"id": "codegen",
|
|
75
|
+
"description": "Generates AssemblyScript types for a subgraph",
|
|
76
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
77
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
78
|
+
"pluginType": "core",
|
|
79
|
+
"aliases": [],
|
|
80
|
+
"flags": {},
|
|
81
|
+
"args": {}
|
|
82
|
+
},
|
|
83
|
+
"create": {
|
|
84
|
+
"id": "create",
|
|
85
|
+
"description": "Registers a subgraph name",
|
|
86
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
87
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
88
|
+
"pluginType": "core",
|
|
89
|
+
"aliases": [],
|
|
90
|
+
"flags": {},
|
|
91
|
+
"args": {}
|
|
92
|
+
},
|
|
93
|
+
"deploy": {
|
|
94
|
+
"id": "deploy",
|
|
95
|
+
"description": "Deploys the subgraph to a Graph node",
|
|
96
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
97
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
98
|
+
"pluginType": "core",
|
|
99
|
+
"aliases": [],
|
|
100
|
+
"flags": {},
|
|
101
|
+
"args": {}
|
|
102
|
+
},
|
|
103
|
+
"init": {
|
|
104
|
+
"id": "init",
|
|
105
|
+
"description": "Creates a new subgraph with basic scaffolding",
|
|
106
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
107
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
108
|
+
"pluginType": "core",
|
|
109
|
+
"aliases": [],
|
|
110
|
+
"flags": {},
|
|
111
|
+
"args": {}
|
|
112
|
+
},
|
|
113
|
+
"local": {
|
|
114
|
+
"id": "local",
|
|
115
|
+
"description": "Runs local tests against a Graph Node environment (using Ganache by default)",
|
|
116
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
117
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
118
|
+
"pluginType": "core",
|
|
119
|
+
"aliases": [],
|
|
120
|
+
"flags": {},
|
|
121
|
+
"args": {}
|
|
122
|
+
},
|
|
123
|
+
"remove": {
|
|
124
|
+
"id": "remove",
|
|
125
|
+
"description": "Unregisters a subgraph name",
|
|
126
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
127
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
128
|
+
"pluginType": "core",
|
|
129
|
+
"aliases": [],
|
|
130
|
+
"flags": {},
|
|
131
|
+
"args": {}
|
|
132
|
+
},
|
|
133
|
+
"test": {
|
|
134
|
+
"id": "test",
|
|
135
|
+
"description": "Runs rust binary for subgraph testing",
|
|
136
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
137
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
138
|
+
"pluginType": "core",
|
|
139
|
+
"aliases": [],
|
|
140
|
+
"flags": {},
|
|
141
|
+
"args": {}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphprotocol/graph-cli",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.1-alpha-20230207152800-4428ad7",
|
|
4
4
|
"description": "CLI for building for and deploying to The Graph",
|
|
5
5
|
"license": "(Apache-2.0 OR MIT)",
|
|
6
6
|
"engines": {
|
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
"bin": {
|
|
10
10
|
"graph": "dist/bin.js"
|
|
11
11
|
},
|
|
12
|
-
"main": "dist/
|
|
12
|
+
"main": "dist/index.js",
|
|
13
13
|
"files": [
|
|
14
14
|
"CHANGELOG.md",
|
|
15
15
|
"dist",
|
|
16
|
+
"oclif.manifest.json",
|
|
16
17
|
"README.md"
|
|
17
18
|
],
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@float-capital/float-subgraph-uncrashable": "^0.0.0-alpha.4",
|
|
21
|
+
"@oclif/core": "2.0.7",
|
|
20
22
|
"assemblyscript": "0.19.23",
|
|
21
23
|
"binary-install-raw": "0.0.13",
|
|
22
24
|
"chalk": "3.0.0",
|
|
@@ -52,6 +54,7 @@
|
|
|
52
54
|
"@types/which": "^2.0.1",
|
|
53
55
|
"copyfiles": "^2.4.1",
|
|
54
56
|
"jest": "26.0.0",
|
|
57
|
+
"oclif": "3.6.1",
|
|
55
58
|
"spawn-command": "0.0.2-1",
|
|
56
59
|
"strip-ansi": "6.0.0",
|
|
57
60
|
"tern": "0.24.3",
|
|
@@ -60,8 +63,12 @@
|
|
|
60
63
|
"publishConfig": {
|
|
61
64
|
"access": "public"
|
|
62
65
|
},
|
|
66
|
+
"oclif": {
|
|
67
|
+
"bin": "graph",
|
|
68
|
+
"commands": "./dist/commands"
|
|
69
|
+
},
|
|
63
70
|
"scripts": {
|
|
64
|
-
"build": "tsc -b tsconfig.build.json && copyfiles -u 1 src/**/*.graphql dist/ && chmod +x ./dist/bin.js",
|
|
71
|
+
"build": "tsc -b tsconfig.build.json && oclif manifest && copyfiles -u 1 src/**/*.graphql dist/ && chmod +x ./dist/bin.js",
|
|
65
72
|
"test": "jest --verbose",
|
|
66
73
|
"test:init": "jest tests/cli/init.test.ts --verbose",
|
|
67
74
|
"test:validation": "jest tests/cli/validation.test.ts --verbose",
|
package/dist/cli.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.run = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const gluegun_1 = require("gluegun");
|
|
9
|
-
const run = async (argv) => {
|
|
10
|
-
let builder = (0, gluegun_1.build)().brand('graph').src(__dirname);
|
|
11
|
-
const pluginDirs = [];
|
|
12
|
-
await Promise.all(['npm root -g', 'npm root', 'yarn global dir'].map(async (cmd) => {
|
|
13
|
-
try {
|
|
14
|
-
const dir = await gluegun_1.system.run(cmd, { trim: true });
|
|
15
|
-
pluginDirs.push(dir);
|
|
16
|
-
}
|
|
17
|
-
catch (_) {
|
|
18
|
-
// noop
|
|
19
|
-
}
|
|
20
|
-
}));
|
|
21
|
-
// Inject potential plugin directories
|
|
22
|
-
builder = pluginDirs.reduce((cli, dir) => cli.plugin(path_1.default.join(dir, '@graphprotocol', 'indexer-cli', 'dist')), builder);
|
|
23
|
-
const cli = builder.help().version().defaultCommand().create();
|
|
24
|
-
return await cli.run(argv);
|
|
25
|
-
};
|
|
26
|
-
exports.run = run;
|