Skip to content

Commit

Permalink
simplify npm commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Sep 13, 2024
1 parent c8bbbcc commit 87b8f0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 38 deletions.
18 changes: 4 additions & 14 deletions codegen/subgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,10 @@ func generateSubgraphEnv(cmd *cobra.Command, args []string) error {
input := fmt.Sprintf(
"Your Subgraph Powered Subtreams is now generated!\n\n" +
"**Now follow the next steps:**\n\n" +
"Open the subgraph directory:\n\n" +
"`cd subgraph`\n\n" +
"Install all the dependencies:\n\n" +
"`npm install`\n\n" +
"Generate AssemblyScript types:\n\n" +
"`npm run codegen`\n\n" +
"Generate protobuf:\n\n" +
"`npm run protogen`\n\n" +
"Build your project:\n\n" +
"`npm run build`\n\n" +
"Create the subgraph:\n\n" +
"`npm run create-local`\n\n" +
"Deploy the subgraph:\n\n" +
"`npm run deploy-local`\n\n",
"`cd subgraph`\n" +
"`npm install`\n" +
"`npm run generate` # generate AssemblyScript and Protobuf bindings\n" +
"`npm run deploy-local` # build and deploy to a local graph-node\n",
)
fmt.Println(ToMarkdown(input))
return nil
Expand Down
28 changes: 9 additions & 19 deletions codegen/templates/subgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,21 @@

_Describe important modules here_


## Develop

```bash
npm install
npm run protogen # Generate protobuf bindings
npm run codegen # Generate subgraph mapping types
npm run build
```

Configure `graph-node` in `.graph-node/config.toml`.
* Make sure that you have a graph-node running locally (or set LOCAL_GRAPH_NODE_HOSTNAME)
* You can use the 'devcontainer' from https://github.com/streamingfast/substreams-starter to set this up for you!

```bash
substreams auth
. ./.substreams.dev # or insert the SUBSTREAMS_API_TOKEN into the `config.toml` file.
```

Once `graph-node` is ready`, run:

```bash
npm run create-local
npm install
npm run generate
npm run deploy-local

# rince and repeat
npm run remove-local
```

### Query a subgraph
## Deploy

In the devcontainer, you can access the port-forwarded `graph-node` instance at: http://localhost:8000/subgraphs/name/{name_of_your_subgraph}/
* To studio: `npm run deploy-studio`
* To the network: `npm run publish`
11 changes: 6 additions & 5 deletions codegen/templates/subgraph/package.json.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"name": "{{ .Name }}",
"license": "Apache-2.0",
"scripts": {
"generate": "npm run codegen && npm run protogen",
"deploy-local": "graph create --node http://${LOCAL_GRAPH_NODE_HOSTNAME:-localhost}:8020/ {{ .Name }} && graph deploy --node http://${LOCAL_GRAPH_NODE_HOSTNAME:-localhost}:8020/ --ipfs http://${LOCAL_IPFS_HOSTNAME:-localhost}:5001 {{ .Name }} --version-label=v0.0.1",

"codegen": "graph codegen",
"protogen": "buf generate --type=\"{{ $.GetOutputProtoPath}}\" ../{{ $.SpkgProjectName}}#format=bin; echo ''; echo '^^^ You can safely ignore warnings about \"non-conform Protobuf generation specification\": they come from the assemblyscript buf plugin'; echo ''",
"build": "graph build",
"create-local": "graph create --node http://${LOCAL_GRAPH_NODE_HOSTNAME:-localhost}:8020/ {{ .Name }}",
"deploy-local": "graph deploy --node http://${LOCAL_GRAPH_NODE_HOSTNAME:-localhost}:8020/ --ipfs http://${LOCAL_IPFS_HOSTNAME:-localhost}:5001 {{ .Name }} --version-label=v0.0.1",
"deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ {{ .Name }}",
"remove-local": "graph remove --node http://${LOCAL_GRAPH_NODE_HOSTNAME:-localhost}:8020/ {{ .Name }}",
"deploy-studio": "graph deploy --node https://api.studio.thegraph.com/deploy/ {{ .Name }}",
"publish": "graph publish",
"test": "graph test",
"remove-local": "graph remove --node http://${LOCAL_GRAPH_NODE_HOSTNAME:-localhost}:8020/ {{ .Name }}"
"test": "graph test"
},
"dependencies": {
"@graphprotocol/graph-cli": "^0.73.0",
Expand Down

0 comments on commit 87b8f0a

Please sign in to comment.