@graphprotocol/graph-cli 0.92.0 → 0.93.0
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 +47 -0
- package/dist/command-helpers/compiler.d.ts +1 -1
- package/dist/command-helpers/compiler.js +1 -1
- package/dist/commands/build.js +1 -1
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/publish.js +1 -1
- package/dist/compiler/asc.d.ts +2 -1
- package/dist/compiler/asc.js +18 -4
- package/dist/compiler/index.d.ts +2 -2
- package/dist/compiler/index.js +9 -22
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
+
## 0.93.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1849](https://github.com/graphprotocol/graph-tooling/pull/1849)
|
|
8
|
+
[`00e0a83`](https://github.com/graphprotocol/graph-tooling/commit/00e0a830165a946749d12fdbcdc0ad00074a2ecd)
|
|
9
|
+
Thanks [@YaroShkvorets](https://github.com/YaroShkvorets)! - Update all dependencies
|
|
10
|
+
|
|
11
|
+
- [#1849](https://github.com/graphprotocol/graph-tooling/pull/1849)
|
|
12
|
+
[`00e0a83`](https://github.com/graphprotocol/graph-tooling/commit/00e0a830165a946749d12fdbcdc0ad00074a2ecd)
|
|
13
|
+
Thanks [@YaroShkvorets](https://github.com/YaroShkvorets)! - - add networks registry support
|
|
14
|
+
- improve `graph init` flow
|
|
15
|
+
- filter through the networks as you type
|
|
16
|
+
- more information about the networks
|
|
17
|
+
- remove unnecessary options depending on the selection
|
|
18
|
+
- ESC key to go back
|
|
19
|
+
- allow specifying ipfs/url for substreams package
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#1849](https://github.com/graphprotocol/graph-tooling/pull/1849)
|
|
24
|
+
[`00e0a83`](https://github.com/graphprotocol/graph-tooling/commit/00e0a830165a946749d12fdbcdc0ad00074a2ecd)
|
|
25
|
+
Thanks [@YaroShkvorets](https://github.com/YaroShkvorets)! - dependencies updates:
|
|
26
|
+
|
|
27
|
+
- Updated dependency
|
|
28
|
+
[`assemblyscript@0.19.23` ↗︎](https://www.npmjs.com/package/assemblyscript/v/0.19.23) (from
|
|
29
|
+
`0.27.31`, in `dependencies`)
|
|
30
|
+
|
|
31
|
+
- [#1849](https://github.com/graphprotocol/graph-tooling/pull/1849)
|
|
32
|
+
[`00e0a83`](https://github.com/graphprotocol/graph-tooling/commit/00e0a830165a946749d12fdbcdc0ad00074a2ecd)
|
|
33
|
+
Thanks [@YaroShkvorets](https://github.com/YaroShkvorets)! - Fix `graph add` flag parameters
|
|
34
|
+
parsing
|
|
35
|
+
|
|
36
|
+
- [#1849](https://github.com/graphprotocol/graph-tooling/pull/1849)
|
|
37
|
+
[`00e0a83`](https://github.com/graphprotocol/graph-tooling/commit/00e0a830165a946749d12fdbcdc0ad00074a2ecd)
|
|
38
|
+
Thanks [@YaroShkvorets](https://github.com/YaroShkvorets)! - fix bug with clashing \_id field name
|
|
39
|
+
in schema
|
|
40
|
+
|
|
41
|
+
- [#1849](https://github.com/graphprotocol/graph-tooling/pull/1849)
|
|
42
|
+
[`00e0a83`](https://github.com/graphprotocol/graph-tooling/commit/00e0a830165a946749d12fdbcdc0ad00074a2ecd)
|
|
43
|
+
Thanks [@YaroShkvorets](https://github.com/YaroShkvorets)! - fix generated example entity id
|
|
44
|
+
uniqueness
|
|
45
|
+
|
|
46
|
+
- [#1849](https://github.com/graphprotocol/graph-tooling/pull/1849)
|
|
47
|
+
[`00e0a83`](https://github.com/graphprotocol/graph-tooling/commit/00e0a830165a946749d12fdbcdc0ad00074a2ecd)
|
|
48
|
+
Thanks [@YaroShkvorets](https://github.com/YaroShkvorets)! - rollback asc version
|
|
49
|
+
|
|
3
50
|
## 0.92.0
|
|
4
51
|
|
|
5
52
|
### Minor Changes
|
|
@@ -14,5 +14,5 @@ interface CreateCompilerOptions {
|
|
|
14
14
|
* Appends /api/v0 to the end of a The Graph IPFS URL
|
|
15
15
|
*/
|
|
16
16
|
export declare function appendApiVersionForGraph(inputString: string): string;
|
|
17
|
-
export declare function createCompiler(manifest: string, { ipfs, headers, outputDir, outputFormat, skipMigrations, blockIpfsMethods, protocol, }: CreateCompilerOptions):
|
|
17
|
+
export declare function createCompiler(manifest: string, { ipfs, headers, outputDir, outputFormat, skipMigrations, blockIpfsMethods, protocol, }: CreateCompilerOptions): Compiler | null;
|
|
18
18
|
export {};
|
|
@@ -19,7 +19,7 @@ export function appendApiVersionForGraph(inputString) {
|
|
|
19
19
|
return inputString;
|
|
20
20
|
}
|
|
21
21
|
// Helper function to construct a subgraph compiler
|
|
22
|
-
export
|
|
22
|
+
export function createCompiler(manifest, { ipfs, headers, outputDir, outputFormat, skipMigrations, blockIpfsMethods, protocol, }) {
|
|
23
23
|
// Validate the IPFS URL (if a node address was provided)
|
|
24
24
|
try {
|
|
25
25
|
if (ipfs && typeof ipfs === 'string')
|
package/dist/commands/build.js
CHANGED
|
@@ -66,7 +66,7 @@ export default class BuildCommand extends Command {
|
|
|
66
66
|
const identifierName = protocol.getContract().identifierName();
|
|
67
67
|
await updateSubgraphNetwork(manifest, network, networkFile, identifierName);
|
|
68
68
|
}
|
|
69
|
-
const compiler =
|
|
69
|
+
const compiler = createCompiler(manifest, {
|
|
70
70
|
ipfs,
|
|
71
71
|
outputDir,
|
|
72
72
|
outputFormat,
|
package/dist/commands/deploy.js
CHANGED
|
@@ -227,7 +227,7 @@ export default class DeployCommand extends Command {
|
|
|
227
227
|
const identifierName = protocol.getContract().identifierName();
|
|
228
228
|
await updateSubgraphNetwork(manifest, network, networkFile, identifierName);
|
|
229
229
|
}
|
|
230
|
-
const compiler =
|
|
230
|
+
const compiler = createCompiler(manifest, {
|
|
231
231
|
ipfs,
|
|
232
232
|
headers,
|
|
233
233
|
outputDir,
|
package/dist/commands/publish.js
CHANGED
|
@@ -104,7 +104,7 @@ export default class PublishCommand extends Command {
|
|
|
104
104
|
catch (e) {
|
|
105
105
|
this.error(e, { exit: 1 });
|
|
106
106
|
}
|
|
107
|
-
const compiler =
|
|
107
|
+
const compiler = createCompiler(manifest, {
|
|
108
108
|
ipfs,
|
|
109
109
|
outputDir: 'build/',
|
|
110
110
|
outputFormat: 'wasm',
|
package/dist/compiler/asc.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const ready: () => Promise<void>;
|
|
1
2
|
export interface CompileOptions {
|
|
2
3
|
inputFile: string;
|
|
3
4
|
global: string;
|
|
@@ -5,4 +6,4 @@ export interface CompileOptions {
|
|
|
5
6
|
libs: string;
|
|
6
7
|
outputFile: string;
|
|
7
8
|
}
|
|
8
|
-
export declare const compile: ({ inputFile, global, baseDir, libs, outputFile }: CompileOptions) =>
|
|
9
|
+
export declare const compile: ({ inputFile, global, baseDir, libs, outputFile }: CompileOptions) => void;
|
package/dist/compiler/asc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import asc from 'assemblyscript/asc';
|
|
1
|
+
import * as asc from 'assemblyscript/cli/asc';
|
|
2
2
|
const createExitHandler = (inputFile) => () => {
|
|
3
3
|
throw new Error(`The AssemblyScript compiler crashed when compiling this file: '${inputFile}'
|
|
4
4
|
Suggestion: try to comment the whole file and uncomment it little by little while re-running the graph-cli until you isolate the line where the problem happens.
|
|
@@ -8,19 +8,33 @@ Also, please contact us so we can make the CLI better by handling errors like th
|
|
|
8
8
|
};
|
|
9
9
|
const setupExitHandler = (exitHandler) => process.addListener('exit', exitHandler);
|
|
10
10
|
const removeExitHandler = (exitHandler) => process.removeListener('exit', exitHandler);
|
|
11
|
-
|
|
11
|
+
// Important note, the `asc.main` callback function parameter is synchronous,
|
|
12
|
+
// that's why this function doesn't need to be `async` and the throw works properly.
|
|
13
|
+
const assemblyScriptCompiler = (argv, options) => asc.main(argv, options, err => {
|
|
14
|
+
if (err) {
|
|
15
|
+
throw err;
|
|
16
|
+
}
|
|
17
|
+
return 0;
|
|
18
|
+
});
|
|
12
19
|
const compilerDefaults = {
|
|
13
20
|
stdout: process.stdout,
|
|
14
21
|
stderr: process.stdout,
|
|
15
22
|
};
|
|
23
|
+
// You MUST call this function once before compiling anything.
|
|
24
|
+
// Internally it just delegates to the AssemblyScript compiler
|
|
25
|
+
// which just delegates to the binaryen lib.
|
|
26
|
+
export const ready = async () => {
|
|
27
|
+
await asc.ready;
|
|
28
|
+
};
|
|
16
29
|
// For now this function doesn't check if `asc` is ready, because
|
|
17
30
|
// it requires an asynchronous wait. Whenever you call this function,
|
|
18
31
|
// it doesn't matter how many times, just make sure you call `ready`
|
|
19
32
|
// once before everything..
|
|
20
|
-
export const compile =
|
|
33
|
+
export const compile = ({ inputFile, global, baseDir, libs, outputFile }) => {
|
|
21
34
|
const exitHandler = createExitHandler(inputFile);
|
|
22
35
|
setupExitHandler(exitHandler);
|
|
23
36
|
const compilerArgs = [
|
|
37
|
+
'--explicitStart',
|
|
24
38
|
'--exportRuntime',
|
|
25
39
|
'--runtime',
|
|
26
40
|
'stub',
|
|
@@ -35,7 +49,7 @@ export const compile = async ({ inputFile, global, baseDir, libs, outputFile })
|
|
|
35
49
|
'--optimize',
|
|
36
50
|
'--debug',
|
|
37
51
|
];
|
|
38
|
-
|
|
52
|
+
assemblyScriptCompiler(compilerArgs, compilerDefaults);
|
|
39
53
|
// only if compiler succeeded, that is, when the line above doesn't throw
|
|
40
54
|
removeExitHandler(exitHandler);
|
|
41
55
|
};
|
package/dist/compiler/index.d.ts
CHANGED
|
@@ -55,8 +55,8 @@ export default class Compiler {
|
|
|
55
55
|
pathToWasm: string;
|
|
56
56
|
dataSource: immutable.Map<any, any>;
|
|
57
57
|
}): any[];
|
|
58
|
-
_compileDataSourceMapping(protocol: Protocol, dataSource: immutable.Map<any, any>, mappingPath: string, compiledFiles: Map<any, any>, spinner: Spinner, validate?: boolean):
|
|
59
|
-
_compileTemplateMapping(template: immutable.Collection<any, any>, mappingPath: string, compiledFiles: Map<any, any>, spinner: Spinner):
|
|
58
|
+
_compileDataSourceMapping(protocol: Protocol, dataSource: immutable.Map<any, any>, mappingPath: string, compiledFiles: Map<any, any>, spinner: Spinner, validate?: boolean): any;
|
|
59
|
+
_compileTemplateMapping(template: immutable.Collection<any, any>, mappingPath: string, compiledFiles: Map<any, any>, spinner: Spinner): any;
|
|
60
60
|
_validateMappingContent(filePath: string): void;
|
|
61
61
|
writeSubgraphToOutputDirectory(protocol: Protocol, subgraph: immutable.Map<any, any>): Promise<any>;
|
|
62
62
|
uploadSubgraphToIPFS(subgraph: immutable.Map<any, any>): Promise<any>;
|
package/dist/compiler/index.js
CHANGED
|
@@ -180,24 +180,11 @@ export default class Compiler {
|
|
|
180
180
|
return await withSpinner(`Compile subgraph`, `Failed to compile subgraph`, `Warnings while compiling subgraph`, async (spinner) => {
|
|
181
181
|
// Cache compiled files so identical input files are only compiled once
|
|
182
182
|
const compiledFiles = new Map();
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return dataSource.setIn(['mapping', 'file'], compiledPath);
|
|
189
|
-
}));
|
|
190
|
-
subgraph = subgraph.set('dataSources', compiledDataSources);
|
|
191
|
-
// Handle templates if they exist
|
|
192
|
-
const templates = subgraph.get('templates');
|
|
193
|
-
if (templates !== undefined) {
|
|
194
|
-
const compiledTemplates = await Promise.all(templates.map(async (template) => {
|
|
195
|
-
const mappingPath = template.getIn(['mapping', 'file']);
|
|
196
|
-
const compiledPath = await this._compileTemplateMapping(template, mappingPath, compiledFiles, spinner);
|
|
197
|
-
return template.setIn(['mapping', 'file'], compiledPath);
|
|
198
|
-
}));
|
|
199
|
-
subgraph = subgraph.set('templates', compiledTemplates);
|
|
200
|
-
}
|
|
183
|
+
await asc.ready();
|
|
184
|
+
subgraph = subgraph.update('dataSources', (dataSources) => dataSources.map((dataSource) => dataSource.updateIn(['mapping', 'file'], (mappingPath) => this._compileDataSourceMapping(this.protocol, dataSource, mappingPath, compiledFiles, spinner, validate))));
|
|
185
|
+
subgraph = subgraph.update('templates', (templates) => templates === undefined
|
|
186
|
+
? templates
|
|
187
|
+
: templates.map((template) => template.updateIn(['mapping', 'file'], (mappingPath) => this._compileTemplateMapping(template, mappingPath, compiledFiles, spinner))));
|
|
201
188
|
return subgraph;
|
|
202
189
|
});
|
|
203
190
|
}
|
|
@@ -240,7 +227,7 @@ export default class Compiler {
|
|
|
240
227
|
const missingHandlers = handlerNamesFromDataSources.filter((handler) => !handlerNamesFromWasm.has(handler));
|
|
241
228
|
return missingHandlers;
|
|
242
229
|
}
|
|
243
|
-
|
|
230
|
+
_compileDataSourceMapping(protocol, dataSource, mappingPath, compiledFiles, spinner, validate = false) {
|
|
244
231
|
if (protocol.name == 'substreams') {
|
|
245
232
|
return;
|
|
246
233
|
}
|
|
@@ -269,7 +256,7 @@ export default class Compiler {
|
|
|
269
256
|
throw Error('Could not locate `@graphprotocol/graph-ts` package in parent directories of subgraph manifest.');
|
|
270
257
|
}
|
|
271
258
|
const global = path.relative(baseDir, this.globalsFile);
|
|
272
|
-
|
|
259
|
+
asc.compile({
|
|
273
260
|
inputFile,
|
|
274
261
|
global,
|
|
275
262
|
baseDir,
|
|
@@ -293,7 +280,7 @@ export default class Compiler {
|
|
|
293
280
|
throw Error(`Failed to compile data source mapping: ${e.message}`);
|
|
294
281
|
}
|
|
295
282
|
}
|
|
296
|
-
|
|
283
|
+
_compileTemplateMapping(template, mappingPath, compiledFiles, spinner) {
|
|
297
284
|
try {
|
|
298
285
|
const templateName = template.get('name');
|
|
299
286
|
const baseDir = this.sourceDir;
|
|
@@ -319,7 +306,7 @@ export default class Compiler {
|
|
|
319
306
|
throw Error('Could not locate `@graphprotocol/graph-ts` package in parent directories of subgraph manifest.');
|
|
320
307
|
}
|
|
321
308
|
const global = path.relative(baseDir, this.globalsFile);
|
|
322
|
-
|
|
309
|
+
asc.compile({
|
|
323
310
|
inputFile,
|
|
324
311
|
global,
|
|
325
312
|
baseDir,
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphprotocol/graph-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.93.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for building for and deploying to The Graph",
|
|
6
6
|
"license": "(Apache-2.0 OR MIT)",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@oclif/plugin-warn-if-update-available": "^3.1.24",
|
|
29
29
|
"@pinax/graph-networks-registry": "^0.6.5",
|
|
30
30
|
"@whatwg-node/fetch": "^0.10.1",
|
|
31
|
-
"assemblyscript": "0.
|
|
31
|
+
"assemblyscript": "0.19.23",
|
|
32
32
|
"binary-install": "^1.1.0",
|
|
33
33
|
"chokidar": "4.0.1",
|
|
34
34
|
"debug": "4.3.7",
|