@lage-run/cli 0.33.4 → 0.34.1
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/lib/commands/createReporter.d.ts +23 -1
- package/lib/commands/createReporter.js +51 -27
- package/lib/commands/createReporter.js.map +1 -1
- package/lib/commands/exec/action.js +6 -1
- package/lib/commands/exec/action.js.map +1 -1
- package/lib/commands/exec/executeRemotely.js +5 -2
- package/lib/commands/exec/executeRemotely.js.map +1 -1
- package/lib/commands/info/action.d.ts +7 -1
- package/lib/commands/info/action.js +15 -10
- package/lib/commands/info/action.js.map +1 -1
- package/lib/commands/init/action.js +4 -2
- package/lib/commands/init/action.js.map +1 -1
- package/lib/commands/initializeReporters.d.ts +2 -1
- package/lib/commands/initializeReporters.js +3 -3
- package/lib/commands/initializeReporters.js.map +1 -1
- package/lib/commands/run/createTargetGraph.d.ts +3 -2
- package/lib/commands/run/createTargetGraph.js +27 -9
- package/lib/commands/run/createTargetGraph.js.map +1 -1
- package/lib/commands/run/runAction.js +7 -3
- package/lib/commands/run/runAction.js.map +1 -1
- package/lib/commands/run/watchAction.js +4 -3
- package/lib/commands/run/watchAction.js.map +1 -1
- package/lib/commands/server/action.js +7 -2
- package/lib/commands/server/action.js.map +1 -1
- package/lib/commands/server/lageService.js +2 -1
- package/lib/commands/server/lageService.js.map +1 -1
- package/lib/filter/getFilteredPackages.js +11 -2
- package/lib/filter/getFilteredPackages.js.map +1 -1
- package/lib/filter/hasRepoChanged.d.ts +13 -1
- package/lib/filter/hasRepoChanged.js +14 -12
- package/lib/filter/hasRepoChanged.js.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/internal.d.ts +1 -0
- package/lib/internal.js +4 -0
- package/lib/internal.js.map +1 -0
- package/lib/optimizeTargetGraph.js +1 -1
- package/lib/optimizeTargetGraph.js.map +1 -1
- package/lib/types/ReporterInitOptions.d.ts +4 -0
- package/lib/types/ReporterInitOptions.js.map +1 -1
- package/package.json +10 -10
- package/lib/cache/isRunningFromCI.d.ts +0 -1
- package/lib/cache/isRunningFromCI.js +0 -11
- package/lib/cache/isRunningFromCI.js.map +0 -1
- package/lib/commands/isRunningFromCI.d.ts +0 -1
- package/lib/commands/isRunningFromCI.js +0 -11
- package/lib/commands/isRunningFromCI.js.map +0 -1
|
@@ -1,3 +1,25 @@
|
|
|
1
1
|
import type { ReporterInitOptions } from "../types/ReporterInitOptions.js";
|
|
2
2
|
import type { Reporter } from "@lage-run/logger";
|
|
3
|
-
export
|
|
3
|
+
export interface CustomReportersOptions {
|
|
4
|
+
customReporters: Record<string, string> | undefined;
|
|
5
|
+
/** Monorepo root for resolving custom reporters*/
|
|
6
|
+
root: string;
|
|
7
|
+
}
|
|
8
|
+
type MockImportReporter = (params: {
|
|
9
|
+
reporterName: string;
|
|
10
|
+
resolvedPath: string;
|
|
11
|
+
}) => unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Mock the reporter importing for tests. We don't currently support ESM in Jest, and it's too much
|
|
14
|
+
* of a headache to set it up for one package, so instead we mock for most cases and handle a few
|
|
15
|
+
* full realistic cases in the e2e tests.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setMockImportReporter(mock: MockImportReporter | undefined): void;
|
|
18
|
+
/**
|
|
19
|
+
* Create a reporter of the given type.
|
|
20
|
+
*
|
|
21
|
+
* NOTE: This is covered by tests in `initializeReporter.test.ts`, `customReporter.test.ts`, and
|
|
22
|
+
* E2E `customReporter.test.ts`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createReporter(reporter: string, options: ReporterInitOptions, customReportersOptions: CustomReportersOptions | undefined): Promise<Reporter>;
|
|
25
|
+
export {};
|
|
@@ -2,16 +2,24 @@
|
|
|
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: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get createReporter () {
|
|
8
13
|
return createReporter;
|
|
14
|
+
},
|
|
15
|
+
get setMockImportReporter () {
|
|
16
|
+
return setMockImportReporter;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
11
19
|
const _logger = require("@lage-run/logger");
|
|
12
20
|
const _reporters = require("@lage-run/reporters");
|
|
13
21
|
const _workspacetools = require("workspace-tools");
|
|
14
|
-
const _fs = require("fs");
|
|
22
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
15
23
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
16
24
|
const _url = require("url");
|
|
17
25
|
const _isinteractive = /*#__PURE__*/ _interop_require_default(require("is-interactive"));
|
|
@@ -20,11 +28,15 @@ function _interop_require_default(obj) {
|
|
|
20
28
|
default: obj
|
|
21
29
|
};
|
|
22
30
|
}
|
|
23
|
-
|
|
31
|
+
let mockImportReporter;
|
|
32
|
+
function setMockImportReporter(mock) {
|
|
33
|
+
mockImportReporter = mock;
|
|
34
|
+
}
|
|
35
|
+
async function createReporter(reporter, options, customReportersOptions) {
|
|
24
36
|
const { verbose, grouped, logLevel: logLevelName, concurrency, profile, progress, logFile, indented } = options;
|
|
25
37
|
const logLevel = _logger.LogLevel[logLevelName];
|
|
26
|
-
const
|
|
27
|
-
const packageJson = JSON.parse(
|
|
38
|
+
const lageRoot = (0, _workspacetools.findPackageRoot)(__filename);
|
|
39
|
+
const packageJson = JSON.parse(_fs.default.readFileSync(_path.default.join(lageRoot, "package.json"), "utf-8"));
|
|
28
40
|
const version = packageJson.version;
|
|
29
41
|
switch(reporter){
|
|
30
42
|
case "profile":
|
|
@@ -65,26 +77,8 @@ async function createReporter(reporter, options, customReporters = {}) {
|
|
|
65
77
|
return new _reporters.VerboseFileLogReporter(logFile);
|
|
66
78
|
}
|
|
67
79
|
// Check if it's a custom reporter defined in config
|
|
68
|
-
if (customReporters
|
|
69
|
-
|
|
70
|
-
const resolvedPath = _path.default.isAbsolute(reporterPath) ? reporterPath : _path.default.resolve(process.cwd(), reporterPath);
|
|
71
|
-
try {
|
|
72
|
-
// Use dynamic import to load the custom reporter module
|
|
73
|
-
// This works with both ESM (.mjs, .js with type: module) and CommonJS (.cjs, .js) files
|
|
74
|
-
const reporterModule = await import((0, _url.pathToFileURL)(resolvedPath).href);
|
|
75
|
-
// Try different export patterns
|
|
76
|
-
const ReporterClass = reporterModule.default ?? reporterModule[reporter] ?? reporterModule;
|
|
77
|
-
if (typeof ReporterClass === "function") {
|
|
78
|
-
return new ReporterClass(options);
|
|
79
|
-
} else if (typeof ReporterClass === "object" && ReporterClass !== null) {
|
|
80
|
-
// If it's already an instance
|
|
81
|
-
return ReporterClass;
|
|
82
|
-
} else {
|
|
83
|
-
throw new Error(`Custom reporter "${reporter}" at "${resolvedPath}" does not export a valid reporter class or instance.`);
|
|
84
|
-
}
|
|
85
|
-
} catch (error) {
|
|
86
|
-
throw new Error(`Failed to load custom reporter "${reporter}" from "${resolvedPath}": ${error}`);
|
|
87
|
-
}
|
|
80
|
+
if (customReportersOptions?.customReporters?.[reporter]) {
|
|
81
|
+
return loadCustomReporterModule(reporter, options, customReportersOptions);
|
|
88
82
|
}
|
|
89
83
|
// Default reporter behavior - auto-detect CI environments
|
|
90
84
|
if (process.env.GITHUB_ACTIONS) {
|
|
@@ -110,3 +104,33 @@ async function createReporter(reporter, options, customReporters = {}) {
|
|
|
110
104
|
logLevel: verbose ? _logger.LogLevel.verbose : logLevel
|
|
111
105
|
});
|
|
112
106
|
}
|
|
107
|
+
async function loadCustomReporterModule(reporter, options, customReportersOptions) {
|
|
108
|
+
const { customReporters, root } = customReportersOptions;
|
|
109
|
+
const resolvedPath = _path.default.resolve(root, customReporters[reporter]);
|
|
110
|
+
if (!_fs.default.existsSync(resolvedPath)) {
|
|
111
|
+
throw new Error(`Custom reporter "${reporter}" file "${resolvedPath}" does not exist`);
|
|
112
|
+
}
|
|
113
|
+
let reporterInstance;
|
|
114
|
+
try {
|
|
115
|
+
// Use dynamic import to load the custom reporter module
|
|
116
|
+
// This works with both ESM (.mjs, .js with type: module) and CommonJS (.cjs, .js) files
|
|
117
|
+
const reporterModule = mockImportReporter ? mockImportReporter({
|
|
118
|
+
reporterName: reporter,
|
|
119
|
+
resolvedPath
|
|
120
|
+
}) : await import((0, _url.pathToFileURL)(resolvedPath).href);
|
|
121
|
+
// Try different export patterns
|
|
122
|
+
const maybeReporter = reporterModule[reporter] ?? reporterModule.default ?? reporterModule;
|
|
123
|
+
if (typeof maybeReporter === "function") {
|
|
124
|
+
reporterInstance = new maybeReporter(options);
|
|
125
|
+
} else if (maybeReporter && typeof maybeReporter === "object") {
|
|
126
|
+
reporterInstance = maybeReporter;
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
throw new Error(`Failed to load custom reporter "${reporter}" from "${resolvedPath}": ${error}`);
|
|
130
|
+
}
|
|
131
|
+
if (reporterInstance && typeof reporterInstance.log === "function" && typeof reporterInstance.summarize === "function") {
|
|
132
|
+
return reporterInstance;
|
|
133
|
+
}
|
|
134
|
+
const issue = reporterInstance ? "does not implement the Reporter interface (missing log or summarize method)" : "does not export a valid reporter class or instance";
|
|
135
|
+
throw new Error(`Custom reporter "${reporter}" at "${resolvedPath}" ${issue}`);
|
|
136
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/createReporter.ts"],"sourcesContent":["import { LogLevel } from \"@lage-run/logger\";\nimport {\n JsonReporter,\n AdoReporter,\n GithubActionsReporter,\n LogReporter,\n ProgressReporter,\n BasicReporter,\n VerboseFileLogReporter,\n ChromeTraceEventsReporter,\n} from \"@lage-run/reporters\";\nimport type { BuiltInReporterName, ReporterInitOptions } from \"../types/ReporterInitOptions.js\";\nimport type { Reporter } from \"@lage-run/logger\";\nimport { findPackageRoot } from \"workspace-tools\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/commands/createReporter.ts"],"sourcesContent":["import { LogLevel } from \"@lage-run/logger\";\nimport {\n JsonReporter,\n AdoReporter,\n GithubActionsReporter,\n LogReporter,\n ProgressReporter,\n BasicReporter,\n VerboseFileLogReporter,\n ChromeTraceEventsReporter,\n} from \"@lage-run/reporters\";\nimport type { BuiltInReporterName, ReporterInitOptions } from \"../types/ReporterInitOptions.js\";\nimport type { Reporter } from \"@lage-run/logger\";\nimport { findPackageRoot } from \"workspace-tools\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { pathToFileURL } from \"url\";\nimport isInteractive from \"is-interactive\";\n\nexport interface CustomReportersOptions {\n customReporters: Record<string, string> | undefined;\n /** Monorepo root for resolving custom reporters*/\n root: string;\n}\n\ntype MockImportReporter = (params: { reporterName: string; resolvedPath: string }) => unknown;\n\nlet mockImportReporter: MockImportReporter | undefined;\n\n/**\n * Mock the reporter importing for tests. We don't currently support ESM in Jest, and it's too much\n * of a headache to set it up for one package, so instead we mock for most cases and handle a few\n * full realistic cases in the e2e tests.\n */\nexport function setMockImportReporter(mock: MockImportReporter | undefined): void {\n mockImportReporter = mock;\n}\n\n/**\n * Create a reporter of the given type.\n *\n * NOTE: This is covered by tests in `initializeReporter.test.ts`, `customReporter.test.ts`, and\n * E2E `customReporter.test.ts`.\n */\nexport async function createReporter(\n reporter: string,\n options: ReporterInitOptions,\n customReportersOptions: CustomReportersOptions | undefined\n): Promise<Reporter> {\n const { verbose, grouped, logLevel: logLevelName, concurrency, profile, progress, logFile, indented } = options;\n const logLevel = LogLevel[logLevelName];\n\n const lageRoot = findPackageRoot(__filename)!;\n const packageJson = JSON.parse(fs.readFileSync(path.join(lageRoot, \"package.json\"), \"utf-8\"));\n const version = packageJson.version;\n\n switch (reporter as BuiltInReporterName) {\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 \"githubActions\":\n case \"gha\":\n return new GithubActionsReporter({ 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 \"fancy\":\n return new ProgressReporter({ concurrency, version });\n\n case \"verboseFileLog\":\n case \"vfl\":\n return new VerboseFileLogReporter(logFile);\n }\n\n // Check if it's a custom reporter defined in config\n if (customReportersOptions?.customReporters?.[reporter]) {\n return loadCustomReporterModule(reporter, options, customReportersOptions);\n }\n\n // Default reporter behavior - auto-detect CI environments\n if (process.env.GITHUB_ACTIONS) {\n return new GithubActionsReporter({ grouped: true, logLevel: verbose ? LogLevel.verbose : logLevel });\n }\n\n if (process.env.TF_BUILD) {\n return new AdoReporter({ grouped: true, logLevel: verbose ? LogLevel.verbose : logLevel });\n }\n\n if (progress && isInteractive() && !(logLevel >= LogLevel.verbose || verbose || grouped)) {\n return new BasicReporter({ concurrency, version });\n }\n\n return new LogReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel });\n}\n\nasync function loadCustomReporterModule(\n reporter: string,\n options: ReporterInitOptions,\n customReportersOptions: Required<CustomReportersOptions>\n): Promise<Reporter> {\n const { customReporters, root } = customReportersOptions;\n const resolvedPath = path.resolve(root, customReporters![reporter]);\n\n if (!fs.existsSync(resolvedPath)) {\n throw new Error(`Custom reporter \"${reporter}\" file \"${resolvedPath}\" does not exist`);\n }\n\n let reporterInstance: Reporter | undefined;\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 = mockImportReporter\n ? mockImportReporter({ reporterName: reporter, resolvedPath })\n : await import(pathToFileURL(resolvedPath).href);\n\n // Try different export patterns\n const maybeReporter = reporterModule[reporter] ?? reporterModule.default ?? reporterModule;\n\n if (typeof maybeReporter === \"function\") {\n reporterInstance = new maybeReporter(options);\n } else if (maybeReporter && typeof maybeReporter === \"object\") {\n reporterInstance = maybeReporter;\n }\n } catch (error) {\n throw new Error(`Failed to load custom reporter \"${reporter}\" from \"${resolvedPath}\": ${error}`);\n }\n\n if (reporterInstance && typeof reporterInstance.log === \"function\" && typeof reporterInstance.summarize === \"function\") {\n return reporterInstance;\n }\n\n const issue = reporterInstance\n ? \"does not implement the Reporter interface (missing log or summarize method)\"\n : \"does not export a valid reporter class or instance\";\n throw new Error(`Custom reporter \"${reporter}\" at \"${resolvedPath}\" ${issue}`);\n}\n"],"names":["createReporter","setMockImportReporter","mockImportReporter","mock","reporter","options","customReportersOptions","verbose","grouped","logLevel","logLevelName","concurrency","profile","progress","logFile","indented","LogLevel","lageRoot","findPackageRoot","__filename","packageJson","JSON","parse","fs","readFileSync","path","join","version","ChromeTraceEventsReporter","outputFile","undefined","JsonReporter","AdoReporter","GithubActionsReporter","LogReporter","ProgressReporter","VerboseFileLogReporter","customReporters","loadCustomReporterModule","process","env","GITHUB_ACTIONS","TF_BUILD","isInteractive","BasicReporter","root","resolvedPath","resolve","existsSync","Error","reporterInstance","reporterModule","reporterName","pathToFileURL","href","maybeReporter","default","error","log","summarize","issue"],"mappings":";;;;;;;;;;;QA4CsBA;eAAAA;;QAVNC;eAAAA;;;wBAlCS;2BAUlB;gCAGyB;2DACjB;6DACE;qBACa;sEACJ;;;;;;AAU1B,IAAIC;AAOG,SAASD,sBAAsBE,IAAoC;IACxED,qBAAqBC;AACvB;AAQO,eAAeH,eACpBI,QAAgB,EAChBC,OAA4B,EAC5BC,sBAA0D;IAE1D,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,WA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AAOA,iBAAiBQ,GAAG,KAAK,cAAc,OAAOR,iBAAiBS,SAAS,KAAK,YAAY;QACtH,OAAOT;IACT;IAEA,MAAMU,QAAQV,mBACV,gFACA;IACJ,MAAM,IAAID,MAAM,CAAC,iBAAiB,EAAE7C,SAAS,MAAM,EAAE0C,aAAa,EAAE,EAAEc,OAAO;AAC/E"}
|
|
@@ -13,6 +13,7 @@ const _initializeReporters = require("../initializeReporters.js");
|
|
|
13
13
|
const _executeInProcess = require("./executeInProcess.js");
|
|
14
14
|
const _executeRemotely = require("./executeRemotely.js");
|
|
15
15
|
const _config = require("@lage-run/config");
|
|
16
|
+
const _workspacetools = require("workspace-tools");
|
|
16
17
|
function _interop_require_default(obj) {
|
|
17
18
|
return obj && obj.__esModule ? obj : {
|
|
18
19
|
default: obj
|
|
@@ -20,12 +21,16 @@ function _interop_require_default(obj) {
|
|
|
20
21
|
}
|
|
21
22
|
async function execAction(options, command) {
|
|
22
23
|
const cwd = options.cwd ?? process.cwd();
|
|
24
|
+
const root = (0, _workspacetools.getWorkspaceManagerRoot)(cwd) ?? cwd;
|
|
23
25
|
const config = await (0, _config.getConfig)(cwd);
|
|
24
26
|
const logger = (0, _logger.default)();
|
|
25
27
|
options.cwd = cwd;
|
|
26
28
|
options.logLevel = options.logLevel ?? "info";
|
|
27
29
|
options.reporter = options.reporter ?? "json";
|
|
28
|
-
await (0, _initializeReporters.initializeReporters)(logger, options,
|
|
30
|
+
await (0, _initializeReporters.initializeReporters)(logger, options, {
|
|
31
|
+
customReporters: config.reporters,
|
|
32
|
+
root
|
|
33
|
+
});
|
|
29
34
|
const { server } = options;
|
|
30
35
|
if (server) {
|
|
31
36
|
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\";\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): Promise<void> {\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":";;;;+
|
|
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\";\nimport { getWorkspaceManagerRoot } from \"workspace-tools\";\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): Promise<void> {\n const cwd = options.cwd ?? process.cwd();\n const root = getWorkspaceManagerRoot(cwd) ?? 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, { customReporters: config.reporters, root });\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","root","getWorkspaceManagerRoot","config","getConfig","logger","createLogger","logLevel","reporter","initializeReporters","customReporters","reporters","server","info","tasks","Error","executeRemotely","executeInProcess","args","nodeArg"],"mappings":";;;;+BAqBsBA;;;eAAAA;;;+DApBG;qCAEW;kCACH;iCACD;wBACN;gCACc;;;;;;AAcjC,eAAeA,WAAWC,OAAoB,EAAEC,OAAgB;IACrE,MAAMC,MAAMF,QAAQE,GAAG,IAAIC,QAAQD,GAAG;IACtC,MAAME,OAAOC,IAAAA,uCAAuB,EAACH,QAAQA;IAC7C,MAAMI,SAAS,MAAMC,IAAAA,iBAAS,EAACL;IAC/B,MAAMM,SAASC,IAAAA,eAAY;IAC3BT,QAAQE,GAAG,GAAGA;IACdF,QAAQU,QAAQ,GAAGV,QAAQU,QAAQ,IAAI;IACvCV,QAAQW,QAAQ,GAAGX,QAAQW,QAAQ,IAAI;IACvC,MAAMC,IAAAA,wCAAmB,EAACJ,QAAQR,SAAS;QAAEa,iBAAiBP,OAAOQ,SAAS;QAAEV;IAAK;IAErF,MAAM,EAAEW,MAAM,EAAE,GAAGf;IACnB,IAAIe,QAAQ;QACVP,OAAOQ,IAAI,CAAC;QAEZ,IAAI,OAAOhB,QAAQiB,KAAK,KAAK,aAAa;YACxC,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMC,IAAAA,gCAAe,EAACnB,SAA8BC;IACtD,OAAO;QACL,MAAMmB,IAAAA,kCAAgB,EAAC;YAAEZ;YAAQa,MAAMpB,QAAQoB,IAAI;YAAEnB,KAAKF,QAAQE,GAAG;YAAEoB,SAAStB,QAAQsB,OAAO;QAAC;IAClG;AACF"}
|
|
@@ -93,12 +93,15 @@ async function executeRemotely(options, command) {
|
|
|
93
93
|
const timeout = options.timeout ?? 5 * 60;
|
|
94
94
|
const { host, port } = (0, _parseServerOption.parseServerOption)(server);
|
|
95
95
|
const cwd = options.cwd ?? process.cwd();
|
|
96
|
+
const root = (0, _workspacetools.getWorkspaceManagerRoot)(cwd) ?? cwd;
|
|
96
97
|
const config = await (0, _config.getConfig)(cwd);
|
|
97
98
|
const logger = (0, _logger.default)();
|
|
98
99
|
options.logLevel = options.logLevel ?? "info";
|
|
99
100
|
options.reporter = options.reporter ?? "json";
|
|
100
|
-
await (0, _initializeReporters.initializeReporters)(logger, options,
|
|
101
|
-
|
|
101
|
+
await (0, _initializeReporters.initializeReporters)(logger, options, {
|
|
102
|
+
customReporters: config.reporters,
|
|
103
|
+
root
|
|
104
|
+
});
|
|
102
105
|
let client = await tryCreateClient(host, port);
|
|
103
106
|
const args = command.args;
|
|
104
107
|
logger.info(`Command args ${command.args.join(" ")}`);
|
|
@@ -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 { getConfig } from \"@lage-run/config\";\nimport { getWorkspaceManagerRoot } 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): Promise<void> {\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
|
|
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 { getWorkspaceManagerRoot } 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): Promise<void> {\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 root = getWorkspaceManagerRoot(cwd) ?? 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, { customReporters: config.reporters, root });\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","root","getWorkspaceManagerRoot","config","getConfig","createLogger","logLevel","reporter","initializeReporters","customReporters","reporters","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;gCACc;0CAEC;;;;;;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;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EAnB,OAAOkB,IAAI,CAAC;AACd"}
|
|
@@ -28,6 +28,12 @@ export interface PackageTask {
|
|
|
28
28
|
options?: Record<string, any>;
|
|
29
29
|
weight?: number;
|
|
30
30
|
}
|
|
31
|
+
/** Result logged and written to a file by the `info` command */
|
|
32
|
+
export interface InfoResult {
|
|
33
|
+
packageTasks: PackageTask[];
|
|
34
|
+
scope: string[];
|
|
35
|
+
command: string[];
|
|
36
|
+
}
|
|
31
37
|
/**
|
|
32
38
|
* The info command displays information about a target graph in a workspace.
|
|
33
39
|
* The generated output can be read and used by other task runners, such as BuildXL.
|
|
@@ -53,7 +59,7 @@ export interface PackageTask {
|
|
|
53
59
|
* ],
|
|
54
60
|
* "weight": 3,
|
|
55
61
|
* "inputs": ["src//**/ export declare function infoAction(options: InfoActionOptions, command: Command): Promise<void>;
|
|
56
|
-
export declare function generatePackageTask(target: Target, taskArgs: string[], config: ConfigOptions, options: InfoActionOptions, binPaths: {
|
|
62
|
+
export declare function generatePackageTask(target: Target, taskArgs: string[], config: Pick<ConfigOptions, "npmClient">, options: Pick<InfoActionOptions, "concurrency" | "server">, binPaths: {
|
|
57
63
|
lage: string;
|
|
58
64
|
"lage-server": string;
|
|
59
65
|
}, packageInfos: PackageInfos, tasks: string[]): PackageTask;
|
|
@@ -47,8 +47,11 @@ 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
|
-
|
|
51
|
-
|
|
50
|
+
const root = (0, _workspacetools.getWorkspaceManagerRoot)(cwd) ?? cwd;
|
|
51
|
+
await (0, _initializeReporters.initializeReporters)(logger, options, {
|
|
52
|
+
customReporters: config.reporters,
|
|
53
|
+
root
|
|
54
|
+
});
|
|
52
55
|
const packageInfos = (0, _workspacetools.getPackageInfos)(root);
|
|
53
56
|
const { tasks, taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
|
|
54
57
|
const targetGraph = await (0, _createTargetGraph.createTargetGraph)({
|
|
@@ -65,7 +68,8 @@ async function infoAction(options, command) {
|
|
|
65
68
|
tasks,
|
|
66
69
|
packageInfos,
|
|
67
70
|
priorities: config.priorities,
|
|
68
|
-
enableTargetConfigMerging: config.enableTargetConfigMerging
|
|
71
|
+
enableTargetConfigMerging: config.enableTargetConfigMerging,
|
|
72
|
+
enablePhantomTargetOptimization: config.enablePhantomTargetOptimization
|
|
69
73
|
});
|
|
70
74
|
const scope = (0, _getFilteredPackages.getFilteredPackages)({
|
|
71
75
|
root,
|
|
@@ -104,12 +108,12 @@ async function infoAction(options, command) {
|
|
|
104
108
|
root
|
|
105
109
|
});
|
|
106
110
|
const globHashCache = new Map();
|
|
107
|
-
const globHashWithCache = (patterns,
|
|
111
|
+
const globHashWithCache = (patterns, opts)=>{
|
|
108
112
|
const key = patterns.join("###");
|
|
109
113
|
if (globHashCache.has(key)) {
|
|
110
114
|
return globHashCache.get(key);
|
|
111
115
|
}
|
|
112
|
-
const files = (0, _globby.glob)(patterns,
|
|
116
|
+
const files = (0, _globby.glob)(patterns, opts);
|
|
113
117
|
const hash = (0, _hasher.hashStrings)(Object.values(fileHasher.hash(files.map((file)=>_path.default.join(root, file)))));
|
|
114
118
|
globHashCache.set(key, hash);
|
|
115
119
|
return hash;
|
|
@@ -184,7 +188,7 @@ function shouldRunWorkersAsService(options) {
|
|
|
184
188
|
return typeof process.env.LAGE_WORKER_SERVER === "string" && process.env.LAGE_WORKER_SERVER !== "false" || !!options.server;
|
|
185
189
|
}
|
|
186
190
|
function generateCommand(target, taskArgs, config, options, binPaths, packageInfos, tasks) {
|
|
187
|
-
if (target.type ===
|
|
191
|
+
if (target.type === _targetgraph.builtInTargetTypes.npmScript) {
|
|
188
192
|
const script = target.packageName !== undefined ? packageInfos[target.packageName]?.scripts?.[target.task] : undefined;
|
|
189
193
|
// If the script is a node script, and that it does not have any shell operators (&&, ||, etc)
|
|
190
194
|
// then we can simply pass this along to info command rather than using npm client to run it.
|
|
@@ -198,12 +202,12 @@ function generateCommand(target, taskArgs, config, options, binPaths, packageInf
|
|
|
198
202
|
}
|
|
199
203
|
}
|
|
200
204
|
const npmClient = config.npmClient ?? "npm";
|
|
201
|
-
|
|
205
|
+
return [
|
|
202
206
|
npmClient,
|
|
203
207
|
...getNpmArgs(target.task, taskArgs)
|
|
204
208
|
];
|
|
205
|
-
|
|
206
|
-
|
|
209
|
+
}
|
|
210
|
+
if (target.type === _targetgraph.builtInTargetTypes.worker && shouldRunWorkersAsService(options)) {
|
|
207
211
|
const { host, port } = (0, _parseServerOption.parseServerOption)(options.server);
|
|
208
212
|
const command = [
|
|
209
213
|
binPaths["lage"],
|
|
@@ -224,7 +228,8 @@ function generateCommand(target, taskArgs, config, options, binPaths, packageInf
|
|
|
224
228
|
}
|
|
225
229
|
command.push(...taskArgs);
|
|
226
230
|
return command;
|
|
227
|
-
}
|
|
231
|
+
}
|
|
232
|
+
if (target.type === _targetgraph.builtInTargetTypes.worker) {
|
|
228
233
|
const command = [
|
|
229
234
|
binPaths.lage,
|
|
230
235
|
"exec"
|
|
@@ -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, getWorkspaceManagerRoot } 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 { getBuiltInRunners } from \"../../getBuiltInRunners.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\nexport interface 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): Promise<void> {\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 = getWorkspaceManagerRoot(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 = getBuiltInRunners({ nodeArg: options.nodeArg, npmCmd: 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: Target) {\n const cwd = process.cwd();\n const workingDirectory = path.relative(getWorkspaceManagerRoot(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","getWorkspaceManagerRoot","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","getBuiltInRunners","nodeArg","npmCmd","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;gCACkD;qCACxC;+DACX;6DACR;2DACF;4BACO;6BAGwB;qCACV;yBACD;6BACP;mCACM;mCACA;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,QAAQU,MAAM;IAC1G,MAAMC,IAAAA,wCAAmB,EAACL,QAAQN,SAASI,OAAOQ,SAAS;IAC3D,MAAMC,OAAOC,IAAAA,uCAAuB,EAACZ;IAErC,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;QAC1ChB;QACAO;QACAU,cAAcvB,QAAQuB,YAAY;QAClCC,YAAYxB,QAAQwB,UAAU,IAAI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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, getWorkspaceManagerRoot } 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, builtInTargetTypes, getStartTargetId } from \"@lage-run/target-graph\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { TargetRunnerPicker } from \"@lage-run/runners\";\nimport { getBinPaths } from \"../../getBinPaths.js\";\nimport { getBuiltInRunners } from \"../../getBuiltInRunners.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\nexport interface 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/** Result logged and written to a file by the `info` command */\nexport interface InfoResult {\n packageTasks: PackageTask[];\n scope: string[];\n command: string[];\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): Promise<void> {\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 const root = getWorkspaceManagerRoot(cwd) ?? cwd;\n await initializeReporters(logger, options, { customReporters: config.reporters, root });\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 enablePhantomTargetOptimization: config.enablePhantomTargetOptimization,\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 = getBuiltInRunners({ nodeArg: options.nodeArg, npmCmd: 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[], opts: { cwd: string }) => {\n const key = patterns.join(\"###\");\n if (globHashCache.has(key)) {\n return globHashCache.get(key)!;\n }\n\n const files = glob(patterns, opts);\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: 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: Pick<ConfigOptions, \"npmClient\">,\n options: Pick<InfoActionOptions, \"concurrency\" | \"server\">,\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: Pick<InfoActionOptions, \"server\">) {\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: Pick<ConfigOptions, \"npmClient\">,\n options: Pick<InfoActionOptions, \"concurrency\" | \"server\">,\n binPaths: { lage: string; \"lage-server\": string },\n packageInfos: PackageInfos,\n tasks: string[]\n) {\n if (target.type === builtInTargetTypes.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 return [npmClient, ...getNpmArgs(target.task, taskArgs)];\n }\n\n if (target.type === builtInTargetTypes.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 }\n\n if (target.type === builtInTargetTypes.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: Target) {\n const cwd = process.cwd();\n const workingDirectory = path.relative(getWorkspaceManagerRoot(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","root","getWorkspaceManagerRoot","initializeReporters","customReporters","reporters","packageInfos","getPackageInfos","tasks","taskArgs","filterArgsForTasks","args","targetGraph","createTargetGraph","dependencies","dependents","to","ignore","concat","pipeline","repoWideChanges","scope","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","enablePhantomTargetOptimization","getFilteredPackages","includeDependencies","includeDependents","sinceIgnoreGlobs","pickerOptions","getBuiltInRunners","nodeArg","npmCmd","npmClient","runnerPicker","TargetRunnerPicker","createBackwardsCompatGraph","env","optimizeGraph","optimizedTargets","optimizeTargetGraph","binPaths","getBinPaths","packageTasks","map","target","shouldRunWorkersAsService","fileHasher","FileHasher","globHashCache","Map","globHashWithCache","patterns","opts","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","builtInTargetTypes","npmScript","script","scripts","startsWith","parsed","parse","every","entry","getNpmArgs","worker","host","port","parseServerOption","concurrency","push","toString","lage","relative","replace","taskTargs","extraArgs"],"mappings":";;;;;;;;;;;QA2OgBA;eAAA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AAGiH,KAAK,CAAC,EAAEC,MAAM;SAAC;QAC9F,IAAIpI,QAAQsI,WAAW,EAAE;YACvBrI,QAAQsI,IAAI,CAAC,iBAAiBvI,QAAQsI,WAAW,CAACE,QAAQ;QAC5D;QAEA,IAAI7E,OAAOqD,WAAW,EAAE;YACtB/G,QAAQsI,IAAI,CAAC5E,OAAOqD,WAAW;QACjC;QAEA,IAAIrD,OAAOsD,IAAI,EAAE;YACfhH,QAAQsI,IAAI,CAAC5E,OAAOsD,IAAI;QAC1B;QAEAhH,QAAQsI,IAAI,IAAIpH;QAChB,OAAOlB;IACT;IAEA,IAAI0D,OAAO4D,IAAI,KAAKC,+BAAkB,CAACU,MAAM,EAAE;QAC7C,MAAMjI,UAAU;YAACsD,SAASkF,IAAI;YAAE;SAAO;QACvCxI,QAAQsI,IAAI,CAAC5E,OAAOqD,WAAW,IAAI;QACnC/G,QAAQsI,IAAI,CAAC5E,OAAOsD,IAAI;QACxBhH,QAAQsI,IAAI,IAAIpH;QAChB,OAAOlB;IACT;IAEA,OAAO,EAAE;AACX;AAEA,SAAS4G,oBAAoBlD,MAAc;IACzC,MAAMzD,MAAMC,QAAQD,GAAG;IACvB,MAAM0G,mBAAmB7B,aAAI,CAAC2D,QAAQ,CAAC9H,IAAAA,uCAAuB,EAACV,QAAQ,IAAIyD,OAAOzD,GAAG,EAAEyI,OAAO,CAAC,OAAO;IACtG,OAAO/B;AACT;AAEA,SAASqB,WAAWhB,IAAY,EAAE2B,SAAmB;IACnD,MAAMC,YAAYD,aAAapC,aAAaoC,UAAUvB,MAAM,GAAG,IAAI;QAAC;WAASuB;KAAU,GAAG,EAAE;IAC5F,OAAO;QAAC;QAAO3B;WAAS4B;KAAU;AACpC"}
|
|
@@ -53,8 +53,10 @@ const config = {
|
|
|
53
53
|
// (relative to package root; folders must end with **/*)
|
|
54
54
|
outputGlob: ["lib/**/*"],
|
|
55
55
|
// Changes to any of these files/globs will invalidate the cache (relative to repo root;
|
|
56
|
-
// folders must end with **/*). This should include
|
|
57
|
-
//
|
|
56
|
+
// folders must end with **/*). This should include any repo-wide configs or scripts that
|
|
57
|
+
// are outside a package but could invalidate previous output. Including the lock file is
|
|
58
|
+
// optional--lage attempts to more granularly check resolved dependency changes, but this
|
|
59
|
+
// isn't entirely reliable, especially for peerDependencies.
|
|
58
60
|
environmentGlob: ${JSON.stringify([
|
|
59
61
|
"package.json",
|
|
60
62
|
lockFile,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/init/action.ts"],"sourcesContent":["/* eslint-disable no-console -- logger doesn't work in this context */\nimport { readConfigFile } from \"@lage-run/config\";\nimport { getPackageInfo, getWorkspaceManagerAndRoot, type WorkspaceManager } from \"workspace-tools\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport execa from \"execa\";\n\nexport async function initAction(): Promise<void> {\n const cwd = process.cwd();\n\n const managerAndRoot = getWorkspaceManagerAndRoot(cwd);\n if (!managerAndRoot) {\n console.error(\"lage only works with workspaces - make sure you are using yarn workspaces, npm workspaces, pnpm workspaces, or rush\");\n process.exitCode = 1;\n return;\n }\n\n const { manager: workspaceManager, root } = managerAndRoot;\n const config = await readConfigFile(root);\n if (config) {\n console.error(\"lage is already initialized in this repo\");\n process.exitCode = 1;\n return;\n }\n\n console.info(\"Installing lage and creating a default configuration file\");\n\n const isMetaManager = workspaceManager === \"rush\" || workspaceManager === \"lerna\";\n const npmClientLine = isMetaManager ? \"\" : `npmClient: \"${workspaceManager}\",`;\n const lockFile = isMetaManager\n ? \"\"\n : workspaceManager === \"yarn\"\n ? \"yarn.lock\"\n : workspaceManager === \"pnpm\"\n ? \"pnpm-lock.yaml\"\n : \"package-lock.json\";\n\n const configContent = `// @ts-check\n/** @type {import(\"lage\").ConfigFileOptions} */\nconst config = {\n // Define your tasks and their dependencies here\n pipeline: {\n build: [\"^build\"],\n test: [\"build\"],\n lint: [],\n },\n ${npmClientLine}\n // Update these according to your repo's build setup\n cacheOptions: {\n // Generated files in each package that will be saved into the cache\n // (relative to package root; folders must end with **/*)\n outputGlob: [\"lib/**/*\"],\n // Changes to any of these files/globs will invalidate the cache (relative to repo root;\n // folders must end with **/*). This should include
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/init/action.ts"],"sourcesContent":["/* eslint-disable no-console -- logger doesn't work in this context */\nimport { readConfigFile } from \"@lage-run/config\";\nimport { getPackageInfo, getWorkspaceManagerAndRoot, type WorkspaceManager } from \"workspace-tools\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport execa from \"execa\";\n\nexport async function initAction(): Promise<void> {\n const cwd = process.cwd();\n\n const managerAndRoot = getWorkspaceManagerAndRoot(cwd);\n if (!managerAndRoot) {\n console.error(\"lage only works with workspaces - make sure you are using yarn workspaces, npm workspaces, pnpm workspaces, or rush\");\n process.exitCode = 1;\n return;\n }\n\n const { manager: workspaceManager, root } = managerAndRoot;\n const config = await readConfigFile(root);\n if (config) {\n console.error(\"lage is already initialized in this repo\");\n process.exitCode = 1;\n return;\n }\n\n console.info(\"Installing lage and creating a default configuration file\");\n\n const isMetaManager = workspaceManager === \"rush\" || workspaceManager === \"lerna\";\n const npmClientLine = isMetaManager ? \"\" : `npmClient: \"${workspaceManager}\",`;\n const lockFile = isMetaManager\n ? \"\"\n : workspaceManager === \"yarn\"\n ? \"yarn.lock\"\n : workspaceManager === \"pnpm\"\n ? \"pnpm-lock.yaml\"\n : \"package-lock.json\";\n\n const configContent = `// @ts-check\n/** @type {import(\"lage\").ConfigFileOptions} */\nconst config = {\n // Define your tasks and their dependencies here\n pipeline: {\n build: [\"^build\"],\n test: [\"build\"],\n lint: [],\n },\n ${npmClientLine}\n // Update these according to your repo's build setup\n cacheOptions: {\n // Generated files in each package that will be saved into the cache\n // (relative to package root; folders must end with **/*)\n outputGlob: [\"lib/**/*\"],\n // Changes to any of these files/globs will invalidate the cache (relative to repo root;\n // folders must end with **/*). This should include any repo-wide configs or scripts that\n // are outside a package but could invalidate previous output. Including the lock file is\n // optional--lage attempts to more granularly check resolved dependency changes, but this\n // isn't entirely reliable, especially for peerDependencies.\n environmentGlob: ${JSON.stringify([\"package.json\", lockFile, \"lage.config.js\"].filter(Boolean))},\n },\n};\nmodule.exports = config;\n`;\n\n fs.writeFileSync(path.join(root, \"lage.config.js\"), configContent);\n\n await installLage(root, workspaceManager, [\"build\", \"test\", \"lint\"]);\n\n console.info(`Lage is initialized! You can now run: ${getBuildCommand(workspaceManager)}`);\n}\n\nfunction getBuildCommand(workspaceManager: WorkspaceManager) {\n switch (workspaceManager) {\n case \"yarn\":\n return \"yarn lage build\";\n\n case \"pnpm\":\n return \"pnpm run lage build\";\n\n default:\n return \"npm run lage build\";\n }\n}\n\nasync function installLage(cwd: string, workspaceManager: WorkspaceManager, scripts: string[]) {\n const lageVersion = getLageVersion();\n const packageJson = readPackageJson(cwd);\n packageJson.scripts ??= {};\n for (const script of scripts) {\n packageJson.scripts[script] = `lage ${script}`;\n }\n\n if (workspaceManager === \"rush\") {\n packageJson.scripts.lage = `node common/scripts/install-run.js lage@${lageVersion} lage`;\n writePackageJson(cwd, packageJson);\n } else {\n packageJson.scripts.lage = \"lage\";\n packageJson.devDependencies ??= {};\n packageJson.devDependencies.lage = lageVersion;\n writePackageJson(cwd, packageJson);\n\n await execa(workspaceManager, [\"install\"], { stdio: \"inherit\", shell: true });\n }\n}\n\nfunction getLageVersion() {\n // NOTE: this would give the wrong version prior to bundling of the `lage` package\n const lagePackageInfo = getPackageInfo(__dirname);\n if (!lagePackageInfo) {\n throw new Error(\"Could not find lage package root\");\n }\n return lagePackageInfo.version;\n}\n\nfunction writePackageJson(cwd: string, packageJson: any) {\n const packageJsonFile = path.join(cwd, \"package.json\");\n fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));\n}\n\nfunction readPackageJson(cwd: string): {\n scripts?: Record<string, string>;\n devDependencies?: Record<string, string>;\n workspaces?: any;\n} {\n const packageJsonFile = path.join(cwd, \"package.json\");\n return JSON.parse(fs.readFileSync(packageJsonFile, \"utf-8\"));\n}\n"],"names":["initAction","cwd","process","managerAndRoot","getWorkspaceManagerAndRoot","console","error","exitCode","manager","workspaceManager","root","config","readConfigFile","info","isMetaManager","npmClientLine","lockFile","configContent","JSON","stringify","filter","Boolean","fs","writeFileSync","path","join","installLage","getBuildCommand","scripts","packageJson","lageVersion","getLageVersion","readPackageJson","script","lage","writePackageJson","devDependencies","execa","stdio","shell","lagePackageInfo","getPackageInfo","__dirname","Error","version","packageJsonFile","parse","readFileSync"],"mappings":"AAAA,oEAAoE;;;;+BAO9CA;;;eAAAA;;;wBANS;gCACmD;2DACnE;6DACE;8DACC;;;;;;AAEX,eAAeA;IACpB,MAAMC,MAAMC,QAAQD,GAAG;IAEvB,MAAME,iBAAiBC,IAAAA,0CAA0B,EAACH;IAClD,IAAI,CAACE,gBAAgB;QACnBE,QAAQC,KAAK,CAAC;QACdJ,QAAQK,QAAQ,GAAG;QACnB;IACF;IAEA,MAAM,EAAEC,SAASC,gBAAgB,EAAEC,IAAI,EAAE,GAAGP;IAC5C,MAAMQ,SAAS,MAAMC,IAAAA,sBAAc,EAACF;IACpC,IAAIC,QAAQ;QACVN,QAAQC,KAAK,CAAC;QACdJ,QAAQK,QAAQ,GAAG;QACnB;IACF;IAEAF,QAAQQ,IAAI,CAAC;IAEb,MAAMC,gBAAgBL,qBAAqB,UAAUA,qBAAqB;IAC1E,MAAMM,gBAAgBD,gBAAgB,KAAK,CAAC,YAAY,EAAEL,iBAAiB,EAAE,CAAC;IAC9E,MAAMO,WAAWF,gBACb,KACAL,qBAAqB,SACnB,cACAA,qBAAqB,SACnB,mBACA;IAER,MAAMQ,gBAAgB,CAAC;;;;;;;;;EASvB,EAAEF,cAAc;;;;;;;;;;;qBAWG,EAAEG,KAAKC,SAAS,CAAC;QAAC;QAAgBH;QAAU;KAAiB,CAACI,MAAM,CAACC,UAAU;;;;AAIpG,CAAC;IAECC,WAAE,CAACC,aAAa,CAACC,aAAI,CAACC,IAAI,CAACf,MAAM,mBAAmBO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AACC,IAAI,CAACxB,KAAK;IACvCqB,WAAE,CAACC,aAAa,CAACsB,iBAAiB3B,KAAKC,SAAS,CAACU,aAAa,MAAM;AACtE;AAEA,SAASG,gBAAgB/B,GAAW;IAKlC,MAAM4C,kBAAkBrB,aAAI,CAACC,IAAI,CAACxB,KAAK;IACvC,OAAOiB,KAAK4B,KAAK,CAACxB,WAAE,CAACyB,YAAY,CAACF,iBAAiB;AACrD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CustomReportersOptions } from "./createReporter.js";
|
|
1
2
|
import type { LogStructuredData, Logger, Reporter } from "@lage-run/logger";
|
|
2
3
|
import { type ReporterInitOptions } from "../types/ReporterInitOptions.js";
|
|
3
|
-
export declare function initializeReporters(logger: Logger, options: ReporterInitOptions,
|
|
4
|
+
export declare function initializeReporters(logger: Logger, options: ReporterInitOptions, customReportersOptions: CustomReportersOptions | undefined): Promise<Reporter<LogStructuredData>[]>;
|
|
@@ -10,8 +10,8 @@ Object.defineProperty(exports, "initializeReporters", {
|
|
|
10
10
|
});
|
|
11
11
|
const _createReporter = require("./createReporter.js");
|
|
12
12
|
const _ReporterInitOptions = require("../types/ReporterInitOptions.js");
|
|
13
|
-
async function initializeReporters(logger, options,
|
|
14
|
-
const customReporterNames = Object.keys(customReporters);
|
|
13
|
+
async function initializeReporters(logger, options, customReportersOptions) {
|
|
14
|
+
const customReporterNames = Object.keys(customReportersOptions?.customReporters || {});
|
|
15
15
|
// Mapping from lowercase reporter name to original name
|
|
16
16
|
const supportedReportersLower = Object.fromEntries([
|
|
17
17
|
..._ReporterInitOptions.builtInReporterNames,
|
|
@@ -42,7 +42,7 @@ async function initializeReporters(logger, options, customReporters = {}) {
|
|
|
42
42
|
].join(", ");
|
|
43
43
|
throw new Error(`Invalid --reporter option: "${rawReporterName}". Supported reporters are: ${reportersList}`);
|
|
44
44
|
}
|
|
45
|
-
const reporterInstance = await (0, _createReporter.createReporter)(reporterName, options,
|
|
45
|
+
const reporterInstance = await (0, _createReporter.createReporter)(reporterName, options, customReportersOptions);
|
|
46
46
|
logger.addReporter(reporterInstance);
|
|
47
47
|
}
|
|
48
48
|
return logger.reporters;
|