@lage-run/cli 0.4.32 → 0.4.34

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