@lage-run/cli 0.5.5 → 0.5.7

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