diff --git a/package.json b/package.json index 22172e8..ed6ae1a 100644 --- a/package.json +++ b/package.json @@ -32,13 +32,13 @@ "express-session": "^1.15.6", "forever-monitor": "^1.7.1", "fs-extra": "^8.0.0", + "get-port": "^5.1.1", "hot-shots": "^6.3.0", "http-proxy": "^1.17.0", "jest": "^24.0.0", "lodash": "^4.17.10", "node-fetch": "^2.2.1", "nodegit": "^0.26.5", - "portfinder": "^1.0.16", "react": "^16.4.2", "react-dom": "^16.4.2", "strip-ansi": "^5.0.0", diff --git a/src/api.ts b/src/api.ts index ed3678f..81deb9e 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,7 +1,7 @@ import httpProxy from 'http-proxy'; import Docker, { ImageInfo } from 'dockerode'; import _ from 'lodash'; -import portfinder from 'portfinder'; +import getPort from 'get-port'; import git from 'nodegit'; import fs from 'fs-extra'; import path from 'path'; @@ -187,7 +187,7 @@ export async function startContainer( commitHash: CommitHash, env: RunEnv ) { // ok, try to start one let freePort: number; try { - freePort = await portfinder.getPortPromise(); + freePort = await getPort(); } catch ( err ) { l.error( { err, image, commitHash }, @@ -571,7 +571,7 @@ export async function proxyRequestToContainer( req: any, res: any, container: Co * Pulls an image. Calls onProgress() when there is an update, resolves the returned promise * when the image is pulled */ -export async function pullImage( imageName: ImageName, onProgress: ( data: any ) => void ) { +export async function pullImage( imageName: ImageName, onProgress: ( data: any ) => void ):Promise { // Store the stream in memory, so other requets can "join" and listen for the progress if ( ! state.pullingImages.has( imageName ) ) { const stream = docker.pull( imageName, {} ) as Promise< DockerodeStream >; @@ -620,7 +620,7 @@ export async function createContainer( imageName: ImageName, env: RunEnv ) { let freePort: number; try { - freePort = await portfinder.getPortPromise(); + freePort = await getPort(); } catch ( err ) { l.error( { err, imageName }, `Error while attempting to find a free port for ${ imageName }` ); throw err; diff --git a/yarn.lock b/yarn.lock index e7feec9..c2f5555 100644 --- a/yarn.lock +++ b/yarn.lock @@ -738,13 +738,6 @@ async@0.2.x, async@~0.2.9: resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" integrity sha1-trvgsGdLnXGXCMo43owjfLUmw9E= -async@^2.6.2: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== - dependencies: - lodash "^4.17.14" - asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -1251,7 +1244,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@^3.0.0, debug@^3.1.1, debug@^3.2.6: +debug@^3.0.0, debug@^3.2.6: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== @@ -1900,6 +1893,11 @@ get-caller-file@^2.0.1: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== +get-port@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/get-port/-/get-port-5.1.1.tgz#0469ed07563479de6efb986baf053dcd7d4e3193" + integrity sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ== + get-stream@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" @@ -3770,15 +3768,6 @@ pn@^1.1.0: resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" integrity sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA== -portfinder@^1.0.16: - version "1.0.25" - resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.25.tgz#254fd337ffba869f4b9d37edc298059cb4d35eca" - integrity sha512-6ElJnHBbxVA1XSLgBp7G1FiCkQdlqGzuF7DswL5tcea+E8UpuvPU7beVAjjRwCioTS9ZluNbu+ZyRvgTsmqEBg== - dependencies: - async "^2.6.2" - debug "^3.1.1" - mkdirp "^0.5.1" - posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"