Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-spiders-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

Fix `import.meta.url` not being parsed as path properly
4 changes: 3 additions & 1 deletion packages/cli/src/command-helpers/network.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as toolbox from 'gluegun';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import yaml from 'yaml';
import { initNetworksConfig, updateSubgraphNetwork } from './network.js';

const SUBGRAPH_PATH_BASE = path.join(
`${process.platform === 'win32' ? '' : '/'}${/file:\/{2,3}(.+)\/[^/]/.exec(import.meta.url)![1]}`,
fileURLToPath(import.meta.url),
'..',
'..',
'..',
'..',
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChildProcess, spawn } from 'node:child_process';
import http from 'node:http';
import net from 'node:net';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import compose from 'docker-compose';
import { filesystem, patching } from 'gluegun';
import stripAnsi from 'strip-ansi';
Expand Down Expand Up @@ -93,9 +94,8 @@ export default class LocalCommand extends Command {
const composeFile =
composeFileFlag ||
path.join(
`${process.platform === 'win32' ? '' : '/'}${
/file:\/{2,3}(.+)\/[^/]/.exec(import.meta.url)![1]
}`,
fileURLToPath(import.meta.url),
'..',
'..',
'..',
'resources',
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/subgraph.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import fs from 'fs-extra';
import * as graphql from 'graphql/language/index.js';
import immutable from 'immutable';
Expand Down Expand Up @@ -53,7 +54,8 @@ export default class Subgraph {
const schema = graphql.parse(
await fs.readFile(
path.join(
`${process.platform === 'win32' ? '' : '/'}${/file:\/{2,3}(.+)\/[^/]/.exec(import.meta.url)![1]}`,
fileURLToPath(import.meta.url),
'..',
'protocols',
// TODO: substreams/triggers is a special case, should be handled better
protocol.name === 'substreams/triggers' ? 'substreams' : protocol.name,
Expand Down
7 changes: 2 additions & 5 deletions packages/cli/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const packageJson = JSON.parse(
fs
.readFileSync(
// works even when bundled/built because the path to package.json is the same
path.join(
`${process.platform === 'win32' ? '' : '/'}${/file:\/{2,3}(.+)\/[^/]/.exec(import.meta.url)![1]}`,
'..',
'package.json',
),
path.join(fileURLToPath(import.meta.url), '..', '..', 'package.json'),
)
.toString(),
);
Expand Down
Loading