@lage-run/cli 0.23.0 → 0.23.2
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 +37 -1
- package/CHANGELOG.md +19 -2
- 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 +125 -0
- package/lib/commands/exec/index.js +9 -0
- package/lib/commands/info/action.js +13 -48
- package/lib/commands/parseServerOption.d.ts +4 -0
- package/lib/commands/parseServerOption.js +34 -0
- 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 +3 -3
- package/lib/commands/run/infoAction.d.ts +0 -14
- package/lib/commands/run/infoAction.js +0 -55
- package/lib/commands/run/runners/NoOpRunner.d.ts +0 -1
- package/lib/commands/run/runners/NoOpRunner.js +0 -11
- package/lib/commands/run/runners/NpmScriptRunner.d.ts +0 -1
- package/lib/commands/run/runners/NpmScriptRunner.js +0 -11
- package/lib/commands/run/runners/WorkerRunner.d.ts +0 -1
- package/lib/commands/run/runners/WorkerRunner.js +0 -11
- /package/lib/commands/{server → exec}/simulateFileAccess.d.ts +0 -0
- /package/lib/commands/{server → exec}/simulateFileAccess.js +0 -0
- /package/lib/{commands/info/runners → runners}/NoOpRunner.d.ts +0 -0
- /package/lib/{commands/info/runners → runners}/NoOpRunner.js +0 -0
- /package/lib/{commands/info/runners → runners}/NpmScriptRunner.d.ts +0 -0
- /package/lib/{commands/info/runners → runners}/NpmScriptRunner.js +0 -0
- /package/lib/{commands/info/runners → runners}/WorkerRunner.d.ts +0 -0
- /package/lib/{commands/info/runners → runners}/WorkerRunner.js +0 -0
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,43 @@
|
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Mon, 07 Oct 2024 19:33:03 GMT",
|
|
6
|
+
"version": "0.23.2",
|
|
7
|
+
"tag": "@lage-run/cli_v0.23.2",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "kchau@microsoft.com",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"commit": "43e4f422ae3436c5dedaa961469420ee683098b1",
|
|
14
|
+
"comment": "Fixing the action command generation to handle the case of launching as server without --server"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Fri, 04 Oct 2024 23:41:44 GMT",
|
|
21
|
+
"version": "0.23.1",
|
|
22
|
+
"tag": "@lage-run/cli_v0.23.1",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "kchau@microsoft.com",
|
|
27
|
+
"package": "@lage-run/cli",
|
|
28
|
+
"commit": "5030c3eca2e52a4b31e4246b06dea37e126aa659",
|
|
29
|
+
"comment": "Modified info command to accommodate a \"LAGE_WORKER_SERVER\" flag (also, --server)"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "beachball",
|
|
33
|
+
"package": "@lage-run/cli",
|
|
34
|
+
"comment": "Bump @lage-run/rpc to v1.2.3",
|
|
35
|
+
"commit": "not available"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"date": "Wed, 02 Oct 2024 20:26:19 GMT",
|
|
6
42
|
"version": "0.23.0",
|
|
7
43
|
"tag": "@lage-run/cli_v0.23.0",
|
|
8
44
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
# Change Log - @lage-run/cli
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Mon, 07 Oct 2024 19:33:03 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.23.2
|
|
8
|
+
|
|
9
|
+
Mon, 07 Oct 2024 19:33:03 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Fixing the action command generation to handle the case of launching as server without --server (kchau@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 0.23.1
|
|
16
|
+
|
|
17
|
+
Fri, 04 Oct 2024 23:41:44 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Modified info command to accommodate a "LAGE_WORKER_SERVER" flag (also, --server) (kchau@microsoft.com)
|
|
22
|
+
- Bump @lage-run/rpc to v1.2.3
|
|
23
|
+
|
|
7
24
|
## 0.23.0
|
|
8
25
|
|
|
9
|
-
Wed, 02 Oct 2024 20:
|
|
26
|
+
Wed, 02 Oct 2024 20:26:19 GMT
|
|
10
27
|
|
|
11
28
|
### Minor changes
|
|
12
29
|
|
|
@@ -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,125 @@
|
|
|
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
|
+
const _parseServerOption = require("../parseServerOption.js");
|
|
19
|
+
function _interop_require_default(obj) {
|
|
20
|
+
return obj && obj.__esModule ? obj : {
|
|
21
|
+
default: obj
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async function tryCreateClient(host, port) {
|
|
25
|
+
const client = (0, _rpc.createClient)({
|
|
26
|
+
baseUrl: `http://${host}:${port}`,
|
|
27
|
+
httpVersion: "2"
|
|
28
|
+
});
|
|
29
|
+
try {
|
|
30
|
+
const success = await client.ping({});
|
|
31
|
+
if (success.pong) {
|
|
32
|
+
return client;
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {
|
|
35
|
+
if (e instanceof _rpc.ConnectError) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
async function tryCreateClientWithRetries(host, port, logger) {
|
|
43
|
+
let client;
|
|
44
|
+
const start = Date.now();
|
|
45
|
+
while(Date.now() - start < 5 * 1000){
|
|
46
|
+
try {
|
|
47
|
+
client = await tryCreateClient(host, port);
|
|
48
|
+
if (client) {
|
|
49
|
+
return client;
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
if (e instanceof _rpc.ConnectError) {
|
|
53
|
+
logger.error("Error connecting to server", e);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
async function executeOnServer(args, client, logger) {
|
|
61
|
+
const task = args.length === 1 ? args[0] : args[1];
|
|
62
|
+
const packageName = args.length > 1 ? args[0] : undefined;
|
|
63
|
+
if (!task) {
|
|
64
|
+
throw new Error("No task provided");
|
|
65
|
+
}
|
|
66
|
+
const { taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(args ?? []);
|
|
67
|
+
const response = await client.runTarget({
|
|
68
|
+
packageName,
|
|
69
|
+
task,
|
|
70
|
+
taskArgs
|
|
71
|
+
});
|
|
72
|
+
logger.info(`Task ${response.packageName} ${response.task} exited with code ${response.exitCode} `);
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
async function executeRemotely(options, command) {
|
|
76
|
+
// launch a 'lage-server.js' process, detached if it is not already running
|
|
77
|
+
// send the command to the server process
|
|
78
|
+
const { server } = options;
|
|
79
|
+
const timeout = options.timeout ?? 120;
|
|
80
|
+
const { host , port } = (0, _parseServerOption.parseServerOption)(server);
|
|
81
|
+
const logger = (0, _logger.default)();
|
|
82
|
+
options.logLevel = options.logLevel ?? "info";
|
|
83
|
+
options.reporter = options.reporter ?? "json";
|
|
84
|
+
(0, _initializeReporters.initializeReporters)(logger, options);
|
|
85
|
+
let client = await tryCreateClient(host, port);
|
|
86
|
+
const args = command.args;
|
|
87
|
+
if (!client) {
|
|
88
|
+
logger.info(`Starting server on http://${host}:${port}`);
|
|
89
|
+
const binPaths = (0, _getBinPaths.getBinPaths)();
|
|
90
|
+
const lageServerBinPath = binPaths["lage-server"];
|
|
91
|
+
const lageServerArgs = [
|
|
92
|
+
lageServerBinPath,
|
|
93
|
+
"--host",
|
|
94
|
+
host,
|
|
95
|
+
"--port",
|
|
96
|
+
port,
|
|
97
|
+
"--timeout",
|
|
98
|
+
timeout,
|
|
99
|
+
...args
|
|
100
|
+
];
|
|
101
|
+
logger.info(`Launching lage-server with these parameters: "${process.execPath}" ${lageServerArgs.join(" ")}`);
|
|
102
|
+
const child = (0, _execa.default)(process.execPath, lageServerArgs, {
|
|
103
|
+
detached: true,
|
|
104
|
+
stdio: "ignore"
|
|
105
|
+
});
|
|
106
|
+
child.unref();
|
|
107
|
+
logger.info("Server started", {
|
|
108
|
+
pid: child.pid
|
|
109
|
+
});
|
|
110
|
+
logger.info("Creating a client to connect to the background services");
|
|
111
|
+
client = await tryCreateClientWithRetries(host, port, logger);
|
|
112
|
+
if (!client) {
|
|
113
|
+
throw new Error("Server could not be started");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
logger.info(`Executing on server http://${host}:${port}`);
|
|
117
|
+
const response = await executeOnServer(args, client, logger);
|
|
118
|
+
process.stdout.write(response.stdout);
|
|
119
|
+
process.stderr.write(response.stderr);
|
|
120
|
+
process.exitCode = response.exitCode;
|
|
121
|
+
if (response.exitCode === 0) {
|
|
122
|
+
await (0, _simulateFileAccess.simulateFileAccess)(logger, response.inputs, response.outputs);
|
|
123
|
+
}
|
|
124
|
+
logger.info("Task execution finished");
|
|
125
|
+
}
|
|
@@ -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);
|
|
@@ -16,9 +16,11 @@ const _getFilteredPackages = require("../../filter/getFilteredPackages.js");
|
|
|
16
16
|
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
17
17
|
const _targetgraph = require("@lage-run/target-graph");
|
|
18
18
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
19
|
-
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
20
19
|
const _initializeReporters = require("../initializeReporters.js");
|
|
21
20
|
const _runners = require("@lage-run/runners");
|
|
21
|
+
const _getBinPaths = require("../../getBinPaths.js");
|
|
22
|
+
const _runnerPickerOptions = require("../../runnerPickerOptions.js");
|
|
23
|
+
const _parseServerOption = require("../parseServerOption.js");
|
|
22
24
|
function _interop_require_default(obj) {
|
|
23
25
|
return obj && obj.__esModule ? obj : {
|
|
24
26
|
default: obj
|
|
@@ -30,7 +32,7 @@ async function infoAction(options, command) {
|
|
|
30
32
|
const logger = (0, _logger.default)();
|
|
31
33
|
options.logLevel = options.logLevel ?? "info";
|
|
32
34
|
options.reporter = options.reporter ?? "json";
|
|
33
|
-
options.server = typeof options.server === "
|
|
35
|
+
options.server = typeof options.server === "boolean" && options.server ? "localhost:5332" : options.server;
|
|
34
36
|
(0, _initializeReporters.initializeReporters)(logger, options);
|
|
35
37
|
const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
|
|
36
38
|
const packageInfos = (0, _workspacetools.getPackageInfos)(root);
|
|
@@ -60,29 +62,10 @@ async function infoAction(options, command) {
|
|
|
60
62
|
repoWideChanges: config.repoWideChanges,
|
|
61
63
|
sinceIgnoreGlobs: options.ignore.concat(config.ignore)
|
|
62
64
|
});
|
|
63
|
-
const pickerOptions =
|
|
64
|
-
npmScript: {
|
|
65
|
-
script: require.resolve("./runners/NpmScriptRunner.js"),
|
|
66
|
-
options: {
|
|
67
|
-
nodeArg: options.nodeArg,
|
|
68
|
-
taskArgs,
|
|
69
|
-
npmCmd: config.npmClient
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
worker: {
|
|
73
|
-
script: require.resolve("./runners/WorkerRunner.js"),
|
|
74
|
-
options: {
|
|
75
|
-
taskArgs
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
noop: {
|
|
79
|
-
script: require.resolve("./runners/NoOpRunner.js"),
|
|
80
|
-
options: {}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
65
|
+
const pickerOptions = (0, _runnerPickerOptions.runnerPickerOptions)(options.nodeArg, config.npmClient, taskArgs);
|
|
83
66
|
const runnerPicker = new _runners.TargetRunnerPicker(pickerOptions);
|
|
84
67
|
const optimizedTargets = await optimizeTargetGraph(targetGraph, runnerPicker);
|
|
85
|
-
const binPaths = getBinPaths();
|
|
68
|
+
const binPaths = (0, _getBinPaths.getBinPaths)();
|
|
86
69
|
const packageTasks = optimizedTargets.map((target)=>generatePackageTask(target, taskArgs, config, options, binPaths));
|
|
87
70
|
logger.info("info", {
|
|
88
71
|
command: command.args,
|
|
@@ -90,22 +73,6 @@ async function infoAction(options, command) {
|
|
|
90
73
|
packageTasks
|
|
91
74
|
});
|
|
92
75
|
}
|
|
93
|
-
function getBinPaths() {
|
|
94
|
-
let dir = __dirname;
|
|
95
|
-
let packageJsonPath = "";
|
|
96
|
-
while(dir !== "/"){
|
|
97
|
-
packageJsonPath = _path.default.join(dir, "package.json");
|
|
98
|
-
if (_fs.default.existsSync(packageJsonPath)) {
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
dir = _path.default.dirname(dir);
|
|
102
|
-
}
|
|
103
|
-
const packageJson = JSON.parse(_fs.default.readFileSync(_path.default.join(dir, "package.json"), "utf8"));
|
|
104
|
-
return {
|
|
105
|
-
lage: _path.default.join(dir, packageJson.bin.lage),
|
|
106
|
-
"lage-server": _path.default.join(dir, packageJson.bin["lage-server"])
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
76
|
async function optimizeTargetGraph(graph, runnerPicker) {
|
|
110
77
|
const targetMinimizedNodes = await (0, _targetgraph.removeNodes)([
|
|
111
78
|
...graph.targets.values()
|
|
@@ -135,6 +102,7 @@ function generatePackageTask(target, taskArgs, config, options, binPaths) {
|
|
|
135
102
|
return packageTask;
|
|
136
103
|
}
|
|
137
104
|
function generateCommand(target, taskArgs, config, options, binPaths) {
|
|
105
|
+
const shouldRunWorkersAsService = typeof process.env.LAGE_WORKER_SERVER === "string" && process.env.LAGE_WORKER_SERVER !== "false" || !!options.server;
|
|
138
106
|
if (target.type === "npmScript") {
|
|
139
107
|
const npmClient = config.npmClient ?? "npm";
|
|
140
108
|
const command = [
|
|
@@ -142,18 +110,15 @@ function generateCommand(target, taskArgs, config, options, binPaths) {
|
|
|
142
110
|
...getNpmArgs(target.task, taskArgs)
|
|
143
111
|
];
|
|
144
112
|
return command;
|
|
145
|
-
} else if (target.type === "worker" &&
|
|
146
|
-
const
|
|
113
|
+
} else if (target.type === "worker" && shouldRunWorkersAsService) {
|
|
114
|
+
const { host , port } = (0, _parseServerOption.parseServerOption)(options.server);
|
|
147
115
|
const command = [
|
|
148
116
|
process.execPath,
|
|
149
|
-
binPaths["lage
|
|
117
|
+
binPaths["lage"],
|
|
118
|
+
"exec",
|
|
119
|
+
"--server",
|
|
120
|
+
`${host}:${port}`
|
|
150
121
|
];
|
|
151
|
-
if (host) {
|
|
152
|
-
command.push("--host", host);
|
|
153
|
-
}
|
|
154
|
-
if (port) {
|
|
155
|
-
command.push("--port", port);
|
|
156
|
-
}
|
|
157
122
|
if (options.concurrency) {
|
|
158
123
|
command.push("--concurrency", options.concurrency.toString());
|
|
159
124
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "parseServerOption", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return parseServerOption;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function parseServerOption(server) {
|
|
12
|
+
const isBooleanAndTrue = typeof server === "boolean" && server;
|
|
13
|
+
const isEmptyServer = typeof server === "undefined" || server === false;
|
|
14
|
+
const serverString = isBooleanAndTrue ? "localhost:5332" : isEmptyServer ? "localhost:5332" : server;
|
|
15
|
+
if (serverString.includes(":")) {
|
|
16
|
+
const parts = serverString.split(":");
|
|
17
|
+
const host = parts[0];
|
|
18
|
+
const port = parseInt(parts[1] ?? "5332");
|
|
19
|
+
return {
|
|
20
|
+
host,
|
|
21
|
+
port
|
|
22
|
+
};
|
|
23
|
+
} else if (serverString.length === 0) {
|
|
24
|
+
return {
|
|
25
|
+
host: "localhost",
|
|
26
|
+
port: 5332
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
return {
|
|
30
|
+
host: serverString,
|
|
31
|
+
port: 5332
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -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.23.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"description": "Command Line Interface for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "tsc",
|
|
19
19
|
"start": "tsc -w --preserveWatchOutput",
|
|
20
|
-
"test": "jest",
|
|
20
|
+
"test": "monorepo-scripts jest",
|
|
21
21
|
"lint": "monorepo-scripts lint"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@lage-run/hasher": "^1.6.0",
|
|
28
28
|
"@lage-run/logger": "^1.3.1",
|
|
29
29
|
"@lage-run/reporters": "^1.2.11",
|
|
30
|
-
"@lage-run/rpc": "^1.2.
|
|
30
|
+
"@lage-run/rpc": "^1.2.3",
|
|
31
31
|
"@lage-run/runners": "^1.0.3",
|
|
32
32
|
"@lage-run/scheduler": "^1.3.2",
|
|
33
33
|
"@lage-run/scheduler-types": "^0.3.16",
|
|
@@ -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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { NoOpRunner } from "@lage-run/runners";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "NoOpRunner", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _runners.NoOpRunner;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _runners = require("@lage-run/runners");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { NpmScriptRunner } from "@lage-run/runners";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "NpmScriptRunner", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _runners.NpmScriptRunner;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _runners = require("@lage-run/runners");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { WorkerRunner } from "@lage-run/runners";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "WorkerRunner", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _runners.WorkerRunner;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _runners = require("@lage-run/runners");
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|