@lage-run/cli 0.24.5 → 0.24.7
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.
- package/CHANGELOG.json +43 -1
- package/CHANGELOG.md +20 -2
- package/lib/commands/exec/executeRemotely.d.ts +1 -0
- package/lib/commands/exec/executeRemotely.js +3 -26
- package/lib/commands/exec/executeRemotely.js.map +1 -1
- package/lib/commands/exec/index.js +1 -0
- package/lib/commands/exec/index.js.map +1 -1
- package/lib/commands/launchServerInBackground.d.ts +2 -1
- package/lib/commands/launchServerInBackground.js +9 -4
- package/lib/commands/launchServerInBackground.js.map +1 -1
- package/lib/commands/server/index.js +1 -0
- package/lib/commands/server/index.js.map +1 -1
- package/lib/commands/server/lageService.js +87 -79
- package/lib/commands/server/lageService.js.map +1 -1
- package/lib/getBinPaths.d.ts +4 -0
- package/lib/getBinPaths.js +31 -3
- package/lib/getBinPaths.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,49 @@
|
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Mon, 09 Dec 2024 06:21:41 GMT",
|
|
6
|
+
"version": "0.24.7",
|
|
7
|
+
"tag": "@lage-run/cli_v0.24.7",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "kchau@microsoft.com",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"commit": "4584a7356e544bd87a0c79180baa9f14cd971baf",
|
|
14
|
+
"comment": "fixing the outputs so it includes files I/O"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Sun, 08 Dec 2024 00:07:28 GMT",
|
|
21
|
+
"version": "0.24.6",
|
|
22
|
+
"tag": "@lage-run/cli_v0.24.6",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "kchau@microsoft.com",
|
|
27
|
+
"package": "@lage-run/cli",
|
|
28
|
+
"commit": "e6eaba8d27f25d746caed332198519a7dc4a218e",
|
|
29
|
+
"comment": "adds the ability to do workerIdleMemoryLimit"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "beachball",
|
|
33
|
+
"package": "@lage-run/cli",
|
|
34
|
+
"comment": "Bump @lage-run/scheduler to v1.4.2",
|
|
35
|
+
"commit": "not available"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "beachball",
|
|
39
|
+
"package": "@lage-run/cli",
|
|
40
|
+
"comment": "Bump @lage-run/worker-threads-pool to v0.8.6",
|
|
41
|
+
"commit": "not available"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"date": "Wed, 04 Dec 2024 23:50:15 GMT",
|
|
6
48
|
"version": "0.24.5",
|
|
7
49
|
"tag": "@lage-run/cli_v0.24.5",
|
|
8
50
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
# Change Log - @lage-run/cli
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Mon, 09 Dec 2024 06:21:41 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.24.7
|
|
8
|
+
|
|
9
|
+
Mon, 09 Dec 2024 06:21:41 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- fixing the outputs so it includes files I/O (kchau@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 0.24.6
|
|
16
|
+
|
|
17
|
+
Sun, 08 Dec 2024 00:07:28 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- adds the ability to do workerIdleMemoryLimit (kchau@microsoft.com)
|
|
22
|
+
- Bump @lage-run/scheduler to v1.4.2
|
|
23
|
+
- Bump @lage-run/worker-threads-pool to v0.8.6
|
|
24
|
+
|
|
7
25
|
## 0.24.5
|
|
8
26
|
|
|
9
|
-
Wed, 04 Dec 2024 23:
|
|
27
|
+
Wed, 04 Dec 2024 23:50:15 GMT
|
|
10
28
|
|
|
11
29
|
### Patches
|
|
12
30
|
|
|
@@ -5,6 +5,7 @@ interface ExecRemotelyOptions extends ReporterInitOptions {
|
|
|
5
5
|
server?: string | boolean;
|
|
6
6
|
timeout?: number;
|
|
7
7
|
tasks: string[];
|
|
8
|
+
nodeArg?: string;
|
|
8
9
|
}
|
|
9
10
|
export declare function executeRemotely(options: ExecRemotelyOptions, command: Command): Promise<void>;
|
|
10
11
|
export {};
|
|
@@ -14,8 +14,6 @@ const _rpc = require("@lage-run/rpc");
|
|
|
14
14
|
const _filterArgsForTasks = require("../run/filterArgsForTasks.js");
|
|
15
15
|
const _simulateFileAccess = require("./simulateFileAccess.js");
|
|
16
16
|
const _parseServerOption = require("../parseServerOption.js");
|
|
17
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
18
|
-
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
19
17
|
const _workspacetools = require("workspace-tools");
|
|
20
18
|
const _launchServerInBackground = require("../launchServerInBackground.js");
|
|
21
19
|
function _interop_require_default(obj) {
|
|
@@ -86,32 +84,10 @@ async function executeOnServer(args, client, logger) {
|
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
|
-
function isAlive(pid) {
|
|
90
|
-
try {
|
|
91
|
-
return process.kill(pid, 0);
|
|
92
|
-
} catch {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function ensurePidFile(lockfilePath) {
|
|
97
|
-
if (!_fs.default.existsSync(_path.default.dirname(lockfilePath))) {
|
|
98
|
-
_fs.default.mkdirSync(_path.default.dirname(lockfilePath), {
|
|
99
|
-
recursive: true
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
if (!_fs.default.existsSync(lockfilePath)) {
|
|
103
|
-
try {
|
|
104
|
-
const fd = _fs.default.openSync(lockfilePath, "w");
|
|
105
|
-
_fs.default.closeSync(fd);
|
|
106
|
-
} catch {
|
|
107
|
-
// ignore
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
87
|
async function executeRemotely(options, command) {
|
|
112
88
|
// launch a 'lage-server.js' process, detached if it is not already running
|
|
113
89
|
// send the command to the server process
|
|
114
|
-
const { server, tasks } = options;
|
|
90
|
+
const { server, tasks, nodeArg } = options;
|
|
115
91
|
const timeout = options.timeout ?? 5 * 60;
|
|
116
92
|
const { host, port } = (0, _parseServerOption.parseServerOption)(server);
|
|
117
93
|
const logger = (0, _logger.default)();
|
|
@@ -130,7 +106,8 @@ async function executeRemotely(options, command) {
|
|
|
130
106
|
args,
|
|
131
107
|
timeout,
|
|
132
108
|
logger,
|
|
133
|
-
root
|
|
109
|
+
root,
|
|
110
|
+
nodeArg
|
|
134
111
|
});
|
|
135
112
|
logger.info("Creating a client to connect to the background services");
|
|
136
113
|
client = await tryCreateClientWithRetries(host, port, logger);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/exec/executeRemotely.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport createLogger from \"@lage-run/logger\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport type { LageClient } from \"@lage-run/rpc\";\nimport { ConnectError, createClient } from \"@lage-run/rpc\";\nimport { filterArgsForTasks } from \"../run/filterArgsForTasks.js\";\nimport { simulateFileAccess } from \"./simulateFileAccess.js\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/exec/executeRemotely.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport createLogger from \"@lage-run/logger\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport type { LageClient } from \"@lage-run/rpc\";\nimport { ConnectError, createClient } from \"@lage-run/rpc\";\nimport { filterArgsForTasks } from \"../run/filterArgsForTasks.js\";\nimport { simulateFileAccess } from \"./simulateFileAccess.js\";\nimport { parseServerOption } from \"../parseServerOption.js\";\nimport { getWorkspaceRoot } from \"workspace-tools\";\nimport type { Command } from \"commander\";\nimport { launchServerInBackground } from \"../launchServerInBackground.js\";\n\ninterface ExecRemotelyOptions extends ReporterInitOptions {\n cwd?: string;\n server?: string | boolean;\n timeout?: number;\n tasks: string[];\n nodeArg?: string;\n}\n\nasync function tryCreateClient(host: string, port: number) {\n const client = createClient({\n baseUrl: `http://${host}:${port}`,\n httpVersion: \"2\",\n });\n\n try {\n const success = await client.ping({});\n if (success.pong) {\n return client;\n }\n } catch (e) {\n if (e instanceof ConnectError) {\n return undefined;\n }\n\n throw e;\n }\n\n return undefined;\n}\n\nasync function tryCreateClientWithRetries(host: string, port: number, logger: Logger) {\n let client: ReturnType<typeof createClient> | undefined;\n\n const start = Date.now();\n while (Date.now() - start < 5 * 1000) {\n try {\n client = await tryCreateClient(host, port);\n\n if (client) {\n return client;\n }\n } catch (e) {\n if (e instanceof ConnectError) {\n logger.error(\"Error connecting to server\", e);\n }\n }\n\n await new Promise((resolve) => setTimeout(resolve, 1000));\n }\n\n return undefined;\n}\n\nasync function executeOnServer(args: string[], client: LageClient, logger: Logger) {\n const task = args.length === 1 ? args[0] : args[1];\n const packageName = args.length > 1 ? args[0] : undefined;\n\n if (!task) {\n throw new Error(\"No task provided\");\n }\n\n const { taskArgs } = filterArgsForTasks(args ?? []);\n\n try {\n const response = await client.runTarget({\n packageName,\n task,\n taskArgs,\n });\n logger.info(`Task ${response.packageName} ${response.task} exited with code ${response.exitCode} `);\n return response;\n } catch (error) {\n if (error instanceof ConnectError) {\n logger.error(\"Error connecting to server\", { error });\n } else {\n logger.error(\"Error running task\", { error });\n }\n }\n}\n\nexport async function executeRemotely(options: ExecRemotelyOptions, command: Command) {\n // launch a 'lage-server.js' process, detached if it is not already running\n // send the command to the server process\n const { server, tasks, nodeArg } = options;\n const timeout = options.timeout ?? 5 * 60;\n\n const { host, port } = parseServerOption(server);\n\n const logger = createLogger();\n options.logLevel = options.logLevel ?? \"info\";\n options.reporter = options.reporter ?? \"json\";\n initializeReporters(logger, options);\n\n const root = getWorkspaceRoot(options.cwd ?? process.cwd())!;\n\n let client = await tryCreateClient(host, port);\n const args = command.args;\n\n logger.info(`Command args ${command.args.join(\" \")}`);\n\n if (!client) {\n await launchServerInBackground({\n host,\n port,\n tasks,\n args,\n timeout,\n logger,\n root,\n nodeArg,\n });\n\n logger.info(\"Creating a client to connect to the background services\");\n client = await tryCreateClientWithRetries(host, port, logger);\n\n if (!client) {\n throw new Error(\"Server could not be started\");\n }\n }\n\n logger.info(`Executing on server http://${host}:${port}`);\n const response = await executeOnServer(args, client, logger);\n\n if (response) {\n process.stdout.write(response.stdout);\n process.stderr.write(response.stderr);\n process.exitCode = response.exitCode;\n\n if (response.exitCode === 0) {\n await simulateFileAccess(logger, response.inputs, response.outputs);\n }\n } else {\n process.exitCode = 1;\n }\n\n logger.info(\"Task execution finished\");\n}\n"],"names":["executeRemotely","tryCreateClient","host","port","client","createClient","baseUrl","httpVersion","success","ping","pong","e","ConnectError","undefined","tryCreateClientWithRetries","logger","start","Date","now","error","Promise","resolve","setTimeout","executeOnServer","args","task","length","packageName","Error","taskArgs","filterArgsForTasks","response","runTarget","info","exitCode","options","command","server","tasks","nodeArg","timeout","parseServerOption","createLogger","logLevel","reporter","initializeReporters","root","getWorkspaceRoot","cwd","process","join","launchServerInBackground","stdout","write","stderr","simulateFileAccess","inputs","outputs"],"mappings":";;;;+BA6FsBA;;;eAAAA;;;+DA5FG;qCACW;qBAGO;oCACR;oCACA;mCACD;gCACD;0CAEQ;;;;;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BAA2BZ,MAAMC,MAAMY;QAEtD,IAAI,CAACX,QAAQ;YACX,MAAM,IAAIwB,MAAM;QAClB;IACF;IAEAb,OAAOkB,IAAI,CAAC,CAAC,2BAA2B,EAAE/B,KAAK,CAAC,EAAEC,MAAM;IACxD,MAAM4B,WAAW,MAAMR,gBAAgBC,MAAMpB,QAAQW;IAErD,IAAIgB,UAAU;QACZkB,QAAQG,MAAM,CAACC,KAAK,CAACtB,SAASqB,MAAM;QACpCH,QAAQK,MAAM,CAACD,KAAK,CAACtB,SAASuB,MAAM;QACpCL,QAAQf,QAAQ,GAAGH,SAASG,QAAQ;QAEpC,IAAIH,SAASG,QAAQ,KAAK,GAAG;YAC3B,MAAMqB,IAAAA,sCAAkB,EAACxC,QAAQgB,SAASyB,MAAM,EAAEzB,SAAS0B,OAAO;QACpE;IACF,OAAO;QACLR,QAAQf,QAAQ,GAAG;IACrB;IAEAnB,OAAOkB,IAAI,CAAC;AACd"}
|
|
@@ -18,6 +18,7 @@ function _interop_require_default(obj) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
const execCommand = new _commander.Command("exec");
|
|
21
|
+
execCommand.option("-n|--node-arg <arg>", "node argument to pass to worker, just a single string to be passed into node like a NODE_OPTIONS setting");
|
|
21
22
|
execCommand.option("-c|--concurrency <number>", "max jobs to run at a time", (v)=>parseInt(v), _os.default.cpus().length - 1);
|
|
22
23
|
execCommand.option("-s|--server [host:port]", "lage server host");
|
|
23
24
|
execCommand.option("-t|--timeout <seconds>", "lage server autoshutoff timeout", (v)=>parseInt(v), 5 * 60);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/exec/index.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { execAction } from \"./action.js\";\nimport { addLoggerOptions } from \"../addLoggerOptions.js\";\nimport os from \"os\";\n\nconst execCommand = new Command(\"exec\");\nexecCommand.option(\"-c|--concurrency <number>\", \"max jobs to run at a time\", (v) => parseInt(v), os.cpus().length - 1);\nexecCommand.option(\"-s|--server [host:port]\", \"lage server host\");\nexecCommand.option<number>(\"-t|--timeout <seconds>\", \"lage server autoshutoff timeout\", (v) => parseInt(v), 5 * 60);\nexecCommand.option(\"--tasks [tasks...]\", \"A list of tasks to run, separated by space e.g. 'build test', used with --server\");\naddLoggerOptions(execCommand).action(execAction);\nexport { execCommand };\n"],"names":["execCommand","Command","option","v","parseInt","os","cpus","length","addLoggerOptions","action","execAction"],"mappings":";;;;+
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/exec/index.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { execAction } from \"./action.js\";\nimport { addLoggerOptions } from \"../addLoggerOptions.js\";\nimport os from \"os\";\n\nconst execCommand = new Command(\"exec\");\nexecCommand.option(\n \"-n|--node-arg <arg>\",\n \"node argument to pass to worker, just a single string to be passed into node like a NODE_OPTIONS setting\"\n);\nexecCommand.option(\"-c|--concurrency <number>\", \"max jobs to run at a time\", (v) => parseInt(v), os.cpus().length - 1);\nexecCommand.option(\"-s|--server [host:port]\", \"lage server host\");\nexecCommand.option<number>(\"-t|--timeout <seconds>\", \"lage server autoshutoff timeout\", (v) => parseInt(v), 5 * 60);\nexecCommand.option(\"--tasks [tasks...]\", \"A list of tasks to run, separated by space e.g. 'build test', used with --server\");\naddLoggerOptions(execCommand).action(execAction);\nexport { execCommand };\n"],"names":["execCommand","Command","option","v","parseInt","os","cpus","length","addLoggerOptions","action","execAction"],"mappings":";;;;+BAeSA;;;eAAAA;;;2BAfe;wBACG;kCACM;2DAClB;;;;;;AAEf,MAAMA,cAAc,IAAIC,kBAAO,CAAC;AAChCD,YAAYE,MAAM,CAChB,uBACA;AAEFF,YAAYE,MAAM,CAAC,6BAA6B,6BAA6B,CAACC,IAAMC,SAASD,IAAIE,WAAE,CAACC,IAAI,GAAGC,MAAM,GAAG;AACpHP,YAAYE,MAAM,CAAC,2BAA2B;AAC9CF,YAAYE,MAAM,CAAS,0BAA0B,mCAAmC,CAACC,IAAMC,SAASD,IAAI,IAAI;AAChHH,YAAYE,MAAM,CAAC,sBAAsB;AACzCM,IAAAA,kCAAgB,EAACR,aAAaS,MAAM,CAACC,kBAAU"}
|
|
@@ -7,5 +7,6 @@ export interface launchServerInBackgroundOptions {
|
|
|
7
7
|
tasks: string[];
|
|
8
8
|
timeout: number;
|
|
9
9
|
args: string[];
|
|
10
|
+
nodeArg?: string;
|
|
10
11
|
}
|
|
11
|
-
export declare function launchServerInBackground({ logger, root, host, port, tasks, timeout, args }: launchServerInBackgroundOptions): Promise<void>;
|
|
12
|
+
export declare function launchServerInBackground({ logger, root, host, port, tasks, timeout, args, nodeArg, }: launchServerInBackgroundOptions): Promise<void>;
|
|
@@ -18,7 +18,7 @@ function _interop_require_default(obj) {
|
|
|
18
18
|
default: obj
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
async function launchServerInBackground({ logger, root, host, port, tasks, timeout, args }) {
|
|
21
|
+
async function launchServerInBackground({ logger, root, host, port, tasks, timeout, args, nodeArg }) {
|
|
22
22
|
const lockfilePath = _path.default.join(root, `node_modules/.cache/lage/.lage-server-${host}-${port}.pid`);
|
|
23
23
|
logger.info(`Starting server on http://${host}:${port}`);
|
|
24
24
|
logger.info(`acquiring lock: ${lockfilePath}`);
|
|
@@ -44,9 +44,14 @@ async function launchServerInBackground({ logger, root, host, port, tasks, timeo
|
|
|
44
44
|
pid
|
|
45
45
|
});
|
|
46
46
|
} else {
|
|
47
|
-
const
|
|
48
|
-
const lageServerBinPath =
|
|
47
|
+
const binScripts = (0, _getBinPaths.getBinScripts)();
|
|
48
|
+
const lageServerBinPath = binScripts["lage-server"];
|
|
49
49
|
const lageServerArgs = [
|
|
50
|
+
...nodeArg ? [
|
|
51
|
+
"--node-arg",
|
|
52
|
+
nodeArg
|
|
53
|
+
] : [],
|
|
54
|
+
lageServerBinPath,
|
|
50
55
|
"--tasks",
|
|
51
56
|
...tasks,
|
|
52
57
|
"--host",
|
|
@@ -58,7 +63,7 @@ async function launchServerInBackground({ logger, root, host, port, tasks, timeo
|
|
|
58
63
|
...args
|
|
59
64
|
];
|
|
60
65
|
logger.info(`Launching lage-server with these parameters: ${lageServerArgs.join(" ")}`);
|
|
61
|
-
const child = (0, _execa.default)(
|
|
66
|
+
const child = (0, _execa.default)("node", lageServerArgs, {
|
|
62
67
|
cwd: root,
|
|
63
68
|
detached: true,
|
|
64
69
|
stdio: "ignore",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/launchServerInBackground.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport execa from \"execa\";\nimport { getBinPaths } from \"../getBinPaths.js\";\n\nexport interface launchServerInBackgroundOptions {\n logger: Logger;\n root: string;\n host: string;\n port: number;\n tasks: string[];\n timeout: number;\n args: string[];\n}\n\nexport async function launchServerInBackground({
|
|
1
|
+
{"version":3,"sources":["../../src/commands/launchServerInBackground.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport execa from \"execa\";\nimport { getBinPaths, getBinScripts } from \"../getBinPaths.js\";\n\nexport interface launchServerInBackgroundOptions {\n logger: Logger;\n root: string;\n host: string;\n port: number;\n tasks: string[];\n timeout: number;\n args: string[];\n nodeArg?: string;\n}\n\nexport async function launchServerInBackground({\n logger,\n root,\n host,\n port,\n tasks,\n timeout,\n args,\n nodeArg,\n}: launchServerInBackgroundOptions) {\n const lockfilePath = path.join(root, `node_modules/.cache/lage/.lage-server-${host}-${port}.pid`);\n\n logger.info(`Starting server on http://${host}:${port}`);\n logger.info(`acquiring lock: ${lockfilePath}`);\n\n ensurePidFile(lockfilePath);\n\n const releaseLock = await lockfile.lock(lockfilePath, {\n stale: 1000 * 60 * 1,\n retries: {\n retries: 10,\n factor: 3,\n minTimeout: 0.5 * 1000,\n maxTimeout: 60 * 1000,\n randomize: true,\n },\n });\n\n const pid = parseInt(fs.readFileSync(lockfilePath, \"utf-8\"));\n const isServerRunning = pid && isAlive(pid);\n logger.info(\"Checking if server is already running\", { pid, isServerRunning });\n if (pid && isServerRunning) {\n logger.info(\"Server already running\", { pid });\n } else {\n const binScripts = getBinScripts();\n\n const lageServerBinPath = binScripts[\"lage-server\"];\n const lageServerArgs = [\n ...(nodeArg ? [\"--node-arg\", nodeArg] : []),\n lageServerBinPath,\n \"--tasks\",\n ...tasks,\n \"--host\",\n host,\n \"--port\",\n `${port}`,\n \"--timeout\",\n `${timeout}`,\n ...args,\n ];\n\n logger.info(`Launching lage-server with these parameters: ${lageServerArgs.join(\" \")}`);\n const child = execa(\"node\", lageServerArgs, {\n cwd: root,\n detached: true,\n stdio: \"ignore\",\n maxBuffer: 1024 * 1024 * 100,\n });\n\n if (child && child.pid) {\n fs.writeFileSync(lockfilePath, child.pid.toString());\n }\n\n child.unref();\n logger.info(\"Server started\", { pid: child.pid });\n }\n\n await releaseLock();\n}\n\nfunction ensurePidFile(lockfilePath: string) {\n if (!fs.existsSync(path.dirname(lockfilePath))) {\n fs.mkdirSync(path.dirname(lockfilePath), { recursive: true });\n }\n\n if (!fs.existsSync(lockfilePath)) {\n try {\n const fd = fs.openSync(lockfilePath, \"w\");\n fs.closeSync(fd);\n } catch {\n // ignore\n }\n }\n}\n\nfunction isAlive(pid: number) {\n try {\n return process.kill(pid, 0);\n } catch {\n return false;\n }\n}\n"],"names":["launchServerInBackground","logger","root","host","port","tasks","timeout","args","nodeArg","lockfilePath","path","join","info","ensurePidFile","releaseLock","lockfile","lock","stale","retries","factor","minTimeout","maxTimeout","randomize","pid","parseInt","fs","readFileSync","isServerRunning","isAlive","binScripts","getBinScripts","lageServerBinPath","lageServerArgs","child","execa","cwd","detached","stdio","maxBuffer","writeFileSync","toString","unref","existsSync","dirname","mkdirSync","recursive","fd","openSync","closeSync","process","kill"],"mappings":";;;;+BAkBsBA;;;eAAAA;;;2DAjBP;6DAC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C,UAAU;YACVC,OAAO;YACPC,WAAW,OAAO,OAAO;QAC3B;QAEA,IAAIL,SAASA,MAAMV,GAAG,EAAE;YACtBE,WAAE,CAACc,aAAa,CAAC9B,cAAcwB,MAAMV,GAAG,CAACiB,QAAQ;QACnD;QAEAP,MAAMQ,KAAK;QACXxC,OAAOW,IAAI,CAAC,kBAAkB;YAAEW,KAAKU,MAAMV,GAAG;QAAC;IACjD;IAEA,MAAMT;AACR;AAEA,SAASD,cAAcJ,YAAoB;IACzC,IAAI,CAACgB,WAAE,CAACiB,UAAU,CAAChC,aAAI,CAACiC,OAAO,CAAClC,gBAAgB;QAC9CgB,WAAE,CAACmB,SAAS,CAAClC,aAAI,CAACiC,OAAO,CAAClC,eAAe;YAAEoC,WAAW;QAAK;IAC7D;IAEA,IAAI,CAACpB,WAAE,CAACiB,UAAU,CAACjC,eAAe;QAChC,IAAI;YACF,MAAMqC,KAAKrB,WAAE,CAACsB,QAAQ,CAACtC,cAAc;YACrCgB,WAAE,CAACuB,SAAS,CAACF;QACf,EAAE,OAAM;QACN,SAAS;QACX;IACF;AACF;AAEA,SAASlB,QAAQL,GAAW;IAC1B,IAAI;QACF,OAAO0B,QAAQC,IAAI,CAAC3B,KAAK;IAC3B,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
|
@@ -12,6 +12,7 @@ const _commander = require("commander");
|
|
|
12
12
|
const _action = require("./action.js");
|
|
13
13
|
const _addLoggerOptions = require("../addLoggerOptions.js");
|
|
14
14
|
const serverCommand = new _commander.Command("server");
|
|
15
|
+
serverCommand.option("-n|--node-arg <arg>", "node argument to pass to worker, just a single string to be passed into node like a NODE_OPTIONS setting");
|
|
15
16
|
serverCommand.option("-c|--concurrency <number>", "max jobs to run at a time", (v)=>parseInt(v));
|
|
16
17
|
serverCommand.option("-h|--host <host>", "lage server host", "localhost");
|
|
17
18
|
serverCommand.option("-p|--port <port>", "lage worker server port", (v)=>parseInt(v), 5332);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/server/index.ts"],"sourcesContent":["import os from \"os\";\nimport { Command } from \"commander\";\nimport { serverAction } from \"./action.js\";\nimport { addLoggerOptions } from \"../addLoggerOptions.js\";\n\nconst serverCommand = new Command(\"server\");\nserverCommand.option(\"-c|--concurrency <number>\", \"max jobs to run at a time\", (v) => parseInt(v));\nserverCommand.option(\"-h|--host <host>\", \"lage server host\", \"localhost\");\nserverCommand.option<number>(\"-p|--port <port>\", \"lage worker server port\", (v) => parseInt(v), 5332);\nserverCommand.option<number>(\"-t|--timeout <seconds>\", \"lage server autoshutoff timeout\", (v) => parseInt(v), 5 * 60);\nserverCommand.option(\"--tasks <tasks...>\", \"A list of tasks to run, separated by space e.g. 'build test'\");\n\naddLoggerOptions(serverCommand).action(serverAction);\n\nexport { serverCommand };\n"],"names":["serverCommand","Command","option","v","parseInt","addLoggerOptions","action","serverAction"],"mappings":";;;;+
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/server/index.ts"],"sourcesContent":["import os from \"os\";\nimport { Command } from \"commander\";\nimport { serverAction } from \"./action.js\";\nimport { addLoggerOptions } from \"../addLoggerOptions.js\";\n\nconst serverCommand = new Command(\"server\");\nserverCommand.option(\n \"-n|--node-arg <arg>\",\n \"node argument to pass to worker, just a single string to be passed into node like a NODE_OPTIONS setting\"\n);\nserverCommand.option(\"-c|--concurrency <number>\", \"max jobs to run at a time\", (v) => parseInt(v));\nserverCommand.option(\"-h|--host <host>\", \"lage server host\", \"localhost\");\nserverCommand.option<number>(\"-p|--port <port>\", \"lage worker server port\", (v) => parseInt(v), 5332);\nserverCommand.option<number>(\"-t|--timeout <seconds>\", \"lage server autoshutoff timeout\", (v) => parseInt(v), 5 * 60);\nserverCommand.option(\"--tasks <tasks...>\", \"A list of tasks to run, separated by space e.g. 'build test'\");\n\naddLoggerOptions(serverCommand).action(serverAction);\n\nexport { serverCommand };\n"],"names":["serverCommand","Command","option","v","parseInt","addLoggerOptions","action","serverAction"],"mappings":";;;;+BAkBSA;;;eAAAA;;;2BAjBe;wBACK;kCACI;AAEjC,MAAMA,gBAAgB,IAAIC,kBAAO,CAAC;AAClCD,cAAcE,MAAM,CAClB,uBACA;AAEFF,cAAcE,MAAM,CAAC,6BAA6B,6BAA6B,CAACC,IAAMC,SAASD;AAC/FH,cAAcE,MAAM,CAAC,oBAAoB,oBAAoB;AAC7DF,cAAcE,MAAM,CAAS,oBAAoB,2BAA2B,CAACC,IAAMC,SAASD,IAAI;AAChGH,cAAcE,MAAM,CAAS,0BAA0B,mCAAmC,CAACC,IAAMC,SAASD,IAAI,IAAI;AAClHH,cAAcE,MAAM,CAAC,sBAAsB;AAE3CG,IAAAA,kCAAgB,EAACL,eAAeM,MAAM,CAACC,oBAAY"}
|
|
@@ -24,90 +24,91 @@ let initializedPromise;
|
|
|
24
24
|
function formatBytes(bytes) {
|
|
25
25
|
return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
|
|
26
26
|
}
|
|
27
|
+
async function createInitializedPromise({ cwd, logger, serverControls, nodeArg, taskArgs, concurrency, tasks }) {
|
|
28
|
+
if (initializedPromise) {
|
|
29
|
+
return initializedPromise;
|
|
30
|
+
}
|
|
31
|
+
const config = await (0, _config.getConfig)(cwd);
|
|
32
|
+
const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
|
|
33
|
+
const maxWorkers = (0, _config.getConcurrency)(concurrency, config.concurrency);
|
|
34
|
+
logger.info(`Initializing with ${maxWorkers} workers, tasks: ${tasks.join(", ")}`);
|
|
35
|
+
const { pipeline } = config;
|
|
36
|
+
const packageInfos = (0, _workspacetools.getPackageInfos)(root);
|
|
37
|
+
const targetGraph = await (0, _createTargetGraph.createTargetGraph)({
|
|
38
|
+
logger,
|
|
39
|
+
root,
|
|
40
|
+
dependencies: false,
|
|
41
|
+
dependents: false,
|
|
42
|
+
ignore: [],
|
|
43
|
+
pipeline,
|
|
44
|
+
repoWideChanges: config.repoWideChanges,
|
|
45
|
+
scope: undefined,
|
|
46
|
+
since: undefined,
|
|
47
|
+
outputs: config.cacheOptions.outputGlob,
|
|
48
|
+
tasks,
|
|
49
|
+
packageInfos
|
|
50
|
+
});
|
|
51
|
+
const dependencyMap = (0, _workspacetools.createDependencyMap)(packageInfos, {
|
|
52
|
+
withDevDependencies: true,
|
|
53
|
+
withPeerDependencies: false
|
|
54
|
+
});
|
|
55
|
+
const packageTree = new _hasher.PackageTree({
|
|
56
|
+
root,
|
|
57
|
+
packageInfos,
|
|
58
|
+
includeUntracked: true
|
|
59
|
+
});
|
|
60
|
+
logger.info("Initializing Package Tree");
|
|
61
|
+
await packageTree.initialize();
|
|
62
|
+
const filteredPipeline = (0, _filterPipelineDefinitions.filterPipelineDefinitions)(targetGraph.targets.values(), config.pipeline);
|
|
63
|
+
const pool = new _workerthreadspool.AggregatedPool({
|
|
64
|
+
logger,
|
|
65
|
+
maxWorkersByGroup: new Map([
|
|
66
|
+
...(0, _config.getMaxWorkersPerTask)(filteredPipeline, maxWorkers)
|
|
67
|
+
]),
|
|
68
|
+
groupBy: ({ target })=>target.task,
|
|
69
|
+
maxWorkers,
|
|
70
|
+
script: require.resolve("./singleTargetWorker.js"),
|
|
71
|
+
workerOptions: {
|
|
72
|
+
stdout: true,
|
|
73
|
+
stderr: true,
|
|
74
|
+
workerData: {
|
|
75
|
+
runners: {
|
|
76
|
+
...(0, _runnerPickerOptions.runnerPickerOptions)(nodeArg, config.npmClient, taskArgs),
|
|
77
|
+
...config.runners,
|
|
78
|
+
shouldCache: false,
|
|
79
|
+
shouldResetCache: false
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
workerIdleMemoryLimit: config.workerIdleMemoryLimit
|
|
84
|
+
});
|
|
85
|
+
serverControls.abortController.signal.addEventListener("abort", ()=>{
|
|
86
|
+
pool?.close();
|
|
87
|
+
});
|
|
88
|
+
pool?.on("freedWorker", ()=>{
|
|
89
|
+
logger.silly(`Max Worker Memory Usage: ${formatBytes(pool?.stats().maxWorkerMemoryUsage)}`);
|
|
90
|
+
});
|
|
91
|
+
pool?.on("idle", ()=>{
|
|
92
|
+
logger.info("All workers are idle, shutting down after timeout");
|
|
93
|
+
serverControls.countdownToShutdown();
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
config,
|
|
97
|
+
targetGraph,
|
|
98
|
+
packageTree,
|
|
99
|
+
dependencyMap,
|
|
100
|
+
root,
|
|
101
|
+
pool
|
|
102
|
+
};
|
|
103
|
+
}
|
|
27
104
|
/**
|
|
28
105
|
* Initializes the lageService: the extra "initializePromise" ensures only one initialization is done at a time across threads
|
|
29
106
|
* @param cwd
|
|
30
107
|
* @param logger
|
|
31
108
|
* @returns
|
|
32
|
-
*/ async function initialize(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return initializedPromise;
|
|
36
|
-
}
|
|
37
|
-
const config = await (0, _config.getConfig)(cwd);
|
|
38
|
-
const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
|
|
39
|
-
const maxWorkers = (0, _config.getConcurrency)(concurrency, config.concurrency);
|
|
40
|
-
logger.info(`Initializing with ${maxWorkers} workers, tasks: ${tasks.join(", ")}`);
|
|
41
|
-
const { pipeline } = config;
|
|
42
|
-
const packageInfos = (0, _workspacetools.getPackageInfos)(root);
|
|
43
|
-
const targetGraph = await (0, _createTargetGraph.createTargetGraph)({
|
|
44
|
-
logger,
|
|
45
|
-
root,
|
|
46
|
-
dependencies: false,
|
|
47
|
-
dependents: false,
|
|
48
|
-
ignore: [],
|
|
49
|
-
pipeline,
|
|
50
|
-
repoWideChanges: config.repoWideChanges,
|
|
51
|
-
scope: undefined,
|
|
52
|
-
since: undefined,
|
|
53
|
-
outputs: config.cacheOptions.outputGlob,
|
|
54
|
-
tasks,
|
|
55
|
-
packageInfos
|
|
56
|
-
});
|
|
57
|
-
const dependencyMap = (0, _workspacetools.createDependencyMap)(packageInfos, {
|
|
58
|
-
withDevDependencies: true,
|
|
59
|
-
withPeerDependencies: false
|
|
60
|
-
});
|
|
61
|
-
const packageTree = new _hasher.PackageTree({
|
|
62
|
-
root,
|
|
63
|
-
packageInfos,
|
|
64
|
-
includeUntracked: true
|
|
65
|
-
});
|
|
66
|
-
logger.info("Initializing Package Tree");
|
|
67
|
-
await packageTree.initialize();
|
|
68
|
-
const filteredPipeline = (0, _filterPipelineDefinitions.filterPipelineDefinitions)(targetGraph.targets.values(), config.pipeline);
|
|
69
|
-
const pool = new _workerthreadspool.AggregatedPool({
|
|
70
|
-
logger,
|
|
71
|
-
maxWorkersByGroup: new Map([
|
|
72
|
-
...(0, _config.getMaxWorkersPerTask)(filteredPipeline, maxWorkers)
|
|
73
|
-
]),
|
|
74
|
-
groupBy: ({ target })=>target.task,
|
|
75
|
-
maxWorkers,
|
|
76
|
-
script: require.resolve("./singleTargetWorker.js"),
|
|
77
|
-
workerOptions: {
|
|
78
|
-
stdout: true,
|
|
79
|
-
stderr: true,
|
|
80
|
-
workerData: {
|
|
81
|
-
runners: {
|
|
82
|
-
...(0, _runnerPickerOptions.runnerPickerOptions)(nodeArg, config.npmClient, taskArgs),
|
|
83
|
-
...config.runners,
|
|
84
|
-
shouldCache: false,
|
|
85
|
-
shouldResetCache: false
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
serverControls.abortController.signal.addEventListener("abort", ()=>{
|
|
91
|
-
pool?.close();
|
|
92
|
-
});
|
|
93
|
-
pool?.on("freedWorker", ()=>{
|
|
94
|
-
logger.silly(`Max Worker Memory Usage: ${formatBytes(pool?.stats().maxWorkerMemoryUsage)}`);
|
|
95
|
-
});
|
|
96
|
-
pool?.on("idle", ()=>{
|
|
97
|
-
logger.info("All workers are idle, shutting down after timeout");
|
|
98
|
-
serverControls.countdownToShutdown();
|
|
99
|
-
});
|
|
100
|
-
return {
|
|
101
|
-
config,
|
|
102
|
-
targetGraph,
|
|
103
|
-
packageTree,
|
|
104
|
-
dependencyMap,
|
|
105
|
-
root,
|
|
106
|
-
pool
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
initializedPromise = createInitializedPromise();
|
|
110
|
-
return await initializedPromise;
|
|
109
|
+
*/ async function initialize(options) {
|
|
110
|
+
initializedPromise = createInitializedPromise(options);
|
|
111
|
+
return initializedPromise;
|
|
111
112
|
}
|
|
112
113
|
async function createLageService({ cwd, serverControls, logger, concurrency, tasks }) {
|
|
113
114
|
return {
|
|
@@ -117,6 +118,9 @@ async function createLageService({ cwd, serverControls, logger, concurrency, tas
|
|
|
117
118
|
};
|
|
118
119
|
},
|
|
119
120
|
async runTarget (request) {
|
|
121
|
+
if (global.gc) {
|
|
122
|
+
global.gc();
|
|
123
|
+
}
|
|
120
124
|
serverControls.clearCountdown();
|
|
121
125
|
// THIS IS A BIG ASSUMPTION; TODO: memoize based on the parameters of the initialize() call
|
|
122
126
|
// The first request sets up the nodeArg and taskArgs - we are assuming that all requests to run this target are coming from the same
|
|
@@ -174,6 +178,10 @@ async function createLageService({ cwd, serverControls, logger, concurrency, tas
|
|
|
174
178
|
targetRun.status = "running";
|
|
175
179
|
targetRun.startTime = process.hrtime();
|
|
176
180
|
}, (worker)=>{
|
|
181
|
+
logger.info(`Max Worker Memory Usage: ${formatBytes(pool.stats().maxWorkerMemoryUsage)}`);
|
|
182
|
+
// logger.info the main process memory usage
|
|
183
|
+
const memoryUsage = process.memoryUsage();
|
|
184
|
+
logger.info(`Main Process Memory Usage: RSS: ${formatBytes(memoryUsage.rss)} Heap Total: ${formatBytes(memoryUsage.heapTotal)} Heap Used: ${formatBytes(memoryUsage.heapUsed)}`);
|
|
177
185
|
targetRun.status = "success";
|
|
178
186
|
targetRun.duration = (0, _formathrtime.hrtimeDiff)(targetRun.startTime, process.hrtime());
|
|
179
187
|
logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} end: ${(0, _formathrtime.formatDuration)((0, _formathrtime.hrToSeconds)(targetRun.duration))}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/server/lageService.ts"],"sourcesContent":["import { type ConfigOptions, getConfig, getConcurrency, getMaxWorkersPerTask } from \"@lage-run/config\";\nimport type { Logger } from \"@lage-run/logger\";\nimport type { ILageService } from \"@lage-run/rpc\";\nimport { getTargetId, type TargetGraph } from \"@lage-run/target-graph\";\nimport { type DependencyMap, getPackageInfos, getWorkspaceRoot } from \"workspace-tools\";\nimport { createTargetGraph } from \"../run/createTargetGraph.js\";\nimport { type Readable } from \"stream\";\nimport { type Pool, AggregatedPool } from \"@lage-run/worker-threads-pool\";\nimport { getInputFiles, PackageTree } from \"@lage-run/hasher\";\nimport { createDependencyMap } from \"workspace-tools\";\nimport { getOutputFiles } from \"./getOutputFiles.js\";\nimport { glob } from \"@lage-run/globby\";\nimport { MemoryStream } from \"./MemoryStream.js\";\nimport { runnerPickerOptions } from \"../../runnerPickerOptions.js\";\nimport { filterPipelineDefinitions } from \"../run/filterPipelineDefinitions.js\";\nimport type { TargetRun } from \"@lage-run/scheduler-types\";\nimport { formatDuration, hrToSeconds, hrtimeDiff } from \"@lage-run/format-hrtime\";\n\ninterface LageServiceContext {\n config: ConfigOptions;\n targetGraph: TargetGraph;\n packageTree: PackageTree;\n dependencyMap: DependencyMap;\n root: string;\n pool: Pool;\n}\n\nlet initializedPromise: Promise<LageServiceContext> | undefined;\ninterface ServiceControls {\n abortController: AbortController;\n countdownToShutdown: () => void;\n clearCountdown: () => void;\n}\ninterface InitializeOptions {\n cwd: string;\n logger: Logger;\n serverControls: ServiceControls;\n concurrency?: number;\n nodeArg?: string;\n taskArgs: string[];\n tasks: string[];\n}\n\nfunction formatBytes(bytes: number) {\n return `${(bytes / 1024 / 1024).toFixed(2)} MB`;\n}\n\n/**\n * Initializes the lageService: the extra \"initializePromise\" ensures only one initialization is done at a time across threads\n * @param cwd\n * @param logger\n * @returns\n */\nasync function initialize({\n cwd,\n logger,\n serverControls,\n nodeArg,\n taskArgs,\n concurrency,\n tasks,\n}: InitializeOptions): Promise<LageServiceContext> {\n async function createInitializedPromise() {\n if (initializedPromise) {\n return initializedPromise;\n }\n\n const config = await getConfig(cwd);\n const root = getWorkspaceRoot(cwd)!;\n const maxWorkers = getConcurrency(concurrency, config.concurrency);\n\n logger.info(`Initializing with ${maxWorkers} workers, tasks: ${tasks.join(\", \")}`);\n\n const { pipeline } = config;\n\n const packageInfos = getPackageInfos(root);\n\n const targetGraph = await createTargetGraph({\n logger,\n root,\n dependencies: false,\n dependents: false,\n ignore: [],\n pipeline,\n repoWideChanges: config.repoWideChanges,\n scope: undefined,\n since: undefined,\n outputs: config.cacheOptions.outputGlob,\n tasks,\n packageInfos,\n });\n\n const dependencyMap = createDependencyMap(packageInfos, { withDevDependencies: true, withPeerDependencies: false });\n const packageTree = new PackageTree({\n root,\n packageInfos,\n includeUntracked: true,\n });\n\n logger.info(\"Initializing Package Tree\");\n await packageTree.initialize();\n\n const filteredPipeline = filterPipelineDefinitions(targetGraph.targets.values(), config.pipeline);\n\n const pool = new AggregatedPool({\n logger,\n maxWorkersByGroup: new Map([...getMaxWorkersPerTask(filteredPipeline, maxWorkers)]),\n groupBy: ({ target }) => target.task,\n maxWorkers,\n script: require.resolve(\"./singleTargetWorker.js\"),\n workerOptions: {\n stdout: true,\n stderr: true,\n workerData: {\n runners: {\n ...runnerPickerOptions(nodeArg, config.npmClient, taskArgs),\n ...config.runners,\n shouldCache: false,\n shouldResetCache: false,\n },\n },\n },\n });\n\n serverControls.abortController.signal.addEventListener(\"abort\", () => {\n pool?.close();\n });\n\n pool?.on(\"freedWorker\", () => {\n logger.silly(`Max Worker Memory Usage: ${formatBytes(pool?.stats().maxWorkerMemoryUsage)}`);\n });\n\n pool?.on(\"idle\", () => {\n logger.info(\"All workers are idle, shutting down after timeout\");\n serverControls.countdownToShutdown();\n });\n\n return { config, targetGraph, packageTree, dependencyMap, root, pool };\n }\n\n initializedPromise = createInitializedPromise();\n\n return await initializedPromise;\n}\n\ninterface CreateLageServiceOptions {\n cwd: string;\n serverControls: ServiceControls;\n logger: Logger;\n concurrency?: number;\n tasks: string[];\n}\n\nexport async function createLageService({\n cwd,\n serverControls,\n logger,\n concurrency,\n tasks,\n}: CreateLageServiceOptions): Promise<ILageService> {\n return {\n async ping() {\n return { pong: true };\n },\n\n async runTarget(request) {\n serverControls.clearCountdown();\n\n // THIS IS A BIG ASSUMPTION; TODO: memoize based on the parameters of the initialize() call\n // The first request sets up the nodeArg and taskArgs - we are assuming that all requests to run this target are coming from the same\n // `lage info` call\n const { config, targetGraph, dependencyMap, packageTree, root, pool } = await initialize({\n cwd,\n logger,\n nodeArg: request.nodeOptions,\n taskArgs: request.taskArgs,\n serverControls,\n concurrency,\n tasks,\n });\n\n const runners = runnerPickerOptions(request.nodeOptions, config.npmClient, request.taskArgs);\n\n const id = getTargetId(request.packageName, request.task);\n\n if (!targetGraph.targets.has(id)) {\n logger.info(`Target not found: ${request.packageName}#${request.task}`);\n return {\n packageName: request.packageName,\n task: request.task,\n exitCode: 1,\n };\n }\n\n const target = targetGraph.targets.get(id)!;\n const task = {\n target,\n runners,\n };\n\n const writableStdout = new MemoryStream();\n const writableStderr = new MemoryStream();\n let pipedStdout: Readable;\n let pipedStderr: Readable;\n\n const targetRun: TargetRun = {\n queueTime: process.hrtime(),\n target,\n duration: [0, 0],\n startTime: [0, 0],\n status: \"queued\",\n threadId: 0,\n };\n\n try {\n await pool.exec(\n task,\n 0,\n (worker, stdout, stderr) => {\n logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} start`);\n\n pipedStdout = stdout;\n pipedStderr = stderr;\n\n stdout.pipe(writableStdout);\n stderr.pipe(writableStderr);\n\n targetRun.threadId = worker.threadId;\n targetRun.status = \"running\";\n targetRun.startTime = process.hrtime();\n },\n (worker) => {\n targetRun.status = \"success\";\n targetRun.duration = hrtimeDiff(targetRun.startTime, process.hrtime());\n\n logger.info(\n `[${worker.threadId}] ${request.packageName}#${request.task} end: ${formatDuration(hrToSeconds(targetRun.duration))}`\n );\n pipedStdout.unpipe(writableStdout);\n pipedStderr.unpipe(writableStderr);\n }\n );\n\n const globalInputs = target.environmentGlob\n ? glob(target.environmentGlob, { cwd: root, gitignore: true })\n : config.cacheOptions?.environmentGlob\n ? glob(config.cacheOptions?.environmentGlob, { cwd: root, gitignore: true })\n : [\"lage.config.js\"];\n const inputs = (getInputFiles(target, dependencyMap, packageTree) ?? []).concat(globalInputs);\n\n return {\n packageName: request.packageName,\n task: request.task,\n exitCode: 0,\n hash: \"\",\n inputs,\n outputs: getOutputFiles(root, target, config.cacheOptions?.outputGlob, packageTree),\n stdout: writableStdout.toString(),\n stderr: writableStderr.toString(),\n id,\n };\n } catch (e) {\n return {\n packageName: request.packageName,\n task: request.task,\n exitCode: 1,\n hash: \"\",\n inputs: [],\n outputs: [],\n stdout: \"\",\n stderr: e instanceof Error ? e.toString() : \"\",\n id,\n };\n }\n },\n };\n}\n"],"names":["createLageService","initializedPromise","formatBytes","bytes","toFixed","initialize","cwd","logger","serverControls","nodeArg","taskArgs","concurrency","tasks","createInitializedPromise","config","getConfig","root","getWorkspaceRoot","maxWorkers","getConcurrency","info","join","pipeline","packageInfos","getPackageInfos","targetGraph","createTargetGraph","dependencies","dependents","ignore","repoWideChanges","scope","undefined","since","outputs","cacheOptions","outputGlob","dependencyMap","createDependencyMap","withDevDependencies","withPeerDependencies","packageTree","PackageTree","includeUntracked","filteredPipeline","filterPipelineDefinitions","targets","values","pool","AggregatedPool","maxWorkersByGroup","Map","getMaxWorkersPerTask","groupBy","target","task","script","require","resolve","workerOptions","stdout","stderr","workerData","runners","runnerPickerOptions","npmClient","shouldCache","shouldResetCache","abortController","signal","addEventListener","close","on","silly","stats","maxWorkerMemoryUsage","countdownToShutdown","ping","pong","runTarget","request","clearCountdown","nodeOptions","id","getTargetId","packageName","has","exitCode","get","writableStdout","MemoryStream","writableStderr","pipedStdout","pipedStderr","targetRun","queueTime","process","hrtime","duration","startTime","status","threadId","exec","worker","pipe","hrtimeDiff","formatDuration","hrToSeconds","unpipe","globalInputs","environmentGlob","glob","gitignore","inputs","get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AYK;oBACvEmB,QAAQ6B,eAAe6B,QAAQ;oBAC/BzD,QAAQ8B,eAAe2B,QAAQ;oBAC/BnC;gBACF;YACF,EAAE,OAAOoC,GAAG;gBACV,OAAO;oBACLlC,aAAaL,QAAQK,WAAW;oBAChC9B,MAAMyB,QAAQzB,IAAI;oBAClBgC,UAAU;oBACV6B,MAAM;oBACNH,QAAQ,EAAE;oBACV/E,SAAS,EAAE;oBACX0B,QAAQ;oBACRC,QAAQ0D,aAAaC,QAAQD,EAAED,QAAQ,KAAK;oBAC5CnC;gBACF;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/server/lageService.ts"],"sourcesContent":["import { type ConfigOptions, getConfig, getConcurrency, getMaxWorkersPerTask } from \"@lage-run/config\";\nimport type { Logger } from \"@lage-run/logger\";\nimport type { ILageService } from \"@lage-run/rpc\";\nimport { getTargetId, type TargetGraph } from \"@lage-run/target-graph\";\nimport { type DependencyMap, getPackageInfos, getWorkspaceRoot } from \"workspace-tools\";\nimport { createTargetGraph } from \"../run/createTargetGraph.js\";\nimport { type Readable } from \"stream\";\nimport { type Pool, AggregatedPool } from \"@lage-run/worker-threads-pool\";\nimport { getInputFiles, PackageTree } from \"@lage-run/hasher\";\nimport { createDependencyMap } from \"workspace-tools\";\nimport { getOutputFiles } from \"./getOutputFiles.js\";\nimport { glob } from \"@lage-run/globby\";\nimport { MemoryStream } from \"./MemoryStream.js\";\nimport { runnerPickerOptions } from \"../../runnerPickerOptions.js\";\nimport { filterPipelineDefinitions } from \"../run/filterPipelineDefinitions.js\";\nimport type { TargetRun } from \"@lage-run/scheduler-types\";\nimport { formatDuration, hrToSeconds, hrtimeDiff } from \"@lage-run/format-hrtime\";\n\ninterface LageServiceContext {\n config: ConfigOptions;\n targetGraph: TargetGraph;\n packageTree: PackageTree;\n dependencyMap: DependencyMap;\n root: string;\n pool: Pool;\n}\n\nlet initializedPromise: Promise<LageServiceContext> | undefined;\ninterface ServiceControls {\n abortController: AbortController;\n countdownToShutdown: () => void;\n clearCountdown: () => void;\n}\ninterface InitializeOptions {\n cwd: string;\n logger: Logger;\n serverControls: ServiceControls;\n concurrency?: number;\n nodeArg?: string;\n taskArgs: string[];\n tasks: string[];\n}\n\nfunction formatBytes(bytes: number) {\n return `${(bytes / 1024 / 1024).toFixed(2)} MB`;\n}\n\nasync function createInitializedPromise({ cwd, logger, serverControls, nodeArg, taskArgs, concurrency, tasks }: InitializeOptions) {\n if (initializedPromise) {\n return initializedPromise;\n }\n\n const config = await getConfig(cwd);\n const root = getWorkspaceRoot(cwd)!;\n const maxWorkers = getConcurrency(concurrency, config.concurrency);\n\n logger.info(`Initializing with ${maxWorkers} workers, tasks: ${tasks.join(\", \")}`);\n\n const { pipeline } = config;\n\n const packageInfos = getPackageInfos(root);\n\n const targetGraph = await createTargetGraph({\n logger,\n root,\n dependencies: false,\n dependents: false,\n ignore: [],\n pipeline,\n repoWideChanges: config.repoWideChanges,\n scope: undefined,\n since: undefined,\n outputs: config.cacheOptions.outputGlob,\n tasks,\n packageInfos,\n });\n\n const dependencyMap = createDependencyMap(packageInfos, { withDevDependencies: true, withPeerDependencies: false });\n const packageTree = new PackageTree({\n root,\n packageInfos,\n includeUntracked: true,\n });\n\n logger.info(\"Initializing Package Tree\");\n await packageTree.initialize();\n\n const filteredPipeline = filterPipelineDefinitions(targetGraph.targets.values(), config.pipeline);\n\n const pool = new AggregatedPool({\n logger,\n maxWorkersByGroup: new Map([...getMaxWorkersPerTask(filteredPipeline, maxWorkers)]),\n groupBy: ({ target }) => target.task,\n maxWorkers,\n script: require.resolve(\"./singleTargetWorker.js\"),\n workerOptions: {\n stdout: true,\n stderr: true,\n workerData: {\n runners: {\n ...runnerPickerOptions(nodeArg, config.npmClient, taskArgs),\n ...config.runners,\n shouldCache: false,\n shouldResetCache: false,\n },\n },\n },\n workerIdleMemoryLimit: config.workerIdleMemoryLimit,\n });\n\n serverControls.abortController.signal.addEventListener(\"abort\", () => {\n pool?.close();\n });\n\n pool?.on(\"freedWorker\", () => {\n logger.silly(`Max Worker Memory Usage: ${formatBytes(pool?.stats().maxWorkerMemoryUsage)}`);\n });\n\n pool?.on(\"idle\", () => {\n logger.info(\"All workers are idle, shutting down after timeout\");\n serverControls.countdownToShutdown();\n });\n\n return { config, targetGraph, packageTree, dependencyMap, root, pool };\n}\n\n/**\n * Initializes the lageService: the extra \"initializePromise\" ensures only one initialization is done at a time across threads\n * @param cwd\n * @param logger\n * @returns\n */\nasync function initialize(options: InitializeOptions): Promise<LageServiceContext> {\n initializedPromise = createInitializedPromise(options);\n return initializedPromise;\n}\n\ninterface CreateLageServiceOptions {\n cwd: string;\n serverControls: ServiceControls;\n logger: Logger;\n concurrency?: number;\n tasks: string[];\n}\n\nexport async function createLageService({\n cwd,\n serverControls,\n logger,\n concurrency,\n tasks,\n}: CreateLageServiceOptions): Promise<ILageService> {\n return {\n async ping() {\n return { pong: true };\n },\n\n async runTarget(request) {\n if (global.gc) {\n global.gc();\n }\n\n serverControls.clearCountdown();\n\n // THIS IS A BIG ASSUMPTION; TODO: memoize based on the parameters of the initialize() call\n // The first request sets up the nodeArg and taskArgs - we are assuming that all requests to run this target are coming from the same\n // `lage info` call\n const { config, targetGraph, dependencyMap, packageTree, root, pool } = await initialize({\n cwd,\n logger,\n nodeArg: request.nodeOptions,\n taskArgs: request.taskArgs,\n serverControls,\n concurrency,\n tasks,\n });\n\n const runners = runnerPickerOptions(request.nodeOptions, config.npmClient, request.taskArgs);\n\n const id = getTargetId(request.packageName, request.task);\n\n if (!targetGraph.targets.has(id)) {\n logger.info(`Target not found: ${request.packageName}#${request.task}`);\n return {\n packageName: request.packageName,\n task: request.task,\n exitCode: 1,\n };\n }\n\n const target = targetGraph.targets.get(id)!;\n const task = {\n target,\n runners,\n };\n\n const writableStdout = new MemoryStream();\n const writableStderr = new MemoryStream();\n let pipedStdout: Readable;\n let pipedStderr: Readable;\n\n const targetRun: TargetRun = {\n queueTime: process.hrtime(),\n target,\n duration: [0, 0],\n startTime: [0, 0],\n status: \"queued\",\n threadId: 0,\n };\n\n try {\n await pool.exec(\n task,\n 0,\n (worker, stdout, stderr) => {\n logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} start`);\n\n pipedStdout = stdout;\n pipedStderr = stderr;\n\n stdout.pipe(writableStdout);\n stderr.pipe(writableStderr);\n\n targetRun.threadId = worker.threadId;\n targetRun.status = \"running\";\n targetRun.startTime = process.hrtime();\n },\n (worker) => {\n logger.info(`Max Worker Memory Usage: ${formatBytes(pool.stats().maxWorkerMemoryUsage)}`);\n\n // logger.info the main process memory usage\n const memoryUsage = process.memoryUsage();\n logger.info(\n `Main Process Memory Usage: RSS: ${formatBytes(memoryUsage.rss)} Heap Total: ${formatBytes(\n memoryUsage.heapTotal\n )} Heap Used: ${formatBytes(memoryUsage.heapUsed)}`\n );\n\n targetRun.status = \"success\";\n targetRun.duration = hrtimeDiff(targetRun.startTime, process.hrtime());\n\n logger.info(\n `[${worker.threadId}] ${request.packageName}#${request.task} end: ${formatDuration(hrToSeconds(targetRun.duration))}`\n );\n pipedStdout.unpipe(writableStdout);\n pipedStderr.unpipe(writableStderr);\n }\n );\n\n const globalInputs = target.environmentGlob\n ? glob(target.environmentGlob, { cwd: root, gitignore: true })\n : config.cacheOptions?.environmentGlob\n ? glob(config.cacheOptions?.environmentGlob, { cwd: root, gitignore: true })\n : [\"lage.config.js\"];\n const inputs = (getInputFiles(target, dependencyMap, packageTree) ?? []).concat(globalInputs);\n\n return {\n packageName: request.packageName,\n task: request.task,\n exitCode: 0,\n hash: \"\",\n inputs,\n outputs: getOutputFiles(root, target, config.cacheOptions?.outputGlob, packageTree),\n stdout: writableStdout.toString(),\n stderr: writableStderr.toString(),\n id,\n };\n } catch (e) {\n return {\n packageName: request.packageName,\n task: request.task,\n exitCode: 1,\n hash: \"\",\n inputs: [],\n outputs: [],\n stdout: \"\",\n stderr: e instanceof Error ? e.toString() : \"\",\n id,\n };\n }\n },\n };\n}\n"],"names":["createLageService","initializedPromise","formatBytes","bytes","toFixed","createInitializedPromise","cwd","logger","serverControls","nodeArg","taskArgs","concurrency","tasks","config","getConfig","root","getWorkspaceRoot","maxWorkers","getConcurrency","info","join","pipeline","packageInfos","getPackageInfos","targetGraph","createTargetGraph","dependencies","dependents","ignore","repoWideChanges","scope","undefined","since","outputs","cacheOptions","outputGlob","dependencyMap","createDependencyMap","withDevDependencies","withPeerDependencies","packageTree","PackageTree","includeUntracked","initialize","filteredPipeline","filterPipelineDefinitions","targets","values","pool","AggregatedPool","maxWorkersByGroup","Map","getMaxWorkersPerTask","groupBy","target","task","script","require","resolve","workerOptions","stdout","stderr","workerData","runners","runnerPickerOptions","npmClient","shouldCache","shouldResetCache","workerIdleMemoryLimit","abortController","signal","addEventListener","close","on","silly","stats","maxWorkerMemoryUsage","countdownToShutdown","options","ping","pong","runTarget","request","global","gc","clearCountdown","nodeOptions","id","getTargetId","packageName","has","exitCode","get","writableStdout","MemoryStream","writableStderr","pipedStdout","pipedStderr","targetRun","queueTime","process","hrtime","duration","startTime","status","threadId","exec","worker","pipe","memoryUsage","rss","heapTotal","heapUsed","hrtimeDiff","formatDuration","hrToSeconds","unpipe","globalInputs","environmentGlob","glob","gitignore","inputs","getInputFiles","concat","hash","getOutputFiles","toString","e","Error"],"mappings":";;;;+BAiJsBA;;;eAAAA;;;wBAjJ8D;6BAGtC;gCACwB;mCACpC;mCAEQ;wBACC;gCAEZ;wBACV;8BACQ;qCACO;2CACM;8BAEc;AAWxD,IAAIC;AAgBJ,SAASC,YAAYC,KAAa;IAChC,OAAO,GAAG,AAACA,CAAAA,QAAQ,OAAO,IAAG,EAAGC,OAAO,CAAC,GAAG,GAAG,CAAC;AACjD;AAEA,eAAeC,yBAAyB,EAAEC,GAAG,EAAEC,MAAM,EAAEC,cAAc,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,KAAK,EAAqB;IAC/H,IAAIX,oBAAoB;QACtB,OAAOA;IACT;IAEA,MAAMY,SAAS,M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QAAQ;oBAC/BjE,QAAQkC,eAAe+B,QAAQ;oBAC/BvC;gBACF;YACF,EAAE,OAAOwC,GAAG;gBACV,OAAO;oBACLtC,aAAaP,QAAQO,WAAW;oBAChClC,MAAM2B,QAAQ3B,IAAI;oBAClBoC,UAAU;oBACViC,MAAM;oBACNH,QAAQ,EAAE;oBACVxF,SAAS,EAAE;oBACX2B,QAAQ;oBACRC,QAAQkE,aAAaC,QAAQD,EAAED,QAAQ,KAAK;oBAC5CvC;gBACF;YACF;QACF;IACF;AACF"}
|
package/lib/getBinPaths.d.ts
CHANGED
package/lib/getBinPaths.js
CHANGED
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getBinPaths: function() {
|
|
8
13
|
return getBinPaths;
|
|
14
|
+
},
|
|
15
|
+
getBinScripts: function() {
|
|
16
|
+
return getBinScripts;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
11
19
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
@@ -44,3 +52,23 @@ function getBinPaths() {
|
|
|
44
52
|
"lage-server": binPaths[1]
|
|
45
53
|
};
|
|
46
54
|
}
|
|
55
|
+
function getBinScripts() {
|
|
56
|
+
const thisPackageJsonPath = findUp("package.json", __dirname);
|
|
57
|
+
if (!thisPackageJsonPath) {
|
|
58
|
+
throw new Error("Could not find package.json of this packageF");
|
|
59
|
+
}
|
|
60
|
+
const thisPackagePath = _path.default.dirname(thisPackageJsonPath);
|
|
61
|
+
if (_fs.default.existsSync(_path.default.join(thisPackagePath, "dist", "lage.js"))) {
|
|
62
|
+
// the case for CLI package after build
|
|
63
|
+
return {
|
|
64
|
+
lage: _path.default.join(thisPackagePath, "dist", "lage.js"),
|
|
65
|
+
"lage-server": _path.default.join(thisPackagePath, "dist", "lage-server.js")
|
|
66
|
+
};
|
|
67
|
+
} else {
|
|
68
|
+
// the case for CLI package during development
|
|
69
|
+
return {
|
|
70
|
+
lage: _path.default.join(thisPackagePath, "bin", "lage.js"),
|
|
71
|
+
"lage-server": _path.default.join(thisPackagePath, "bin", "lage-server.js")
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
package/lib/getBinPaths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/getBinPaths.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport os from \"os\";\n\nfunction findUp(name: string, dir: string) {\n let currentDir = dir;\n while (currentDir !== \"/\") {\n const fullPath = path.join(currentDir, name);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return undefined;\n}\n\nexport function getBinPaths() {\n const bins = os.platform() === \"win32\" ? [\"lage.cmd\", \"lage-server.cmd\"] : [\"lage\", \"lage-server\"];\n const binPaths = bins.map((bin) => findUp(\"node_modules/.bin/\" + bin, __dirname));\n\n if (binPaths.some((binPath) => binPath === undefined)) {\n throw new Error(\"Could not find bin paths for lage or lage-server\");\n }\n\n return { lage: binPaths[0]!, \"lage-server\": binPaths[1]! };\n}\n"],"names":["getBinPaths","findUp","name","dir","currentDir","fullPath","path","join","fs","existsSync","dirname","undefined","bins","os","platform","binPaths","map","bin","__dirname","some","binPath","Error","lage"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/getBinPaths.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport os from \"os\";\n\nfunction findUp(name: string, dir: string) {\n let currentDir = dir;\n while (currentDir !== \"/\") {\n const fullPath = path.join(currentDir, name);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return undefined;\n}\n\nexport function getBinPaths() {\n const bins = os.platform() === \"win32\" ? [\"lage.cmd\", \"lage-server.cmd\"] : [\"lage\", \"lage-server\"];\n const binPaths = bins.map((bin) => findUp(\"node_modules/.bin/\" + bin, __dirname));\n\n if (binPaths.some((binPath) => binPath === undefined)) {\n throw new Error(\"Could not find bin paths for lage or lage-server\");\n }\n\n return { lage: binPaths[0]!, \"lage-server\": binPaths[1]! };\n}\n\nexport function getBinScripts() {\n const thisPackageJsonPath = findUp(\"package.json\", __dirname);\n\n if (!thisPackageJsonPath) {\n throw new Error(\"Could not find package.json of this packageF\");\n }\n\n const thisPackagePath = path.dirname(thisPackageJsonPath);\n\n if (fs.existsSync(path.join(thisPackagePath, \"dist\", \"lage.js\"))) {\n // the case for CLI package after build\n return {\n lage: path.join(thisPackagePath, \"dist\", \"lage.js\"),\n \"lage-server\": path.join(thisPackagePath, \"dist\", \"lage-server.js\"),\n };\n } else {\n // the case for CLI package during development\n return {\n lage: path.join(thisPackagePath, \"bin\", \"lage.js\"),\n \"lage-server\": path.join(thisPackagePath, \"bin\", \"lage-server.js\"),\n };\n }\n}\n"],"names":["getBinPaths","getBinScripts","findUp","name","dir","currentDir","fullPath","path","join","fs","existsSync","dirname","undefined","bins","os","platform","binPaths","map","bin","__dirname","some","binPath","Error","lage","thisPackageJsonPath","thisPackagePath"],"mappings":";;;;;;;;;;;IAgBgBA,WAAW;eAAXA;;IAWAC,aAAa;eAAbA;;;6DA3BC;2DACF;2DACA;;;;;;AAEf,SAASC,OAAOC,IAAY,EAAEC,GAAW;IACvC,IAAIC,aAAaD;IACjB,MAAOC,eAAe,IAAK;QACzB,MAAMC,WAAWC,aAAI,CAACC,IAAI,CAACH,YAAYF;QACvC,IAAIM,WAAE,CAACC,UAAU,CAACJ,WAAW;YAC3B,OAAOA;QACT;QACAD,aAAaE,aAAI,CAACI,OAAO,CAACN;IAC5B;IACA,OAAOO;AACT;AAEO,SAASZ;IACd,MAAMa,OAAOC,WAAE,CAACC,QAAQ,OAAO,UAAU;QAAC;QAAY;KAAkB,GAAG;QAAC;QAAQ;KAAc;IAClG,MAAMC,WAAWH,KAAKI,GAAG,CAAC,CAACC,MAAQhB,OAAO,uBAAuBgB,KAAKC;IAEtE,IAAIH,SAASI,IAAI,CAAC,CAACC,UAAYA,YAAYT,YAAY;QACrD,MAAM,IAAIU,MAAM;IAClB;IAEA,OAAO;QAAEC,MAAMP,QAAQ,CAAC,EAAE;QAAG,eAAeA,QAAQ,CAAC,EAAE;IAAE;AAC3D;AAEO,SAASf;IACd,MAAMuB,sBAAsBtB,OAAO,gBAAgBiB;IAEnD,IAAI,CAACK,qBAAqB;QACxB,MAAM,IAAIF,MAAM;IAClB;IAEA,MAAMG,kBAAkBlB,aAAI,CAACI,OAAO,CAACa;IAErC,IAAIf,WAAE,CAACC,UAAU,CAACH,aAAI,CAACC,IAAI,CAACiB,iBAAiB,QAAQ,aAAa;QAChE,uCAAuC;QACvC,OAAO;YACLF,MAAMhB,aAAI,CAACC,IAAI,CAACiB,iBAAiB,QAAQ;YACzC,eAAelB,aAAI,CAACC,IAAI,CAACiB,iBAAiB,QAAQ;QACpD;IACF,OAAO;QACL,8CAA8C;QAC9C,OAAO;YACLF,MAAMhB,aAAI,CAACC,IAAI,CAACiB,iBAAiB,OAAO;YACxC,eAAelB,aAAI,CAACC,IAAI,CAACiB,iBAAiB,OAAO;QACnD;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.7",
|
|
4
4
|
"description": "Command Line Interface for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@lage-run/reporters": "^1.2.18",
|
|
31
31
|
"@lage-run/rpc": "^1.2.3",
|
|
32
32
|
"@lage-run/runners": "^1.2.0",
|
|
33
|
-
"@lage-run/scheduler": "^1.4.
|
|
33
|
+
"@lage-run/scheduler": "^1.4.2",
|
|
34
34
|
"@lage-run/scheduler-types": "^0.3.22",
|
|
35
35
|
"@lage-run/target-graph": "^0.11.0",
|
|
36
|
-
"@lage-run/worker-threads-pool": "^0.8.
|
|
36
|
+
"@lage-run/worker-threads-pool": "^0.8.6",
|
|
37
37
|
"chokidar": "3.5.3",
|
|
38
38
|
"commander": "9.5.0",
|
|
39
39
|
"execa": "5.1.1",
|