@lage-run/cli 0.32.3 → 0.33.0

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 CHANGED
@@ -1,6 +1,21 @@
1
1
  {
2
2
  "name": "@lage-run/cli",
3
3
  "entries": [
4
+ {
5
+ "date": "Tue, 21 Oct 2025 23:42:14 GMT",
6
+ "version": "0.33.0",
7
+ "tag": "@lage-run/cli_v0.33.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "nemanjatesic@microsoft.com",
12
+ "package": "@lage-run/cli",
13
+ "commit": "cd3ca59beba687a1d3c859524786e2aeeea09953",
14
+ "comment": "Add custom reporter capability to Lage"
15
+ }
16
+ ]
17
+ }
18
+ },
4
19
  {
5
20
  "date": "Mon, 01 Sep 2025 08:10:36 GMT",
6
21
  "version": "0.32.0",
package/CHANGELOG.md CHANGED
@@ -1,9 +1,17 @@
1
1
  # Change Log - @lage-run/cli
2
2
 
3
- <!-- This log was last generated on Mon, 01 Sep 2025 08:10:36 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Tue, 21 Oct 2025 23:42:14 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.33.0
8
+
9
+ Tue, 21 Oct 2025 23:42:14 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Add custom reporter capability to Lage (nemanjatesic@microsoft.com)
14
+
7
15
  ## 0.32.0
8
16
 
9
17
  Mon, 01 Sep 2025 08:10:36 GMT
@@ -1,3 +1,3 @@
1
- import { JsonReporter, AdoReporter, LogReporter, ProgressReporter, VerboseFileLogReporter, ChromeTraceEventsReporter } from "@lage-run/reporters";
2
1
  import type { ReporterInitOptions } from "../types/ReporterInitOptions.js";
3
- export declare function createReporter(reporter: string, options: ReporterInitOptions): ChromeTraceEventsReporter | JsonReporter | AdoReporter | LogReporter | VerboseFileLogReporter | ProgressReporter;
2
+ import type { Reporter } from "@lage-run/logger";
3
+ export declare function createReporter(reporter: string, options: ReporterInitOptions, customReporters?: Record<string, string>): Promise<Reporter>;
@@ -13,12 +13,13 @@ const _reporters = require("@lage-run/reporters");
13
13
  const _workspacetools = require("workspace-tools");
14
14
  const _fs = require("fs");
15
15
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
16
+ const _url = require("url");
16
17
  function _interop_require_default(obj) {
17
18
  return obj && obj.__esModule ? obj : {
18
19
  default: obj
19
20
  };
20
21
  }
21
- function createReporter(reporter, options) {
22
+ async function createReporter(reporter, options, customReporters = {}) {
22
23
  const { verbose, grouped, logLevel: logLevelName, concurrency, profile, progress, logFile, indented } = options;
23
24
  const logLevel = _logger.LogLevel[logLevelName];
24
25
  const root = (0, _workspacetools.findPackageRoot)(__filename);
@@ -51,6 +52,29 @@ function createReporter(reporter, options) {
51
52
  case "vfl":
52
53
  return new _reporters.VerboseFileLogReporter(logFile);
53
54
  default:
55
+ // Check if it's a custom reporter defined in config
56
+ if (customReporters && customReporters[reporter]) {
57
+ const reporterPath = customReporters[reporter];
58
+ const resolvedPath = _path.default.isAbsolute(reporterPath) ? reporterPath : _path.default.resolve(process.cwd(), reporterPath);
59
+ try {
60
+ // Use dynamic import to load the custom reporter module
61
+ // This works with both ESM (.mjs, .js with type: module) and CommonJS (.cjs, .js) files
62
+ const reporterModule = await import((0, _url.pathToFileURL)(resolvedPath).href);
63
+ // Try different export patterns
64
+ const ReporterClass = reporterModule.default ?? reporterModule[reporter] ?? reporterModule;
65
+ if (typeof ReporterClass === "function") {
66
+ return new ReporterClass(options);
67
+ } else if (typeof ReporterClass === "object" && ReporterClass !== null) {
68
+ // If it's already an instance
69
+ return ReporterClass;
70
+ } else {
71
+ throw new Error(`Custom reporter "${reporter}" at "${resolvedPath}" does not export a valid reporter class or instance.`);
72
+ }
73
+ } catch (error) {
74
+ throw new Error(`Failed to load custom reporter "${reporter}" from "${resolvedPath}": ${error}`);
75
+ }
76
+ }
77
+ // Default reporter behavior
54
78
  if (progress && !(logLevel >= _logger.LogLevel.verbose || verbose || grouped)) {
55
79
  return new _reporters.ProgressReporter({
56
80
  concurrency,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/createReporter.ts"],"sourcesContent":["import { LogLevel } from \"@lage-run/logger\";\nimport {\n JsonReporter,\n AdoReporter,\n LogReporter,\n ProgressReporter,\n VerboseFileLogReporter,\n ChromeTraceEventsReporter,\n} from \"@lage-run/reporters\";\nimport type { ReporterInitOptions } from \"../types/ReporterInitOptions.js\";\nimport { findPackageRoot } from \"workspace-tools\";\nimport { readFileSync } from \"fs\";\nimport path from \"path\";\n\nexport function createReporter(reporter: string, options: ReporterInitOptions) {\n const { verbose, grouped, logLevel: logLevelName, concurrency, profile, progress, logFile, indented } = options;\n const logLevel = LogLevel[logLevelName];\n\n const root = findPackageRoot(__filename)!;\n const packageJson = JSON.parse(readFileSync(path.join(root, \"package.json\"), \"utf-8\"));\n const version = packageJson.version;\n\n switch (reporter) {\n case \"profile\":\n return new ChromeTraceEventsReporter({\n concurrency,\n outputFile: typeof profile === \"string\" ? profile : undefined,\n });\n case \"json\":\n return new JsonReporter({ logLevel, indented: indented ?? false });\n case \"azureDevops\":\n case \"adoLog\":\n return new AdoReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel });\n\n case \"npmLog\":\n case \"old\":\n return new LogReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel });\n\n case \"verboseFileLog\":\n case \"vfl\":\n return new VerboseFileLogReporter(logFile);\n\n default:\n if (progress && !(logLevel >= LogLevel.verbose || verbose || grouped)) {\n return new ProgressReporter({ concurrency, version });\n }\n\n return new LogReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel });\n }\n}\n"],"names":["createReporter","reporter","options","verbose","grouped","logLevel","logLevelName","concurrency","profile","progress","logFile","indented","LogLevel","root","findPackageRoot","__filename","packageJson","JSON","parse","readFileSync","path","join","version","ChromeTraceEventsReporter","outputFile","undefined","JsonReporter","AdoReporter","LogReporter","VerboseFile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AO,GAAGE;YAAS;IACtF;AACF"}
1
+ {"version":3,"sources":["../../src/commands/createReporter.ts"],"sourcesContent":["import { LogLevel } from \"@lage-run/logger\";\nimport {\n JsonReporter,\n AdoReporter,\n LogReporter,\n ProgressReporter,\n VerboseFileLogReporter,\n ChromeTraceEventsReporter,\n} from \"@lage-run/reporters\";\nimport type { ReporterInitOptions } from \"../types/ReporterInitOptions.js\";\nimport type { Reporter } from \"@lage-run/logger\";\nimport { findPackageRoot } from \"workspace-tools\";\nimport { readFileSync } from \"fs\";\nimport path from \"path\";\nimport { pathToFileURL } from \"url\";\n\nexport async function createReporter(\n reporter: string,\n options: ReporterInitOptions,\n customReporters: Record<string, string> = {}\n): Promise<Reporter> {\n const { verbose, grouped, logLevel: logLevelName, concurrency, profile, progress, logFile, indented } = options;\n const logLevel = LogLevel[logLevelName];\n\n const root = findPackageRoot(__filename)!;\n const packageJson = JSON.parse(readFileSync(path.join(root, \"package.json\"), \"utf-8\"));\n const version = packageJson.version;\n\n switch (reporter) {\n case \"profile\":\n return new ChromeTraceEventsReporter({\n concurrency,\n outputFile: typeof profile === \"string\" ? profile : undefined,\n });\n case \"json\":\n return new JsonReporter({ logLevel, indented: indented ?? false });\n case \"azureDevops\":\n case \"adoLog\":\n return new AdoReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel });\n\n case \"npmLog\":\n case \"old\":\n return new LogReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel });\n\n case \"verboseFileLog\":\n case \"vfl\":\n return new VerboseFileLogReporter(logFile);\n\n default:\n // Check if it's a custom reporter defined in config\n if (customReporters && customReporters[reporter]) {\n const reporterPath = customReporters[reporter];\n const resolvedPath = path.isAbsolute(reporterPath) ? reporterPath : path.resolve(process.cwd(), reporterPath);\n\n try {\n // Use dynamic import to load the custom reporter module\n // This works with both ESM (.mjs, .js with type: module) and CommonJS (.cjs, .js) files\n const reporterModule = await import(pathToFileURL(resolvedPath).href);\n\n // Try different export patterns\n const ReporterClass = reporterModule.default ?? reporterModule[reporter] ?? reporterModule;\n\n if (typeof ReporterClass === \"function\") {\n return new ReporterClass(options);\n } else if (typeof ReporterClass === \"object\" && ReporterClass !== null) {\n // If it's already an instance\n return ReporterClass;\n } else {\n throw new Error(`Custom reporter \"${reporter}\" at \"${resolvedPath}\" does not export a valid reporter class or instance.`);\n }\n } catch (error) {\n throw new Error(`Failed to load custom reporter \"${reporter}\" from \"${resolvedPath}\": ${error}`);\n }\n }\n\n // Default reporter behavior\n if (progress && !(logLevel >= LogLevel.verbose || verbose || grouped)) {\n return new ProgressReporter({ concurrency, version });\n }\n\n return new LogReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel });\n }\n}\n"],"names":["createReporter","reporter","options","customReporters","verbose","grouped","logLevel","logLevelName","concurrency","profile","progress","logFile","indented","LogLevel","root","findPackageRoot","__filename","packageJson","JSON","parse","readFileSync","path","join","version","ChromeTraceEventsReporter","outputFile","undefined","JsonReporter","AdoReporter","LogReporter","VerboseFileLogReporter","reporterPath","resolvedPath","isAbsolute","resolve","process","cwd","reporterModule","pathToFileURL","href","ReporterClass","default","Error","error","ProgressReporter"],"mappings":";;;;+BAgBsBA;;;eAAAA;;;wBAhBG;2BAQlB;gCAGyB;oBACH;6DACZ;qBACa;;;;;;AAEvB,eAAeA,eACpBC,QAAgB,EAChBC,OAA4B,EAC5BC,kBAA0C,CAAC,CAAC;IAE5C,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,UAAUC,YAAY,EAAEC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGV;IACxG,MAAMI,WAAWO,gBAAQ,CAACN,aAAa;IAEvC,MAAMO,OAAOC,IAAAA,+BAAe,EAACC;IAC7B,MAAMC,cAAcC,KAAKC,KAAK,CAACC,IAAAA,gBAAY,EAACC,aAAI,CAACC,IAAI,CAACR,MAAM,iBAAiB;IAC7E,MAAMS,UAAUN,YAAYM,OAAO;IAEnC,OAA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gCAAgC,EAAEzC,SAAS,QAAQ,EAAE+B,aAAa,GAAG,EAAEW,OAAO;gBACjG;YACF;YAEA,4BAA4B;YAC5B,IAAIjC,YAAY,CAAEJ,CAAAA,YAAYO,gBAAQ,CAACT,OAAO,IAAIA,WAAWC,OAAM,GAAI;gBACrE,OAAO,IAAIuC,2BAAgB,CAAC;oBAAEpC;oBAAae;gBAAQ;YACrD;YAEA,OAAO,IAAIM,sBAAW,CAAC;gBAAExB;gBAASC,UAAUF,UAAUS,gBAAQ,CAACT,OAAO,GAAGE;YAAS;IACtF;AACF"}
@@ -12,17 +12,20 @@ const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger
12
12
  const _initializeReporters = require("../initializeReporters.js");
13
13
  const _executeInProcess = require("./executeInProcess.js");
14
14
  const _executeRemotely = require("./executeRemotely.js");
15
+ const _config = require("@lage-run/config");
15
16
  function _interop_require_default(obj) {
16
17
  return obj && obj.__esModule ? obj : {
17
18
  default: obj
18
19
  };
19
20
  }
20
21
  async function execAction(options, command) {
22
+ const cwd = options.cwd ?? process.cwd();
23
+ const config = await (0, _config.getConfig)(cwd);
21
24
  const logger = (0, _logger.default)();
22
- options.cwd = options.cwd ?? process.cwd();
25
+ options.cwd = cwd;
23
26
  options.logLevel = options.logLevel ?? "info";
24
27
  options.reporter = options.reporter ?? "json";
25
- (0, _initializeReporters.initializeReporters)(logger, options);
28
+ await (0, _initializeReporters.initializeReporters)(logger, options, config.reporters);
26
29
  const { server } = options;
27
30
  if (server) {
28
31
  logger.info("Running in server mode");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/exec/action.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport createLogger from \"@lage-run/logger\";\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { executeInProcess } from \"./executeInProcess.js\";\nimport { executeRemotely } from \"./executeRemotely.js\";\n\ninterface ExecOptions extends ReporterInitOptions {\n cwd?: string;\n server?: boolean | string;\n timeout?: number;\n nodeArg?: string;\n tasks?: string[];\n}\n\ninterface ExecRemoteOptions extends ExecOptions {\n tasks: string[];\n}\n\nexport async function execAction(options: ExecOptions, command: Command) {\n const logger = createLogger();\n options.cwd = options.cwd ?? process.cwd();\n options.logLevel = options.logLevel ?? \"info\";\n options.reporter = options.reporter ?? \"json\";\n initializeReporters(logger, options);\n\n const { server } = options;\n if (server) {\n logger.info(\"Running in server mode\");\n\n if (typeof options.tasks === \"undefined\") {\n throw new Error(\"No tasks specified, this is required for when running in server mode\");\n }\n\n await executeRemotely(options as ExecRemoteOptions, command);\n } else {\n await executeInProcess({ logger, args: command.args, cwd: options.cwd, nodeArg: options.nodeArg });\n }\n}\n"],"names":["execAction","options","command","logger","createLogger","cwd","process","logLevel","reporter","initializeReporters","server","info","tasks","Error","executeRemotely","executeInProcess","args","nodeArg"],"mappings":";;;;+BAmBsBA;;;eAAAA;;;+DAlBG;qCAEW;kCACH;iCACD;;;;;;AAczB,eAAeA,WAAWC,OAAoB,EAAEC,OAAgB;IACrE,MAAMC,SAASC,IAAAA,eAAY;IAC3BH,QAAQI,GAAG,GAAGJ,QAAQI,GAAG,IAAIC,QAAQD,GAAG;IACxCJ,QAAQM,QAAQ,GAAGN,QAAQM,QAAQ,IAAI;IACvCN,QAAQO,QAAQ,GAAGP,QAAQO,QAAQ,IAAI;IACvCC,IAAAA,wCAAmB,EAACN,QAAQF;IAE5B,MAAM,EAAES,MAAM,EAAE,GAAGT;IACnB,IAAIS,QAAQ;QACVP,OAAOQ,IAAI,CAAC;QAEZ,IAAI,OAAOV,QAAQW,KAAK,KAAK,aAAa;YACxC,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMC,IAAAA,gCAAe,EAACb,SAA8BC;IACtD,OAAO;QACL,MAAMa,IAAAA,kCAAgB,EAAC;YAAEZ;YAAQa,MAAMd,QAAQc,IAAI;YAAEX,KAAKJ,QAAQI,GAAG;YAAEY,SAAShB,QAAQgB,OAAO;QAAC;IAClG;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/exec/action.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport createLogger from \"@lage-run/logger\";\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { executeInProcess } from \"./executeInProcess.js\";\nimport { executeRemotely } from \"./executeRemotely.js\";\nimport { getConfig } from \"@lage-run/config\";\n\ninterface ExecOptions extends ReporterInitOptions {\n cwd?: string;\n server?: boolean | string;\n timeout?: number;\n nodeArg?: string;\n tasks?: string[];\n}\n\ninterface ExecRemoteOptions extends ExecOptions {\n tasks: string[];\n}\n\nexport async function execAction(options: ExecOptions, command: Command) {\n const cwd = options.cwd ?? process.cwd();\n const config = await getConfig(cwd);\n const logger = createLogger();\n options.cwd = cwd;\n options.logLevel = options.logLevel ?? \"info\";\n options.reporter = options.reporter ?? \"json\";\n await initializeReporters(logger, options, config.reporters);\n\n const { server } = options;\n if (server) {\n logger.info(\"Running in server mode\");\n\n if (typeof options.tasks === \"undefined\") {\n throw new Error(\"No tasks specified, this is required for when running in server mode\");\n }\n\n await executeRemotely(options as ExecRemoteOptions, command);\n } else {\n await executeInProcess({ logger, args: command.args, cwd: options.cwd, nodeArg: options.nodeArg });\n }\n}\n"],"names":["execAction","options","command","cwd","process","config","getConfig","logger","createLogger","logLevel","reporter","initializeReporters","reporters","server","info","tasks","Error","executeRemotely","executeInProcess","args","nodeArg"],"mappings":";;;;+BAoBsBA;;;eAAAA;;;+DAnBG;qCAEW;kCACH;iCACD;wBACN;;;;;;AAcnB,eAAeA,WAAWC,OAAoB,EAAEC,OAAgB;IACrE,MAAMC,MAAMF,QAAQE,GAAG,IAAIC,QAAQD,GAAG;IACtC,MAAME,SAAS,MAAMC,IAAAA,iBAAS,EAACH;IAC/B,MAAMI,SAASC,IAAAA,eAAY;IAC3BP,QAAQE,GAAG,GAAGA;IACdF,QAAQQ,QAAQ,GAAGR,QAAQQ,QAAQ,IAAI;IACvCR,QAAQS,QAAQ,GAAGT,QAAQS,QAAQ,IAAI;IACvC,MAAMC,IAAAA,wCAAmB,EAACJ,QAAQN,SAASI,OAAOO,SAAS;IAE3D,MAAM,EAAEC,MAAM,EAAE,GAAGZ;IACnB,IAAIY,QAAQ;QACVN,OAAOO,IAAI,CAAC;QAEZ,IAAI,OAAOb,QAAQc,KAAK,KAAK,aAAa;YACxC,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMC,IAAAA,gCAAe,EAAChB,SAA8BC;IACtD,OAAO;QACL,MAAMgB,IAAAA,kCAAgB,EAAC;YAAEX;YAAQY,MAAMjB,QAAQiB,IAAI;YAAEhB,KAAKF,QAAQE,GAAG;YAAEiB,SAASnB,QAAQmB,OAAO;QAAC;IAClG;AACF"}
@@ -15,6 +15,7 @@ const _rpc = require("@lage-run/rpc");
15
15
  const _filterArgsForTasks = require("../run/filterArgsForTasks.js");
16
16
  const _simulateFileAccess = require("./simulateFileAccess.js");
17
17
  const _parseServerOption = require("../parseServerOption.js");
18
+ const _config = require("@lage-run/config");
18
19
  const _workspacetools = require("workspace-tools");
19
20
  const _launchServerInBackground = require("../launchServerInBackground.js");
20
21
  function _interop_require_default(obj) {
@@ -91,10 +92,12 @@ async function executeRemotely(options, command) {
91
92
  const { server, tasks, nodeArg } = options;
92
93
  const timeout = options.timeout ?? 5 * 60;
93
94
  const { host, port } = (0, _parseServerOption.parseServerOption)(server);
95
+ const cwd = options.cwd ?? process.cwd();
96
+ const config = await (0, _config.getConfig)(cwd);
94
97
  const logger = (0, _logger.default)();
95
98
  options.logLevel = options.logLevel ?? "info";
96
99
  options.reporter = options.reporter ?? "json";
97
- (0, _initializeReporters.initializeReporters)(logger, options);
100
+ await (0, _initializeReporters.initializeReporters)(logger, options, config.reporters);
98
101
  const root = (0, _workspacetools.getWorkspaceRoot)(options.cwd ?? process.cwd());
99
102
  let client = await tryCreateClient(host, port);
100
103
  const args = command.args;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/exec/executeRemotely.ts"],"sourcesContent":["import path from \"path\";\nimport 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 // we will simulate file access even if exit code may be non-zero\n const relativeGlobalInputsForTarget = path.relative(root, path.join(response.cwd, response.globalInputHashFile));\n await simulateFileAccess(logger, root, [...response.inputs, relativeGlobalInputsForTarget], response.outputs);\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","relativeGlobalInputsForTarget","path","relative","globalInputHashFile","simulateFileAccess","inputs","outputs"],"mappings":";;;;+BA8FsBA;;;eAAAA;;;6DA9FL;+DAEQ;qCACW;qBAGO;oCACR;oCACA;mCACD;gCACD;0CAEQ;;;;;;AAUzC,eAAeC,gBAAgBC,IAAY,EAAEC,IAAY;IACvD,MAAMC,SAASC,IAAAA,iBAAY,EAAC;QAC1BC,SAAS,CAAC,OAAO,EAAEJ,KAAK,CAAC,EAAEC,MAAM;QACjCI,aAAa;IACf;IAEA,IAAI;QACF,MAAMC,UAAU,MAAMJ,OAAOK,IAAI,CAAC,CAAC;QACnC,IAAID,QAAQE,IAAI,EAAE;YAChB,OAAON;QACT;IACF,EAAE,OAAOO,GAAG;QACV,IAAIA,aAAaC,iBAAY,EAAE;YAC7B,OAAOC;QACT;QAEA,MAAMF;IACR;IAEA,OAAOE;AACT;AAEA,eAAeC,2BAA2BZ,IAAY,EAAEC,IAAY,EAAEY,MAAc;IAClF,IAAIX;IAEJ,MAAMY,QAAQC,KAAKC,GAAG;IACtB,MAAOD,KAAKC,GAAG,KAAKF,QAAQ,IAAI,KAAM;QACpC,IAAI;YACFZ,SAAS,MAAMH,gBAAgBC,MAAMC;YAErC,IAAIC,QAAQ;gBACV,OAAOA;YACT;QACF,EAAE,OAAOO,GAAG;YACV,IAAIA,aAAaC,iBAAY,EAAE;gBAC7BG,OAAOI,KAAK,CAAC,8BAA8BR;YAC7C;QACF;QAEA,MAAM,IAAIS,QAAQ,CAACC,UAAYC,WAAWD,SAAS;IACrD;IAEA,OAAOR;AACT;AAEA,eAAeU,gBAAgBC,IAAc,EAAEpB,MAAkB,EAAEW,MAAc;IAC/E,MAAMU,OAAOD,KAAKE,MAAM,KAAK,IAAIF,IAAI,CAAC,EAAE,GAAGA,IAAI,CAAC,EAAE;IAClD,MAAMG,cAAcH,KAAKE,MAAM,GAAG,IAAIF,IAAI,CAAC,EAAE,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,CAAC,MAAM;IAEpD,IAAI,CAAC9C,QAAQ;QACX,MAAM+C,IAAAA,kDAAwB,EAAC;YAC7BjD;YACAC;YACAmC;YACAd;YACAgB;YACAzB;YACA+B;YACAP;QACF;QAEAxB,OAAOkB,IAAI,CAAC;QACZ7B,SAAS,MAAMU,2BAA2BZ,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,iEAAiE;QACjE,MAAMqB,gCAAgCC,aAAI,CAACC,QAAQ,CAACX,MAAMU,aAAI,CAACN,IAAI,CAACnB,SAASiB,GAAG,EAAEjB,SAAS2B,mBAAmB;QAC9G,MAAMC,IAAAA,sCAAkB,EAAC5C,QAAQ+B,MAAM;eAAIf,SAAS6B,MAAM;YAAEL;SAA8B,EAAExB,SAAS8B,OAAO;IAC9G,OAAO;QACLZ,QAAQf,QAAQ,GAAG;IACrB;IAEAnB,OAAOkB,IAAI,CAAC;AACd"}
1
+ {"version":3,"sources":["../../../src/commands/exec/executeRemotely.ts"],"sourcesContent":["import path from \"path\";\nimport 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 { getConfig } from \"@lage-run/config\";\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 const cwd = options.cwd ?? process.cwd();\n const config = await getConfig(cwd);\n\n const logger = createLogger();\n options.logLevel = options.logLevel ?? \"info\";\n options.reporter = options.reporter ?? \"json\";\n await initializeReporters(logger, options, config.reporters);\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 // we will simulate file access even if exit code may be non-zero\n const relativeGlobalInputsForTarget = path.relative(root, path.join(response.cwd, response.globalInputHashFile));\n await simulateFileAccess(logger, root, [...response.inputs, relativeGlobalInputsForTarget], response.outputs);\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","cwd","process","config","getConfig","createLogger","logLevel","reporter","initializeReporters","reporters","root","getWorkspaceRoot","join","launchServerInBackground","stdout","write","stderr","relativeGlobalInputsForTarget","path","relative","globalInputHashFile","simulateFileAccess","inputs","outputs"],"mappings":";;;;+BA+FsBA;;;eAAAA;;;6DA/FL;+DAEQ;qCACW;qBAGO;oCACR;oCACA;mCACD;wBACR;gCACO;0CAEQ;;;;;;AAUzC,eAAeC,g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C;YACAd;YACAgB;YACAzB;YACAoC;YACAZ;QACF;QAEAxB,OAAOkB,IAAI,CAAC;QACZ7B,SAAS,MAAMU,2BAA2BZ,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;QACZY,QAAQY,MAAM,CAACC,KAAK,CAACzB,SAASwB,MAAM;QACpCZ,QAAQc,MAAM,CAACD,KAAK,CAACzB,SAAS0B,MAAM;QACpCd,QAAQT,QAAQ,GAAGH,SAASG,QAAQ;QAEpC,iEAAiE;QACjE,MAAMwB,gCAAgCC,aAAI,CAACC,QAAQ,CAACT,MAAMQ,aAAI,CAACN,IAAI,CAACtB,SAASW,GAAG,EAAEX,SAAS8B,mBAAmB;QAC9G,MAAMC,IAAAA,sCAAkB,EAAC/C,QAAQoC,MAAM;eAAIpB,SAASgC,MAAM;YAAEL;SAA8B,EAAE3B,SAASiC,OAAO;IAC9G,OAAO;QACLrB,QAAQT,QAAQ,GAAG;IACrB;IAEAnB,OAAOkB,IAAI,CAAC;AACd"}
@@ -47,7 +47,7 @@ async function infoAction(options, command) {
47
47
  options.logLevel = options.logLevel ?? "info";
48
48
  options.reporter = options.reporter ?? "json";
49
49
  options.server = typeof options.server === "boolean" && options.server ? "localhost:5332" : options.server;
50
- (0, _initializeReporters.initializeReporters)(logger, options);
50
+ await (0, _initializeReporters.initializeReporters)(logger, options, config.reporters);
51
51
  const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
52
52
  const packageInfos = (0, _workspacetools.getPackageInfos)(root);
53
53
  const { tasks, taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/info/action.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { createTargetGraph } from \"../run/createTargetGraph.js\";\nimport { filterArgsForTasks } from \"../run/filterArgsForTasks.js\";\nimport type { ConfigOptions } from \"@lage-run/config\";\nimport { getConfig } from \"@lage-run/config\";\nimport { type PackageInfos, getPackageInfos, getWorkspaceRoot } from \"workspace-tools\";\nimport { getFilteredPackages } from \"../../filter/getFilteredPackages.js\";\nimport createLogger from \"@lage-run/logger\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { parse } from \"shell-quote\";\n\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport { type Target, getStartTargetId } from \"@lage-run/target-graph\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { TargetRunnerPicker } from \"@lage-run/runners\";\nimport { getBinPaths } from \"../../getBinPaths.js\";\nimport { runnerPickerOptions } from \"../../runnerPickerOptions.js\";\nimport { parseServerOption } from \"../parseServerOption.js\";\nimport { optimizeTargetGraph } from \"../../optimizeTargetGraph.js\";\nimport { glob } from \"@lage-run/globby\";\nimport { FileHasher, hashStrings } from \"@lage-run/hasher\";\nimport { getGlobalInputHashFilePath } from \"../targetHashFilePath.js\";\n\nexport interface InfoActionOptions extends ReporterInitOptions {\n dependencies: boolean;\n dependents: boolean;\n since: string;\n scope: string[];\n to: string[];\n cache: boolean;\n nodeArg: string;\n ignore: string[];\n server: string;\n outputFile?: string;\n optimizeGraph: boolean;\n}\n\ninterface PackageTask {\n id: string;\n command: string[];\n dependencies: string[];\n workingDirectory: string;\n package: string;\n task: string;\n inputs?: string[];\n outputs?: string[];\n options?: Record<string, any>;\n weight?: number;\n}\n\n/**\n * The info command displays information about a target graph in a workspace.\n * The generated output can be read and used by other task runners, such as BuildXL.\n *\n * Expected format:\n * [\n * {\n * \"id\": \"bar##build\",\n * \"package\": \"bar\",\n * \"task\": \"build\",\n * \"command\": \"npm run build --blah\",\n * \"workingDirectory\": \"packages/bar\",\n * \"dependencies\": []\n * },\n * {\n * \"id\": \"foo##build\",\n * \"package\": \"foo\",\n * \"task\": \"build\",\n * \"command\": \"npm run build --blah\",\n * \"workingDirectory\": \"packages/foo\",\n * \"dependencies\": [\n * \"bar##build\"\n * ],\n * \"weight\": 3,\n * \"inputs\": [\"src//**/ /*.ts\"],\n * \"inputs\": [\"lib//**/ /*.js\", \"lib//**/ /*.d.ts]\"\n * \"options\": {\n * \"environment\": {\n * \"custom_env_var\": \"x\",\n * }\n * }\n * },\n * {\n * \"id\": \"foo##test\",\n * \"package\": \"foo\",\n * \"task\": \"test\",\n * \"command\": \"npm run test --blah\",\n * \"workingDirectory\": \"packages/foo\",\n * \"dependencies\": [\n * \"foo##build\"\n * ]\n * },\n * ...\n * ]\n */\nexport async function infoAction(options: InfoActionOptions, command: Command) {\n const cwd = process.cwd();\n const config = await getConfig(cwd);\n const logger = createLogger();\n options.logLevel = options.logLevel ?? \"info\";\n options.reporter = options.reporter ?? \"json\";\n options.server = typeof options.server === \"boolean\" && options.server ? \"localhost:5332\" : options.server;\n initializeReporters(logger, options);\n const root = getWorkspaceRoot(cwd)!;\n\n const packageInfos = getPackageInfos(root);\n\n const { tasks, taskArgs } = filterArgsForTasks(command.args);\n\n const targetGraph = await createTargetGraph({\n logger,\n root,\n dependencies: options.dependencies,\n dependents: options.dependents && !options.to, // --to is a short hand for --scope + --no-dependents\n ignore: options.ignore.concat(config.ignore),\n pipeline: config.pipeline,\n repoWideChanges: config.repoWideChanges,\n scope: (options.scope ?? []).concat(options.to ?? []), // --to is a short hand for --scope + --no-dependents\n since: options.since,\n outputs: config.cacheOptions.outputGlob,\n tasks,\n packageInfos,\n priorities: config.priorities,\n enableTargetConfigMerging: config.enableTargetConfigMerging,\n });\n\n const scope = getFilteredPackages({\n root,\n packageInfos,\n logger,\n includeDependencies: options.dependencies,\n includeDependents: options.dependents && !options.to, // --to is a short hand for --scope + --no-dependents\n since: options.since,\n scope: (options.scope ?? []).concat(options.to ?? []), // --to is a short hand for --scope + --no-dependents\n repoWideChanges: config.repoWideChanges,\n sinceIgnoreGlobs: options.ignore.concat(config.ignore),\n });\n\n const pickerOptions = runnerPickerOptions(options.nodeArg, config.npmClient, taskArgs);\n\n const runnerPicker = new TargetRunnerPicker(pickerOptions);\n\n // This is a temporary flag to allow backwards compatibility with the old lage graph format used by BuildXL (formerly known as Domino).\n // I initially worked on a commandline flag, but threading that through requires 3 different releases (lage, buildxl, ohome).\n // This is a temp solution to be able to upgrade to Lage V2 without breaking the BuildXL integration. And allow us\n // to update to lage v2.\n // Unfortunately this is the only variable that we can use to not break any other customers\n const createBackwardsCompatGraph = process.env[\"DOMINO\"] === \"1\" || !options.optimizeGraph;\n\n const optimizedTargets = await optimizeTargetGraph(targetGraph, runnerPicker, createBackwardsCompatGraph);\n const binPaths = getBinPaths();\n const packageTasks = optimizedTargets.map((target) =>\n generatePackageTask(target, taskArgs, config, options, binPaths, packageInfos, tasks)\n );\n\n // In worker server mode, we need to actually speed up the BuildXL runs with presupplied global input hashes so that it doesn't try to read it over and over again\n // This is an important optimization for BuildXL for large amount of env glob matches in non-well-behaved monorepos\n // (e.g. repos that have files listed in env glob to avoid circular dependencies in package graph)\n if (shouldRunWorkersAsService(options)) {\n // For each target in the target graph, we need to create a global input hash file in this kind of location:\n // ${target.cwd}/.lage/global_inputs_hash\n // We will use glob for these files and use the FileHasher to generate these hashes.\n const fileHasher = new FileHasher({\n root,\n });\n\n const globHashCache = new Map<string, string>();\n const globHashWithCache = (patterns: string[], options: { cwd: string }) => {\n const key = patterns.join(\"###\");\n if (globHashCache.has(key)) {\n return globHashCache.get(key)!;\n }\n\n const files = glob(patterns, options);\n const hash = hashStrings(Object.values(fileHasher.hash(files.map((file) => path.join(root, file)))));\n\n globHashCache.set(key, hash);\n\n return hash;\n };\n\n const globalInputs = config.cacheOptions?.environmentGlob\n ? glob(config.cacheOptions?.environmentGlob, { cwd: root })\n : [\"lage.config.js\"];\n\n for (const target of optimizedTargets) {\n if (target.id === getStartTargetId()) {\n continue;\n }\n\n const targetGlobalInputsHash = target.environmentGlob\n ? globHashWithCache(target.environmentGlob, { cwd: root })\n : globHashWithCache(globalInputs, { cwd: root });\n\n const targetGlobalInputsHashFile = path.join(target.cwd, getGlobalInputHashFilePath(target));\n const targetGlobalInputsHashFileDir = path.dirname(targetGlobalInputsHashFile);\n\n // Make sure the directory exists\n if (!fs.existsSync(targetGlobalInputsHashFileDir)) {\n fs.mkdirSync(targetGlobalInputsHashFileDir, { recursive: true });\n }\n\n // Write the hash to the file\n fs.writeFileSync(targetGlobalInputsHashFile, targetGlobalInputsHash);\n }\n }\n\n const infoResult = {\n command: command.args,\n scope,\n packageTasks,\n };\n\n if (options.outputFile) {\n const parentFolder = path.dirname(options.outputFile);\n if (!fs.existsSync(parentFolder)) {\n await fs.promises.mkdir(parentFolder, { recursive: true });\n }\n const infoJson = JSON.stringify(infoResult, null, options.verbose ? 2 : undefined);\n await fs.promises.writeFile(options.outputFile, infoJson);\n logger.info(`Wrote info to file: ${options.outputFile}`);\n } else {\n logger.info(\"info\", infoResult);\n }\n}\n\nexport function generatePackageTask(\n target: Target,\n taskArgs: string[],\n config: ConfigOptions,\n options: InfoActionOptions,\n binPaths: { lage: string; \"lage-server\": string },\n packageInfos: PackageInfos,\n tasks: string[]\n): PackageTask {\n const command = generateCommand(target, taskArgs, config, options, binPaths, packageInfos, tasks);\n const workingDirectory = getWorkingDirectory(target);\n\n const packageTask: PackageTask = {\n id: target.id,\n command,\n dependencies: target.dependencies,\n workingDirectory,\n package: target.packageName ?? \"\",\n task: target.task,\n inputs: target.inputs,\n outputs: target.outputs,\n };\n\n if (target.weight && target.weight !== 1) {\n packageTask.weight = target.weight;\n }\n\n if (target.options && Object.keys(target.options).length != 0) {\n packageTask.options = target.options;\n }\n\n return packageTask;\n}\n\nfunction shouldRunWorkersAsService(options: InfoActionOptions) {\n return (typeof process.env.LAGE_WORKER_SERVER === \"string\" && process.env.LAGE_WORKER_SERVER !== \"false\") || !!options.server;\n}\n\nfunction generateCommand(\n target: Target,\n taskArgs: string[],\n config: ConfigOptions,\n options: InfoActionOptions,\n binPaths: { lage: string; \"lage-server\": string },\n packageInfos: PackageInfos,\n tasks: string[]\n) {\n if (target.type === \"npmScript\") {\n const script = target.packageName !== undefined ? packageInfos[target.packageName]?.scripts?.[target.task] : undefined;\n\n // If the script is a node script, and that it does not have any shell operators (&&, ||, etc)\n // then we can simply pass this along to info command rather than using npm client to run it.\n if (script && script.startsWith(\"node\")) {\n const parsed = parse(script);\n if (parsed.length > 0 && parsed.every((entry) => typeof entry === \"string\")) {\n return [...(parsed as string[]), ...taskArgs];\n }\n }\n\n const npmClient = config.npmClient ?? \"npm\";\n const command = [npmClient, ...getNpmArgs(target.task, taskArgs)];\n return command;\n } else if (target.type === \"worker\" && shouldRunWorkersAsService(options)) {\n const { host, port } = parseServerOption(options.server);\n const command = [binPaths[\"lage\"], \"exec\", \"--tasks\", ...tasks, \"--server\", `${host}:${port}`];\n if (options.concurrency) {\n command.push(\"--concurrency\", options.concurrency.toString());\n }\n\n if (target.packageName) {\n command.push(target.packageName);\n }\n\n if (target.task) {\n command.push(target.task);\n }\n\n command.push(...taskArgs);\n return command;\n } else if (target.type === \"worker\") {\n const command = [binPaths.lage, \"exec\"];\n command.push(target.packageName ?? \"\");\n command.push(target.task);\n command.push(...taskArgs);\n return command;\n }\n\n return [];\n}\n\nfunction getWorkingDirectory(target) {\n const cwd = process.cwd();\n const workingDirectory = path.relative(getWorkspaceRoot(cwd) ?? \"\", target.cwd).replace(/\\\\/g, \"/\");\n return workingDirectory;\n}\n\nfunction getNpmArgs(task: string, taskTargs: string[]) {\n const extraArgs = taskTargs != undefined && taskTargs.length > 0 ? [\"--\", ...taskTargs] : [];\n return [\"run\", task, ...extraArgs];\n}\n"],"names":["generatePackageTask","infoAction","options","command","cwd","process","config","getConfig","logger","createLogger","logLevel","reporter","server","initializeReporters","root","getWorkspaceRoot","packageInfos","getPackageInfos","tasks","taskArgs","filterArgsForTasks","args","targetGraph","createTargetGraph","dependencies","dependents","to","ignore","concat","pipeline","repoWideChanges","scope","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","getFilteredPackages","includeDependencies","includeDependents","sinceIgnoreGlobs","pickerOptions","runnerPickerOptions","nodeArg","npmClient","runnerPicker","TargetRunnerPicker","createBackwardsCompatGraph","env","optimizeGraph","optimizedTargets","optimizeTargetGraph","binPaths","getBinPaths","packageTasks","map","target","shouldRunWorkersAsService","fileHasher","FileHasher","globHashCache","Map","globHashWithCache","patterns","key","join","has","get","files","glob","hash","hashStrings","Object","values","file","path","set","globalInputs","environmentGlob","id","getStartTargetId","targetGlobalInputsHash","targetGlobalInputsHashFile","getGlobalInputHashFilePath","targetGlobalInputsHashFileDir","dirname","fs","existsSync","mkdirSync","recursive","writeFileSync","infoResult","outputFile","parentFolder","promises","mkdir","infoJson","JSON","stringify","verbose","undefined","writeFile","info","generateCommand","workingDirectory","getWorkingDirectory","packageTask","package","packageName","task","inputs","weight","keys","length","LAGE_WORKER_SERVER","type","script","scripts","startsWith","parsed","parse","every","entry","getNpmArgs","host","port","parseServerOption","concurrency","push","toString","lage","relative","replace","taskTargs","extraArgs"],"mappings":";;;;;;;;;;;QAmOgBA;eAAAA;;QAnIMC;eAAAA;;;mCA/FY;oCACC;wBAET;gCAC2C;qCACjC;+DACX;6DACR;2DACF;4BACO;6BAGwB;qCACV;yBACD;6BACP;qCACQ;mCACF;qCACE;wBACf;wBACmB;oCACG;;;;;;AA0EpC,eAAeA,WAAWC,OAA0B,EAAEC,OAAgB;IAC3E,MAAMC,MAAMC,QAAQD,GAAG;IACvB,MAAME,SAAS,MAAMC,IAAAA,iBAAS,EAACH;IAC/B,MAAMI,SAASC,IAAAA,eAAY;IAC3BP,QAAQQ,QAAQ,GAAGR,QAAQQ,QAAQ,IAAI;IACvCR,QAAQS,QAAQ,GAAGT,QAAQS,QAAQ,IAAI;IACvCT,QAAQU,MAAM,GAAG,OAAOV,QAAQU,MAAM,KAAK,aAAaV,QAAQU,MAAM,GAAG,mBAAmBV,QA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uG,oBAAoBjD,MAAM;IACjC,MAAMrD,MAAMC,QAAQD,GAAG;IACvB,MAAMqG,mBAAmB7B,aAAI,CAACwD,QAAQ,CAACrH,IAAAA,gCAAgB,EAACX,QAAQ,IAAIqD,OAAOrD,GAAG,EAAEiI,OAAO,CAAC,OAAO;IAC/F,OAAO5B;AACT;AAEA,SAASmB,WAAWd,IAAY,EAAEwB,SAAmB;IACnD,MAAMC,YAAYD,aAAajC,aAAaiC,UAAUpB,MAAM,GAAG,IAAI;QAAC;WAASoB;KAAU,GAAG,EAAE;IAC5F,OAAO;QAAC;QAAOxB;WAASyB;KAAU;AACpC"}
1
+ {"version":3,"sources":["../../../src/commands/info/action.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { createTargetGraph } from \"../run/createTargetGraph.js\";\nimport { filterArgsForTasks } from \"../run/filterArgsForTasks.js\";\nimport type { ConfigOptions } from \"@lage-run/config\";\nimport { getConfig } from \"@lage-run/config\";\nimport { type PackageInfos, getPackageInfos, getWorkspaceRoot } from \"workspace-tools\";\nimport { getFilteredPackages } from \"../../filter/getFilteredPackages.js\";\nimport createLogger from \"@lage-run/logger\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { parse } from \"shell-quote\";\n\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport { type Target, getStartTargetId } from \"@lage-run/target-graph\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { TargetRunnerPicker } from \"@lage-run/runners\";\nimport { getBinPaths } from \"../../getBinPaths.js\";\nimport { runnerPickerOptions } from \"../../runnerPickerOptions.js\";\nimport { parseServerOption } from \"../parseServerOption.js\";\nimport { optimizeTargetGraph } from \"../../optimizeTargetGraph.js\";\nimport { glob } from \"@lage-run/globby\";\nimport { FileHasher, hashStrings } from \"@lage-run/hasher\";\nimport { getGlobalInputHashFilePath } from \"../targetHashFilePath.js\";\n\nexport interface InfoActionOptions extends ReporterInitOptions {\n dependencies: boolean;\n dependents: boolean;\n since: string;\n scope: string[];\n to: string[];\n cache: boolean;\n nodeArg: string;\n ignore: string[];\n server: string;\n outputFile?: string;\n optimizeGraph: boolean;\n}\n\ninterface PackageTask {\n id: string;\n command: string[];\n dependencies: string[];\n workingDirectory: string;\n package: string;\n task: string;\n inputs?: string[];\n outputs?: string[];\n options?: Record<string, any>;\n weight?: number;\n}\n\n/**\n * The info command displays information about a target graph in a workspace.\n * The generated output can be read and used by other task runners, such as BuildXL.\n *\n * Expected format:\n * [\n * {\n * \"id\": \"bar##build\",\n * \"package\": \"bar\",\n * \"task\": \"build\",\n * \"command\": \"npm run build --blah\",\n * \"workingDirectory\": \"packages/bar\",\n * \"dependencies\": []\n * },\n * {\n * \"id\": \"foo##build\",\n * \"package\": \"foo\",\n * \"task\": \"build\",\n * \"command\": \"npm run build --blah\",\n * \"workingDirectory\": \"packages/foo\",\n * \"dependencies\": [\n * \"bar##build\"\n * ],\n * \"weight\": 3,\n * \"inputs\": [\"src//**/ /*.ts\"],\n * \"inputs\": [\"lib//**/ /*.js\", \"lib//**/ /*.d.ts]\"\n * \"options\": {\n * \"environment\": {\n * \"custom_env_var\": \"x\",\n * }\n * }\n * },\n * {\n * \"id\": \"foo##test\",\n * \"package\": \"foo\",\n * \"task\": \"test\",\n * \"command\": \"npm run test --blah\",\n * \"workingDirectory\": \"packages/foo\",\n * \"dependencies\": [\n * \"foo##build\"\n * ]\n * },\n * ...\n * ]\n */\nexport async function infoAction(options: InfoActionOptions, command: Command) {\n const cwd = process.cwd();\n const config = await getConfig(cwd);\n const logger = createLogger();\n options.logLevel = options.logLevel ?? \"info\";\n options.reporter = options.reporter ?? \"json\";\n options.server = typeof options.server === \"boolean\" && options.server ? \"localhost:5332\" : options.server;\n await initializeReporters(logger, options, config.reporters);\n const root = getWorkspaceRoot(cwd)!;\n\n const packageInfos = getPackageInfos(root);\n\n const { tasks, taskArgs } = filterArgsForTasks(command.args);\n\n const targetGraph = await createTargetGraph({\n logger,\n root,\n dependencies: options.dependencies,\n dependents: options.dependents && !options.to, // --to is a short hand for --scope + --no-dependents\n ignore: options.ignore.concat(config.ignore),\n pipeline: config.pipeline,\n repoWideChanges: config.repoWideChanges,\n scope: (options.scope ?? []).concat(options.to ?? []), // --to is a short hand for --scope + --no-dependents\n since: options.since,\n outputs: config.cacheOptions.outputGlob,\n tasks,\n packageInfos,\n priorities: config.priorities,\n enableTargetConfigMerging: config.enableTargetConfigMerging,\n });\n\n const scope = getFilteredPackages({\n root,\n packageInfos,\n logger,\n includeDependencies: options.dependencies,\n includeDependents: options.dependents && !options.to, // --to is a short hand for --scope + --no-dependents\n since: options.since,\n scope: (options.scope ?? []).concat(options.to ?? []), // --to is a short hand for --scope + --no-dependents\n repoWideChanges: config.repoWideChanges,\n sinceIgnoreGlobs: options.ignore.concat(config.ignore),\n });\n\n const pickerOptions = runnerPickerOptions(options.nodeArg, config.npmClient, taskArgs);\n\n const runnerPicker = new TargetRunnerPicker(pickerOptions);\n\n // This is a temporary flag to allow backwards compatibility with the old lage graph format used by BuildXL (formerly known as Domino).\n // I initially worked on a commandline flag, but threading that through requires 3 different releases (lage, buildxl, ohome).\n // This is a temp solution to be able to upgrade to Lage V2 without breaking the BuildXL integration. And allow us\n // to update to lage v2.\n // Unfortunately this is the only variable that we can use to not break any other customers\n const createBackwardsCompatGraph = process.env[\"DOMINO\"] === \"1\" || !options.optimizeGraph;\n\n const optimizedTargets = await optimizeTargetGraph(targetGraph, runnerPicker, createBackwardsCompatGraph);\n const binPaths = getBinPaths();\n const packageTasks = optimizedTargets.map((target) =>\n generatePackageTask(target, taskArgs, config, options, binPaths, packageInfos, tasks)\n );\n\n // In worker server mode, we need to actually speed up the BuildXL runs with presupplied global input hashes so that it doesn't try to read it over and over again\n // This is an important optimization for BuildXL for large amount of env glob matches in non-well-behaved monorepos\n // (e.g. repos that have files listed in env glob to avoid circular dependencies in package graph)\n if (shouldRunWorkersAsService(options)) {\n // For each target in the target graph, we need to create a global input hash file in this kind of location:\n // ${target.cwd}/.lage/global_inputs_hash\n // We will use glob for these files and use the FileHasher to generate these hashes.\n const fileHasher = new FileHasher({\n root,\n });\n\n const globHashCache = new Map<string, string>();\n const globHashWithCache = (patterns: string[], options: { cwd: string }) => {\n const key = patterns.join(\"###\");\n if (globHashCache.has(key)) {\n return globHashCache.get(key)!;\n }\n\n const files = glob(patterns, options);\n const hash = hashStrings(Object.values(fileHasher.hash(files.map((file) => path.join(root, file)))));\n\n globHashCache.set(key, hash);\n\n return hash;\n };\n\n const globalInputs = config.cacheOptions?.environmentGlob\n ? glob(config.cacheOptions?.environmentGlob, { cwd: root })\n : [\"lage.config.js\"];\n\n for (const target of optimizedTargets) {\n if (target.id === getStartTargetId()) {\n continue;\n }\n\n const targetGlobalInputsHash = target.environmentGlob\n ? globHashWithCache(target.environmentGlob, { cwd: root })\n : globHashWithCache(globalInputs, { cwd: root });\n\n const targetGlobalInputsHashFile = path.join(target.cwd, getGlobalInputHashFilePath(target));\n const targetGlobalInputsHashFileDir = path.dirname(targetGlobalInputsHashFile);\n\n // Make sure the directory exists\n if (!fs.existsSync(targetGlobalInputsHashFileDir)) {\n fs.mkdirSync(targetGlobalInputsHashFileDir, { recursive: true });\n }\n\n // Write the hash to the file\n fs.writeFileSync(targetGlobalInputsHashFile, targetGlobalInputsHash);\n }\n }\n\n const infoResult = {\n command: command.args,\n scope,\n packageTasks,\n };\n\n if (options.outputFile) {\n const parentFolder = path.dirname(options.outputFile);\n if (!fs.existsSync(parentFolder)) {\n await fs.promises.mkdir(parentFolder, { recursive: true });\n }\n const infoJson = JSON.stringify(infoResult, null, options.verbose ? 2 : undefined);\n await fs.promises.writeFile(options.outputFile, infoJson);\n logger.info(`Wrote info to file: ${options.outputFile}`);\n } else {\n logger.info(\"info\", infoResult);\n }\n}\n\nexport function generatePackageTask(\n target: Target,\n taskArgs: string[],\n config: ConfigOptions,\n options: InfoActionOptions,\n binPaths: { lage: string; \"lage-server\": string },\n packageInfos: PackageInfos,\n tasks: string[]\n): PackageTask {\n const command = generateCommand(target, taskArgs, config, options, binPaths, packageInfos, tasks);\n const workingDirectory = getWorkingDirectory(target);\n\n const packageTask: PackageTask = {\n id: target.id,\n command,\n dependencies: target.dependencies,\n workingDirectory,\n package: target.packageName ?? \"\",\n task: target.task,\n inputs: target.inputs,\n outputs: target.outputs,\n };\n\n if (target.weight && target.weight !== 1) {\n packageTask.weight = target.weight;\n }\n\n if (target.options && Object.keys(target.options).length != 0) {\n packageTask.options = target.options;\n }\n\n return packageTask;\n}\n\nfunction shouldRunWorkersAsService(options: InfoActionOptions) {\n return (typeof process.env.LAGE_WORKER_SERVER === \"string\" && process.env.LAGE_WORKER_SERVER !== \"false\") || !!options.server;\n}\n\nfunction generateCommand(\n target: Target,\n taskArgs: string[],\n config: ConfigOptions,\n options: InfoActionOptions,\n binPaths: { lage: string; \"lage-server\": string },\n packageInfos: PackageInfos,\n tasks: string[]\n) {\n if (target.type === \"npmScript\") {\n const script = target.packageName !== undefined ? packageInfos[target.packageName]?.scripts?.[target.task] : undefined;\n\n // If the script is a node script, and that it does not have any shell operators (&&, ||, etc)\n // then we can simply pass this along to info command rather than using npm client to run it.\n if (script && script.startsWith(\"node\")) {\n const parsed = parse(script);\n if (parsed.length > 0 && parsed.every((entry) => typeof entry === \"string\")) {\n return [...(parsed as string[]), ...taskArgs];\n }\n }\n\n const npmClient = config.npmClient ?? \"npm\";\n const command = [npmClient, ...getNpmArgs(target.task, taskArgs)];\n return command;\n } else if (target.type === \"worker\" && shouldRunWorkersAsService(options)) {\n const { host, port } = parseServerOption(options.server);\n const command = [binPaths[\"lage\"], \"exec\", \"--tasks\", ...tasks, \"--server\", `${host}:${port}`];\n if (options.concurrency) {\n command.push(\"--concurrency\", options.concurrency.toString());\n }\n\n if (target.packageName) {\n command.push(target.packageName);\n }\n\n if (target.task) {\n command.push(target.task);\n }\n\n command.push(...taskArgs);\n return command;\n } else if (target.type === \"worker\") {\n const command = [binPaths.lage, \"exec\"];\n command.push(target.packageName ?? \"\");\n command.push(target.task);\n command.push(...taskArgs);\n return command;\n }\n\n return [];\n}\n\nfunction getWorkingDirectory(target) {\n const cwd = process.cwd();\n const workingDirectory = path.relative(getWorkspaceRoot(cwd) ?? \"\", target.cwd).replace(/\\\\/g, \"/\");\n return workingDirectory;\n}\n\nfunction getNpmArgs(task: string, taskTargs: string[]) {\n const extraArgs = taskTargs != undefined && taskTargs.length > 0 ? [\"--\", ...taskTargs] : [];\n return [\"run\", task, ...extraArgs];\n}\n"],"names":["generatePackageTask","infoAction","options","command","cwd","process","config","getConfig","logger","createLogger","logLevel","reporter","server","initializeReporters","reporters","root","getWorkspaceRoot","packageInfos","getPackageInfos","tasks","taskArgs","filterArgsForTasks","args","targetGraph","createTargetGraph","dependencies","dependents","to","ignore","concat","pipeline","repoWideChanges","scope","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","getFilteredPackages","includeDependencies","includeDependents","sinceIgnoreGlobs","pickerOptions","runnerPickerOptions","nodeArg","npmClient","runnerPicker","TargetRunnerPicker","createBackwardsCompatGraph","env","optimizeGraph","optimizedTargets","optimizeTargetGraph","binPaths","getBinPaths","packageTasks","map","target","shouldRunWorkersAsService","fileHasher","FileHasher","globHashCache","Map","globHashWithCache","patterns","key","join","has","get","files","glob","hash","hashStrings","Object","values","file","path","set","globalInputs","environmentGlob","id","getStartTargetId","targetGlobalInputsHash","targetGlobalInputsHashFile","getGlobalInputHashFilePath","targetGlobalInputsHashFileDir","dirname","fs","existsSync","mkdirSync","recursive","writeFileSync","infoResult","outputFile","parentFolder","promises","mkdir","infoJson","JSON","stringify","verbose","undefined","writeFile","info","generateCommand","workingDirectory","getWorkingDirectory","packageTask","package","packageName","task","inputs","weight","keys","length","LAGE_WORKER_SERVER","type","script","scripts","startsWith","parsed","parse","every","entry","getNpmArgs","host","port","parseServerOption","concurrency","push","toString","lage","relative","replace","taskTargs","extraArgs"],"mappings":";;;;;;;;;;;QAmOgBA;eAAAA;;QAnIMC;eAAAA;;;mCA/FY;oCACC;wBAET;gCAC2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AAIzE,OAAOoD,WAAW,EAAE;YACtB3G,QAAQ+H,IAAI,CAACxE,OAAOoD,WAAW;QACjC;QAEA,IAAIpD,OAAOqD,IAAI,EAAE;YACf5G,QAAQ+H,IAAI,CAACxE,OAAOqD,IAAI;QAC1B;QAEA5G,QAAQ+H,IAAI,IAAI9G;QAChB,OAAOjB;IACT,OAAO,IAAIuD,OAAO2D,IAAI,KAAK,UAAU;QACnC,MAAMlH,UAAU;YAACmD,SAAS8E,IAAI;YAAE;SAAO;QACvCjI,QAAQ+H,IAAI,CAACxE,OAAOoD,WAAW,IAAI;QACnC3G,QAAQ+H,IAAI,CAACxE,OAAOqD,IAAI;QACxB5G,QAAQ+H,IAAI,IAAI9G;QAChB,OAAOjB;IACT;IAEA,OAAO,EAAE;AACX;AAEA,SAASwG,oBAAoBjD,MAAM;IACjC,MAAMtD,MAAMC,QAAQD,GAAG;IACvB,MAAMsG,mBAAmB7B,aAAI,CAACwD,QAAQ,CAACrH,IAAAA,gCAAgB,EAACZ,QAAQ,IAAIsD,OAAOtD,GAAG,EAAEkI,OAAO,CAAC,OAAO;IAC/F,OAAO5B;AACT;AAEA,SAASmB,WAAWd,IAAY,EAAEwB,SAAmB;IACnD,MAAMC,YAAYD,aAAajC,aAAaiC,UAAUpB,MAAM,GAAG,IAAI;QAAC;WAASoB;KAAU,GAAG,EAAE;IAC5F,OAAO;QAAC;QAAOxB;WAASyB;KAAU;AACpC"}
@@ -1,3 +1,3 @@
1
1
  import type { Logger } from "@lage-run/logger";
2
2
  import type { ReporterInitOptions } from "../types/ReporterInitOptions.js";
3
- export declare function initializeReporters(logger: Logger, options: ReporterInitOptions): import("@lage-run/logger").Reporter<import("@lage-run/logger").LogStructuredData>[];
3
+ export declare function initializeReporters(logger: Logger, options: ReporterInitOptions, customReporters?: Record<string, string>): Promise<import("@lage-run/logger").Reporter<import("@lage-run/logger").LogStructuredData>[]>;
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "initializeReporters", {
9
9
  }
10
10
  });
11
11
  const _createReporter = require("./createReporter.js");
12
- function initializeReporters(logger, options) {
12
+ async function initializeReporters(logger, options, customReporters = {}) {
13
13
  const { reporter } = options;
14
14
  // filter out falsy values (e.g. undefined) from the reporter array
15
15
  const reporterOptions = (Array.isArray(reporter) ? reporter : [
@@ -24,7 +24,7 @@ function initializeReporters(logger, options) {
24
24
  reporterOptions.push("profile");
25
25
  }
26
26
  for (const reporterName of reporterOptions){
27
- const reporterInstance = (0, _createReporter.createReporter)(reporterName, options);
27
+ const reporterInstance = await (0, _createReporter.createReporter)(reporterName, options, customReporters);
28
28
  logger.addReporter(reporterInstance);
29
29
  }
30
30
  return logger.reporters;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/initializeReporters.ts"],"sourcesContent":["import { createReporter } from \"./createReporter.js\";\nimport type { Logger } from \"@lage-run/logger\";\nimport type { ReporterInitOptions } from \"../types/ReporterInitOptions.js\";\n\nexport function initializeReporters(logger: Logger, options: ReporterInitOptions) {\n const { reporter } = options;\n\n // filter out falsy values (e.g. undefined) from the reporter array\n const reporterOptions = (Array.isArray(reporter) ? reporter : [reporter]).filter(Boolean);\n\n if (reporterOptions.length === 0) {\n // \"default\" is just a dummy name to trigger the default case in createReporter\n reporterOptions.push(\"default\");\n }\n\n // add profile reporter if --profile is passed\n if (options.profile) {\n reporterOptions.push(\"profile\");\n }\n\n for (const reporterName of reporterOptions) {\n const reporterInstance = createReporter(reporterName, options);\n logger.addReporter(reporterInstance);\n }\n\n return logger.reporters;\n}\n"],"names":["initializeReporters","logger","options","reporter","reporterOptions","Array","isArray","filter","Boolean","length","push","profile","reporterName","reporterInstance","createReporter","addReporter","reporters"],"mappings":";;;;+BAIgBA;;;eAAAA;;;gCAJe;AAIxB,SAASA,oBAAoBC,MAAc,EAAEC,OAA4B;IAC9E,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IAErB,mEAAmE;IACnE,MAAME,kBAAkB,AAACC,CAAAA,MAAMC,OAAO,CAACH,YAAYA,WAAW;QAACA;KAAS,AAAD,EAAGI,MAAM,CAACC;IAEjF,IAAIJ,gBAAgBK,MAAM,KAAK,GAAG;QAChC,+EAA+E;QAC/EL,gBAAgBM,IAAI,CAAC;IACvB;IAEA,8CAA8C;IAC9C,IAAIR,QAAQS,OAAO,EAAE;QACnBP,gBAAgBM,IAAI,CAAC;IACvB;IAEA,KAAK,MAAME,gBAAgBR,gBAAiB;QAC1C,MAAMS,mBAAmBC,IAAAA,8BAAc,EAACF,cAAcV;QACtDD,OAAOc,WAAW,CAACF;IACrB;IAEA,OAAOZ,OAAOe,SAAS;AACzB"}
1
+ {"version":3,"sources":["../../src/commands/initializeReporters.ts"],"sourcesContent":["import { createReporter } from \"./createReporter.js\";\nimport type { Logger } from \"@lage-run/logger\";\nimport type { ReporterInitOptions } from \"../types/ReporterInitOptions.js\";\n\nexport async function initializeReporters(logger: Logger, options: ReporterInitOptions, customReporters: Record<string, string> = {}) {\n const { reporter } = options;\n\n // filter out falsy values (e.g. undefined) from the reporter array\n const reporterOptions = (Array.isArray(reporter) ? reporter : [reporter]).filter(Boolean);\n\n if (reporterOptions.length === 0) {\n // \"default\" is just a dummy name to trigger the default case in createReporter\n reporterOptions.push(\"default\");\n }\n\n // add profile reporter if --profile is passed\n if (options.profile) {\n reporterOptions.push(\"profile\");\n }\n\n for (const reporterName of reporterOptions) {\n const reporterInstance = await createReporter(reporterName, options, customReporters);\n logger.addReporter(reporterInstance);\n }\n\n return logger.reporters;\n}\n"],"names":["initializeReporters","logger","options","customReporters","reporter","reporterOptions","Array","isArray","filter","Boolean","length","push","profile","reporterName","reporterInstance","createReporter","addReporter","reporters"],"mappings":";;;;+BAIsBA;;;eAAAA;;;gCAJS;AAIxB,eAAeA,oBAAoBC,MAAc,EAAEC,OAA4B,EAAEC,kBAA0C,CAAC,CAAC;IAClI,MAAM,EAAEC,QAAQ,EAAE,GAAGF;IAErB,mEAAmE;IACnE,MAAMG,kBAAkB,AAACC,CAAAA,MAAMC,OAAO,CAACH,YAAYA,WAAW;QAACA;KAAS,AAAD,EAAGI,MAAM,CAACC;IAEjF,IAAIJ,gBAAgBK,MAAM,KAAK,GAAG;QAChC,+EAA+E;QAC/EL,gBAAgBM,IAAI,CAAC;IACvB;IAEA,8CAA8C;IAC9C,IAAIT,QAAQU,OAAO,EAAE;QACnBP,gBAAgBM,IAAI,CAAC;IACvB;IAEA,KAAK,MAAME,gBAAgBR,gBAAiB;QAC1C,MAAMS,mBAAmB,MAAMC,IAAAA,8BAAc,EAACF,cAAcX,SAASC;QACrEF,OAAOe,WAAW,CAACF;IACrB;IAEA,OAAOb,OAAOgB,SAAS;AACzB"}
@@ -33,10 +33,10 @@ async function runAction(options, command) {
33
33
  const allowNoTargetRuns = options.allowNoTargetRuns || config.allowNoTargetRuns;
34
34
  // Configure logger
35
35
  const logger = (0, _logger.default)();
36
- const reporters = (0, _initializeReporters.initializeReporters)(logger, {
36
+ const reporters = await (0, _initializeReporters.initializeReporters)(logger, {
37
37
  ...options,
38
38
  concurrency
39
- });
39
+ }, config.reporters);
40
40
  // Build Target Graph
41
41
  const root = (0, _workspacetools.getWorkspaceRoot)(process.cwd());
42
42
  const packageInfos = (0, _workspacetools.getPackageInfos)(root);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/run/runAction.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { createTargetGraph } from \"./createTargetGraph.js\";\nimport { filterArgsForTasks } from \"./filterArgsForTasks.js\";\nimport { filterPipelineDefinitions } from \"./filterPipelineDefinitions.js\";\nimport { getConfig, getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions, getConcurrency } from \"@lage-run/config\";\nimport { getPackageInfos, getWorkspaceRoot } from \"workspace-tools\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { SimpleScheduler } from \"@lage-run/scheduler\";\n\nimport type { Reporter } from \"@lage-run/logger\";\nimport createLogger from \"@lage-run/logger\";\n\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport type { FilterOptions } from \"../../types/FilterOptions.js\";\nimport type { SchedulerRunSummary } from \"@lage-run/scheduler-types\";\nimport type { TargetGraph } from \"@lage-run/target-graph\";\nimport { NoTargetFoundError } from \"../../types/errors.js\";\nimport { createCache } from \"../../cache/createCacheProvider.js\";\nimport { runnerPickerOptions } from \"../../runnerPickerOptions.js\";\nimport { optimizeTargetGraph } from \"../../optimizeTargetGraph.js\";\n\ninterface RunOptions extends ReporterInitOptions, FilterOptions {\n concurrency: number;\n maxWorkersPerTask: string[];\n profile: string | boolean | undefined;\n skipLocalCache: boolean;\n continue: boolean;\n cache: boolean;\n resetCache: boolean;\n nodeArg: string;\n allowNoTargetRuns: boolean;\n}\n\nexport async function runAction(options: RunOptions, command: Command) {\n const cwd = process.cwd();\n const config = await getConfig(cwd);\n\n // Merged options\n const concurrency = getConcurrency(options.concurrency, config.concurrency);\n const allowNoTargetRuns = options.allowNoTargetRuns || config.allowNoTargetRuns;\n\n // Configure logger\n const logger = createLogger();\n\n const reporters = initializeReporters(logger, { ...options, concurrency });\n\n // Build Target Graph\n const root = getWorkspaceRoot(process.cwd())!;\n const packageInfos = getPackageInfos(root);\n\n const { tasks, taskArgs } = filterArgsForTasks(command.args);\n\n const targetGraph = await createTargetGraph({\n logger,\n root,\n dependencies: options.dependencies,\n dependents: options.dependents && !options.to, // --to is a short hand for --scope + --no-dependents\n ignore: options.ignore.concat(config.ignore),\n pipeline: config.pipeline,\n repoWideChanges: config.repoWideChanges,\n scope: (options.scope ?? []).concat(options.to ?? []), // --to is a short hand for --scope + --no-dependents\n since: options.since,\n outputs: config.cacheOptions.outputGlob,\n tasks,\n packageInfos,\n priorities: config.priorities,\n enableTargetConfigMerging: config.enableTargetConfigMerging,\n });\n\n validateTargetGraph(targetGraph, allowNoTargetRuns);\n\n logger.verbose(`Running with ${concurrency} workers`);\n\n const filteredPipeline = filterPipelineDefinitions(targetGraph.targets.values(), config.pipeline);\n\n const maxWorkersPerTaskMap = getMaxWorkersPerTaskFromOptions(options.maxWorkersPerTask);\n\n const { hasher } = await createCache({\n root,\n logger,\n cacheOptions: config.cacheOptions,\n cliArgs: taskArgs,\n skipLocalCache: options.skipLocalCache,\n });\n\n const scheduler = new SimpleScheduler({\n logger,\n concurrency,\n continueOnError: options.continue,\n shouldCache: options.cache,\n shouldResetCache: options.resetCache,\n workerData: {\n root,\n taskArgs,\n skipLocalCache: options.skipLocalCache,\n cacheOptions: config.cacheOptions,\n runners: {\n ...runnerPickerOptions(options.nodeArg, config.npmClient, taskArgs),\n ...config.runners,\n },\n },\n maxWorkersPerTask: new Map([...getMaxWorkersPerTask(filteredPipeline, concurrency), ...maxWorkersPerTaskMap]),\n hasher,\n workerIdleMemoryLimit: config.workerIdleMemoryLimit, // in bytes\n });\n\n const optimizedTargets = await optimizeTargetGraph(targetGraph, scheduler.runnerPicker, false);\n const optimizedGraph: TargetGraph = {\n targets: new Map(optimizedTargets.map((target) => [target.id, target])),\n };\n\n const summary = await scheduler.run(root, optimizedGraph);\n await scheduler.cleanup();\n\n displaySummaryAndExit(summary, logger.reporters);\n\n for (const reporter of reporters) {\n await reporter.cleanup?.();\n }\n}\n\nfunction displaySummaryAndExit(summary: SchedulerRunSummary, reporters: Reporter[]) {\n if (summary.results !== \"success\") {\n process.exitCode = 1;\n }\n\n for (const reporter of reporters) {\n reporter.summarize(summary);\n }\n}\n\nfunction validateTargetGraph(targetGraph: TargetGraph, allowNoTargetRuns: boolean) {\n const visibleTargets = Array.from(targetGraph.targets.values()).filter((target) => !target.hidden);\n if (visibleTargets.length === 0 && !allowNoTargetRuns) {\n throw NoTargetFoundError;\n }\n}\n"],"names":["runAction","options","command","cwd","process","config","getConfig","concurrency","getConcurrency","allowNoTargetRuns","logger","createLogger","reporters","initializeReporters","root","getWorkspaceRoot","packageInfos","getPackageInfos","tasks","taskArgs","filterArgsForTasks","args","targetGraph","createTargetGraph","dependencies","dependents","to","ignore","concat","pipeline","repoWideChanges","scope","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","validateTargetGraph","verbose","filteredPipeline","filterPipelineDefinitions","targets","values","maxWorkersPerTaskMap","getMaxWorkersPerTaskFromOptions","maxWorkersPerTask","hasher","createCache","cliArgs","skipLocalCache","scheduler","SimpleScheduler","continueOnError","continue","shouldCache","cache","shouldResetCache","resetCache","workerData","runners","runnerPickerOptions","nodeArg","npmClient","Map","getMaxWorkersPerTask","workerIdleMemoryLimit","optimizedTargets","optimizeTargetGraph","runnerPicker","optimizedGraph","map","target","id","summary","run","cleanup","displaySummaryAndExit","reporter","results","exitCode","summarize","visibleTargets","Array","from","filter","hidden","length","NoTargetFoundError"],"mappings":";;;;+BAiCsBA;;;eAAAA;;;mCAhCY;oCACC;2CACO;wBACuD;gCAC/C;qCACd;2BACJ;+DAGP;wBAMU;qCACP;qCACQ;qCACA;;;;;;AAc7B,eAAeA,UAAUC,OAAmB,EAAEC,OAAgB;IACnE,MAAMC,MAAMC,QAAQD,GAAG;IACvB,MAAME,SAAS,MAAMC,IAAAA,iBAAS,EAACH;IAE/B,iBAAiB;IACjB,MAAMI,cAAcC,IAAAA,sBAAc,EAACP,QAAQM,WAAW,EAAEF,OAAOE,WAAW;IAC1E,MAAME,oBAAoBR,QAAQQ,iBAAiB,IAAIJ,OAAOI,iBAAiB;IAE/E,mBAAmB;IACnB,MAAMC,SAASC,IAAAA,eAAY;IAE3B,MAAMC,YAAYC,IAAAA,wCAAmB,EAACH,QAAQ;QAAE,GAAGT,OAAO;QAAEM;IAAY;IAExE,qBAAqB;IACrB,MAAMO,OAAOC,IAAAA,gCAAgB,EAACX,QAAQD,GAAG;IACzC,MAAMa,eAAeC,IAAAA,+BAAe,EAACH;IAErC,MAAM,EAAEI,KAAK,EAAEC,QAAQ,EAAE,GAAGC,IAAAA,sCAAkB,EAAClB,QAAQmB,IAAI;IAE3D,MAAMC,cAAc,MAAMC,IAAAA,oCAAiB,EAAC;QAC1Cb;QACAI;QACAU,cAAcvB,QAAQuB,YAAY;QAClCC,YAAYx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OuD,OAAO;YACnB;QACF;QACAd,mBAAmB,IAAIkB,IAAI;eAAIC,IAAAA,4BAAoB,EAACzB,kBAAkBjC;eAAiBqC;SAAqB;QAC5GG;QACAmB,uBAAuB7D,OAAO6D,qBAAqB;IACrD;IAEA,MAAMC,mBAAmB,MAAMC,IAAAA,wCAAmB,EAAC9C,aAAa6B,UAAUkB,YAAY,EAAE;IACxF,MAAMC,iBAA8B;QAClC5B,SAAS,IAAIsB,IAAIG,iBAAiBI,GAAG,CAAC,CAACC,SAAW;gBAACA,OAAOC,EAAE;gBAAED;aAAO;IACvE;IAEA,MAAME,UAAU,MAAMvB,UAAUwB,GAAG,CAAC7D,MAAMwD;IAC1C,MAAMnB,UAAUyB,OAAO;IAEvBC,sBAAsBH,SAAShE,OAAOE,SAAS;IAE/C,KAAK,MAAMkE,YAAYlE,UAAW;QAChC,MAAMkE,SAASF,OAAO;IACxB;AACF;AAEA,SAASC,sBAAsBH,OAA4B,EAAE9D,SAAqB;IAChF,IAAI8D,QAAQK,OAAO,KAAK,WAAW;QACjC3E,QAAQ4E,QAAQ,GAAG;IACrB;IAEA,KAAK,MAAMF,YAAYlE,UAAW;QAChCkE,SAASG,SAAS,CAACP;IACrB;AACF;AAEA,SAASpC,oBAAoBhB,WAAwB,EAAEb,iBAA0B;IAC/E,MAAMyE,iBAAiBC,MAAMC,IAAI,CAAC9D,YAAYoB,OAAO,CAACC,MAAM,IAAI0C,MAAM,CAAC,CAACb,SAAW,CAACA,OAAOc,MAAM;IACjG,IAAIJ,eAAeK,MAAM,KAAK,KAAK,CAAC9E,mBAAmB;QACrD,MAAM+E,0BAAkB;IAC1B;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/run/runAction.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { createTargetGraph } from \"./createTargetGraph.js\";\nimport { filterArgsForTasks } from \"./filterArgsForTasks.js\";\nimport { filterPipelineDefinitions } from \"./filterPipelineDefinitions.js\";\nimport { getConfig, getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions, getConcurrency } from \"@lage-run/config\";\nimport { getPackageInfos, getWorkspaceRoot } from \"workspace-tools\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { SimpleScheduler } from \"@lage-run/scheduler\";\n\nimport type { Reporter } from \"@lage-run/logger\";\nimport createLogger from \"@lage-run/logger\";\n\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport type { FilterOptions } from \"../../types/FilterOptions.js\";\nimport type { SchedulerRunSummary } from \"@lage-run/scheduler-types\";\nimport type { TargetGraph } from \"@lage-run/target-graph\";\nimport { NoTargetFoundError } from \"../../types/errors.js\";\nimport { createCache } from \"../../cache/createCacheProvider.js\";\nimport { runnerPickerOptions } from \"../../runnerPickerOptions.js\";\nimport { optimizeTargetGraph } from \"../../optimizeTargetGraph.js\";\n\ninterface RunOptions extends ReporterInitOptions, FilterOptions {\n concurrency: number;\n maxWorkersPerTask: string[];\n profile: string | boolean | undefined;\n skipLocalCache: boolean;\n continue: boolean;\n cache: boolean;\n resetCache: boolean;\n nodeArg: string;\n allowNoTargetRuns: boolean;\n}\n\nexport async function runAction(options: RunOptions, command: Command) {\n const cwd = process.cwd();\n const config = await getConfig(cwd);\n\n // Merged options\n const concurrency = getConcurrency(options.concurrency, config.concurrency);\n const allowNoTargetRuns = options.allowNoTargetRuns || config.allowNoTargetRuns;\n\n // Configure logger\n const logger = createLogger();\n\n const reporters = await initializeReporters(logger, { ...options, concurrency }, config.reporters);\n\n // Build Target Graph\n const root = getWorkspaceRoot(process.cwd())!;\n const packageInfos = getPackageInfos(root);\n\n const { tasks, taskArgs } = filterArgsForTasks(command.args);\n\n const targetGraph = await createTargetGraph({\n logger,\n root,\n dependencies: options.dependencies,\n dependents: options.dependents && !options.to, // --to is a short hand for --scope + --no-dependents\n ignore: options.ignore.concat(config.ignore),\n pipeline: config.pipeline,\n repoWideChanges: config.repoWideChanges,\n scope: (options.scope ?? []).concat(options.to ?? []), // --to is a short hand for --scope + --no-dependents\n since: options.since,\n outputs: config.cacheOptions.outputGlob,\n tasks,\n packageInfos,\n priorities: config.priorities,\n enableTargetConfigMerging: config.enableTargetConfigMerging,\n });\n\n validateTargetGraph(targetGraph, allowNoTargetRuns);\n\n logger.verbose(`Running with ${concurrency} workers`);\n\n const filteredPipeline = filterPipelineDefinitions(targetGraph.targets.values(), config.pipeline);\n\n const maxWorkersPerTaskMap = getMaxWorkersPerTaskFromOptions(options.maxWorkersPerTask);\n\n const { hasher } = await createCache({\n root,\n logger,\n cacheOptions: config.cacheOptions,\n cliArgs: taskArgs,\n skipLocalCache: options.skipLocalCache,\n });\n\n const scheduler = new SimpleScheduler({\n logger,\n concurrency,\n continueOnError: options.continue,\n shouldCache: options.cache,\n shouldResetCache: options.resetCache,\n workerData: {\n root,\n taskArgs,\n skipLocalCache: options.skipLocalCache,\n cacheOptions: config.cacheOptions,\n runners: {\n ...runnerPickerOptions(options.nodeArg, config.npmClient, taskArgs),\n ...config.runners,\n },\n },\n maxWorkersPerTask: new Map([...getMaxWorkersPerTask(filteredPipeline, concurrency), ...maxWorkersPerTaskMap]),\n hasher,\n workerIdleMemoryLimit: config.workerIdleMemoryLimit, // in bytes\n });\n\n const optimizedTargets = await optimizeTargetGraph(targetGraph, scheduler.runnerPicker, false);\n const optimizedGraph: TargetGraph = {\n targets: new Map(optimizedTargets.map((target) => [target.id, target])),\n };\n\n const summary = await scheduler.run(root, optimizedGraph);\n await scheduler.cleanup();\n\n displaySummaryAndExit(summary, logger.reporters);\n\n for (const reporter of reporters) {\n await reporter.cleanup?.();\n }\n}\n\nfunction displaySummaryAndExit(summary: SchedulerRunSummary, reporters: Reporter[]) {\n if (summary.results !== \"success\") {\n process.exitCode = 1;\n }\n\n for (const reporter of reporters) {\n reporter.summarize(summary);\n }\n}\n\nfunction validateTargetGraph(targetGraph: TargetGraph, allowNoTargetRuns: boolean) {\n const visibleTargets = Array.from(targetGraph.targets.values()).filter((target) => !target.hidden);\n if (visibleTargets.length === 0 && !allowNoTargetRuns) {\n throw NoTargetFoundError;\n }\n}\n"],"names":["runAction","options","command","cwd","process","config","getConfig","concurrency","getConcurrency","allowNoTargetRuns","logger","createLogger","reporters","initializeReporters","root","getWorkspaceRoot","packageInfos","getPackageInfos","tasks","taskArgs","filterArgsForTasks","args","targetGraph","createTargetGraph","dependencies","dependents","to","ignore","concat","pipeline","repoWideChanges","scope","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","validateTargetGraph","verbose","filteredPipeline","filterPipelineDefinitions","targets","values","maxWorkersPerTaskMap","getMaxWorkersPerTaskFromOptions","maxWorkersPerTask","hasher","createCache","cliArgs","skipLocalCache","scheduler","SimpleScheduler","continueOnError","continue","shouldCache","cache","shouldResetCache","resetCache","workerData","runners","runnerPickerOptions","nodeArg","npmClient","Map","getMaxWorkersPerTask","workerIdleMemoryLimit","optimizedTargets","optimizeTargetGraph","runnerPicker","optimizedGraph","map","target","id","summary","run","cleanup","displaySummaryAndExit","reporter","results","exitCode","summarize","visibleTargets","Array","from","filter","hidden","length","NoTargetFoundError"],"mappings":";;;;+BAiCsBA;;;eAAAA;;;mCAhCY;oCACC;2CACO;wBACuD;gCAC/C;qCACd;2BACJ;+DAGP;wBAMU;qCACP;qCACQ;qCACA;;;;;;AAc7B,eAAeA,UAAUC,OAAmB,EAAEC,OAAgB;IACnE,MAAMC,MAAMC,QAAQD,GAAG;IACvB,MAAME,SAAS,MAAMC,IAAAA,iBAAS,EAACH;IAE/B,iBAAiB;IACjB,MAAMI,cAAcC,IAAAA,sBAAc,EAACP,QAAQM,WAAW,EAAEF,OAAOE,WAAW;IAC1E,MAAME,oBAAoBR,QAAQQ,iBAAiB,IAAIJ,OAAOI,iBAAiB;IAE/E,mBAAmB;IACnB,MAAMC,SAASC,IAAAA,eAAY;IAE3B,MAAMC,YAAY,MAAMC,IAAAA,wCAAmB,EAACH,QAAQ;QAAE,GAAGT,OAAO;QAAEM;IAAY,GAAGF,OAAOO,SAAS;IAEjG,qBAAqB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IJ,eAAeK,MAAM,KAAK,KAAK,CAAC9E,mBAAmB;QACrD,MAAM+E,0BAAkB;IAC1B;AACF"}
@@ -13,6 +13,7 @@ const _initializeReporters = require("../initializeReporters.js");
13
13
  const _lageService = require("./lageService.js");
14
14
  const _rpc = require("@lage-run/rpc");
15
15
  const _parseServerOption = require("../parseServerOption.js");
16
+ const _config = require("@lage-run/config");
16
17
  function _interop_require_default(obj) {
17
18
  return obj && obj.__esModule ? obj : {
18
19
  default: obj
@@ -21,11 +22,13 @@ function _interop_require_default(obj) {
21
22
  async function serverAction(options) {
22
23
  const { server = "localhost:5332", timeout = 1, tasks } = options;
23
24
  const { host, port } = (0, _parseServerOption.parseServerOption)(server);
25
+ const cwd = process.cwd();
26
+ const config = await (0, _config.getConfig)(cwd);
24
27
  const logger = (0, _logger.default)();
25
28
  options.logLevel = options.logLevel ?? "info";
26
29
  options.logFile = options.logFile ?? "node_modules/.cache/lage/server.log";
27
30
  options.reporter = options.reporter ?? "verboseFileLog";
28
- (0, _initializeReporters.initializeReporters)(logger, options);
31
+ await (0, _initializeReporters.initializeReporters)(logger, options, config.reporters);
29
32
  logger.info(`Starting server on http://${host}:${port}`);
30
33
  const abortController = new AbortController();
31
34
  const lageService = await (0, _lageService.createLageService)({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/server/action.ts"],"sourcesContent":["import createLogger, { type Logger } from \"@lage-run/logger\";\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { createLageService } from \"./lageService.js\";\nimport { createServer } from \"@lage-run/rpc\";\nimport { parseServerOption } from \"../parseServerOption.js\";\n\ninterface WorkerOptions extends ReporterInitOptions {\n nodeArg?: string[];\n server?: string;\n timeout?: number;\n shutdown: boolean;\n tasks: string[];\n}\n\nexport async function serverAction(options: WorkerOptions) {\n const { server = \"localhost:5332\", timeout = 1, tasks } = options;\n\n const { host, port } = parseServerOption(server);\n\n const logger = createLogger();\n options.logLevel = options.logLevel ?? \"info\";\n options.logFile = options.logFile ?? \"node_modules/.cache/lage/server.log\";\n options.reporter = options.reporter ?? \"verboseFileLog\";\n initializeReporters(logger, options);\n\n logger.info(`Starting server on http://${host}:${port}`);\n\n const abortController = new AbortController();\n\n const lageService = await createLageService({\n cwd: process.cwd(),\n serverControls: {\n abortController,\n countdownToShutdown: () => resetTimer(logger, timeout, abortController, lageServer),\n clearCountdown: clearTimer,\n },\n logger,\n concurrency: options.concurrency,\n tasks,\n });\n const lageServer = await createServer(lageService, abortController);\n\n await lageServer.listen({ host, port });\n logger.info(`Server listening on http://${host}:${port}, timeout in ${timeout} seconds`);\n}\n\nlet timeoutHandle: NodeJS.Timeout | undefined;\nfunction resetTimer(logger: Logger, timeout: number, abortController: AbortController, server: any) {\n clearTimer();\n\n timeoutHandle = globalThis.setTimeout(() => {\n logger.info(`Server timed out after ${timeout} seconds`);\n abortController.abort();\n server.close();\n }, timeout * 1000);\n}\n\nfunction clearTimer() {\n if (timeoutHandle) {\n globalThis.clearTimeout(timeoutHandle);\n }\n}\n"],"names":["serverAction","options","server","timeout","tasks","host","port","parseServerOption","logger","createLogger","logLevel","logFile","reporter","initializeReporters","info","abortController","AbortController","lageService","createLageService","cwd","process","serverControls","countdownToShutdown","resetTimer","lageServer","clearCountdown","clearTimer","concurrency","createServer","listen","timeoutHandle","globalThis","setTimeout","abort","close","clearTimeout"],"mappings":";;;;+BAesBA;;;eAAAA;;;+DAfoB;qCAEN;6BACF;qBACL;mCACK;;;;;;AAU3B,eAAeA,aAAaC,OAAsB;IACvD,MAAM,EAAEC,SAAS,gBAAgB,EAAEC,UAAU,CAAC,EAAEC,KAAK,EAAE,GAAGH;IAE1D,MAAM,EAAEI,IAAI,EAAEC,IAAI,EAAE,GAAGC,IAAAA,oCAAiB,EAACL;IAEzC,MAAMM,SAASC,IAAAA,eAAY;IAC3BR,QAAQS,QAAQ,GAAGT,QAAQS,QAAQ,IAAI;IACvCT,QAAQU,OAAO,GAAGV,QAAQU,OAAO,IAAI;IACrCV,QAAQW,QAAQ,GAAGX,QAAQW,QAAQ,IAAI;IACvCC,IAAAA,wCAAmB,EAACL,QAAQP;IAE5BO,OAAOM,IAAI,CAAC,CAAC,0BAA0B,EAAET,KAAK,CAAC,EAAEC,MAAM;IAEvD,MAAMS,kBAAkB,IAAIC;IAE5B,MAAMC,cAAc,MAAMC,IAAAA,8BAAiB,EAAC;QAC1CC,KAAKC,QAAQD,GAAG;QAChBE,gBAAgB;YACdN;YACAO,qBAAqB,IAAMC,WAAWf,QAAQL,SAASY,iBAAiBS;YACxEC,gBAAgBC;QAClB;QACAlB;QACAmB,aAAa1B,QAAQ0B,WAAW;QAChCvB;IACF;IACA,MAAMoB,aAAa,MAAMI,IAAAA,iBAAY,EAACX,aAAaF;IAEnD,MAAMS,WAAWK,MAAM,CAAC;QAAExB;QAAMC;IAAK;IACrCE,OAAOM,IAAI,CAAC,CAAC,2BAA2B,EAAET,KAAK,CAAC,EAAEC,KAAK,aAAa,EAAEH,QAAQ,QAAQ,CAAC;AACzF;AAEA,IAAI2B;AACJ,SAASP,WAAWf,MAAc,EAAEL,OAAe,EAAEY,eAAgC,EAAEb,MAAW;IAChGwB;IAEAI,gBAAgBC,WAAWC,UAAU,CAAC;QACpCxB,OAAOM,IAAI,CAAC,CAAC,uBAAuB,EAAEX,QAAQ,QAAQ,CAAC;QACvDY,gBAAgBkB,KAAK;QACrB/B,OAAOgC,KAAK;IACd,GAAG/B,UAAU;AACf;AAEA,SAASuB;IACP,IAAII,eAAe;QACjBC,WAAWI,YAAY,CAACL;IAC1B;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/server/action.ts"],"sourcesContent":["import createLogger, { type Logger } from \"@lage-run/logger\";\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { createLageService } from \"./lageService.js\";\nimport { createServer } from \"@lage-run/rpc\";\nimport { parseServerOption } from \"../parseServerOption.js\";\nimport { getConfig } from \"@lage-run/config\";\n\ninterface WorkerOptions extends ReporterInitOptions {\n nodeArg?: string[];\n server?: string;\n timeout?: number;\n shutdown: boolean;\n tasks: string[];\n}\n\nexport async function serverAction(options: WorkerOptions) {\n const { server = \"localhost:5332\", timeout = 1, tasks } = options;\n\n const { host, port } = parseServerOption(server);\n const cwd = process.cwd();\n const config = await getConfig(cwd);\n\n const logger = createLogger();\n options.logLevel = options.logLevel ?? \"info\";\n options.logFile = options.logFile ?? \"node_modules/.cache/lage/server.log\";\n options.reporter = options.reporter ?? \"verboseFileLog\";\n await initializeReporters(logger, options, config.reporters);\n\n logger.info(`Starting server on http://${host}:${port}`);\n\n const abortController = new AbortController();\n\n const lageService = await createLageService({\n cwd: process.cwd(),\n serverControls: {\n abortController,\n countdownToShutdown: () => resetTimer(logger, timeout, abortController, lageServer),\n clearCountdown: clearTimer,\n },\n logger,\n concurrency: options.concurrency,\n tasks,\n });\n const lageServer = await createServer(lageService, abortController);\n\n await lageServer.listen({ host, port });\n logger.info(`Server listening on http://${host}:${port}, timeout in ${timeout} seconds`);\n}\n\nlet timeoutHandle: NodeJS.Timeout | undefined;\nfunction resetTimer(logger: Logger, timeout: number, abortController: AbortController, server: any) {\n clearTimer();\n\n timeoutHandle = globalThis.setTimeout(() => {\n logger.info(`Server timed out after ${timeout} seconds`);\n abortController.abort();\n server.close();\n }, timeout * 1000);\n}\n\nfunction clearTimer() {\n if (timeoutHandle) {\n globalThis.clearTimeout(timeoutHandle);\n }\n}\n"],"names":["serverAction","options","server","timeout","tasks","host","port","parseServerOption","cwd","process","config","getConfig","logger","createLogger","logLevel","logFile","reporter","initializeReporters","reporters","info","abortController","AbortController","lageService","createLageService","serverControls","countdownToShutdown","resetTimer","lageServer","clearCountdown","clearTimer","concurrency","createServer","listen","timeoutHandle","globalThis","setTimeout","abort","close","clearTimeout"],"mappings":";;;;+BAgBsBA;;;eAAAA;;;+DAhBoB;qCAEN;6BACF;qBACL;mCACK;wBACR;;;;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B,EAAEhB,QAAQ,QAAQ,CAAC;QACvDiB,gBAAgBgB,KAAK;QACrBlC,OAAOmC,KAAK;IACd,GAAGlC,UAAU;AACf;AAEA,SAAS0B;IACP,IAAII,eAAe;QACjBC,WAAWI,YAAY,CAACL;IAC1B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/cli",
3
- "version": "0.32.3",
3
+ "version": "0.33.0",
4
4
  "description": "Command Line Interface for Lage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "lint": "monorepo-scripts lint"
22
22
  },
23
23
  "dependencies": {
24
- "@lage-run/cache": "^1.4.1",
25
- "@lage-run/config": "^0.6.0",
24
+ "@lage-run/cache": "^1.4.2",
25
+ "@lage-run/config": "^0.7.0",
26
26
  "@lage-run/format-hrtime": "^0.1.6",
27
27
  "@lage-run/globby": "^14.2.1",
28
28
  "@lage-run/hasher": "^1.9.0",
@@ -30,7 +30,7 @@
30
30
  "@lage-run/reporters": "^1.3.5",
31
31
  "@lage-run/rpc": "^1.4.0",
32
32
  "@lage-run/runners": "^1.2.4",
33
- "@lage-run/scheduler": "^1.5.13",
33
+ "@lage-run/scheduler": "^1.5.14",
34
34
  "@lage-run/scheduler-types": "^0.3.26",
35
35
  "@lage-run/target-graph": "^0.12.0",
36
36
  "@lage-run/worker-threads-pool": "^0.9.0",