Skip to content

Commit 74aebdb

Browse files
committed
ci: fix pnpm 10 install for prettier plugins and snapshot job
- Add root .npmrc with public-hoist-pattern for *eslint* and *prettier* so transitive plugins of @theguild/{prettier,eslint}-config remain resolvable from the workspace root. pnpm 10 changed the default public-hoist-pattern from ["*eslint*","*prettier*"] to [], which broke `prettier -c .` with "Cannot find package 'prettier-plugin-sh'". - Drop packageManagerVersion: 9 from publish.yml stable+snapshot jobs. With pnpm/action-setup@v6 it conflicted with the pnpm@10.17.1 pin in package.json, aborting the Snapshot job at setup. - Reformat docs and bin/run.js touched on this branch.
1 parent a0fcbde commit 74aebdb

6 files changed

Lines changed: 76 additions & 70 deletions

File tree

.github/workflows/publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
with:
3737
nodeVersion: 24
3838
packageManager: pnpm
39-
packageManagerVersion: 9
4039

4140
- name: Build
4241
if: ${{ startsWith(github.event.head_commit.message, env.RELEASE_COMMIT_MSG) }}
@@ -95,7 +94,6 @@ jobs:
9594
with:
9695
nodeVersion: 24
9796
packageManager: pnpm
98-
packageManagerVersion: 9
9997

10098
- name: Determine snapshot tag
10199
id: tag

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
public-hoist-pattern[]=*eslint*
2+
public-hoist-pattern[]=*prettier*

CLAUDE.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Tools for building and deploying subgraphs on The Graph Network.
44

55
## Packages
66

7-
| Package | Description | Docs |
8-
|---------|-------------|------|
7+
| Package | Description | Docs |
8+
| -------------------------- | ------------------------------------ | ------------------------------------------------ |
99
| `@graphprotocol/graph-cli` | CLI for init, codegen, build, deploy | [packages/cli/CLAUDE.md](packages/cli/CLAUDE.md) |
10-
| `@graphprotocol/graph-ts` | AssemblyScript library for mappings | [packages/ts/CLAUDE.md](packages/ts/CLAUDE.md) |
10+
| `@graphprotocol/graph-ts` | AssemblyScript library for mappings | [packages/ts/CLAUDE.md](packages/ts/CLAUDE.md) |
1111

1212
## Development Setup
1313

@@ -24,14 +24,14 @@ pnpm build
2424
pnpm build
2525

2626
# Run tests
27-
pnpm test # All packages
28-
pnpm test:cli # CLI only
29-
pnpm test:ts # graph-ts only
27+
pnpm test # All packages
28+
pnpm test:cli # CLI only
29+
pnpm test:ts # graph-ts only
3030

3131
# Code quality
32-
pnpm lint # Check formatting + linting
33-
pnpm lint:fix # Auto-fix issues
34-
pnpm type-check # TypeScript type checking
32+
pnpm lint # Check formatting + linting
33+
pnpm lint:fix # Auto-fix issues
34+
pnpm type-check # TypeScript type checking
3535
```
3636

3737
## Code Style

packages/cli/CLAUDE.md

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,35 @@ src/
3939

4040
## Commands
4141

42-
| Command | Description |
43-
|---------|-------------|
44-
| `init` | Scaffold a new subgraph |
45-
| `codegen` | Generate AssemblyScript types from schema/ABIs |
46-
| `build` | Compile subgraph to WASM |
47-
| `deploy` | Deploy to hosted service or decentralized network |
48-
| `test` | Run matchstick tests |
49-
| `create` | Create subgraph name on node |
50-
| `publish` | Publish to The Graph Network |
51-
| `add` | Add data source to manifest |
52-
| `remove` | Remove data source from manifest |
53-
| `auth` | Set deploy key |
54-
| `local` | Manage local Graph Node (always TS — gnd has no equivalent) |
55-
| `dev` | Run graph-node in dev mode (delegates to `gnd dev`) |
56-
| `clean` | Remove build artifacts |
42+
| Command | Description |
43+
| --------- | ----------------------------------------------------------- |
44+
| `init` | Scaffold a new subgraph |
45+
| `codegen` | Generate AssemblyScript types from schema/ABIs |
46+
| `build` | Compile subgraph to WASM |
47+
| `deploy` | Deploy to hosted service or decentralized network |
48+
| `test` | Run matchstick tests |
49+
| `create` | Create subgraph name on node |
50+
| `publish` | Publish to The Graph Network |
51+
| `add` | Add data source to manifest |
52+
| `remove` | Remove data source from manifest |
53+
| `auth` | Set deploy key |
54+
| `local` | Manage local Graph Node (always TS — gnd has no equivalent) |
55+
| `dev` | Run graph-node in dev mode (delegates to `gnd dev`) |
56+
| `clean` | Remove build artifacts |
5757

5858
## Protocol System
5959

6060
Factory pattern for multi-chain support (`src/protocols/index.ts`):
6161

6262
```typescript
63-
import Protocol from './protocols/index.js';
63+
import Protocol from './protocols/index.js'
6464

