From 362625041b69c81e3d8931da024fcc6300ad2511 Mon Sep 17 00:00:00 2001 From: Vicente Eduardo Ferrer Garcia Date: Sun, 19 Apr 2026 20:06:45 +0200 Subject: [PATCH 1/2] Trying to solve issues with delete. --- package-lock.json | 96 ++++++++++++++--------------------------------- package.json | 6 +-- src/test/cli.ts | 91 ++++++++++++++------------------------------ 3 files changed, 59 insertions(+), 134 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8ed57dd..d9463a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,21 +28,18 @@ "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/archiver": "^3.1.1", - "@types/concat-stream": "^2.0.0", - "@types/cross-spawn": "^6.0.2", "@types/ini": "^1.3.30", "@types/inquirer": "^8.2.12", "@types/mocha": "^8.2.2", - "@types/node": "^14.14.7", + "@types/node": "^18.19.130", "@typescript-eslint/eslint-plugin": "^5.11.0", "@typescript-eslint/parser": "^5.11.0", - "concat-stream": "^2.0.0", - "cross-spawn": "^7.0.3", "eslint": "^7.13.0", "eslint-config-prettier": "^6.15.0", "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-tsdoc": "^0.2.7", "mocha": "^9.2.0", + "node-pty": "^1.1.0", "nyc": "^15.1.0", "prettier": "^2.1.2", "typescript": "^4.3.2" @@ -787,16 +784,6 @@ "@types/glob": "*" } }, - "node_modules/@types/concat-stream": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-2.0.3.tgz", - "integrity": "sha512-3qe4oQAPNwVNwK4C9c8u+VJqv9kez+2MR4qJpoPFfXtgxxif1QbFusvXzK0/Wra2VX07smostI2VMmJNSpZjuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/cross-spawn": { "version": "6.0.6", "resolved": "https://registry.npmjs.org/@types/cross-spawn/-/cross-spawn-6.0.6.tgz", @@ -858,11 +845,13 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "14.18.63", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.63.tgz", - "integrity": "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==", - "dev": true, - "license": "MIT" + "version": "18.19.130", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz", + "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==", + "devOptional": true, + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@types/semver": { "version": "7.7.1", @@ -1518,13 +1507,6 @@ "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true, - "license": "MIT" - }, "node_modules/caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -1888,22 +1870,6 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "license": "MIT" }, - "node_modules/concat-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", - "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", - "dev": true, - "engines": [ - "node >= 6.0" - ], - "license": "MIT", - "dependencies": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.0.2", - "typedarray": "^0.0.6" - } - }, "node_modules/console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", @@ -3120,17 +3086,6 @@ } } }, - "node_modules/inquirer/node_modules/@types/node": { - "version": "25.5.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.5.2.tgz", - "integrity": "sha512-tO4ZIRKNC+MDWV4qKVZe3Ql/woTnmHDr5JD8UI5hn2pwBrHEwOEMZK7WlNb5RKB6EoJ02gwmQS9OrjuFnZYdpg==", - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "undici-types": "~7.18.0" - } - }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -3992,6 +3947,12 @@ "dev": true, "license": "MIT" }, + "node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "dev": true + }, "node_modules/node-preload": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", @@ -4005,6 +3966,16 @@ "node": ">=8" } }, + "node_modules/node-pty": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/node-pty/-/node-pty-1.1.0.tgz", + "integrity": "sha512-20JqtutY6JPXTUnL0ij1uad7Qe1baT46lyolh2sSENDd4sTzKZ4nmAFkeAARDKwmlLjPx6XKRlwRUxwjOy+lUg==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "node-addon-api": "^7.1.0" + } + }, "node_modules/node-releases": { "version": "2.0.37", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.37.tgz", @@ -5249,13 +5220,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", - "dev": true, - "license": "MIT" - }, "node_modules/typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", @@ -5290,12 +5254,10 @@ } }, "node_modules/undici-types": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", - "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", - "license": "MIT", - "optional": true, - "peer": true + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "devOptional": true }, "node_modules/update-browserslist-db": { "version": "1.2.3", diff --git a/package.json b/package.json index 31a5139..5a93024 100644 --- a/package.json +++ b/package.json @@ -109,21 +109,19 @@ "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/archiver": "^3.1.1", - "@types/concat-stream": "^2.0.0", "@types/cross-spawn": "^6.0.2", "@types/ini": "^1.3.30", "@types/inquirer": "^8.2.12", "@types/mocha": "^8.2.2", - "@types/node": "^14.14.7", + "@types/node": "^18.19.130", "@typescript-eslint/eslint-plugin": "^5.11.0", "@typescript-eslint/parser": "^5.11.0", - "concat-stream": "^2.0.0", - "cross-spawn": "^7.0.3", "eslint": "^7.13.0", "eslint-config-prettier": "^6.15.0", "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-tsdoc": "^0.2.7", "mocha": "^9.2.0", + "node-pty": "^1.1.0", "nyc": "^15.1.0", "prettier": "^2.1.2", "typescript": "^4.3.2" diff --git a/src/test/cli.ts b/src/test/cli.ts index 7b11b37..acac944 100644 --- a/src/test/cli.ts +++ b/src/test/cli.ts @@ -1,13 +1,13 @@ import API from '@metacall/protocol/protocol'; import { fail } from 'assert'; -import concat from 'concat-stream'; -import spawn from 'cross-spawn'; import * as dotenv from 'dotenv'; import { existsSync } from 'fs'; import fs from 'fs/promises'; import inspector from 'inspector'; +import * as pty from 'node-pty'; import os from 'os'; import { join } from 'path'; +import { stripVTControlCharacters } from 'util'; import args from '../cli/args'; import { configFilePath } from '../config'; import { startup } from '../startup'; @@ -19,9 +19,6 @@ dotenv.config(); process.env.NODE_ENV = 'testing'; process.env.METACALL_DEPLOY_INTERACTIVE = 'true'; -const PATH = process.env.PATH; -const HOME = process.env.HOME; - export const isInDebugMode = () => inspector.url() !== undefined; export const run = ( @@ -36,20 +33,18 @@ export const run = ( // TODO: Implement this properly for better debugging /* const debugArgs = isInDebugMode() ? ['--inspect-brk=0'] : []; */ - const child = spawn('node', [/*...debugArgs,*/ path, ...args], { - env: Object.assign( - { - NODE_ENV: 'test', - PATH, - HOME - }, - env - ), - stdio: [null, null, null, 'ipc'] + const child = pty.spawn('node', [/*...debugArgs,*/ path, ...args], { + name: 'xterm-color', + cols: 80, + rows: 30, + cwd: process.cwd(), + env: { + ...process.env, + NODE_ENV: 'test', + ...env + } }); - child.stdin?.setDefaultEncoding('utf-8'); - return child; }; @@ -60,59 +55,29 @@ export const runWithInput = ( env: Record = {} ) => { const child = run(path, args, env); - let childTimeout: NodeJS.Timeout, killTimeout: NodeJS.Timeout; - - const loop = (inputs: string[]) => { - if (killTimeout) { - clearTimeout(killTimeout); - } - - if ( - inputs.length === 0 || - (inputs.length > 0 && inputs[0] === keys.kill) - ) { - child.stdin?.end(); - - killTimeout = setTimeout(() => { - child.kill(os.constants.signals.SIGTERM); - }, 3000); - - return; - } - - childTimeout = setTimeout(() => { - child.stdin?.cork(); - child.stdin?.write(inputs.shift()); - child.stdin?.uncork(); - loop(inputs); - }, 3000); - }; return { promise: new Promise((resolve, reject) => { - child.stderr?.once('data', err => { - child.stdin?.end(); + let output = ''; - if (childTimeout) { - clearTimeout(childTimeout); - inputs = []; - } - reject(String(err)); + child.onData(data => { + output += stripVTControlCharacters(data); }); - child.on('error', reject); - - loop(inputs); - - child.stdout?.pipe( - concat(result => { - if (killTimeout) { - clearTimeout(killTimeout); - } + child.onExit(({ exitCode }) => { + if (exitCode === 0) { + resolve(output); + } else { + reject({ + output, + exitCode + }); + } + }); - resolve(result.toString()); - }) - ); + for (const input of inputs) { + child.write(input); + } }), child }; From d253d5c7e33ec47950615ff009c19263af8d015d Mon Sep 17 00:00:00 2001 From: Vicente Eduardo Ferrer Garcia Date: Sun, 19 Apr 2026 20:10:47 +0200 Subject: [PATCH 2/2] Enable production tests. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a36c0b..caaa50b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: run: npm run build - name: Run Tests (production) - if: github.event_name != 'pull_request' + # if: github.event_name != 'pull_request' run: | echo 'METACALL_AUTH_EMAIL="${{ secrets.METACALL_AUTH_EMAIL }}"' > .env echo 'METACALL_AUTH_PASSWORD="${{ secrets.METACALL_AUTH_PASSWORD }}"' >> .env