Skip to content

Commit 6f22879

Browse files
authored
Merge pull request #758 from graphprotocol/tiago/api-version-0-0-6-update
apiVersion 0.0.6
2 parents 22d571b + 5d8ba04 commit 6f22879

File tree

7 files changed

+86
-12
lines changed

7 files changed

+86
-12
lines changed

examples/basic-event-handlers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"deploy-test": "../../bin/graph deploy test/basic-event-handlers --version-label v0.0.1 --ipfs http://localhost:15001 --node http://127.0.0.1:18020"
1010
},
1111
"devDependencies": {
12-
"@graphprotocol/graph-ts": "0.23.1",
12+
"@graphprotocol/graph-ts": "0.24.0-alpha.0",
1313
"apollo-fetch": "^0.7.0"
1414
},
1515
"dependencies": {

examples/basic-event-handlers/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@graphprotocol/graph-ts@0.23.1":
6-
version "0.23.1"
7-
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.23.1.tgz#76e595d26ec5672f3778b1d3830e4640a57aec1b"
8-
integrity sha512-pipofvN1LlwLOXrS7IWy8hSBFZzVyVHdLXDpQskl9nKqdbb3chelj4JoVEzCl7klvomDpP84ngLpW17fBh5vww==
5+
"@graphprotocol/graph-ts@0.24.0-alpha.0":
6+
version "0.24.0-alpha.0"
7+
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.24.0-alpha.0.tgz#8fe2b09a123adc5a65c82b823a1cb2d99f3cce2b"
8+
integrity sha512-PLhTMlFMoLZpTqJlKH5f+5VRN3yWmXfssVwWk7uauVeY8IuAWjWB3RNubS574q9uf0QjPKOacekXY5EKRWOzEA==
99
dependencies:
1010
assemblyscript "0.19.10"
1111

examples/example-subgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build-wast": "../../bin/graph build -t wast subgraph.yaml"
88
},
99
"devDependencies": {
10-
"@graphprotocol/graph-ts": "0.23.1"
10+
"@graphprotocol/graph-ts": "0.24.0-alpha.0"
1111
},
1212
"resolutions": {
1313
"assemblyscript": "0.19.10"

examples/example-subgraph/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@graphprotocol/graph-ts@0.23.1":
6-
version "0.23.1"
7-
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.23.1.tgz#76e595d26ec5672f3778b1d3830e4640a57aec1b"
8-
integrity sha512-pipofvN1LlwLOXrS7IWy8hSBFZzVyVHdLXDpQskl9nKqdbb3chelj4JoVEzCl7klvomDpP84ngLpW17fBh5vww==
5+
"@graphprotocol/graph-ts@0.24.0-alpha.0":
6+
version "0.24.0-alpha.0"
7+
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.24.0-alpha.0.tgz#8fe2b09a123adc5a65c82b823a1cb2d99f3cce2b"
8+
integrity sha512-PLhTMlFMoLZpTqJlKH5f+5VRN3yWmXfssVwWk7uauVeY8IuAWjWB3RNubS574q9uf0QjPKOacekXY5EKRWOzEA==
99
dependencies:
1010
assemblyscript "0.19.10"
1111

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphprotocol/graph-cli",
3-
"version": "0.23.2",
3+
"version": "0.24.0-alpha.0",
44
"description": "CLI for building for and deploying to The Graph",
55
"dependencies": {
66
"assemblyscript": "0.19.10",
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const fs = require('fs-extra')
2+
const semver = require('semver')
3+
const toolbox = require('gluegun/toolbox')
4+
const yaml = require('js-yaml')
5+
const { loadManifest } = require('./util/load-manifest')
6+
const { getGraphTsVersion } = require('./util/versions')
7+
8+
// If any of the manifest apiVersions are 0.0.5, replace them with 0.0.6
9+
module.exports = {
10+
name: 'Bump mapping apiVersion from 0.0.5 to 0.0.6',
11+
predicate: async ({ sourceDir, manifestFile }) => {
12+
// Obtain the graph-ts version, if possible
13+
let graphTsVersion
14+
try {
15+
graphTsVersion = await getGraphTsVersion(sourceDir)
16+
} catch (_) {
17+
// If we cannot obtain the version, return a hint that the graph-ts
18+
// hasn't been installed yet
19+
return 'graph-ts dependency not installed yet'
20+
}
21+
22+
let manifest = loadManifest(manifestFile)
23+
return (
24+
// Only migrate if the graph-ts version is >= 0.23.0...
25+
// Coerce needed because we may be dealing with an alpha version
26+
// and in the `semver` library this would not return true on equality.
27+
semver.gte(semver.coerce(graphTsVersion), '0.24.0') &&
28+
// ...and we have a manifest with mapping > apiVersion = 0.0.5
29+
manifest &&
30+
typeof manifest === 'object' &&
31+
Array.isArray(manifest.dataSources) &&
32+
(manifest.dataSources.reduce(
33+
(hasOldMappings, dataSource) =>
34+
hasOldMappings ||
35+
(typeof dataSource === 'object' &&
36+
dataSource.mapping &&
37+
typeof dataSource.mapping === 'object' &&
38+
dataSource.mapping.apiVersion === '0.0.5'),
39+
false,
40+
) ||
41+
(Array.isArray(manifest.templates) &&
42+
manifest.templates.reduce(
43+
(hasOldMappings, template) =>
44+
hasOldMappings ||
45+
(typeof template === 'object' &&
46+
template.mapping &&
47+
typeof template.mapping === 'object' &&
48+
template.mapping.apiVersion === '0.0.5'),
49+
false,
50+
)))
51+
)
52+
},
53+
apply: async ({ manifestFile }) => {
54+
// Make sure we catch all variants; we could load the manifest
55+
// and replace the values in the data structures here; unfortunately
56+
// writing that back to the file messes with the formatting more than
57+
// we'd like; that's why for now, we use a simple patching approach
58+
await toolbox.patching.replace(
59+
manifestFile,
60+
new RegExp('apiVersion: 0.0.5', 'g'),
61+
'apiVersion: 0.0.6',
62+
)
63+
await toolbox.patching.replace(
64+
manifestFile,
65+
new RegExp("apiVersion: '0.0.5'", 'g'),
66+
"apiVersion: '0.0.6'",
67+
)
68+
await toolbox.patching.replace(
69+
manifestFile,
70+
new RegExp('apiVersion: "0.0.5"', 'g'),
71+
'apiVersion: "0.0.6"',
72+
)
73+
},
74+
}

src/scaffold.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const generatePackageJson = ({ subgraphName, node }) =>
4949
},
5050
dependencies: {
5151
'@graphprotocol/graph-cli': graphCliVersion,
52-
'@graphprotocol/graph-ts': `0.23.1`,
52+
'@graphprotocol/graph-ts': `0.24.0-alpha.0`,
5353
},
5454
}),
5555
{ parser: 'json' },

0 commit comments

Comments
 (0)