diff --git a/Dockerfile b/Dockerfile index b9db4c9..3ca816d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16.20.1-alpine +FROM node:18.17.1-alpine RUN apk update && apk upgrade && apk add --no-cache bash mc RUN mkdir -p /debugger @@ -10,7 +10,8 @@ COPY package.json ./ COPY yarn.lock ./ # install cf-runtime required binaries RUN apk add --no-cache --virtual buildDeps make python3 g++ git && \ - yarn install --forzen-lockfile --production + npm update -g npm && \ + yarn install --frozen-lockfile --production RUN yarn cache clean && \ apk del buildDeps && \ diff --git a/package.json b/package.json index 58766c8..e7d20bc 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,13 @@ { "name": "cf-debugger", - "version": "1.3.3", + "version": "1.3.4", "main": "index.js", "license": "MIT", + "resolutions": { + "nan": "2.17.0", + "semver": "7.5.4" + }, "dependencies": { - "node-pty": "git+https://github.com/microsoft/node-pty.git" + "node-pty": "^1.0.0" } } diff --git a/src/app.js b/src/app.js index 3d5dd43..c072301 100644 --- a/src/app.js +++ b/src/app.js @@ -1,16 +1,28 @@ const pty = require('node-pty'); const Resizer = require('./Resizer.js'); +let exit = false; + const shell = pty.spawn('/bin/bash', [], { - name: 'xterm', + name: 'xterm-color', cwd: process.env.PWD, env: process.env }); -shell.on('exit', (code) => { - process.exit(code); + +process.on('uncaughtException', (err) => { + if (exit) { + process.exit(0) + } + console.error(err.message); + console.error(err.stack); }); const resizerStream = new Resizer(shell.resize.bind(shell)); + +shell.on('close', () => { + exit = true +}) + process.stdin .pipe(resizerStream) .pipe(shell) diff --git a/yarn.lock b/yarn.lock index ab5a841..4803d7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,13 +2,33 @@ # yarn lockfile v1 -nan@^2.14.0: - version "2.16.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.16.0.tgz#664f43e45460fb98faf00edca0bb0d7b8dce7916" - integrity sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA== - -"node-pty@git+https://github.com/microsoft/node-pty.git": - version "0.10.0" - resolved "git+https://github.com/microsoft/node-pty.git#1674722e1caf3ff4dd52438b70ed68d46af83a6d" +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== dependencies: - nan "^2.14.0" + yallist "^4.0.0" + +nan@2.17.0, nan@^2.17.0: + version "2.17.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb" + integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ== + +node-pty@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-1.0.0.tgz#7daafc0aca1c4ca3de15c61330373af4af5861fd" + integrity sha512-wtBMWWS7dFZm/VgqElrTvtfMq4GzJ6+edFI0Y0zyzygUSZMgZdraDUMUhCIvkjhJjme15qWmbyJbtAx4ot4uZA== + dependencies: + nan "^2.17.0" + +semver@7.5.4: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==