diff --git a/.changeset/serious-crabs-begin.md b/.changeset/serious-crabs-begin.md new file mode 100644 index 00000000000..83b35166bd8 --- /dev/null +++ b/.changeset/serious-crabs-begin.md @@ -0,0 +1,4 @@ +--- +--- + +chore: make `build:schema` script self-sufficient diff --git a/packages/account/package.json b/packages/account/package.json index cb6c7a21ecb..d6a2f093b5d 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -42,7 +42,7 @@ "scripts": { "build": "tsup", "prebuild": "pnpm build:operations", - "build:schema": "get-graphql-schema http://127.0.0.1:4000/v1/graphql > src/providers/fuel-core-schema.graphql && prettier --write src/providers/fuel-core-schema.graphql", + "build:schema": "tsx ./scripts/generate-fuel-core-schema.mts", "build:operations": "pnpm graphql-codegen", "postbuild": "tsx ../../scripts/postbuild.ts" }, diff --git a/packages/account/scripts/generate-fuel-core-schema.mts b/packages/account/scripts/generate-fuel-core-schema.mts new file mode 100644 index 00000000000..be01f771052 --- /dev/null +++ b/packages/account/scripts/generate-fuel-core-schema.mts @@ -0,0 +1,15 @@ +import { execSync } from "child_process"; +import { join } from "path"; + +import { setupTestProviderAndWallets } from "../src/test-utils/setup-test-provider-and-wallets"; + +using launched = await setupTestProviderAndWallets(); + +const accountPackageDir = join(process.cwd(), "packages/account"); +const schemaPath = join( + accountPackageDir, + "src/providers/fuel-core-schema.graphql", +); +execSync( + `cd ${accountPackageDir} && pnpm get-graphql-schema ${launched.provider.url} > ${schemaPath} && prettier --write ${schemaPath}`, +); diff --git a/packages/account/test/fuel-core-schema.test.ts b/packages/account/test/fuel-core-schema.test.ts index 0c55f803bc7..5d737e1e4c3 100644 --- a/packages/account/test/fuel-core-schema.test.ts +++ b/packages/account/test/fuel-core-schema.test.ts @@ -4,8 +4,6 @@ import type { BinaryToTextEncoding } from 'crypto'; import { createHash } from 'crypto'; import { readFile } from 'fs/promises'; -import { setupTestProviderAndWallets } from '../src/test-utils'; - const FUEL_CORE_SCHEMA_FILE_PATH = 'packages/account/src/providers/fuel-core-schema.graphql'; const FUEL_CORE_SCHEMA_SYNC_COMMAND = 'pnpm --filter @fuel-ts/account build:schema'; @@ -23,21 +21,6 @@ function generateChecksum( * @group node */ describe('fuel-core-schema.graphql', () => { - let destroy: () => void; - - beforeEach(async () => { - const { cleanup } = await setupTestProviderAndWallets({ - nodeOptions: { - port: '4000', - }, - }); - destroy = cleanup; - }); - - afterEach(() => { - destroy(); - }); - it('should not change on schema build', async () => { const preSyncChecksum = await readFile(FUEL_CORE_SCHEMA_FILE_PATH).then(generateChecksum);