Skip to content

Commit 308cb8a

Browse files
authored
fix: point to new examples (#1329)
* fix: point to new example repo * legacy reasons * account for new path * Apply suggestions from code review
1 parent 7202035 commit 308cb8a

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

.changeset/ninety-maps-remember.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphprotocol/graph-cli': patch
3+
---
4+
5+
Point to new examples repo instead of old

packages/cli/src/commands/init.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import AddCommand from './add';
2424
const protocolChoices = Array.from(Protocol.availableProtocols().keys());
2525
const availableNetworks = Protocol.availableNetworks();
2626

27-
const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum/gravatar';
27+
const DEFAULT_EXAMPLE_SUBGRAPH = 'ethereum-gravatar';
2828

2929
export default class InitCommand extends Command {
3030
static description = 'Creates a new subgraph with basic scaffolding.';
@@ -824,15 +824,18 @@ async function initSubgraphFromExample(
824824
const tmpDir = fs.mkdtempSync(prefix);
825825

826826
try {
827-
await system.run(`git clone http://github.com/graphprotocol/example-subgraphs ${tmpDir}`);
827+
await system.run(`git clone https://github.com/graphprotocol/graph-tooling ${tmpDir}`);
828828

829829
// If an example is not specified, use the default one
830830
if (fromExample === undefined || fromExample === true) {
831831
fromExample = DEFAULT_EXAMPLE_SUBGRAPH;
832832
}
833+
// Legacy purposes when everything existed in examples repo
834+
if (fromExample === 'ethereum/gravatar') {
835+
fromExample = DEFAULT_EXAMPLE_SUBGRAPH;
836+
}
833837

834-
const exampleSubgraphPath = path.join(tmpDir, String(fromExample));
835-
838+
const exampleSubgraphPath = path.join(tmpDir, 'examples', String(fromExample));
836839
if (!filesystem.exists(exampleSubgraphPath)) {
837840
return { result: false, error: `Example not found: ${fromExample}` };
838841
}

packages/cli/src/subgraph.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export default class Subgraph {
100100
static validateRepository(manifest: immutable.Collection<any, any>) {
101101
const repository = manifest.get('repository');
102102

103-
return /^https:\/\/github\.com\/graphprotocol\/example-subgraphs?$/.test(repository)
103+
return /^https:\/\/github\.com\/graphprotocol\/graph-tooling?$/.test(repository) ||
104+
// For legacy reasons, we should error on example subgraphs
105+
/^https:\/\/github\.com\/graphprotocol\/example-subgraphs?$/.test(repository)
104106
? immutable.List().push(
105107
immutable.fromJS({
106108
path: ['repository'],

packages/cli/tests/cli/add/expected/subgraph.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
specVersion: 0.0.5
22
description: Gravatar for Ethereum
3-
repository: https://github.com/graphprotocol/example-subgraph
3+
repository: https://github.com/graphprotocol/graph-tooling
44
schema:
55
file: ./schema.graphql
66
dataSources:

packages/cli/tests/cli/add/subgraph/subgraph.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
specVersion: 0.0.5
22
description: Gravatar for Ethereum
3-
repository: https://github.com/graphprotocol/example-subgraph
3+
repository: https://github.com/graphprotocol/graph-tooling
44
schema:
55
file: ./schema.graphql
66
dataSources:

packages/cli/tests/cli/validation/example-values-found.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
⚠ Warnings while loading subgraph from subgraph.yaml: Warnings in subgraph.yaml:
33

44
Path: repository
5-
The repository is still set to https://github.com/graphprotocol/example-subgraph.
5+
The repository is still set to https://github.com/graphprotocol/graph-tooling.
66
Please replace it with a link to your subgraph source code.
77

88
Path: description

packages/cli/tests/cli/validation/example-values-found/subgraph.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
specVersion: 0.0.1
2-
repository: https://github.com/graphprotocol/example-subgraph
2+
repository: https://github.com/graphprotocol/graph-tooling
33
description: Gravatar for Ethereum
44
schema:
55
file: ./schema.graphql

0 commit comments

Comments
 (0)