()
| 932 | } |
| 933 | |
| 934 | async function startArgentToolServer() { |
| 935 | const port = await freePort(); |
| 936 | const packageRoot = globalPackageRoot("@swmansion/argent"); |
| 937 | const serverPath = path.join(packageRoot, "dist", "tool-server.cjs"); |
| 938 | const serverDir = path.join(packageRoot, "bin"); |
| 939 | const devtoolsDir = path.join(packageRoot, "dylibs"); |
| 940 | const env = { |
| 941 | ...process.env, |
| 942 | PORT: String(port), |
| 943 | ARGENT_TOOLS_URL: `http://127.0.0.1:${port}`, |
| 944 | ARGENT_SIMULATOR_SERVER_DIR: serverDir, |
| 945 | ARGENT_NATIVE_DEVTOOLS_DIR: devtoolsDir, |
| 946 | }; |
| 947 | const started = performance.now(); |
| 948 | const child = spawn("node", [serverPath, "start"], { |
| 949 | cwd: repoRoot, |
| 950 | env, |
| 951 | stdio: ["ignore", "pipe", "pipe"], |
| 952 | }); |
| 953 | let output = ""; |
| 954 | child.stdout.on("data", (chunk) => { |
| 955 | output += chunk.toString(); |
| 956 | }); |
| 957 | child.stderr.on("data", (chunk) => { |
| 958 | output += chunk.toString(); |
| 959 | }); |
| 960 | |
| 961 | const ready = await waitUntil(async () => { |
| 962 | const response = run("argent", ["tools", "--json"], { |
| 963 | env: { ARGENT_TOOLS_URL: env.ARGENT_TOOLS_URL }, |
| 964 | timeoutMs: 3000, |
| 965 | allowFailure: true, |
| 966 | }); |
| 967 | return response.status === 0; |
| 968 | }, 15000); |
| 969 | |
| 970 | const result = { |
| 971 | ok: ready, |
| 972 | status: ready ? 0 : 1, |
| 973 | stdout: output, |
| 974 | stderr: ready ? "" : output || "Argent tool-server did not become ready.", |
| 975 | durationMs: performance.now() - started, |
| 976 | }; |
| 977 | |
| 978 | return { |
| 979 | env: { ARGENT_TOOLS_URL: env.ARGENT_TOOLS_URL }, |
| 980 | result, |
| 981 | stop: async () => { |
| 982 | if (!child.killed) { |
| 983 | child.kill("SIGTERM"); |
| 984 | await sleep(500); |
| 985 | if (!child.killed) { |
| 986 | child.kill("SIGKILL"); |
| 987 | } |
| 988 | } |
| 989 | }, |
| 990 | }; |
| 991 | } |
no test coverage detected