@lage-run/cli 0.35.2 → 0.36.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.js +20 -11
- package/lib/commands/createReporter.js.map +1 -1
- package/lib/commands/exec/simulateFileAccess.js +4 -4
- package/lib/commands/exec/simulateFileAccess.js.map +1 -1
- package/lib/commands/info/action.js +3 -3
- package/lib/commands/info/action.js.map +1 -1
- package/lib/commands/launchServerInBackground.js +2 -1
- package/lib/commands/launchServerInBackground.js.map +1 -1
- package/lib/commands/options.js +2 -1
- package/lib/commands/options.js.map +1 -1
- package/lib/commands/run/createTargetGraph.js +2 -2
- package/lib/commands/run/createTargetGraph.js.map +1 -1
- package/lib/commands/run/runAction.js +5 -7
- package/lib/commands/run/runAction.js.map +1 -1
- package/lib/commands/run/watchAction.js +4 -4
- package/lib/commands/run/watchAction.js.map +1 -1
- package/lib/commands/server/action.js +3 -1
- package/lib/commands/server/action.js.map +1 -1
- package/lib/commands/server/getOutputFiles.js +2 -2
- package/lib/commands/server/getOutputFiles.js.map +1 -1
- package/lib/commands/server/lageService.js +24 -39
- package/lib/commands/server/lageService.js.map +1 -1
- package/lib/types/ReporterInitOptions.d.ts +2 -0
- package/lib/types/ReporterInitOptions.js.map +1 -1
- package/package.json +13 -14
|
@@ -33,7 +33,7 @@ function setMockImportReporter(mock) {
|
|
|
33
33
|
mockImportReporter = mock;
|
|
34
34
|
}
|
|
35
35
|
async function createReporter(reporter, options, customReportersOptions) {
|
|
36
|
-
const { verbose, grouped, logLevel: logLevelName, concurrency, profile, progress, logFile, indented } = options;
|
|
36
|
+
const { verbose, grouped, logLevel: logLevelName, concurrency, profile, progress, logFile, indented, logMemory } = options;
|
|
37
37
|
const logLevel = _logger.LogLevel[logLevelName];
|
|
38
38
|
const lageRoot = (0, _workspacetools.findPackageRoot)(__filename);
|
|
39
39
|
const packageJson = JSON.parse(_fs.default.readFileSync(_path.default.join(lageRoot, "package.json"), "utf-8"));
|
|
@@ -47,34 +47,39 @@ async function createReporter(reporter, options, customReportersOptions) {
|
|
|
47
47
|
case "json":
|
|
48
48
|
return new _reporters.JsonReporter({
|
|
49
49
|
logLevel,
|
|
50
|
-
indented: indented ?? false
|
|
50
|
+
indented: indented ?? false,
|
|
51
|
+
logMemory
|
|
51
52
|
});
|
|
52
53
|
case "azureDevops":
|
|
53
54
|
case "adoLog":
|
|
54
55
|
return new _reporters.AdoReporter({
|
|
55
56
|
grouped,
|
|
56
|
-
logLevel: verbose ? _logger.LogLevel.verbose : logLevel
|
|
57
|
+
logLevel: verbose ? _logger.LogLevel.verbose : logLevel,
|
|
58
|
+
logMemory
|
|
57
59
|
});
|
|
58
60
|
case "githubActions":
|
|
59
61
|
case "gha":
|
|
60
62
|
return new _reporters.GithubActionsReporter({
|
|
61
63
|
grouped,
|
|
62
|
-
logLevel: verbose ? _logger.LogLevel.verbose : logLevel
|
|
64
|
+
logLevel: verbose ? _logger.LogLevel.verbose : logLevel,
|
|
65
|
+
logMemory
|
|
63
66
|
});
|
|
64
67
|
case "npmLog":
|
|
65
68
|
case "old":
|
|
66
69
|
return new _reporters.LogReporter({
|
|
67
70
|
grouped,
|
|
68
|
-
logLevel: verbose ? _logger.LogLevel.verbose : logLevel
|
|
71
|
+
logLevel: verbose ? _logger.LogLevel.verbose : logLevel,
|
|
72
|
+
logMemory
|
|
69
73
|
});
|
|
70
74
|
case "fancy":
|
|
71
75
|
return new _reporters.ProgressReporter({
|
|
72
76
|
concurrency,
|
|
73
|
-
version
|
|
77
|
+
version,
|
|
78
|
+
logMemory
|
|
74
79
|
});
|
|
75
80
|
case "verboseFileLog":
|
|
76
81
|
case "vfl":
|
|
77
|
-
return new _reporters.VerboseFileLogReporter(logFile);
|
|
82
|
+
return new _reporters.VerboseFileLogReporter(logFile, undefined, logMemory);
|
|
78
83
|
}
|
|
79
84
|
// Check if it's a custom reporter defined in config
|
|
80
85
|
if (customReportersOptions?.customReporters?.[reporter]) {
|
|
@@ -84,24 +89,28 @@ async function createReporter(reporter, options, customReportersOptions) {
|
|
|
84
89
|
if (process.env.GITHUB_ACTIONS) {
|
|
85
90
|
return new _reporters.GithubActionsReporter({
|
|
86
91
|
grouped: true,
|
|
87
|
-
logLevel: verbose ? _logger.LogLevel.verbose : logLevel
|
|
92
|
+
logLevel: verbose ? _logger.LogLevel.verbose : logLevel,
|
|
93
|
+
logMemory
|
|
88
94
|
});
|
|
89
95
|
}
|
|
90
96
|
if (process.env.TF_BUILD) {
|
|
91
97
|
return new _reporters.AdoReporter({
|
|
92
98
|
grouped: true,
|
|
93
|
-
logLevel: verbose ? _logger.LogLevel.verbose : logLevel
|
|
99
|
+
logLevel: verbose ? _logger.LogLevel.verbose : logLevel,
|
|
100
|
+
logMemory
|
|
94
101
|
});
|
|
95
102
|
}
|
|
96
103
|
if (progress && (0, _isinteractive.default)() && !(logLevel >= _logger.LogLevel.verbose || verbose || grouped)) {
|
|
97
104
|
return new _reporters.BasicReporter({
|
|
98
105
|
concurrency,
|
|
99
|
-
version
|
|
106
|
+
version,
|
|
107
|
+
logMemory
|
|
100
108
|
});
|
|
101
109
|
}
|
|
102
110
|
return new _reporters.LogReporter({
|
|
103
111
|
grouped,
|
|
104
|
-
logLevel: verbose ? _logger.LogLevel.verbose : logLevel
|
|
112
|
+
logLevel: verbose ? _logger.LogLevel.verbose : logLevel,
|
|
113
|
+
logMemory
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
116
|
async function loadCustomReporterModule(reporter, options, customReportersOptions) {
|
|
@@ -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 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,
|
|
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, logMemory } = 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, logMemory });\n case \"azureDevops\":\n case \"adoLog\":\n return new AdoReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel, logMemory });\n\n case \"githubActions\":\n case \"gha\":\n return new GithubActionsReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel, logMemory });\n\n case \"npmLog\":\n case \"old\":\n return new LogReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel, logMemory });\n\n case \"fancy\":\n return new ProgressReporter({ concurrency, version, logMemory });\n\n case \"verboseFileLog\":\n case \"vfl\":\n return new VerboseFileLogReporter(logFile, undefined, logMemory);\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, logMemory });\n }\n\n if (process.env.TF_BUILD) {\n return new AdoReporter({ grouped: true, logLevel: verbose ? LogLevel.verbose : logLevel, logMemory });\n }\n\n if (progress && isInteractive() && !(logLevel >= LogLevel.verbose || verbose || grouped)) {\n return new BasicReporter({ concurrency, version, logMemory });\n }\n\n return new LogReporter({ grouped, logLevel: verbose ? LogLevel.verbose : logLevel, logMemory });\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","logMemory","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,EAAEC,SAAS,EAAE,GAAGX;IACnH,MAAMI,WAAWQ,gBAAQ,CAACP,aAAa;IAEvC,MAAMQ,WAAWC,IAAAA,+BAAe,EAACC;IACjC,MAAMC,cAAcC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACC,aAAI,CAACC,IAAI,CAACT,UAAU,iBAAiB;IACpF,MAAMU,UAAUP,YAAYO,OAAO;IAEnC,OAAQxB;QACN,KAAK;YACH,OAAO,IAAIyB,oCAAyB,CAAC;gBACnClB;gBACAmB,YAAY,OAAOlB,YAAY,WA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9C,SAAS,MAAM,EAAE2C,aAAa,EAAE,EAAEc,OAAO;AAC/E"}
|
|
@@ -42,7 +42,7 @@ function simulateFileAccess(logger, root, inputs, outputs) {
|
|
|
42
42
|
} else {
|
|
43
43
|
inputDirectories.add(input);
|
|
44
44
|
}
|
|
45
|
-
} catch
|
|
45
|
+
} catch {
|
|
46
46
|
// ignore
|
|
47
47
|
}
|
|
48
48
|
// Add all directory parts to the set
|
|
@@ -52,7 +52,7 @@ function simulateFileAccess(logger, root, inputs, outputs) {
|
|
|
52
52
|
try {
|
|
53
53
|
// Simulate enumerating a directory
|
|
54
54
|
_fs.default.readdirSync(_path.default.join(root, directory));
|
|
55
|
-
} catch
|
|
55
|
+
} catch {
|
|
56
56
|
// ignore
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -64,14 +64,14 @@ function simulateFileAccess(logger, root, inputs, outputs) {
|
|
|
64
64
|
getAllDirectoryParts(output).forEach((dir)=>outputDirectories.add(dir));
|
|
65
65
|
try {
|
|
66
66
|
_fs.default.utimesSync(_path.default.join(root, output), time, time);
|
|
67
|
-
} catch
|
|
67
|
+
} catch {
|
|
68
68
|
// ignore
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
for (const directory of outputDirectories){
|
|
72
72
|
try {
|
|
73
73
|
_fs.default.utimesSync(_path.default.join(root, directory), time, time);
|
|
74
|
-
} catch
|
|
74
|
+
} catch {
|
|
75
75
|
// ignore
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/exec/simulateFileAccess.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport function simulateFileAccess(logger: Logger, root: string, inputs: string[], outputs: string[]): void {\n logger.silly(\"Now probing and touching inputs and outputs\");\n\n // Helper to get all directory parts up to root\n const getAllDirectoryParts = (filePath: string): string[] => {\n const parts: string[] = [];\n let dirPath = path.dirname(filePath);\n\n while (dirPath !== \".\" && dirPath !== \"\") {\n parts.push(dirPath);\n dirPath = path.dirname(dirPath);\n }\n\n return parts;\n };\n\n const inputDirectories = new Set<string>();\n\n // read input files\n let fd: number;\n const buffer: Buffer = Buffer.alloc(1);\n for (const input of inputs) {\n try {\n const inputPath = path.join(root, input);\n if (!fs.lstatSync(inputPath).isDirectory()) {\n fd = fs.openSync(inputPath, \"r\");\n // Simulate a file content read by reading 1 byte of the opened file handle\n fs.readSync(fd, buffer, 0, 1, 0);\n fs.closeSync(fd);\n } else {\n inputDirectories.add(input);\n }\n } catch
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/exec/simulateFileAccess.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport function simulateFileAccess(logger: Logger, root: string, inputs: string[], outputs: string[]): void {\n logger.silly(\"Now probing and touching inputs and outputs\");\n\n // Helper to get all directory parts up to root\n const getAllDirectoryParts = (filePath: string): string[] => {\n const parts: string[] = [];\n let dirPath = path.dirname(filePath);\n\n while (dirPath !== \".\" && dirPath !== \"\") {\n parts.push(dirPath);\n dirPath = path.dirname(dirPath);\n }\n\n return parts;\n };\n\n const inputDirectories = new Set<string>();\n\n // read input files\n let fd: number;\n const buffer: Buffer = Buffer.alloc(1);\n for (const input of inputs) {\n try {\n const inputPath = path.join(root, input);\n if (!fs.lstatSync(inputPath).isDirectory()) {\n fd = fs.openSync(inputPath, \"r\");\n // Simulate a file content read by reading 1 byte of the opened file handle\n fs.readSync(fd, buffer, 0, 1, 0);\n fs.closeSync(fd);\n } else {\n inputDirectories.add(input);\n }\n } catch {\n // ignore\n }\n\n // Add all directory parts to the set\n getAllDirectoryParts(input).forEach((dir) => inputDirectories.add(dir));\n }\n\n for (const directory of inputDirectories) {\n try {\n // Simulate enumerating a directory\n fs.readdirSync(path.join(root, directory));\n } catch {\n // ignore\n }\n }\n\n // touch output files\n const time = new Date();\n const outputDirectories = new Set<string>();\n for (const output of outputs) {\n // Add all directory parts to the set\n getAllDirectoryParts(output).forEach((dir) => outputDirectories.add(dir));\n\n try {\n fs.utimesSync(path.join(root, output), time, time);\n } catch {\n // ignore\n }\n }\n\n for (const directory of outputDirectories) {\n try {\n fs.utimesSync(path.join(root, directory), time, time);\n } catch {\n // ignore\n }\n }\n}\n"],"names":["simulateFileAccess","logger","root","inputs","outputs","silly","getAllDirectoryParts","filePath","parts","dirPath","path","dirname","push","inputDirectories","Set","fd","buffer","Buffer","alloc","input","inputPath","join","fs","lstatSync","isDirectory","openSync","readSync","closeSync","add","forEach","dir","directory","readdirSync","time","Date","outputDirectories","output","utimesSync"],"mappings":";;;;+BAIgBA;;;eAAAA;;;6DAHC;2DACF;;;;;;AAER,SAASA,mBAAmBC,MAAc,EAAEC,IAAY,EAAEC,MAAgB,EAAEC,OAAiB;IAClGH,OAAOI,KAAK,CAAC;IAEb,+CAA+C;IAC/C,MAAMC,uBAAuB,CAACC;QAC5B,MAAMC,QAAkB,EAAE;QAC1B,IAAIC,UAAUC,aAAI,CAACC,OAAO,CAACJ;QAE3B,MAAOE,YAAY,OAAOA,YAAY,GAAI;YACxCD,MAAMI,IAAI,CAACH;YACXA,UAAUC,aAAI,CAACC,OAAO,CAACF;QACzB;QAEA,OAAOD;IACT;IAEA,MAAMK,mBAAmB,IAAIC;IAE7B,mBAAmB;IACnB,IAAIC;IACJ,MAAMC,SAAiBC,OAAOC,KAAK,CAAC;IACpC,KAAK,MAAMC,SAAShB,OAAQ;QAC1B,IAAI;YACF,MAAMiB,YAAYV,aAAI,CAACW,IAAI,CAACnB,MAAMiB;YAClC,IAAI,CAACG,WAAE,CAACC,SAAS,CAACH,WAAWI,WAAW,IAAI;gBAC1CT,KAAKO,WAAE,CAACG,QAAQ,CAACL,WAAW;gBAC5B,2EAA2E;gBAC3EE,WAAE,CAACI,QAAQ,CAACX,IAAIC,QAAQ,GAAG,GAAG;gBAC9BM,WAAE,CAACK,SAAS,CAACZ;YACf,OAAO;gBACLF,iBAAiBe,GAAG,CAACT;YACvB;QACF,EAAE,OAAM;QACN,SAAS;QACX;QAEA,qCAAqC;QACrCb,qBAAqBa,OAAOU,OAAO,CAAC,CAACC,MAAQjB,iBAAiBe,GAAG,CAACE;IACpE;IAEA,KAAK,MAAMC,aAAalB,iBAAkB;QACxC,IAAI;YACF,mCAAmC;YACnCS,WAAE,CAACU,WAAW,CAACtB,aAAI,CAACW,IAAI,CAACnB,MAAM6B;QACjC,EAAE,OAAM;QACN,SAAS;QACX;IACF;IAEA,qBAAqB;IACrB,MAAME,OAAO,IAAIC;IACjB,MAAMC,oBAAoB,IAAIrB;IAC9B,KAAK,MAAMsB,UAAUhC,QAAS;QAC5B,qCAAqC;QACrCE,qBAAqB8B,QAAQP,OAAO,CAAC,CAACC,MAAQK,kBAAkBP,GAAG,CAACE;QAEpE,IAAI;YACFR,WAAE,CAACe,UAAU,CAAC3B,aAAI,CAACW,IAAI,CAACnB,MAAMkC,SAASH,MAAMA;QAC/C,EAAE,OAAM;QACN,SAAS;QACX;IACF;IAEA,KAAK,MAAMF,aAAaI,kBAAmB;QACzC,IAAI;YACFb,WAAE,CAACe,UAAU,CAAC3B,aAAI,CAACW,IAAI,CAACnB,MAAM6B,YAAYE,MAAMA;QAClD,EAAE,OAAM;QACN,SAAS;QACX;IACF;AACF"}
|
|
@@ -32,7 +32,7 @@ const _getBinPaths = require("../../getBinPaths.js");
|
|
|
32
32
|
const _getBuiltInRunners = require("../../getBuiltInRunners.js");
|
|
33
33
|
const _parseServerOption = require("../parseServerOption.js");
|
|
34
34
|
const _optimizeTargetGraph = require("../../optimizeTargetGraph.js");
|
|
35
|
-
const _globby = require("
|
|
35
|
+
const _globby = require("globby");
|
|
36
36
|
const _hasher = require("@lage-run/hasher");
|
|
37
37
|
const _targetHashFilePath = require("../targetHashFilePath.js");
|
|
38
38
|
function _interop_require_default(obj) {
|
|
@@ -113,12 +113,12 @@ async function infoAction(options, command) {
|
|
|
113
113
|
if (globHashCache.has(key)) {
|
|
114
114
|
return globHashCache.get(key);
|
|
115
115
|
}
|
|
116
|
-
const files = (0, _globby.
|
|
116
|
+
const files = (0, _globby.sync)(patterns, opts);
|
|
117
117
|
const hash = (0, _hasher.hashStrings)(Object.values(fileHasher.hash(files.map((file)=>_path.default.join(root, file)))));
|
|
118
118
|
globHashCache.set(key, hash);
|
|
119
119
|
return hash;
|
|
120
120
|
};
|
|
121
|
-
const globalInputs = config.cacheOptions?.environmentGlob ? (0, _globby.
|
|
121
|
+
const globalInputs = config.cacheOptions?.environmentGlob ? (0, _globby.sync)(config.cacheOptions?.environmentGlob, {
|
|
122
122
|
cwd: root
|
|
123
123
|
}) : [
|
|
124
124
|
"lage.config.js"
|
|
@@ -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, 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;eAAAA;;QApIMC;eAAAA;;;mCAtGY;oCACC;wBAET;gCACkD;qCACxC;+DACX;6DACR;2DACF;4BACO;6BAG4C;qCAC9B;yBACD;6BACP;mCACM;mCACA;qCACE;wBACf;wBACmB;oCACG;;;;;;AAiFpC,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,OAAOC,IAAAA,uCAAuB,EAACV,QAAQA;IAC7C,MAAMW,IAAAA,wCAAmB,EAACP,QAAQN,SAAS;QAAEc,iBAAiBV,OAAOW,SAAS;QAAEJ;IAAK;IAErF,MAAMK,eAAeC,IAAAA,+BAAe,EAACN;IAErC,MAAM,EAAEO,KAAK,EAAEC,QAAQ,EAAE,GAAGC,IAAAA,sCAAkB,EAACnB,QAAQoB,IAAI;IAE3D,MAAMC,cAAc,MAAMC,IAAAA,oCAAiB,EAAC;QAC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AAO,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"}
|
|
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 { sync as globbySync } from \"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 = globbySync(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 ? globbySync(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","globbySync","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;eAAAA;;QApIMC;eAAAA;;;mCAtGY;oCACC;wBAET;gCACkD;qCACxC;+DACX;6DACR;2DACF;4BACO;6BAG4C;qCAC9B;yBACD;6BACP;mCACM;mCACA;qCACE;wBACD;wBACK;oCACG;;;;;;AAiFpC,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,OAAOC,IAAAA,uCAAuB,EAACV,QAAQA;IAC7C,MAAMW,IAAAA,wCAAmB,EAACP,QAAQN,SAAS;QAAEc,iBAAiBV,OAAOW,SAAS;QAAEJ;IAAK;IAErF,MAAMK,eAAeC,IAAAA,+BAAe,EAACN;IAErC,MAAM,EAAEO,KAAK,EAAEC,QAAQ,EAAE,GAAGC,IAAAA,sCAAkB,EAACnB,QAAQoB,IAAI;IAE3D,MAAMC,cAAc,MAAMC,IAAAA,oCAAiB,EAAC;QAC1CjB;QACAK;QACAa,cAAcxB,QAAQwB,YAAY;QAClCC,YAAYzB,QAAQyB,UAAU,IAAI,CAACzB,QAAQ0B,EAAE;QAC7CC,QAAQ3B,QAAQ2B,MAAM,CAACC,MAAM,CAACxB,OAAOuB,MAAM;QAC3CE,UAAUzB,OAAOyB,QAAQ;QACzBC,iBAAiB1B,OAAO0B,e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
@@ -13,13 +13,14 @@ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
|
13
13
|
const _properlockfile = /*#__PURE__*/ _interop_require_default(require("proper-lockfile"));
|
|
14
14
|
const _execa = /*#__PURE__*/ _interop_require_default(require("execa"));
|
|
15
15
|
const _getBinPaths = require("../getBinPaths.js");
|
|
16
|
+
const _cache = require("@lage-run/cache");
|
|
16
17
|
function _interop_require_default(obj) {
|
|
17
18
|
return obj && obj.__esModule ? obj : {
|
|
18
19
|
default: obj
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
async function launchServerInBackground({ logger, root, host, port, tasks, timeout, args, nodeArg }) {
|
|
22
|
-
const lockfilePath = _path.default.join(root,
|
|
23
|
+
const lockfilePath = _path.default.join((0, _cache.getCacheDirectoryRoot)(root), `.lage-server-${host}-${port}.pid`);
|
|
23
24
|
logger.info(`Starting server on http://${host}:${port}`);
|
|
24
25
|
logger.info(`acquiring lock: ${lockfilePath}`);
|
|
25
26
|
ensurePidFile(lockfilePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/launchServerInBackground.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport execa from \"execa\";\nimport { getBinScripts } from \"../getBinPaths.js\";\n\nexport interface LaunchServerInBackgroundOptions {\n logger: Logger;\n root: string;\n host: string;\n port: number;\n tasks: string[];\n timeout: number;\n args: string[];\n nodeArg?: string;\n}\n\nexport async function launchServerInBackground({\n logger,\n root,\n host,\n port,\n tasks,\n timeout,\n args,\n nodeArg,\n}: LaunchServerInBackgroundOptions): Promise<void> {\n const lockfilePath = path.join(root,
|
|
1
|
+
{"version":3,"sources":["../../src/commands/launchServerInBackground.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport execa from \"execa\";\nimport { getBinScripts } from \"../getBinPaths.js\";\nimport { getCacheDirectoryRoot } from \"@lage-run/cache\";\n\nexport interface LaunchServerInBackgroundOptions {\n logger: Logger;\n root: string;\n host: string;\n port: number;\n tasks: string[];\n timeout: number;\n args: string[];\n nodeArg?: string;\n}\n\nexport async function launchServerInBackground({\n logger,\n root,\n host,\n port,\n tasks,\n timeout,\n args,\n nodeArg,\n}: LaunchServerInBackgroundOptions): Promise<void> {\n const lockfilePath = path.join(getCacheDirectoryRoot(root), `.lage-server-${host}-${port}.pid`);\n\n logger.info(`Starting server on http://${host}:${port}`);\n logger.info(`acquiring lock: ${lockfilePath}`);\n\n ensurePidFile(lockfilePath);\n\n const releaseLock = await lockfile.lock(lockfilePath, {\n stale: 1000 * 60 * 1,\n retries: {\n retries: 10,\n factor: 3,\n minTimeout: 0.5 * 1000,\n maxTimeout: 60 * 1000,\n randomize: true,\n },\n });\n\n const pid = parseInt(fs.readFileSync(lockfilePath, \"utf-8\"));\n const isServerRunning = pid && isAlive(pid);\n logger.info(\"Checking if server is already running\", { pid, isServerRunning });\n if (pid && isServerRunning) {\n logger.info(\"Server already running\", { pid });\n } else {\n const binScripts = getBinScripts();\n\n const lageServerBinPath = binScripts[\"lage-server\"];\n const lageServerArgs = [\n ...(nodeArg ? [\"--node-arg\", nodeArg] : []),\n lageServerBinPath,\n \"--tasks\",\n ...tasks,\n \"--server\",\n `${host}:${port}`,\n \"--timeout\",\n `${timeout}`,\n ...args,\n ];\n\n logger.info(`Launching lage-server with these parameters: ${lageServerArgs.join(\" \")}`);\n const child = execa(\"node\", lageServerArgs, {\n cwd: root,\n detached: true,\n stdio: \"ignore\",\n maxBuffer: 1024 * 1024 * 100,\n });\n\n if (child.pid) {\n fs.writeFileSync(lockfilePath, child.pid.toString());\n }\n\n child.unref();\n logger.info(\"Server started\", { pid: child.pid });\n }\n\n await releaseLock();\n}\n\nfunction ensurePidFile(lockfilePath: string) {\n if (!fs.existsSync(path.dirname(lockfilePath))) {\n fs.mkdirSync(path.dirname(lockfilePath), { recursive: true });\n }\n\n if (!fs.existsSync(lockfilePath)) {\n try {\n const fd = fs.openSync(lockfilePath, \"w\");\n fs.closeSync(fd);\n } catch {\n // ignore\n }\n }\n}\n\nfunction isAlive(pid: number) {\n try {\n return process.kill(pid, 0);\n } catch {\n return false;\n }\n}\n"],"names":["launchServerInBackground","logger","root","host","port","tasks","timeout","args","nodeArg","lockfilePath","path","join","getCacheDirectoryRoot","info","ensurePidFile","releaseLock","lockfile","lock","stale","retries","factor","minTimeout","maxTimeout","randomize","pid","parseInt","fs","readFileSync","isServerRunning","isAlive","binScripts","getBinScripts","lageServerBinPath","lageServerArgs","child","execa","cwd","detached","stdio","maxBuffer","writeFileSync","toString","unref","existsSync","dirname","mkdirSync","recursive","fd","openSync","closeSync","process","kill"],"mappings":";;;;+BAmBsBA;;;eAAAA;;;2DAlBP;6DACE;uEACI;8DACH;6BACY;uBACQ;;;;;;AAa/B,eAAeA,yBAAyB,EAC7CC,MAAM,EACNC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,KAAK,EACLC,OAAO,EACPC,IAAI,EACJC,OAAO,EACyB;IAChC,MAAMC,eAAeC,aAAI,CAACC,IAAI,CAACC,IAAAA,4BAAqB,EAACV,OAAO,CAAC,aAAa,EAAEC,KAAK,CAAC,EAAEC,KAAK,IAAI,CAAC;IAE9FH,OAAOY,IAAI,CAAC,CAAC,0BAA0B,EAAEV,KAAK,CAAC,EAAEC,MAAM;IACvDH,OAAOY,IAAI,CAAC,CAAC,gBAAgB,EAAEJ,cAAc;IAE7CK,cAAcL;IAEd,MAAMM,cAAc,MAAMC,uBAAQ,CAACC,IAAI,CAACR,cAAc;QACpDS,OAAO,OAAO,KAAK;QACnBC,SAAS;YACPA,SAAS;YACTC,QAAQ;YACRC,YAAY,MAAM;YAClBC,YAAY,KAAK;YACjBC,WAAW;QACb;IACF;IAEA,MAAMC,MAAMC,SAASC,WAAE,CAACC,YAAY,CAAClB,cAAc;IACnD,MAAMmB,k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;QACX;IACF;AACF;AAEA,SAASlB,QAAQL,GAAW;IAC1B,IAAI;QACF,OAAO0B,QAAQC,IAAI,CAAC3B,KAAK;IAC3B,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
package/lib/commands/options.js
CHANGED
|
@@ -46,7 +46,8 @@ const options = {
|
|
|
46
46
|
profile: new _commander.Option("--profile [profile]", "writes a run profile into a file that can be processed by Chromium devtool"),
|
|
47
47
|
continue: new _commander.Option("--continue", "continues the run even on error"),
|
|
48
48
|
allowNoTargetRuns: new _commander.Option("--allow-no-target-runs", "succeed even if no targets match the given name"),
|
|
49
|
-
watch: new _commander.Option("--watch", "runs in watch mode")
|
|
49
|
+
watch: new _commander.Option("--watch", "runs in watch mode"),
|
|
50
|
+
logMemory: new _commander.Option("--log-memory", "log main process memory usage at task completion").default(false)
|
|
50
51
|
},
|
|
51
52
|
server: {
|
|
52
53
|
server: new _commander.Option("--server [host:port]", "Run targets of type 'worker' on a background service"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/options.ts"],"sourcesContent":["import { Option } from \"commander\";\nimport { logBuiltInReporterNames } from \"../types/ReporterInitOptions.js\";\n\nconst isCI = process.env.CI || process.env.TF_BUILD;\n\ninterface Options {\n // Groupings of options\n logger: { [key: string]: Option };\n pool: { [key: string]: Option };\n runner: { [key: string]: Option };\n run: { [key: string]: Option };\n server: { [key: string]: Option };\n filter: { [key: string]: Option };\n affected: { [key: string]: Option };\n cache: { [key: string]: Option };\n info: { [key: string]: Option };\n}\n\nconst options: Options = {\n logger: {\n reporter: new Option(\"--reporter <reporter...>\", `log reporter (built-in choices: ${logBuiltInReporterNames.join(\", \")})`),\n grouped: new Option(\"--grouped\", \"groups the logs\").default(false),\n progress: new Option(\"--progress\", \"show progress\").conflicts([\"reporter\", \"grouped\", \"verbose\"]).default(!isCI),\n logLevel: new Option(\"--log-level <level>\", \"log level\").choices([\"info\", \"warn\", \"error\", \"verbose\", \"silly\"]).conflicts(\"verbose\"),\n logFile: new Option(\"--log-file <file>\", \"when used with --reporter vfl, writes verbose, ungrouped logs to the specified file\"),\n verbose: new Option(\"--verbose\", \"verbose output\").default(false),\n indented: new Option(\"--indented\", \"enabled indentation of the JSON output\").default(false),\n },\n pool: {\n concurrency: new Option(\"-c|--concurrency <number>\", \"max jobs to run at a time\").argParser((v) => parseInt(v)),\n continue: new Option(\"--continue\", \"continue running even after encountering an error for one of the targets\"),\n maxWorkersPerTask: new Option(\n \"--max-workers-per-task <values...>\",\n \"set max worker per task, e.g. --max-workers-per-task build=2 test=4\"\n ).default([]),\n },\n runner: {\n nodeArg: new Option(\n \"-n|--node-arg <arg>\",\n 'node arguments for workers and child processes (like NODE_OPTIONS) as a single string (e.g. --node-arg=\"--max_old_space_size=1234 --heap-prof\")'\n ),\n },\n run: {\n cache: new Option(\"--no-cache\", \"disables the cache\"),\n resetCache: new Option(\"--reset-cache\", \"resets the cache, filling it after a run\"),\n skipLocalCache: new Option(\"--skip-local-cache\", \"skips caching locally (defaults to true in CI environments)\").default(isCI),\n profile: new Option(\"--profile [profile]\", \"writes a run profile into a file that can be processed by Chromium devtool\"),\n continue: new Option(\"--continue\", \"continues the run even on error\"),\n allowNoTargetRuns: new Option(\"--allow-no-target-runs\", \"succeed even if no targets match the given name\"),\n watch: new Option(\"--watch\", \"runs in watch mode\"),\n },\n server: {\n server: new Option(\"--server [host:port]\", \"Run targets of type 'worker' on a background service\"),\n tasks: new Option(\"--tasks <tasks...>\", \"A list of tasks to run, separated by space e.g. 'build test'\"),\n timeout: new Option(\"-t|--timeout <seconds>\", \"lage server autoshutoff timeout\").default(5 * 60).argParser((v) => parseInt(v)),\n },\n filter: {\n scope: new Option(\n \"--scope <scope...>\",\n \"scopes the run to a subset of packages (by default, includes the dependencies and dependents as well)\"\n ),\n noDeps: new Option(\"--no-deps|--no-dependents\", \"disables running any dependents of the scoped packages\"),\n includeDependencies: new Option(\n \"--include-dependencies|--dependencies\",\n 'adds the scoped packages dependencies as the \"entry points\" for the target graph run'\n ),\n to: new Option(\"--to <scope...>\", \"runs up to a package (shorthand for --scope=<scope...> --no-dependents)\"),\n since: new Option(\"--since <since>\", \"only runs packages that have changed since the given commit, tag, or branch\"),\n ignore: new Option(\n \"--ignore <ignore...>\",\n \"ignores files when calculating the scope with `--since` in addition to the files specified in lage.config\"\n ).default([]),\n },\n affected: {\n outputFormat: new Option(\n \"--output-format <graph|json|default>\",\n `Generate a report about what packages are affected by the current change (defaults to human readable format). ` +\n `\"graph\" will generate a GraphViz .dot file format`\n ),\n },\n cache: {\n prune: new Option(\"--prune <days>\", \"Prunes cache older than certain number of <days>\").argParser(parseInt).conflicts(\"--clear\"),\n clear: new Option(\"--clear\", \"Clears the cache locally\"),\n },\n info: {\n outputFile: new Option(\"-o|--output-file <file>\", \"Output the target graph as json to the specified file.\"),\n noOptimizeGraph: new Option(\"--no-optimize-graph\", \"Do not optimize the target graph\"),\n },\n} as const;\n\nconst optionsWithEnv: Options = addEnvOptions(options);\n\nfunction addEnvOptions(opts: typeof options) {\n for (const key in opts) {\n for (const [name, option] of Object.entries<Option>((opts as any)[key])) {\n // convert the camel cased name to uppercase with underscores\n const upperCaseSnakeKey = key.replace(/([A-Z])/g, \"_$1\").toUpperCase();\n const upperCaseSnakeName = name.replace(/([A-Z])/g, \"_$1\").toUpperCase();\n option.env(`LAGE_${upperCaseSnakeKey}_${upperCaseSnakeName}`);\n }\n }\n\n return opts;\n}\n\nexport { optionsWithEnv as options };\n"],"names":["options","optionsWithEnv","isCI","process","env","CI","TF_BUILD","logger","reporter","Option","logBuiltInReporterNames","join","grouped","default","progress","conflicts","logLevel","choices","logFile","verbose","indented","pool","concurrency","argParser","v","parseInt","continue","maxWorkersPerTask","runner","nodeArg","run","cache","resetCache","skipLocalCache","profile","allowNoTargetRuns","watch","server","tasks","timeout","filter","scope","noDeps","includeDependencies","to","since","ignore","affected","outputFormat","prune","clear","info","outputFile","noOptimizeGraph","addEnvOptions","opts","key","name","option","Object","entries","upperCaseSnakeKey","replace","toUpperCase","upperCaseSnakeName"],"mappings":";;;;+
|
|
1
|
+
{"version":3,"sources":["../../src/commands/options.ts"],"sourcesContent":["import { Option } from \"commander\";\nimport { logBuiltInReporterNames } from \"../types/ReporterInitOptions.js\";\n\nconst isCI = process.env.CI || process.env.TF_BUILD;\n\ninterface Options {\n // Groupings of options\n logger: { [key: string]: Option };\n pool: { [key: string]: Option };\n runner: { [key: string]: Option };\n run: { [key: string]: Option };\n server: { [key: string]: Option };\n filter: { [key: string]: Option };\n affected: { [key: string]: Option };\n cache: { [key: string]: Option };\n info: { [key: string]: Option };\n}\n\nconst options: Options = {\n logger: {\n reporter: new Option(\"--reporter <reporter...>\", `log reporter (built-in choices: ${logBuiltInReporterNames.join(\", \")})`),\n grouped: new Option(\"--grouped\", \"groups the logs\").default(false),\n progress: new Option(\"--progress\", \"show progress\").conflicts([\"reporter\", \"grouped\", \"verbose\"]).default(!isCI),\n logLevel: new Option(\"--log-level <level>\", \"log level\").choices([\"info\", \"warn\", \"error\", \"verbose\", \"silly\"]).conflicts(\"verbose\"),\n logFile: new Option(\"--log-file <file>\", \"when used with --reporter vfl, writes verbose, ungrouped logs to the specified file\"),\n verbose: new Option(\"--verbose\", \"verbose output\").default(false),\n indented: new Option(\"--indented\", \"enabled indentation of the JSON output\").default(false),\n },\n pool: {\n concurrency: new Option(\"-c|--concurrency <number>\", \"max jobs to run at a time\").argParser((v) => parseInt(v)),\n continue: new Option(\"--continue\", \"continue running even after encountering an error for one of the targets\"),\n maxWorkersPerTask: new Option(\n \"--max-workers-per-task <values...>\",\n \"set max worker per task, e.g. --max-workers-per-task build=2 test=4\"\n ).default([]),\n },\n runner: {\n nodeArg: new Option(\n \"-n|--node-arg <arg>\",\n 'node arguments for workers and child processes (like NODE_OPTIONS) as a single string (e.g. --node-arg=\"--max_old_space_size=1234 --heap-prof\")'\n ),\n },\n run: {\n cache: new Option(\"--no-cache\", \"disables the cache\"),\n resetCache: new Option(\"--reset-cache\", \"resets the cache, filling it after a run\"),\n skipLocalCache: new Option(\"--skip-local-cache\", \"skips caching locally (defaults to true in CI environments)\").default(isCI),\n profile: new Option(\"--profile [profile]\", \"writes a run profile into a file that can be processed by Chromium devtool\"),\n continue: new Option(\"--continue\", \"continues the run even on error\"),\n allowNoTargetRuns: new Option(\"--allow-no-target-runs\", \"succeed even if no targets match the given name\"),\n watch: new Option(\"--watch\", \"runs in watch mode\"),\n logMemory: new Option(\"--log-memory\", \"log main process memory usage at task completion\").default(false),\n },\n server: {\n server: new Option(\"--server [host:port]\", \"Run targets of type 'worker' on a background service\"),\n tasks: new Option(\"--tasks <tasks...>\", \"A list of tasks to run, separated by space e.g. 'build test'\"),\n timeout: new Option(\"-t|--timeout <seconds>\", \"lage server autoshutoff timeout\").default(5 * 60).argParser((v) => parseInt(v)),\n },\n filter: {\n scope: new Option(\n \"--scope <scope...>\",\n \"scopes the run to a subset of packages (by default, includes the dependencies and dependents as well)\"\n ),\n noDeps: new Option(\"--no-deps|--no-dependents\", \"disables running any dependents of the scoped packages\"),\n includeDependencies: new Option(\n \"--include-dependencies|--dependencies\",\n 'adds the scoped packages dependencies as the \"entry points\" for the target graph run'\n ),\n to: new Option(\"--to <scope...>\", \"runs up to a package (shorthand for --scope=<scope...> --no-dependents)\"),\n since: new Option(\"--since <since>\", \"only runs packages that have changed since the given commit, tag, or branch\"),\n ignore: new Option(\n \"--ignore <ignore...>\",\n \"ignores files when calculating the scope with `--since` in addition to the files specified in lage.config\"\n ).default([]),\n },\n affected: {\n outputFormat: new Option(\n \"--output-format <graph|json|default>\",\n `Generate a report about what packages are affected by the current change (defaults to human readable format). ` +\n `\"graph\" will generate a GraphViz .dot file format`\n ),\n },\n cache: {\n prune: new Option(\"--prune <days>\", \"Prunes cache older than certain number of <days>\").argParser(parseInt).conflicts(\"--clear\"),\n clear: new Option(\"--clear\", \"Clears the cache locally\"),\n },\n info: {\n outputFile: new Option(\"-o|--output-file <file>\", \"Output the target graph as json to the specified file.\"),\n noOptimizeGraph: new Option(\"--no-optimize-graph\", \"Do not optimize the target graph\"),\n },\n} as const;\n\nconst optionsWithEnv: Options = addEnvOptions(options);\n\nfunction addEnvOptions(opts: typeof options) {\n for (const key in opts) {\n for (const [name, option] of Object.entries<Option>((opts as any)[key])) {\n // convert the camel cased name to uppercase with underscores\n const upperCaseSnakeKey = key.replace(/([A-Z])/g, \"_$1\").toUpperCase();\n const upperCaseSnakeName = name.replace(/([A-Z])/g, \"_$1\").toUpperCase();\n option.env(`LAGE_${upperCaseSnakeKey}_${upperCaseSnakeName}`);\n }\n }\n\n return opts;\n}\n\nexport { optionsWithEnv as options };\n"],"names":["options","optionsWithEnv","isCI","process","env","CI","TF_BUILD","logger","reporter","Option","logBuiltInReporterNames","join","grouped","default","progress","conflicts","logLevel","choices","logFile","verbose","indented","pool","concurrency","argParser","v","parseInt","continue","maxWorkersPerTask","runner","nodeArg","run","cache","resetCache","skipLocalCache","profile","allowNoTargetRuns","watch","logMemory","server","tasks","timeout","filter","scope","noDeps","includeDependencies","to","since","ignore","affected","outputFormat","prune","clear","info","outputFile","noOptimizeGraph","addEnvOptions","opts","key","name","option","Object","entries","upperCaseSnakeKey","replace","toUpperCase","upperCaseSnakeName"],"mappings":";;;;+BA0G2BA;;;eAAlBC;;;2BA1Gc;qCACiB;AAExC,MAAMC,OAAOC,QAAQC,GAAG,CAACC,EAAE,IAAIF,QAAQC,GAAG,CAACE,QAAQ;AAenD,MAAMN,UAAmB;IACvBO,QAAQ;QACNC,UAAU,IAAIC,iBAAM,CAAC,4BAA4B,CAAC,gCAAgC,EAAEC,4CAAuB,CAACC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzHC,SAAS,IAAIH,iBAAM,CAAC,aAAa,mBAAmBI,OAAO,CAAC;QAC5DC,UAAU,IAAIL,iBAAM,CAAC,cAAc,iBAAiBM,SAAS,CAAC;YAAC;YAAY;YAAW;SAAU,EAAEF,OAAO,CAAC,CAACX;QAC3Gc,UAAU,IAAIP,iBAAM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QAEFkC,QAAQ,IAAIlC,iBAAM,CAAC,6BAA6B;QAChDmC,qBAAqB,IAAInC,iBAAM,CAC7B,yCACA;QAEFoC,IAAI,IAAIpC,iBAAM,CAAC,mBAAmB;QAClCqC,OAAO,IAAIrC,iBAAM,CAAC,mBAAmB;QACrCsC,QAAQ,IAAItC,iBAAM,CAChB,wBACA,6GACAI,OAAO,CAAC,EAAE;IACd;IACAmC,UAAU;QACRC,cAAc,IAAIxC,iBAAM,CACtB,wCACA,CAAC,8GAA8G,CAAC,GAC9G,CAAC,iDAAiD,CAAC;IAEzD;IACAsB,OAAO;QACLmB,OAAO,IAAIzC,iBAAM,CAAC,kBAAkB,oDAAoDc,SAAS,CAACE,UAAUV,SAAS,CAAC;QACtHoC,OAAO,IAAI1C,iBAAM,CAAC,WAAW;IAC/B;IACA2C,MAAM;QACJC,YAAY,IAAI5C,iBAAM,CAAC,2BAA2B;QAClD6C,iBAAiB,IAAI7C,iBAAM,CAAC,uBAAuB;IACrD;AACF;AAEA,MAAMR,iBAA0BsD,cAAcvD;AAE9C,SAASuD,cAAcC,IAAoB;IACzC,IAAK,MAAMC,OAAOD,KAAM;QACtB,KAAK,MAAM,CAACE,MAAMC,OAAO,IAAIC,OAAOC,OAAO,CAAS,AAACL,IAAY,CAACC,IAAI,EAAG;YACvE,6DAA6D;YAC7D,MAAMK,oBAAoBL,IAAIM,OAAO,CAAC,YAAY,OAAOC,WAAW;YACpE,MAAMC,qBAAqBP,KAAKK,OAAO,CAAC,YAAY,OAAOC,WAAW;YACtEL,OAAOvD,GAAG,CAAC,CAAC,KAAK,EAAE0D,kBAAkB,CAAC,EAAEG,oBAAoB;QAC9D;IACF;IAEA,OAAOT;AACT"}
|
|
@@ -70,9 +70,9 @@ async function createTargetGraph(options) {
|
|
|
70
70
|
// Add lage pipeline configuration in the package.json files.
|
|
71
71
|
// They are configured in the lage field, but without the package id.
|
|
72
72
|
// i.e. having this package.json
|
|
73
|
-
// { "name": "
|
|
73
|
+
// { "name": "foo", "lage": { "transpile": { type: "npmScript" } }}
|
|
74
74
|
// is equivalent to having the following in lage.config.js
|
|
75
|
-
// { pipeline: { "
|
|
75
|
+
// { pipeline: { "foo#transpile": { type: "npmScript" } }
|
|
76
76
|
// We conciously add these 'after' the ones in lage.config.js
|
|
77
77
|
// to indicate that the more specific package.json definition takes
|
|
78
78
|
// precedence over the global lage.config.js.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/run/createTargetGraph.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport { type Priority, type TargetGraph, WorkspaceTargetGraphBuilder } from \"@lage-run/target-graph\";\nimport type { PackageInfos } from \"workspace-tools\";\nimport { getBranchChanges, getDefaultRemoteBranch, getStagedChanges, getUnstagedChanges, getUntrackedChanges } from \"workspace-tools\";\nimport { getFilteredPackages } from \"../../filter/getFilteredPackages.js\";\nimport type { PipelineDefinition } from \"@lage-run/config\";\nimport { hasRepoChanged } from \"../../filter/hasRepoChanged.js\";\n\ninterface CreateTargetGraphOptions {\n logger: Logger;\n root: string;\n dependencies: boolean;\n dependents: boolean;\n since?: string;\n scope?: string[];\n ignore: string[];\n repoWideChanges: string[];\n pipeline: PipelineDefinition;\n outputs: string[];\n tasks: string[];\n packageInfos: PackageInfos;\n priorities: Priority[];\n enableTargetConfigMerging: boolean;\n enablePhantomTargetOptimization: boolean;\n}\n\nfunction getChangedFiles(since: string, cwd: string) {\n const targetBranch = since || getDefaultRemoteBranch({ cwd });\n\n return [\n ...new Set([\n ...(getUntrackedChanges({ cwd }) || []),\n ...(getUnstagedChanges({ cwd }) || []),\n ...(getBranchChanges({ branch: targetBranch, cwd }) || []),\n ...(getStagedChanges({ cwd }) || []),\n ]),\n ];\n}\n\nexport async function createTargetGraph(options: CreateTargetGraphOptions): Promise<TargetGraph> {\n const {\n logger,\n root,\n dependencies,\n dependents,\n enableTargetConfigMerging,\n enablePhantomTargetOptimization,\n since,\n scope,\n repoWideChanges,\n ignore,\n pipeline,\n outputs,\n tasks,\n packageInfos,\n priorities,\n } = options;\n\n const builder = new WorkspaceTargetGraphBuilder({ root, packageInfos, enableTargetConfigMerging, enablePhantomTargetOptimization });\n\n const packages = getFilteredPackages({\n root,\n logger,\n packageInfos,\n includeDependencies: dependencies,\n includeDependents: dependents,\n since,\n scope,\n repoWideChanges,\n sinceIgnoreGlobs: ignore,\n });\n\n let changedFiles: string[] = [];\n\n // TODO: enhancement would be for workspace-tools to implement a \"getChangedPackageFromChangedFiles()\" type function\n // TODO: optimize this so that we don't double up the work to determine if repo has changed\n if (since) {\n if (!hasRepoChanged({ since, root, environmentGlob: repoWideChanges, logger })) {\n changedFiles = getChangedFiles(since, root);\n }\n }\n\n const pipelineEntries = Object.entries(pipeline);\n\n // Add lage pipeline configuration in the package.json files.\n // They are configured in the lage field, but without the package id.\n // i.e. having this package.json\n // { \"name\": \"
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/run/createTargetGraph.ts"],"sourcesContent":["import type { Logger } from \"@lage-run/logger\";\nimport { type Priority, type TargetGraph, WorkspaceTargetGraphBuilder } from \"@lage-run/target-graph\";\nimport type { PackageInfos } from \"workspace-tools\";\nimport { getBranchChanges, getDefaultRemoteBranch, getStagedChanges, getUnstagedChanges, getUntrackedChanges } from \"workspace-tools\";\nimport { getFilteredPackages } from \"../../filter/getFilteredPackages.js\";\nimport type { PipelineDefinition } from \"@lage-run/config\";\nimport { hasRepoChanged } from \"../../filter/hasRepoChanged.js\";\n\ninterface CreateTargetGraphOptions {\n logger: Logger;\n root: string;\n dependencies: boolean;\n dependents: boolean;\n since?: string;\n scope?: string[];\n ignore: string[];\n repoWideChanges: string[];\n pipeline: PipelineDefinition;\n outputs: string[];\n tasks: string[];\n packageInfos: PackageInfos;\n priorities: Priority[];\n enableTargetConfigMerging: boolean;\n enablePhantomTargetOptimization: boolean;\n}\n\nfunction getChangedFiles(since: string, cwd: string) {\n const targetBranch = since || getDefaultRemoteBranch({ cwd });\n\n return [\n ...new Set([\n ...(getUntrackedChanges({ cwd }) || []),\n ...(getUnstagedChanges({ cwd }) || []),\n ...(getBranchChanges({ branch: targetBranch, cwd }) || []),\n ...(getStagedChanges({ cwd }) || []),\n ]),\n ];\n}\n\nexport async function createTargetGraph(options: CreateTargetGraphOptions): Promise<TargetGraph> {\n const {\n logger,\n root,\n dependencies,\n dependents,\n enableTargetConfigMerging,\n enablePhantomTargetOptimization,\n since,\n scope,\n repoWideChanges,\n ignore,\n pipeline,\n outputs,\n tasks,\n packageInfos,\n priorities,\n } = options;\n\n const builder = new WorkspaceTargetGraphBuilder({ root, packageInfos, enableTargetConfigMerging, enablePhantomTargetOptimization });\n\n const packages = getFilteredPackages({\n root,\n logger,\n packageInfos,\n includeDependencies: dependencies,\n includeDependents: dependents,\n since,\n scope,\n repoWideChanges,\n sinceIgnoreGlobs: ignore,\n });\n\n let changedFiles: string[] = [];\n\n // TODO: enhancement would be for workspace-tools to implement a \"getChangedPackageFromChangedFiles()\" type function\n // TODO: optimize this so that we don't double up the work to determine if repo has changed\n if (since) {\n if (!hasRepoChanged({ since, root, environmentGlob: repoWideChanges, logger })) {\n changedFiles = getChangedFiles(since, root);\n }\n }\n\n const pipelineEntries = Object.entries(pipeline);\n\n // Add lage pipeline configuration in the package.json files.\n // They are configured in the lage field, but without the package id.\n // i.e. having this package.json\n // { \"name\": \"foo\", \"lage\": { \"transpile\": { type: \"npmScript\" } }}\n // is equivalent to having the following in lage.config.js\n // { pipeline: { \"foo#transpile\": { type: \"npmScript\" } }\n // We conciously add these 'after' the ones in lage.config.js\n // to indicate that the more specific package.json definition takes\n // precedence over the global lage.config.js.\n for (const [packageId, packageInfo] of Object.entries(packageInfos)) {\n const packageLageDefinition = packageInfo.lage as PipelineDefinition;\n if (packageLageDefinition) {\n for (const [id, definition] of Object.entries(packageLageDefinition)) {\n pipelineEntries.push([packageId + \"#\" + id, definition]);\n }\n }\n }\n\n for (const [id, definition] of pipelineEntries) {\n if (Array.isArray(definition)) {\n builder.addTargetConfig(\n id,\n {\n cache: true,\n dependsOn: definition,\n options: {},\n outputs,\n },\n changedFiles\n );\n } else {\n builder.addTargetConfig(id, definition, changedFiles);\n }\n }\n\n return await builder.build(tasks, packages, priorities);\n}\n"],"names":["createTargetGraph","getChangedFiles","since","cwd","targetBranch","getDefaultRemoteBranch","Set","getUntrackedChanges","getUnstagedChanges","getBranchChanges","branch","getStagedChanges","options","logger","root","dependencies","dependents","enableTargetConfigMerging","enablePhantomTargetOptimization","scope","repoWideChanges","ignore","pipeline","outputs","tasks","packageInfos","priorities","builder","WorkspaceTargetGraphBuilder","packages","getFilteredPackages","includeDependencies","includeDependents","sinceIgnoreGlobs","changedFiles","hasRepoChanged","environmentGlob","pipelineEntries","Object","entries","packageId","packageInfo","packageLageDefinition","lage","id","definition","push","Array","isArray","addTargetConfig","cache","dependsOn","build"],"mappings":";;;;+BAuCsBA;;;eAAAA;;;6BAtCuD;gCAEuC;qCAChF;gCAEL;AAoB/B,SAASC,gBAAgBC,KAAa,EAAEC,GAAW;IACjD,MAAMC,eAAeF,SAASG,IAAAA,sCAAsB,EAAC;QAAEF;IAAI;IAE3D,OAAO;WACF,IAAIG,IAAI;eACLC,IAAAA,mCAAmB,EAAC;gBAAEJ;YAAI,MAAM,EAAE;eAClCK,IAAAA,kCAAkB,EAAC;gBAAEL;YAAI,MAAM,EAAE;eACjCM,IAAAA,gCAAgB,EAAC;gBAAEC,QAAQN;gBAAcD;YAAI,MAAM,EAAE;eACrDQ,IAAAA,gCAAgB,EAAC;gBAAER;YAAI,MAAM,EAAE;SACpC;KACF;AACH;AAEO,eAAeH,kBAAkBY,OAAiC;IACvE,MAAM,EACJC,MAAM,EACNC,IAAI,EACJC,YAAY,EACZC,UAAU,EACVC,yBAAyB,EACzBC,+BAA+B,EAC/BhB,KAAK,EACLiB,KAAK,EACLC,eAAe,EACfC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,KAAK,EACLC,YAAY,EACZC,UAAU,EACX,GAAGd;IAE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@ -97,7 +97,8 @@ async function runAction(options, command) {
|
|
|
97
97
|
...maxWorkersPerTaskMap
|
|
98
98
|
]),
|
|
99
99
|
hasher,
|
|
100
|
-
workerIdleMemoryLimit: config.workerIdleMemoryLimit
|
|
100
|
+
workerIdleMemoryLimit: config.workerIdleMemoryLimit,
|
|
101
|
+
logMemory: options.logMemory
|
|
101
102
|
});
|
|
102
103
|
const optimizedTargets = await (0, _optimizeTargetGraph.optimizeTargetGraph)(targetGraph, scheduler.runnerPicker, false);
|
|
103
104
|
const optimizedGraph = {
|
|
@@ -108,18 +109,15 @@ async function runAction(options, command) {
|
|
|
108
109
|
};
|
|
109
110
|
const summary = await scheduler.run(root, optimizedGraph);
|
|
110
111
|
await scheduler.cleanup();
|
|
111
|
-
displaySummaryAndExit(summary, logger.reporters);
|
|
112
|
-
for (const reporter of reporters){
|
|
113
|
-
reporter.cleanup?.();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function displaySummaryAndExit(summary, reporters) {
|
|
117
112
|
if (summary.results !== "success") {
|
|
118
113
|
process.exitCode = 1;
|
|
119
114
|
}
|
|
120
115
|
for (const reporter of reporters){
|
|
121
116
|
reporter.summarize(summary);
|
|
122
117
|
}
|
|
118
|
+
for (const reporter of reporters){
|
|
119
|
+
await reporter.cleanup?.();
|
|
120
|
+
}
|
|
123
121
|
}
|
|
124
122
|
function validateTargetGraph(targetGraph, allowNoTargetRuns) {
|
|
125
123
|
const visibleTargets = Array.from(targetGraph.targets.values()).filter((target)=>!target.hidden);
|
|
@@ -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, getWorkspaceManagerRoot } from \"workspace-tools\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { SimpleScheduler } from \"@lage-run/scheduler\";\
|
|
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, getWorkspaceManagerRoot } from \"workspace-tools\";\nimport { initializeReporters } from \"../initializeReporters.js\";\nimport { SimpleScheduler } from \"@lage-run/scheduler\";\nimport createLogger from \"@lage-run/logger\";\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport type { FilterOptions } from \"../../types/FilterOptions.js\";\nimport type { TargetGraph } from \"@lage-run/target-graph\";\nimport { NoTargetFoundError } from \"../../types/errors.js\";\nimport { createCache } from \"../../cache/createCacheProvider.js\";\nimport { getBuiltInRunners } from \"../../getBuiltInRunners.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): Promise<void> {\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 root = getWorkspaceManagerRoot(cwd) ?? cwd;\n const reporters = await initializeReporters(logger, { ...options, concurrency }, { customReporters: config.reporters, root });\n\n // Build Target Graph\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 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 ...getBuiltInRunners({ nodeArg: options.nodeArg, npmCmd: 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 logMemory: options.logMemory,\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 if (summary.results !== \"success\") {\n process.exitCode = 1;\n }\n\n for (const reporter of reporters) {\n reporter.summarize(summary);\n }\n\n for (const reporter of reporters) {\n await reporter.cleanup?.();\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","root","getWorkspaceManagerRoot","reporters","initializeReporters","customReporters","packageInfos","getPackageInfos","tasks","taskArgs","filterArgsForTasks","args","targetGraph","createTargetGraph","dependencies","dependents","to","ignore","concat","pipeline","repoWideChanges","scope","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","enablePhantomTargetOptimization","validateTargetGraph","verbose","filteredPipeline","filterPipelineDefinitions","targets","values","maxWorkersPerTaskMap","getMaxWorkersPerTaskFromOptions","maxWorkersPerTask","hasher","createCache","cliArgs","skipLocalCache","scheduler","SimpleScheduler","continueOnError","continue","shouldCache","cache","shouldResetCache","resetCache","workerData","runners","getBuiltInRunners","nodeArg","npmCmd","npmClient","Map","getMaxWorkersPerTask","workerIdleMemoryLimit","logMemory","optimizedTargets","optimizeTargetGraph","runnerPicker","optimizedGraph","map","target","id","summary","run","cleanup","results","exitCode","reporter","summarize","visibleTargets","Array","from","filter","hidden","length","NoTargetFoundError"],"mappings":";;;;+BA6BsBA;;;eAAAA;;;mCA5BY;oCACC;2CACO;wBACuD;gCACxC;qCACrB;2BACJ;+DACP;wBAIU;qCACP;mCACM;qCACE;;;;;;AAc7B,eAAeA,UAAUC,OAAmB,EAAEC,OAAgB;IACnE,MAAMC,MAAMC,QAAQD,GAAG;IACvB,MAAME,SAAS,MAAMC,IAAAA,iBAAS,EAACH;IAE/B,iBAAiB;IACjB,MAAMI,cAAcC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G;IACrB;IAEA,KAAK,MAAMC,YAAYrE,UAAW;QAChCqE,SAASC,SAAS,CAACN;IACrB;IAEA,KAAK,MAAMK,YAAYrE,UAAW;QAChC,MAAMqE,SAASH,OAAO;IACxB;AACF;AAEA,SAASxC,oBAAoBjB,WAAwB,EAAEd,iBAA0B;IAC/E,MAAM4E,iBAAiBC,MAAMC,IAAI,CAAChE,YAAYqB,OAAO,CAACC,MAAM,IAAI2C,MAAM,CAAC,CAACZ,SAAW,CAACA,OAAOa,MAAM;IACjG,IAAIJ,eAAeK,MAAM,KAAK,KAAK,CAACjF,mBAAmB;QACrD,MAAMkF,0BAAkB;IAC1B;AACF"}
|
|
@@ -131,7 +131,7 @@ async function watchAction(options, command) {
|
|
|
131
131
|
});
|
|
132
132
|
// Initial run
|
|
133
133
|
const summary = await scheduler.run(root, targetGraph);
|
|
134
|
-
displaySummary(summary, logger.reporters);
|
|
134
|
+
await displaySummary(summary, logger.reporters);
|
|
135
135
|
logger.info("Running scheduler in watch mode");
|
|
136
136
|
// Disables cache for subsequent runs
|
|
137
137
|
// TODO: support updating hasher + write-only local cacheProvider for subsequent runs
|
|
@@ -153,13 +153,13 @@ async function watchAction(options, command) {
|
|
|
153
153
|
};
|
|
154
154
|
void (async ()=>{
|
|
155
155
|
const deltaSummary = await scheduler.run(root, deltaGraph, true);
|
|
156
|
-
displaySummary(deltaSummary, logger.reporters);
|
|
156
|
+
await displaySummary(deltaSummary, logger.reporters);
|
|
157
157
|
})().catch(()=>{});
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
function displaySummary(summary, reporters) {
|
|
160
|
+
async function displaySummary(summary, reporters) {
|
|
161
161
|
for (const reporter of reporters){
|
|
162
162
|
reporter.summarize(summary);
|
|
163
|
-
reporter.cleanup?.();
|
|
163
|
+
await reporter.cleanup?.();
|
|
164
164
|
}
|
|
165
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/run/watchAction.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { createTargetGraph } from \"./createTargetGraph.js\";\nimport { filterArgsForTasks } from \"./filterArgsForTasks.js\";\nimport { getConfig, getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions, getConcurrency } from \"@lage-run/config\";\nimport { getPackageInfosAsync, getWorkspaceManagerRoot } from \"workspace-tools\";\nimport { filterPipelineDefinitions } from \"./filterPipelineDefinitions.js\";\nimport { LogReporter } from \"@lage-run/reporters\";\nimport { SimpleScheduler } from \"@lage-run/scheduler\";\nimport { watch } from \"./watcher.js\";\
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/run/watchAction.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { createTargetGraph } from \"./createTargetGraph.js\";\nimport { filterArgsForTasks } from \"./filterArgsForTasks.js\";\nimport { getConfig, getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions, getConcurrency } from \"@lage-run/config\";\nimport { getPackageInfosAsync, getWorkspaceManagerRoot } from \"workspace-tools\";\nimport { filterPipelineDefinitions } from \"./filterPipelineDefinitions.js\";\nimport { LogReporter } from \"@lage-run/reporters\";\nimport { SimpleScheduler } from \"@lage-run/scheduler\";\nimport { watch } from \"./watcher.js\";\nimport type { Reporter } from \"@lage-run/logger\";\nimport createLogger, { LogLevel } from \"@lage-run/logger\";\nimport type { ReporterInitOptions } from \"../../types/ReporterInitOptions.js\";\nimport type { SchedulerRunSummary } from \"@lage-run/scheduler-types\";\nimport type { Target } from \"@lage-run/target-graph\";\nimport type { FilterOptions } from \"../../types/FilterOptions.js\";\nimport { createCache } from \"../../cache/createCacheProvider.js\";\nimport { getBuiltInRunners } from \"../../getBuiltInRunners.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 watchAction(options: RunOptions, command: Command): Promise<void> {\n const cwd = process.cwd();\n const config = await getConfig(cwd);\n const concurrency = getConcurrency(options.concurrency, config.concurrency);\n\n // Configure logger\n const logger = createLogger();\n const reporter = new LogReporter({\n logLevel: LogLevel[options.logLevel],\n });\n logger.addReporter(reporter);\n\n // Build Target Graph\n const root = getWorkspaceManagerRoot(process.cwd())!;\n const packageInfos = await getPackageInfosAsync(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 // Make sure we do not attempt writeRemoteCache in watch mode\n config.cacheOptions.writeRemoteCache = false;\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: true,\n workerData: {\n root,\n taskArgs,\n skipLocalCache: options.skipLocalCache,\n cacheOptions: config.cacheOptions,\n runners: {\n ...getBuiltInRunners({ nodeArg: options.nodeArg, npmCmd: config.npmClient, taskArgs }),\n ...config.runners,\n },\n },\n shouldCache: options.cache,\n shouldResetCache: options.resetCache,\n maxWorkersPerTask: new Map([...getMaxWorkersPerTask(filteredPipeline, concurrency), ...maxWorkersPerTaskMap]),\n hasher,\n workerIdleMemoryLimit: config.workerIdleMemoryLimit, // in bytes\n });\n\n // Initial run\n const summary = await scheduler.run(root, targetGraph);\n await displaySummary(summary, logger.reporters);\n\n logger.info(\"Running scheduler in watch mode\");\n\n // Disables cache for subsequent runs\n // TODO: support updating hasher + write-only local cacheProvider for subsequent runs\n for (const targetRun of scheduler.targetRuns.values()) {\n targetRun.options.shouldCache = false;\n }\n\n // When initial run is done, disable fetching of caches on all targets, keep writing to the cache\n const watcher = watch(root, packageInfos);\n watcher.on(\"change\", (packageName) => {\n reporter.resetLogEntries();\n const targets = new Map<string, Target>();\n for (const target of targetGraph.targets.values()) {\n if (target.packageName === packageName) {\n targets.set(target.id, target);\n }\n }\n\n const deltaGraph = { targets };\n\n void (async () => {\n const deltaSummary = await scheduler.run(root, deltaGraph, true);\n await displaySummary(deltaSummary, logger.reporters);\n })().catch(() => {});\n });\n}\n\nasync function displaySummary(summary: SchedulerRunSummary, reporters: Reporter[]) {\n for (const reporter of reporters) {\n reporter.summarize(summary);\n await reporter.cleanup?.();\n }\n}\n"],"names":["watchAction","options","command","cwd","process","config","getConfig","concurrency","getConcurrency","logger","createLogger","reporter","LogReporter","logLevel","LogLevel","addReporter","root","getWorkspaceManagerRoot","packageInfos","getPackageInfosAsync","tasks","taskArgs","filterArgsForTasks","args","targetGraph","createTargetGraph","dependencies","dependents","to","ignore","concat","pipeline","repoWideChanges","scope","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","enablePhantomTargetOptimization","writeRemoteCache","filteredPipeline","filterPipelineDefinitions","targets","values","maxWorkersPerTaskMap","getMaxWorkersPerTaskFromOptions","maxWorkersPerTask","hasher","createCache","cliArgs","skipLocalCache","scheduler","SimpleScheduler","continueOnError","workerData","runners","getBuiltInRunners","nodeArg","npmCmd","npmClient","shouldCache","cache","shouldResetCache","resetCache","Map","getMaxWorkersPerTask","workerIdleMemoryLimit","summary","run","displaySummary","reporters","info","targetRun","targetRuns","watcher","watch","on","packageName","resetLogEntries","target","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F;IACrF,KAAK,MAAMC,aAAarB,UAAUsB,UAAU,CAAC9B,MAAM,GAAI;QACrD6B,UAAUzE,OAAO,CAAC6D,WAAW,GAAG;IAClC;IAEA,iGAAiG;IACjG,MAAMc,UAAUC,IAAAA,cAAK,EAAC7D,MAAME;IAC5B0D,QAAQE,EAAE,CAAC,UAAU,CAACC;QACpBpE,SAASqE,eAAe;QACxB,MAAMpC,UAAU,IAAIsB;QACpB,KAAK,MAAMe,UAAUzD,YAAYoB,OAAO,CAACC,MAAM,GAAI;YACjD,IAAIoC,OAAOF,WAAW,KAAKA,aAAa;gBACtCnC,QAAQsC,GAAG,CAACD,OAAOE,EAAE,EAAEF;YACzB;QACF;QAEA,MAAMG,aAAa;YAAExC;QAAQ;QAE7B,KAAK,AAAC,CAAA;YACJ,MAAMyC,eAAe,MAAMhC,UAAUiB,GAAG,CAACtD,MAAMoE,YAAY;YAC3D,MAAMb,eAAec,cAAc5E,OAAO+D,SAAS;QACrD,CAAA,IAAKc,KAAK,CAAC,KAAO;IACpB;AACF;AAEA,eAAef,eAAeF,OAA4B,EAAEG,SAAqB;IAC/E,KAAK,MAAM7D,YAAY6D,UAAW;QAChC7D,SAAS4E,SAAS,CAAClB;QACnB,MAAM1D,SAAS6E,OAAO;IACxB;AACF"}
|
|
@@ -15,6 +15,8 @@ const _rpc = require("@lage-run/rpc");
|
|
|
15
15
|
const _parseServerOption = require("../parseServerOption.js");
|
|
16
16
|
const _config = require("@lage-run/config");
|
|
17
17
|
const _workspacetools = require("workspace-tools");
|
|
18
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
19
|
+
const _cache = require("@lage-run/cache");
|
|
18
20
|
function _interop_require_default(obj) {
|
|
19
21
|
return obj && obj.__esModule ? obj : {
|
|
20
22
|
default: obj
|
|
@@ -28,7 +30,7 @@ async function serverAction(options) {
|
|
|
28
30
|
const config = await (0, _config.getConfig)(cwd);
|
|
29
31
|
const logger = (0, _logger.default)();
|
|
30
32
|
options.logLevel = options.logLevel ?? "info";
|
|
31
|
-
options.logFile = options.logFile ?? "
|
|
33
|
+
options.logFile = options.logFile ?? _path.default.join((0, _cache.getCacheDirectoryRoot)(root), "server.log");
|
|
32
34
|
options.reporter = options.reporter ?? "verboseFileLog";
|
|
33
35
|
await (0, _initializeReporters.initializeReporters)(logger, options, {
|
|
34
36
|
customReporters: config.reporters,
|
|
@@ -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\";\nimport { getConfig } from \"@lage-run/config\";\nimport { getWorkspaceManagerRoot } from \"workspace-tools\";\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): Promise<void> {\n const { server = \"localhost:5332\", timeout = 1, tasks } = options;\n\n const { host, port } = parseServerOption(server);\n const 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.logFile = options.logFile ?? \"
|
|
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\";\nimport { getWorkspaceManagerRoot } from \"workspace-tools\";\nimport path from \"path\";\nimport { getCacheDirectoryRoot } from \"@lage-run/cache\";\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): Promise<void> {\n const { server = \"localhost:5332\", timeout = 1, tasks } = options;\n\n const { host, port } = parseServerOption(server);\n const 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.logFile = options.logFile ?? path.join(getCacheDirectoryRoot(root), \"server.log\");\n options.reporter = options.reporter ?? \"verboseFileLog\";\n await initializeReporters(logger, options, { customReporters: config.reporters, root });\n\n logger.info(`Starting server on http://${host}:${port}`);\n\n const abortController = new AbortController();\n\n const lageService = createLageService({\n 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","root","getWorkspaceManagerRoot","config","getConfig","logger","createLogger","logLevel","logFile","path","join","getCacheDirectoryRoot","reporter","initializeReporters","customReporters","reporters","info","abortController","AbortController","lageService","createLageService","serverControls","countdownToShutdown","resetTimer","lageServer","clearCountdown","clearTimer","concurrency","createServer","listen","timeoutHandle","globalThis","setTimeout","abort","close","clearTimeout"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C,KAAK,aAAa,EAAEH,QAAQ,QAAQ,CAAC;AACzF;AAEA,IAAIoC;AACJ,SAASP,WAAWlB,MAAc,EAAEX,OAAe,EAAEuB,eAAgC,EAAExB,MAAW;IAChGiC;IAEAI,gBAAgBC,WAAWC,UAAU,CAAC;QACpC3B,OAAOW,IAAI,CAAC,CAAC,uBAAuB,EAAEtB,QAAQ,QAAQ,CAAC;QACvDuB,gBAAgBgB,KAAK;QACrBxC,OAAOyC,KAAK;IACd,GAAGxC,UAAU;AACf;AAEA,SAASgC;IACP,IAAII,eAAe;QACjBC,WAAWI,YAAY,CAACL;IAC1B;AACF"}
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "getOutputFiles", {
|
|
|
8
8
|
return getOutputFiles;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _globby = require("
|
|
11
|
+
const _globby = require("globby");
|
|
12
12
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
13
|
function _interop_require_default(obj) {
|
|
14
14
|
return obj && obj.__esModule ? obj : {
|
|
@@ -20,7 +20,7 @@ function getOutputFiles(root, target, outputGlob, packageTree) {
|
|
|
20
20
|
"**/*"
|
|
21
21
|
];
|
|
22
22
|
const sourceControlledFiles = new Set(packageTree.getPackageFiles(target.packageName ?? "", patterns));
|
|
23
|
-
const outputs = (0, _globby.
|
|
23
|
+
const outputs = (0, _globby.sync)(patterns, {
|
|
24
24
|
cwd: target.cwd,
|
|
25
25
|
gitignore: false,
|
|
26
26
|
dot: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/server/getOutputFiles.ts"],"sourcesContent":["import type { CacheOptions } from \"@lage-run/config\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/server/getOutputFiles.ts"],"sourcesContent":["import type { CacheOptions } from \"@lage-run/config\";\nimport { sync as globbySync } from \"globby\";\nimport type { PackageTree } from \"@lage-run/hasher\";\nimport type { Target } from \"@lage-run/target-graph\";\n\nimport path from \"path\";\n\nexport function getOutputFiles(root: string, target: Target, outputGlob: CacheOptions[\"outputGlob\"], packageTree: PackageTree): string[] {\n const patterns = target.outputs ?? outputGlob ?? [\"**/*\"];\n\n const sourceControlledFiles = new Set(packageTree.getPackageFiles(target.packageName ?? \"\", patterns));\n const outputs = globbySync(patterns, { cwd: target.cwd, gitignore: false, dot: true })\n .map((file) => path.relative(root, path.join(target.cwd, file)))\n .filter((file) => !sourceControlledFiles.has(file));\n\n return outputs;\n}\n"],"names":["getOutputFiles","root","target","outputGlob","packageTree","patterns","outputs","sourceControlledFiles","Set","getPackageFiles","packageName","globbySync","cwd","gitignore","dot","map","file","path","relative","join","filter","has"],"mappings":";;;;+BAOgBA;;;eAAAA;;;wBANmB;6DAIlB;;;;;;AAEV,SAASA,eAAeC,IAAY,EAAEC,MAAc,EAAEC,UAAsC,EAAEC,WAAwB;IAC3H,MAAMC,WAAWH,OAAOI,OAAO,IAAIH,cAAc;QAAC;KAAO;IAEzD,MAAMI,wBAAwB,IAAIC,IAAIJ,YAAYK,eAAe,CAACP,OAAOQ,WAAW,IAAI,IAAIL;IAC5F,MAAMC,UAAUK,IAAAA,YAAU,EAACN,UAAU;QAAEO,KAAKV,OAAOU,GAAG;QAAEC,WAAW;QAAOC,KAAK;IAAK,GACjFC,GAAG,CAAC,CAACC,OAASC,aAAI,CAACC,QAAQ,CAACjB,MAAMgB,aAAI,CAACE,IAAI,CAACjB,OAAOU,GAAG,EAAEI,QACxDI,MAAM,CAAC,CAACJ,OAAS,CAACT,sBAAsBc,GAAG,CAACL;IAE/C,OAAOV;AACT"}
|
|
@@ -19,7 +19,7 @@ const _getOutputFiles = require("./getOutputFiles.js");
|
|
|
19
19
|
const _MemoryStream = require("./MemoryStream.js");
|
|
20
20
|
const _getBuiltInRunners = require("../../getBuiltInRunners.js");
|
|
21
21
|
const _filterPipelineDefinitions = require("../run/filterPipelineDefinitions.js");
|
|
22
|
-
const
|
|
22
|
+
const _reporters = require("@lage-run/reporters");
|
|
23
23
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
24
24
|
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
25
25
|
const _targetHashFilePath = require("../targetHashFilePath.js");
|
|
@@ -123,9 +123,6 @@ async function createInitializedPromise({ cwd, logger, serverControls, nodeArg,
|
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Initializes the lageService: the extra "initializePromise" ensures only one initialization is done at a time across threads
|
|
126
|
-
* @param cwd
|
|
127
|
-
* @param logger
|
|
128
|
-
* @returns
|
|
129
126
|
*/ async function initialize(options) {
|
|
130
127
|
initializedPromise = createInitializedPromise(options);
|
|
131
128
|
return initializedPromise;
|
|
@@ -193,7 +190,6 @@ function createLageService({ cwd, serverControls, logger, concurrency, tasks })
|
|
|
193
190
|
status: "queued",
|
|
194
191
|
threadId: 0
|
|
195
192
|
};
|
|
196
|
-
let results;
|
|
197
193
|
const inputs = (0, _hasher.getInputFiles)(target, dependencyMap, packageTree);
|
|
198
194
|
for (const dep of target.dependencies){
|
|
199
195
|
if (dep === (0, _targetgraph.getStartTargetId)()) {
|
|
@@ -212,10 +208,12 @@ function createLageService({ cwd, serverControls, logger, concurrency, tasks })
|
|
|
212
208
|
});
|
|
213
209
|
}
|
|
214
210
|
_fs.default.writeFileSync(targetHashFullPath, await targetHasher.hash(target));
|
|
215
|
-
} catch
|
|
211
|
+
} catch {
|
|
216
212
|
throw new _rpc.ConnectError(`Error writing target hash file: ${targetHashFullPath}`, _rpc.Code.Internal);
|
|
217
213
|
}
|
|
218
214
|
const targetGlobalInputHashRelativePath = (0, _targetHashFilePath.getGlobalInputHashFilePath)(target);
|
|
215
|
+
let execErrorText;
|
|
216
|
+
let hasError = false;
|
|
219
217
|
try {
|
|
220
218
|
await pool.exec(task, 0, (worker, stdout, stderr)=>{
|
|
221
219
|
logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} start`);
|
|
@@ -232,45 +230,32 @@ function createLageService({ cwd, serverControls, logger, concurrency, tasks })
|
|
|
232
230
|
const memoryUsage = process.memoryUsage();
|
|
233
231
|
logger.info(`Main Process Memory Usage: RSS: ${formatBytes(memoryUsage.rss)} Heap Total: ${formatBytes(memoryUsage.heapTotal)} Heap Used: ${formatBytes(memoryUsage.heapUsed)}`);
|
|
234
232
|
targetRun.status = "success";
|
|
235
|
-
targetRun.duration = (0,
|
|
236
|
-
logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} end: ${(0,
|
|
233
|
+
targetRun.duration = (0, _reporters.hrtimeDiff)(targetRun.startTime, process.hrtime());
|
|
234
|
+
logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} end: ${(0, _reporters.formatHrtime)(targetRun.duration)}`);
|
|
237
235
|
pipedStdout.unpipe(writableStdout);
|
|
238
236
|
pipedStderr.unpipe(writableStderr);
|
|
239
237
|
});
|
|
240
|
-
const outputs = (0, _getOutputFiles.getOutputFiles)(root, target, config.cacheOptions?.outputGlob, packageTree);
|
|
241
|
-
const targetHashFileRelativePath = _path.default.relative(root, targetHashFullPath).replace(/\\/g, "/");
|
|
242
|
-
outputs.push(targetHashFileRelativePath);
|
|
243
|
-
results = {
|
|
244
|
-
packageName: request.packageName,
|
|
245
|
-
task: request.task,
|
|
246
|
-
cwd: target.cwd,
|
|
247
|
-
exitCode: 0,
|
|
248
|
-
inputs,
|
|
249
|
-
outputs,
|
|
250
|
-
stdout: writableStdout.toString(),
|
|
251
|
-
stderr: writableStderr.toString(),
|
|
252
|
-
id,
|
|
253
|
-
globalInputHashFile: targetGlobalInputHashRelativePath
|
|
254
|
-
};
|
|
255
238
|
} catch (e) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
outputs.push(targetHashFileRelativePath);
|
|
239
|
+
execErrorText = e instanceof Error ? e.toString() : "";
|
|
240
|
+
hasError = true;
|
|
259
241
|
targetRun.status = "failed";
|
|
260
|
-
targetRun.duration = (0,
|
|
261
|
-
results = {
|
|
262
|
-
packageName: request.packageName,
|
|
263
|
-
task: request.task,
|
|
264
|
-
cwd: target.cwd,
|
|
265
|
-
exitCode: 1,
|
|
266
|
-
inputs,
|
|
267
|
-
outputs,
|
|
268
|
-
stdout: "",
|
|
269
|
-
stderr: e instanceof Error ? e.toString() : "",
|
|
270
|
-
id,
|
|
271
|
-
globalInputHashFile: targetGlobalInputHashRelativePath
|
|
272
|
-
};
|
|
242
|
+
targetRun.duration = (0, _reporters.hrtimeDiff)(targetRun.startTime, process.hrtime());
|
|
273
243
|
}
|
|
244
|
+
const outputs = (0, _getOutputFiles.getOutputFiles)(root, target, config.cacheOptions?.outputGlob, packageTree);
|
|
245
|
+
const targetHashFileRelativePath = _path.default.relative(root, targetHashFullPath).replace(/\\/g, "/");
|
|
246
|
+
outputs.push(targetHashFileRelativePath);
|
|
247
|
+
const results = {
|
|
248
|
+
packageName: request.packageName,
|
|
249
|
+
task: request.task,
|
|
250
|
+
cwd: target.cwd,
|
|
251
|
+
exitCode: hasError ? 1 : 0,
|
|
252
|
+
inputs,
|
|
253
|
+
outputs,
|
|
254
|
+
stdout: hasError ? "" : writableStdout.toString(),
|
|
255
|
+
stderr: hasError ? execErrorText : writableStderr.toString(),
|
|
256
|
+
id,
|
|
257
|
+
globalInputHashFile: targetGlobalInputHashRelativePath
|
|
258
|
+
};
|
|
274
259
|
logger.info(`${request.packageName}#${request.task} results: \n${JSON.stringify({
|
|
275
260
|
packageName: results.packageName,
|
|
276
261
|
task: results.task,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/server/lageService.ts"],"sourcesContent":["import { type ConfigOptions, getConfig, getConcurrency, getMaxWorkersPerTask } from \"@lage-run/config\";\nimport type { Logger } from \"@lage-run/logger\";\nimport { ConnectError, Code, type ILageService } from \"@lage-run/rpc\";\nimport { getStartTargetId, getTargetId, type TargetGraph } from \"@lage-run/target-graph\";\nimport { type DependencyMap, getPackageInfos, getWorkspaceManagerRoot } from \"workspace-tools\";\nimport { createTargetGraph } from \"../run/createTargetGraph.js\";\nimport { type Readable } from \"stream\";\nimport { type Pool, AggregatedPool } from \"@lage-run/worker-threads-pool\";\nimport { getInputFiles, type PackageTree, TargetHasher } from \"@lage-run/hasher\";\nimport { getOutputFiles } from \"./getOutputFiles.js\";\nimport { MemoryStream } from \"./MemoryStream.js\";\nimport { getBuiltInRunners } from \"../../getBuiltInRunners.js\";\nimport { filterPipelineDefinitions } from \"../run/filterPipelineDefinitions.js\";\nimport type { TargetRun } from \"@lage-run/scheduler-types\";\nimport { formatDuration, hrToSeconds, hrtimeDiff } from \"@lage-run/format-hrtime\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { getGlobalInputHashFilePath, getHashFilePath } from \"../targetHashFilePath.js\";\n\ninterface LageServiceContext {\n config: ConfigOptions;\n targetGraph: TargetGraph;\n packageTree: PackageTree;\n dependencyMap: DependencyMap;\n root: string;\n pool: Pool;\n targetHasher: TargetHasher;\n}\n\nlet initializedPromise: Promise<LageServiceContext> | undefined;\ninterface ServiceControls {\n abortController: AbortController;\n countdownToShutdown: () => void;\n clearCountdown: () => void;\n}\ninterface InitializeOptions {\n cwd: string;\n logger: Logger;\n serverControls: ServiceControls;\n concurrency?: number;\n nodeArg?: string;\n taskArgs: string[];\n tasks: string[];\n}\n\nfunction formatBytes(bytes: number) {\n return `${(bytes / 1024 / 1024).toFixed(2)} MB`;\n}\n\nasync function createInitializedPromise({ cwd, logger, serverControls, nodeArg, taskArgs, concurrency, tasks }: InitializeOptions) {\n if (initializedPromise) {\n return initializedPromise;\n }\n\n const config = await getConfig(cwd);\n const root = getWorkspaceManagerRoot(cwd)!;\n const maxWorkers = getConcurrency(concurrency, config.concurrency);\n\n logger.info(`Initializing with ${maxWorkers} workers, tasks: ${tasks.join(\", \")}`);\n\n const { pipeline } = config;\n\n const packageInfos = getPackageInfos(root);\n\n logger.info(\"Initializing target graph\");\n const targetGraph = await createTargetGraph({\n logger,\n root,\n dependencies: false,\n dependents: false,\n ignore: [],\n pipeline,\n repoWideChanges: config.repoWideChanges,\n scope: undefined,\n since: undefined,\n outputs: config.cacheOptions.outputGlob,\n tasks,\n packageInfos,\n priorities: config.priorities,\n enableTargetConfigMerging: config.enableTargetConfigMerging,\n enablePhantomTargetOptimization: config.enablePhantomTargetOptimization,\n });\n\n const targetHasher = new TargetHasher({\n root,\n environmentGlob: config.cacheOptions?.environmentGlob ?? [],\n logger,\n cacheKey: config.cacheOptions?.cacheKey,\n cliArgs: taskArgs,\n });\n\n logger.info(\"Initializing hasher\");\n await targetHasher.initialize();\n\n logger.info(\"Initializing dependency map\");\n\n const packageTree = targetHasher.packageTree!;\n const dependencyMap = targetHasher.dependencyMap;\n\n const filteredPipeline = filterPipelineDefinitions(targetGraph.targets.values(), config.pipeline);\n\n logger.info(\"Initializing Pool\");\n const pool = new AggregatedPool({\n logger,\n maxWorkersByGroup: new Map([...getMaxWorkersPerTask(filteredPipeline, maxWorkers)]),\n groupBy: ({ target }) => target.task,\n maxWorkers,\n script: require.resolve(\"./singleTargetWorker.js\"),\n workerOptions: {\n stdout: true,\n stderr: true,\n workerData: {\n runners: {\n ...getBuiltInRunners({ nodeArg, npmCmd: config.npmClient, taskArgs }),\n ...config.runners,\n shouldCache: false,\n shouldResetCache: false,\n },\n },\n },\n workerIdleMemoryLimit: config.workerIdleMemoryLimit,\n });\n\n serverControls.abortController.signal.addEventListener(\"abort\", () => {\n void pool?.close();\n });\n\n pool?.on(\"freedWorker\", () => {\n logger.silly(`Max Worker Memory Usage: ${formatBytes(pool?.stats().maxWorkerMemoryUsage)}`);\n });\n\n pool?.on(\"idle\", () => {\n logger.info(\"All workers are idle, shutting down after timeout\");\n serverControls.countdownToShutdown();\n });\n\n logger.info(\"done initializing\");\n return { config, targetGraph, packageTree, dependencyMap, root, pool, targetHasher };\n}\n\n/**\n * Initializes the lageService: the extra \"initializePromise\" ensures only one initialization is done at a time across threads\n * @param cwd\n * @param logger\n * @returns\n */\nasync function initialize(options: InitializeOptions): Promise<LageServiceContext> {\n initializedPromise = createInitializedPromise(options);\n return initializedPromise;\n}\n\ninterface CreateLageServiceOptions {\n cwd: string;\n serverControls: ServiceControls;\n logger: Logger;\n concurrency?: number;\n tasks: string[];\n}\n\nexport function createLageService({ cwd, serverControls, logger, concurrency, tasks }: CreateLageServiceOptions): ILageService {\n return {\n // eslint-disable-next-line @typescript-eslint/require-await\n async ping() {\n return { pong: true };\n },\n\n async runTarget(request) {\n if (global.gc) {\n global.gc();\n }\n\n serverControls.clearCountdown();\n\n // THIS IS A BIG ASSUMPTION; TODO: memoize based on the parameters of the initialize() call\n // The first request sets up the nodeArg and taskArgs - we are assuming that all requests to run this target are coming from the same\n // `lage info` call\n const { config, targetGraph, dependencyMap, packageTree, root, pool, targetHasher } = await initialize({\n cwd,\n logger,\n nodeArg: request.nodeOptions,\n taskArgs: request.taskArgs,\n serverControls,\n concurrency,\n tasks,\n });\n\n const runners = getBuiltInRunners({ nodeArg: request.nodeOptions, npmCmd: config.npmClient, taskArgs: request.taskArgs });\n\n const id = getTargetId(request.packageName, request.task);\n\n if (!targetGraph.targets.has(id)) {\n logger.info(`Target not found: ${request.packageName}#${request.task}`);\n return {\n packageName: request.packageName,\n task: request.task,\n exitCode: 1,\n };\n }\n\n logger.info(`Running target: ${request.packageName}#${request.task}`);\n\n const target = targetGraph.targets.get(id)!;\n const task = {\n target,\n runners,\n };\n\n const writableStdout = new MemoryStream();\n const writableStderr = new MemoryStream();\n let pipedStdout: Readable;\n let pipedStderr: Readable;\n\n const targetRun: TargetRun = {\n queueTime: process.hrtime(),\n target,\n duration: [0, 0],\n startTime: [0, 0],\n status: \"queued\",\n threadId: 0,\n };\n\n let results: {\n packageName?: string;\n task: string;\n cwd: string;\n exitCode: number;\n inputs: string[];\n outputs: string[];\n stdout: string;\n stderr: string;\n id: string;\n globalInputHashFile: string;\n };\n\n const inputs = getInputFiles(target, dependencyMap, packageTree);\n\n for (const dep of target.dependencies) {\n if (dep === getStartTargetId()) {\n continue;\n }\n\n const depTarget = targetGraph.targets.get(dep)!;\n inputs.push(path.join(path.relative(root, depTarget.cwd), getHashFilePath(depTarget)).replace(/\\\\/g, \"/\"));\n }\n\n // Write the target hash to a file for its dependants to use\n const targetHashFile = getHashFilePath(target);\n const targetHashFullPath = path.join(target.cwd, targetHashFile);\n\n try {\n if (!fs.existsSync(path.dirname(targetHashFullPath))) {\n fs.mkdirSync(path.dirname(targetHashFullPath), { recursive: true });\n }\n\n fs.writeFileSync(targetHashFullPath, await targetHasher.hash(target));\n } catch (e) {\n throw new ConnectError(`Error writing target hash file: ${targetHashFullPath}`, Code.Internal);\n }\n\n const targetGlobalInputHashRelativePath = getGlobalInputHashFilePath(target);\n\n try {\n await pool.exec(\n task,\n 0,\n (worker, stdout, stderr) => {\n logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} start`);\n\n pipedStdout = stdout;\n pipedStderr = stderr;\n\n stdout.pipe(writableStdout);\n stderr.pipe(writableStderr);\n\n targetRun.threadId = worker.threadId;\n targetRun.status = \"running\";\n targetRun.startTime = process.hrtime();\n },\n (worker) => {\n logger.info(`Max Worker Memory Usage: ${formatBytes(pool.stats().maxWorkerMemoryUsage)}`);\n\n // logger.info the main process memory usage\n const memoryUsage = process.memoryUsage();\n logger.info(\n `Main Process Memory Usage: RSS: ${formatBytes(memoryUsage.rss)} Heap Total: ${formatBytes(\n memoryUsage.heapTotal\n )} Heap Used: ${formatBytes(memoryUsage.heapUsed)}`\n );\n\n targetRun.status = \"success\";\n targetRun.duration = hrtimeDiff(targetRun.startTime, process.hrtime());\n\n logger.info(\n `[${worker.threadId}] ${request.packageName}#${request.task} end: ${formatDuration(hrToSeconds(targetRun.duration))}`\n );\n pipedStdout.unpipe(writableStdout);\n pipedStderr.unpipe(writableStderr);\n }\n );\n\n const outputs = getOutputFiles(root, target, config.cacheOptions?.outputGlob, packageTree);\n const targetHashFileRelativePath = path.relative(root, targetHashFullPath).replace(/\\\\/g, \"/\");\n outputs.push(targetHashFileRelativePath);\n\n results = {\n packageName: request.packageName,\n task: request.task,\n cwd: target.cwd,\n exitCode: 0,\n inputs,\n outputs,\n stdout: writableStdout.toString(),\n stderr: writableStderr.toString(),\n id,\n globalInputHashFile: targetGlobalInputHashRelativePath,\n };\n } catch (e) {\n const outputs = getOutputFiles(root, target, config.cacheOptions?.outputGlob, packageTree);\n const targetHashFileRelativePath = path.relative(root, targetHashFullPath).replace(/\\\\/g, \"/\");\n outputs.push(targetHashFileRelativePath);\n\n targetRun.status = \"failed\";\n targetRun.duration = hrtimeDiff(targetRun.startTime, process.hrtime());\n\n results = {\n packageName: request.packageName,\n task: request.task,\n cwd: target.cwd,\n exitCode: 1,\n inputs,\n outputs,\n stdout: \"\",\n stderr: e instanceof Error ? e.toString() : \"\",\n id,\n globalInputHashFile: targetGlobalInputHashRelativePath,\n };\n }\n\n logger.info(\n `${request.packageName}#${request.task} results: \\n${JSON.stringify(\n {\n packageName: results.packageName,\n task: results.task,\n cwd: results.cwd,\n exitCode: results.exitCode,\n inputs: results.inputs,\n outputs: results.outputs,\n id: results.id,\n globalInputHashFile: targetGlobalInputHashRelativePath,\n },\n null,\n 2\n )}\\n------`,\n results\n );\n\n return results;\n },\n };\n}\n"],"names":["createLageService","initializedPromise","formatBytes","bytes","toFixed","createInitializedPromise","cwd","logger","serverControls","nodeArg","taskArgs","concurrency","tasks","config","getConfig","root","getWorkspaceManagerRoot","maxWorkers","getConcurrency","info","join","pipeline","packageInfos","getPackageInfos","targetGraph","createTargetGraph","dependencies","dependents","ignore","repoWideChanges","scope","undefined","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","enablePhantomTargetOptimization","targetHasher","TargetHasher","environmentGlob","cacheKey","cliArgs","initialize","packageTree","dependencyMap","filteredPipeline","filterPipelineDefinitions","targets","values","pool","AggregatedPool","maxWorkersByGroup","Map","getMaxWorkersPerTask","groupBy","target","task","script","require","resolve","workerOptions","stdout","stderr","workerData","runners","getBuiltInRunners","npmCmd","npmClient","shouldCache","shouldResetCache","workerIdleMemoryLimit","abortController","signal","addEventListener","close","on","silly","stats","maxWorkerMemoryUsage","countdownToShutdown","options","ping","pong","runTarget","request","global","gc","clearCountdown","nodeOptions","id","getTargetId","packageName","has","exitCode","get","writableStdout","MemoryStream","writableStderr","pipedStdout","pipedStderr","targetRun","queueTime","process","hrtime","duration","startTime","status","threadId","results","inputs","getInputFiles","dep","getStartTargetId","depTarget","push","path","relative","getHashFilePath","replace","targetHashFile","targetHashFullPath","fs","existsSync","dirname","mkdirSync","recursive","writeFileSync","hash","e","ConnectError","Code","Internal","targetGlobalInputHashRelativePath","getGlobalInputHashFilePath","exec","worker","pipe","memoryUsage","rss","heapTotal","heapUsed","hrtimeDiff","formatDuration","hrToSeconds","unpipe","getOutputFiles","targetHashFileRelativePath","toString","globalInputHashFile","Error","JSON","stringify"],"mappings":";;;;+BA+JgBA;;;eAAAA;;;wBA/JoE;qBAE9B;6BACU;gCACa;mCAC3C;mCAEQ;wBACoB;gCAC/B;8BACF;mCACK;2CACQ;8BAEc;6DACvC;2DACF;oCAC6C;;;;;;AAY5D,IAAIC;AAgBJ,SAASC,YAAYC,KAAa;IAChC,OAAO,GAAG,AAACA,CAAAA,QAAQ,OAAO,IAAG,EAAGC,OAAO,CAAC,GAAG,GAAG,CAAC;AACjD;AAEA,eAAeC,yBAAyB,EAAEC,GAAG,EAAEC,MAAM,EAAEC,cAAc,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,KAAK,EAAqB;IAC/H,IAAIX,oBAAoB;QACtB,OAAOA;IACT;IAEA,MAAMY,SAAS,MAAMC,IAAAA,iBAAS,EAACR;IAC/B,MAAMS,OAAOC,IAAAA,uCAAuB,EAACV;IACrC,MAAMW,aAAaC,IAAAA,sBAAc,EAACP,aAAaE,OAAOF,WAAW;IAEjEJ,OAAOY,IAAI,CAAC,CAAC,kBAAkB,EAAEF,WAAW,iBAAiB,EAAEL,MAAMQ,IAAI,CAAC,OAAO;IAEjF,MAAM,EAAEC,QAAQ,EAAE,GAAGR;I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AQ,CAACvG,MAAM2G,oBAAoBF,OAAO,CAAC,OAAO;gBAC1FvF,QAAQmF,IAAI,CAACgC;gBAEb9C,UAAUM,MAAM,GAAG;gBACnBN,UAAUI,QAAQ,GAAGqC,IAAAA,wBAAU,EAACzC,UAAUK,SAAS,EAAEH,QAAQC,MAAM;gBAEnEK,UAAU;oBACRjB,aAAaP,QAAQO,WAAW;oBAChCnC,MAAM4B,QAAQ5B,IAAI;oBAClBpD,KAAKmD,OAAOnD,GAAG;oBACfyF,UAAU;oBACVgB;oBACA9E;oBACA8B,QAAQ;oBACRC,QAAQkE,aAAaqB,QAAQrB,EAAEmB,QAAQ,KAAK;oBAC5C1D;oBACA2D,qBAAqBhB;gBACvB;YACF;YAEA/H,OAAOY,IAAI,CACT,GAAGmE,QAAQO,WAAW,CAAC,CAAC,EAAEP,QAAQ5B,IAAI,CAAC,YAAY,EAAE8F,KAAKC,SAAS,CACjE;gBACE5D,aAAaiB,QAAQjB,WAAW;gBAChCnC,MAAMoD,QAAQpD,IAAI;gBAClBpD,KAAKwG,QAAQxG,GAAG;gBAChByF,UAAUe,QAAQf,QAAQ;gBAC1BgB,QAAQD,QAAQC,MAAM;gBACtB9E,SAAS6E,QAAQ7E,OAAO;gBACxB0D,IAAImB,QAAQnB,EAAE;gBACd2D,qBAAqBhB;YACvB,GACA,MACA,GACA,QAAQ,CAAC,EACXxB;YAGF,OAAOA;QACT;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/server/lageService.ts"],"sourcesContent":["import { type ConfigOptions, getConfig, getConcurrency, getMaxWorkersPerTask } from \"@lage-run/config\";\nimport type { Logger } from \"@lage-run/logger\";\nimport { ConnectError, Code, type ILageService } from \"@lage-run/rpc\";\nimport { getStartTargetId, getTargetId, type TargetGraph } from \"@lage-run/target-graph\";\nimport { type DependencyMap, getPackageInfos, getWorkspaceManagerRoot } from \"workspace-tools\";\nimport { createTargetGraph } from \"../run/createTargetGraph.js\";\nimport { type Readable } from \"stream\";\nimport { type Pool, AggregatedPool } from \"@lage-run/worker-threads-pool\";\nimport { getInputFiles, type PackageTree, TargetHasher } from \"@lage-run/hasher\";\nimport { getOutputFiles } from \"./getOutputFiles.js\";\nimport { MemoryStream } from \"./MemoryStream.js\";\nimport { getBuiltInRunners } from \"../../getBuiltInRunners.js\";\nimport { filterPipelineDefinitions } from \"../run/filterPipelineDefinitions.js\";\nimport type { TargetRun } from \"@lage-run/scheduler-types\";\nimport { formatHrtime, hrtimeDiff } from \"@lage-run/reporters\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { getGlobalInputHashFilePath, getHashFilePath } from \"../targetHashFilePath.js\";\n\ninterface LageServiceContext {\n config: ConfigOptions;\n targetGraph: TargetGraph;\n packageTree: PackageTree;\n dependencyMap: DependencyMap;\n root: string;\n pool: Pool;\n targetHasher: TargetHasher;\n}\n\nlet initializedPromise: Promise<LageServiceContext> | undefined;\ninterface ServiceControls {\n abortController: AbortController;\n countdownToShutdown: () => void;\n clearCountdown: () => void;\n}\ninterface InitializeOptions {\n cwd: string;\n logger: Logger;\n serverControls: ServiceControls;\n concurrency?: number;\n nodeArg?: string;\n taskArgs: string[];\n tasks: string[];\n}\n\nfunction formatBytes(bytes: number) {\n return `${(bytes / 1024 / 1024).toFixed(2)} MB`;\n}\n\nasync function createInitializedPromise({ cwd, logger, serverControls, nodeArg, taskArgs, concurrency, tasks }: InitializeOptions) {\n if (initializedPromise) {\n return initializedPromise;\n }\n\n const config = await getConfig(cwd);\n const root = getWorkspaceManagerRoot(cwd)!;\n const maxWorkers = getConcurrency(concurrency, config.concurrency);\n\n logger.info(`Initializing with ${maxWorkers} workers, tasks: ${tasks.join(\", \")}`);\n\n const { pipeline } = config;\n\n const packageInfos = getPackageInfos(root);\n\n logger.info(\"Initializing target graph\");\n const targetGraph = await createTargetGraph({\n logger,\n root,\n dependencies: false,\n dependents: false,\n ignore: [],\n pipeline,\n repoWideChanges: config.repoWideChanges,\n scope: undefined,\n since: undefined,\n outputs: config.cacheOptions.outputGlob,\n tasks,\n packageInfos,\n priorities: config.priorities,\n enableTargetConfigMerging: config.enableTargetConfigMerging,\n enablePhantomTargetOptimization: config.enablePhantomTargetOptimization,\n });\n\n const targetHasher = new TargetHasher({\n root,\n environmentGlob: config.cacheOptions?.environmentGlob ?? [],\n logger,\n cacheKey: config.cacheOptions?.cacheKey,\n cliArgs: taskArgs,\n });\n\n logger.info(\"Initializing hasher\");\n await targetHasher.initialize();\n\n logger.info(\"Initializing dependency map\");\n\n const packageTree = targetHasher.packageTree!;\n const dependencyMap = targetHasher.dependencyMap;\n\n const filteredPipeline = filterPipelineDefinitions(targetGraph.targets.values(), config.pipeline);\n\n logger.info(\"Initializing Pool\");\n const pool = new AggregatedPool({\n logger,\n maxWorkersByGroup: new Map([...getMaxWorkersPerTask(filteredPipeline, maxWorkers)]),\n groupBy: ({ target }) => target.task,\n maxWorkers,\n script: require.resolve(\"./singleTargetWorker.js\"),\n workerOptions: {\n stdout: true,\n stderr: true,\n workerData: {\n runners: {\n ...getBuiltInRunners({ nodeArg, npmCmd: config.npmClient, taskArgs }),\n ...config.runners,\n shouldCache: false,\n shouldResetCache: false,\n },\n },\n },\n workerIdleMemoryLimit: config.workerIdleMemoryLimit,\n });\n\n serverControls.abortController.signal.addEventListener(\"abort\", () => {\n void pool?.close();\n });\n\n pool?.on(\"freedWorker\", () => {\n logger.silly(`Max Worker Memory Usage: ${formatBytes(pool?.stats().maxWorkerMemoryUsage)}`);\n });\n\n pool?.on(\"idle\", () => {\n logger.info(\"All workers are idle, shutting down after timeout\");\n serverControls.countdownToShutdown();\n });\n\n logger.info(\"done initializing\");\n return { config, targetGraph, packageTree, dependencyMap, root, pool, targetHasher };\n}\n\n/**\n * Initializes the lageService: the extra \"initializePromise\" ensures only one initialization is done at a time across threads\n */\nasync function initialize(options: InitializeOptions): Promise<LageServiceContext> {\n initializedPromise = createInitializedPromise(options);\n return initializedPromise;\n}\n\ninterface CreateLageServiceOptions {\n cwd: string;\n serverControls: ServiceControls;\n logger: Logger;\n concurrency?: number;\n tasks: string[];\n}\n\nexport function createLageService({ cwd, serverControls, logger, concurrency, tasks }: CreateLageServiceOptions): ILageService {\n return {\n // eslint-disable-next-line @typescript-eslint/require-await\n async ping() {\n return { pong: true };\n },\n\n async runTarget(request) {\n if (global.gc) {\n global.gc();\n }\n\n serverControls.clearCountdown();\n\n // THIS IS A BIG ASSUMPTION; TODO: memoize based on the parameters of the initialize() call\n // The first request sets up the nodeArg and taskArgs - we are assuming that all requests to run this target are coming from the same\n // `lage info` call\n const { config, targetGraph, dependencyMap, packageTree, root, pool, targetHasher } = await initialize({\n cwd,\n logger,\n nodeArg: request.nodeOptions,\n taskArgs: request.taskArgs,\n serverControls,\n concurrency,\n tasks,\n });\n\n const runners = getBuiltInRunners({ nodeArg: request.nodeOptions, npmCmd: config.npmClient, taskArgs: request.taskArgs });\n\n const id = getTargetId(request.packageName, request.task);\n\n if (!targetGraph.targets.has(id)) {\n logger.info(`Target not found: ${request.packageName}#${request.task}`);\n return {\n packageName: request.packageName,\n task: request.task,\n exitCode: 1,\n };\n }\n\n logger.info(`Running target: ${request.packageName}#${request.task}`);\n\n const target = targetGraph.targets.get(id)!;\n const task = {\n target,\n runners,\n };\n\n const writableStdout = new MemoryStream();\n const writableStderr = new MemoryStream();\n let pipedStdout: Readable;\n let pipedStderr: Readable;\n\n const targetRun: TargetRun = {\n queueTime: process.hrtime(),\n target,\n duration: [0, 0],\n startTime: [0, 0],\n status: \"queued\",\n threadId: 0,\n };\n\n const inputs = getInputFiles(target, dependencyMap, packageTree);\n\n for (const dep of target.dependencies) {\n if (dep === getStartTargetId()) {\n continue;\n }\n\n const depTarget = targetGraph.targets.get(dep)!;\n inputs.push(path.join(path.relative(root, depTarget.cwd), getHashFilePath(depTarget)).replace(/\\\\/g, \"/\"));\n }\n\n // Write the target hash to a file for its dependants to use\n const targetHashFile = getHashFilePath(target);\n const targetHashFullPath = path.join(target.cwd, targetHashFile);\n\n try {\n if (!fs.existsSync(path.dirname(targetHashFullPath))) {\n fs.mkdirSync(path.dirname(targetHashFullPath), { recursive: true });\n }\n\n fs.writeFileSync(targetHashFullPath, await targetHasher.hash(target));\n } catch {\n throw new ConnectError(`Error writing target hash file: ${targetHashFullPath}`, Code.Internal);\n }\n\n const targetGlobalInputHashRelativePath = getGlobalInputHashFilePath(target);\n let execErrorText: string | undefined;\n let hasError = false;\n\n try {\n await pool.exec(\n task,\n 0,\n (worker, stdout, stderr) => {\n logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} start`);\n\n pipedStdout = stdout;\n pipedStderr = stderr;\n\n stdout.pipe(writableStdout);\n stderr.pipe(writableStderr);\n\n targetRun.threadId = worker.threadId;\n targetRun.status = \"running\";\n targetRun.startTime = process.hrtime();\n },\n (worker) => {\n logger.info(`Max Worker Memory Usage: ${formatBytes(pool.stats().maxWorkerMemoryUsage)}`);\n\n // logger.info the main process memory usage\n const memoryUsage = process.memoryUsage();\n logger.info(\n `Main Process Memory Usage: RSS: ${formatBytes(memoryUsage.rss)} Heap Total: ${formatBytes(\n memoryUsage.heapTotal\n )} Heap Used: ${formatBytes(memoryUsage.heapUsed)}`\n );\n\n targetRun.status = \"success\";\n targetRun.duration = hrtimeDiff(targetRun.startTime, process.hrtime());\n\n logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} end: ${formatHrtime(targetRun.duration)}`);\n pipedStdout.unpipe(writableStdout);\n pipedStderr.unpipe(writableStderr);\n }\n );\n } catch (e) {\n execErrorText = e instanceof Error ? e.toString() : \"\";\n hasError = true;\n targetRun.status = \"failed\";\n targetRun.duration = hrtimeDiff(targetRun.startTime, process.hrtime());\n }\n\n const outputs = getOutputFiles(root, target, config.cacheOptions?.outputGlob, packageTree);\n const targetHashFileRelativePath = path.relative(root, targetHashFullPath).replace(/\\\\/g, \"/\");\n outputs.push(targetHashFileRelativePath);\n\n const results: Awaited<ReturnType<NonNullable<ILageService[\"runTarget\"]>>> = {\n packageName: request.packageName,\n task: request.task,\n cwd: target.cwd,\n exitCode: hasError ? 1 : 0,\n inputs,\n outputs,\n stdout: hasError ? \"\" : writableStdout.toString(),\n stderr: hasError ? execErrorText : writableStderr.toString(),\n id,\n globalInputHashFile: targetGlobalInputHashRelativePath,\n };\n\n logger.info(\n `${request.packageName}#${request.task} results: \\n${JSON.stringify(\n {\n packageName: results.packageName,\n task: results.task,\n cwd: results.cwd,\n exitCode: results.exitCode,\n inputs: results.inputs,\n outputs: results.outputs,\n id: results.id,\n globalInputHashFile: targetGlobalInputHashRelativePath,\n },\n null,\n 2\n )}\\n------`,\n results\n );\n\n return results;\n },\n };\n}\n"],"names":["createLageService","initializedPromise","formatBytes","bytes","toFixed","createInitializedPromise","cwd","logger","serverControls","nodeArg","taskArgs","concurrency","tasks","config","getConfig","root","getWorkspaceManagerRoot","maxWorkers","getConcurrency","info","join","pipeline","packageInfos","getPackageInfos","targetGraph","createTargetGraph","dependencies","dependents","ignore","repoWideChanges","scope","undefined","since","outputs","cacheOptions","outputGlob","priorities","enableTargetConfigMerging","enablePhantomTargetOptimization","targetHasher","TargetHasher","environmentGlob","cacheKey","cliArgs","initialize","packageTree","dependencyMap","filteredPipeline","filterPipelineDefinitions","targets","values","pool","AggregatedPool","maxWorkersByGroup","Map","getMaxWorkersPerTask","groupBy","target","task","script","require","resolve","workerOptions","stdout","stderr","workerData","runners","getBuiltInRunners","npmCmd","npmClient","shouldCache","shouldResetCache","workerIdleMemoryLimit","abortController","signal","addEventListener","close","on","silly","stats","maxWorkerMemoryUsage","countdownToShutdown","options","ping","pong","runTarget","request","global","gc","clearCountdown","nodeOptions","id","getTargetId","packageName","has","exitCode","get","writableStdout","MemoryStream","writableStderr","pipedStdout","pipedStderr","targetRun","queueTime","process","hrtime","duration","startTime","status","threadId","inputs","getInputFiles","dep","getStartTargetId","depTarget","push","path","relative","getHashFilePath","replace","targetHashFile","targetHashFullPath","fs","existsSync","dirname","mkdirSync","recursive","writeFileSync","hash","ConnectError","Code","Internal","targetGlobalInputHashRelativePath","getGlobalInputHashFilePath","execErrorText","hasError","exec","worker","pipe","memoryUsage","rss","heapTotal","heapUsed","hrtimeDiff","formatHrtime","unpipe","e","Error","toString","getOutputFiles","targetHashFileRelativePath","results","globalInputHashFile","JSON","stringify"],"mappings":";;;;+BA4JgBA;;;eAAAA;;;wBA5JoE;qBAE9B;6BACU;gCACa;mCAC3C;mCAEQ;wBACoB;gCAC/B;8BACF;mCACK;2CACQ;2BAED;6DACxB;2DACF;oCAC6C;;;;;;AAY5D,IAAIC;AAgBJ,SAASC,YAAYC,KAAa;IAChC,OAAO,GAAG,AAACA,CAAAA,QAAQ,OAAO,IAAG,EAAGC,OAAO,CAAC,GAAG,GAAG,CAAC;AACjD;AAEA,eAAeC,yBAAyB,EAAEC,GAAG,EAAEC,MAAM,EAAEC,cAAc,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,KAAK,EAAqB;IAC/H,IAAIX,oBAAoB;QACtB,OAAOA;IACT;IAEA,MAAMY,SAAS,MAAMC,IAAAA,iBAAS,EAACR;IAC/B,MAAMS,OAAOC,IAAAA,uCAAuB,EAACV;IACrC,MAAMW,aAAaC,IAAAA,sBAAc,EAACP,aAAaE,OAAOF,WAAW;IAEjEJ,OAAOY,IAAI,CAAC,CAAC,kBAAkB,EAAEF,WAAW,iBAAiB,EAAEL,MAAMQ,IAAI,CAAC,OAAO;IAEjF,MAAM,EAAEC,QAAQ,EAAE,GAAGR;IAErB,MAAMS,eAAeC,IAAAA,+BAAe,EAACR;IAErCR,OAAOY,IAAI,CAAC;IACZ,MAAMK,cAAc,MAAMC,IAAAA,oCAAiB,EAAC;QAC1ClB;QACAQ;QACAW,cAAc;QACdC,YAAY;QACZC,QAAQ,EAAE;QACVP;QACAQ,iBAAiBhB,OAAOgB,eAAe;QACvCC,OAAOC;QACPC,OAAOD;QACPE,SAASpB,OAAOqB,YAAY,CAACC,UAAU;QACvCvB;QACAU;QACAc,YAAYvB,OAAOuB,UAAU;QAC7BC,2B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QAAQxD,QAAQ;gBAC1Be,QAAQyC,QAAQzC,MAAM;gBACtB7E,SAASsH,QAAQtH,OAAO;gBACxB0D,IAAI4D,QAAQ5D,EAAE;gBACd6D,qBAAqBpB;YACvB,GACA,MACA,GACA,QAAQ,CAAC,EACXmB;YAGF,OAAOA;QACT;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/ReporterInitOptions.ts"],"sourcesContent":["import type { LogLevel } from \"@lage-run/logger\";\n\n/** All the built-in reporter names */\nexport type BuiltInReporterName =\n | \"default\"\n | \"profile\"\n | \"json\"\n | \"azureDevops\"\n | \"adoLog\"\n | \"githubActions\"\n | \"gha\"\n | \"npmLog\"\n | \"old\"\n | \"verboseFileLog\"\n | \"vfl\"\n | \"fancy\";\n/** Built-in or custom reporter name */\nexport type ReporterName = BuiltInReporterName | string;\n\n/** Whether each built-in reporter name should be listed in doc output */\nconst shouldListBuiltInReporters: Record<BuiltInReporterName, boolean> = {\n json: true,\n azureDevops: true,\n npmLog: true,\n verboseFileLog: true,\n vfl: true,\n adoLog: true,\n githubActions: true,\n gha: true,\n fancy: true,\n default: true,\n // Not encouraged\n old: false,\n // Intended to be set via --profile\n profile: false,\n};\n\n/** All the built-in reporter names */\nexport const builtInReporterNames: string[] = Object.keys(shouldListBuiltInReporters);\n\n/** Built-in reporter names that should be listed in doc output */\nexport const logBuiltInReporterNames: string[] = builtInReporterNames.filter(\n (name) => shouldListBuiltInReporters[name as BuiltInReporterName]\n);\n\n/**\n * Options for initializing reporters.\n * This is also passed to the constructor of a custom reporter class.\n */\nexport interface ReporterInitOptions {\n reporter: ReporterName[] | ReporterName | undefined;\n progress: boolean;\n verbose: boolean;\n grouped: boolean;\n concurrency: number;\n logLevel: keyof typeof LogLevel;\n profile?: boolean | string;\n logFile?: string;\n indented?: boolean;\n}\n"],"names":["builtInReporterNames","logBuiltInReporterNames","shouldListBuiltInReporters","json","azureDevops","npmLog","verboseFileLog","vfl","adoLog","githubActions","gha","fancy","default","old","profile","Object","keys","filter","name"],"mappings":";;;;;;;;;;;QAsCaA;eAAAA;;QAGAC;eAAAA;;;AAtBb,uEAAuE,GACvE,MAAMC,6BAAmE;IACvEC,MAAM;IACNC,aAAa;IACbC,QAAQ;IACRC,gBAAgB;IAChBC,KAAK;IACLC,QAAQ;IACRC,eAAe;IACfC,KAAK;IACLC,OAAO;IACPC,SAAS;IACT,iBAAiB;IACjBC,KAAK;IACL,mCAAmC;IACnCC,SAAS;AACX;AAGO,MAAMd,uBAAiCe,OAAOC,IAAI,CAACd;AAGnD,MAAMD,0BAAoCD,qBAAqBiB,MAAM,CAC1E,CAACC,OAAShB,0BAA0B,CAACgB,KAA4B"}
|
|
1
|
+
{"version":3,"sources":["../../src/types/ReporterInitOptions.ts"],"sourcesContent":["import type { LogLevel } from \"@lage-run/logger\";\n\n/** All the built-in reporter names */\nexport type BuiltInReporterName =\n | \"default\"\n | \"profile\"\n | \"json\"\n | \"azureDevops\"\n | \"adoLog\"\n | \"githubActions\"\n | \"gha\"\n | \"npmLog\"\n | \"old\"\n | \"verboseFileLog\"\n | \"vfl\"\n | \"fancy\";\n/** Built-in or custom reporter name */\nexport type ReporterName = BuiltInReporterName | string;\n\n/** Whether each built-in reporter name should be listed in doc output */\nconst shouldListBuiltInReporters: Record<BuiltInReporterName, boolean> = {\n json: true,\n azureDevops: true,\n npmLog: true,\n verboseFileLog: true,\n vfl: true,\n adoLog: true,\n githubActions: true,\n gha: true,\n fancy: true,\n default: true,\n // Not encouraged\n old: false,\n // Intended to be set via --profile\n profile: false,\n};\n\n/** All the built-in reporter names */\nexport const builtInReporterNames: string[] = Object.keys(shouldListBuiltInReporters);\n\n/** Built-in reporter names that should be listed in doc output */\nexport const logBuiltInReporterNames: string[] = builtInReporterNames.filter(\n (name) => shouldListBuiltInReporters[name as BuiltInReporterName]\n);\n\n/**\n * Options for initializing reporters.\n * This is also passed to the constructor of a custom reporter class.\n */\nexport interface ReporterInitOptions {\n reporter: ReporterName[] | ReporterName | undefined;\n progress: boolean;\n verbose: boolean;\n grouped: boolean;\n concurrency: number;\n logLevel: keyof typeof LogLevel;\n profile?: boolean | string;\n logFile?: string;\n indented?: boolean;\n /** Whether to capture and report main process memory usage on target completion */\n logMemory?: boolean;\n}\n"],"names":["builtInReporterNames","logBuiltInReporterNames","shouldListBuiltInReporters","json","azureDevops","npmLog","verboseFileLog","vfl","adoLog","githubActions","gha","fancy","default","old","profile","Object","keys","filter","name"],"mappings":";;;;;;;;;;;QAsCaA;eAAAA;;QAGAC;eAAAA;;;AAtBb,uEAAuE,GACvE,MAAMC,6BAAmE;IACvEC,MAAM;IACNC,aAAa;IACbC,QAAQ;IACRC,gBAAgB;IAChBC,KAAK;IACLC,QAAQ;IACRC,eAAe;IACfC,KAAK;IACLC,OAAO;IACPC,SAAS;IACT,iBAAiB;IACjBC,KAAK;IACL,mCAAmC;IACnCC,SAAS;AACX;AAGO,MAAMd,uBAAiCe,OAAOC,IAAI,CAACd;AAGnD,MAAMD,0BAAoCD,qBAAqBiB,MAAM,CAC1E,CAACC,OAAShB,0BAA0B,CAACgB,KAA4B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "Command Line Interface for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,27 +23,26 @@
|
|
|
23
23
|
"lint": "monorepo-scripts lint"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lage-run/cache": "^1.
|
|
27
|
-
"@lage-run/config": "^0.9.
|
|
28
|
-
"@lage-run/
|
|
29
|
-
"@lage-run/
|
|
30
|
-
"@lage-run/
|
|
31
|
-
"@lage-run/logger": "^1.3.3",
|
|
32
|
-
"@lage-run/reporters": "^1.5.1",
|
|
26
|
+
"@lage-run/cache": "^1.5.0",
|
|
27
|
+
"@lage-run/config": "^0.9.4",
|
|
28
|
+
"@lage-run/hasher": "^1.10.1",
|
|
29
|
+
"@lage-run/logger": "^1.4.0",
|
|
30
|
+
"@lage-run/reporters": "^1.7.0",
|
|
33
31
|
"@lage-run/rpc": "^1.4.4",
|
|
34
|
-
"@lage-run/runners": "^1.4.
|
|
35
|
-
"@lage-run/scheduler": "^1.
|
|
36
|
-
"@lage-run/scheduler-types": "^0.
|
|
37
|
-
"@lage-run/target-graph": "^0.
|
|
38
|
-
"@lage-run/worker-threads-pool": "^0.
|
|
32
|
+
"@lage-run/runners": "^1.4.3",
|
|
33
|
+
"@lage-run/scheduler": "^1.6.1",
|
|
34
|
+
"@lage-run/scheduler-types": "^0.4.1",
|
|
35
|
+
"@lage-run/target-graph": "^0.15.0",
|
|
36
|
+
"@lage-run/worker-threads-pool": "^0.10.1",
|
|
39
37
|
"chokidar": "^3.6.0",
|
|
40
38
|
"commander": "^9.5.0",
|
|
41
39
|
"execa": "^5.1.1",
|
|
42
40
|
"fast-glob": "^3.3.3",
|
|
41
|
+
"globby": "^11.1.0",
|
|
43
42
|
"is-interactive": "^1.0.0",
|
|
44
43
|
"proper-lockfile": "^4.1.2",
|
|
45
44
|
"shell-quote": "^1.8.3",
|
|
46
|
-
"workspace-tools": "^0.41.
|
|
45
|
+
"workspace-tools": "^0.41.2"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@lage-run/monorepo-scripts": "^1.0.0",
|