Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
feat: automate port number selection (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
domjtalbot authored Aug 14, 2022
1 parent 329c391 commit 5e436b8
Show file tree
Hide file tree
Showing 45 changed files with 392 additions and 134 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-planets-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nx-plugin-graphql-mesh': minor
---

Add automatic port selection for `dev`, `start` & `serve` executors
14 changes: 7 additions & 7 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ jobs:
env:
NX_CLOUD_ENV_NAME: node-${{ matrix.node }}
outputs:
affected: ${{ steps.affected.affected }}
affectedLength: ${{ steps.affected.affectedLength }}
affectedApps: ${{ steps.affected.affectedApps }}
affectedAppsLength: ${{ steps.affected.affectedAppsLength }}
affectedLibs: ${{ steps.affected.affectedLibs }}
affectedLibsLength: ${{ steps.affected.affectedLibsLength }}
affected: ${{ steps.affected.outputs.affected }}
affectedLength: ${{ steps.affected.outputs.affectedLength }}
affectedApps: ${{ steps.affected.outputs.affectedApps }}
affectedAppsLength: ${{ steps.affected.outputs.affectedAppsLength }}
affectedLibs: ${{ steps.affected.outputs.affectedLibs }}
affectedLibsLength: ${{ steps.affected.outputs.affectedLibsLength }}
hasAffected: ${{ steps.affected.outputs.hasAffected }}
steps:
- name: Check out repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
Expand All @@ -82,7 +83,6 @@ jobs:

- name: Affected
id: affected
if: matrix.node == 'lts'
uses: ./.github/actions/nx-affected

- name: Workspace Lint
Expand Down
59 changes: 40 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,19 @@ This is the equifilent of using `graphql-mesh dev`.

#### Options

| Name | Type | Required | Default | Description |
| ------------- | ---------- | :------: | ------- | ------------------------------------------------------------------------------------------- |
| **`debug`** | `boolean` | - | `false` | Display debugging info by applying the `DEBUG` env variable. |
| **`dir`** | `string` || - | The path of the directory containing the GraphQL Mesh config. |
| **`port`** | `number` | - | `4000` | The port number to run on. |
| **`require`** | `string[]` | - | `[]` | Loads specific require.extensions before running the codegen and reading the configuration. |
| Name | Type | Required | Default | Description |
| --------------------- | -------------- | :------: | --------- | -------------------------------------------------------------------------------------------------- |
| **`debug`** | `boolean` | - | `false` | Display debugging info by applying the `DEBUG` env variable. |
| **`dir`** | `string` || - | The path of the directory containing the GraphQL Mesh config. |
| **`port`** | `object` | - | - | Port selection settings |
| **`port.auto`** | `boolean` | - | `true` | Use the first available port |
| **`port.number`** | `number` | - | `4200` | Define the preferred port to use when `auto` is set to `false` |
| **`port.range`** | `object` | - | - | The range of ports to select from. |
| **`port.range.from`** | `boolean` | - | - | The first port of the range. Must be in the range `1024`...`65535` |
| **`port.range.to`** | `boolean` | - | - | The last port of the range. Must be in the range `1024`...`65535` and must be greater than `from`. |
| **`port.fallback`** | `auto`, `none` | - | `auto` | The fallback strategy to use when the preferred port is unavailable. |
| **`port.host`** | `string` | - | `0.0.0.0` | The host to listern on (only used for port number lookup). |
| **`require`** | `string[]` | - | `[]` | Loads specific require.extensions before running the codegen and reading the configuration. |

<br/>

Expand All @@ -326,12 +333,19 @@ This is the equifilent of using `graphql-mesh start`.

#### Options

| Name | Type | Required | Default | Description |
| ------------- | ---------- | :------: | ------- | ------------------------------------------------------------------------------------------- |
| **`debug`** | `boolean` | - | `false` | Display debugging info by applying the `DEBUG` env variable. |
| **`dir`** | `string` || - | The path of the directory containing the GraphQL Mesh config. |
| **`port`** | `number` | - | `4000` | The port number to run on. |
| **`require`** | `string[]` | - | `[]` | Loads specific require.extensions before running the codegen and reading the configuration. |
| Name | Type | Required | Default | Description |
| --------------------- | -------------- | :------: | --------- | -------------------------------------------------------------------------------------------------- |
| **`debug`** | `boolean` | - | `false` | Display debugging info by applying the `DEBUG` env variable. |
| **`dir`** | `string` || - | The path of the directory containing the GraphQL Mesh config. |
| **`port`** | `object` | - | - | Port selection settings |
| **`port.auto`** | `boolean` | - | `true` | Use the first available port |
| **`port.number`** | `number` | - | `4200` | Define the preferred port to use when `auto` is set to `false` |
| **`port.range`** | `object` | - | - | The range of ports to select from. |
| **`port.range.from`** | `boolean` | - | - | The first port of the range. Must be in the range `1024`...`65535` |
| **`port.range.to`** | `boolean` | - | - | The last port of the range. Must be in the range `1024`...`65535` and must be greater than `from`. |
| **`port.fallback`** | `auto`, `none` | - | `auto` | The fallback strategy to use when the preferred port is unavailable. |
| **`port.host`** | `string` | - | `0.0.0.0` | The host to listern on (only used for port number lookup). |
| **`require`** | `string[]` | - | `[]` | Loads specific require.extensions before running the codegen and reading the configuration. |

<br/>

Expand Down Expand Up @@ -360,13 +374,20 @@ This combines `dev` & `start` via a `dev` option toggle.

#### Options

| Name | Type | Required | Default | Description |
| ------------- | ---------- | :------: | ------- | ------------------------------------------------------------------------------------------- |
| **`debug`** | `boolean` | - | `false` | Display debugging info by applying the `DEBUG` env variable. |
| **`dev`** | `string` | - | `false` | Run the server in dev or production mode. |
| **`dir`** | `string` || - | The path of the directory containing the GraphQL Mesh config. |
| **`port`** | `number` | - | `4000` | The port number to run on. |
| **`require`** | `string[]` | - | `[]` | Loads specific require.extensions before running the codegen and reading the configuration. |
| Name | Type | Required | Default | Description |
| --------------------- | -------------- | :------: | --------- | -------------------------------------------------------------------------------------------------- |
| **`debug`** | `boolean` | - | `false` | Display debugging info by applying the `DEBUG` env variable. |
| **`dev`** | `string` | - | `false` | Run the server in dev or production mode. |
| **`dir`** | `string` || - | The path of the directory containing the GraphQL Mesh config. |
| **`port`** | `object` | - | - | Port selection settings |
| **`port.auto`** | `boolean` | - | `true` | Use the first available port |
| **`port.number`** | `number` | - | `4200` | Define the preferred port to use when `auto` is set to `false` |
| **`port.range`** | `object` | - | - | The range of ports to select from. |
| **`port.range.from`** | `boolean` | - | - | The first port of the range. Must be in the range `1024`...`65535` |
| **`port.range.to`** | `boolean` | - | - | The last port of the range. Must be in the range `1024`...`65535` and must be greater than `from`. |
| **`port.fallback`** | `auto`, `none` | - | `auto` | The fallback strategy to use when the preferred port is unavailable. |
| **`port.host`** | `string` | - | `0.0.0.0` | The host to listern on (only used for port number lookup). |
| **`require`** | `string[]` | - | `[]` | Loads specific require.extensions before running the codegen and reading the configuration. |

<br/>

Expand Down
3 changes: 1 addition & 2 deletions apps/api-gateway/javascript-wiki/cjs-config/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"executor": "@domjtalbot/nx-plugin-graphql-mesh:serve",
"options": {
"dev": true,
"dir": "apps/api-gateway/javascript-wiki/cjs-config",
"port": 4800
"dir": "apps/api-gateway/javascript-wiki/cjs-config"
},
"configurations": {
"production": {
Expand Down
3 changes: 1 addition & 2 deletions apps/api-gateway/javascript-wiki/js-config/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"executor": "@domjtalbot/nx-plugin-graphql-mesh:serve",
"options": {
"dev": true,
"dir": "apps/api-gateway/javascript-wiki/js-config",
"port": 4801
"dir": "apps/api-gateway/javascript-wiki/js-config"
},
"configurations": {
"production": {
Expand Down
3 changes: 1 addition & 2 deletions apps/api-gateway/javascript-wiki/json-config/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"executor": "@domjtalbot/nx-plugin-graphql-mesh:serve",
"options": {
"dev": true,
"dir": "apps/api-gateway/javascript-wiki/json-config",
"port": 4802
"dir": "apps/api-gateway/javascript-wiki/json-config"
},
"configurations": {
"production": {
Expand Down
3 changes: 1 addition & 2 deletions apps/api-gateway/javascript-wiki/yml-config/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"executor": "@domjtalbot/nx-plugin-graphql-mesh:serve",
"options": {
"dev": true,
"dir": "apps/api-gateway/javascript-wiki/yml-config",
"port": 4803
"dir": "apps/api-gateway/javascript-wiki/yml-config"
},
"configurations": {
"production": {
Expand Down
16 changes: 5 additions & 11 deletions apps/api-gateway/stackexchange/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,34 @@
"executor": "@domjtalbot/nx-plugin-graphql-mesh:serve",
"options": {
"dir": "apps/api-gateway/stackexchange",
"port": 4700,
"dev": true
},
"configurations": {
"production": {
"dir": "dist/apps/api-gateway/stackexchange",
"dev": false,
"port": 5200
"dev": false
}
}
},
"dev": {
"executor": "@domjtalbot/nx-plugin-graphql-mesh:dev",
"options": {
"dir": "apps/api-gateway/stackexchange",
"port": 4500
"dir": "apps/api-gateway/stackexchange"
},
"configurations": {
"e2e": {
"debug": false,
"port": 4700
"debug": false
}
}
},
"start": {
"executor": "@domjtalbot/nx-plugin-graphql-mesh:start",
"options": {
"dir": "dist/apps/api-gateway/stackexchange",
"port": 5200
"dir": "dist/apps/api-gateway/stackexchange"
},
"configurations": {
"e2e": {
"debug": false,
"port": 5201
"debug": false
}
},
"dependsOn": [
Expand Down
21 changes: 9 additions & 12 deletions apps/api-gateway/trippin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,37 @@
"executor": "@domjtalbot/nx-plugin-graphql-mesh:serve",
"options": {
"dir": "apps/api-gateway/trippin",
"port": 5001,
"dev": true
"dev": true,
"port": {
"host": "localhost"
}
},
"configurations": {
"production": {
"dir": "dist/apps/api-gateway/trippin",
"dev": false,
"port": 5100
"dev": false
}
}
},
"dev": {
"executor": "@domjtalbot/nx-plugin-graphql-mesh:dev",
"options": {
"dir": "apps/api-gateway/trippin",
"port": 4500
"dir": "apps/api-gateway/trippin"
},
"configurations": {
"e2e": {
"debug": false,
"port": 5001
"debug": false
}
}
},
"start": {
"executor": "@domjtalbot/nx-plugin-graphql-mesh:start",
"options": {
"dir": "dist/apps/api-gateway/trippin",
"port": 5100
"dir": "dist/apps/api-gateway/trippin"
},
"configurations": {
"e2e": {
"debug": false,
"port": 5101
"debug": false
}
},
"dependsOn": [
Expand Down
16 changes: 5 additions & 11 deletions apps/api-gateway/weatherbit/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,34 @@
"executor": "@domjtalbot/nx-plugin-graphql-mesh:serve",
"options": {
"dir": "apps/api-gateway/weatherbit",
"port": 4600,
"dev": true
},
"configurations": {
"production": {
"dir": "dist/apps/api-gateway/weatherbit",
"dev": false,
"port": 5300
"dev": false
}
}
},
"dev": {
"executor": "@domjtalbot/nx-plugin-graphql-mesh:dev",
"options": {
"dir": "apps/api-gateway/weatherbit",
"port": 4500
"dir": "apps/api-gateway/weatherbit"
},
"configurations": {
"e2e": {
"debug": false,
"port": 4600
"debug": false
}
}
},
"start": {
"executor": "@domjtalbot/nx-plugin-graphql-mesh:start",
"options": {
"dir": "dist/apps/api-gateway/weatherbit",
"port": 5300
"dir": "dist/apps/api-gateway/weatherbit"
},
"configurations": {
"e2e": {
"debug": false,
"port": 5301
"debug": false
}
},
"dependsOn": [
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/javascript-wiki-swc/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"defaultConfiguration": "development",
"options": {
"buildTarget": "nextjs-javascript-wiki-swc:build",
"dev": true
"dev": true,
"port": 4800
},
"configurations": {
"development": {
Expand All @@ -30,8 +31,7 @@
},
"e2e": {
"buildTarget": "nextjs-javascript-wiki-swc:build:production",
"dev": false,
"port": 4900
"dev": false
},
"production": {
"buildTarget": "nextjs-javascript-wiki-swc:build:production",
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/javascript-wiki/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"defaultConfiguration": "development",
"options": {
"buildTarget": "nextjs-javascript-wiki:build",
"dev": true
"dev": true,
"port": 5000
},
"configurations": {
"development": {
Expand All @@ -30,8 +31,7 @@
},
"e2e": {
"buildTarget": "nextjs-javascript-wiki:build:production",
"dev": false,
"port": 4900
"dev": false
},
"production": {
"buildTarget": "nextjs-javascript-wiki:build:production",
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/stackexchange/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"defaultConfiguration": "development",
"options": {
"buildTarget": "nextjs-stackexchange:build",
"dev": true
"dev": true,
"port": 4700
},
"configurations": {
"development": {
Expand All @@ -30,8 +31,7 @@
},
"e2e": {
"buildTarget": "nextjs-stackexchange:build:production",
"dev": false,
"port": 5002
"dev": false
},
"production": {
"buildTarget": "nextjs-stackexchange:build:production",
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/trippin-swc/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"defaultConfiguration": "development",
"options": {
"buildTarget": "nextjs-trippin-swc:build",
"dev": true
"dev": true,
"port": 4500
},
"configurations": {
"development": {
Expand All @@ -30,8 +31,7 @@
},
"e2e": {
"buildTarget": "nextjs-trippin:build:production",
"dev": false,
"port": 4300
"dev": false
},
"production": {
"buildTarget": "nextjs-trippin-swc:build:production",
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/trippin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"defaultConfiguration": "development",
"options": {
"buildTarget": "nextjs-trippin:build",
"dev": true
"dev": true,
"port": 4600
},
"configurations": {
"development": {
Expand All @@ -30,8 +31,7 @@
},
"e2e": {
"buildTarget": "nextjs-trippin:build:production",
"dev": false,
"port": 4900
"dev": false
},
"production": {
"buildTarget": "nextjs-trippin:build:production",
Expand Down
Loading

0 comments on commit 5e436b8

Please sign in to comment.