65-
const protocol = Protocol.fromDataSources(dataSources);
66-
const manifest = protocol.getManifest();
65+
const protocol = Protocol.fromDataSources(dataSources)
66+
const manifest = protocol.getManifest()
6767
```
6868

6969
Each protocol provides:
70+
7071
- ABI handling and type generation
7172
- Manifest schema and validation
7273
- Scaffolding templates
@@ -75,45 +76,49 @@ Each protocol provides:
7576
## Scaffolding
7677

7778
Templates in `src/scaffold/` generate:
79+
7880
- `subgraph.yaml` manifest
7981
- `schema.graphql` entity definitions
8082
- `src/mapping.ts` event handlers
8183
- Test files
8284

8385
```typescript
84-
import Scaffold from './scaffold/index.js';
86+
import Scaffold from './scaffold/index.js'
8587

8688
const scaffold = new Scaffold({
8789
protocol,
8890
network,
89-
contractName,
91+
contractName
9092
// ...
91-
});
92-
await scaffold.generate();
93+
})
94+
await scaffold.generate()
9395
```
9496

9597
## Type Generation
9698

9799
`src/type-generator.ts` creates AssemblyScript classes from:
100+
98101
- GraphQL schema -> Entity classes
99102
- Contract ABIs -> Event/Call types
100103

101104
## Development
102105

103106
```bash
104-
pnpm build # Compile TypeScript + generate oclif manifest
105-
pnpm test # Run vitest tests
106-
pnpm type-check # TypeScript type checking
107+
pnpm build # Compile TypeScript + generate oclif manifest
108+
pnpm test # Run vitest tests
109+
pnpm type-check # TypeScript type checking
107110
```
108111

109112
### Testing
110113

111114
Uses Vitest with snapshot tests in `tests/`. Key test files:
115+
112116
- `tests/cli/init.test.ts` - Scaffolding tests
113117
- `tests/cli/validation.test.ts` - Manifest validation
114118
- `tests/cli/add.test.ts` - Data source addition
115119

116120
Run specific tests:
121+
117122
```bash
118123
pnpm test:init
119124
pnpm test:validation
@@ -124,15 +129,15 @@ pnpm test:validation
124129
### Command Structure
125130

126131
```typescript
127-
import { Command, Flags } from '@oclif/core';
132+
import { Command, Flags } from '@oclif/core'
128133

129134
export default class MyCommand extends Command {
130135
static flags = {
131-
network: Flags.string({ description: 'Network name' }),
132-
};
136+
network: Flags.string({ description: 'Network name' })
137+
}
133138

134139
async run() {
135-
const { flags } = await this.parse(MyCommand);
140+
const { flags } = await this.parse(MyCommand)
136141
// ...
137142
}
138143
}
@@ -141,10 +146,10 @@ export default class MyCommand extends Command {
141146
### Subgraph Manifest Loading
142147

143148
```typescript
144-
import Subgraph from './subgraph.js';
149+
import Subgraph from './subgraph.js'
145150

146-
const subgraph = await Subgraph.load('subgraph.yaml');
147-
const dataSources = subgraph.get('dataSources');
151+
const subgraph = await Subgraph.load('subgraph.yaml')
152+
const dataSources = subgraph.get('dataSources')
148153
```
149154

150155
## Related

packages/cli/bin/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import process from 'node:process';
33
import semver from 'semver';
44
import { execute } from '@oclif/core';
5-
import { nodeVersion } from '../dist/version.js';
65
import { runGnd } from '../dist/command-helpers/gnd.js';
6+
import { nodeVersion } from '../dist/version.js';
77

88
if (!semver.satisfies(process.version, nodeVersion)) {
99
process.stderr.write(

packages/ts/CLAUDE.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ This library provides types and host interfaces that compile to WASM and run in
2828
## Core Types
2929

3030
```typescript
31-
import { BigInt, BigDecimal, Address, Bytes, Entity } from '@graphprotocol/graph-ts';
31+
import { Address, BigDecimal, BigInt, Bytes, Entity } from '@graphprotocol/graph-ts'
3232

