@lage-run/cli 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +43 -1
- package/CHANGELOG.md +20 -2
- package/lib/cli.js +10 -8
- package/lib/commands/addFilterOptions.js +3 -1
- package/lib/commands/addLoggerOptions.js +3 -1
- package/lib/commands/affected/action.js +10 -8
- package/lib/commands/affected/index.js +6 -4
- package/lib/commands/cache/action.js +9 -7
- package/lib/commands/cache/clearCache.js +5 -3
- package/lib/commands/cache/index.js +6 -4
- package/lib/commands/cache/pruneCache.js +5 -3
- package/lib/commands/cache/runners/ClearCacheRunner.js +6 -4
- package/lib/commands/cache/runners/PruneCacheRunner.js +6 -4
- package/lib/commands/createReporter.js +7 -5
- package/lib/commands/init/action.d.ts +1 -0
- package/lib/commands/init/action.js +122 -0
- package/lib/commands/init/index.d.ts +3 -0
- package/lib/commands/init/index.js +15 -0
- package/lib/commands/initializeReporters.js +5 -3
- package/lib/commands/isRunningFromCI.js +3 -1
- package/lib/commands/run/action.js +9 -7
- package/lib/commands/run/createTargetGraph.js +7 -5
- package/lib/commands/run/filterArgsForTasks.js +3 -1
- package/lib/commands/run/filterPipelineDefinitions.js +3 -1
- package/lib/commands/run/index.js +9 -7
- package/lib/commands/run/infoAction.js +15 -13
- package/lib/commands/run/runAction.js +20 -18
- package/lib/commands/run/runners/NoOpRunner.js +3 -1
- package/lib/commands/run/runners/NpmScriptRunner.js +3 -1
- package/lib/commands/run/runners/WorkerRunner.js +3 -1
- package/lib/commands/run/watchAction.js +18 -16
- package/lib/commands/run/watcher.js +9 -7
- package/lib/filter/getFilteredPackages.js +16 -12
- package/lib/showHelp.js +3 -1
- package/lib/types/errors.js +3 -1
- package/package.json +11 -10
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,49 @@
|
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Mon, 08 May 2023 16:33:14 GMT",
|
|
6
|
+
"tag": "@lage-run/cli_v0.15.1",
|
|
7
|
+
"version": "0.15.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "beachball",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"comment": "Bump @lage-run/reporters to v1.2.1",
|
|
14
|
+
"commit": "fbe51aa289332ec599ceeace4171dc1f7d2f5377"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 26 Apr 2023 04:56:20 GMT",
|
|
21
|
+
"tag": "@lage-run/cli_v0.15.0",
|
|
22
|
+
"version": "0.15.0",
|
|
23
|
+
"comments": {
|
|
24
|
+
"minor": [
|
|
25
|
+
{
|
|
26
|
+
"author": "elcraig@microsoft.com",
|
|
27
|
+
"package": "@lage-run/cli",
|
|
28
|
+
"commit": "56910ce2ef67d9d3dc99b7a75df007820e9444c8",
|
|
29
|
+
"comment": "Add back the init command"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "beachball",
|
|
33
|
+
"package": "@lage-run/cli",
|
|
34
|
+
"comment": "Bump @lage-run/config to v0.2.0",
|
|
35
|
+
"commit": "994af55fcc890b448fc2b5cd5e4ba8bca0832997"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "beachball",
|
|
39
|
+
"package": "@lage-run/cli",
|
|
40
|
+
"comment": "Bump @lage-run/scheduler to v0.11.4",
|
|
41
|
+
"commit": "994af55fcc890b448fc2b5cd5e4ba8bca0832997"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"date": "Tue, 25 Apr 2023 02:51:19 GMT",
|
|
6
48
|
"tag": "@lage-run/cli_v0.14.0",
|
|
7
49
|
"version": "0.14.0",
|
|
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 Mon, 08 May 2023 16:33:14 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.15.1
|
|
8
|
+
|
|
9
|
+
Mon, 08 May 2023 16:33:14 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Bump @lage-run/reporters to v1.2.1
|
|
14
|
+
|
|
15
|
+
## 0.15.0
|
|
16
|
+
|
|
17
|
+
Wed, 26 Apr 2023 04:56:20 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- Add back the init command (elcraig@microsoft.com)
|
|
22
|
+
- Bump @lage-run/config to v0.2.0
|
|
23
|
+
- Bump @lage-run/scheduler to v0.11.4
|
|
24
|
+
|
|
7
25
|
## 0.14.0
|
|
8
26
|
|
|
9
|
-
Tue, 25 Apr 2023 02:
|
|
27
|
+
Tue, 25 Apr 2023 02:51:19 GMT
|
|
10
28
|
|
|
11
29
|
### Minor changes
|
|
12
30
|
|
package/lib/cli.js
CHANGED
|
@@ -3,22 +3,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _commander = require("commander");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
const _index = require("./commands/run/index.js");
|
|
7
|
+
const _index1 = require("./commands/cache/index.js");
|
|
8
|
+
const _errors = require("./types/errors.js");
|
|
9
|
+
const _index2 = require("./commands/affected/index.js");
|
|
10
|
+
const _index3 = require("./commands/init/index.js");
|
|
10
11
|
async function main() {
|
|
11
12
|
const program = new _commander.Command();
|
|
12
|
-
program.addCommand(
|
|
13
|
+
program.addCommand(_index.runCommand, {
|
|
13
14
|
isDefault: true
|
|
14
15
|
});
|
|
15
|
-
program.addCommand(
|
|
16
|
-
program.addCommand(
|
|
16
|
+
program.addCommand(_index1.cacheCommand);
|
|
17
|
+
program.addCommand(_index2.affectedCommand);
|
|
18
|
+
program.addCommand(_index3.initCommand);
|
|
17
19
|
await program.parseAsync(process.argv);
|
|
18
20
|
}
|
|
19
21
|
main().catch((err)=>{
|
|
20
22
|
/* eslint-disable no-console */ switch(err){
|
|
21
|
-
case
|
|
23
|
+
case _errors.NoTargetFoundError:
|
|
22
24
|
console.log("lage: no targets found that matches the given scope.");
|
|
23
25
|
break;
|
|
24
26
|
default:
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "addFilterOptions", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return addFilterOptions;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
function addFilterOptions(program) {
|
|
10
12
|
return program.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("--to <scope...>", "runs up to a package (shorthand for --scope=<scope...> --no-dependents)").option("--since <since>", "only runs packages that have changed since the given commit, tag, or branch").option("--ignore <ignore...>", "ignores files when calculating the scope with `--since` in addition to the files specified in lage.config", []);
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "addLoggerOptions", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return addLoggerOptions;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _commander = require("commander");
|
|
10
12
|
function addLoggerOptions(program) {
|
|
@@ -4,13 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "affectedAction", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return affectedAction;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _logger = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
+
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
12
|
+
const _workspacetools = require("workspace-tools");
|
|
11
13
|
const _config = require("@lage-run/config");
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
+
const _getFilteredPackages = require("../../filter/getFilteredPackages.js");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
14
16
|
return obj && obj.__esModule ? obj : {
|
|
15
17
|
default: obj
|
|
16
18
|
};
|
|
@@ -20,9 +22,9 @@ async function affectedAction(options) {
|
|
|
20
22
|
const cwd = process.cwd();
|
|
21
23
|
const config = await (0, _config.getConfig)(cwd);
|
|
22
24
|
const logger = (0, _logger.default)();
|
|
23
|
-
const root = (0,
|
|
24
|
-
const packageInfos = await (0,
|
|
25
|
-
const packages = (0,
|
|
25
|
+
const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
|
|
26
|
+
const packageInfos = await (0, _workspacetools.getPackageInfosAsync)(root);
|
|
27
|
+
const packages = (0, _getFilteredPackages.getFilteredPackages)({
|
|
26
28
|
root,
|
|
27
29
|
logger,
|
|
28
30
|
packageInfos,
|
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "affectedCommand", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return affectedCommand;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _commander = require("commander");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
+
const _addFilterOptions = require("../addFilterOptions.js");
|
|
13
|
+
const _action = require("./action.js");
|
|
12
14
|
const affectedCommand = new _commander.Command("affected");
|
|
13
|
-
(0,
|
|
15
|
+
(0, _addFilterOptions.addFilterOptions)(affectedCommand).action(_action.affectedAction).option("--output-format <graph|json|default>", `Generate a report about what packages are affected by the current change (defaults to human readable format) ` + `"graph" will generate a GraphViz .dot file format`).option("--since <branch>", "Calculate changes since this branch (defaults to origin/master)", "origin/master");
|
|
@@ -4,13 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "cacheAction", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return cacheAction;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
11
|
+
const _clearCache = require("./clearCache.js");
|
|
10
12
|
const _config = require("@lage-run/config");
|
|
11
|
-
const
|
|
12
|
-
const _logger = /*#__PURE__*/
|
|
13
|
-
function
|
|
13
|
+
const _pruneCache = require("./pruneCache.js");
|
|
14
|
+
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
15
|
+
function _interop_require_default(obj) {
|
|
14
16
|
return obj && obj.__esModule ? obj : {
|
|
15
17
|
default: obj
|
|
16
18
|
};
|
|
@@ -20,14 +22,14 @@ async function cacheAction(options, command) {
|
|
|
20
22
|
const config = await (0, _config.getConfig)(cwd);
|
|
21
23
|
const logger = (0, _logger.default)();
|
|
22
24
|
if (options.clear) {
|
|
23
|
-
return await (0,
|
|
25
|
+
return await (0, _clearCache.clearCache)({
|
|
24
26
|
cwd: process.cwd(),
|
|
25
27
|
internalCacheFolder: config.cacheOptions.internalCacheFolder,
|
|
26
28
|
logger,
|
|
27
29
|
concurrency: options.concurrency
|
|
28
30
|
});
|
|
29
31
|
} else if (options.prune) {
|
|
30
|
-
return await (0,
|
|
32
|
+
return await (0, _pruneCache.pruneCache)({
|
|
31
33
|
pruneDays: options.prune,
|
|
32
34
|
cwd: process.cwd(),
|
|
33
35
|
internalCacheFolder: config.cacheOptions.internalCacheFolder,
|
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "clearCache", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return clearCache;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _config = require("@lage-run/config");
|
|
10
|
-
const
|
|
12
|
+
const _workspacetools = require("workspace-tools");
|
|
11
13
|
const _cache = require("@lage-run/cache");
|
|
12
14
|
async function clearCache(options) {
|
|
13
15
|
const { logger , cwd } = options;
|
|
14
16
|
const config = await (0, _config.getConfig)(cwd);
|
|
15
|
-
const workspaceRoot = (0,
|
|
17
|
+
const workspaceRoot = (0, _workspacetools.getWorkspaceRoot)(cwd);
|
|
16
18
|
const concurrency = (0, _config.getConcurrency)(options.concurrency, config.concurrency);
|
|
17
19
|
if (!workspaceRoot) {
|
|
18
20
|
return;
|
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "cacheCommand", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return cacheCommand;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _commander = require("commander");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
+
const _addLoggerOptions = require("../addLoggerOptions.js");
|
|
13
|
+
const _action = require("./action.js");
|
|
12
14
|
const cacheCommand = new _commander.Command("cache");
|
|
13
|
-
(0,
|
|
15
|
+
(0, _addLoggerOptions.addLoggerOptions)(cacheCommand).action(_action.cacheAction).addOption(new _commander.Option("--prune <days>", "Prunes cache older than certain number of <days>").argParser(parseInt).conflicts("--clear")).option("--clear", "Clears the cache locally");
|
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "pruneCache", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return pruneCache;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
11
|
+
const _workspacetools = require("workspace-tools");
|
|
10
12
|
const _config = require("@lage-run/config");
|
|
11
13
|
const _cache = require("@lage-run/cache");
|
|
12
14
|
async function pruneCache(options) {
|
|
13
15
|
const { logger , cwd , pruneDays } = options;
|
|
14
16
|
const config = await (0, _config.getConfig)(cwd);
|
|
15
|
-
const workspaceRoot = (0,
|
|
17
|
+
const workspaceRoot = (0, _workspacetools.getWorkspaceRoot)(cwd);
|
|
16
18
|
const concurrency = (0, _config.getConcurrency)(options.concurrency, config.concurrency);
|
|
17
19
|
if (!workspaceRoot) {
|
|
18
20
|
return;
|
|
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "ClearCacheRunner", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ClearCacheRunner;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const _path = /*#__PURE__*/
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
11
13
|
const _promises = require("fs/promises");
|
|
12
|
-
function
|
|
14
|
+
function _interop_require_default(obj) {
|
|
13
15
|
return obj && obj.__esModule ? obj : {
|
|
14
16
|
default: obj
|
|
15
17
|
};
|
|
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "PruneCacheRunner", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return PruneCacheRunner;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const _path = /*#__PURE__*/
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
11
13
|
const _promises = require("fs/promises");
|
|
12
|
-
function
|
|
14
|
+
function _interop_require_default(obj) {
|
|
13
15
|
return obj && obj.__esModule ? obj : {
|
|
14
16
|
default: obj
|
|
15
17
|
};
|
|
@@ -4,14 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "createReporter", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return createReporter;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _logger = require("@lage-run/logger");
|
|
10
12
|
const _reporters = require("@lage-run/reporters");
|
|
11
|
-
const
|
|
13
|
+
const _workspacetools = require("workspace-tools");
|
|
12
14
|
const _fs = require("fs");
|
|
13
|
-
const _path = /*#__PURE__*/
|
|
14
|
-
function
|
|
15
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
16
|
+
function _interop_require_default(obj) {
|
|
15
17
|
return obj && obj.__esModule ? obj : {
|
|
16
18
|
default: obj
|
|
17
19
|
};
|
|
@@ -19,7 +21,7 @@ function _interopRequireDefault(obj) {
|
|
|
19
21
|
function createReporter(reporter, options) {
|
|
20
22
|
const { verbose , grouped , logLevel: logLevelName , concurrency , profile , progress , logFile } = options;
|
|
21
23
|
const logLevel = _logger.LogLevel[logLevelName];
|
|
22
|
-
const root = (0,
|
|
24
|
+
const root = (0, _workspacetools.findPackageRoot)(__filename);
|
|
23
25
|
const packageJson = JSON.parse((0, _fs.readFileSync)(_path.default.join(root, "package.json"), "utf-8"));
|
|
24
26
|
const version = packageJson.version;
|
|
25
27
|
switch(reporter){
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initAction(): Promise<void>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* eslint-disable no-console -- logger doesn't work in this context */ "use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "initAction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return initAction;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _config = require("@lage-run/config");
|
|
12
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
13
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
14
|
+
const _execa = /*#__PURE__*/ _interop_require_default(require("execa"));
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async function initAction() {
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
const config = await (0, _config.readConfigFile)(cwd);
|
|
23
|
+
if (config) {
|
|
24
|
+
console.error("lage is already initialized in this workspace");
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
console.info("Installing lage and creating a default configuration file");
|
|
29
|
+
let workspaceManager = "yarn";
|
|
30
|
+
try {
|
|
31
|
+
workspaceManager = whichWorkspaceManager(cwd);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.error("lage requires you to be using a workspace - make sure you are using yarn workspaces, npm workspaces, pnpm workspaces, or rush");
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const pipeline = {
|
|
38
|
+
build: [
|
|
39
|
+
"^build"
|
|
40
|
+
],
|
|
41
|
+
test: [
|
|
42
|
+
"build"
|
|
43
|
+
],
|
|
44
|
+
lint: []
|
|
45
|
+
};
|
|
46
|
+
const lageConfig = {
|
|
47
|
+
pipeline,
|
|
48
|
+
npmClient: workspaceManager === "yarn" ? "yarn" : "npm"
|
|
49
|
+
};
|
|
50
|
+
const lageConfigFile = _path.default.join(cwd, "lage.config.js");
|
|
51
|
+
_fs.default.writeFileSync(lageConfigFile, "module.exports = " + JSON.stringify(lageConfig, null, 2) + ";");
|
|
52
|
+
installLage(cwd, workspaceManager, pipeline);
|
|
53
|
+
console.info(`Lage is initialized! You can now run: ${getBuildCommand(workspaceManager)}`);
|
|
54
|
+
}
|
|
55
|
+
function getBuildCommand(workspaceManager) {
|
|
56
|
+
switch(workspaceManager){
|
|
57
|
+
case "yarn":
|
|
58
|
+
return "yarn lage build";
|
|
59
|
+
case "pnpm":
|
|
60
|
+
return "pnpm run lage build";
|
|
61
|
+
case "rush":
|
|
62
|
+
case "npm":
|
|
63
|
+
return "npm run lage build";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function whichWorkspaceManager(cwd) {
|
|
67
|
+
const packageJson = readPackageJson(cwd);
|
|
68
|
+
if (_fs.default.existsSync(_path.default.join(cwd, "rush.json"))) {
|
|
69
|
+
return "rush";
|
|
70
|
+
}
|
|
71
|
+
if (_fs.default.existsSync(_path.default.join(cwd, "yarn.lock")) && packageJson.workspaces) {
|
|
72
|
+
return "yarn";
|
|
73
|
+
}
|
|
74
|
+
if (_fs.default.existsSync(_path.default.join(cwd, "pnpm-workspace.yaml"))) {
|
|
75
|
+
return "pnpm";
|
|
76
|
+
}
|
|
77
|
+
if (_fs.default.existsSync(_path.default.join(cwd, "package-lock.json")) && packageJson.workspaces) {
|
|
78
|
+
return "npm";
|
|
79
|
+
}
|
|
80
|
+
throw new Error("not a workspace");
|
|
81
|
+
}
|
|
82
|
+
async function installLage(cwd, workspaceManager, pipeline) {
|
|
83
|
+
var _packageJson;
|
|
84
|
+
const lageVersion = getLageVersion();
|
|
85
|
+
const packageJson = readPackageJson(cwd);
|
|
86
|
+
(_packageJson = packageJson).scripts ?? (_packageJson.scripts = {});
|
|
87
|
+
for (const script of Object.keys(pipeline)){
|
|
88
|
+
packageJson.scripts[script] = `lage ${script}`;
|
|
89
|
+
}
|
|
90
|
+
if (workspaceManager === "rush") {
|
|
91
|
+
packageJson.scripts.lage = `node common/scripts/install-run.js lage@${lageVersion} lage`;
|
|
92
|
+
writePackageJson(cwd, packageJson);
|
|
93
|
+
} else {
|
|
94
|
+
var _packageJson1;
|
|
95
|
+
packageJson.scripts.lage = "lage";
|
|
96
|
+
(_packageJson1 = packageJson).devDependencies ?? (_packageJson1.devDependencies = {});
|
|
97
|
+
packageJson.devDependencies.lage = lageVersion;
|
|
98
|
+
writePackageJson(cwd, packageJson);
|
|
99
|
+
await (0, _execa.default)(workspaceManager, [
|
|
100
|
+
"install"
|
|
101
|
+
], {
|
|
102
|
+
stdio: "inherit"
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function getLageVersion() {
|
|
107
|
+
const lagePackageJsonFile = require.resolve("../../package.json", {
|
|
108
|
+
paths: [
|
|
109
|
+
__dirname
|
|
110
|
+
]
|
|
111
|
+
});
|
|
112
|
+
const lagePackageJson = JSON.parse(_fs.default.readFileSync(lagePackageJsonFile, "utf-8"));
|
|
113
|
+
return lagePackageJson.version;
|
|
114
|
+
}
|
|
115
|
+
function writePackageJson(cwd, packageJson) {
|
|
116
|
+
const packageJsonFile = _path.default.join(cwd, "package.json");
|
|
117
|
+
_fs.default.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
|
|
118
|
+
}
|
|
119
|
+
function readPackageJson(cwd) {
|
|
120
|
+
const packageJsonFile = _path.default.join(cwd, "package.json");
|
|
121
|
+
return JSON.parse(_fs.default.readFileSync(packageJsonFile, "utf-8"));
|
|
122
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "initCommand", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return initCommand;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _commander = require("commander");
|
|
12
|
+
const _addFilterOptions = require("../addFilterOptions.js");
|
|
13
|
+
const _action = require("./action.js");
|
|
14
|
+
const initCommand = new _commander.Command("init");
|
|
15
|
+
(0, _addFilterOptions.addFilterOptions)(initCommand).description("Install lage in a workspace and create a config file").action(_action.initAction);
|
|
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "initializeReporters", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return initializeReporters;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
11
|
+
const _createReporter = require("./createReporter.js");
|
|
10
12
|
function initializeReporters(logger, options) {
|
|
11
13
|
const { reporter } = options;
|
|
12
14
|
// filter out falsy values (e.g. undefined) from the reporter array
|
|
@@ -22,7 +24,7 @@ function initializeReporters(logger, options) {
|
|
|
22
24
|
reporterOptions.push("profile");
|
|
23
25
|
}
|
|
24
26
|
for (const reporterName of reporterOptions){
|
|
25
|
-
const reporterInstance = (0,
|
|
27
|
+
const reporterInstance = (0, _createReporter.createReporter)(reporterName, options);
|
|
26
28
|
logger.addReporter(reporterInstance);
|
|
27
29
|
}
|
|
28
30
|
return logger.reporters;
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "isRunningFromCI", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return isRunningFromCI;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const isRunningFromCI = process.env.NODE_ENV !== "test" && (!!process.env.CI || !!process.env.TF_BUILD);
|
|
@@ -4,17 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "action", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return action;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
11
|
+
const _infoAction = require("./infoAction.js");
|
|
12
|
+
const _runAction = require("./runAction.js");
|
|
13
|
+
const _watchAction = require("./watchAction.js");
|
|
12
14
|
async function action(options, command) {
|
|
13
15
|
if (options.info) {
|
|
14
|
-
return (0,
|
|
16
|
+
return (0, _infoAction.infoAction)(options, command);
|
|
15
17
|
} else if (options.unstableWatch) {
|
|
16
|
-
return (0,
|
|
18
|
+
return (0, _watchAction.watchAction)(options, command);
|
|
17
19
|
} else {
|
|
18
|
-
return (0,
|
|
20
|
+
return (0, _runAction.runAction)(options, command);
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -4,14 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "createTargetGraph", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return createTargetGraph;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const _targetgraph = require("@lage-run/target-graph");
|
|
12
|
+
const _getFilteredPackages = require("../../filter/getFilteredPackages.js");
|
|
11
13
|
function createTargetGraph(options) {
|
|
12
14
|
const { logger , root , dependencies , dependents , since , scope , repoWideChanges , ignore , pipeline , outputs , tasks , packageInfos } = options;
|
|
13
|
-
const builder = new
|
|
14
|
-
const packages = (0,
|
|
15
|
+
const builder = new _targetgraph.WorkspaceTargetGraphBuilder(root, packageInfos);
|
|
16
|
+
const packages = (0, _getFilteredPackages.getFilteredPackages)({
|
|
15
17
|
root,
|
|
16
18
|
logger,
|
|
17
19
|
packageInfos,
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "filterArgsForTasks", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return filterArgsForTasks;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
function filterArgsForTasks(args) {
|
|
10
12
|
const optionsPosition = args.findIndex((arg)=>arg.startsWith("-"));
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "filterPipelineDefinitions", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return filterPipelineDefinitions;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
function filterPipelineDefinitions(targets, pipeline) {
|
|
10
12
|
const tasksSet = new Set();
|
|
@@ -4,16 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "runCommand", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return runCommand;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _commander = require("commander");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const _action = require("./action.js");
|
|
13
|
+
const _addLoggerOptions = require("../addLoggerOptions.js");
|
|
14
|
+
const _isRunningFromCI = require("../isRunningFromCI.js");
|
|
15
|
+
const _addFilterOptions = require("../addFilterOptions.js");
|
|
14
16
|
const runCommand = new _commander.Command("run");
|
|
15
|
-
(0,
|
|
16
|
-
.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)",
|
|
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").addOption(new _commander.Option("--info", "outputs information about a run action, suitable for calculating shards or as an input for another task runner").conflicts("unstableWatch")).option("--unstable-watch", "runs in watch mode").allowUnknownOption(true).addHelpCommand("[run] command1 [command2...commandN] [options]", "run commands").addHelpText("after", `
|
|
17
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.
|
|
18
20
|
|
|
19
21
|
Examples
|
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "infoAction", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return infoAction;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const _createTargetGraph = require("./createTargetGraph.js");
|
|
12
|
+
const _filterArgsForTasks = require("./filterArgsForTasks.js");
|
|
11
13
|
const _config = require("@lage-run/config");
|
|
12
|
-
const
|
|
13
|
-
const _logger = /*#__PURE__*/
|
|
14
|
-
const
|
|
15
|
-
function
|
|
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) {
|
|
16
18
|
return obj && obj.__esModule ? obj : {
|
|
17
19
|
default: obj
|
|
18
20
|
};
|
|
@@ -22,10 +24,10 @@ async function infoAction(options, command) {
|
|
|
22
24
|
const config = await (0, _config.getConfig)(cwd);
|
|
23
25
|
const logger = (0, _logger.default)();
|
|
24
26
|
// Build Target Graph
|
|
25
|
-
const root = (0,
|
|
26
|
-
const packageInfos = await (0,
|
|
27
|
-
const { tasks } = (0,
|
|
28
|
-
const targetGraph = (0,
|
|
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)({
|
|
29
31
|
logger,
|
|
30
32
|
root,
|
|
31
33
|
dependencies: options.dependencies,
|
|
@@ -43,10 +45,10 @@ async function infoAction(options, command) {
|
|
|
43
45
|
config.cacheOptions.writeRemoteCache = false;
|
|
44
46
|
const { targets } = targetGraph;
|
|
45
47
|
for (const target of targets.values()){
|
|
46
|
-
if (target.id === (0,
|
|
48
|
+
if (target.id === (0, _targetgraph.getStartTargetId)()) {
|
|
47
49
|
continue;
|
|
48
50
|
}
|
|
49
|
-
const startIdIndex = target.dependencies.indexOf((0,
|
|
51
|
+
const startIdIndex = target.dependencies.indexOf((0, _targetgraph.getStartTargetId)());
|
|
50
52
|
target.dependencies.splice(startIdIndex, 1);
|
|
51
53
|
process.stdout.write(`${JSON.stringify(target)}\n`);
|
|
52
54
|
}
|
|
@@ -4,19 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "runAction", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return runAction;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const _createTargetGraph = require("./createTargetGraph.js");
|
|
12
|
+
const _filterArgsForTasks = require("./filterArgsForTasks.js");
|
|
13
|
+
const _filterPipelineDefinitions = require("./filterPipelineDefinitions.js");
|
|
14
|
+
const _findnpmclient = require("@lage-run/find-npm-client");
|
|
13
15
|
const _config = require("@lage-run/config");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
+
const _workspacetools = require("workspace-tools");
|
|
17
|
+
const _initializeReporters = require("../initializeReporters.js");
|
|
16
18
|
const _scheduler = require("@lage-run/scheduler");
|
|
17
|
-
const _logger = /*#__PURE__*/
|
|
18
|
-
const
|
|
19
|
-
function
|
|
19
|
+
const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
|
|
20
|
+
const _errors = require("../../types/errors.js");
|
|
21
|
+
function _interop_require_default(obj) {
|
|
20
22
|
return obj && obj.__esModule ? obj : {
|
|
21
23
|
default: obj
|
|
22
24
|
};
|
|
@@ -29,15 +31,15 @@ async function runAction(options, command) {
|
|
|
29
31
|
const allowNoTargetRuns = options.allowNoTargetRuns || config.allowNoTargetRuns;
|
|
30
32
|
// Configure logger
|
|
31
33
|
const logger = (0, _logger.default)();
|
|
32
|
-
const reporters = (0,
|
|
34
|
+
const reporters = (0, _initializeReporters.initializeReporters)(logger, {
|
|
33
35
|
...options,
|
|
34
36
|
concurrency
|
|
35
37
|
});
|
|
36
38
|
// Build Target Graph
|
|
37
|
-
const root = (0,
|
|
38
|
-
const packageInfos = await (0,
|
|
39
|
-
const { tasks , taskArgs } = (0,
|
|
40
|
-
const targetGraph = (0,
|
|
39
|
+
const root = (0, _workspacetools.getWorkspaceRoot)(process.cwd());
|
|
40
|
+
const packageInfos = await (0, _workspacetools.getPackageInfosAsync)(root);
|
|
41
|
+
const { tasks , taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
|
|
42
|
+
const targetGraph = (0, _createTargetGraph.createTargetGraph)({
|
|
41
43
|
logger,
|
|
42
44
|
root,
|
|
43
45
|
dependencies: options.dependencies,
|
|
@@ -53,7 +55,7 @@ async function runAction(options, command) {
|
|
|
53
55
|
});
|
|
54
56
|
validateTargetGraph(targetGraph, allowNoTargetRuns);
|
|
55
57
|
logger.verbose(`Running with ${concurrency} workers`);
|
|
56
|
-
const filteredPipeline = (0,
|
|
58
|
+
const filteredPipeline = (0, _filterPipelineDefinitions.filterPipelineDefinitions)(targetGraph.targets.values(), config.pipeline);
|
|
57
59
|
const maxWorkersPerTaskMap = (0, _config.getMaxWorkersPerTaskFromOptions)(options.maxWorkersPerTask);
|
|
58
60
|
const scheduler = new _scheduler.SimpleScheduler({
|
|
59
61
|
logger,
|
|
@@ -71,7 +73,7 @@ async function runAction(options, command) {
|
|
|
71
73
|
options: {
|
|
72
74
|
nodeArg: options.nodeArg,
|
|
73
75
|
taskArgs,
|
|
74
|
-
npmCmd: (0,
|
|
76
|
+
npmCmd: (0, _findnpmclient.findNpmClient)(config.npmClient)
|
|
75
77
|
}
|
|
76
78
|
},
|
|
77
79
|
worker: {
|
|
@@ -111,6 +113,6 @@ function displaySummaryAndExit(summary, reporters) {
|
|
|
111
113
|
function validateTargetGraph(targetGraph, allowNoTargetRuns) {
|
|
112
114
|
const visibleTargets = Array.from(targetGraph.targets.values()).filter((target)=>!target.hidden);
|
|
113
115
|
if (visibleTargets.length === 0 && !allowNoTargetRuns) {
|
|
114
|
-
throw
|
|
116
|
+
throw _errors.NoTargetFoundError;
|
|
115
117
|
}
|
|
116
118
|
}
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "NoOpRunner", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _scheduler.NoOpRunner;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _scheduler = require("@lage-run/scheduler");
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "NpmScriptRunner", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _scheduler.NpmScriptRunner;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _scheduler = require("@lage-run/scheduler");
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "WorkerRunner", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _scheduler.WorkerRunner;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _scheduler = require("@lage-run/scheduler");
|
|
@@ -4,18 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "watchAction", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return watchAction;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
11
|
+
const _createTargetGraph = require("./createTargetGraph.js");
|
|
12
|
+
const _filterArgsForTasks = require("./filterArgsForTasks.js");
|
|
13
|
+
const _findnpmclient = require("@lage-run/find-npm-client");
|
|
12
14
|
const _config = require("@lage-run/config");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
+
const _workspacetools = require("workspace-tools");
|
|
16
|
+
const _filterPipelineDefinitions = require("./filterPipelineDefinitions.js");
|
|
15
17
|
const _reporters = require("@lage-run/reporters");
|
|
16
18
|
const _scheduler = require("@lage-run/scheduler");
|
|
17
|
-
const
|
|
18
|
-
const _logger = /*#__PURE__*/
|
|
19
|
+
const _watcher = require("./watcher.js");
|
|
20
|
+
const _logger = /*#__PURE__*/ _interop_require_wildcard(require("@lage-run/logger"));
|
|
19
21
|
function _getRequireWildcardCache(nodeInterop) {
|
|
20
22
|
if (typeof WeakMap !== "function") return null;
|
|
21
23
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -24,7 +26,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
24
26
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
25
27
|
})(nodeInterop);
|
|
26
28
|
}
|
|
27
|
-
function
|
|
29
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
28
30
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
29
31
|
return obj;
|
|
30
32
|
}
|
|
@@ -66,10 +68,10 @@ async function watchAction(options, command) {
|
|
|
66
68
|
});
|
|
67
69
|
logger.addReporter(reporter);
|
|
68
70
|
// Build Target Graph
|
|
69
|
-
const root = (0,
|
|
70
|
-
const packageInfos = await (0,
|
|
71
|
-
const { tasks , taskArgs } = (0,
|
|
72
|
-
const targetGraph = (0,
|
|
71
|
+
const root = (0, _workspacetools.getWorkspaceRoot)(process.cwd());
|
|
72
|
+
const packageInfos = await (0, _workspacetools.getPackageInfosAsync)(root);
|
|
73
|
+
const { tasks , taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
|
|
74
|
+
const targetGraph = (0, _createTargetGraph.createTargetGraph)({
|
|
73
75
|
logger,
|
|
74
76
|
root,
|
|
75
77
|
dependencies: options.dependencies,
|
|
@@ -85,7 +87,7 @@ async function watchAction(options, command) {
|
|
|
85
87
|
});
|
|
86
88
|
// Make sure we do not attempt writeRemoteCache in watch mode
|
|
87
89
|
config.cacheOptions.writeRemoteCache = false;
|
|
88
|
-
const filteredPipeline = (0,
|
|
90
|
+
const filteredPipeline = (0, _filterPipelineDefinitions.filterPipelineDefinitions)(targetGraph.targets.values(), config.pipeline);
|
|
89
91
|
const maxWorkersPerTaskMap = (0, _config.getMaxWorkersPerTaskFromOptions)(options.maxWorkersPerTask);
|
|
90
92
|
const scheduler = new _scheduler.SimpleScheduler({
|
|
91
93
|
logger,
|
|
@@ -101,7 +103,7 @@ async function watchAction(options, command) {
|
|
|
101
103
|
options: {
|
|
102
104
|
nodeArg: options.nodeArg,
|
|
103
105
|
taskArgs,
|
|
104
|
-
npmCmd: (0,
|
|
106
|
+
npmCmd: (0, _findnpmclient.findNpmClient)(config.npmClient)
|
|
105
107
|
}
|
|
106
108
|
},
|
|
107
109
|
worker: {
|
|
@@ -135,7 +137,7 @@ async function watchAction(options, command) {
|
|
|
135
137
|
targetRun.options.shouldCache = false;
|
|
136
138
|
}
|
|
137
139
|
// When initial run is done, disable fetching of caches on all targets, keep writing to the cache
|
|
138
|
-
const watcher = await (0,
|
|
140
|
+
const watcher = await (0, _watcher.watch)(root, packageInfos);
|
|
139
141
|
watcher.on("change", async (packageName)=>{
|
|
140
142
|
reporter.resetLogEntries();
|
|
141
143
|
const targets = new Map();
|
|
@@ -4,20 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "watch", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return watch;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _chokidar = /*#__PURE__*/
|
|
10
|
-
const _path = /*#__PURE__*/
|
|
11
|
-
const
|
|
12
|
-
const _events = /*#__PURE__*/
|
|
13
|
-
function
|
|
11
|
+
const _chokidar = /*#__PURE__*/ _interop_require_default(require("chokidar"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
const _workspacetools = require("workspace-tools");
|
|
14
|
+
const _events = /*#__PURE__*/ _interop_require_default(require("events"));
|
|
15
|
+
function _interop_require_default(obj) {
|
|
14
16
|
return obj && obj.__esModule ? obj : {
|
|
15
17
|
default: obj
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
function watch(cwd, packageInfos) {
|
|
19
21
|
const events = new _events.default();
|
|
20
|
-
const root = (0,
|
|
22
|
+
const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
|
|
21
23
|
// generate a tree index of all the packages
|
|
22
24
|
const packageIndex = createPackageIndex(root, packageInfos);
|
|
23
25
|
const packagePaths = Object.values(packageInfos).map((pkg)=>_path.default.dirname(pkg.packageJsonPath));
|
|
@@ -9,11 +9,15 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
getFilteredPackages: ()
|
|
13
|
-
|
|
12
|
+
getFilteredPackages: function() {
|
|
13
|
+
return getFilteredPackages;
|
|
14
|
+
},
|
|
15
|
+
filterPackages: function() {
|
|
16
|
+
return filterPackages;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const
|
|
16
|
-
const
|
|
19
|
+
const _workspacetools = require("workspace-tools");
|
|
20
|
+
const _fastglob = /*#__PURE__*/ _interop_require_wildcard(require("fast-glob"));
|
|
17
21
|
function _getRequireWildcardCache(nodeInterop) {
|
|
18
22
|
if (typeof WeakMap !== "function") return null;
|
|
19
23
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -22,7 +26,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
22
26
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
23
27
|
})(nodeInterop);
|
|
24
28
|
}
|
|
25
|
-
function
|
|
29
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
26
30
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
31
|
return obj;
|
|
28
32
|
}
|
|
@@ -63,7 +67,7 @@ function getFilteredPackages(options) {
|
|
|
63
67
|
const hasSince = typeof since !== "undefined";
|
|
64
68
|
// If scope is defined, get scoped packages and return
|
|
65
69
|
if (hasScopes) {
|
|
66
|
-
scopedPackages = (0,
|
|
70
|
+
scopedPackages = (0, _workspacetools.getScopedPackages)(scope, packageInfos);
|
|
67
71
|
// return filteredPackages;
|
|
68
72
|
return filterPackages({
|
|
69
73
|
logger,
|
|
@@ -75,7 +79,7 @@ function getFilteredPackages(options) {
|
|
|
75
79
|
});
|
|
76
80
|
} else if (hasSince) {
|
|
77
81
|
try {
|
|
78
|
-
changedPackages = (0,
|
|
82
|
+
changedPackages = (0, _workspacetools.getChangedPackages)(root, since, sinceIgnoreGlobs);
|
|
79
83
|
} catch (e) {
|
|
80
84
|
logger.warn(`An error in the git command has caused this scope run to include every package\n${e}`);
|
|
81
85
|
// if getChangedPackages throws, we will assume all have changed (using changedPackage = undefined)
|
|
@@ -104,8 +108,8 @@ function getFilteredPackages(options) {
|
|
|
104
108
|
}
|
|
105
109
|
function hasRepoChanged(since, root, environmentGlob, logger) {
|
|
106
110
|
try {
|
|
107
|
-
const changedFiles = (0,
|
|
108
|
-
const envFiles =
|
|
111
|
+
const changedFiles = (0, _workspacetools.getBranchChanges)(since, root);
|
|
112
|
+
const envFiles = _fastglob.sync(environmentGlob, {
|
|
109
113
|
cwd: root
|
|
110
114
|
});
|
|
111
115
|
let repoWideChanged = false;
|
|
@@ -132,7 +136,7 @@ function filterPackages(options) {
|
|
|
132
136
|
// If both scoped and since are specified, we have to merge two lists:
|
|
133
137
|
// 1. changed packages that ARE themselves the scoped packages
|
|
134
138
|
// 2. changed package consumers (package dependents) that are within the scoped subgraph
|
|
135
|
-
filtered = changedPackages.filter((pkg)=>scopedPackages.includes(pkg)).concat((0,
|
|
139
|
+
filtered = changedPackages.filter((pkg)=>scopedPackages.includes(pkg)).concat((0, _workspacetools.getTransitiveDependents)(changedPackages, packageInfos, scopedPackages));
|
|
136
140
|
logger.verbose(`filterPackages changed within scope: ${filtered.join(",")}`);
|
|
137
141
|
} else if (typeof changedPackages !== "undefined") {
|
|
138
142
|
filtered = [
|
|
@@ -150,12 +154,12 @@ function filterPackages(options) {
|
|
|
150
154
|
// adds dependents (consumers) of all filtered package thus far
|
|
151
155
|
if (includeDependents) {
|
|
152
156
|
logger.verbose(`filterPackages running with dependents`);
|
|
153
|
-
filtered = filtered.concat((0,
|
|
157
|
+
filtered = filtered.concat((0, _workspacetools.getTransitiveDependents)(filtered, packageInfos));
|
|
154
158
|
}
|
|
155
159
|
// adds dependencies of all filtered package thus far
|
|
156
160
|
if (includeDependencies) {
|
|
157
161
|
logger.verbose(`filterPackages running with dependencies`);
|
|
158
|
-
filtered = filtered.concat((0,
|
|
162
|
+
filtered = filtered.concat((0, _workspacetools.getTransitiveDependencies)(filtered, packageInfos));
|
|
159
163
|
}
|
|
160
164
|
const unique = new Set(filtered);
|
|
161
165
|
return [
|
package/lib/showHelp.js
CHANGED
package/lib/types/errors.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "NoTargetFoundError", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return NoTargetFoundError;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const NoTargetFoundError = new Error("No target found");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Command Line Interface for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,22 +20,23 @@
|
|
|
20
20
|
"lint": "monorepo-scripts lint"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lage-run/
|
|
23
|
+
"@lage-run/cache": "^0.5.4",
|
|
24
|
+
"@lage-run/config": "^0.2.0",
|
|
24
25
|
"@lage-run/find-npm-client": "^0.1.4",
|
|
25
26
|
"@lage-run/logger": "^1.3.0",
|
|
26
|
-
"@lage-run/
|
|
27
|
+
"@lage-run/reporters": "^1.2.1",
|
|
28
|
+
"@lage-run/scheduler": "^0.11.4",
|
|
27
29
|
"@lage-run/scheduler-types": "^0.3.8",
|
|
28
30
|
"@lage-run/target-graph": "^0.8.4",
|
|
29
|
-
"@lage-run/cache": "^0.5.4",
|
|
30
|
-
"@lage-run/reporters": "^1.2.0",
|
|
31
|
-
"commander": "^9.4.0",
|
|
32
|
-
"workspace-tools": "^0.34.0",
|
|
33
31
|
"chokidar": "3.5.3",
|
|
34
|
-
"
|
|
32
|
+
"commander": "^9.4.0",
|
|
33
|
+
"execa": "5.1.1",
|
|
34
|
+
"fast-glob": "^3.2.11",
|
|
35
|
+
"workspace-tools": "^0.34.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"monorepo-
|
|
38
|
-
"
|
|
38
|
+
"@lage-run/monorepo-fixture": "*",
|
|
39
|
+
"monorepo-scripts": "*"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|