Skip to content

Commit

Permalink
Correct few things
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela committed Sep 3, 2024
1 parent b71b988 commit 893e341
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gateways/hive/install.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# It's just to install dependencies and make it ready for `run.sh` script
npx --yes @graphql-hive/[email protected].0 --version
npx --yes @graphql-hive/[email protected].1 --version
2 changes: 1 addition & 1 deletion gateways/hive/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
npm start supergraph -- --cwd ./gateways/hive --test $1
npx --yes @graphql-hive/[email protected].0 supergraph supergraph.graphql --port 4000 --fork 1
npx --yes @graphql-hive/[email protected].1 supergraph supergraph.graphql --port 4000 --fork 1
39 changes: 36 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"jest-diff": "29.7.0",
"kill-port-process": "3.2.1",
"wait-on": "7.2.0",
"detect-port": "1.6.1",
"yargs": "17.7.2"
},
"devDependencies": {
Expand All @@ -72,6 +73,7 @@
"@types/node": "20.14.12",
"@types/wait-on": "5.3.4",
"@types/yargs": "17.0.32",
"@types/detect-port": "1.3.5",
"express": "4.19.2",
"prettier": "3.3.3",
"tsx": "4.15.7",
Expand Down
15 changes: 11 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import retry from "async-retry";
import yargs from "yargs";
import waitOn from "wait-on";
import getPort from "get-port";
import detectPort from "detect-port";
import { spawn } from "node:child_process";
import { hideBin } from "yargs/helpers";
import { run } from "node:test";
Expand All @@ -29,7 +30,7 @@ const ext = extname(fileURLToPath(import.meta.url));
const defaultPort = 4200;

function readPort(address: string) {
return new URL(address).port;
return parseInt(new URL(address).port, 10);
}

function resolvePath(
Expand Down Expand Up @@ -183,7 +184,7 @@ yargs(hideBin(process.argv))

process.stdout.write("\n");

await killPortProcess(readPort(argv.graphql)).catch(() => {});
await killPortIfRunning(readPort(argv.graphql)).catch(() => {});

const gatewayExit = Promise.withResolvers<void>();
let gatewayExited = false;
Expand Down Expand Up @@ -273,7 +274,7 @@ yargs(hideBin(process.argv))
mkdirSync(resolvePath(argv, "./logs"));
}

await killPortProcess(readPort(argv.graphql)).catch(() => {});
await killPortIfRunning(readPort(argv.graphql)).catch(() => {});
const logStream = createWriteStream(
resolvePath(argv, `./logs/${argv.test}-gateway.log`),
{
Expand Down Expand Up @@ -397,7 +398,7 @@ yargs(hideBin(process.argv))

process.stdout.write("\n");
for await (const id of ids) {
await killPortProcess(readPort(argv.graphql)).catch(() => {});
await killPortIfRunning(readPort(argv.graphql)).catch(() => {});
const logStream = createWriteStream(
resolvePath(argv, `./logs/${id}-gateway.log`),
{
Expand Down Expand Up @@ -658,3 +659,9 @@ async function waitOnGraphQL(endpoints: {
throw new Error("Failed to fetch __typename");
}
}

async function killPortIfRunning(port: number) {
if (await detectPort(port)) {
await killPortProcess(port);
}
}
4 changes: 2 additions & 2 deletions website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ <h4 class="pt-4 group" id="why">
<a
href="https://the-guild.dev/graphql/hive"
title="Visit GraphQL Hive website"
>Mesh Gateway</a
>Hive Gateway</a
>
(our Gateway for GraphQL Federation, previously known as GraphQL
Mesh), in order to be fully compatible with the Apollo
Expand Down Expand Up @@ -516,7 +516,7 @@ <h4 class="text-lg font-semibold pt-4 group" id="methodology">
href="https://the-guild.dev/graphql/mesh"
title="GraphQL Federation Gateway"
>GraphQL Mesh</a
>
> (now Hive Gateway)
and
<a
href="https://the-guild.dev/graphql/hive"
Expand Down

0 comments on commit 893e341

Please sign in to comment.