@lage-run/cli 0.7.2 → 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 CHANGED
@@ -2,7 +2,37 @@
2
2
  "name": "@lage-run/cli",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 31 Jan 2023 18:24:29 GMT",
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",
21
+ "tag": "@lage-run/cli_v0.7.3",
22
+ "version": "0.7.3",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "beachball",
27
+ "package": "@lage-run/cli",
28
+ "comment": "Bump @lage-run/scheduler to v0.8.2",
29
+ "commit": "9340358c80d388e0d56b40d1fdb965e1b4e20454"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Tue, 31 Jan 2023 18:24:39 GMT",
6
36
  "tag": "@lage-run/cli_v0.7.2",
7
37
  "version": "0.7.2",
8
38
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,28 @@
1
1
  # Change Log - @lage-run/cli
2
2
 
3
- This log was last generated on Tue, 31 Jan 2023 18:24:29 GMT and should not be manually modified.
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
+
15
+ ## 0.7.3
16
+
17
+ Tue, 31 Jan 2023 23:54:49 GMT
18
+
19
+ ### Patches
20
+
21
+ - Bump @lage-run/scheduler to v0.8.2
22
+
7
23
  ## 0.7.2
8
24
 
9
- Tue, 31 Jan 2023 18:24:29 GMT
25
+ Tue, 31 Jan 2023 18:24:39 GMT
10
26
 
11
27
  ### Patches
12
28
 
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", []).option("--allow-no-target-runs");
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,6 @@
1
+ import type { FilterOptions } from "../../types/FilterOptions.js";
2
+ interface AffectedOptions extends FilterOptions {
3
+ outputFormat?: "json" | "graph" | "default";
4
+ }
5
+ export declare function affectedAction(options: AffectedOptions): Promise<void>;
6
+ export {};
@@ -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,3 @@
1
+ import { Command } from "commander";
2
+ declare const affectedCommand: Command;
3
+ export { affectedCommand };
@@ -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
- interface RunOptions extends ReporterInitOptions {
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
- interface RunOptions extends ReporterInitOptions {
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[];
13
+ allowNoTargetRuns: boolean;
18
14
  }
19
15
  export declare function watchAction(options: RunOptions, command: Command): Promise<void>;
20
16
  export {};
@@ -0,0 +1,9 @@
1
+ export interface FilterOptions {
2
+ dependencies: boolean;
3
+ dependents: boolean;
4
+ since: string;
5
+ scope: string[];
6
+ to: string[];
7
+ ignore: string[];
8
+ allowNoTargetRuns: boolean;
9
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/cli",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Command Line Interface for Lage",
5
5
  "repository": {
6
6
  "url": "https://github.com/microsoft/lage"
@@ -20,7 +20,7 @@
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.8.1",
23
+ "@lage-run/scheduler": "^0.8.2",
24
24
  "@lage-run/scheduler-types": "^0.3.0",
25
25
  "@lage-run/target-graph": "^0.6.1",
26
26
  "@lage-run/cache": "^0.2.3",