@teambit/bit 1.9.53 → 1.9.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_bit@1.9.53/dist/bit.compositions.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_bit@1.9.53/dist/bit.docs.js';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_bit@1.9.55/dist/bit.compositions.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_bit@1.9.55/dist/bit.docs.js';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -439,7 +439,7 @@ function execCommand(cmd) {
439
439
  *
440
440
  * On Linux: readlink /proc/<pid>/cwd
441
441
  * On macOS: lsof -p <pid> and parse line with 'cwd'
442
- * On Windows: Attempt with wmic (not guaranteed)
442
+ * On Windows: forget about it. tried with wmic, didn't went well.
443
443
  */
444
444
  async function getCwdByPid(pid) {
445
445
  const platform = _os().default.platform();
@@ -458,29 +458,6 @@ async function getCwdByPid(pid) {
458
458
  // The last part should be the directory path
459
459
  return parts[parts.length - 1] || null;
460
460
  } else if (platform === 'win32') {
461
- // On Windows, we can try wmic:
462
- // wmic process where "ProcessId=<pid>" get CommandLine,ExecutablePath
463
- // CommandLine or ExecutablePath might give hints.
464
- // This is not guaranteed to give the original working directory, as Windows doesn't expose it easily.
465
- const output = await execCommand(`wmic process where "ProcessId=${pid}" get ExecutablePath /format:list`);
466
- // Output looks like:
467
- // ExecutablePath=C:\path\to\executable.exe
468
- const line = output.split('\n').find(l => l.startsWith('ExecutablePath='));
469
- if (line) {
470
- const exePath = line.split('=')[1].trim();
471
- // Guess: the working directory might be the directory containing the executable
472
- return (0, _path().dirname)(exePath);
473
- }
474
- // If no executable path, try CommandLine
475
- const cmdOutput = await execCommand(`wmic process where "ProcessId=${pid}" get CommandLine /format:list`);
476
- const cmdLine = cmdOutput.split('\n').find(l => l.startsWith('CommandLine='));
477
- if (cmdLine) {
478
- const command = cmdLine.split('=')[1].trim();
479
- // Attempt a guess: if command is a full path, take its directory
480
- if (command.includes('\\')) {
481
- return (0, _path().dirname)(command.split(' ')[0]);
482
- }
483
- }
484
461
  return null;
485
462
  } else {
486
463
  throw new Error(`Platform ${platform} not supported`);
@@ -1 +1 @@
1
- {"version":3,"names":["_nodeFetch","data","_interopRequireDefault","require","_net","_fsExtra","_child_process","_path","_os","_eventsource","_scopeModules","_chalk","_legacy","_bootstrap","_serverForever","e","__esModule","default","CMD_SERVER_PORT","CMD_SERVER_PORT_DELETE","CMD_SERVER_SOCKET_PORT","ServerPortFileNotFound","Error","constructor","filePath","ServerIsNotRunning","port","ScopeNotFound","scopePath","ServerCommander","execute","results","runCommandWithHttpServer","exitCode","loader","off","dataToPrint","JSON","stringify","undefined","console","log","process","exit","err","error","chalk","red","message","shouldUseTTYPath","platform","env","BIT_CLI_SERVER_TTY","argv","includes","printPortAndExit","printSocketPortAndExit","deletePortAndExit","printBitVersionIfAsked","getExistingUsedPort","url","shouldUsePTY","BIT_CLI_SERVER_PTY","connectToSocket","ttyPath","execSync","encoding","stdio","trim","initSSE","args","slice","on","endpoint","pwd","cwd","body","command","envBitFeatures","BIT_FEATURES","isPty","res","fetch","method","headers","code","deleteServerPortFile","join","ok","json","jsonResponse","statusText","Promise","resolve","reject","socketPort","getSocketPort","socket","net","createConnection","resetStdin","stdin","setRawMode","pause","destroy","resume","write","toString","end","stdout","cleanup","eventSource","EventSource","onerror","_error","close","addEventListener","event","parsed","parse","getExistingPort","isPortInUse","isPortInUseForCurrentDir","pid","getPidByPort","dirUsedByPort","getCwdByPid","currentDir","getServerPortFilePath","fileContent","fs","readFile","parseInt","remove","findScopePath","exports","shouldUseBitServer","commandsToSkip","hasFlag","BIT_CLI_SERVER","length","execCommand","cmd","exec","os","output","line","split","find","l","parts","startsWith","exePath","dirname","cmdOutput","cmdLine"],"sources":["server-commander.ts"],"sourcesContent":["/**\n * This file is responsible for interacting with bit through a long-running background process \"bit-server\" rather than directly.\n * Why not directly?\n * 1. startup cost. currently it takes around 1 second to bootstrap bit.\n * 2. an experimental package-manager saves node_modules in-memory. if a client starts a new process, it won't have the node_modules in-memory.\n *\n * In this file, there are three ways to achieve this. It's outlined in the order it was evolved.\n * The big challenge here is to show the output correctly to the client even though the server is running in a different process.\n *\n * 1. process.env.BIT_CLI_SERVER === 'true'\n * This method uses SSE - Server Send Events. The server sends events to the client with the output to print. The client listens to\n * these events and prints them. It's cumbersome. For this, the logger was changed and every time the logger needs to print to the console,\n * it was using this SSE to send events. Same with the loader.\n * Cons: Other output, such as pnpm, needs an extra effort to print - for pnpm, the \"process\" object was passed to pnpm\n * and its stdout was modified to use the SSE.\n * However, other tools that print directly to the console, such as Jest, won't work.\n *\n * 2. process.env.BIT_CLI_SERVER_TTY === 'true'\n * Because the terminal - tty is a fd (file descriptor) on mac/linux, it can be passed to the server. The server can write to this\n * fd and it will be printed to the client terminal. On the server, the process.stdout.write was monkey-patched to\n * write to the tty. (see cli-raw.route.ts file).\n * It solves the problem of Jest and other tools that print directly to the console.\n * Cons:\n * A. It doesn't work on Windows. Windows doesn't treat tty as a file descriptor.\n * B. We need two ways communication. Commands such as \"bit update\", display a prompt with option to select using the arrow keys.\n * This is not possible with the tty approach. Also, if the client hits Ctrl+C, the server won't know about it and it\n * won't kill the process.\n *\n * 3. process.env.BIT_CLI_SERVER_PTY === 'true'\n * This is the most advanced approach. It spawns a pty (pseudo terminal) process to communicate between the client and the server.\n * The client connects to the server using a socket. The server writes to the socket and the client reads from it.\n * The client also writes to the socket and the server reads from it. See server-forever.ts to understand better.\n * In order to pass terminal sequences, such as arrow keys or Ctrl+C, the stdin of the client is set to raw mode.\n * In theory, this approach could work by spawning a normal process, not pty, however, then, the stdin/stdout are non-tty,\n * and as a result, loaders such as Ora and chalk won't work.\n * With this new approach, we also support terminating and reloading the server. A new command is added\n * \"bit server-forever\", which spawns the pty-process. If the client hits Ctrl+C, this server-forever process will kill\n * the pty-process and re-load it.\n * Keep in mind, that to send the command and get the results, we still using http. The usage of the pty is only for\n * the input/output during the command.\n * I was trying to avoid the http, and use only the pty, by implementing readline to get the command from the socket,\n * but then I wasn't able to return the prompt to the user easily. So, I decided to keep the http for the request/response part.\n */\n\nimport fetch from 'node-fetch';\nimport net from 'net';\nimport fs from 'fs-extra';\nimport { exec, execSync } from 'child_process';\nimport { join, dirname } from 'path';\nimport os from 'os';\nimport EventSource from 'eventsource';\nimport { findScopePath } from '@teambit/scope.modules.find-scope-path';\nimport chalk from 'chalk';\nimport { loader } from '@teambit/legacy.loader';\nimport { printBitVersionIfAsked } from './bootstrap';\nimport { getPidByPort, getSocketPort } from './server-forever';\n\nconst CMD_SERVER_PORT = 'cli-server-port';\nconst CMD_SERVER_PORT_DELETE = 'cli-server-port-delete';\nconst CMD_SERVER_SOCKET_PORT = 'cli-server-socket-port';\n\nclass ServerPortFileNotFound extends Error {\n constructor(filePath: string) {\n super(`server port file not found at ${filePath}`);\n }\n}\nclass ServerIsNotRunning extends Error {\n constructor(port: number) {\n super(`bit server is not running on port ${port}`);\n }\n}\nclass ScopeNotFound extends Error {\n constructor(scopePath: string) {\n super(`scope not found at ${scopePath}`);\n }\n}\n\ntype CommandResult = { data: any; exitCode: number };\n\nexport class ServerCommander {\n async execute() {\n try {\n const results = await this.runCommandWithHttpServer();\n if (results) {\n const { data, exitCode } = results;\n loader.off();\n const dataToPrint = typeof data === 'string' ? data : JSON.stringify(data, undefined, 2);\n // eslint-disable-next-line no-console\n console.log(dataToPrint);\n process.exit(exitCode);\n }\n\n process.exit(0);\n } catch (err: any) {\n if (err instanceof ScopeNotFound || err instanceof ServerPortFileNotFound || err instanceof ServerIsNotRunning) {\n throw err;\n }\n loader.off();\n // eslint-disable-next-line no-console\n console.error(chalk.red(err.message));\n process.exit(1);\n }\n }\n\n private shouldUseTTYPath() {\n if (process.platform === 'win32') return false; // windows doesn't support tty path\n return process.env.BIT_CLI_SERVER_TTY === 'true';\n }\n\n async runCommandWithHttpServer(): Promise<CommandResult | undefined | void> {\n if (process.argv.includes(CMD_SERVER_PORT)) return this.printPortAndExit();\n if (process.argv.includes(CMD_SERVER_SOCKET_PORT)) return this.printSocketPortAndExit();\n if (process.argv.includes(CMD_SERVER_PORT_DELETE)) return this.deletePortAndExit();\n printBitVersionIfAsked();\n const port = await this.getExistingUsedPort();\n const url = `http://localhost:${port}/api`;\n const shouldUsePTY = process.env.BIT_CLI_SERVER_PTY === 'true';\n\n if (shouldUsePTY) {\n await this.connectToSocket();\n }\n const ttyPath = this.shouldUseTTYPath()\n ? execSync('tty', {\n encoding: 'utf8',\n stdio: ['inherit', 'pipe', 'pipe'],\n }).trim()\n : undefined;\n if (!ttyPath && !shouldUsePTY) this.initSSE(url);\n // parse the args and options from the command\n const args = process.argv.slice(2);\n if (!args.includes('--json') && !args.includes('-j')) {\n loader.on();\n }\n const endpoint = `cli-raw`;\n const pwd = process.cwd();\n const body = { command: args, pwd, envBitFeatures: process.env.BIT_FEATURES, ttyPath, isPty: shouldUsePTY };\n let res;\n try {\n res = await fetch(`${url}/${endpoint}`, {\n method: 'post',\n body: JSON.stringify(body),\n headers: { 'Content-Type': 'application/json' },\n });\n } catch (err: any) {\n if (err.code === 'ECONNREFUSED') {\n await this.deleteServerPortFile();\n throw new ServerIsNotRunning(port);\n }\n throw new Error(`failed to run command \"${args.join(' ')}\" on the server. ${err.message}`);\n }\n\n if (res.ok) {\n const results = await res.json();\n return results;\n }\n\n let jsonResponse;\n try {\n jsonResponse = await res.json();\n } catch {\n // the response is not json, ignore the body.\n }\n throw new Error(jsonResponse?.message || jsonResponse || res.statusText);\n }\n\n private async connectToSocket() {\n return new Promise<void>((resolve, reject) => {\n const socketPort = getSocketPort();\n const socket = net.createConnection({ port: socketPort });\n\n const resetStdin = () => {\n process.stdin.setRawMode(false);\n process.stdin.pause();\n };\n\n // Handle errors that occur before or after connection\n socket.on('error', (err: any) => {\n if (err.code === 'ECONNREFUSED') {\n reject(\n new Error(`Error: Unable to connect to the socket on port ${socketPort}.\nPlease run the command \"bit server-forever\" first to start the server.`)\n );\n }\n resetStdin();\n socket.destroy(); // Ensure the socket is fully closed\n reject(err);\n });\n\n // Handle successful connection\n socket.on('connect', () => {\n process.stdin.setRawMode(true);\n process.stdin.resume();\n\n // Forward stdin to the socket\n process.stdin.on('data', (data: any) => {\n socket.write(data);\n\n // Detect Ctrl+C (hex code '03')\n if (data.toString('hex') === '03') {\n // Important to write it to the socket so the server knows to kill the PTY process\n process.stdin.setRawMode(false);\n process.stdin.pause();\n socket.end();\n process.exit();\n }\n });\n\n // Forward data from the socket to stdout\n socket.on('data', (data: any) => {\n process.stdout.write(data);\n });\n\n // Handle socket close and end events\n const cleanup = () => {\n resetStdin();\n socket.destroy();\n };\n\n socket.on('close', cleanup);\n socket.on('end', cleanup);\n\n resolve(); // Connection successful, resolve the Promise\n });\n });\n }\n\n /**\n * Initialize the server-sent events (SSE) connection to the server.\n * This is used to print the logs and show the loader during the command.\n * Without this, it only shows the response from http server, but not the \"logger.console\" or \"logger.setStatusLine\" texts.\n *\n * I wasn't able to find a better way to do it. The challenge here is that the http server is running in a different\n * process, which is not connected to the current process in any way. (unlike the IDE which is its child process and\n * can access its stdout).\n * One of the attempts I made is sending the \"tty\" path to the server and let the server console log to that path, but\n * it didn't work well. It was printed only after the response came back from the server.\n */\n private initSSE(url: string) {\n const eventSource = new EventSource(`${url}/sse-events`);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n eventSource.onerror = (_error: any) => {\n // eslint-disable-next-line no-console\n // console.error('Error occurred in SSE connection:', _error);\n // probably was unable to connect to the server and will throw ServerNotFound right after. no need to show this error.\n eventSource.close();\n };\n eventSource.addEventListener('onLoader', (event: any) => {\n const parsed = JSON.parse(event.data);\n const { method, args } = parsed;\n loader[method](...(args || []));\n });\n eventSource.addEventListener('onLogWritten', (event: any) => {\n const parsed = JSON.parse(event.data);\n process.stdout.write(parsed.message);\n });\n }\n\n private async printPortAndExit() {\n try {\n const port = await this.getExistingUsedPort();\n process.stdout.write(port.toString());\n process.exit(0);\n } catch (err: any) {\n if (err instanceof ScopeNotFound || err instanceof ServerPortFileNotFound || err instanceof ServerIsNotRunning) {\n process.exit(0);\n }\n console.error(err.message); // eslint-disable-line no-console\n process.exit(1);\n }\n }\n private async deletePortAndExit() {\n try {\n await this.deleteServerPortFile();\n process.exit(0);\n } catch {\n // probably file doesn't exist.\n process.exit(0);\n }\n }\n\n private printSocketPortAndExit() {\n try {\n const port = getSocketPort();\n process.stdout.write(port.toString());\n process.exit(0);\n } catch (err: any) {\n console.error(err.message); // eslint-disable-line no-console\n process.exit(1);\n }\n }\n\n private async getExistingUsedPort(): Promise<number> {\n const port = await this.getExistingPort();\n const isPortInUse = await this.isPortInUseForCurrentDir(port);\n if (!isPortInUse) {\n await this.deleteServerPortFile();\n throw new ServerIsNotRunning(port);\n }\n\n return port;\n }\n\n private async isPortInUseForCurrentDir(port: number) {\n const pid = getPidByPort(port);\n if (!pid) {\n return false;\n }\n const dirUsedByPort = await getCwdByPid(pid);\n if (!dirUsedByPort) {\n // might not be supported by Windows. this is on-best-effort basis.\n return true;\n }\n const currentDir = process.cwd();\n return dirUsedByPort === currentDir;\n }\n\n private async getExistingPort(): Promise<number> {\n const filePath = this.getServerPortFilePath();\n try {\n const fileContent = await fs.readFile(filePath, 'utf8');\n return parseInt(fileContent, 10);\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n throw new ServerPortFileNotFound(filePath);\n }\n throw err;\n }\n }\n\n private async deleteServerPortFile() {\n const filePath = this.getServerPortFilePath();\n await fs.remove(filePath);\n }\n\n private getServerPortFilePath() {\n const scopePath = findScopePath(process.cwd());\n if (!scopePath) {\n throw new ScopeNotFound(process.cwd());\n }\n return join(scopePath, 'server-port.txt');\n }\n}\n\nexport function shouldUseBitServer() {\n const commandsToSkip = ['start', 'run', 'watch', 'server'];\n const hasFlag =\n process.env.BIT_CLI_SERVER === 'true' ||\n process.env.BIT_CLI_SERVER === '1' ||\n process.env.BIT_CLI_SERVER_PTY === 'true' ||\n process.env.BIT_CLI_SERVER_TTY === 'true';\n return (\n hasFlag &&\n process.argv.length > 2 && // if it has no args, it shows the help\n !commandsToSkip.includes(process.argv[2])\n );\n}\n\n/**\n * Executes a command and returns stdout as a string.\n */\nfunction execCommand(cmd: string): Promise<string> {\n return new Promise((resolve, reject) => {\n exec(cmd, { encoding: 'utf-8' }, (error, stdout) => {\n if (error) {\n return reject(error);\n }\n resolve(stdout.trim());\n });\n });\n}\n\n/**\n * Get the CWD of a process by PID.\n *\n * On Linux: readlink /proc/<pid>/cwd\n * On macOS: lsof -p <pid> and parse line with 'cwd'\n * On Windows: Attempt with wmic (not guaranteed)\n */\nasync function getCwdByPid(pid: string): Promise<string | null> {\n const platform = os.platform();\n\n try {\n if (platform === 'linux') {\n const cwd = await execCommand(`readlink /proc/${pid}/cwd`);\n return cwd || null;\n } else if (platform === 'darwin') {\n // macOS does not have /proc, but lsof -p <pid> shows cwd line like:\n // COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME\n // node 12345 user cwd DIR 1,2 1024 56789 /Users/username/project\n const output = await execCommand(`lsof -p ${pid}`);\n const line = output.split('\\n').find((l) => l.includes(' cwd '));\n if (!line) return null;\n const parts = line.trim().split(/\\s+/);\n // The last part should be the directory path\n return parts[parts.length - 1] || null;\n } else if (platform === 'win32') {\n // On Windows, we can try wmic:\n // wmic process where \"ProcessId=<pid>\" get CommandLine,ExecutablePath\n // CommandLine or ExecutablePath might give hints.\n // This is not guaranteed to give the original working directory, as Windows doesn't expose it easily.\n const output = await execCommand(`wmic process where \"ProcessId=${pid}\" get ExecutablePath /format:list`);\n // Output looks like:\n // ExecutablePath=C:\\path\\to\\executable.exe\n const line = output.split('\\n').find((l) => l.startsWith('ExecutablePath='));\n if (line) {\n const exePath = line.split('=')[1].trim();\n // Guess: the working directory might be the directory containing the executable\n return dirname(exePath);\n }\n // If no executable path, try CommandLine\n const cmdOutput = await execCommand(`wmic process where \"ProcessId=${pid}\" get CommandLine /format:list`);\n const cmdLine = cmdOutput.split('\\n').find((l) => l.startsWith('CommandLine='));\n if (cmdLine) {\n const command = cmdLine.split('=')[1].trim();\n // Attempt a guess: if command is a full path, take its directory\n if (command.includes('\\\\')) {\n return dirname(command.split(' ')[0]);\n }\n }\n return null;\n } else {\n throw new Error(`Platform ${platform} not supported`);\n }\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;AA4CA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,IAAA;EAAA,MAAAP,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAK,GAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SA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AAG,mCAAmC,CAAC;MACzG;MACA;MACA,MAAMuB,IAAI,GAAGD,MAAM,CAACE,KAAK,CAAC,IAAI,CAAC,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACE,UAAU,CAAC,iBAAiB,CAAC,CAAC;MAC5E,IAAIL,IAAI,EAAE;QACR,MAAMM,OAAO,GAAGN,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC/E,IAAI,CAAC,CAAC;QACzC;QACA,OAAO,IAAAqF,eAAO,EAACD,OAAO,CAAC;MACzB;MACA;MACA,MAAME,SAAS,GAAG,MAAMb,WAAW,CAAC,iCAAiClB,GAAG,gCAAgC,CAAC;MACzG,MAAMgC,OAAO,GAAGD,SAAS,CAACP,KAAK,CAAC,IAAI,CAAC,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACE,UAAU,CAAC,cAAc,CAAC,CAAC;MAC/E,IAAII,OAAO,EAAE;QACX,MAAM9E,OAAO,GAAG8E,OAAO,CAACR,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC/E,IAAI,CAAC,CAAC;QAC5C;QACA,IAAIS,OAAO,CAACvB,QAAQ,CAAC,IAAI,CAAC,EAAE;UAC1B,OAAO,IAAAmG,eAAO,EAAC5E,OAAO,CAACsE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC;MACF;MACA,OAAO,IAAI;IACb,CAAC,MAAM;MACL,MAAM,IAAI7H,KAAK,CAAC,YAAY4B,QAAQ,gBAAgB,CAAC;IACvD;EACF,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_nodeFetch","data","_interopRequireDefault","require","_net","_fsExtra","_child_process","_path","_os","_eventsource","_scopeModules","_chalk","_legacy","_bootstrap","_serverForever","e","__esModule","default","CMD_SERVER_PORT","CMD_SERVER_PORT_DELETE","CMD_SERVER_SOCKET_PORT","ServerPortFileNotFound","Error","constructor","filePath","ServerIsNotRunning","port","ScopeNotFound","scopePath","ServerCommander","execute","results","runCommandWithHttpServer","exitCode","loader","off","dataToPrint","JSON","stringify","undefined","console","log","process","exit","err","error","chalk","red","message","shouldUseTTYPath","platform","env","BIT_CLI_SERVER_TTY","argv","includes","printPortAndExit","printSocketPortAndExit","deletePortAndExit","printBitVersionIfAsked","getExistingUsedPort","url","shouldUsePTY","BIT_CLI_SERVER_PTY","connectToSocket","ttyPath","execSync","encoding","stdio","trim","initSSE","args","slice","on","endpoint","pwd","cwd","body","command","envBitFeatures","BIT_FEATURES","isPty","res","fetch","method","headers","code","deleteServerPortFile","join","ok","json","jsonResponse","statusText","Promise","resolve","reject","socketPort","getSocketPort","socket","net","createConnection","resetStdin","stdin","setRawMode","pause","destroy","resume","write","toString","end","stdout","cleanup","eventSource","EventSource","onerror","_error","close","addEventListener","event","parsed","parse","getExistingPort","isPortInUse","isPortInUseForCurrentDir","pid","getPidByPort","dirUsedByPort","getCwdByPid","currentDir","getServerPortFilePath","fileContent","fs","readFile","parseInt","remove","findScopePath","exports","shouldUseBitServer","commandsToSkip","hasFlag","BIT_CLI_SERVER","length","execCommand","cmd","exec","os","output","line","split","find","l","parts"],"sources":["server-commander.ts"],"sourcesContent":["/**\n * This file is responsible for interacting with bit through a long-running background process \"bit-server\" rather than directly.\n * Why not directly?\n * 1. startup cost. currently it takes around 1 second to bootstrap bit.\n * 2. an experimental package-manager saves node_modules in-memory. if a client starts a new process, it won't have the node_modules in-memory.\n *\n * In this file, there are three ways to achieve this. It's outlined in the order it was evolved.\n * The big challenge here is to show the output correctly to the client even though the server is running in a different process.\n *\n * 1. process.env.BIT_CLI_SERVER === 'true'\n * This method uses SSE - Server Send Events. The server sends events to the client with the output to print. The client listens to\n * these events and prints them. It's cumbersome. For this, the logger was changed and every time the logger needs to print to the console,\n * it was using this SSE to send events. Same with the loader.\n * Cons: Other output, such as pnpm, needs an extra effort to print - for pnpm, the \"process\" object was passed to pnpm\n * and its stdout was modified to use the SSE.\n * However, other tools that print directly to the console, such as Jest, won't work.\n *\n * 2. process.env.BIT_CLI_SERVER_TTY === 'true'\n * Because the terminal - tty is a fd (file descriptor) on mac/linux, it can be passed to the server. The server can write to this\n * fd and it will be printed to the client terminal. On the server, the process.stdout.write was monkey-patched to\n * write to the tty. (see cli-raw.route.ts file).\n * It solves the problem of Jest and other tools that print directly to the console.\n * Cons:\n * A. It doesn't work on Windows. Windows doesn't treat tty as a file descriptor.\n * B. We need two ways communication. Commands such as \"bit update\", display a prompt with option to select using the arrow keys.\n * This is not possible with the tty approach. Also, if the client hits Ctrl+C, the server won't know about it and it\n * won't kill the process.\n *\n * 3. process.env.BIT_CLI_SERVER_PTY === 'true'\n * This is the most advanced approach. It spawns a pty (pseudo terminal) process to communicate between the client and the server.\n * The client connects to the server using a socket. The server writes to the socket and the client reads from it.\n * The client also writes to the socket and the server reads from it. See server-forever.ts to understand better.\n * In order to pass terminal sequences, such as arrow keys or Ctrl+C, the stdin of the client is set to raw mode.\n * In theory, this approach could work by spawning a normal process, not pty, however, then, the stdin/stdout are non-tty,\n * and as a result, loaders such as Ora and chalk won't work.\n * With this new approach, we also support terminating and reloading the server. A new command is added\n * \"bit server-forever\", which spawns the pty-process. If the client hits Ctrl+C, this server-forever process will kill\n * the pty-process and re-load it.\n * Keep in mind, that to send the command and get the results, we still using http. The usage of the pty is only for\n * the input/output during the command.\n * I was trying to avoid the http, and use only the pty, by implementing readline to get the command from the socket,\n * but then I wasn't able to return the prompt to the user easily. So, I decided to keep the http for the request/response part.\n */\n\nimport fetch from 'node-fetch';\nimport net from 'net';\nimport fs from 'fs-extra';\nimport { exec, execSync } from 'child_process';\nimport { join } from 'path';\nimport os from 'os';\nimport EventSource from 'eventsource';\nimport { findScopePath } from '@teambit/scope.modules.find-scope-path';\nimport chalk from 'chalk';\nimport { loader } from '@teambit/legacy.loader';\nimport { printBitVersionIfAsked } from './bootstrap';\nimport { getPidByPort, getSocketPort } from './server-forever';\n\nconst CMD_SERVER_PORT = 'cli-server-port';\nconst CMD_SERVER_PORT_DELETE = 'cli-server-port-delete';\nconst CMD_SERVER_SOCKET_PORT = 'cli-server-socket-port';\n\nclass ServerPortFileNotFound extends Error {\n constructor(filePath: string) {\n super(`server port file not found at ${filePath}`);\n }\n}\nclass ServerIsNotRunning extends Error {\n constructor(port: number) {\n super(`bit server is not running on port ${port}`);\n }\n}\nclass ScopeNotFound extends Error {\n constructor(scopePath: string) {\n super(`scope not found at ${scopePath}`);\n }\n}\n\ntype CommandResult = { data: any; exitCode: number };\n\nexport class ServerCommander {\n async execute() {\n try {\n const results = await this.runCommandWithHttpServer();\n if (results) {\n const { data, exitCode } = results;\n loader.off();\n const dataToPrint = typeof data === 'string' ? data : JSON.stringify(data, undefined, 2);\n // eslint-disable-next-line no-console\n console.log(dataToPrint);\n process.exit(exitCode);\n }\n\n process.exit(0);\n } catch (err: any) {\n if (err instanceof ScopeNotFound || err instanceof ServerPortFileNotFound || err instanceof ServerIsNotRunning) {\n throw err;\n }\n loader.off();\n // eslint-disable-next-line no-console\n console.error(chalk.red(err.message));\n process.exit(1);\n }\n }\n\n private shouldUseTTYPath() {\n if (process.platform === 'win32') return false; // windows doesn't support tty path\n return process.env.BIT_CLI_SERVER_TTY === 'true';\n }\n\n async runCommandWithHttpServer(): Promise<CommandResult | undefined | void> {\n if (process.argv.includes(CMD_SERVER_PORT)) return this.printPortAndExit();\n if (process.argv.includes(CMD_SERVER_SOCKET_PORT)) return this.printSocketPortAndExit();\n if (process.argv.includes(CMD_SERVER_PORT_DELETE)) return this.deletePortAndExit();\n printBitVersionIfAsked();\n const port = await this.getExistingUsedPort();\n const url = `http://localhost:${port}/api`;\n const shouldUsePTY = process.env.BIT_CLI_SERVER_PTY === 'true';\n\n if (shouldUsePTY) {\n await this.connectToSocket();\n }\n const ttyPath = this.shouldUseTTYPath()\n ? execSync('tty', {\n encoding: 'utf8',\n stdio: ['inherit', 'pipe', 'pipe'],\n }).trim()\n : undefined;\n if (!ttyPath && !shouldUsePTY) this.initSSE(url);\n // parse the args and options from the command\n const args = process.argv.slice(2);\n if (!args.includes('--json') && !args.includes('-j')) {\n loader.on();\n }\n const endpoint = `cli-raw`;\n const pwd = process.cwd();\n const body = { command: args, pwd, envBitFeatures: process.env.BIT_FEATURES, ttyPath, isPty: shouldUsePTY };\n let res;\n try {\n res = await fetch(`${url}/${endpoint}`, {\n method: 'post',\n body: JSON.stringify(body),\n headers: { 'Content-Type': 'application/json' },\n });\n } catch (err: any) {\n if (err.code === 'ECONNREFUSED') {\n await this.deleteServerPortFile();\n throw new ServerIsNotRunning(port);\n }\n throw new Error(`failed to run command \"${args.join(' ')}\" on the server. ${err.message}`);\n }\n\n if (res.ok) {\n const results = await res.json();\n return results;\n }\n\n let jsonResponse;\n try {\n jsonResponse = await res.json();\n } catch {\n // the response is not json, ignore the body.\n }\n throw new Error(jsonResponse?.message || jsonResponse || res.statusText);\n }\n\n private async connectToSocket() {\n return new Promise<void>((resolve, reject) => {\n const socketPort = getSocketPort();\n const socket = net.createConnection({ port: socketPort });\n\n const resetStdin = () => {\n process.stdin.setRawMode(false);\n process.stdin.pause();\n };\n\n // Handle errors that occur before or after connection\n socket.on('error', (err: any) => {\n if (err.code === 'ECONNREFUSED') {\n reject(\n new Error(`Error: Unable to connect to the socket on port ${socketPort}.\nPlease run the command \"bit server-forever\" first to start the server.`)\n );\n }\n resetStdin();\n socket.destroy(); // Ensure the socket is fully closed\n reject(err);\n });\n\n // Handle successful connection\n socket.on('connect', () => {\n process.stdin.setRawMode(true);\n process.stdin.resume();\n\n // Forward stdin to the socket\n process.stdin.on('data', (data: any) => {\n socket.write(data);\n\n // Detect Ctrl+C (hex code '03')\n if (data.toString('hex') === '03') {\n // Important to write it to the socket so the server knows to kill the PTY process\n process.stdin.setRawMode(false);\n process.stdin.pause();\n socket.end();\n process.exit();\n }\n });\n\n // Forward data from the socket to stdout\n socket.on('data', (data: any) => {\n process.stdout.write(data);\n });\n\n // Handle socket close and end events\n const cleanup = () => {\n resetStdin();\n socket.destroy();\n };\n\n socket.on('close', cleanup);\n socket.on('end', cleanup);\n\n resolve(); // Connection successful, resolve the Promise\n });\n });\n }\n\n /**\n * Initialize the server-sent events (SSE) connection to the server.\n * This is used to print the logs and show the loader during the command.\n * Without this, it only shows the response from http server, but not the \"logger.console\" or \"logger.setStatusLine\" texts.\n *\n * I wasn't able to find a better way to do it. The challenge here is that the http server is running in a different\n * process, which is not connected to the current process in any way. (unlike the IDE which is its child process and\n * can access its stdout).\n * One of the attempts I made is sending the \"tty\" path to the server and let the server console log to that path, but\n * it didn't work well. It was printed only after the response came back from the server.\n */\n private initSSE(url: string) {\n const eventSource = new EventSource(`${url}/sse-events`);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n eventSource.onerror = (_error: any) => {\n // eslint-disable-next-line no-console\n // console.error('Error occurred in SSE connection:', _error);\n // probably was unable to connect to the server and will throw ServerNotFound right after. no need to show this error.\n eventSource.close();\n };\n eventSource.addEventListener('onLoader', (event: any) => {\n const parsed = JSON.parse(event.data);\n const { method, args } = parsed;\n loader[method](...(args || []));\n });\n eventSource.addEventListener('onLogWritten', (event: any) => {\n const parsed = JSON.parse(event.data);\n process.stdout.write(parsed.message);\n });\n }\n\n private async printPortAndExit() {\n try {\n const port = await this.getExistingUsedPort();\n process.stdout.write(port.toString());\n process.exit(0);\n } catch (err: any) {\n if (err instanceof ScopeNotFound || err instanceof ServerPortFileNotFound || err instanceof ServerIsNotRunning) {\n process.exit(0);\n }\n console.error(err.message); // eslint-disable-line no-console\n process.exit(1);\n }\n }\n private async deletePortAndExit() {\n try {\n await this.deleteServerPortFile();\n process.exit(0);\n } catch {\n // probably file doesn't exist.\n process.exit(0);\n }\n }\n\n private printSocketPortAndExit() {\n try {\n const port = getSocketPort();\n process.stdout.write(port.toString());\n process.exit(0);\n } catch (err: any) {\n console.error(err.message); // eslint-disable-line no-console\n process.exit(1);\n }\n }\n\n private async getExistingUsedPort(): Promise<number> {\n const port = await this.getExistingPort();\n const isPortInUse = await this.isPortInUseForCurrentDir(port);\n if (!isPortInUse) {\n await this.deleteServerPortFile();\n throw new ServerIsNotRunning(port);\n }\n\n return port;\n }\n\n private async isPortInUseForCurrentDir(port: number) {\n const pid = getPidByPort(port);\n if (!pid) {\n return false;\n }\n const dirUsedByPort = await getCwdByPid(pid);\n if (!dirUsedByPort) {\n // might not be supported by Windows. this is on-best-effort basis.\n return true;\n }\n const currentDir = process.cwd();\n return dirUsedByPort === currentDir;\n }\n\n private async getExistingPort(): Promise<number> {\n const filePath = this.getServerPortFilePath();\n try {\n const fileContent = await fs.readFile(filePath, 'utf8');\n return parseInt(fileContent, 10);\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n throw new ServerPortFileNotFound(filePath);\n }\n throw err;\n }\n }\n\n private async deleteServerPortFile() {\n const filePath = this.getServerPortFilePath();\n await fs.remove(filePath);\n }\n\n private getServerPortFilePath() {\n const scopePath = findScopePath(process.cwd());\n if (!scopePath) {\n throw new ScopeNotFound(process.cwd());\n }\n return join(scopePath, 'server-port.txt');\n }\n}\n\nexport function shouldUseBitServer() {\n const commandsToSkip = ['start', 'run', 'watch', 'server'];\n const hasFlag =\n process.env.BIT_CLI_SERVER === 'true' ||\n process.env.BIT_CLI_SERVER === '1' ||\n process.env.BIT_CLI_SERVER_PTY === 'true' ||\n process.env.BIT_CLI_SERVER_TTY === 'true';\n return (\n hasFlag &&\n process.argv.length > 2 && // if it has no args, it shows the help\n !commandsToSkip.includes(process.argv[2])\n );\n}\n\n/**\n * Executes a command and returns stdout as a string.\n */\nfunction execCommand(cmd: string): Promise<string> {\n return new Promise((resolve, reject) => {\n exec(cmd, { encoding: 'utf-8' }, (error, stdout) => {\n if (error) {\n return reject(error);\n }\n resolve(stdout.trim());\n });\n });\n}\n\n/**\n * Get the CWD of a process by PID.\n *\n * On Linux: readlink /proc/<pid>/cwd\n * On macOS: lsof -p <pid> and parse line with 'cwd'\n * On Windows: forget about it. tried with wmic, didn't went well.\n */\nasync function getCwdByPid(pid: string): Promise<string | null> {\n const platform = os.platform();\n\n try {\n if (platform === 'linux') {\n const cwd = await execCommand(`readlink /proc/${pid}/cwd`);\n return cwd || null;\n } else if (platform === 'darwin') {\n // macOS does not have /proc, but lsof -p <pid> shows cwd line like:\n // COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME\n // node 12345 user cwd DIR 1,2 1024 56789 /Users/username/project\n const output = await execCommand(`lsof -p ${pid}`);\n const line = output.split('\\n').find((l) => l.includes(' cwd '));\n if (!line) return null;\n const parts = line.trim().split(/\\s+/);\n // The last part should be the directory path\n return parts[parts.length - 1] || null;\n } else if (platform === 'win32') {\n return null;\n } else {\n throw new Error(`Platform ${platform} not supported`);\n }\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;AA4CA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,IAAA;EAAA,MAAAP,IAAA,GAAAC,sB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AAQ,KAAK,OAAO,EAAE;MAC/B,OAAO,IAAI;IACb,CAAC,MAAM;MACL,MAAM,IAAI5B,KAAK,CAAC,YAAY4B,QAAQ,gBAAgB,CAAC;IACvD;EACF,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF","ignoreList":[]}
@@ -14,6 +14,13 @@ function _net() {
14
14
  };
15
15
  return data;
16
16
  }
17
+ function _os() {
18
+ const data = _interopRequireDefault(require("os"));
19
+ _os = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
17
24
  function _crypto() {
18
25
  const data = _interopRequireDefault(require("crypto"));
19
26
  _crypto = function () {
@@ -49,22 +56,23 @@ function spawnPTY() {
49
56
  // Create a PTY (terminal emulation) running the 'bit server' process
50
57
  // this way, we can catch terminal sequences like arrows, ctrl+c, etc.
51
58
  const flags = process.argv.slice(2).filter(arg => arg.startsWith('-'));
52
- const ptyProcess = (0, _nodePty().spawn)('bit', ['server', ...flags], {
59
+ const opts = {
53
60
  name: 'xterm-color',
54
61
  cols: 80,
55
62
  rows: 30,
56
63
  cwd: process.cwd(),
57
64
  env: process.env
58
- });
65
+ };
66
+ const ptyProcess = _os().default.platform() === 'win32' ? (0, _nodePty().spawn)('powershell.exe', ['bit', 'server', ...flags], opts) : (0, _nodePty().spawn)('bit', ['server', ...flags], opts);
59
67
 
60
68
  // Keep track of connected clients
61
69
  const clients = [];
62
70
  let didGetClient = false;
63
- let outputNotForClients = false;
71
+ let outputNotForClients = '';
64
72
 
65
73
  // @ts-ignore
66
74
  ptyProcess.on('data', data => {
67
- if (!clients.length) outputNotForClients = data.toString();
75
+ if (!clients.length) outputNotForClients += data.toString();
68
76
  // Forward data from the ptyProcess to connected clients
69
77
  // console.log('ptyProcess data:', data.toString());
70
78
  clients.forEach(socket => {
@@ -91,7 +99,7 @@ function spawnPTY() {
91
99
 
92
100
  // Handle client disconnect
93
101
  socket.on('end', () => {
94
- console.log('Client disconnected.');
102
+ console.log('Client disconnected (gracefully).');
95
103
  const index = clients.indexOf(socket);
96
104
  if (index !== -1) {
97
105
  clients.splice(index, 1);
@@ -100,7 +108,11 @@ function spawnPTY() {
100
108
 
101
109
  // Handle socket errors
102
110
  socket.on('error', err => {
103
- console.error('Socket error:', err);
111
+ if (err.code === 'ECONNRESET') {
112
+ console.log('Client disconnected (forcibly).');
113
+ } else {
114
+ console.error('Socket error:', err);
115
+ }
104
116
  const index = clients.indexOf(socket);
105
117
  if (index !== -1) {
106
118
  clients.splice(index, 1);
@@ -1 +1 @@
1
- {"version":3,"names":["_net","data","_interopRequireDefault","require","_crypto","_child_process","_nodePty","e","__esModule","default","spawnPTY","flags","process","argv","slice","filter","arg","startsWith","ptyProcess","spawn","name","cols","rows","cwd","env","clients","didGetClient","outputNotForClients","on","length","toString","forEach","socket","write","server","net","createServer","console","log","push","kill","index","indexOf","splice","err","error","PORT","getSocketPort","code","pid","getPidByPort","usedByPid","killCmd","exit","listen","signal","close","setTimeout","BIT_CLI_SERVER_SOCKET_PORT","parseInt","getPortFromPath","path","hash","crypto","createHash","update","digest","hashInt","substring","minPort","maxPort","portRange","port","consoleErrors","platform","cmd","stdout","execSync","lines","trim","split","columns","line","localAddress","endsWith","message"],"sources":["server-forever.ts"],"sourcesContent":["/**\n * see the docs of server-commander.ts for more info\n * this \"server-forever\" command is used to run the bit server in a way that it will never stop. if it gets killed,\n * it will restart itself.\n * it spawns \"bit server\" using node-pty for a pseudo-terminal (PTY) in order for libs such as inquirer/ora/chalk to work properly.\n */\n\n/* eslint-disable no-console */\n\nimport net from 'net';\nimport crypto from 'crypto';\nimport { execSync } from 'child_process';\nimport { spawn } from '@lydell/node-pty';\n\nexport function spawnPTY() {\n // Create a PTY (terminal emulation) running the 'bit server' process\n // this way, we can catch terminal sequences like arrows, ctrl+c, etc.\n const flags = process.argv.slice(2).filter((arg) => arg.startsWith('-'));\n const ptyProcess = spawn('bit', ['server', ...flags], {\n name: 'xterm-color',\n cols: 80,\n rows: 30,\n cwd: process.cwd(),\n env: process.env,\n });\n\n // Keep track of connected clients\n const clients: net.Socket[] = [];\n\n let didGetClient = false;\n let outputNotForClients = false;\n\n // @ts-ignore\n ptyProcess.on('data', (data) => {\n if (!clients.length) outputNotForClients = data.toString();\n // Forward data from the ptyProcess to connected clients\n // console.log('ptyProcess data:', data.toString());\n clients.forEach((socket) => {\n socket.write(data);\n });\n });\n\n // Create a TCP server\n const server = net.createServer((socket) => {\n console.log('Client connected.');\n didGetClient = true;\n clients.push(socket);\n\n // Forward data from the client to the ptyProcess\n socket.on('data', (data: any) => {\n // console.log('Server received data from client:', data.toString());\n if (data.toString('hex') === '03') {\n // User hit Ctrl+C\n ptyProcess.kill();\n } else {\n ptyProcess.write(data);\n }\n });\n\n // Handle client disconnect\n socket.on('end', () => {\n console.log('Client disconnected.');\n const index = clients.indexOf(socket);\n if (index !== -1) {\n clients.splice(index, 1);\n }\n });\n\n // Handle socket errors\n socket.on('error', (err) => {\n console.error('Socket error:', err);\n const index = clients.indexOf(socket);\n if (index !== -1) {\n clients.splice(index, 1);\n }\n });\n });\n\n const PORT = getSocketPort();\n\n server.on('error', (err: any) => {\n if (err.code === 'EADDRINUSE') {\n const pid = getPidByPort(PORT, true);\n const usedByPid = pid ? ` (used by PID ${pid})` : '';\n const killCmd = pid ? `\\nAlternatively, you can kill the process by running \"kill ${pid}\".` : '';\n console.error(`Error: Port ${PORT} is already in use${usedByPid}.\nThis port is assigned based on the workspace path: '${process.cwd()}'\nThis means another instance may already be running in this workspace.\n\\nTo resolve this issue:\n- If another instance is running, please stop it before starting a new one.\n If a vscode is open on this workspace, it might be running the server. Close it.${killCmd}\n- If no other instance is running, the port may be occupied by another application.\n You can override the default port by setting the 'BIT_CLI_SERVER_SOCKET_PORT' environment variable.\n`);\n process.exit(1); // Exit the process with an error code\n } else {\n console.error('Server encountered an error:', err);\n process.exit(1);\n }\n });\n\n server.listen(PORT, () => {\n console.log(`Socket listening on port ${PORT}`);\n });\n\n // @ts-ignore\n ptyProcess.on('exit', (code, signal) => {\n server.close();\n if (didGetClient) {\n console.log(`PTY exited with code ${code} and signal ${signal}`);\n setTimeout(() => {\n console.log('Restarting the PTY process...');\n spawnPTY(); // Restart the PTY process\n }, 100);\n } else {\n console.error(`Failed to start the PTY Process. Error: ${outputNotForClients}`);\n }\n });\n}\n\nexport function getSocketPort(): number {\n return process.env.BIT_CLI_SERVER_SOCKET_PORT\n ? parseInt(process.env.BIT_CLI_SERVER_SOCKET_PORT)\n : getPortFromPath(process.cwd());\n}\n\n/**\n * it's easier to generate a random port based on the workspace path than to save it in a file\n */\nexport function getPortFromPath(path: string): number {\n // Step 1: Hash the workspace path using MD5\n const hash = crypto.createHash('md5').update(path).digest('hex');\n\n // Step 2: Convert a portion of the hash to an integer\n // We'll use the first 8 characters (32 bits)\n const hashInt = parseInt(hash.substring(0, 8), 16);\n\n // Step 3: Map the integer to the port range 49152 to 65535 (these are dynamic ports not assigned by IANA)\n const minPort = 49152;\n const maxPort = 65535;\n const portRange = maxPort - minPort + 1;\n\n const port = (hashInt % portRange) + minPort;\n\n return port;\n}\n\nexport function getPidByPort(port: number, consoleErrors = false): string | null {\n const platform = process.platform;\n try {\n if (platform === 'darwin' || platform === 'linux') {\n // For macOS and Linux\n const cmd = `lsof -iTCP:${port} -sTCP:LISTEN -n -P`;\n const stdout = execSync(cmd).toString();\n const lines = stdout.trim().split('\\n');\n\n if (lines.length > 1) {\n // Skip the header line and parse the first result\n const columns = lines[1].split(/\\s+/);\n const pid = columns[1];\n return pid;\n }\n } else if (platform === 'win32') {\n // For Windows\n const cmd = `netstat -ano -p tcp`;\n const stdout = execSync(cmd).toString();\n const lines = stdout.trim().split('\\n');\n\n for (const line of lines) {\n if (line.trim().startsWith('TCP')) {\n const columns = line.trim().split(/\\s+/);\n const localAddress = columns[1];\n const pid = columns[4];\n\n if (localAddress.endsWith(`:${port}`)) {\n return pid;\n }\n }\n }\n } else {\n if (consoleErrors) console.error('Unsupported platform:', platform);\n }\n } catch (error: any) {\n if (consoleErrors) console.error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BAAuB,EAAE6B,QAAQ,CAAC;IACrE;EACF,CAAC,CAAC,OAAO7B,KAAU,EAAE;IACnB,IAAI4B,aAAa,EAAEpC,OAAO,CAACQ,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAACwC,OAAO,CAAC;EAC7E;EACA,OAAO,IAAI;AACb","ignoreList":[]}
1
+ {"version":3,"names":["_net","data","_interopRequireDefault","require","_os","_crypto","_child_process","_nodePty","e","__esModule","default","spawnPTY","flags","process","argv","slice","filter","arg","startsWith","opts","name","cols","rows","cwd","env","ptyProcess","os","platform","spawn","clients","didGetClient","outputNotForClients","on","length","toString","forEach","socket","write","server","net","createServer","console","log","push","kill","index","indexOf","splice","err","code","error","PORT","getSocketPort","pid","getPidByPort","usedByPid","killCmd","exit","listen","signal","close","setTimeout","BIT_CLI_SERVER_SOCKET_PORT","parseInt","getPortFromPath","path","hash","crypto","createHash","update","digest","hashInt","substring","minPort","maxPort","portRange","port","consoleErrors","cmd","stdout","execSync","lines","trim","split","columns","line","localAddress","endsWith","message"],"sources":["server-forever.ts"],"sourcesContent":["/**\n * see the docs of server-commander.ts for more info\n * this \"server-forever\" command is used to run the bit server in a way that it will never stop. if it gets killed,\n * it will restart itself.\n * it spawns \"bit server\" using node-pty for a pseudo-terminal (PTY) in order for libs such as inquirer/ora/chalk to work properly.\n */\n\n/* eslint-disable no-console */\n\nimport net from 'net';\nimport os from 'os';\nimport crypto from 'crypto';\nimport { execSync } from 'child_process';\nimport { spawn } from '@lydell/node-pty';\n\nexport function spawnPTY() {\n // Create a PTY (terminal emulation) running the 'bit server' process\n // this way, we can catch terminal sequences like arrows, ctrl+c, etc.\n const flags = process.argv.slice(2).filter((arg) => arg.startsWith('-'));\n const opts = {\n name: 'xterm-color',\n cols: 80,\n rows: 30,\n cwd: process.cwd(),\n env: process.env,\n };\n const ptyProcess =\n os.platform() === 'win32'\n ? spawn('powershell.exe', ['bit', 'server', ...flags], opts)\n : spawn('bit', ['server', ...flags], opts);\n\n // Keep track of connected clients\n const clients: net.Socket[] = [];\n\n let didGetClient = false;\n let outputNotForClients = '';\n\n // @ts-ignore\n ptyProcess.on('data', (data) => {\n if (!clients.length) outputNotForClients += data.toString();\n // Forward data from the ptyProcess to connected clients\n // console.log('ptyProcess data:', data.toString());\n clients.forEach((socket) => {\n socket.write(data);\n });\n });\n\n // Create a TCP server\n const server = net.createServer((socket) => {\n console.log('Client connected.');\n didGetClient = true;\n clients.push(socket);\n\n // Forward data from the client to the ptyProcess\n socket.on('data', (data: any) => {\n // console.log('Server received data from client:', data.toString());\n if (data.toString('hex') === '03') {\n // User hit Ctrl+C\n ptyProcess.kill();\n } else {\n ptyProcess.write(data);\n }\n });\n\n // Handle client disconnect\n socket.on('end', () => {\n console.log('Client disconnected (gracefully).');\n const index = clients.indexOf(socket);\n if (index !== -1) {\n clients.splice(index, 1);\n }\n });\n\n // Handle socket errors\n socket.on('error', (err: any) => {\n if (err.code === 'ECONNRESET') {\n console.log('Client disconnected (forcibly).');\n } else {\n console.error('Socket error:', err);\n }\n const index = clients.indexOf(socket);\n if (index !== -1) {\n clients.splice(index, 1);\n }\n });\n });\n\n const PORT = getSocketPort();\n\n server.on('error', (err: any) => {\n if (err.code === 'EADDRINUSE') {\n const pid = getPidByPort(PORT, true);\n const usedByPid = pid ? ` (used by PID ${pid})` : '';\n const killCmd = pid ? `\\nAlternatively, you can kill the process by running \"kill ${pid}\".` : '';\n console.error(`Error: Port ${PORT} is already in use${usedByPid}.\nThis port is assigned based on the workspace path: '${process.cwd()}'\nThis means another instance may already be running in this workspace.\n\\nTo resolve this issue:\n- If another instance is running, please stop it before starting a new one.\n If a vscode is open on this workspace, it might be running the server. Close it.${killCmd}\n- If no other instance is running, the port may be occupied by another application.\n You can override the default port by setting the 'BIT_CLI_SERVER_SOCKET_PORT' environment variable.\n`);\n process.exit(1); // Exit the process with an error code\n } else {\n console.error('Server encountered an error:', err);\n process.exit(1);\n }\n });\n\n server.listen(PORT, () => {\n console.log(`Socket listening on port ${PORT}`);\n });\n\n // @ts-ignore\n ptyProcess.on('exit', (code, signal) => {\n server.close();\n if (didGetClient) {\n console.log(`PTY exited with code ${code} and signal ${signal}`);\n setTimeout(() => {\n console.log('Restarting the PTY process...');\n spawnPTY(); // Restart the PTY process\n }, 100);\n } else {\n console.error(`Failed to start the PTY Process. Error: ${outputNotForClients}`);\n }\n });\n}\n\nexport function getSocketPort(): number {\n return process.env.BIT_CLI_SERVER_SOCKET_PORT\n ? parseInt(process.env.BIT_CLI_SERVER_SOCKET_PORT)\n : getPortFromPath(process.cwd());\n}\n\n/**\n * it's easier to generate a random port based on the workspace path than to save it in a file\n */\nexport function getPortFromPath(path: string): number {\n // Step 1: Hash the workspace path using MD5\n const hash = crypto.createHash('md5').update(path).digest('hex');\n\n // Step 2: Convert a portion of the hash to an integer\n // We'll use the first 8 characters (32 bits)\n const hashInt = parseInt(hash.substring(0, 8), 16);\n\n // Step 3: Map the integer to the port range 49152 to 65535 (these are dynamic ports not assigned by IANA)\n const minPort = 49152;\n const maxPort = 65535;\n const portRange = maxPort - minPort + 1;\n\n const port = (hashInt % portRange) + minPort;\n\n return port;\n}\n\nexport function getPidByPort(port: number, consoleErrors = false): string | null {\n const platform = process.platform;\n try {\n if (platform === 'darwin' || platform === 'linux') {\n // For macOS and Linux\n const cmd = `lsof -iTCP:${port} -sTCP:LISTEN -n -P`;\n const stdout = execSync(cmd).toString();\n const lines = stdout.trim().split('\\n');\n\n if (lines.length > 1) {\n // Skip the header line and parse the first result\n const columns = lines[1].split(/\\s+/);\n const pid = columns[1];\n return pid;\n }\n } else if (platform === 'win32') {\n // For Windows\n const cmd = `netstat -ano -p tcp`;\n const stdout = execSync(cmd).toString();\n const lines = stdout.trim().split('\\n');\n\n for (const line of lines) {\n if (line.trim().startsWith('TCP')) {\n const columns = line.trim().split(/\\s+/);\n const localAddress = columns[1];\n const pid = columns[4];\n\n if (localAddress.endsWith(`:${port}`)) {\n return pid;\n }\n }\n }\n } else {\n if (consoleErrors) console.error('Unsupported platform:', platform);\n }\n } catch (error: any) {\n if (consoleErrors) console.error('Error executing command:', error.message);\n }\n return null;\n}\n"],"mappings":";;;;;;;;;AASA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,IAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,GAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,SAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAyC,SAAAC,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAbzC;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAQO,SAASG,QAAQA,CAAA,EAAG;EACzB;EACA;EACA,MAAMC,KAAK,GAAGC,OAAO,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAACC,MAAM,CAAEC,GAAG,IAAKA,GAAG,CAACC,UAAU,CAAC,GAAG,CAAC,CAAC;EACxE,MAAMC,IAAI,GAAG;IACXC,IAAI,EAAE,aAAa;IACnBC,IAAI,EAAE,EAAE;IACRC,IAAI,EAAE,EAAE;IACRC,GAAG,EAA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EvC,KAAK,MAAME,IAAI,IAAIJ,KAAK,EAAE;QACxB,IAAII,IAAI,CAACH,IAAI,CAAC,CAAC,CAAChE,UAAU,CAAC,KAAK,CAAC,EAAE;UACjC,MAAMkE,OAAO,GAAGC,IAAI,CAACH,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,KAAK,CAAC;UACxC,MAAMG,YAAY,GAAGF,OAAO,CAAC,CAAC,CAAC;UAC/B,MAAM/B,GAAG,GAAG+B,OAAO,CAAC,CAAC,CAAC;UAEtB,IAAIE,YAAY,CAACC,QAAQ,CAAC,IAAIX,IAAI,EAAE,CAAC,EAAE;YACrC,OAAOvB,GAAG;UACZ;QACF;MACF;IACF,CAAC,MAAM;MACL,IAAIwB,aAAa,EAAEpC,OAAO,CAACS,KAAK,CAAC,uBAAuB,EAAEvB,QAAQ,CAAC;IACrE;EACF,CAAC,CAAC,OAAOuB,KAAU,EAAE;IACnB,IAAI2B,aAAa,EAAEpC,OAAO,CAACS,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAACsC,OAAO,CAAC;EAC7E;EACA,OAAO,IAAI;AACb","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/bit",
3
- "version": "1.9.53",
3
+ "version": "1.9.55",
4
4
  "homepage": "https://bit.cloud/teambit/harmony/bit",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.harmony",
8
8
  "name": "bit",
9
- "version": "1.9.53"
9
+ "version": "1.9.55"
10
10
  },
11
11
  "dependencies": {
12
12
  "graceful-fs": "4.2.10",
@@ -49,125 +49,125 @@
49
49
  "@teambit/legacy-bit-id": "1.1.1",
50
50
  "@teambit/ui-foundation.ui.navigation.react-router-adapter": "6.1.1",
51
51
  "@teambit/base-react.navigation.link": "2.0.31",
52
- "@teambit/cli": "0.0.1104",
53
- "@teambit/harmony.content.cli-reference": "2.0.539",
54
- "@teambit/legacy.extension-data": "0.0.26",
52
+ "@teambit/cli": "0.0.1106",
53
+ "@teambit/harmony.content.cli-reference": "2.0.541",
54
+ "@teambit/legacy.extension-data": "0.0.27",
55
55
  "@teambit/bit.get-bit-version": "0.0.3",
56
56
  "@teambit/legacy.analytics": "0.0.68",
57
57
  "@teambit/legacy.constants": "0.0.8",
58
58
  "@teambit/legacy.loader": "0.0.5",
59
59
  "@teambit/legacy.logger": "0.0.10",
60
- "@teambit/aspect-loader": "1.0.527",
61
- "@teambit/clear-cache": "0.0.443",
62
- "@teambit/config": "0.0.1278",
63
- "@teambit/envs": "1.0.527",
64
- "@teambit/generator": "1.0.528",
65
- "@teambit/legacy.bit-map": "0.0.81",
66
- "@teambit/legacy.consumer-component": "0.0.25",
67
- "@teambit/legacy.consumer-config": "0.0.24",
68
- "@teambit/legacy.consumer": "0.0.24",
69
- "@teambit/legacy.scope-api": "0.0.79",
60
+ "@teambit/aspect-loader": "1.0.529",
61
+ "@teambit/clear-cache": "0.0.444",
62
+ "@teambit/config": "0.0.1280",
63
+ "@teambit/envs": "1.0.529",
64
+ "@teambit/generator": "1.0.530",
65
+ "@teambit/legacy.bit-map": "0.0.82",
66
+ "@teambit/legacy.consumer-component": "0.0.26",
67
+ "@teambit/legacy.consumer-config": "0.0.25",
68
+ "@teambit/legacy.consumer": "0.0.25",
69
+ "@teambit/legacy.scope-api": "0.0.80",
70
70
  "@teambit/scope.modules.find-scope-path": "0.0.9",
71
- "@teambit/workspace.modules.node-modules-linker": "0.0.252",
71
+ "@teambit/workspace.modules.node-modules-linker": "0.0.253",
72
72
  "@teambit/workspace.modules.workspace-locator": "0.0.9",
73
- "@teambit/api-reference": "1.0.527",
74
- "@teambit/api-server": "1.0.527",
75
- "@teambit/application": "1.0.527",
76
- "@teambit/aspect": "1.0.527",
77
- "@teambit/babel": "1.0.527",
78
- "@teambit/builder": "1.0.527",
79
- "@teambit/bundler": "1.0.527",
80
- "@teambit/cache": "0.0.1197",
81
- "@teambit/changelog": "1.0.527",
82
- "@teambit/checkout": "1.0.527",
83
- "@teambit/cloud": "0.0.803",
84
- "@teambit/code": "1.0.527",
85
- "@teambit/command-bar": "1.0.527",
86
- "@teambit/community": "1.0.527",
87
- "@teambit/compiler": "1.0.527",
88
- "@teambit/component-compare": "1.0.527",
89
- "@teambit/component-log": "1.0.527",
90
- "@teambit/component-sizer": "1.0.527",
91
- "@teambit/component-tree": "1.0.527",
92
- "@teambit/component-writer": "1.0.527",
93
- "@teambit/component": "1.0.527",
94
- "@teambit/compositions": "1.0.527",
95
- "@teambit/config-merger": "0.0.394",
96
- "@teambit/dependencies": "1.0.527",
97
- "@teambit/dependency-resolver": "1.0.527",
98
- "@teambit/deprecation": "1.0.527",
99
- "@teambit/dev-files": "1.0.527",
100
- "@teambit/diagnostic": "1.0.527",
101
- "@teambit/docs": "1.0.527",
102
- "@teambit/doctor": "0.0.210",
103
- "@teambit/eject": "1.0.527",
104
- "@teambit/env": "1.0.527",
105
- "@teambit/eslint": "1.0.527",
106
- "@teambit/export": "1.0.527",
107
- "@teambit/express": "0.0.1203",
108
- "@teambit/forking": "1.0.527",
109
- "@teambit/formatter": "1.0.527",
110
- "@teambit/git": "1.0.527",
111
- "@teambit/global-config": "0.0.1107",
112
- "@teambit/graph": "1.0.527",
113
- "@teambit/graphql": "1.0.527",
114
- "@teambit/harmony-ui-app": "1.0.527",
115
- "@teambit/host-initializer": "0.0.240",
116
- "@teambit/importer": "1.0.527",
117
- "@teambit/insights": "1.0.527",
118
- "@teambit/install": "1.0.527",
119
- "@teambit/ipc-events": "1.0.527",
120
- "@teambit/isolator": "1.0.527",
121
- "@teambit/issues": "1.0.527",
122
- "@teambit/jest": "1.0.527",
123
- "@teambit/lanes": "1.0.527",
124
- "@teambit/linter": "1.0.527",
125
- "@teambit/lister": "1.0.527",
126
- "@teambit/logger": "0.0.1197",
127
- "@teambit/mdx": "1.0.527",
128
- "@teambit/merge-lanes": "1.0.527",
129
- "@teambit/merging": "1.0.527",
130
- "@teambit/mocha": "1.0.527",
131
- "@teambit/mover": "1.0.527",
132
- "@teambit/multi-compiler": "1.0.527",
133
- "@teambit/multi-tester": "1.0.527",
134
- "@teambit/new-component-helper": "1.0.527",
135
- "@teambit/node": "1.0.527",
136
- "@teambit/notifications": "1.0.527",
137
- "@teambit/objects": "0.0.34",
138
- "@teambit/panels": "0.0.1106",
139
- "@teambit/pkg": "1.0.527",
140
- "@teambit/pnpm": "1.0.528",
141
- "@teambit/prettier": "1.0.527",
142
- "@teambit/preview": "1.0.527",
143
- "@teambit/pubsub": "1.0.527",
144
- "@teambit/react-router": "1.0.527",
145
- "@teambit/react": "1.0.527",
146
- "@teambit/readme": "1.0.527",
147
- "@teambit/refactoring": "1.0.527",
148
- "@teambit/remove": "1.0.527",
149
- "@teambit/renaming": "1.0.527",
150
- "@teambit/schema": "1.0.527",
151
- "@teambit/scope": "1.0.527",
152
- "@teambit/sidebar": "1.0.527",
153
- "@teambit/sign": "1.0.527",
154
- "@teambit/snapping": "1.0.527",
155
- "@teambit/stash": "1.0.527",
156
- "@teambit/status": "1.0.527",
157
- "@teambit/tester": "1.0.527",
158
- "@teambit/tracker": "1.0.527",
159
- "@teambit/typescript": "1.0.527",
160
- "@teambit/ui": "1.0.527",
161
- "@teambit/update-dependencies": "1.0.527",
162
- "@teambit/user-agent": "1.0.527",
163
- "@teambit/variants": "0.0.1371",
164
- "@teambit/version-history": "0.0.319",
165
- "@teambit/watcher": "1.0.527",
166
- "@teambit/webpack": "1.0.527",
167
- "@teambit/worker": "0.0.1408",
168
- "@teambit/workspace-config-files": "1.0.527",
169
- "@teambit/workspace": "1.0.527",
170
- "@teambit/yarn": "1.0.527"
73
+ "@teambit/api-reference": "1.0.529",
74
+ "@teambit/api-server": "1.0.529",
75
+ "@teambit/application": "1.0.529",
76
+ "@teambit/aspect": "1.0.529",
77
+ "@teambit/babel": "1.0.529",
78
+ "@teambit/builder": "1.0.529",
79
+ "@teambit/bundler": "1.0.529",
80
+ "@teambit/cache": "0.0.1199",
81
+ "@teambit/changelog": "1.0.529",
82
+ "@teambit/checkout": "1.0.529",
83
+ "@teambit/cloud": "0.0.805",
84
+ "@teambit/code": "1.0.529",
85
+ "@teambit/command-bar": "1.0.529",
86
+ "@teambit/community": "1.0.529",
87
+ "@teambit/compiler": "1.0.529",
88
+ "@teambit/component-compare": "1.0.529",
89
+ "@teambit/component-log": "1.0.529",
90
+ "@teambit/component-sizer": "1.0.529",
91
+ "@teambit/component-tree": "1.0.529",
92
+ "@teambit/component-writer": "1.0.529",
93
+ "@teambit/component": "1.0.529",
94
+ "@teambit/compositions": "1.0.529",
95
+ "@teambit/config-merger": "0.0.396",
96
+ "@teambit/dependencies": "1.0.529",
97
+ "@teambit/dependency-resolver": "1.0.529",
98
+ "@teambit/deprecation": "1.0.529",
99
+ "@teambit/dev-files": "1.0.529",
100
+ "@teambit/diagnostic": "1.0.529",
101
+ "@teambit/docs": "1.0.529",
102
+ "@teambit/doctor": "0.0.212",
103
+ "@teambit/eject": "1.0.529",
104
+ "@teambit/env": "1.0.529",
105
+ "@teambit/eslint": "1.0.529",
106
+ "@teambit/export": "1.0.529",
107
+ "@teambit/express": "0.0.1205",
108
+ "@teambit/forking": "1.0.529",
109
+ "@teambit/formatter": "1.0.529",
110
+ "@teambit/git": "1.0.529",
111
+ "@teambit/global-config": "0.0.1109",
112
+ "@teambit/graph": "1.0.529",
113
+ "@teambit/graphql": "1.0.529",
114
+ "@teambit/harmony-ui-app": "1.0.529",
115
+ "@teambit/host-initializer": "0.0.242",
116
+ "@teambit/importer": "1.0.529",
117
+ "@teambit/insights": "1.0.529",
118
+ "@teambit/install": "1.0.529",
119
+ "@teambit/ipc-events": "1.0.529",
120
+ "@teambit/isolator": "1.0.529",
121
+ "@teambit/issues": "1.0.529",
122
+ "@teambit/jest": "1.0.529",
123
+ "@teambit/lanes": "1.0.529",
124
+ "@teambit/linter": "1.0.529",
125
+ "@teambit/lister": "1.0.529",
126
+ "@teambit/logger": "0.0.1199",
127
+ "@teambit/mdx": "1.0.529",
128
+ "@teambit/merge-lanes": "1.0.529",
129
+ "@teambit/merging": "1.0.529",
130
+ "@teambit/mocha": "1.0.529",
131
+ "@teambit/mover": "1.0.529",
132
+ "@teambit/multi-compiler": "1.0.529",
133
+ "@teambit/multi-tester": "1.0.529",
134
+ "@teambit/new-component-helper": "1.0.529",
135
+ "@teambit/node": "1.0.529",
136
+ "@teambit/notifications": "1.0.529",
137
+ "@teambit/objects": "0.0.36",
138
+ "@teambit/panels": "0.0.1108",
139
+ "@teambit/pkg": "1.0.529",
140
+ "@teambit/pnpm": "1.0.530",
141
+ "@teambit/prettier": "1.0.529",
142
+ "@teambit/preview": "1.0.529",
143
+ "@teambit/pubsub": "1.0.529",
144
+ "@teambit/react-router": "1.0.529",
145
+ "@teambit/react": "1.0.529",
146
+ "@teambit/readme": "1.0.529",
147
+ "@teambit/refactoring": "1.0.529",
148
+ "@teambit/remove": "1.0.529",
149
+ "@teambit/renaming": "1.0.529",
150
+ "@teambit/schema": "1.0.529",
151
+ "@teambit/scope": "1.0.529",
152
+ "@teambit/sidebar": "1.0.529",
153
+ "@teambit/sign": "1.0.529",
154
+ "@teambit/snapping": "1.0.529",
155
+ "@teambit/stash": "1.0.529",
156
+ "@teambit/status": "1.0.529",
157
+ "@teambit/tester": "1.0.529",
158
+ "@teambit/tracker": "1.0.529",
159
+ "@teambit/typescript": "1.0.529",
160
+ "@teambit/ui": "1.0.529",
161
+ "@teambit/update-dependencies": "1.0.529",
162
+ "@teambit/user-agent": "1.0.529",
163
+ "@teambit/variants": "0.0.1373",
164
+ "@teambit/version-history": "0.0.321",
165
+ "@teambit/watcher": "1.0.529",
166
+ "@teambit/webpack": "1.0.529",
167
+ "@teambit/worker": "0.0.1410",
168
+ "@teambit/workspace-config-files": "1.0.529",
169
+ "@teambit/workspace": "1.0.529",
170
+ "@teambit/yarn": "1.0.529"
171
171
  },
172
172
  "devDependencies": {
173
173
  "@types/fs-extra": "9.0.7",