@lage-run/cli 0.22.0 → 0.23.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/CHANGELOG.json +103 -1
- package/CHANGELOG.md +30 -2
- package/bin/lage-server.js +3 -0
- package/lib/commands/exec/action.d.ts +3 -2
- package/lib/commands/exec/action.js +13 -6
- package/lib/commands/exec/executeInProcess.d.ts +1 -1
- package/lib/commands/exec/executeInProcess.js +2 -20
- package/lib/commands/exec/executeRemotely.d.ts +7 -0
- package/lib/commands/exec/executeRemotely.js +127 -0
- package/lib/commands/exec/index.js +9 -0
- package/lib/commands/info/action.d.ts +4 -3
- package/lib/commands/info/action.js +69 -71
- package/lib/commands/info/index.js +5 -1
- package/lib/commands/run/action.d.ts +1 -1
- package/lib/commands/run/action.js +1 -4
- package/lib/commands/run/createTargetGraph.d.ts +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/run/runAction.js +2 -18
- package/lib/commands/run/watchAction.js +2 -18
- package/lib/commands/server/MemoryStream.d.ts +10 -0
- package/lib/commands/server/MemoryStream.js +40 -0
- package/lib/commands/server/action.d.ts +1 -2
- package/lib/commands/server/action.js +19 -71
- package/lib/commands/server/lageService.js +19 -27
- package/lib/getBinPaths.d.ts +4 -0
- package/lib/getBinPaths.js +33 -0
- package/lib/runnerPickerOptions.d.ts +2 -0
- package/lib/runnerPickerOptions.js +32 -0
- package/package.json +14 -13
- package/lib/commands/run/infoAction.d.ts +0 -14
- package/lib/commands/run/infoAction.js +0 -55
- /package/lib/commands/{server → exec}/simulateFileAccess.d.ts +0 -0
- /package/lib/commands/{server → exec}/simulateFileAccess.js +0 -0
- /package/lib/{commands/run/runners → runners}/NoOpRunner.d.ts +0 -0
- /package/lib/{commands/run/runners → runners}/NoOpRunner.js +0 -0
- /package/lib/{commands/run/runners → runners}/NpmScriptRunner.d.ts +0 -0
- /package/lib/{commands/run/runners → runners}/NpmScriptRunner.js +0 -0
- /package/lib/{commands/run/runners → runners}/WorkerRunner.d.ts +0 -0
- /package/lib/{commands/run/runners → runners}/WorkerRunner.js +0 -0
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,109 @@
|
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Fri,
|
|
5
|
+
"date": "Fri, 04 Oct 2024 23:41:31 GMT",
|
|
6
|
+
"version": "0.23.1",
|
|
7
|
+
"tag": "@lage-run/cli_v0.23.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "kchau@microsoft.com",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"commit": "5030c3eca2e52a4b31e4246b06dea37e126aa659",
|
|
14
|
+
"comment": "Modified info command to accommodate a \"LAGE_WORKER_SERVER\" flag (also, --server)"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@lage-run/cli",
|
|
19
|
+
"comment": "Bump @lage-run/rpc to v1.2.3",
|
|
20
|
+
"commit": "not available"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"date": "Wed, 02 Oct 2024 20:26:19 GMT",
|
|
27
|
+
"version": "0.23.0",
|
|
28
|
+
"tag": "@lage-run/cli_v0.23.0",
|
|
29
|
+
"comments": {
|
|
30
|
+
"minor": [
|
|
31
|
+
{
|
|
32
|
+
"author": "kchau@microsoft.com",
|
|
33
|
+
"package": "@lage-run/cli",
|
|
34
|
+
"commit": "6ecbd570669a07fa87429af5de13ec1adc58b864",
|
|
35
|
+
"comment": "Simulate file access for lage server"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "beachball",
|
|
39
|
+
"package": "@lage-run/cli",
|
|
40
|
+
"comment": "Bump @lage-run/cache to v1.3.4",
|
|
41
|
+
"commit": "not available"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"author": "beachball",
|
|
45
|
+
"package": "@lage-run/cli",
|
|
46
|
+
"comment": "Bump @lage-run/config to v0.4.3",
|
|
47
|
+
"commit": "not available"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"author": "beachball",
|
|
51
|
+
"package": "@lage-run/cli",
|
|
52
|
+
"comment": "Bump @lage-run/globby to v14.2.0",
|
|
53
|
+
"commit": "not available"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"author": "beachball",
|
|
57
|
+
"package": "@lage-run/cli",
|
|
58
|
+
"comment": "Bump @lage-run/hasher to v1.6.0",
|
|
59
|
+
"commit": "not available"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"author": "beachball",
|
|
63
|
+
"package": "@lage-run/cli",
|
|
64
|
+
"comment": "Bump @lage-run/reporters to v1.2.11",
|
|
65
|
+
"commit": "not available"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"author": "beachball",
|
|
69
|
+
"package": "@lage-run/cli",
|
|
70
|
+
"comment": "Bump @lage-run/rpc to v1.2.2",
|
|
71
|
+
"commit": "not available"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"author": "beachball",
|
|
75
|
+
"package": "@lage-run/cli",
|
|
76
|
+
"comment": "Bump @lage-run/runners to v1.0.3",
|
|
77
|
+
"commit": "not available"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"author": "beachball",
|
|
81
|
+
"package": "@lage-run/cli",
|
|
82
|
+
"comment": "Bump @lage-run/scheduler to v1.3.2",
|
|
83
|
+
"commit": "not available"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"author": "beachball",
|
|
87
|
+
"package": "@lage-run/cli",
|
|
88
|
+
"comment": "Bump @lage-run/scheduler-types to v0.3.16",
|
|
89
|
+
"commit": "not available"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"author": "beachball",
|
|
93
|
+
"package": "@lage-run/cli",
|
|
94
|
+
"comment": "Bump @lage-run/target-graph to v0.9.0",
|
|
95
|
+
"commit": "not available"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"author": "beachball",
|
|
99
|
+
"package": "@lage-run/cli",
|
|
100
|
+
"comment": "Bump @lage-run/worker-threads-pool to v0.8.3",
|
|
101
|
+
"commit": "not available"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"date": "Fri, 27 Sep 2024 20:03:49 GMT",
|
|
6
108
|
"version": "0.22.0",
|
|
7
109
|
"tag": "@lage-run/cli_v0.22.0",
|
|
8
110
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
# Change Log - @lage-run/cli
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on Fri,
|
|
3
|
+
<!-- This log was last generated on Fri, 04 Oct 2024 23:41:31 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.23.1
|
|
8
|
+
|
|
9
|
+
Fri, 04 Oct 2024 23:41:31 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Modified info command to accommodate a "LAGE_WORKER_SERVER" flag (also, --server) (kchau@microsoft.com)
|
|
14
|
+
- Bump @lage-run/rpc to v1.2.3
|
|
15
|
+
|
|
16
|
+
## 0.23.0
|
|
17
|
+
|
|
18
|
+
Wed, 02 Oct 2024 20:26:19 GMT
|
|
19
|
+
|
|
20
|
+
### Minor changes
|
|
21
|
+
|
|
22
|
+
- Simulate file access for lage server (kchau@microsoft.com)
|
|
23
|
+
- Bump @lage-run/cache to v1.3.4
|
|
24
|
+
- Bump @lage-run/config to v0.4.3
|
|
25
|
+
- Bump @lage-run/globby to v14.2.0
|
|
26
|
+
- Bump @lage-run/hasher to v1.6.0
|
|
27
|
+
- Bump @lage-run/reporters to v1.2.11
|
|
28
|
+
- Bump @lage-run/rpc to v1.2.2
|
|
29
|
+
- Bump @lage-run/runners to v1.0.3
|
|
30
|
+
- Bump @lage-run/scheduler to v1.3.2
|
|
31
|
+
- Bump @lage-run/scheduler-types to v0.3.16
|
|
32
|
+
- Bump @lage-run/target-graph to v0.9.0
|
|
33
|
+
- Bump @lage-run/worker-threads-pool to v0.8.3
|
|
34
|
+
|
|
7
35
|
## 0.22.0
|
|
8
36
|
|
|
9
|
-
Fri, 27 Sep 2024 20:03:
|
|
37
|
+
Fri, 27 Sep 2024 20:03:49 GMT
|
|
10
38
|
|
|
11
39
|
### Minor changes
|
|
12
40
|
|
|
@@ -2,8 +2,9 @@ import type { Command } from "commander";
|
|
|
2
2
|
import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
|
|
3
3
|
interface ExecOptions extends ReporterInitOptions {
|
|
4
4
|
cwd?: string;
|
|
5
|
-
server?:
|
|
6
|
-
|
|
5
|
+
server?: boolean | string;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
nodeArg?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare function execAction(options: ExecOptions, command: Command): Promise<void>;
|
|
9
10
|
export {};
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "execAction", {
|
|
|
11
11
|
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
12
12
|
const _initializeReporters = require("../initializeReporters.js");
|
|
13
13
|
const _executeInProcess = require("./executeInProcess.js");
|
|
14
|
+
const _executeRemotely = require("./executeRemotely.js");
|
|
14
15
|
function _interop_require_default(obj) {
|
|
15
16
|
return obj && obj.__esModule ? obj : {
|
|
16
17
|
default: obj
|
|
@@ -21,10 +22,16 @@ async function execAction(options, command) {
|
|
|
21
22
|
options.logLevel = options.logLevel ?? "info";
|
|
22
23
|
options.reporter = options.reporter ?? "json";
|
|
23
24
|
(0, _initializeReporters.initializeReporters)(logger, options);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const { server } = options;
|
|
26
|
+
if (server) {
|
|
27
|
+
logger.info("Running in server mode");
|
|
28
|
+
await (0, _executeRemotely.executeRemotely)(options, command);
|
|
29
|
+
} else {
|
|
30
|
+
await (0, _executeInProcess.executeInProcess)({
|
|
31
|
+
logger,
|
|
32
|
+
args: command.args,
|
|
33
|
+
cwd: options.cwd,
|
|
34
|
+
nodeArg: options.nodeArg
|
|
35
|
+
});
|
|
36
|
+
}
|
|
30
37
|
}
|
|
@@ -16,6 +16,7 @@ const _workspacetools = require("workspace-tools");
|
|
|
16
16
|
const _filterArgsForTasks = require("../run/filterArgsForTasks.js");
|
|
17
17
|
const _expandTargetDefinition = require("./expandTargetDefinition.js");
|
|
18
18
|
const _runners = require("@lage-run/runners");
|
|
19
|
+
const _runnerPickerOptions = require("../../runnerPickerOptions.js");
|
|
19
20
|
function _interop_require_default(obj) {
|
|
20
21
|
return obj && obj.__esModule ? obj : {
|
|
21
22
|
default: obj
|
|
@@ -102,26 +103,7 @@ async function executeInProcess({ cwd , args , nodeArg , logger }) {
|
|
|
102
103
|
});
|
|
103
104
|
const definition = (0, _expandTargetDefinition.expandTargetDefinition)(isGlobal ? undefined : info.name, task, pipeline, config.cacheOptions.outputGlob ?? []);
|
|
104
105
|
const target = isGlobal ? factory.createGlobalTarget(task, definition) : factory.createPackageTarget(info.name, task, definition);
|
|
105
|
-
const pickerOptions =
|
|
106
|
-
npmScript: {
|
|
107
|
-
script: require.resolve("../run/runners/NpmScriptRunner.js"),
|
|
108
|
-
options: {
|
|
109
|
-
nodeArg,
|
|
110
|
-
taskArgs,
|
|
111
|
-
npmCmd: config.npmClient
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
worker: {
|
|
115
|
-
script: require.resolve("../run/runners/WorkerRunner.js"),
|
|
116
|
-
options: {
|
|
117
|
-
taskArgs
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
noop: {
|
|
121
|
-
script: require.resolve("../run/runners/NoOpRunner.js"),
|
|
122
|
-
options: {}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
106
|
+
const pickerOptions = (0, _runnerPickerOptions.runnerPickerOptions)(nodeArg, config.npmClient, taskArgs);
|
|
125
107
|
const runnerPicker = new _runners.TargetRunnerPicker(pickerOptions);
|
|
126
108
|
const runner = await runnerPicker.pick(target);
|
|
127
109
|
if (await runner.shouldRun(target)) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
|
|
2
|
+
interface ExecRemotelyOptions extends ReporterInitOptions {
|
|
3
|
+
server?: string | boolean;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function executeRemotely(options: ExecRemotelyOptions, command: any): Promise<void>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "executeRemotely", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return executeRemotely;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
12
|
+
const _initializeReporters = require("../initializeReporters.js");
|
|
13
|
+
const _rpc = require("@lage-run/rpc");
|
|
14
|
+
const _filterArgsForTasks = require("../run/filterArgsForTasks.js");
|
|
15
|
+
const _simulateFileAccess = require("./simulateFileAccess.js");
|
|
16
|
+
const _execa = /*#__PURE__*/ _interop_require_default(require("execa"));
|
|
17
|
+
const _getBinPaths = require("../../getBinPaths.js");
|
|
18
|
+
function _interop_require_default(obj) {
|
|
19
|
+
return obj && obj.__esModule ? obj : {
|
|
20
|
+
default: obj
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async function tryCreateClient(host, port) {
|
|
24
|
+
const client = (0, _rpc.createClient)({
|
|
25
|
+
baseUrl: `http://${host}:${port}`,
|
|
26
|
+
httpVersion: "2"
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
const success = await client.ping({});
|
|
30
|
+
if (success.pong) {
|
|
31
|
+
return client;
|
|
32
|
+
}
|
|
33
|
+
} catch (e) {
|
|
34
|
+
if (e instanceof _rpc.ConnectError) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
async function tryCreateClientWithRetries(host, port, logger) {
|
|
42
|
+
let client;
|
|
43
|
+
const start = Date.now();
|
|
44
|
+
while(Date.now() - start < 5 * 1000){
|
|
45
|
+
try {
|
|
46
|
+
client = await tryCreateClient(host, port);
|
|
47
|
+
if (client) {
|
|
48
|
+
return client;
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
if (e instanceof _rpc.ConnectError) {
|
|
52
|
+
logger.error("Error connecting to server", e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
async function executeOnServer(args, client, logger) {
|
|
60
|
+
const task = args.length === 1 ? args[0] : args[1];
|
|
61
|
+
const packageName = args.length > 1 ? args[0] : undefined;
|
|
62
|
+
if (!task) {
|
|
63
|
+
throw new Error("No task provided");
|
|
64
|
+
}
|
|
65
|
+
const { taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(args ?? []);
|
|
66
|
+
const response = await client.runTarget({
|
|
67
|
+
packageName,
|
|
68
|
+
task,
|
|
69
|
+
taskArgs
|
|
70
|
+
});
|
|
71
|
+
logger.info(`Task ${response.packageName} ${response.task} exited with code ${response.exitCode} `);
|
|
72
|
+
return response;
|
|
73
|
+
}
|
|
74
|
+
async function executeRemotely(options, command) {
|
|
75
|
+
// launch a 'lage-server.js' process, detached if it is not already running
|
|
76
|
+
// send the command to the server process
|
|
77
|
+
const { server ="localhost:5332" } = options;
|
|
78
|
+
const timeout = options.timeout ?? 120;
|
|
79
|
+
const serverString = typeof options.server === "boolean" && options.server ? "localhost:5332" : !server ? "localhost:5332" : server;
|
|
80
|
+
const parts = serverString.split(":");
|
|
81
|
+
const host = parts[0];
|
|
82
|
+
const port = parseInt(parts[1] ?? "5332");
|
|
83
|
+
const logger = (0, _logger.default)();
|
|
84
|
+
options.logLevel = options.logLevel ?? "info";
|
|
85
|
+
options.reporter = options.reporter ?? "json";
|
|
86
|
+
(0, _initializeReporters.initializeReporters)(logger, options);
|
|
87
|
+
let client = await tryCreateClient(host, port);
|
|
88
|
+
const args = command.args;
|
|
89
|
+
if (!client) {
|
|
90
|
+
logger.info(`Starting server on http://${host}:${port}`);
|
|
91
|
+
const binPaths = (0, _getBinPaths.getBinPaths)();
|
|
92
|
+
const lageServerBinPath = binPaths["lage-server"];
|
|
93
|
+
const lageServerArgs = [
|
|
94
|
+
lageServerBinPath,
|
|
95
|
+
"--host",
|
|
96
|
+
host,
|
|
97
|
+
"--port",
|
|
98
|
+
port,
|
|
99
|
+
"--timeout",
|
|
100
|
+
timeout,
|
|
101
|
+
...args
|
|
102
|
+
];
|
|
103
|
+
logger.info(`Launching lage-server with these parameters: "${process.execPath}" ${lageServerArgs.join(" ")}`);
|
|
104
|
+
const child = (0, _execa.default)(process.execPath, lageServerArgs, {
|
|
105
|
+
detached: true,
|
|
106
|
+
stdio: "ignore"
|
|
107
|
+
});
|
|
108
|
+
child.unref();
|
|
109
|
+
logger.info("Server started", {
|
|
110
|
+
pid: child.pid
|
|
111
|
+
});
|
|
112
|
+
logger.info("Creating a client to connect to the background services");
|
|
113
|
+
client = await tryCreateClientWithRetries(host, port, logger);
|
|
114
|
+
if (!client) {
|
|
115
|
+
throw new Error("Server could not be started");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
logger.info(`Executing on server http://${host}:${port}`);
|
|
119
|
+
const response = await executeOnServer(args, client, logger);
|
|
120
|
+
process.stdout.write(response.stdout);
|
|
121
|
+
process.stderr.write(response.stderr);
|
|
122
|
+
process.exitCode = response.exitCode;
|
|
123
|
+
if (response.exitCode === 0) {
|
|
124
|
+
await (0, _simulateFileAccess.simulateFileAccess)(logger, response.inputs, response.outputs);
|
|
125
|
+
}
|
|
126
|
+
logger.info("Task execution finished");
|
|
127
|
+
}
|
|
@@ -11,5 +11,14 @@ Object.defineProperty(exports, "execCommand", {
|
|
|
11
11
|
const _commander = require("commander");
|
|
12
12
|
const _action = require("./action.js");
|
|
13
13
|
const _addLoggerOptions = require("../addLoggerOptions.js");
|
|
14
|
+
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
14
20
|
const execCommand = new _commander.Command("exec");
|
|
21
|
+
execCommand.option("-c|--concurrency <number>", "max jobs to run at a time", (v)=>parseInt(v), _os.default.cpus().length - 1);
|
|
22
|
+
execCommand.option("-s|--server [host:port]", "lage server host");
|
|
23
|
+
execCommand.option("-t|--timeout <seconds>", "lage server autoshutoff timeout", (v)=>parseInt(v), 1 * 60);
|
|
15
24
|
(0, _addLoggerOptions.addLoggerOptions)(execCommand).action(_action.execAction);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
|
|
3
|
-
interface
|
|
3
|
+
interface InfoActionOptions extends ReporterInitOptions {
|
|
4
4
|
dependencies: boolean;
|
|
5
5
|
dependents: boolean;
|
|
6
6
|
since: string;
|
|
@@ -9,9 +9,10 @@ interface RunOptions extends ReporterInitOptions {
|
|
|
9
9
|
cache: boolean;
|
|
10
10
|
nodeArg: string;
|
|
11
11
|
ignore: string[];
|
|
12
|
+
server: string;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* The info command displays information about a target graph in a workspace.
|
|
15
16
|
* The generated output can be read and used by other task runners, such as BuildXL.
|
|
16
17
|
*
|
|
17
18
|
* Expected format:
|
|
@@ -47,5 +48,5 @@ interface RunOptions extends ReporterInitOptions {
|
|
|
47
48
|
* ...
|
|
48
49
|
* ]
|
|
49
50
|
*/
|
|
50
|
-
export declare function infoAction(options:
|
|
51
|
+
export declare function infoAction(options: InfoActionOptions, command: Command): Promise<void>;
|
|
51
52
|
export {};
|
|
@@ -14,9 +14,12 @@ const _config = require("@lage-run/config");
|
|
|
14
14
|
const _workspacetools = require("workspace-tools");
|
|
15
15
|
const _getFilteredPackages = require("../../filter/getFilteredPackages.js");
|
|
16
16
|
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
17
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
18
17
|
const _targetgraph = require("@lage-run/target-graph");
|
|
18
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
19
19
|
const _initializeReporters = require("../initializeReporters.js");
|
|
20
|
+
const _runners = require("@lage-run/runners");
|
|
21
|
+
const _getBinPaths = require("../../getBinPaths.js");
|
|
22
|
+
const _runnerPickerOptions = require("../../runnerPickerOptions.js");
|
|
20
23
|
function _interop_require_default(obj) {
|
|
21
24
|
return obj && obj.__esModule ? obj : {
|
|
22
25
|
default: obj
|
|
@@ -28,22 +31,11 @@ async function infoAction(options, command) {
|
|
|
28
31
|
const logger = (0, _logger.default)();
|
|
29
32
|
options.logLevel = options.logLevel ?? "info";
|
|
30
33
|
options.reporter = options.reporter ?? "json";
|
|
34
|
+
options.server = typeof options.server === "boolean" && options.server ? "localhost:5332" : options.server;
|
|
31
35
|
(0, _initializeReporters.initializeReporters)(logger, options);
|
|
32
36
|
const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
|
|
33
37
|
const packageInfos = (0, _workspacetools.getPackageInfos)(root);
|
|
34
|
-
const
|
|
35
|
-
const scope = prepareAndGetFilteredPackages(config, logger, root, options, packageInfos);
|
|
36
|
-
const packageTasks = processTargets(targetGraph.targets, packageInfos, config);
|
|
37
|
-
logger.info("info", {
|
|
38
|
-
command: command.args,
|
|
39
|
-
scope,
|
|
40
|
-
packageTasks: [
|
|
41
|
-
...packageTasks.values()
|
|
42
|
-
].flat()
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function prepareAndCreateTargetGraph(config, logger, root, options, packageInfos, command) {
|
|
46
|
-
const { tasks } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
|
|
38
|
+
const { tasks , taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
|
|
47
39
|
const targetGraph = (0, _createTargetGraph.createTargetGraph)({
|
|
48
40
|
logger,
|
|
49
41
|
root,
|
|
@@ -58,9 +50,6 @@ function prepareAndCreateTargetGraph(config, logger, root, options, packageInfos
|
|
|
58
50
|
tasks,
|
|
59
51
|
packageInfos
|
|
60
52
|
});
|
|
61
|
-
return targetGraph;
|
|
62
|
-
}
|
|
63
|
-
function prepareAndGetFilteredPackages(config, logger, root, options, packageInfos) {
|
|
64
53
|
const scope = (0, _getFilteredPackages.getFilteredPackages)({
|
|
65
54
|
root,
|
|
66
55
|
packageInfos,
|
|
@@ -72,76 +61,85 @@ function prepareAndGetFilteredPackages(config, logger, root, options, packageInf
|
|
|
72
61
|
repoWideChanges: config.repoWideChanges,
|
|
73
62
|
sinceIgnoreGlobs: options.ignore.concat(config.ignore)
|
|
74
63
|
});
|
|
75
|
-
|
|
64
|
+
const pickerOptions = (0, _runnerPickerOptions.runnerPickerOptions)(options.nodeArg, config.npmClient, taskArgs);
|
|
65
|
+
const runnerPicker = new _runners.TargetRunnerPicker(pickerOptions);
|
|
66
|
+
const optimizedTargets = await optimizeTargetGraph(targetGraph, runnerPicker);
|
|
67
|
+
const binPaths = (0, _getBinPaths.getBinPaths)();
|
|
68
|
+
const packageTasks = optimizedTargets.map((target)=>generatePackageTask(target, taskArgs, config, options, binPaths));
|
|
69
|
+
logger.info("info", {
|
|
70
|
+
command: command.args,
|
|
71
|
+
scope,
|
|
72
|
+
packageTasks
|
|
73
|
+
});
|
|
76
74
|
}
|
|
77
|
-
function
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
75
|
+
async function optimizeTargetGraph(graph, runnerPicker) {
|
|
76
|
+
const targetMinimizedNodes = await (0, _targetgraph.removeNodes)([
|
|
77
|
+
...graph.targets.values()
|
|
78
|
+
] ?? [], async (target)=>{
|
|
79
|
+
if (target.type === "noop") {
|
|
80
|
+
return true;
|
|
83
81
|
}
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
const packageName = packageTask.package;
|
|
88
|
-
if (!packageTasks.has(packageName)) {
|
|
89
|
-
packageTasks.set(packageName, []);
|
|
90
|
-
}
|
|
91
|
-
packageTasks.get(packageName).push(packageTask); // Use the non-null assertion operator to avoid type errors
|
|
82
|
+
const runner = await runnerPicker.pick(target);
|
|
83
|
+
if (!await runner.shouldRun(target)) {
|
|
84
|
+
return true;
|
|
92
85
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
function isTargetNoop(target, packageInfos) {
|
|
97
|
-
return !packageInfos[target.packageName]?.scripts?.[target.task];
|
|
98
|
-
}
|
|
99
|
-
function shouldSkipTarget(target, packageInfos) {
|
|
100
|
-
return target.id === (0, _targetgraph.getStartTargetId)() || isTargetNoop(target, packageInfos);
|
|
86
|
+
return false;
|
|
87
|
+
});
|
|
88
|
+
return (0, _targetgraph.transitiveReduction)(targetMinimizedNodes);
|
|
101
89
|
}
|
|
102
|
-
function generatePackageTask(target,
|
|
103
|
-
const command = generateCommand(target, config);
|
|
90
|
+
function generatePackageTask(target, taskArgs, config, options, binPaths) {
|
|
91
|
+
const command = generateCommand(target, taskArgs, config, options, binPaths);
|
|
104
92
|
const workingDirectory = getWorkingDirectory(target);
|
|
105
|
-
const dependenciesSet = resolveDependencies(target.dependencies, targets, packageInfos, dependenciesCache);
|
|
106
93
|
const packageTask = {
|
|
107
94
|
id: target.id,
|
|
108
95
|
command,
|
|
109
|
-
dependencies:
|
|
110
|
-
...dependenciesSet
|
|
111
|
-
],
|
|
96
|
+
dependencies: target.dependencies,
|
|
112
97
|
workingDirectory,
|
|
113
|
-
package: target.packageName,
|
|
98
|
+
package: target.packageName ?? "",
|
|
114
99
|
task: target.task
|
|
115
100
|
};
|
|
116
101
|
return packageTask;
|
|
117
102
|
}
|
|
118
|
-
function
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
103
|
+
function generateCommand(target, taskArgs, config, options, binPaths) {
|
|
104
|
+
const shouldRunWorkersAsService = typeof process.env.LAGE_WORKER_SERVER === "string" && process.env.LAGE_WORKER_SERVER !== "false" || !!options.server;
|
|
105
|
+
if (target.type === "npmScript") {
|
|
106
|
+
const npmClient = config.npmClient ?? "npm";
|
|
107
|
+
const command = [
|
|
108
|
+
npmClient,
|
|
109
|
+
...getNpmArgs(target.task, taskArgs)
|
|
110
|
+
];
|
|
111
|
+
return command;
|
|
112
|
+
} else if (target.type === "worker" && shouldRunWorkersAsService) {
|
|
113
|
+
const command = [
|
|
114
|
+
process.execPath,
|
|
115
|
+
binPaths["lage"],
|
|
116
|
+
"exec",
|
|
117
|
+
"--server",
|
|
118
|
+
options.server
|
|
119
|
+
];
|
|
120
|
+
if (options.concurrency) {
|
|
121
|
+
command.push("--concurrency", options.concurrency.toString());
|
|
122
|
+
}
|
|
123
|
+
if (target.packageName) {
|
|
124
|
+
command.push(target.packageName);
|
|
123
125
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
if (isTargetNoop(dependencyTarget, packageInfos)) {
|
|
127
|
-
dependenciesCache.set(dependency, resolveDependencies(dependencyTarget.dependencies, targets, packageInfos, dependenciesCache));
|
|
128
|
-
} else {
|
|
129
|
-
dependenciesCache.set(dependency, new Set([
|
|
130
|
-
dependency
|
|
131
|
-
]));
|
|
132
|
-
}
|
|
126
|
+
if (target.task) {
|
|
127
|
+
command.push(target.task);
|
|
133
128
|
}
|
|
134
|
-
|
|
129
|
+
command.push(...taskArgs);
|
|
130
|
+
return command;
|
|
131
|
+
} else if (target.type === "worker") {
|
|
132
|
+
const command = [
|
|
133
|
+
process.execPath,
|
|
134
|
+
binPaths.lage,
|
|
135
|
+
"exec"
|
|
136
|
+
];
|
|
137
|
+
command.push(target.packageName ?? "");
|
|
138
|
+
command.push(target.task);
|
|
139
|
+
command.push(...taskArgs);
|
|
140
|
+
return command;
|
|
135
141
|
}
|
|
136
|
-
return
|
|
137
|
-
}
|
|
138
|
-
function generateCommand(target, config) {
|
|
139
|
-
const npmClient = config.npmClient ?? "npm";
|
|
140
|
-
const command = [
|
|
141
|
-
npmClient,
|
|
142
|
-
...getNpmArgs(target.task, target.taskArgs)
|
|
143
|
-
];
|
|
144
|
-
return command;
|
|
142
|
+
return [];
|
|
145
143
|
}
|
|
146
144
|
function getWorkingDirectory(target) {
|
|
147
145
|
const cwd = process.cwd();
|
|
@@ -13,4 +13,8 @@ const _action = require("./action.js");
|
|
|
13
13
|
const _addFilterOptions = require("../addFilterOptions.js");
|
|
14
14
|
const _addLoggerOptions = require("../addLoggerOptions.js");
|
|
15
15
|
const infoCommand = new _commander.Command("info");
|
|
16
|
-
(0, _addFilterOptions.addFilterOptions)((0, _addLoggerOptions.addLoggerOptions)(infoCommand))
|
|
16
|
+
(0, _addFilterOptions.addFilterOptions)((0, _addLoggerOptions.addLoggerOptions)(infoCommand));
|
|
17
|
+
infoCommand.description("Display information about a target graph in a workspace.\n" + "It is used by BuildXL to build a pip-graph");
|
|
18
|
+
infoCommand.option("--server [host:port]", "Run targets of type 'worker' on a background service");
|
|
19
|
+
infoCommand.option("--nodearg|--node-arg <nodeArg>", 'arguments to be passed to node (e.g. --nodearg="--max_old_space_size=1234 --heap-prof" - set via "NODE_OPTIONS" environment variable');
|
|
20
|
+
infoCommand.action(_action.infoAction);
|
|
@@ -8,13 +8,10 @@ Object.defineProperty(exports, "action", {
|
|
|
8
8
|
return action;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _infoAction = require("./infoAction.js");
|
|
12
11
|
const _runAction = require("./runAction.js");
|
|
13
12
|
const _watchAction = require("./watchAction.js");
|
|
14
13
|
async function action(options, command) {
|
|
15
|
-
if (options.
|
|
16
|
-
return (0, _infoAction.infoAction)(options, command);
|
|
17
|
-
} else if (options.unstableWatch) {
|
|
14
|
+
if (options.watch) {
|
|
18
15
|
return (0, _watchAction.watchAction)(options, command);
|
|
19
16
|
} else {
|
|
20
17
|
return (0, _runAction.runAction)(options, command);
|
|
@@ -15,7 +15,7 @@ const _isRunningFromCI = require("../isRunningFromCI.js");
|
|
|
15
15
|
const _addFilterOptions = require("../addFilterOptions.js");
|
|
16
16
|
const runCommand = new _commander.Command("run");
|
|
17
17
|
(0, _addFilterOptions.addFilterOptions)((0, _addLoggerOptions.addLoggerOptions)(runCommand)).action(_action.action).option("-c, --concurrency <n>", "concurrency", (value)=>parseInt(value, 10)).option("--max-workers-per-task <maxWorkersPerTarget...>", "set max worker per task, e.g. --max-workers-per-task build=2 test=4", [])// Run Command Options
|
|
18
|
-
.option("--no-cache", "disables the cache").option("--reset-cache", "resets the cache, filling it after a run").option("--skip-local-cache", "skips caching locally (defaults to true in CI environments)", _isRunningFromCI.isRunningFromCI).option("--profile [profile]", "writes a run profile into a file that can be processed by Chromium devtool").option("--nodearg|--node-arg <nodeArg>", 'arguments to be passed to node (e.g. --nodearg="--max_old_space_size=1234 --heap-prof" - set via "NODE_OPTIONS" environment variable').option("--continue", "continues the run even on error").option("--allow-no-target-runs").
|
|
18
|
+
.option("--no-cache", "disables the cache").option("--reset-cache", "resets the cache, filling it after a run").option("--skip-local-cache", "skips caching locally (defaults to true in CI environments)", _isRunningFromCI.isRunningFromCI).option("--profile [profile]", "writes a run profile into a file that can be processed by Chromium devtool").option("--nodearg|--node-arg <nodeArg>", 'arguments to be passed to node (e.g. --nodearg="--max_old_space_size=1234 --heap-prof" - set via "NODE_OPTIONS" environment variable').option("--continue", "continues the run even on error").option("--allow-no-target-runs").option("--watch", "runs in watch mode").allowUnknownOption(true).addHelpCommand("[run] command1 [command2...commandN] [options]", "run commands").addHelpText("after", `
|
|
19
19
|
Runs a set of commands in a target graph. The targets are defined by packages and their scripts as defined the package.json files.
|
|
20
20
|
|
|
21
21
|
Examples
|
|
@@ -18,6 +18,7 @@ const _scheduler = require("@lage-run/scheduler");
|
|
|
18
18
|
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
19
19
|
const _errors = require("../../types/errors.js");
|
|
20
20
|
const _createCacheProvider = require("../../cache/createCacheProvider.js");
|
|
21
|
+
const _runnerPickerOptions = require("../../runnerPickerOptions.js");
|
|
21
22
|
function _interop_require_default(obj) {
|
|
22
23
|
return obj && obj.__esModule ? obj : {
|
|
23
24
|
default: obj
|
|
@@ -76,24 +77,7 @@ async function runAction(options, command) {
|
|
|
76
77
|
skipLocalCache: options.skipLocalCache,
|
|
77
78
|
cacheOptions: config.cacheOptions,
|
|
78
79
|
runners: {
|
|
79
|
-
|
|
80
|
-
script: require.resolve("./runners/NpmScriptRunner.js"),
|
|
81
|
-
options: {
|
|
82
|
-
nodeArg: options.nodeArg,
|
|
83
|
-
taskArgs,
|
|
84
|
-
npmCmd: config.npmClient
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
worker: {
|
|
88
|
-
script: require.resolve("./runners/WorkerRunner.js"),
|
|
89
|
-
options: {
|
|
90
|
-
taskArgs
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
noop: {
|
|
94
|
-
script: require.resolve("./runners/NoOpRunner.js"),
|
|
95
|
-
options: {}
|
|
96
|
-
},
|
|
80
|
+
...(0, _runnerPickerOptions.runnerPickerOptions)(options.nodeArg, config.npmClient, taskArgs),
|
|
97
81
|
...config.runners
|
|
98
82
|
}
|
|
99
83
|
},
|
|
@@ -18,6 +18,7 @@ const _scheduler = require("@lage-run/scheduler");
|
|
|
18
18
|
const _watcher = require("./watcher.js");
|
|
19
19
|
const _logger = /*#__PURE__*/ _interop_require_wildcard(require("@lage-run/logger"));
|
|
20
20
|
const _createCacheProvider = require("../../cache/createCacheProvider.js");
|
|
21
|
+
const _runnerPickerOptions = require("../../runnerPickerOptions.js");
|
|
21
22
|
function _getRequireWildcardCache(nodeInterop) {
|
|
22
23
|
if (typeof WeakMap !== "function") return null;
|
|
23
24
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -106,24 +107,7 @@ async function watchAction(options, command) {
|
|
|
106
107
|
skipLocalCache: options.skipLocalCache,
|
|
107
108
|
cacheOptions: config.cacheOptions,
|
|
108
109
|
runners: {
|
|
109
|
-
|
|
110
|
-
script: require.resolve("./runners/NpmScriptRunner.js"),
|
|
111
|
-
options: {
|
|
112
|
-
nodeArg: options.nodeArg,
|
|
113
|
-
taskArgs,
|
|
114
|
-
npmCmd: config.npmClient
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
worker: {
|
|
118
|
-
script: require.resolve("./runners/WorkerRunner.js"),
|
|
119
|
-
options: {
|
|
120
|
-
taskArgs
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
noop: {
|
|
124
|
-
script: require.resolve("./runners/NoOpRunner.js"),
|
|
125
|
-
options: {}
|
|
126
|
-
},
|
|
110
|
+
...(0, _runnerPickerOptions.runnerPickerOptions)(options.nodeArg, config.npmClient, taskArgs),
|
|
127
111
|
...config.runners
|
|
128
112
|
}
|
|
129
113
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Writable } from "stream";
|
|
4
|
+
export declare class MemoryStream extends Writable {
|
|
5
|
+
private chunks;
|
|
6
|
+
constructor();
|
|
7
|
+
_write(chunk: any, encoding: BufferEncoding): void;
|
|
8
|
+
getData(): Buffer;
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "MemoryStream", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return MemoryStream;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _stream = require("stream");
|
|
12
|
+
function _define_property(obj, key, value) {
|
|
13
|
+
if (key in obj) {
|
|
14
|
+
Object.defineProperty(obj, key, {
|
|
15
|
+
value: value,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
obj[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
class MemoryStream extends _stream.Writable {
|
|
26
|
+
_write(chunk, encoding) {
|
|
27
|
+
this.chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding));
|
|
28
|
+
}
|
|
29
|
+
getData() {
|
|
30
|
+
return Buffer.concat(this.chunks);
|
|
31
|
+
}
|
|
32
|
+
toString() {
|
|
33
|
+
return this.getData().toString();
|
|
34
|
+
}
|
|
35
|
+
constructor(){
|
|
36
|
+
super();
|
|
37
|
+
_define_property(this, "chunks", void 0);
|
|
38
|
+
this.chunks = [];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
|
|
2
|
-
import type { Command } from "commander";
|
|
3
2
|
interface WorkerOptions extends ReporterInitOptions {
|
|
4
3
|
nodeArg?: string[];
|
|
5
4
|
port?: number;
|
|
@@ -7,5 +6,5 @@ interface WorkerOptions extends ReporterInitOptions {
|
|
|
7
6
|
timeout?: number;
|
|
8
7
|
shutdown: boolean;
|
|
9
8
|
}
|
|
10
|
-
export declare function serverAction(options: WorkerOptions
|
|
9
|
+
export declare function serverAction(options: WorkerOptions): Promise<void>;
|
|
11
10
|
export {};
|
|
@@ -11,88 +11,36 @@ Object.defineProperty(exports, "serverAction", {
|
|
|
11
11
|
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
12
12
|
const _initializeReporters = require("../initializeReporters.js");
|
|
13
13
|
const _lageService = require("./lageService.js");
|
|
14
|
-
const _filterArgsForTasks = require("../run/filterArgsForTasks.js");
|
|
15
14
|
const _rpc = require("@lage-run/rpc");
|
|
16
|
-
const _simulateFileAccess = require("./simulateFileAccess.js");
|
|
17
15
|
function _interop_require_default(obj) {
|
|
18
16
|
return obj && obj.__esModule ? obj : {
|
|
19
17
|
default: obj
|
|
20
18
|
};
|
|
21
19
|
}
|
|
22
|
-
async function
|
|
23
|
-
const client = (0, _rpc.createClient)({
|
|
24
|
-
baseUrl: `http://${host}:${port}`,
|
|
25
|
-
httpVersion: "1.1"
|
|
26
|
-
});
|
|
27
|
-
try {
|
|
28
|
-
const success = await client.ping({});
|
|
29
|
-
if (success.pong) {
|
|
30
|
-
return client;
|
|
31
|
-
}
|
|
32
|
-
} catch (e) {
|
|
33
|
-
if (e instanceof _rpc.ConnectError) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
throw e;
|
|
37
|
-
}
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
async function executeOnServer(args, client, logger) {
|
|
41
|
-
const task = args.length === 1 ? args[0] : args[1];
|
|
42
|
-
const packageName = args.length > 1 ? args[0] : undefined;
|
|
43
|
-
if (!task) {
|
|
44
|
-
throw new Error("No task provided");
|
|
45
|
-
}
|
|
46
|
-
const { taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(args ?? []);
|
|
47
|
-
const response = await client.runTarget({
|
|
48
|
-
packageName,
|
|
49
|
-
task,
|
|
50
|
-
taskArgs
|
|
51
|
-
});
|
|
52
|
-
logger.info(`Task ${response.packageName} ${response.task} exited with code ${response.exitCode} `);
|
|
53
|
-
process.exitCode = response.exitCode;
|
|
54
|
-
if (response.exitCode === 0) {
|
|
55
|
-
await (0, _simulateFileAccess.simulateFileAccess)(logger, response.inputs, response.outputs);
|
|
56
|
-
}
|
|
57
|
-
logger.info("Task execution finished");
|
|
58
|
-
}
|
|
59
|
-
async function serverAction(options, command) {
|
|
20
|
+
async function serverAction(options) {
|
|
60
21
|
const { port =5332 , host ="localhost" , timeout =1 } = options;
|
|
61
22
|
const logger = (0, _logger.default)();
|
|
62
23
|
options.logLevel = options.logLevel ?? "info";
|
|
63
24
|
options.reporter = options.reporter ?? "json";
|
|
64
25
|
(0, _initializeReporters.initializeReporters)(logger, options);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const server = await (0, _rpc.createServer)(lageService, abortController);
|
|
84
|
-
await server.listen({
|
|
85
|
-
host,
|
|
86
|
-
port
|
|
87
|
-
});
|
|
88
|
-
logger.info(`Server listening on http://${host}:${port}, timeout in ${timeout} seconds`);
|
|
89
|
-
const client = await tryCreateClient(host, port);
|
|
90
|
-
if (!client) {
|
|
91
|
-
throw new Error("Server could not be reached");
|
|
92
|
-
}
|
|
93
|
-
const args = command.args;
|
|
94
|
-
await executeOnServer(args, client, logger);
|
|
95
|
-
}
|
|
26
|
+
logger.info(`Starting server on http://${host}:${port}`);
|
|
27
|
+
const abortController = new AbortController();
|
|
28
|
+
const lageService = await (0, _lageService.createLageService)({
|
|
29
|
+
cwd: process.cwd(),
|
|
30
|
+
serverControls: {
|
|
31
|
+
abortController,
|
|
32
|
+
countdownToShutdown: ()=>resetTimer(logger, timeout, abortController, server),
|
|
33
|
+
clearCountdown: clearTimer
|
|
34
|
+
},
|
|
35
|
+
logger,
|
|
36
|
+
maxWorkers: options.concurrency
|
|
37
|
+
});
|
|
38
|
+
const server = await (0, _rpc.createServer)(lageService, abortController);
|
|
39
|
+
await server.listen({
|
|
40
|
+
host,
|
|
41
|
+
port
|
|
42
|
+
});
|
|
43
|
+
logger.info(`Server listening on http://${host}:${port}, timeout in ${timeout} seconds`);
|
|
96
44
|
}
|
|
97
45
|
let timeoutHandle;
|
|
98
46
|
function resetTimer(logger, timeout, abortController, server) {
|
|
@@ -16,6 +16,8 @@ const _workerthreadspool = require("@lage-run/worker-threads-pool");
|
|
|
16
16
|
const _hasher = require("@lage-run/hasher");
|
|
17
17
|
const _getOutputFiles = require("./getOutputFiles.js");
|
|
18
18
|
const _globby = require("@lage-run/globby");
|
|
19
|
+
const _MemoryStream = require("./MemoryStream.js");
|
|
20
|
+
const _runnerPickerOptions = require("../../runnerPickerOptions.js");
|
|
19
21
|
function findAllTasks(pipeline) {
|
|
20
22
|
const tasks = new Set();
|
|
21
23
|
for (const key of Object.keys(pipeline)){
|
|
@@ -45,7 +47,7 @@ async function initializeOnce(cwd, logger) {
|
|
|
45
47
|
pipeline,
|
|
46
48
|
repoWideChanges: config.repoWideChanges,
|
|
47
49
|
scope: undefined,
|
|
48
|
-
since:
|
|
50
|
+
since: undefined,
|
|
49
51
|
outputs: config.cacheOptions.outputGlob,
|
|
50
52
|
tasks,
|
|
51
53
|
packageInfos
|
|
@@ -92,27 +94,9 @@ async function createLageService({ cwd , serverControls , logger , maxWorkers }
|
|
|
92
94
|
},
|
|
93
95
|
async runTarget (request) {
|
|
94
96
|
serverControls.clearCountdown();
|
|
97
|
+
logger.info("Running target", request);
|
|
95
98
|
const { config , targetGraph , dependencyMap , packageTree , root } = await initializeOnce(cwd, logger);
|
|
96
|
-
const runners =
|
|
97
|
-
npmScript: {
|
|
98
|
-
script: require.resolve("../run/runners/NpmScriptRunner.js"),
|
|
99
|
-
options: {
|
|
100
|
-
nodeOptions: request.nodeOptions,
|
|
101
|
-
taskArgs: request.taskArgs,
|
|
102
|
-
npmCmd: config.npmClient
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
worker: {
|
|
106
|
-
script: require.resolve("../run/runners/WorkerRunner.js"),
|
|
107
|
-
options: {
|
|
108
|
-
taskArgs: request.taskArgs
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
noop: {
|
|
112
|
-
script: require.resolve("../run/runners/NoOpRunner.js"),
|
|
113
|
-
options: {}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
99
|
+
const runners = (0, _runnerPickerOptions.runnerPickerOptions)(request.nodeOptions, config.npmClient, request.taskArgs);
|
|
116
100
|
const id = (0, _targetgraph.getTargetId)(request.packageName, request.task);
|
|
117
101
|
if (!targetGraph.targets.has(id)) {
|
|
118
102
|
logger.error(`Target not found: ${request.packageName}#${request.task}`);
|
|
@@ -127,6 +111,8 @@ async function createLageService({ cwd , serverControls , logger , maxWorkers }
|
|
|
127
111
|
target,
|
|
128
112
|
runners
|
|
129
113
|
};
|
|
114
|
+
const writableStdout = new _MemoryStream.MemoryStream();
|
|
115
|
+
const writableStderr = new _MemoryStream.MemoryStream();
|
|
130
116
|
let pipedStdout;
|
|
131
117
|
let pipedStderr;
|
|
132
118
|
try {
|
|
@@ -134,20 +120,22 @@ async function createLageService({ cwd , serverControls , logger , maxWorkers }
|
|
|
134
120
|
logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} start`);
|
|
135
121
|
pipedStdout = stdout;
|
|
136
122
|
pipedStderr = stderr;
|
|
137
|
-
stdout.pipe(
|
|
138
|
-
stderr.pipe(
|
|
123
|
+
stdout.pipe(writableStdout);
|
|
124
|
+
stderr.pipe(writableStderr);
|
|
139
125
|
}, (worker)=>{
|
|
140
126
|
logger.info(`[${worker.threadId}] ${request.packageName}#${request.task} end`);
|
|
141
|
-
pipedStdout.unpipe(
|
|
142
|
-
pipedStderr.unpipe(
|
|
127
|
+
pipedStdout.unpipe(writableStdout);
|
|
128
|
+
pipedStderr.unpipe(writableStderr);
|
|
143
129
|
});
|
|
144
130
|
const globalInputs = target.environmentGlob ? (0, _globby.glob)(target.environmentGlob, {
|
|
145
131
|
cwd: root,
|
|
146
132
|
gitignore: true
|
|
147
|
-
}) : (0, _globby.glob)(config.cacheOptions?.environmentGlob, {
|
|
133
|
+
}) : config.cacheOptions?.environmentGlob ? (0, _globby.glob)(config.cacheOptions?.environmentGlob, {
|
|
148
134
|
cwd: root,
|
|
149
135
|
gitignore: true
|
|
150
|
-
})
|
|
136
|
+
}) : [
|
|
137
|
+
"lage.config.js"
|
|
138
|
+
];
|
|
151
139
|
const inputs = ((0, _hasher.getInputFiles)(target, dependencyMap, packageTree) ?? []).concat(globalInputs);
|
|
152
140
|
return {
|
|
153
141
|
packageName: request.packageName,
|
|
@@ -156,6 +144,8 @@ async function createLageService({ cwd , serverControls , logger , maxWorkers }
|
|
|
156
144
|
hash: "",
|
|
157
145
|
inputs,
|
|
158
146
|
outputs: (0, _getOutputFiles.getOutputFiles)(root, target, config.cacheOptions?.outputGlob, packageTree),
|
|
147
|
+
stdout: writableStdout.toString(),
|
|
148
|
+
stderr: writableStderr.toString(),
|
|
159
149
|
id
|
|
160
150
|
};
|
|
161
151
|
} catch (e) {
|
|
@@ -166,6 +156,8 @@ async function createLageService({ cwd , serverControls , logger , maxWorkers }
|
|
|
166
156
|
hash: "",
|
|
167
157
|
inputs: [],
|
|
168
158
|
outputs: [],
|
|
159
|
+
stdout: "",
|
|
160
|
+
stderr: e instanceof Error ? e.toString() : "",
|
|
169
161
|
id
|
|
170
162
|
};
|
|
171
163
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getBinPaths", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getBinPaths;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function getBinPaths() {
|
|
19
|
+
let dir = __dirname;
|
|
20
|
+
let packageJsonPath = "";
|
|
21
|
+
while(dir !== "/"){
|
|
22
|
+
packageJsonPath = _path.default.join(dir, "package.json");
|
|
23
|
+
if (_fs.default.existsSync(packageJsonPath)) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
dir = _path.default.dirname(dir);
|
|
27
|
+
}
|
|
28
|
+
const packageJson = JSON.parse(_fs.default.readFileSync(_path.default.join(dir, "package.json"), "utf8"));
|
|
29
|
+
return {
|
|
30
|
+
lage: _path.default.join(dir, packageJson.bin.lage),
|
|
31
|
+
"lage-server": _path.default.join(dir, packageJson.bin["lage-server"])
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "runnerPickerOptions", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return runnerPickerOptions;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function runnerPickerOptions(nodeArg, npmCmd, taskArgs) {
|
|
12
|
+
return {
|
|
13
|
+
npmScript: {
|
|
14
|
+
script: require.resolve("./runners/NpmScriptRunner.js"),
|
|
15
|
+
options: {
|
|
16
|
+
nodeArg,
|
|
17
|
+
taskArgs,
|
|
18
|
+
npmCmd
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
worker: {
|
|
22
|
+
script: require.resolve("./runners/WorkerRunner.js"),
|
|
23
|
+
options: {
|
|
24
|
+
taskArgs
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
noop: {
|
|
28
|
+
script: require.resolve("./runners/NoOpRunner.js"),
|
|
29
|
+
options: {}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Command Line Interface for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://microsoft.github.io/lage/",
|
|
10
10
|
"bin": {
|
|
11
|
-
"lage": "./bin/lage"
|
|
11
|
+
"lage": "./bin/lage.js",
|
|
12
|
+
"lage-server": "./bin/lage-server.js"
|
|
12
13
|
},
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"main": "lib/index.js",
|
|
@@ -20,18 +21,18 @@
|
|
|
20
21
|
"lint": "monorepo-scripts lint"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@lage-run/cache": "^1.3.
|
|
24
|
-
"@lage-run/config": "^0.4.
|
|
25
|
-
"@lage-run/globby": "^14.
|
|
26
|
-
"@lage-run/hasher": "^1.
|
|
24
|
+
"@lage-run/cache": "^1.3.4",
|
|
25
|
+
"@lage-run/config": "^0.4.3",
|
|
26
|
+
"@lage-run/globby": "^14.2.0",
|
|
27
|
+
"@lage-run/hasher": "^1.6.0",
|
|
27
28
|
"@lage-run/logger": "^1.3.1",
|
|
28
|
-
"@lage-run/reporters": "^1.2.
|
|
29
|
-
"@lage-run/rpc": "^1.2.
|
|
30
|
-
"@lage-run/runners": "^1.0.
|
|
31
|
-
"@lage-run/scheduler": "^1.3.
|
|
32
|
-
"@lage-run/scheduler-types": "^0.3.
|
|
33
|
-
"@lage-run/target-graph": "^0.
|
|
34
|
-
"@lage-run/worker-threads-pool": "^0.8.
|
|
29
|
+
"@lage-run/reporters": "^1.2.11",
|
|
30
|
+
"@lage-run/rpc": "^1.2.3",
|
|
31
|
+
"@lage-run/runners": "^1.0.3",
|
|
32
|
+
"@lage-run/scheduler": "^1.3.2",
|
|
33
|
+
"@lage-run/scheduler-types": "^0.3.16",
|
|
34
|
+
"@lage-run/target-graph": "^0.9.0",
|
|
35
|
+
"@lage-run/worker-threads-pool": "^0.8.3",
|
|
35
36
|
"chokidar": "3.5.3",
|
|
36
37
|
"commander": "9.5.0",
|
|
37
38
|
"execa": "5.1.1",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
|
|
3
|
-
interface RunOptions extends ReporterInitOptions {
|
|
4
|
-
dependencies: boolean;
|
|
5
|
-
dependents: boolean;
|
|
6
|
-
since: string;
|
|
7
|
-
scope: string[];
|
|
8
|
-
to: string[];
|
|
9
|
-
cache: boolean;
|
|
10
|
-
nodeArg: string;
|
|
11
|
-
ignore: string[];
|
|
12
|
-
}
|
|
13
|
-
export declare function infoAction(options: RunOptions, command: Command): Promise<void>;
|
|
14
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "infoAction", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return infoAction;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _createTargetGraph = require("./createTargetGraph.js");
|
|
12
|
-
const _filterArgsForTasks = require("./filterArgsForTasks.js");
|
|
13
|
-
const _config = require("@lage-run/config");
|
|
14
|
-
const _workspacetools = require("workspace-tools");
|
|
15
|
-
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
16
|
-
const _targetgraph = require("@lage-run/target-graph");
|
|
17
|
-
function _interop_require_default(obj) {
|
|
18
|
-
return obj && obj.__esModule ? obj : {
|
|
19
|
-
default: obj
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
async function infoAction(options, command) {
|
|
23
|
-
const cwd = process.cwd();
|
|
24
|
-
const config = await (0, _config.getConfig)(cwd);
|
|
25
|
-
const logger = (0, _logger.default)();
|
|
26
|
-
// Build Target Graph
|
|
27
|
-
const root = (0, _workspacetools.getWorkspaceRoot)(process.cwd());
|
|
28
|
-
const packageInfos = await (0, _workspacetools.getPackageInfosAsync)(root);
|
|
29
|
-
const { tasks } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
|
|
30
|
-
const targetGraph = (0, _createTargetGraph.createTargetGraph)({
|
|
31
|
-
logger,
|
|
32
|
-
root,
|
|
33
|
-
dependencies: options.dependencies,
|
|
34
|
-
dependents: options.dependents && !options.to,
|
|
35
|
-
ignore: options.ignore.concat(config.ignore),
|
|
36
|
-
pipeline: config.pipeline,
|
|
37
|
-
repoWideChanges: config.repoWideChanges,
|
|
38
|
-
scope: (options.scope ?? []).concat(options.to ?? []),
|
|
39
|
-
since: options.since,
|
|
40
|
-
outputs: config.cacheOptions.outputGlob,
|
|
41
|
-
tasks,
|
|
42
|
-
packageInfos
|
|
43
|
-
});
|
|
44
|
-
// Make sure we do not attempt writeRemoteCache in info mode
|
|
45
|
-
config.cacheOptions.writeRemoteCache = false;
|
|
46
|
-
const { targets } = targetGraph;
|
|
47
|
-
for (const target of targets.values()){
|
|
48
|
-
if (target.id === (0, _targetgraph.getStartTargetId)()) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const startIdIndex = target.dependencies.indexOf((0, _targetgraph.getStartTargetId)());
|
|
52
|
-
target.dependencies.splice(startIdIndex, 1);
|
|
53
|
-
process.stdout.write(`${JSON.stringify(target)}\n`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|