Skip to content

Commit

Permalink
chore: make build:schema script self-sufficient (#3222)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedsalk authored Sep 27, 2024
1 parent f243b7b commit 502c89e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .changeset/serious-crabs-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: make `build:schema` script self-sufficient
1 change: 1 addition & 0 deletions .knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@types/rimraf",
"@graphql-codegen*",
"graphql-tag",
"get-graphql-schema",
"events",
"eslint-plugin-jsdoc",
"eslint-plugin-jsx-a11y",
Expand Down
2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
15 changes: 15 additions & 0 deletions packages/account/scripts/generate-fuel-core-schema.mts
Original file line number Diff line number Diff line change
@@ -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}`,
);
17 changes: 0 additions & 17 deletions packages/account/test/fuel-core-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);

Expand Down

0 comments on commit 502c89e

Please sign in to comment.