Skip to content

Commit

Permalink
chore: make build:schema script self-sufficient
Browse files Browse the repository at this point in the history
  • Loading branch information
nedsalk committed Sep 27, 2024
1 parent 465bd5c commit d176738
Show file tree
Hide file tree
Showing 4 changed files with 20 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
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}`,

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
);
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 d176738

Please sign in to comment.