@graphprotocol/graph-cli 0.38.1-alpha-20230208031159-e8f0545 → 0.38.1-alpha-20230208031649-b554fda
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 +1 -1
- package/dist/commands/create.js +1 -1
- package/dist/commands/remove.js +32 -56
- package/oclif.manifest.json +24 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/commands/create.js
CHANGED
package/dist/commands/remove.js
CHANGED
|
@@ -1,74 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const url_1 = require("url");
|
|
7
|
-
const
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
8
5
|
const auth_1 = require("../command-helpers/auth");
|
|
9
6
|
const jsonrpc_1 = require("../command-helpers/jsonrpc");
|
|
10
7
|
const node_1 = require("../command-helpers/node");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
${chalk_1.default.dim('Options:')}
|
|
15
|
-
|
|
16
|
-
--access-token <token> Graph access token
|
|
17
|
-
-h, --help Show usage information
|
|
18
|
-
-g, --node <url> Graph node to create the subgraph in
|
|
19
|
-
`;
|
|
20
|
-
exports.default = {
|
|
21
|
-
description: 'Unregisters a subgraph name',
|
|
22
|
-
run: async (toolbox) => {
|
|
23
|
-
// Obtain tools
|
|
24
|
-
const { print } = toolbox;
|
|
25
|
-
// Read CLI parameters
|
|
26
|
-
let { accessToken, g, h, help, node } = toolbox.parameters.options;
|
|
27
|
-
const subgraphName = toolbox.parameters.first;
|
|
28
|
-
// Support both long and short option variants
|
|
29
|
-
help || (help = h);
|
|
30
|
-
node || (node = g);
|
|
31
|
-
// Show help text if requested
|
|
32
|
-
if (help) {
|
|
33
|
-
print.info(HELP);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
// Validate the subgraph name
|
|
37
|
-
if (!subgraphName) {
|
|
38
|
-
print.error('No subgraph name provided');
|
|
39
|
-
print.info(HELP);
|
|
40
|
-
process.exitCode = 1;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
// Validate node
|
|
44
|
-
if (!node) {
|
|
45
|
-
print.error(`No Graph node provided`);
|
|
46
|
-
print.info(HELP);
|
|
47
|
-
process.exitCode = 1;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
8
|
+
class RemoveCommand extends core_1.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
const { args: { 'subgraph-name': subgraphName }, flags: { 'access-token': accessTokenFlag, node }, } = await this.parse(RemoveCommand);
|
|
50
11
|
try {
|
|
51
12
|
(0, node_1.validateNodeUrl)(node);
|
|
52
13
|
}
|
|
53
14
|
catch (e) {
|
|
54
|
-
|
|
55
|
-
process.exitCode = 1;
|
|
56
|
-
return;
|
|
15
|
+
this.error(`Graph node "${node}" is invalid: ${e.message}`, { exit: 1 });
|
|
57
16
|
}
|
|
58
17
|
const requestUrl = new url_1.URL(node);
|
|
59
18
|
const client = (0, jsonrpc_1.createJsonRpcClient)(requestUrl);
|
|
60
19
|
// Exit with an error code if the client couldn't be created
|
|
61
20
|
if (!client) {
|
|
62
|
-
|
|
21
|
+
this.exit(1);
|
|
63
22
|
return;
|
|
64
23
|
}
|
|
65
24
|
// Use the access token, if one is set
|
|
66
|
-
accessToken = await (0, auth_1.identifyDeployKey)(node,
|
|
25
|
+
const accessToken = await (0, auth_1.identifyDeployKey)(node, accessTokenFlag);
|
|
67
26
|
if (accessToken !== undefined && accessToken !== null) {
|
|
68
27
|
// @ts-expect-error options property seems to exist
|
|
69
28
|
client.options.headers = { Authorization: `Bearer ${accessToken}` };
|
|
70
29
|
}
|
|
71
|
-
|
|
30
|
+
core_1.ux.action.start(`Removing subgraph in Graph node: ${requestUrl}`);
|
|
72
31
|
client.request('subgraph_remove', { name: subgraphName }, (
|
|
73
32
|
// @ts-expect-error TODO: why are the arguments not typed?
|
|
74
33
|
requestError,
|
|
@@ -79,17 +38,34 @@ exports.default = {
|
|
|
79
38
|
// @ts-expect-error TODO: why are the arguments not typed?
|
|
80
39
|
_res) => {
|
|
81
40
|
if (jsonRpcError) {
|
|
82
|
-
|
|
83
|
-
|
|
41
|
+
core_1.ux.action.stop(`✖ Error removed the subgraph: ${jsonRpcError.message}`);
|
|
42
|
+
this.exit(1);
|
|
84
43
|
}
|
|
85
44
|
else if (requestError) {
|
|
86
|
-
|
|
87
|
-
|
|
45
|
+
core_1.ux.action.stop(`✖ HTTP error removed the subgraph: ${requestError.code}`);
|
|
46
|
+
this.exit(1);
|
|
88
47
|
}
|
|
89
48
|
else {
|
|
90
|
-
|
|
91
|
-
|
|
49
|
+
core_1.ux.action.stop('Subgraph removed');
|
|
50
|
+
this.exit(1);
|
|
92
51
|
}
|
|
93
52
|
});
|
|
94
|
-
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.default = RemoveCommand;
|
|
56
|
+
RemoveCommand.description = 'Unregisters a subgraph name';
|
|
57
|
+
RemoveCommand.args = {
|
|
58
|
+
'subgraph-name': core_1.Args.string({
|
|
59
|
+
required: true,
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
RemoveCommand.flags = {
|
|
63
|
+
node: core_1.Flags.string({
|
|
64
|
+
summary: 'Graph node to delete the subgraph from.',
|
|
65
|
+
char: 'g',
|
|
66
|
+
required: true,
|
|
67
|
+
}),
|
|
68
|
+
'access-token': core_1.Flags.string({
|
|
69
|
+
summary: 'Graph access token.',
|
|
70
|
+
}),
|
|
95
71
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.38.1-alpha-
|
|
2
|
+
"version": "0.38.1-alpha-20230208031649-b554fda",
|
|
3
3
|
"commands": {
|
|
4
4
|
"add": {
|
|
5
5
|
"id": "add",
|
|
@@ -327,12 +327,33 @@
|
|
|
327
327
|
"remove": {
|
|
328
328
|
"id": "remove",
|
|
329
329
|
"description": "Unregisters a subgraph name",
|
|
330
|
+
"strict": true,
|
|
330
331
|
"pluginName": "@graphprotocol/graph-cli",
|
|
331
332
|
"pluginAlias": "@graphprotocol/graph-cli",
|
|
332
333
|
"pluginType": "core",
|
|
333
334
|
"aliases": [],
|
|
334
|
-
"flags": {
|
|
335
|
-
|
|
335
|
+
"flags": {
|
|
336
|
+
"node": {
|
|
337
|
+
"name": "node",
|
|
338
|
+
"type": "option",
|
|
339
|
+
"char": "g",
|
|
340
|
+
"summary": "Graph node to delete the subgraph from.",
|
|
341
|
+
"required": true,
|
|
342
|
+
"multiple": false
|
|
343
|
+
},
|
|
344
|
+
"access-token": {
|
|
345
|
+
"name": "access-token",
|
|
346
|
+
"type": "option",
|
|
347
|
+
"summary": "Graph access token.",
|
|
348
|
+
"multiple": false
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
"args": {
|
|
352
|
+
"subgraph-name": {
|
|
353
|
+
"name": "subgraph-name",
|
|
354
|
+
"required": true
|
|
355
|
+
}
|
|
356
|
+
}
|
|
336
357
|
},
|
|
337
358
|
"test": {
|
|
338
359
|
"id": "test",
|
package/package.json
CHANGED