Skip to content

Commit

Permalink
remove endpoint-utils package (#8217)
Browse files Browse the repository at this point in the history
<!--
Thank you for your contribution.

Before making a PR, please read our contributing guidelines at

https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution

We recommend creating a *draft* PR, so that you can mark it as 'ready
for review' when you are done.
-->

## Purpose
_Describe the problem you want to address or the feature you want to
implement._

## Approach
_Describe how your changes address the issue or implement the desired
functionality in as much detail as possible._

## References
closes #8207

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail

---------

Co-authored-by: Bayheck <[email protected]>
Co-authored-by: Popov Aleksey <[email protected]>
  • Loading branch information
3 people authored Jun 25, 2024
1 parent 4d0bc30 commit ff478f3
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 106 deletions.
6 changes: 0 additions & 6 deletions @types/endpoint-utils/index.d.ts

This file was deleted.

127 changes: 41 additions & 86 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"@babel/runtime": "^7.23.2",
"@devexpress/bin-v8-flags-filter": "^1.3.0",
"@devexpress/callsite-record": "^4.1.6",
"@types/node": "^12.20.10",
"@types/node": "^20.14.5",
"address": "^2.0.2",
"async-exit-hook": "^1.1.2",
"babel-plugin-module-resolver": "5.0.0",
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
Expand All @@ -98,7 +99,6 @@
"elegant-spinner": "^1.0.1",
"email-validator": "^2.0.4",
"emittery": "^0.4.1",
"endpoint-utils": "^1.0.2",
"error-stack-parser": "^2.1.4",
"execa": "^4.0.3",
"get-os-info": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getFreePort } from 'endpoint-utils';
import { getFreePort } from '../../../../../utils/endpoint-utils';
import createTempProfile from './create-temp-profile';
import isDocker from 'is-docker';
import isPodman from 'is-podman';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getFreePort } from 'endpoint-utils';
import { getFreePort } from '../../../../../utils/endpoint-utils';
import createTempProfile from './create-temp-profile';


Expand Down
21 changes: 15 additions & 6 deletions src/configuration/utils.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
import { GeneralError } from '../errors/runtime';
import { RUNTIME_ERRORS } from '../errors/types';
import endpointUtils from 'endpoint-utils';
import {
isMyHostname,
getIPAddress,
isFreePort,
getFreePort,
} from '../utils/endpoint-utils';

export async function getValidHostname (hostname: string): Promise<string> {
if (hostname) {
const valid = await endpointUtils.isMyHostname(hostname);
const valid = await isMyHostname(hostname);

if (!valid)
throw new GeneralError(RUNTIME_ERRORS.invalidHostname, hostname);
}
else
hostname = endpointUtils.getIPAddress();
else {
hostname = getIPAddress() ?? '';

if (!hostname)
throw new GeneralError(RUNTIME_ERRORS.invalidHostname, hostname);
}

return hostname;
}

export async function getValidPort (port: number): Promise<number> {
if (port) {
const isFree = await endpointUtils.isFreePort(port);
const isFree = await isFreePort(port);

if (!isFree)
throw new GeneralError(RUNTIME_ERRORS.portIsNotFree, port);
}
else
port = await endpointUtils.getFreePort();
port = await getFreePort();

return port;
}
2 changes: 1 addition & 1 deletion src/runner/tested-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class TestedApp {
public async kill (): Promise<void> {
this._killed = true;

const killPromise = new Promise(resolve => kill((this._process as ChildProcess).pid, 'SIGTERM', resolve));
const killPromise = new Promise(resolve => kill((this._process as ChildProcess).pid ?? 0, 'SIGTERM', resolve));

await killPromise;
}
Expand Down
Loading

0 comments on commit ff478f3

Please sign in to comment.