@lage-run/cli 0.7.3 → 0.8.0
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 +16 -1
- package/CHANGELOG.md +10 -2
- package/lib/cli.js +2 -0
- package/lib/commands/addFilterOptions.js +1 -1
- package/lib/commands/affected/action.d.ts +6 -0
- package/lib/commands/affected/action.js +105 -0
- package/lib/commands/affected/index.d.ts +3 -0
- package/lib/commands/affected/index.js +13 -0
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/run/runAction.d.ts +2 -7
- package/lib/commands/run/watchAction.d.ts +3 -7
- package/lib/types/FilterOptions.d.ts +9 -0
- package/lib/types/FilterOptions.js +4 -0
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Fri, 03 Feb 2023 00:20:00 GMT",
|
|
6
|
+
"tag": "@lage-run/cli_v0.8.0",
|
|
7
|
+
"version": "0.8.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "kchau@microsoft.com",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"commit": "9772c8f6e81edac6a8ae1b4a4c26b1cb8c0986b0",
|
|
14
|
+
"comment": "adding an affected command"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Tue, 31 Jan 2023 23:54:49 GMT",
|
|
6
21
|
"tag": "@lage-run/cli_v0.7.3",
|
|
7
22
|
"version": "0.7.3",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @lage-run/cli
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 03 Feb 2023 00:20:00 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.8.0
|
|
8
|
+
|
|
9
|
+
Fri, 03 Feb 2023 00:20:00 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- adding an affected command (kchau@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.7.3
|
|
8
16
|
|
|
9
|
-
Tue, 31 Jan 2023 23:54:
|
|
17
|
+
Tue, 31 Jan 2023 23:54:49 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/lib/cli.js
CHANGED
|
@@ -6,12 +6,14 @@ const _commander = require("commander");
|
|
|
6
6
|
const _indexJs = require("./commands/run/index.js");
|
|
7
7
|
const _indexJs1 = require("./commands/cache/index.js");
|
|
8
8
|
const _errorsJs = require("./types/errors.js");
|
|
9
|
+
const _indexJs2 = require("./commands/affected/index.js");
|
|
9
10
|
async function main() {
|
|
10
11
|
const program = new _commander.Command();
|
|
11
12
|
program.addCommand(_indexJs.runCommand, {
|
|
12
13
|
isDefault: true
|
|
13
14
|
});
|
|
14
15
|
program.addCommand(_indexJs1.cacheCommand);
|
|
16
|
+
program.addCommand(_indexJs2.affectedCommand);
|
|
15
17
|
await program.parseAsync(process.argv);
|
|
16
18
|
}
|
|
17
19
|
main().catch((err)=>{
|
|
@@ -7,5 +7,5 @@ Object.defineProperty(exports, "addFilterOptions", {
|
|
|
7
7
|
get: ()=>addFilterOptions
|
|
8
8
|
});
|
|
9
9
|
function addFilterOptions(program) {
|
|
10
|
-
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", [])
|
|
10
|
+
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", []);
|
|
11
11
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "affectedAction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>affectedAction
|
|
8
|
+
});
|
|
9
|
+
const _logger = /*#__PURE__*/ _interopRequireDefault(require("@lage-run/logger"));
|
|
10
|
+
const _workspaceTools = require("workspace-tools");
|
|
11
|
+
const _getConfigJs = require("../../config/getConfig.js");
|
|
12
|
+
const _getFilteredPackagesJs = require("../../filter/getFilteredPackages.js");
|
|
13
|
+
function _interopRequireDefault(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async function affectedAction(options) {
|
|
19
|
+
const { dependencies , dependents , since , scope , ignore , outputFormat } = options;
|
|
20
|
+
const cwd = process.cwd();
|
|
21
|
+
const config = await (0, _getConfigJs.getConfig)(cwd);
|
|
22
|
+
const logger = (0, _logger.default)();
|
|
23
|
+
const root = (0, _workspaceTools.getWorkspaceRoot)(cwd);
|
|
24
|
+
const packageInfos = (0, _workspaceTools.getPackageInfos)(root);
|
|
25
|
+
const packages = (0, _getFilteredPackagesJs.getFilteredPackages)({
|
|
26
|
+
root,
|
|
27
|
+
logger,
|
|
28
|
+
packageInfos,
|
|
29
|
+
includeDependencies: dependencies,
|
|
30
|
+
includeDependents: dependents,
|
|
31
|
+
since,
|
|
32
|
+
scope,
|
|
33
|
+
repoWideChanges: config.repoWideChanges,
|
|
34
|
+
sinceIgnoreGlobs: ignore
|
|
35
|
+
});
|
|
36
|
+
let output = "";
|
|
37
|
+
switch(outputFormat){
|
|
38
|
+
case "graph":
|
|
39
|
+
output = renderGraph({
|
|
40
|
+
packages,
|
|
41
|
+
packageInfos
|
|
42
|
+
});
|
|
43
|
+
break;
|
|
44
|
+
case "json":
|
|
45
|
+
output = renderJson({
|
|
46
|
+
packages,
|
|
47
|
+
packageInfos
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
output = renderDefault({
|
|
52
|
+
packages
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.log(output);
|
|
58
|
+
}
|
|
59
|
+
function renderDefault(props) {
|
|
60
|
+
const { packages } = props;
|
|
61
|
+
return `
|
|
62
|
+
All Affected Packages
|
|
63
|
+
---------------------
|
|
64
|
+
|
|
65
|
+
${packages.join("\n")}
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
function renderJson(props) {
|
|
69
|
+
const graph = generatePackageGraph(props);
|
|
70
|
+
return JSON.stringify(graph);
|
|
71
|
+
}
|
|
72
|
+
function renderGraph(props) {
|
|
73
|
+
const graph = generatePackageGraph(props);
|
|
74
|
+
const { packages } = graph;
|
|
75
|
+
const adjacencies = [];
|
|
76
|
+
for (const [pkg, info] of Object.entries(packages)){
|
|
77
|
+
for (const dep of info.dependencies){
|
|
78
|
+
adjacencies.push([
|
|
79
|
+
pkg,
|
|
80
|
+
dep
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return `
|
|
85
|
+
digraph affected {
|
|
86
|
+
${adjacencies.map((entry)=>` "${entry[0]}" -> "${entry[1]}"`).join("\n")}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
function generatePackageGraph(props) {
|
|
91
|
+
const { packages , packageInfos } = props;
|
|
92
|
+
const packageGraph = packages.reduce((accum, pkg)=>{
|
|
93
|
+
const dependencies = Object.keys(packageInfos[pkg].dependencies ?? {}).filter((dep)=>packages.includes(dep));
|
|
94
|
+
const dependents = Object.keys(packageInfos[pkg].dependents ?? {}).filter((dep)=>packages.includes(dep));
|
|
95
|
+
accum[pkg] = {
|
|
96
|
+
dependencies,
|
|
97
|
+
dependents
|
|
98
|
+
};
|
|
99
|
+
return accum;
|
|
100
|
+
}, {});
|
|
101
|
+
return {
|
|
102
|
+
packages: packageGraph,
|
|
103
|
+
count: packages.length
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "affectedCommand", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>affectedCommand
|
|
8
|
+
});
|
|
9
|
+
const _commander = require("commander");
|
|
10
|
+
const _addFilterOptionsJs = require("../addFilterOptions.js");
|
|
11
|
+
const _actionJs = require("./action.js");
|
|
12
|
+
const affectedCommand = new _commander.Command("affected");
|
|
13
|
+
(0, _addFilterOptionsJs.addFilterOptions)(affectedCommand).action(_actionJs.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");
|
|
@@ -13,7 +13,7 @@ const _isRunningFromCIJs = require("../isRunningFromCI.js");
|
|
|
13
13
|
const _addFilterOptionsJs = require("../addFilterOptions.js");
|
|
14
14
|
const runCommand = new _commander.Command("run");
|
|
15
15
|
(0, _addFilterOptionsJs.addFilterOptions)((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", [])// Run Command Options
|
|
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)", _isRunningFromCIJs.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").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", `
|
|
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)", _isRunningFromCIJs.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
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.
|
|
18
18
|
|
|
19
19
|
Examples
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
|
|
3
|
-
|
|
3
|
+
import type { FilterOptions } from "../../types/FilterOptions.js";
|
|
4
|
+
interface RunOptions extends ReporterInitOptions, FilterOptions {
|
|
4
5
|
concurrency: number;
|
|
5
6
|
maxWorkersPerTask: string[];
|
|
6
7
|
profile: string | boolean | undefined;
|
|
7
|
-
dependencies: boolean;
|
|
8
|
-
dependents: boolean;
|
|
9
|
-
since: string;
|
|
10
|
-
scope: string[];
|
|
11
|
-
to: string[];
|
|
12
8
|
skipLocalCache: boolean;
|
|
13
9
|
continue: boolean;
|
|
14
10
|
cache: boolean;
|
|
15
11
|
resetCache: boolean;
|
|
16
12
|
nodeArg: string;
|
|
17
|
-
ignore: string[];
|
|
18
13
|
allowNoTargetRuns: boolean;
|
|
19
14
|
}
|
|
20
15
|
export declare function runAction(options: RunOptions, command: Command): Promise<void>;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
|
|
3
|
-
|
|
3
|
+
import type { FilterOptions } from "../../types/FilterOptions.js";
|
|
4
|
+
interface RunOptions extends ReporterInitOptions, FilterOptions {
|
|
4
5
|
concurrency: number;
|
|
5
6
|
maxWorkersPerTask: string[];
|
|
6
7
|
profile: string | boolean | undefined;
|
|
7
|
-
dependencies: boolean;
|
|
8
|
-
dependents: boolean;
|
|
9
|
-
since: string;
|
|
10
|
-
scope: string[];
|
|
11
|
-
to: string[];
|
|
12
8
|
skipLocalCache: boolean;
|
|
13
9
|
continue: boolean;
|
|
14
10
|
cache: boolean;
|
|
15
11
|
resetCache: boolean;
|
|
16
12
|
nodeArg: string;
|
|
17
|
-
|
|
13
|
+
allowNoTargetRuns: boolean;
|
|
18
14
|
}
|
|
19
15
|
export declare function watchAction(options: RunOptions, command: Command): Promise<void>;
|
|
20
16
|
export {};
|