@graphprotocol/graph-cli 0.37.2 → 0.37.3-alpha-20230110163550-d64bef6
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 +7 -0
- package/babel.config.js +3 -0
- package/dist/bin.js +6 -0
- package/dist/cli.js +32 -0
- package/dist/codegen/schema.js +250 -0
- package/dist/codegen/schema.test.js +458 -0
- package/dist/codegen/template.js +65 -0
- package/dist/codegen/types/conversions.js +359 -0
- package/dist/codegen/types/index.js +71 -0
- package/dist/codegen/types/index.test.js +563 -0
- package/dist/codegen/typescript.js +200 -0
- package/dist/codegen/util.js +46 -0
- package/dist/codegen/util.test.js +93 -0
- package/dist/command-helpers/abi.js +78 -0
- package/dist/command-helpers/auth.js +77 -0
- package/dist/command-helpers/compiler.js +66 -0
- package/dist/command-helpers/data-sources.js +29 -0
- package/dist/command-helpers/fs.js +9 -0
- package/dist/command-helpers/gluegun.js +49 -0
- package/dist/command-helpers/ipfs.js +5 -0
- package/dist/command-helpers/jsonrpc.js +29 -0
- package/dist/command-helpers/network.js +93 -0
- package/dist/command-helpers/network.test.js +86 -0
- package/dist/command-helpers/node.js +40 -0
- package/dist/command-helpers/scaffold.js +112 -0
- package/dist/command-helpers/spinner.js +84 -0
- package/dist/command-helpers/studio.js +13 -0
- package/dist/command-helpers/studio.test.js +41 -0
- package/dist/command-helpers/subgraph.js +24 -0
- package/dist/command-helpers/version.js +74 -0
- package/dist/command-helpers/version.test.js +179 -0
- package/dist/commands/add.js +190 -0
- package/dist/commands/auth.js +127 -0
- package/dist/commands/build.js +140 -0
- package/dist/commands/codegen.js +135 -0
- package/dist/commands/create.js +86 -0
- package/dist/commands/deploy.js +334 -0
- package/dist/commands/init.js +788 -0
- package/dist/commands/local.js +387 -0
- package/dist/commands/remove.js +86 -0
- package/dist/commands/test.js +295 -0
- package/dist/compiler/asc.js +83 -0
- package/dist/compiler/index.js +474 -0
- package/dist/debug.js +16 -0
- package/dist/migrations/mapping_api_version_0_0_1.js +78 -0
- package/dist/migrations/mapping_api_version_0_0_2.js +76 -0
- package/dist/migrations/mapping_api_version_0_0_3.js +78 -0
- package/dist/migrations/mapping_api_version_0_0_4.js +80 -0
- package/dist/migrations/mapping_api_version_0_0_5.js +80 -0
- package/dist/migrations/spec_version_0_0_2.js +49 -0
- package/dist/migrations/spec_version_0_0_3.js +54 -0
- package/dist/migrations/util/load-manifest.js +18 -0
- package/dist/migrations/util/versions.js +29 -0
- package/dist/migrations.js +56 -0
- package/dist/protocols/arweave/manifest.graphql +57 -0
- package/dist/protocols/arweave/scaffold/manifest.js +18 -0
- package/dist/protocols/arweave/scaffold/mapping.js +52 -0
- package/dist/protocols/arweave/subgraph.js +23 -0
- package/dist/protocols/cosmos/manifest.graphql +76 -0
- package/dist/protocols/cosmos/scaffold/manifest.js +15 -0
- package/dist/protocols/cosmos/scaffold/mapping.js +38 -0
- package/dist/protocols/cosmos/subgraph.js +25 -0
- package/dist/protocols/ethereum/abi.js +140 -0
- package/dist/protocols/ethereum/codegen/abi.js +451 -0
- package/dist/protocols/ethereum/codegen/abi.test.js +328 -0
- package/dist/protocols/ethereum/codegen/template.js +50 -0
- package/dist/protocols/ethereum/contract.js +20 -0
- package/dist/protocols/ethereum/manifest.graphql +94 -0
- package/dist/protocols/ethereum/scaffold/manifest.js +32 -0
- package/dist/protocols/ethereum/scaffold/mapping.js +65 -0
- package/dist/protocols/ethereum/subgraph.js +171 -0
- package/dist/protocols/ethereum/type-generator.js +125 -0
- package/dist/protocols/index.js +268 -0
- package/dist/protocols/ipfs/codegen/file_template.js +50 -0
- package/dist/protocols/near/contract.js +41 -0
- package/dist/protocols/near/manifest.graphql +64 -0
- package/dist/protocols/near/scaffold/manifest.js +16 -0
- package/dist/protocols/near/scaffold/mapping.js +38 -0
- package/dist/protocols/near/subgraph.js +20 -0
- package/dist/protocols/subgraph.js +2 -0
- package/dist/protocols/substreams/manifest.graphql +45 -0
- package/dist/protocols/substreams/scaffold/manifest.js +12 -0
- package/dist/protocols/substreams/subgraph.js +23 -0
- package/dist/scaffold/cosmos.test.js +83 -0
- package/dist/scaffold/ethereum.test.js +505 -0
- package/dist/scaffold/index.js +128 -0
- package/dist/scaffold/mapping.js +61 -0
- package/dist/scaffold/near.test.js +86 -0
- package/dist/scaffold/schema.js +83 -0
- package/dist/scaffold/tests.js +175 -0
- package/dist/schema.js +54 -0
- package/dist/subgraph.js +249 -0
- package/dist/type-generator.js +224 -0
- package/dist/validation/contract.js +46 -0
- package/dist/validation/index.js +8 -0
- package/dist/validation/manifest.js +271 -0
- package/dist/validation/schema.js +796 -0
- package/dist/validation/schema.test.js +35 -0
- package/dist/watcher.js +79 -0
- package/jest.config.js +1 -1
- package/package.json +16 -9
- package/{bin/graph → src/bin.ts} +2 -1
- package/src/cli.ts +36 -0
- package/src/codegen/schema.js +23 -22
- package/src/codegen/schema.test.js +33 -27
- package/src/codegen/{template.js → template.ts} +8 -6
- package/src/codegen/types/conversions.ts +382 -0
- package/src/codegen/types/index.js +4 -7
- package/src/codegen/types/index.test.js +10 -4
- package/src/codegen/{typescript.js → typescript.ts} +44 -26
- package/src/codegen/util.js +1 -1
- package/src/codegen/util.test.js +5 -2
- package/src/command-helpers/abi.js +46 -30
- package/src/command-helpers/auth.js +6 -9
- package/src/command-helpers/compiler.js +4 -6
- package/src/command-helpers/data-sources.js +8 -11
- package/src/command-helpers/fs.ts +5 -0
- package/src/command-helpers/gluegun.js +2 -4
- package/src/command-helpers/ipfs.ts +3 -0
- package/src/command-helpers/{jsonrpc.js → jsonrpc.ts} +11 -16
- package/src/command-helpers/network.js +58 -44
- package/src/command-helpers/network.test.js +23 -19
- package/src/command-helpers/node.js +3 -7
- package/src/command-helpers/scaffold.js +34 -25
- package/src/command-helpers/{spinner.js → spinner.ts} +10 -10
- package/src/command-helpers/studio.test.js +61 -30
- package/src/command-helpers/studio.ts +20 -0
- package/src/command-helpers/{subgraph.js → subgraph.ts} +6 -6
- package/src/command-helpers/version.js +11 -16
- package/src/command-helpers/version.test.js +111 -82
- package/src/commands/add.js +49 -35
- package/src/commands/auth.js +13 -25
- package/src/commands/build.js +9 -9
- package/src/commands/codegen.js +12 -12
- package/src/commands/create.js +22 -22
- package/src/commands/deploy.js +39 -34
- package/src/commands/init.js +21 -24
- package/src/commands/local.js +15 -14
- package/src/commands/remove.js +22 -22
- package/src/commands/test.js +86 -70
- package/src/compiler/{asc.js → asc.ts} +29 -16
- package/src/compiler/index.js +18 -18
- package/src/{debug.js → debug.ts} +2 -2
- package/src/migrations/mapping_api_version_0_0_1.js +7 -7
- package/src/migrations/mapping_api_version_0_0_2.js +5 -5
- package/src/migrations/mapping_api_version_0_0_3.js +7 -7
- package/src/migrations/mapping_api_version_0_0_4.js +7 -7
- package/src/migrations/mapping_api_version_0_0_5.js +7 -7
- package/src/migrations/spec_version_0_0_2.js +5 -5
- package/src/migrations/spec_version_0_0_3.js +5 -5
- package/src/migrations/util/load-manifest.js +6 -9
- package/src/migrations/util/versions.js +5 -10
- package/src/{migrations.js → migrations.ts} +14 -15
- package/src/protocols/arweave/scaffold/manifest.js +1 -4
- package/src/protocols/arweave/scaffold/mapping.js +1 -3
- package/src/protocols/arweave/subgraph.ts +22 -0
- package/src/protocols/cosmos/scaffold/manifest.js +1 -4
- package/src/protocols/cosmos/scaffold/mapping.js +1 -3
- package/src/protocols/cosmos/subgraph.js +2 -2
- package/src/protocols/ethereum/abi.js +7 -13
- package/src/protocols/ethereum/codegen/abi.js +219 -222
- package/src/protocols/ethereum/codegen/abi.test.js +6 -6
- package/src/protocols/ethereum/codegen/template.js +3 -5
- package/src/protocols/ethereum/contract.js +3 -2
- package/src/protocols/ethereum/scaffold/manifest.js +4 -7
- package/src/protocols/ethereum/scaffold/mapping.js +4 -11
- package/src/protocols/ethereum/subgraph.js +21 -20
- package/src/protocols/ethereum/type-generator.js +24 -30
- package/src/protocols/{index.js → index.ts} +65 -46
- package/src/protocols/ipfs/codegen/file_template.js +2 -2
- package/src/protocols/near/{contract.js → contract.ts} +16 -12
- package/src/protocols/near/scaffold/manifest.js +2 -5
- package/src/protocols/near/scaffold/mapping.js +1 -3
- package/src/protocols/near/subgraph.js +3 -6
- package/src/protocols/subgraph.ts +12 -0
- package/src/protocols/substreams/scaffold/{manifest.js → manifest.ts} +2 -7
- package/src/protocols/substreams/subgraph.ts +22 -0
- package/src/scaffold/cosmos.test.js +3 -3
- package/src/scaffold/ethereum.test.js +4 -4
- package/src/scaffold/index.js +7 -7
- package/src/scaffold/mapping.js +3 -3
- package/src/scaffold/near.test.js +3 -3
- package/src/scaffold/schema.js +4 -4
- package/src/scaffold/tests.js +72 -58
- package/src/schema.ts +26 -0
- package/src/{subgraph.js → subgraph.ts} +80 -60
- package/src/type-generator.js +20 -20
- package/src/validation/contract.js +2 -6
- package/src/validation/index.js +1 -1
- package/src/validation/manifest.js +24 -22
- package/src/validation/schema.test.js +1 -1
- package/src/validation/{schema.js → schema.ts} +268 -221
- package/src/{watcher.js → watcher.ts} +23 -12
- package/tests/cli/globalSetup.js +2 -2
- package/tests/cli/globalTeardown.js +2 -2
- package/tests/cli/init.test.js +2 -2
- package/tests/cli/util.js +7 -13
- package/tsconfig.json +18 -0
- package/src/cli.js +0 -38
- package/src/codegen/types/conversions.js +0 -329
- package/src/command-helpers/fs.js +0 -8
- package/src/command-helpers/ipfs.js +0 -6
- package/src/command-helpers/studio.js +0 -15
- package/src/protocols/arweave/subgraph.js +0 -20
- package/src/protocols/substreams/subgraph.js +0 -17
- package/src/schema.js +0 -23
|
@@ -1,52 +1,83 @@
|
|
|
1
|
-
|
|
1
|
+
import { validateStudioNetwork, allowedStudioNetworks } from './studio'
|
|
2
2
|
|
|
3
3
|
describe('Version Command Helpers', () => {
|
|
4
4
|
describe('validateStudioNetwork', () => {
|
|
5
5
|
describe("When it's studio", () => {
|
|
6
6
|
test("And it's Ethereum mainnet", () => {
|
|
7
|
-
expect(() =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
expect(() =>
|
|
8
|
+
validateStudioNetwork({
|
|
9
|
+
studio: true,
|
|
10
|
+
network: 'mainnet',
|
|
11
|
+
}),
|
|
12
|
+
).not.toThrow(
|
|
13
|
+
new Error(
|
|
14
|
+
`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
|
|
15
|
+
', ',
|
|
16
|
+
)}`,
|
|
17
|
+
),
|
|
18
|
+
)
|
|
13
19
|
})
|
|
14
20
|
|
|
15
21
|
test("And it's Gnosis chain", () => {
|
|
16
|
-
expect(() =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
expect(() =>
|
|
23
|
+
validateStudioNetwork({
|
|
24
|
+
studio: true,
|
|
25
|
+
network: 'gnosis',
|
|
26
|
+
}),
|
|
27
|
+
).not.toThrow(
|
|
28
|
+
new Error(
|
|
29
|
+
`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
|
|
30
|
+
', ',
|
|
31
|
+
)}`,
|
|
32
|
+
),
|
|
33
|
+
)
|
|
22
34
|
})
|
|
23
35
|
|
|
24
36
|
test("And it's NOT an allowed network", () => {
|
|
25
|
-
expect(() =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
expect(() =>
|
|
38
|
+
validateStudioNetwork({
|
|
39
|
+
product: 'subgraph-studio',
|
|
40
|
+
network: 'celo',
|
|
41
|
+
}),
|
|
42
|
+
).toThrow(
|
|
43
|
+
new Error(
|
|
44
|
+
`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
|
|
45
|
+
', ',
|
|
46
|
+
)}`,
|
|
47
|
+
),
|
|
48
|
+
)
|
|
30
49
|
})
|
|
31
50
|
})
|
|
32
51
|
|
|
33
52
|
describe("When it's NOT studio", () => {
|
|
34
53
|
test("And it's Rinkeby", () => {
|
|
35
|
-
expect(() =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
expect(() =>
|
|
55
|
+
validateStudioNetwork({
|
|
56
|
+
studio: false,
|
|
57
|
+
network: 'rinkeby',
|
|
58
|
+
}),
|
|
59
|
+
).not.toThrow(
|
|
60
|
+
new Error(
|
|
61
|
+
`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
|
|
62
|
+
', ',
|
|
63
|
+
)}`,
|
|
64
|
+
),
|
|
65
|
+
)
|
|
41
66
|
})
|
|
42
67
|
|
|
43
68
|
test("And it's NOT an allowed network", () => {
|
|
44
|
-
expect(() =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
69
|
+
expect(() =>
|
|
70
|
+
validateStudioNetwork({
|
|
71
|
+
product: 'hosted-service',
|
|
72
|
+
network: 'celo',
|
|
73
|
+
}),
|
|
74
|
+
).not.toThrow(
|
|
75
|
+
new Error(
|
|
76
|
+
`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
|
|
77
|
+
', ',
|
|
78
|
+
)}`,
|
|
79
|
+
),
|
|
80
|
+
)
|
|
50
81
|
})
|
|
51
82
|
})
|
|
52
83
|
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const allowedStudioNetworks = ['mainnet', 'rinkeby', 'goerli', 'gnosis'] as const
|
|
2
|
+
|
|
3
|
+
const validateStudioNetwork = ({ studio, product, network }:{
|
|
4
|
+
studio?: boolean
|
|
5
|
+
product?: 'subgraph-studio'
|
|
6
|
+
network: typeof allowedStudioNetworks[number]
|
|
7
|
+
}) => {
|
|
8
|
+
let isStudio = studio || product === 'subgraph-studio'
|
|
9
|
+
let isAllowedNetwork = allowedStudioNetworks.includes(network)
|
|
10
|
+
|
|
11
|
+
if (isStudio && !isAllowedNetwork) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
|
|
14
|
+
', ',
|
|
15
|
+
)}`,
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { allowedStudioNetworks, validateStudioNetwork }
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
const validateSubgraphName = (
|
|
1
|
+
const validateSubgraphName = (
|
|
2
|
+
name: string,
|
|
3
|
+
{ allowSimpleName }: { allowSimpleName: string },
|
|
4
|
+
) => {
|
|
2
5
|
if (allowSimpleName) {
|
|
3
6
|
return name
|
|
4
7
|
} else {
|
|
@@ -13,12 +16,9 @@ You can bypass this check with --allow-simple-name.`)
|
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
const getSubgraphBasename = name => {
|
|
19
|
+
const getSubgraphBasename = (name: string) => {
|
|
17
20
|
let segments = name.split('/', 2)
|
|
18
21
|
return segments[segments.length - 1]
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
validateSubgraphName,
|
|
23
|
-
getSubgraphBasename,
|
|
24
|
-
}
|
|
24
|
+
export { validateSubgraphName, getSubgraphBasename }
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import semver from 'semver'
|
|
2
|
+
import * as graphTsUtil from '../migrations/util/versions'
|
|
3
|
+
import * as manifestUtil from '../migrations/util/load-manifest'
|
|
4
4
|
|
|
5
5
|
const assertManifestApiVersion = async (manifestPath, minimumApiVersion) => {
|
|
6
6
|
let manifest = await manifestUtil.loadManifest(manifestPath)
|
|
7
7
|
|
|
8
8
|
let lessThanMinimumVersion = manifestApiVersion =>
|
|
9
|
-
semver.lt(
|
|
10
|
-
manifestApiVersion,
|
|
11
|
-
minimumApiVersion,
|
|
12
|
-
)
|
|
9
|
+
semver.lt(manifestApiVersion, minimumApiVersion)
|
|
13
10
|
|
|
14
11
|
let isLessThanMinimumVersion = false
|
|
15
12
|
|
|
@@ -20,25 +17,26 @@ const assertManifestApiVersion = async (manifestPath, minimumApiVersion) => {
|
|
|
20
17
|
dataSource &&
|
|
21
18
|
dataSource.mapping &&
|
|
22
19
|
dataSource.mapping.apiVersion &&
|
|
23
|
-
lessThanMinimumVersion(dataSource.mapping.apiVersion)
|
|
20
|
+
lessThanMinimumVersion(dataSource.mapping.apiVersion),
|
|
24
21
|
)
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
if (manifest.templates && Array.isArray(manifest.templates)) {
|
|
28
|
-
isLessThanMinimumVersion =
|
|
25
|
+
isLessThanMinimumVersion =
|
|
26
|
+
isLessThanMinimumVersion ||
|
|
29
27
|
manifest.templates.some(
|
|
30
28
|
template =>
|
|
31
29
|
template &&
|
|
32
30
|
template.mapping &&
|
|
33
31
|
template.mapping.apiVersion &&
|
|
34
|
-
lessThanMinimumVersion(template.mapping.apiVersion)
|
|
32
|
+
lessThanMinimumVersion(template.mapping.apiVersion),
|
|
35
33
|
)
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
if (isLessThanMinimumVersion) {
|
|
40
38
|
throw new Error(
|
|
41
|
-
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'
|
|
39
|
+
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
|
|
42
40
|
)
|
|
43
41
|
}
|
|
44
42
|
}
|
|
@@ -57,12 +55,9 @@ const assertGraphTsVersion = async (sourceDir, minimumGraphTsVersion) => {
|
|
|
57
55
|
if (graphTsVersion && semver.lt(semver.coerce(graphTsVersion), minimumGraphTsVersion)) {
|
|
58
56
|
throw new Error(
|
|
59
57
|
`To use this version of the graph-cli you must upgrade the graph-ts dependency to a version greater than or equal to ${minimumGraphTsVersion}
|
|
60
|
-
Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide
|
|
58
|
+
Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`,
|
|
61
59
|
)
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
assertManifestApiVersion,
|
|
67
|
-
assertGraphTsVersion,
|
|
68
|
-
}
|
|
63
|
+
export { assertManifestApiVersion, assertGraphTsVersion }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { assertManifestApiVersion, assertGraphTsVersion } from './version'
|
|
2
|
+
import * as loadManifestUtil from '../migrations/util/load-manifest'
|
|
3
|
+
import * as graphTsUtil from '../migrations/util/versions'
|
|
4
4
|
|
|
5
5
|
describe('Version Command Helpers', () => {
|
|
6
6
|
describe('assertManifestApiVersion', () => {
|
|
@@ -9,57 +9,64 @@ describe('Version Command Helpers', () => {
|
|
|
9
9
|
|
|
10
10
|
describe('With just dataSources', () => {
|
|
11
11
|
test('When all of them are less than minimum apiVersion', async () => {
|
|
12
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
13
|
-
|
|
12
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
13
|
+
Promise.resolve({
|
|
14
14
|
dataSources: [
|
|
15
15
|
{ mapping: { apiVersion: '0.0.1' } },
|
|
16
16
|
{ mapping: { apiVersion: '0.0.2' } },
|
|
17
17
|
{ mapping: { apiVersion: '0.0.3' } },
|
|
18
18
|
],
|
|
19
|
-
})
|
|
19
|
+
}),
|
|
20
|
+
)
|
|
20
21
|
|
|
21
|
-
await expect(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
await expect(
|
|
23
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
24
|
+
).rejects.toThrow(
|
|
25
|
+
new Error(
|
|
26
|
+
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
|
|
27
|
+
),
|
|
28
|
+
)
|
|
26
29
|
})
|
|
27
30
|
test('When one of them is less than minimum apiVersion', async () => {
|
|
28
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
29
|
-
|
|
31
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
32
|
+
Promise.resolve({
|
|
30
33
|
dataSources: [
|
|
31
34
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
32
35
|
{ mapping: { apiVersion: '0.0.2' } },
|
|
33
36
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
34
37
|
],
|
|
35
|
-
})
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
36
40
|
|
|
37
|
-
await expect(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
await expect(
|
|
42
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
43
|
+
).rejects.toThrow(
|
|
44
|
+
new Error(
|
|
45
|
+
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
|
|
46
|
+
),
|
|
47
|
+
)
|
|
42
48
|
})
|
|
43
49
|
test('When none of them are less than minimum apiVersion', async () => {
|
|
44
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
45
|
-
|
|
50
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
51
|
+
Promise.resolve({
|
|
46
52
|
dataSources: [
|
|
47
53
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
48
54
|
{ mapping: { apiVersion: '0.0.6' } },
|
|
49
55
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
50
56
|
],
|
|
51
|
-
})
|
|
57
|
+
}),
|
|
58
|
+
)
|
|
52
59
|
|
|
53
|
-
await expect(
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
await expect(
|
|
61
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
62
|
+
).resolves.toBe(undefined)
|
|
56
63
|
})
|
|
57
64
|
})
|
|
58
65
|
describe('With dataSources and templates', () => {
|
|
59
66
|
describe('And the dataSources have a lower apiVersion', () => {
|
|
60
67
|
test('When all of the templates are less than minimum apiVersion', async () => {
|
|
61
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
62
|
-
|
|
68
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
69
|
+
Promise.resolve({
|
|
63
70
|
dataSources: [
|
|
64
71
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
65
72
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
@@ -70,17 +77,20 @@ describe('Version Command Helpers', () => {
|
|
|
70
77
|
{ mapping: { apiVersion: '0.0.2' } },
|
|
71
78
|
{ mapping: { apiVersion: '0.0.3' } },
|
|
72
79
|
],
|
|
73
|
-
})
|
|
80
|
+
}),
|
|
81
|
+
)
|
|
74
82
|
|
|
75
|
-
await expect(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
await expect(
|
|
84
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
85
|
+
).rejects.toThrow(
|
|
86
|
+
new Error(
|
|
87
|
+
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
|
|
88
|
+
),
|
|
89
|
+
)
|
|
80
90
|
})
|
|
81
91
|
test('When one of the templates is less than minimum apiVersion', async () => {
|
|
82
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
83
|
-
|
|
92
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
93
|
+
Promise.resolve({
|
|
84
94
|
dataSources: [
|
|
85
95
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
86
96
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
@@ -91,17 +101,20 @@ describe('Version Command Helpers', () => {
|
|
|
91
101
|
{ mapping: { apiVersion: '0.0.2' } },
|
|
92
102
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
93
103
|
],
|
|
94
|
-
})
|
|
104
|
+
}),
|
|
105
|
+
)
|
|
95
106
|
|
|
96
|
-
await expect(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
await expect(
|
|
108
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
109
|
+
).rejects.toThrow(
|
|
110
|
+
new Error(
|
|
111
|
+
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
|
|
112
|
+
),
|
|
113
|
+
)
|
|
101
114
|
})
|
|
102
115
|
test('When none of the templates are less than minimum apiVersion', async () => {
|
|
103
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
104
|
-
|
|
116
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
117
|
+
Promise.resolve({
|
|
105
118
|
dataSources: [
|
|
106
119
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
107
120
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
@@ -112,19 +125,22 @@ describe('Version Command Helpers', () => {
|
|
|
112
125
|
{ mapping: { apiVersion: '0.0.6' } },
|
|
113
126
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
114
127
|
],
|
|
115
|
-
})
|
|
128
|
+
}),
|
|
129
|
+
)
|
|
116
130
|
|
|
117
|
-
await expect(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
await expect(
|
|
132
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
133
|
+
).rejects.toThrow(
|
|
134
|
+
new Error(
|
|
135
|
+
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
|
|
136
|
+
),
|
|
137
|
+
)
|
|
122
138
|
})
|
|
123
139
|
})
|
|
124
140
|
describe('And the dataSources do NOT have a lower apiVersion', () => {
|
|
125
141
|
test('When all of the templates are less than minimum apiVersion', async () => {
|
|
126
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
127
|
-
|
|
142
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
143
|
+
Promise.resolve({
|
|
128
144
|
dataSources: [
|
|
129
145
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
130
146
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
@@ -135,17 +151,20 @@ describe('Version Command Helpers', () => {
|
|
|
135
151
|
{ mapping: { apiVersion: '0.0.2' } },
|
|
136
152
|
{ mapping: { apiVersion: '0.0.3' } },
|
|
137
153
|
],
|
|
138
|
-
})
|
|
154
|
+
}),
|
|
155
|
+
)
|
|
139
156
|
|
|
140
|
-
await expect(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
157
|
+
await expect(
|
|
158
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
159
|
+
).rejects.toThrow(
|
|
160
|
+
new Error(
|
|
161
|
+
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
|
|
162
|
+
),
|
|
163
|
+
)
|
|
145
164
|
})
|
|
146
165
|
test('When one of the templates is less than minimum apiVersion', async () => {
|
|
147
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
148
|
-
|
|
166
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
167
|
+
Promise.resolve({
|
|
149
168
|
dataSources: [
|
|
150
169
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
151
170
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
@@ -156,17 +175,20 @@ describe('Version Command Helpers', () => {
|
|
|
156
175
|
{ mapping: { apiVersion: '0.0.2' } },
|
|
157
176
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
158
177
|
],
|
|
159
|
-
})
|
|
178
|
+
}),
|
|
179
|
+
)
|
|
160
180
|
|
|
161
|
-
await expect(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
181
|
+
await expect(
|
|
182
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
183
|
+
).rejects.toThrow(
|
|
184
|
+
new Error(
|
|
185
|
+
`The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
|
|
186
|
+
),
|
|
187
|
+
)
|
|
166
188
|
})
|
|
167
189
|
test('When none of the templates are less than minimum apiVersion', async () => {
|
|
168
|
-
loadManifestUtil.loadManifest = jest.fn()
|
|
169
|
-
|
|
190
|
+
loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
|
|
191
|
+
Promise.resolve({
|
|
170
192
|
dataSources: [
|
|
171
193
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
172
194
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
@@ -177,11 +199,12 @@ describe('Version Command Helpers', () => {
|
|
|
177
199
|
{ mapping: { apiVersion: '0.0.6' } },
|
|
178
200
|
{ mapping: { apiVersion: '0.0.5' } },
|
|
179
201
|
],
|
|
180
|
-
})
|
|
202
|
+
}),
|
|
203
|
+
)
|
|
181
204
|
|
|
182
|
-
await expect(
|
|
183
|
-
|
|
184
|
-
|
|
205
|
+
await expect(
|
|
206
|
+
assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
|
|
207
|
+
).resolves.toBe(undefined)
|
|
185
208
|
})
|
|
186
209
|
})
|
|
187
210
|
})
|
|
@@ -190,22 +213,28 @@ describe('Version Command Helpers', () => {
|
|
|
190
213
|
const fakeNodeModulesDir = 'fake/path/to/node/modules'
|
|
191
214
|
const minimumGraphTsVersion = '0.22.0'
|
|
192
215
|
|
|
193
|
-
test(
|
|
194
|
-
graphTsUtil.getGraphTsVersion = jest
|
|
216
|
+
test("When the installed graph-ts version is less than what's supported", async () => {
|
|
217
|
+
graphTsUtil.getGraphTsVersion = jest
|
|
218
|
+
.fn()
|
|
219
|
+
.mockImplementation(() => Promise.resolve('0.19.0'))
|
|
195
220
|
|
|
196
|
-
await expect(
|
|
197
|
-
|
|
198
|
-
|
|
221
|
+
await expect(
|
|
222
|
+
assertGraphTsVersion(fakeNodeModulesDir, minimumGraphTsVersion),
|
|
223
|
+
).rejects.toThrow(
|
|
224
|
+
new Error(
|
|
199
225
|
`To use this version of the graph-cli you must upgrade the graph-ts dependency to a version greater than or equal to ${minimumGraphTsVersion}
|
|
200
|
-
Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide
|
|
201
|
-
)
|
|
226
|
+
Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`,
|
|
227
|
+
),
|
|
228
|
+
)
|
|
202
229
|
})
|
|
203
230
|
test('When the installed graph-ts version is a supported one', async () => {
|
|
204
|
-
graphTsUtil.getGraphTsVersion = jest
|
|
231
|
+
graphTsUtil.getGraphTsVersion = jest
|
|
232
|
+
.fn()
|
|
233
|
+
.mockImplementation(() => Promise.resolve('0.22.0'))
|
|
205
234
|
|
|
206
|
-
await expect(
|
|
207
|
-
|
|
208
|
-
|
|
235
|
+
await expect(
|
|
236
|
+
assertGraphTsVersion(fakeNodeModulesDir, minimumGraphTsVersion),
|
|
237
|
+
).resolves.toBe(undefined)
|
|
209
238
|
})
|
|
210
239
|
})
|
|
211
240
|
})
|