diff --git a/workspace/package-lock.json b/workspace/package-lock.json index 13a2e58..8905657 100644 --- a/workspace/package-lock.json +++ b/workspace/package-lock.json @@ -1,12 +1,12 @@ { "name": "@aptos-labs/workspace", - "version": "0.0.25", + "version": "0.0.26", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@aptos-labs/workspace", - "version": "0.0.25", + "version": "0.0.26", "license": "Apache-2.0", "dependencies": { "commander": "^12.1.0", diff --git a/workspace/package.json b/workspace/package.json index 29dd43e..69f8e53 100644 --- a/workspace/package.json +++ b/workspace/package.json @@ -1,6 +1,6 @@ { "name": "@aptos-labs/workspace", - "version": "0.0.25", + "version": "0.0.26", "license": "Apache-2.0", "bin": { "aptos-workspace": "./dist/internal/cli.js", diff --git a/workspace/src/internal/node.ts b/workspace/src/internal/node.ts index 0d2b05a..e304c8b 100644 --- a/workspace/src/internal/node.ts +++ b/workspace/src/internal/node.ts @@ -34,7 +34,7 @@ export class TestNode { const cliCommand = "npx"; const cliArgs: string[] = ["aptos", "workspace", "run"]; - const childProcess = spawn(cliCommand, cliArgs, { detached: false, stdio: ['ignore', 'pipe', 'ignore'], shell: true }); + const childProcess = spawn(cliCommand, cliArgs, { detached: false, stdio: ['pipe', 'pipe', 'ignore'], shell: true }); const rl = readline.createInterface({ input: childProcess.stdout, @@ -122,21 +122,23 @@ export class TestNode { public async stop() { await new Promise((resolve, reject) => { - if (!this.info?.process?.pid) return; + if (this.info == null) return; const process = this.info.process; - kill(this.info.process.pid, 'SIGINT', (err) => { - if (err) { - reject(err); - return; - } - process.on('exit', (code, signal) => { - resolve(true) - }); + const timeout = setTimeout(() => { + reject(new Error("workspace server process failed to exit within given timeout (90s)")); + }, 90000); - // TODO: timeout? - }); + try { + process.stdin.write("stop\n"); + + process.on("exit", (code, signal) => { + resolve(true); + }); + } catch (err) { + reject(err); + } }); } } diff --git a/workspace/src/internal/utils/types.ts b/workspace/src/internal/utils/types.ts index 1d7ab22..37e6a2e 100644 --- a/workspace/src/internal/utils/types.ts +++ b/workspace/src/internal/utils/types.ts @@ -1,8 +1,8 @@ import { ChildProcessByStdio, ChildProcessWithoutNullStreams } from "child_process"; -import { Readable } from "stream"; +import { Writable, Readable } from "stream"; export type NodeInfo = { - process: ChildProcessByStdio; + process: ChildProcessByStdio; rest_api_port: number; faucet_port: number; indexer_port: number; diff --git a/workspace/src/tasks/init.ts b/workspace/src/tasks/init.ts index 6fef391..853558d 100644 --- a/workspace/src/tasks/init.ts +++ b/workspace/src/tasks/init.ts @@ -26,6 +26,7 @@ const getDevDependenciesToInstallCommand = async ( result: PromptResult ): Promise => { if (result.language === "ts") { + REQUIRED_DEV_DEPENDENCIES["@aptos-labs/aptos-cli"] = "^1.0.2"; REQUIRED_DEV_DEPENDENCIES["@types/chai"] = "4"; REQUIRED_DEV_DEPENDENCIES["@types/mocha"] = "^10.0.7"; REQUIRED_DEV_DEPENDENCIES["typescript"] = "^5.7.3"; diff --git a/workspace/src/tasks/test.ts b/workspace/src/tasks/test.ts index b190bf3..e727a9d 100644 --- a/workspace/src/tasks/test.ts +++ b/workspace/src/tasks/test.ts @@ -45,7 +45,7 @@ async function checkAptosVersion(): Promise { } const version = versionMatch[1]; - const minimumVersion = "6.0.2"; + const minimumVersion = "6.1.1"; if (semver.lt(version, minimumVersion)) { return reject(