diff --git a/.changeset/@graphprotocol_graph-cli-1502-dependencies.md b/.changeset/@graphprotocol_graph-cli-1502-dependencies.md new file mode 100644 index 000000000..100a68212 --- /dev/null +++ b/.changeset/@graphprotocol_graph-cli-1502-dependencies.md @@ -0,0 +1,5 @@ +--- +"@graphprotocol/graph-cli": patch +--- +dependencies updates: + - Added dependency [`@graphprotocol/graph-ts@^0.31.0` ↗︎](https://www.npmjs.com/package/@graphprotocol/graph-ts/v/0.31.0) (to `dependencies`) diff --git a/.changeset/stale-peaches-cover.md b/.changeset/stale-peaches-cover.md new file mode 100644 index 000000000..5d3cdbc14 --- /dev/null +++ b/.changeset/stale-peaches-cover.md @@ -0,0 +1,6 @@ +--- +'@graphprotocol/graph-cli': minor +--- + +remove the need of node_modules instead make `graph-ts` dependency for CLI allowing us to bundle +everything in one package diff --git a/packages/cli/package.json b/packages/cli/package.json index 691bc75b8..ee742943c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -29,6 +29,7 @@ }, "dependencies": { "@float-capital/float-subgraph-uncrashable": "^0.0.0-alpha.4", + "@graphprotocol/graph-ts": "^0.31.0", "@oclif/core": "2.8.6", "@oclif/plugin-autocomplete": "^2.3.6", "@oclif/plugin-not-found": "^2.4.0", diff --git a/packages/cli/src/compiler/index.ts b/packages/cli/src/compiler/index.ts index 95ed0d8b0..4e5aed56f 100644 --- a/packages/cli/src/compiler/index.ts +++ b/packages/cli/src/compiler/index.ts @@ -31,12 +31,6 @@ export default class Compiler { private sourceDir: string; private blockIpfsMethods?: RegExpMatchArray; private libsDirs: string[]; - /** - * Path to the global.ts file in the graph-ts package. - * - * @note if you are using substreams as a protocol, this will be undefined. - */ - private globalsFile?: string; private protocol: Protocol; private ABI: any; @@ -53,35 +47,6 @@ export default class Compiler { return; } - for ( - let dir: string | undefined = path.resolve(this.sourceDir); - // Terminate after the root dir or when we have found node_modules - dir !== undefined; - // Continue with the parent directory, terminate after the root dir - dir = path.dirname(dir) === dir ? undefined : path.dirname(dir) - ) { - if (fs.existsSync(path.join(dir, 'node_modules'))) { - this.libsDirs.push(path.join(dir, 'node_modules')); - } - } - - if (this.libsDirs.length === 0) { - throw Error(`could not locate \`node_modules\` in parent directories of subgraph manifest`); - } - - const globalsFile = path.join('@graphprotocol', 'graph-ts', 'global', 'global.ts'); - const globalsLib = this.libsDirs.find(item => { - return fs.existsSync(path.join(item, globalsFile)); - }); - - if (!globalsLib) { - throw Error( - 'Could not locate `@graphprotocol/graph-ts` package in parent directories of subgraph manifest.', - ); - } - - this.globalsFile = path.join(globalsLib, globalsFile); - process.on('uncaughtException', e => { toolbox.print.error(`UNCAUGHT EXCEPTION: ${e}`); }); @@ -383,12 +348,8 @@ export default class Compiler { fs.mkdirsSync(path.dirname(outFile)); const libs = this.libsDirs.join(','); - if (!this.globalsFile) { - throw Error( - 'Could not locate `@graphprotocol/graph-ts` package in parent directories of subgraph manifest.', - ); - } - const global = path.relative(baseDir, this.globalsFile); + const global = require.resolve('@graphprotocol/graph-ts/global/global.ts'); + compilerDebug('Global: %s', global); asc.compile({ inputFile, @@ -464,12 +425,8 @@ export default class Compiler { fs.mkdirsSync(path.dirname(outFile)); const libs = this.libsDirs.join(','); - if (!this.globalsFile) { - throw Error( - 'Could not locate `@graphprotocol/graph-ts` package in parent directories of subgraph manifest.', - ); - } - const global = path.relative(baseDir, this.globalsFile); + const global = require.resolve('@graphprotocol/graph-ts/global/global.ts'); + compilerDebug('Global: %s', global); asc.compile({ inputFile, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ef2530964..72be4e24b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + patchedDependencies: oclif@3.8.1: hash: rxmtqiusuyruv7tkwux5gvotbm @@ -49,7 +53,7 @@ importers: examples/arweave-blocks-transactions: devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -65,7 +69,7 @@ importers: version: 6.26.0 devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -84,7 +88,7 @@ importers: version: 6.26.0 devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -103,7 +107,7 @@ importers: version: 6.26.0 devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -122,7 +126,7 @@ importers: version: 6.26.0 devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -174,7 +178,7 @@ importers: version: 5.0.4 devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -192,7 +196,7 @@ importers: examples/ethereum-gravatar: devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -213,7 +217,7 @@ importers: examples/matic-lens-protocol-posts-subgraph: dependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -226,7 +230,7 @@ importers: examples/near-blocks: devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -235,7 +239,7 @@ importers: examples/near-receipts: devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli '@graphprotocol/graph-ts': specifier: 0.31.0 @@ -244,7 +248,7 @@ importers: examples/substreams-powered-subgraph: devDependencies: '@graphprotocol/graph-cli': - specifier: 0.60.0 + specifier: 0.61.0 version: link:../../packages/cli packages/cli: @@ -252,6 +256,9 @@ importers: '@float-capital/float-subgraph-uncrashable': specifier: ^0.0.0-alpha.4 version: 0.0.0-alpha.6 + '@graphprotocol/graph-ts': + specifier: ^0.31.0 + version: link:../ts '@oclif/core': specifier: 2.8.6 version: 2.8.6(@types/node@20.6.2)(typescript@5.0.2) @@ -14831,7 +14838,3 @@ packages: /zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} dev: true - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false