@lage-run/cli 0.5.4 → 0.5.6
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 +43 -1
- package/CHANGELOG.md +20 -2
- package/lib/cli.js +14 -7
- package/lib/commands/addLoggerOptions.js +2 -1
- package/lib/commands/run/action.d.ts +1 -0
- package/lib/commands/run/createProfileReporter.js +1 -1
- package/lib/commands/run/index.js +2 -14
- package/lib/commands/run/runAction.d.ts +1 -0
- package/lib/commands/run/runAction.js +23 -5
- package/lib/commands/run/watchAction.js +4 -2
- package/lib/config/getConcurrency.d.ts +1 -0
- package/lib/config/getConcurrency.js +17 -0
- package/lib/config/getConfig.js +3 -1
- package/lib/types/ConfigOptions.d.ts +8 -0
- package/lib/types/errors.d.ts +1 -0
- package/lib/types/errors.js +9 -0
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,49 @@
|
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 08 Dec 2022 00:49:16 GMT",
|
|
6
|
+
"tag": "@lage-run/cli_v0.5.6",
|
|
7
|
+
"version": "0.5.6",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "kchau@microsoft.com",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"commit": "ad281dfe8b222d949130821828a680d1c3625154",
|
|
14
|
+
"comment": "sets the default to progress"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@lage-run/cli",
|
|
19
|
+
"comment": "Bump @lage-run/scheduler to v0.7.2",
|
|
20
|
+
"commit": "ad281dfe8b222d949130821828a680d1c3625154"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@lage-run/cli",
|
|
25
|
+
"comment": "Bump @lage-run/reporters to v0.2.43",
|
|
26
|
+
"commit": "ad281dfe8b222d949130821828a680d1c3625154"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"date": "Tue, 06 Dec 2022 23:28:12 GMT",
|
|
33
|
+
"tag": "@lage-run/cli_v0.5.5",
|
|
34
|
+
"version": "0.5.5",
|
|
35
|
+
"comments": {
|
|
36
|
+
"patch": [
|
|
37
|
+
{
|
|
38
|
+
"author": "beachball",
|
|
39
|
+
"package": "@lage-run/cli",
|
|
40
|
+
"comment": "Bump @lage-run/reporters to v0.2.42",
|
|
41
|
+
"commit": "d0ad44eb759503c5642badc5210daf5028886a7c"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"date": "Tue, 06 Dec 2022 00:48:02 GMT",
|
|
6
48
|
"tag": "@lage-run/cli_v0.5.4",
|
|
7
49
|
"version": "0.5.4",
|
|
8
50
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
# Change Log - @lage-run/cli
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 08 Dec 2022 00:49:16 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.5.6
|
|
8
|
+
|
|
9
|
+
Thu, 08 Dec 2022 00:49:16 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- sets the default to progress (kchau@microsoft.com)
|
|
14
|
+
- Bump @lage-run/scheduler to v0.7.2
|
|
15
|
+
- Bump @lage-run/reporters to v0.2.43
|
|
16
|
+
|
|
17
|
+
## 0.5.5
|
|
18
|
+
|
|
19
|
+
Tue, 06 Dec 2022 23:28:12 GMT
|
|
20
|
+
|
|
21
|
+
### Patches
|
|
22
|
+
|
|
23
|
+
- Bump @lage-run/reporters to v0.2.42
|
|
24
|
+
|
|
7
25
|
## 0.5.4
|
|
8
26
|
|
|
9
|
-
Tue, 06 Dec 2022 00:
|
|
27
|
+
Tue, 06 Dec 2022 00:48:02 GMT
|
|
10
28
|
|
|
11
29
|
### Patches
|
|
12
30
|
|
package/lib/cli.js
CHANGED
|
@@ -3,18 +3,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _commander = require("commander");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const _indexJs = require("./commands/run/index.js");
|
|
7
|
+
const _indexJs1 = require("./commands/cache/index.js");
|
|
8
|
+
const _errorsJs = require("./types/errors.js");
|
|
8
9
|
async function main() {
|
|
9
10
|
const program = new _commander.Command();
|
|
10
|
-
program.addCommand(
|
|
11
|
+
program.addCommand(_indexJs.runCommand, {
|
|
11
12
|
isDefault: true
|
|
12
13
|
});
|
|
13
|
-
program.addCommand(
|
|
14
|
+
program.addCommand(_indexJs1.cacheCommand);
|
|
14
15
|
await program.parseAsync(process.argv);
|
|
15
16
|
}
|
|
16
17
|
main().catch((err)=>{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
/* eslint-disable no-console */ switch(err){
|
|
19
|
+
case _errorsJs.NoTargetFoundError:
|
|
20
|
+
console.log("lage: no targets found that matches the given scope.");
|
|
21
|
+
break;
|
|
22
|
+
default:
|
|
23
|
+
console.error(err);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
/* eslint-enable no-console */ process.exitCode = 1;
|
|
20
27
|
});
|
|
@@ -8,7 +8,8 @@ Object.defineProperty(exports, "addLoggerOptions", {
|
|
|
8
8
|
});
|
|
9
9
|
const _commander = require("commander");
|
|
10
10
|
function addLoggerOptions(program) {
|
|
11
|
-
|
|
11
|
+
const isCI = process.env.CI || process.env.TF_BUILD;
|
|
12
|
+
return program.option("--reporter <reporter...>", "reporter", "npmLog").addOption(new _commander.Option("--progress").conflicts("--reporter").default(!isCI)).addOption(new _commander.Option("--log-level <level>", "log level").choices([
|
|
12
13
|
"info",
|
|
13
14
|
"warn",
|
|
14
15
|
"error",
|
|
@@ -16,6 +16,7 @@ interface RunOptions extends ReporterInitOptions {
|
|
|
16
16
|
ignore: string[];
|
|
17
17
|
unstableWatch: boolean;
|
|
18
18
|
maxWorkersPerTask: string[];
|
|
19
|
+
allowNoTargetRuns: boolean;
|
|
19
20
|
}
|
|
20
21
|
export declare function action(options: RunOptions, command: Command): Promise<void>;
|
|
21
22
|
export {};
|
|
@@ -10,7 +10,7 @@ const _reporters = require("@lage-run/reporters");
|
|
|
10
10
|
function createProfileReporter(options) {
|
|
11
11
|
const { concurrency , profile } = options;
|
|
12
12
|
return new _reporters.ChromeTraceEventsReporter({
|
|
13
|
-
concurrency
|
|
13
|
+
concurrency,
|
|
14
14
|
outputFile: typeof profile === "string" ? profile : undefined
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -7,24 +7,12 @@ Object.defineProperty(exports, "runCommand", {
|
|
|
7
7
|
get: ()=>runCommand
|
|
8
8
|
});
|
|
9
9
|
const _commander = require("commander");
|
|
10
|
-
const _os = /*#__PURE__*/ _interopRequireDefault(require("os"));
|
|
11
10
|
const _actionJs = require("./action.js");
|
|
12
11
|
const _addLoggerOptionsJs = require("../addLoggerOptions.js");
|
|
13
12
|
const _isRunningFromCIJs = require("../isRunningFromCI.js");
|
|
14
|
-
function _interopRequireDefault(obj) {
|
|
15
|
-
return obj && obj.__esModule ? obj : {
|
|
16
|
-
default: obj
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
13
|
const runCommand = new _commander.Command("run");
|
|
20
|
-
(0, _addLoggerOptionsJs.addLoggerOptions)(runCommand).action(_actionJs.action).option("-c, --concurrency <n>", "concurrency", (value)=>
|
|
21
|
-
|
|
22
|
-
return parseInt(value.slice(0, -1)) / 100 * _os.default.cpus().length;
|
|
23
|
-
} else {
|
|
24
|
-
return parseInt(value) || _os.default.cpus().length - 1;
|
|
25
|
-
}
|
|
26
|
-
}, _os.default.cpus().length - 1).option("--max-workers-per-task <maxWorkersPerTarget...>", "set max worker per task, e.g. --max-workers-per-task build=2 test=4", [])// Common Options
|
|
27
|
-
.option("--scope <scope...>", "scopes the run to a subset of packages (by default, includes the dependencies and dependents as well)").option("--no-deps|--no-dependents", "disables running any dependents of the scoped packages").option("--include-dependencies|--dependencies", 'adds the scoped packages dependencies as the "entry points" for the target graph run').option("--since <since>", "only runs packages that have changed since the given commit, tag, or branch").option("--to <scope...>", "runs up to a package (shorthand for --scope=<scope...> --no-dependents)")// Run Command Options
|
|
14
|
+
(0, _addLoggerOptionsJs.addLoggerOptions)(runCommand).action(_actionJs.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", [])// Common Options
|
|
15
|
+
.option("--scope <scope...>", "scopes the run to a subset of packages (by default, includes the dependencies and dependents as well)").option("--no-deps|--no-dependents", "disables running any dependents of the scoped packages").option("--include-dependencies|--dependencies", 'adds the scoped packages dependencies as the "entry points" for the target graph run').option("--since <since>", "only runs packages that have changed since the given commit, tag, or branch").option("--to <scope...>", "runs up to a package (shorthand for --scope=<scope...> --no-dependents)").option("--allow-no-target-runs")// Run Command Options
|
|
28
16
|
.option("--grouped", "groups the logs", false).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)", _isRunningFromCIJs.isRunningFromCI).option("--profile [profile]", "writes a run profile into a file that can be processed by Chromium devtool").option("--ignore <ignore...>", "ignores files when calculating the scope with `--since` in addition to the files specified in lage.config", []).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("--unstable-watch", "runs in watch mode").allowUnknownOption(true).addHelpCommand("[run] command1 [command2...commandN] [options]", "run commands").addHelpText("after", `
|
|
29
17
|
Runs a set of commands in a target graph. The targets are defined by packages and their scripts as defined the package.json files.
|
|
30
18
|
|
|
@@ -18,6 +18,8 @@ const _workspaceTools = require("workspace-tools");
|
|
|
18
18
|
const _reporters = require("@lage-run/reporters");
|
|
19
19
|
const _scheduler = require("@lage-run/scheduler");
|
|
20
20
|
const _logger = /*#__PURE__*/ _interopRequireDefault(require("@lage-run/logger"));
|
|
21
|
+
const _getConcurrencyJs = require("../../config/getConcurrency.js");
|
|
22
|
+
const _errorsJs = require("../../types/errors.js");
|
|
21
23
|
function _interopRequireDefault(obj) {
|
|
22
24
|
return obj && obj.__esModule ? obj : {
|
|
23
25
|
default: obj
|
|
@@ -26,11 +28,20 @@ function _interopRequireDefault(obj) {
|
|
|
26
28
|
async function runAction(options, command) {
|
|
27
29
|
const cwd = process.cwd();
|
|
28
30
|
const config = await (0, _getConfigJs.getConfig)(cwd);
|
|
31
|
+
// Merged options
|
|
32
|
+
const concurrency = (0, _getConcurrencyJs.getConcurrency)(options.concurrency, config.concurrency);
|
|
33
|
+
const allowNoTargetRuns = options.allowNoTargetRuns || config.allowNoTargetRuns;
|
|
29
34
|
// Configure logger
|
|
30
35
|
const logger = (0, _logger.default)();
|
|
31
|
-
(0, _reporters.initializeReporters)(logger,
|
|
36
|
+
(0, _reporters.initializeReporters)(logger, {
|
|
37
|
+
...options,
|
|
38
|
+
concurrency
|
|
39
|
+
});
|
|
32
40
|
if (options.profile !== undefined) {
|
|
33
|
-
const reporter = (0, _createProfileReporterJs.createProfileReporter)(
|
|
41
|
+
const reporter = (0, _createProfileReporterJs.createProfileReporter)({
|
|
42
|
+
concurrency,
|
|
43
|
+
profile: options.profile
|
|
44
|
+
});
|
|
34
45
|
logger.addReporter(reporter);
|
|
35
46
|
}
|
|
36
47
|
// Build Target Graph
|
|
@@ -51,25 +62,26 @@ async function runAction(options, command) {
|
|
|
51
62
|
tasks,
|
|
52
63
|
packageInfos
|
|
53
64
|
});
|
|
65
|
+
validateTargetGraph(targetGraph, allowNoTargetRuns);
|
|
54
66
|
const { cacheProvider , hasher } = (0, _createCacheProviderJs.createCache)({
|
|
55
67
|
root,
|
|
56
68
|
logger,
|
|
57
69
|
cacheOptions: config.cacheOptions,
|
|
58
70
|
skipLocalCache: options.skipLocalCache
|
|
59
71
|
});
|
|
60
|
-
logger.verbose(`Running with ${
|
|
72
|
+
logger.verbose(`Running with ${concurrency} workers`);
|
|
61
73
|
const filteredPipeline = (0, _filterPipelineDefinitionsJs.filterPipelineDefinitions)(targetGraph.targets.values(), config.pipeline);
|
|
62
74
|
const maxWorkersPerTaskMap = (0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTaskFromOptions)(options.maxWorkersPerTask);
|
|
63
75
|
const scheduler = new _scheduler.SimpleScheduler({
|
|
64
76
|
logger,
|
|
65
|
-
concurrency
|
|
77
|
+
concurrency,
|
|
66
78
|
cacheProvider,
|
|
67
79
|
hasher,
|
|
68
80
|
continueOnError: options.continue,
|
|
69
81
|
shouldCache: options.cache,
|
|
70
82
|
shouldResetCache: options.resetCache,
|
|
71
83
|
maxWorkersPerTask: new Map([
|
|
72
|
-
...(0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTask)(filteredPipeline,
|
|
84
|
+
...(0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTask)(filteredPipeline, concurrency),
|
|
73
85
|
...maxWorkersPerTaskMap
|
|
74
86
|
]),
|
|
75
87
|
runners: {
|
|
@@ -103,3 +115,9 @@ function displaySummaryAndExit(summary, reporters) {
|
|
|
103
115
|
reporter.summarize(summary);
|
|
104
116
|
}
|
|
105
117
|
}
|
|
118
|
+
function validateTargetGraph(targetGraph, allowNoTargetRuns) {
|
|
119
|
+
const visibleTargets = Array.from(targetGraph.targets.values()).filter((target)=>!target.hidden);
|
|
120
|
+
if (visibleTargets.length === 0 && !allowNoTargetRuns) {
|
|
121
|
+
throw _errorsJs.NoTargetFoundError;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -18,6 +18,7 @@ const _reporters = require("@lage-run/reporters");
|
|
|
18
18
|
const _scheduler = require("@lage-run/scheduler");
|
|
19
19
|
const _watcherJs = require("./watcher.js");
|
|
20
20
|
const _logger = /*#__PURE__*/ _interopRequireWildcard(require("@lage-run/logger"));
|
|
21
|
+
const _getConcurrencyJs = require("../../config/getConcurrency.js");
|
|
21
22
|
function _getRequireWildcardCache(nodeInterop) {
|
|
22
23
|
if (typeof WeakMap !== "function") return null;
|
|
23
24
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -60,6 +61,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
60
61
|
async function watchAction(options, command) {
|
|
61
62
|
const cwd = process.cwd();
|
|
62
63
|
const config = await (0, _getConfigJs.getConfig)(cwd);
|
|
64
|
+
const concurrency = (0, _getConcurrencyJs.getConcurrency)(options.concurrency, config.concurrency);
|
|
63
65
|
// Configure logger
|
|
64
66
|
const logger = (0, _logger.default)();
|
|
65
67
|
const reporter = new _reporters.LogReporter({
|
|
@@ -96,14 +98,14 @@ async function watchAction(options, command) {
|
|
|
96
98
|
const maxWorkersPerTaskMap = (0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTaskFromOptions)(options.maxWorkersPerTask);
|
|
97
99
|
const scheduler = new _scheduler.SimpleScheduler({
|
|
98
100
|
logger,
|
|
99
|
-
concurrency
|
|
101
|
+
concurrency,
|
|
100
102
|
cacheProvider,
|
|
101
103
|
hasher,
|
|
102
104
|
continueOnError: true,
|
|
103
105
|
shouldCache: options.cache,
|
|
104
106
|
shouldResetCache: options.resetCache,
|
|
105
107
|
maxWorkersPerTask: new Map([
|
|
106
|
-
...(0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTask)(filteredPipeline,
|
|
108
|
+
...(0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTask)(filteredPipeline, concurrency),
|
|
107
109
|
...maxWorkersPerTaskMap
|
|
108
110
|
]),
|
|
109
111
|
runners: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getConcurrency(optionsConcurrency: number | undefined, configConcurrency: number | undefined): number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getConcurrency", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>getConcurrency
|
|
8
|
+
});
|
|
9
|
+
const _os = /*#__PURE__*/ _interopRequireDefault(require("os"));
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function getConcurrency(optionsConcurrency, configConcurrency) {
|
|
16
|
+
return optionsConcurrency || configConcurrency || _os.default.cpus().length - 1;
|
|
17
|
+
}
|
package/lib/config/getConfig.js
CHANGED
|
@@ -41,6 +41,8 @@ async function getConfig(cwd) {
|
|
|
41
41
|
],
|
|
42
42
|
loggerOptions: config?.loggerOptions ?? {},
|
|
43
43
|
runners: config?.runners ?? {},
|
|
44
|
-
workerIdleMemoryLimit: config?.workerIdleMemoryLimit ?? _os.default.totalmem()
|
|
44
|
+
workerIdleMemoryLimit: config?.workerIdleMemoryLimit ?? _os.default.totalmem(),
|
|
45
|
+
concurrency: config?.concurrency ?? _os.default.cpus().length - 1,
|
|
46
|
+
allowNoTargetRuns: config?.allowNoTargetRuns ?? false
|
|
45
47
|
};
|
|
46
48
|
}
|
|
@@ -45,4 +45,12 @@ export interface ConfigOptions {
|
|
|
45
45
|
* Maximum worker idle memory, this would cause workers to restart if they exceed this limit. This is useful to prevent memory leaks.
|
|
46
46
|
*/
|
|
47
47
|
workerIdleMemoryLimit: number;
|
|
48
|
+
/**
|
|
49
|
+
* Maximum number of concurrent tasks to run
|
|
50
|
+
*/
|
|
51
|
+
concurrency: number;
|
|
52
|
+
/**
|
|
53
|
+
* Allows for no targets run
|
|
54
|
+
*/
|
|
55
|
+
allowNoTargetRuns: boolean;
|
|
48
56
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NoTargetFoundError: Error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Command Line Interface for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/microsoft/lage"
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@lage-run/find-npm-client": "^0.1.4",
|
|
22
22
|
"@lage-run/logger": "^1.2.2",
|
|
23
|
-
"@lage-run/scheduler": "^0.7.
|
|
23
|
+
"@lage-run/scheduler": "^0.7.2",
|
|
24
24
|
"@lage-run/scheduler-types": "^0.2.10",
|
|
25
25
|
"@lage-run/target-graph": "^0.6.1",
|
|
26
26
|
"@lage-run/cache": "^0.2.3",
|
|
27
|
-
"@lage-run/reporters": "^0.2.
|
|
27
|
+
"@lage-run/reporters": "^0.2.43",
|
|
28
28
|
"commander": "^9.4.0",
|
|
29
29
|
"workspace-tools": "^0.29.0",
|
|
30
30
|
"chokidar": "3.5.3",
|