@graphprotocol/graph-cli 0.72.2 → 0.73.0-alpha-20240523161731-2bda657
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 +24 -0
- package/dist/commands/publish.d.ts +19 -0
- package/dist/commands/publish.js +107 -0
- package/oclif.manifest.json +40 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
+
## 0.73.0-alpha-20240523161731-2bda657
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1670](https://github.com/graphprotocol/graph-tooling/pull/1670)
|
|
8
|
+
[`2bda657`](https://github.com/graphprotocol/graph-tooling/commit/2bda65741d2403dedb743bb34b7d678cdd85a405)
|
|
9
|
+
Thanks [@saihaj](https://github.com/saihaj)! - Introduce `graph publish` command.
|
|
10
|
+
|
|
11
|
+
Now you can publish your subgraphs directly from the CLI. This command will build your subgraph,
|
|
12
|
+
deploy, prompt you to add metadata and then sign the transaction to publish it to the Graph
|
|
13
|
+
Network.
|
|
14
|
+
|
|
15
|
+
1. Build the subgraph and publish it to the network.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
graph publish
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. Provide a IPFS Hash for the subgraph and publish it to the network.
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
graph publish --ipfs <ipfs-hash>
|
|
25
|
+
```
|
|
26
|
+
|
|
3
27
|
## 0.72.2
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class PublishCommand extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
'subgraph-manifest': import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
9
|
+
ipfs: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
'ipfs-hash': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Prompt the user to open up the browser to continue publishing the subgraph
|
|
14
|
+
*/
|
|
15
|
+
publishWithBrowser({ ipfsHash }: {
|
|
16
|
+
ipfsHash: string;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
30
|
+
const gluegun_1 = require("gluegun");
|
|
31
|
+
const open_1 = __importDefault(require("open"));
|
|
32
|
+
const core_1 = require("@oclif/core");
|
|
33
|
+
const compiler_1 = require("../command-helpers/compiler");
|
|
34
|
+
const DataSourcesExtractor = __importStar(require("../command-helpers/data-sources"));
|
|
35
|
+
const ipfs_1 = require("../command-helpers/ipfs");
|
|
36
|
+
const protocols_1 = __importDefault(require("../protocols"));
|
|
37
|
+
class PublishCommand extends core_1.Command {
|
|
38
|
+
/**
|
|
39
|
+
* Prompt the user to open up the browser to continue publishing the subgraph
|
|
40
|
+
*/
|
|
41
|
+
async publishWithBrowser({ ipfsHash }) {
|
|
42
|
+
const answer = await core_1.ux.prompt(`Press ${chalk_1.default.green('y')} (or any key) to open up the browser to continue publishing or ${chalk_1.default.yellow('q')} to exit`);
|
|
43
|
+
if (answer.toLowerCase() === 'q') {
|
|
44
|
+
this.exit(0);
|
|
45
|
+
}
|
|
46
|
+
const URL = `https://cli.thegraph.com/deploy?id=${ipfsHash}`;
|
|
47
|
+
gluegun_1.print.success(`Finalize the publish of the subgraph from the Graph CLI publish page. Opening up the browser to continue publishing at ${URL}`);
|
|
48
|
+
await (0, open_1.default)(URL);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
async run() {
|
|
52
|
+
const { args: { 'subgraph-manifest': manifest }, flags: { 'ipfs-hash': ipfsHash, ipfs, }, } = await this.parse(PublishCommand);
|
|
53
|
+
if (ipfsHash) {
|
|
54
|
+
await this.publishWithBrowser({ ipfsHash });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let protocol;
|
|
58
|
+
try {
|
|
59
|
+
const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest);
|
|
60
|
+
protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
this.error(e, { exit: 1 });
|
|
64
|
+
}
|
|
65
|
+
const compiler = (0, compiler_1.createCompiler)(manifest, {
|
|
66
|
+
ipfs,
|
|
67
|
+
outputDir: 'build/',
|
|
68
|
+
outputFormat: 'wasm',
|
|
69
|
+
skipMigrations: false,
|
|
70
|
+
protocol,
|
|
71
|
+
});
|
|
72
|
+
// Exit with an error code if the compiler couldn't be created
|
|
73
|
+
if (!compiler) {
|
|
74
|
+
this.exit(1);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const result = await compiler.compile({ validate: true });
|
|
78
|
+
if (result === undefined || result === false) {
|
|
79
|
+
// Compilation failed, not deploying.
|
|
80
|
+
process.exitCode = 1;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
await this.publishWithBrowser({ ipfsHash: result });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
PublishCommand.description = 'Publish to the Graph Network';
|
|
88
|
+
PublishCommand.args = {
|
|
89
|
+
'subgraph-manifest': core_1.Args.string({
|
|
90
|
+
default: 'subgraph.yaml',
|
|
91
|
+
}),
|
|
92
|
+
};
|
|
93
|
+
PublishCommand.flags = {
|
|
94
|
+
help: core_1.Flags.help({
|
|
95
|
+
char: 'h',
|
|
96
|
+
}),
|
|
97
|
+
ipfs: core_1.Flags.string({
|
|
98
|
+
summary: 'Upload build results to an IPFS node.',
|
|
99
|
+
char: 'i',
|
|
100
|
+
default: ipfs_1.DEFAULT_IPFS_URL,
|
|
101
|
+
}),
|
|
102
|
+
'ipfs-hash': core_1.Flags.string({
|
|
103
|
+
summary: 'IPFS hash of the subgraph manifest to deploy.',
|
|
104
|
+
required: false,
|
|
105
|
+
}),
|
|
106
|
+
};
|
|
107
|
+
exports.default = PublishCommand;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.73.0-alpha-20240523161731-2bda657",
|
|
3
3
|
"commands": {
|
|
4
4
|
"add": {
|
|
5
5
|
"id": "add",
|
|
@@ -746,6 +746,45 @@
|
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
},
|
|
749
|
+
"publish": {
|
|
750
|
+
"id": "publish",
|
|
751
|
+
"description": "Publish to the Graph Network",
|
|
752
|
+
"strict": true,
|
|
753
|
+
"pluginName": "@graphprotocol/graph-cli",
|
|
754
|
+
"pluginAlias": "@graphprotocol/graph-cli",
|
|
755
|
+
"pluginType": "core",
|
|
756
|
+
"aliases": [],
|
|
757
|
+
"flags": {
|
|
758
|
+
"help": {
|
|
759
|
+
"name": "help",
|
|
760
|
+
"type": "boolean",
|
|
761
|
+
"char": "h",
|
|
762
|
+
"description": "Show CLI help.",
|
|
763
|
+
"allowNo": false
|
|
764
|
+
},
|
|
765
|
+
"ipfs": {
|
|
766
|
+
"name": "ipfs",
|
|
767
|
+
"type": "option",
|
|
768
|
+
"char": "i",
|
|
769
|
+
"summary": "Upload build results to an IPFS node.",
|
|
770
|
+
"multiple": false,
|
|
771
|
+
"default": "https://api.thegraph.com/ipfs/api/v0"
|
|
772
|
+
},
|
|
773
|
+
"ipfs-hash": {
|
|
774
|
+
"name": "ipfs-hash",
|
|
775
|
+
"type": "option",
|
|
776
|
+
"summary": "IPFS hash of the subgraph manifest to deploy.",
|
|
777
|
+
"required": false,
|
|
778
|
+
"multiple": false
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
"args": {
|
|
782
|
+
"subgraph-manifest": {
|
|
783
|
+
"name": "subgraph-manifest",
|
|
784
|
+
"default": "subgraph.yaml"
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
},
|
|
749
788
|
"remove": {
|
|
750
789
|
"id": "remove",
|
|
751
790
|
"description": "Unregisters a subgraph name",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphprotocol/graph-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.73.0-alpha-20240523161731-2bda657",
|
|
4
4
|
"description": "CLI for building for and deploying to The Graph",
|
|
5
5
|
"license": "(Apache-2.0 OR MIT)",
|
|
6
6
|
"engines": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"ipfs-http-client": "55.0.0",
|
|
40
40
|
"jayson": "4.0.0",
|
|
41
41
|
"js-yaml": "3.14.1",
|
|
42
|
+
"open": "8.4.2",
|
|
42
43
|
"prettier": "3.0.3",
|
|
43
44
|
"semver": "7.4.0",
|
|
44
45
|
"sync-request": "6.1.0",
|