@lage-run/cli 0.4.32 → 0.4.34
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 +61 -1
- package/CHANGELOG.md +23 -2
- package/lib/cli.js +12 -9
- package/lib/commands/addLoggerOptions.js +15 -9
- package/lib/commands/cache/action.js +23 -19
- package/lib/commands/cache/cacheDir.js +26 -15
- package/lib/commands/cache/clearCache.js +32 -24
- package/lib/commands/cache/index.js +12 -12
- package/lib/commands/cache/pruneCache.js +31 -23
- package/lib/commands/isRunningFromCI.js +8 -4
- package/lib/commands/run/action.js +12 -10
- package/lib/commands/run/createCacheProvider.js +37 -26
- package/lib/commands/run/createProfileReporter.js +11 -8
- package/lib/commands/run/createTargetGraph.d.ts +0 -1
- package/lib/commands/run/createTargetGraph.js +17 -15
- package/lib/commands/run/filterArgsForTasks.js +9 -6
- package/lib/commands/run/filterPipelineDefinitions.js +9 -6
- package/lib/commands/run/index.js +25 -41
- package/lib/commands/run/runAction.js +49 -41
- package/lib/commands/run/runners/NpmScriptRunner.js +8 -5
- package/lib/commands/run/runners/WorkerRunner.js +8 -5
- package/lib/commands/run/watchAction.js +86 -64
- package/lib/commands/run/watcher.js +33 -23
- package/lib/config/getConfig.js +29 -25
- package/lib/config/getMaxWorkersPerTask.js +25 -16
- package/lib/filter/getFilteredPackages.js +87 -63
- package/lib/index.js +3 -2
- package/lib/showHelp.js +8 -6
- package/lib/types/CacheOptions.js +3 -2
- package/lib/types/ConfigOptions.js +3 -2
- package/lib/types/LoggerOptions.js +3 -2
- package/lib/types/PipelineDefinition.js +3 -2
- package/lib/types/Priority.js +3 -2
- package/package.json +6 -6
- package/lib/cli.js.map +0 -1
- package/lib/commands/addLoggerOptions.js.map +0 -1
- package/lib/commands/cache/action.js.map +0 -1
- package/lib/commands/cache/cacheDir.js.map +0 -1
- package/lib/commands/cache/clearCache.js.map +0 -1
- package/lib/commands/cache/index.js.map +0 -1
- package/lib/commands/cache/pruneCache.js.map +0 -1
- package/lib/commands/isRunningFromCI.js.map +0 -1
- package/lib/commands/run/action.js.map +0 -1
- package/lib/commands/run/createCacheProvider.js.map +0 -1
- package/lib/commands/run/createProfileReporter.js.map +0 -1
- package/lib/commands/run/createTargetGraph.js.map +0 -1
- package/lib/commands/run/filterArgsForTasks.js.map +0 -1
- package/lib/commands/run/filterPipelineDefinitions.js.map +0 -1
- package/lib/commands/run/index.js.map +0 -1
- package/lib/commands/run/runAction.js.map +0 -1
- package/lib/commands/run/runners/NpmScriptRunner.js.map +0 -1
- package/lib/commands/run/runners/WorkerRunner.js.map +0 -1
- package/lib/commands/run/watchAction.js.map +0 -1
- package/lib/commands/run/watcher.js.map +0 -1
- package/lib/config/getConfig.js.map +0 -1
- package/lib/config/getMaxWorkersPerTask.js.map +0 -1
- package/lib/filter/getFilteredPackages.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/showHelp.js.map +0 -1
- package/lib/types/CacheOptions.js.map +0 -1
- package/lib/types/ConfigOptions.js.map +0 -1
- package/lib/types/LoggerOptions.js.map +0 -1
- package/lib/types/PipelineDefinition.js.map +0 -1
- package/lib/types/Priority.js.map +0 -1
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "filterArgsForTasks", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>filterArgsForTasks
|
|
8
|
+
});
|
|
4
9
|
function filterArgsForTasks(args) {
|
|
5
|
-
const optionsPosition = args.findIndex((arg)
|
|
10
|
+
const optionsPosition = args.findIndex((arg)=>arg.startsWith("-"));
|
|
6
11
|
return {
|
|
7
12
|
tasks: args.slice(0, optionsPosition === -1 ? undefined : optionsPosition),
|
|
8
|
-
taskArgs: optionsPosition === -1 ? [] : args.slice(optionsPosition)
|
|
13
|
+
taskArgs: optionsPosition === -1 ? [] : args.slice(optionsPosition)
|
|
9
14
|
};
|
|
10
15
|
}
|
|
11
|
-
exports.filterArgsForTasks = filterArgsForTasks;
|
|
12
|
-
//# sourceMappingURL=filterArgsForTasks.js.map
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "filterPipelineDefinitions", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>filterPipelineDefinitions
|
|
8
|
+
});
|
|
4
9
|
function filterPipelineDefinitions(targets, pipeline) {
|
|
5
10
|
const tasksSet = new Set();
|
|
6
|
-
for (const target of targets)
|
|
11
|
+
for (const target of targets){
|
|
7
12
|
tasksSet.add(target.task);
|
|
8
13
|
}
|
|
9
14
|
const filteredPipeline = {};
|
|
10
|
-
for (const [id, definition] of Object.entries(pipeline
|
|
15
|
+
for (const [id, definition] of Object.entries(pipeline ?? {})){
|
|
11
16
|
if (tasksSet.has(id)) {
|
|
12
17
|
filteredPipeline[id] = definition;
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
return filteredPipeline;
|
|
16
21
|
}
|
|
17
|
-
exports.filterPipelineDefinitions = filterPipelineDefinitions;
|
|
18
|
-
//# sourceMappingURL=filterPipelineDefinitions.js.map
|
|
@@ -1,46 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.
|
|
16
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "runCommand", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>runCommand
|
|
8
|
+
});
|
|
9
|
+
const _commander = require("commander");
|
|
10
|
+
const _os = /*#__PURE__*/ _interopRequireDefault(require("os"));
|
|
11
|
+
const _actionJs = require("./action.js");
|
|
12
|
+
const _addLoggerOptionsJs = require("../addLoggerOptions.js");
|
|
13
|
+
const _isRunningFromCIJs = require("../isRunningFromCI.js");
|
|
14
|
+
function _interopRequireDefault(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const runCommand = new _commander.Command("run");
|
|
20
|
+
(0, _addLoggerOptionsJs.addLoggerOptions)(runCommand).action(_actionJs.action).option("-c, --concurrency <n>", "concurrency", (value)=>{
|
|
17
21
|
if (value.endsWith("%")) {
|
|
18
|
-
return
|
|
22
|
+
return parseInt(value.slice(0, -1)) / 100 * _os.default.cpus().length;
|
|
23
|
+
} else {
|
|
24
|
+
return parseInt(value) || _os.default.cpus().length - 1;
|
|
19
25
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}, os_1.default.cpus().length - 1)
|
|
24
|
-
.option("--max-workers-per-task <maxWorkersPerTarget...>", "set max worker per task, e.g. --max-workers-per-task build=2 test=4", [])
|
|
25
|
-
// Common Options
|
|
26
|
-
.option("--scope <scope...>", "scopes the run to a subset of packages (by default, includes the dependencies and dependents as well)")
|
|
27
|
-
.option("--no-deps|--no-dependents", "disables running any dependents of the scoped packages")
|
|
28
|
-
.option("--include-dependencies|--dependencies", 'adds the scoped packages dependencies as the "entry points" for the target graph run')
|
|
29
|
-
.option("--since <since>", "only runs packages that have changed since the given commit, tag, or branch")
|
|
30
|
-
.option("--to <scope...>", "runs up to a package (shorthand for --scope=<scope...> --no-dependents)")
|
|
31
|
-
// Run Command Options
|
|
32
|
-
.option("--grouped", "groups the logs", false)
|
|
33
|
-
.option("--no-cache", "disables the cache")
|
|
34
|
-
.option("--reset-cache", "resets the cache, filling it after a run")
|
|
35
|
-
.option("--skip-local-cache", "skips caching locally (defaults to true in CI environments)", isRunningFromCI_js_1.isRunningFromCI)
|
|
36
|
-
.option("--profile [profile]", "writes a run profile into a file that can be processed by Chromium devtool")
|
|
37
|
-
.option("--ignore <ignore...>", "ignores files when calculating the scope with `--since` in addition to the files specified in lage.config", [])
|
|
38
|
-
.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')
|
|
39
|
-
.option("--continue", "continues the run even on error")
|
|
40
|
-
.option("--unstable-watch", "runs in watch mode")
|
|
41
|
-
.allowUnknownOption(true)
|
|
42
|
-
.addHelpCommand("[run] command1 [command2...commandN] [options]", "run commands")
|
|
43
|
-
.addHelpText("after", `
|
|
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
|
|
28
|
+
.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", `
|
|
44
29
|
Runs a set of commands in a target graph. The targets are defined by packages and their scripts as defined the package.json files.
|
|
45
30
|
|
|
46
31
|
Examples
|
|
@@ -99,4 +84,3 @@ Ignoring files when calculating the scope with --since in addition to files spec
|
|
|
99
84
|
$ lage build test lint --since origin/master --ignore "package.json" "yarn.lock" "**/.azure-pipelines/**"
|
|
100
85
|
|
|
101
86
|
`);
|
|
102
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,36 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "runAction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>runAction
|
|
8
|
+
});
|
|
9
|
+
const _createCacheProviderJs = require("./createCacheProvider.js");
|
|
10
|
+
const _createProfileReporterJs = require("./createProfileReporter.js");
|
|
11
|
+
const _createTargetGraphJs = require("./createTargetGraph.js");
|
|
12
|
+
const _filterArgsForTasksJs = require("./filterArgsForTasks.js");
|
|
13
|
+
const _filterPipelineDefinitionsJs = require("./filterPipelineDefinitions.js");
|
|
14
|
+
const _findNpmClient = require("@lage-run/find-npm-client");
|
|
15
|
+
const _getConfigJs = require("../../config/getConfig.js");
|
|
16
|
+
const _getMaxWorkersPerTaskJs = require("../../config/getMaxWorkersPerTask.js");
|
|
17
|
+
const _workspaceTools = require("workspace-tools");
|
|
18
|
+
const _reporters = require("@lage-run/reporters");
|
|
19
|
+
const _scheduler = require("@lage-run/scheduler");
|
|
20
|
+
const _logger = /*#__PURE__*/ _interopRequireDefault(require("@lage-run/logger"));
|
|
21
|
+
function _interopRequireDefault(obj) {
|
|
22
|
+
return obj && obj.__esModule ? obj : {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
19
26
|
async function runAction(options, command) {
|
|
20
27
|
const cwd = process.cwd();
|
|
21
|
-
const config = await (0,
|
|
28
|
+
const config = await (0, _getConfigJs.getConfig)(cwd);
|
|
22
29
|
// Configure logger
|
|
23
|
-
const logger = (0,
|
|
24
|
-
(0,
|
|
30
|
+
const logger = (0, _logger.default)();
|
|
31
|
+
(0, _reporters.initializeReporters)(logger, options);
|
|
25
32
|
if (options.profile !== undefined) {
|
|
26
|
-
const reporter = (0,
|
|
33
|
+
const reporter = (0, _createProfileReporterJs.createProfileReporter)(options);
|
|
27
34
|
logger.addReporter(reporter);
|
|
28
35
|
}
|
|
29
36
|
// Build Target Graph
|
|
30
|
-
const root = (0,
|
|
31
|
-
const packageInfos = (0,
|
|
32
|
-
const { tasks, taskArgs
|
|
33
|
-
const targetGraph = (0,
|
|
37
|
+
const root = (0, _workspaceTools.getWorkspaceRoot)(process.cwd());
|
|
38
|
+
const packageInfos = (0, _workspaceTools.getPackageInfos)(root);
|
|
39
|
+
const { tasks , taskArgs } = (0, _filterArgsForTasksJs.filterArgsForTasks)(command.args);
|
|
40
|
+
const targetGraph = (0, _createTargetGraphJs.createTargetGraph)({
|
|
34
41
|
logger,
|
|
35
42
|
root,
|
|
36
43
|
dependencies: options.dependencies,
|
|
@@ -42,18 +49,18 @@ async function runAction(options, command) {
|
|
|
42
49
|
since: options.since,
|
|
43
50
|
outputs: config.cacheOptions.outputGlob,
|
|
44
51
|
tasks,
|
|
45
|
-
packageInfos
|
|
52
|
+
packageInfos
|
|
46
53
|
});
|
|
47
|
-
const { cacheProvider, hasher
|
|
54
|
+
const { cacheProvider , hasher } = (0, _createCacheProviderJs.createCache)({
|
|
48
55
|
root,
|
|
49
56
|
logger,
|
|
50
57
|
cacheOptions: config.cacheOptions,
|
|
51
|
-
skipLocalCache: options.skipLocalCache
|
|
58
|
+
skipLocalCache: options.skipLocalCache
|
|
52
59
|
});
|
|
53
60
|
logger.verbose(`Running with ${options.concurrency} workers`);
|
|
54
|
-
const filteredPipeline = (0,
|
|
55
|
-
const maxWorkersPerTaskMap = (0,
|
|
56
|
-
const scheduler = new
|
|
61
|
+
const filteredPipeline = (0, _filterPipelineDefinitionsJs.filterPipelineDefinitions)(targetGraph.targets.values(), config.pipeline);
|
|
62
|
+
const maxWorkersPerTaskMap = (0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTaskFromOptions)(options.maxWorkersPerTask);
|
|
63
|
+
const scheduler = new _scheduler.SimpleScheduler({
|
|
57
64
|
logger,
|
|
58
65
|
concurrency: options.concurrency,
|
|
59
66
|
cacheProvider,
|
|
@@ -61,37 +68,38 @@ async function runAction(options, command) {
|
|
|
61
68
|
continueOnError: options.continue,
|
|
62
69
|
shouldCache: options.cache,
|
|
63
70
|
shouldResetCache: options.resetCache,
|
|
64
|
-
maxWorkersPerTask: new Map([
|
|
71
|
+
maxWorkersPerTask: new Map([
|
|
72
|
+
...(0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTask)(filteredPipeline, options.concurrency),
|
|
73
|
+
...maxWorkersPerTaskMap
|
|
74
|
+
]),
|
|
65
75
|
runners: {
|
|
66
76
|
npmScript: {
|
|
67
77
|
script: require.resolve("./runners/NpmScriptRunner.js"),
|
|
68
78
|
options: {
|
|
69
79
|
nodeArg: options.nodeArg,
|
|
70
80
|
taskArgs,
|
|
71
|
-
npmCmd: (0,
|
|
72
|
-
}
|
|
81
|
+
npmCmd: (0, _findNpmClient.findNpmClient)(config.npmClient)
|
|
82
|
+
}
|
|
73
83
|
},
|
|
74
84
|
worker: {
|
|
75
85
|
script: require.resolve("./runners/WorkerRunner.js"),
|
|
76
86
|
options: {
|
|
77
|
-
taskArgs
|
|
78
|
-
}
|
|
87
|
+
taskArgs
|
|
88
|
+
}
|
|
79
89
|
},
|
|
80
|
-
...config.runners
|
|
90
|
+
...config.runners
|
|
81
91
|
},
|
|
82
|
-
workerIdleMemoryLimit: config.workerIdleMemoryLimit
|
|
92
|
+
workerIdleMemoryLimit: config.workerIdleMemoryLimit
|
|
83
93
|
});
|
|
84
94
|
const summary = await scheduler.run(root, targetGraph);
|
|
85
95
|
await scheduler.cleanup();
|
|
86
96
|
displaySummaryAndExit(summary, logger.reporters);
|
|
87
97
|
}
|
|
88
|
-
exports.runAction = runAction;
|
|
89
98
|
function displaySummaryAndExit(summary, reporters) {
|
|
90
99
|
if (summary.results !== "success") {
|
|
91
100
|
process.exitCode = 1;
|
|
92
101
|
}
|
|
93
|
-
for (const reporter of reporters)
|
|
102
|
+
for (const reporter of reporters){
|
|
94
103
|
reporter.summarize(summary);
|
|
95
104
|
}
|
|
96
105
|
}
|
|
97
|
-
//# sourceMappingURL=runAction.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "NpmScriptRunner", {
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "NpmScriptRunner", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_scheduler.NpmScriptRunner
|
|
8
|
+
});
|
|
9
|
+
const _scheduler = require("@lage-run/scheduler");
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "WorkerRunner", {
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "WorkerRunner", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_scheduler.WorkerRunner
|
|
8
|
+
});
|
|
9
|
+
const _scheduler = require("@lage-run/scheduler");
|
|
@@ -1,56 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "watchAction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>watchAction
|
|
17
8
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
9
|
+
const _createCacheProviderJs = require("./createCacheProvider.js");
|
|
10
|
+
const _createTargetGraphJs = require("./createTargetGraph.js");
|
|
11
|
+
const _filterArgsForTasksJs = require("./filterArgsForTasks.js");
|
|
12
|
+
const _findNpmClient = require("@lage-run/find-npm-client");
|
|
13
|
+
const _getConfigJs = require("../../config/getConfig.js");
|
|
14
|
+
const _getMaxWorkersPerTaskJs = require("../../config/getMaxWorkersPerTask.js");
|
|
15
|
+
const _workspaceTools = require("workspace-tools");
|
|
16
|
+
const _filterPipelineDefinitionsJs = require("./filterPipelineDefinitions.js");
|
|
17
|
+
const _reporters = require("@lage-run/reporters");
|
|
18
|
+
const _scheduler = require("@lage-run/scheduler");
|
|
19
|
+
const _watcherJs = require("./watcher.js");
|
|
20
|
+
const _logger = /*#__PURE__*/ _interopRequireWildcard(require("@lage-run/logger"));
|
|
21
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
22
|
+
if (typeof WeakMap !== "function") return null;
|
|
23
|
+
var cacheBabelInterop = new WeakMap();
|
|
24
|
+
var cacheNodeInterop = new WeakMap();
|
|
25
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
26
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
|
+
})(nodeInterop);
|
|
28
|
+
}
|
|
29
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
30
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
34
|
+
return {
|
|
35
|
+
default: obj
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
39
|
+
if (cache && cache.has(obj)) {
|
|
40
|
+
return cache.get(obj);
|
|
41
|
+
}
|
|
42
|
+
var newObj = {};
|
|
43
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
|
+
for(var key in obj){
|
|
45
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
46
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
47
|
+
if (desc && (desc.get || desc.set)) {
|
|
48
|
+
Object.defineProperty(newObj, key, desc);
|
|
49
|
+
} else {
|
|
50
|
+
newObj[key] = obj[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
newObj.default = obj;
|
|
55
|
+
if (cache) {
|
|
56
|
+
cache.set(obj, newObj);
|
|
57
|
+
}
|
|
58
|
+
return newObj;
|
|
59
|
+
}
|
|
39
60
|
async function watchAction(options, command) {
|
|
40
61
|
const cwd = process.cwd();
|
|
41
|
-
const config = await (0,
|
|
62
|
+
const config = await (0, _getConfigJs.getConfig)(cwd);
|
|
42
63
|
// Configure logger
|
|
43
|
-
const logger = (0,
|
|
44
|
-
const reporter = new
|
|
64
|
+
const logger = (0, _logger.default)();
|
|
65
|
+
const reporter = new _reporters.LogReporter({
|
|
45
66
|
grouped: true,
|
|
46
|
-
logLevel:
|
|
67
|
+
logLevel: _logger.LogLevel[options.logLevel]
|
|
47
68
|
});
|
|
48
69
|
logger.addReporter(reporter);
|
|
49
70
|
// Build Target Graph
|
|
50
|
-
const root = (0,
|
|
51
|
-
const packageInfos = (0,
|
|
52
|
-
const { tasks, taskArgs
|
|
53
|
-
const targetGraph = (0,
|
|
71
|
+
const root = (0, _workspaceTools.getWorkspaceRoot)(process.cwd());
|
|
72
|
+
const packageInfos = (0, _workspaceTools.getPackageInfos)(root);
|
|
73
|
+
const { tasks , taskArgs } = (0, _filterArgsForTasksJs.filterArgsForTasks)(command.args);
|
|
74
|
+
const targetGraph = (0, _createTargetGraphJs.createTargetGraph)({
|
|
54
75
|
logger,
|
|
55
76
|
root,
|
|
56
77
|
dependencies: options.dependencies,
|
|
@@ -62,19 +83,19 @@ async function watchAction(options, command) {
|
|
|
62
83
|
since: options.since,
|
|
63
84
|
outputs: config.cacheOptions.outputGlob,
|
|
64
85
|
tasks,
|
|
65
|
-
packageInfos
|
|
86
|
+
packageInfos
|
|
66
87
|
});
|
|
67
88
|
// Make sure we do not attempt writeRemoteCache in watch mode
|
|
68
89
|
config.cacheOptions.writeRemoteCache = false;
|
|
69
|
-
const { cacheProvider, hasher
|
|
90
|
+
const { cacheProvider , hasher } = (0, _createCacheProviderJs.createCache)({
|
|
70
91
|
root,
|
|
71
92
|
logger,
|
|
72
93
|
cacheOptions: config.cacheOptions,
|
|
73
|
-
skipLocalCache: false
|
|
94
|
+
skipLocalCache: false
|
|
74
95
|
});
|
|
75
|
-
const filteredPipeline = (0,
|
|
76
|
-
const maxWorkersPerTaskMap = (0,
|
|
77
|
-
const scheduler = new
|
|
96
|
+
const filteredPipeline = (0, _filterPipelineDefinitionsJs.filterPipelineDefinitions)(targetGraph.targets.values(), config.pipeline);
|
|
97
|
+
const maxWorkersPerTaskMap = (0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTaskFromOptions)(options.maxWorkersPerTask);
|
|
98
|
+
const scheduler = new _scheduler.SimpleScheduler({
|
|
78
99
|
logger,
|
|
79
100
|
concurrency: options.concurrency,
|
|
80
101
|
cacheProvider,
|
|
@@ -82,25 +103,28 @@ async function watchAction(options, command) {
|
|
|
82
103
|
continueOnError: true,
|
|
83
104
|
shouldCache: options.cache,
|
|
84
105
|
shouldResetCache: options.resetCache,
|
|
85
|
-
maxWorkersPerTask: new Map([
|
|
106
|
+
maxWorkersPerTask: new Map([
|
|
107
|
+
...(0, _getMaxWorkersPerTaskJs.getMaxWorkersPerTask)(filteredPipeline, options.concurrency),
|
|
108
|
+
...maxWorkersPerTaskMap
|
|
109
|
+
]),
|
|
86
110
|
runners: {
|
|
87
111
|
npmScript: {
|
|
88
112
|
script: require.resolve("./runners/NpmScriptRunner.js"),
|
|
89
113
|
options: {
|
|
90
114
|
nodeArg: options.nodeArg,
|
|
91
115
|
taskArgs,
|
|
92
|
-
npmCmd: (0,
|
|
93
|
-
}
|
|
116
|
+
npmCmd: (0, _findNpmClient.findNpmClient)(config.npmClient)
|
|
117
|
+
}
|
|
94
118
|
},
|
|
95
119
|
worker: {
|
|
96
120
|
script: require.resolve("./runners/WorkerRunner.js"),
|
|
97
121
|
options: {
|
|
98
|
-
taskArgs
|
|
99
|
-
}
|
|
122
|
+
taskArgs
|
|
123
|
+
}
|
|
100
124
|
},
|
|
101
|
-
...config.runners
|
|
125
|
+
...config.runners
|
|
102
126
|
},
|
|
103
|
-
workerIdleMemoryLimit: config.workerIdleMemoryLimit
|
|
127
|
+
workerIdleMemoryLimit: config.workerIdleMemoryLimit
|
|
104
128
|
});
|
|
105
129
|
// Initial run
|
|
106
130
|
const summary = await scheduler.run(root, targetGraph);
|
|
@@ -108,26 +132,24 @@ async function watchAction(options, command) {
|
|
|
108
132
|
logger.info("Running scheduler in watch mode");
|
|
109
133
|
// Disables cache for subsequent runs
|
|
110
134
|
// TODO: support updating hasher + write-only local cacheProvider for subsequent runs
|
|
111
|
-
for (const targetRun of scheduler.targetRuns.values())
|
|
135
|
+
for (const targetRun of scheduler.targetRuns.values()){
|
|
112
136
|
targetRun.options.cacheProvider = undefined;
|
|
113
137
|
targetRun.options.hasher = undefined;
|
|
114
138
|
targetRun.options.shouldCache = false;
|
|
115
139
|
}
|
|
116
140
|
// When initial run is done, disable fetching of caches on all targets, keep writing to the cache
|
|
117
|
-
const watcher = (0,
|
|
118
|
-
watcher.on("change", (packageName)
|
|
141
|
+
const watcher = (0, _watcherJs.watch)(root);
|
|
142
|
+
watcher.on("change", (packageName)=>{
|
|
119
143
|
reporter.resetLogEntries();
|
|
120
|
-
for (const target of targetGraph.targets.values())
|
|
144
|
+
for (const target of targetGraph.targets.values()){
|
|
121
145
|
if (target.packageName === packageName && scheduler.onTargetChange) {
|
|
122
146
|
scheduler.onTargetChange(target.id);
|
|
123
147
|
}
|
|
124
148
|
}
|
|
125
149
|
});
|
|
126
150
|
}
|
|
127
|
-
exports.watchAction = watchAction;
|
|
128
151
|
function displaySummary(summary, reporters) {
|
|
129
|
-
for (const reporter of reporters)
|
|
152
|
+
for (const reporter of reporters){
|
|
130
153
|
reporter.summarize(summary);
|
|
131
154
|
}
|
|
132
155
|
}
|
|
133
|
-
//# sourceMappingURL=watchAction.js.map
|
|
@@ -1,47 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "watch", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>watch
|
|
8
|
+
});
|
|
9
|
+
const _chokidar = /*#__PURE__*/ _interopRequireDefault(require("chokidar"));
|
|
10
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
11
|
+
const _workspaceTools = require("workspace-tools");
|
|
12
|
+
const _events = /*#__PURE__*/ _interopRequireDefault(require("events"));
|
|
13
|
+
function _interopRequireDefault(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
11
18
|
function watch(cwd) {
|
|
12
|
-
const events = new
|
|
13
|
-
const root = (0,
|
|
14
|
-
const packageInfos = (0,
|
|
19
|
+
const events = new _events.default();
|
|
20
|
+
const root = (0, _workspaceTools.getWorkspaceRoot)(cwd);
|
|
21
|
+
const packageInfos = (0, _workspaceTools.getPackageInfos)(cwd);
|
|
15
22
|
// generate a tree index of all the packages
|
|
16
23
|
const packageIndex = createPackageIndex(root, packageInfos);
|
|
17
|
-
const packagePaths = Object.values(packageInfos).map((pkg)
|
|
24
|
+
const packagePaths = Object.values(packageInfos).map((pkg)=>_path.default.dirname(pkg.packageJsonPath));
|
|
18
25
|
// watch for changes in the packages
|
|
19
|
-
const watcher =
|
|
26
|
+
const watcher = _chokidar.default.watch(packagePaths, {
|
|
20
27
|
cwd: root,
|
|
21
|
-
ignored: [
|
|
28
|
+
ignored: [
|
|
29
|
+
"**/node_modules/**",
|
|
30
|
+
"**/dist/**",
|
|
31
|
+
"**/build/**",
|
|
32
|
+
"**/lib/**"
|
|
33
|
+
]
|
|
22
34
|
});
|
|
23
35
|
let timeoutHandle;
|
|
24
36
|
// when a change happens, find the package that changed
|
|
25
|
-
watcher.on("change", (filePath)
|
|
37
|
+
watcher.on("change", (filePath)=>{
|
|
26
38
|
if (timeoutHandle) {
|
|
27
39
|
clearTimeout(timeoutHandle);
|
|
28
40
|
}
|
|
29
|
-
timeoutHandle = setTimeout(()
|
|
41
|
+
timeoutHandle = setTimeout(()=>{
|
|
30
42
|
const packageName = findPackageByPath(filePath, packageIndex);
|
|
31
43
|
events.emit("change", packageName);
|
|
32
44
|
}, 200);
|
|
33
45
|
});
|
|
34
46
|
return events;
|
|
35
47
|
}
|
|
36
|
-
exports.watch = watch;
|
|
37
48
|
function createPackageIndex(root, packageInfos) {
|
|
38
49
|
const pathIndex = {};
|
|
39
50
|
// generate a tree index of all the packages
|
|
40
|
-
for (const [packageName, info] of Object.entries(packageInfos))
|
|
41
|
-
const packagePath =
|
|
51
|
+
for (const [packageName, info] of Object.entries(packageInfos)){
|
|
52
|
+
const packagePath = _path.default.relative(root, _path.default.dirname(info.packageJsonPath));
|
|
42
53
|
const pathParts = packagePath.split(/[/\\]/);
|
|
43
54
|
let pointer = pathIndex;
|
|
44
|
-
for (const pathPart of pathParts)
|
|
55
|
+
for (const pathPart of pathParts){
|
|
45
56
|
if (!pointer[pathPart]) {
|
|
46
57
|
pointer[pathPart] = {};
|
|
47
58
|
}
|
|
@@ -54,7 +65,7 @@ function createPackageIndex(root, packageInfos) {
|
|
|
54
65
|
function findPackageByPath(filePath, index) {
|
|
55
66
|
const pathParts = filePath.split(/[/\\]/);
|
|
56
67
|
let pointer = index;
|
|
57
|
-
for (const pathPart of pathParts)
|
|
68
|
+
for (const pathPart of pathParts){
|
|
58
69
|
if (!pointer[pathPart]) {
|
|
59
70
|
// eslint-disable-next-line no-console
|
|
60
71
|
console.log(pathPart, filePath);
|
|
@@ -67,4 +78,3 @@ function findPackageByPath(filePath, index) {
|
|
|
67
78
|
}
|
|
68
79
|
return undefined;
|
|
69
80
|
}
|
|
70
|
-
//# sourceMappingURL=watcher.js.map
|