3333
// Number types
34-
let amount = BigInt.fromI32(100);
35-
let price = BigDecimal.fromString("1.5");
34+
let amount = BigInt.fromI32(100)
35+
let price = BigDecimal.fromString('1.5')
3636

3737
// Address (20 bytes)
38-
let addr = Address.fromString("0x...");
38+
let addr = Address.fromString('0x...')
3939

4040
// Binary data
41-
let data = Bytes.fromHexString("0xabcd");
41+
let data = Bytes.fromHexString('0xabcd')
4242
```
4343

4444
## Host Interfaces
@@ -52,9 +52,9 @@ store.set(entity, id, data)
5252
store.remove(entity, id)
5353

5454
// Logging
55-
log.info("Value: {}", [value.toString()])
56-
log.warning("Issue: {}", [msg])
57-
log.error("Failed: {}", [err])
55+
log.info('Value: {}', [value.toString()])
56+
log.warning('Issue: {}', [msg])
57+
log.error('Failed: {}', [err])
5858

5959
// IPFS access
6060
ipfs.cat(hash)
@@ -73,37 +73,37 @@ Entities implement the `Entity` interface for store operations:
7373
```typescript
7474
class Transfer extends Entity {
7575
constructor(id: string) {
76-
super();
77-
this.set("id", Value.fromString(id));
76+
super()
77+
this.set('id', Value.fromString(id))
7878
}
7979

8080
save(): void {
81-
store.set("Transfer", this.get("id")!.toString(), this);
81+
store.set('Transfer', this.get('id')!.toString(), this)
8282
}
8383

8484
static load(id: string): Transfer | null {
85-
return changetype<Transfer | null>(store.get("Transfer", id));
85+
return changetype<Transfer | null>(store.get('Transfer', id))
8686
}
8787
}
8888
```
8989

9090
## Ethereum Types
9191

9292
```typescript
93-
import { ethereum } from '@graphprotocol/graph-ts';
93+
import { ethereum } from '@graphprotocol/graph-ts'
9494

9595
// In event handler
9696
export function handleTransfer(event: ethereum.Event): void {
97-
let block = event.block; // ethereum.Block
98-
let tx = event.transaction; // ethereum.Transaction
99-
let receipt = event.receipt; // ethereum.TransactionReceipt | null
100-
let logIndex = event.logIndex; // BigInt
97+
let block = event.block // ethereum.Block
98+
let tx = event.transaction // ethereum.Transaction
99+
let receipt = event.receipt // ethereum.TransactionReceipt | null
100+
let logIndex = event.logIndex // BigInt
101101
}
102102

103103
// Contract calls
104-
let result = contract.try_balanceOf(address);
104+
let result = contract.try_balanceOf(address)
105105
if (!result.reverted) {
106-
let balance = result.value;
106+
let balance = result.value
107107
}
108108
```
109109

@@ -112,13 +112,14 @@ if (!result.reverted) {
112112
Compiles to WASM via AssemblyScript:
113113

114114
```bash
115-
pnpm build # Outputs index.wasm
116-
pnpm test # Run tests
115+
pnpm build # Outputs index.wasm
116+
pnpm test # Run tests
117117
```
118118

119119
## Relationship to CLI
120120

121121
The `@graphprotocol/graph-cli` package generates code that imports from this library:
122+
122123
- `graph codegen` generates entity classes extending `Entity`
123124
- `graph build` compiles mappings + this library to WASM
124125

@@ -128,21 +129,21 @@ The `@graphprotocol/graph-cli` package generates code that imports from this lib
128129

129130
```typescript
130131
// Generated code uses ethereum.CallResult<T>
131-
let result = contract.try_someFunction();
132+
let result = contract.try_someFunction()
132133
if (result.reverted) {
133-
log.warning("Call reverted", []);
134+
log.warning('Call reverted', [])
134135
} else {
135-
let value = result.value;
136+
let value = result.value
136137
}
137138
```
138139

139140
### Dynamic Data Sources
140141

141142
```typescript
142-
import { DataSourceTemplate } from '@graphprotocol/graph-ts';
143+
import { DataSourceTemplate } from '@graphprotocol/graph-ts'
143144

144145
// Create new data source at runtime
145-
DataSourceTemplate.create("TokenTemplate", [tokenAddress.toHexString()]);
146+
DataSourceTemplate.create('TokenTemplate', [tokenAddress.toHexString()])
146147
```
147148

148149
## Related

0 commit comments

Comments
 (0)