@graphprotocol/graph-cli 0.20.0 → 0.20.3
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/.travis.yml +5 -5
- package/examples/arweave-blocks-transactions/node_modules/.bin/graph +17 -0
- package/examples/basic-event-handlers/node_modules/.bin/truffle +17 -0
- package/examples/basic-event-handlers/package.json +5 -2
- package/examples/basic-event-handlers/yarn.lock +311 -164
- package/examples/cosmos-block-filtering/node_modules/.bin/graph +17 -0
- package/examples/cosmos-block-filtering/node_modules/.bin/mustache +17 -0
- package/examples/cosmos-osmosis-token-swaps/node_modules/.bin/graph +17 -0
- package/examples/cosmos-validator-delegations/node_modules/.bin/graph +17 -0
- package/examples/cosmos-validator-delegations/node_modules/.bin/mustache +17 -0
- package/examples/cosmos-validator-rewards/node_modules/.bin/graph +17 -0
- package/examples/cosmos-validator-rewards/node_modules/.bin/mustache +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/graph +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/hardhat +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/solidity-coverage +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/ts-node +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/ts-node-cwd +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/ts-node-esm +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/ts-node-script +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/ts-node-transpile-only +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/ts-script +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/tsc +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/tsserver +17 -0
- package/examples/ethereum-basic-event-handlers/node_modules/.bin/typechain +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/graph +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/hardhat +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/solidity-coverage +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/ts-node +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/ts-node-cwd +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/ts-node-esm +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/ts-node-script +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/ts-node-transpile-only +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/ts-script +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/tsc +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/tsserver +17 -0
- package/examples/ethereum-gravatar/node_modules/.bin/typechain +17 -0
- package/examples/example-subgraph/package.json +3 -0
- package/examples/example-subgraph/yarn.lock +18 -106
- package/examples/near-blocks/node_modules/.bin/graph +17 -0
- package/examples/near-receipts/node_modules/.bin/graph +17 -0
- package/examples/substreams-powered-subgraph/node_modules/.bin/graph +17 -0
- package/package.json +4 -4
- package/src/codegen/typescript.js +0 -55
- package/src/command-helpers/compiler.js +20 -10
- package/src/command-helpers/jsonrpc.js +1 -0
- package/src/commands/deploy.js +1 -1
- package/src/commands/init.js +17 -3
- package/src/compiler.js +12 -3
- package/src/migrations/mapping_api_version_0_0_1.js +14 -3
- package/src/migrations/mapping_api_version_0_0_2.js +15 -6
- package/src/migrations/mapping_api_version_0_0_3.js +14 -3
- package/src/migrations/spec_version_0_0_2.js +2 -1
- package/src/migrations/util/load-manifest.js +16 -0
- package/src/subgraph.js +8 -1
- package/tests/cli/util.js +3 -3
|
@@ -2,6 +2,7 @@ const fs = require('fs-extra')
|
|
|
2
2
|
const semver = require('semver')
|
|
3
3
|
const toolbox = require('gluegun/toolbox')
|
|
4
4
|
const yaml = require('js-yaml')
|
|
5
|
+
const { loadManifest } = require('./util/load-manifest')
|
|
5
6
|
const { getGraphTsVersion } = require('./util/versions')
|
|
6
7
|
|
|
7
8
|
// If any of the manifest apiVersions are 0.0.3, replace them with 0.0.4
|
|
@@ -18,7 +19,7 @@ module.exports = {
|
|
|
18
19
|
return 'graph-ts dependency not installed yet'
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
let manifest =
|
|
22
|
+
let manifest = loadManifest(manifestFile)
|
|
22
23
|
return (
|
|
23
24
|
// Only migrate if the graph-ts version is > 0.17.0...
|
|
24
25
|
semver.gt(graphTsVersion, '0.17.0') &&
|
|
@@ -26,7 +27,7 @@ module.exports = {
|
|
|
26
27
|
manifest &&
|
|
27
28
|
typeof manifest === 'object' &&
|
|
28
29
|
Array.isArray(manifest.dataSources) &&
|
|
29
|
-
manifest.dataSources.reduce(
|
|
30
|
+
(manifest.dataSources.reduce(
|
|
30
31
|
(hasOldMappings, dataSource) =>
|
|
31
32
|
hasOldMappings ||
|
|
32
33
|
(typeof dataSource === 'object' &&
|
|
@@ -34,7 +35,17 @@ module.exports = {
|
|
|
34
35
|
typeof dataSource.mapping === 'object' &&
|
|
35
36
|
dataSource.mapping.apiVersion === '0.0.3'),
|
|
36
37
|
false,
|
|
37
|
-
)
|
|
38
|
+
) ||
|
|
39
|
+
(Array.isArray(manifest.templates) &&
|
|
40
|
+
manifest.templates.reduce(
|
|
41
|
+
(hasOldMappings, template) =>
|
|
42
|
+
hasOldMappings ||
|
|
43
|
+
(typeof template === 'object' &&
|
|
44
|
+
template.mapping &&
|
|
45
|
+
typeof template.mapping === 'object' &&
|
|
46
|
+
template.mapping.apiVersion === '0.0.3'),
|
|
47
|
+
false,
|
|
48
|
+
)))
|
|
38
49
|
)
|
|
39
50
|
},
|
|
40
51
|
apply: async ({ manifestFile }) => {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
const fs = require('fs-extra')
|
|
2
2
|
const toolbox = require('gluegun/toolbox')
|
|
3
3
|
const yaml = require('js-yaml')
|
|
4
|
+
const { loadManifest } = require('./util/load-manifest')
|
|
4
5
|
|
|
5
6
|
// Spec version to 0.0.2 uses top level templates. graph-cli no longer supports
|
|
6
7
|
// 0.0.1 which used nested templates.
|
|
7
8
|
module.exports = {
|
|
8
9
|
name: 'Bump mapping specVersion from 0.0.1 to 0.0.2',
|
|
9
10
|
predicate: async ({ sourceDir, manifestFile }) => {
|
|
10
|
-
let manifest =
|
|
11
|
+
let manifest = loadManifest(manifestFile)
|
|
11
12
|
return (
|
|
12
13
|
manifest &&
|
|
13
14
|
typeof manifest === 'object' &&
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const fs = require('fs-extra')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const yaml = require('js-yaml')
|
|
4
|
+
|
|
5
|
+
function loadManifest(manifestFile) {
|
|
6
|
+
if(manifestFile.match(/.js$/)) {
|
|
7
|
+
return require(path.resolve(manifestFile))
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return yaml.safeLoad(fs.readFileSync(manifestFile, 'utf-8'))
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
loadManifest
|
|
16
|
+
}
|
package/src/subgraph.js
CHANGED
|
@@ -421,7 +421,14 @@ More than one template named '${name}', template names must be unique.`,
|
|
|
421
421
|
|
|
422
422
|
static load(filename, { skipValidation } = { skipValidation: false }) {
|
|
423
423
|
// Load and validate the manifest
|
|
424
|
-
let data =
|
|
424
|
+
let data = null
|
|
425
|
+
|
|
426
|
+
if(filename.match(/.js$/)) {
|
|
427
|
+
data = require(path.resolve(filename))
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
data = yaml.parse(fs.readFileSync(filename, 'utf-8'))
|
|
431
|
+
}
|
|
425
432
|
|
|
426
433
|
// Helper to resolve files relative to the subgraph manifest
|
|
427
434
|
let resolveFile = maybeRelativeFile =>
|
package/tests/cli/util.js
CHANGED
|
@@ -29,15 +29,15 @@ const cliTest = (title, args, testPath, options) => {
|
|
|
29
29
|
expectedStderr = fs.readFileSync(resolvePath(`./${testPath}.stderr`), 'utf-8')
|
|
30
30
|
} catch (e) {}
|
|
31
31
|
|
|
32
|
-
if (expectedStdout !== undefined) {
|
|
33
|
-
expect(stripAnsi(stdout)).toBe(expectedStdout)
|
|
34
|
-
}
|
|
35
32
|
if (expectedStderr !== undefined) {
|
|
36
33
|
expect(stripAnsi(stderr)).toBe(expectedStderr)
|
|
37
34
|
}
|
|
38
35
|
if (expectedExitCode !== undefined) {
|
|
39
36
|
expect(exitCode).toBe(expectedExitCode)
|
|
40
37
|
}
|
|
38
|
+
if (expectedStdout !== undefined) {
|
|
39
|
+
expect(stripAnsi(stdout)).toBe(expectedStdout)
|
|
40
|
+
}
|
|
41
41
|
},
|
|
42
42
|
(options !== undefined && options.timeout) || undefined,
|
|
43
43
|
)
|