@lage-run/cli 0.17.7 → 0.18.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,79 @@
2
2
  "name": "@lage-run/cli",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 25 Jun 2024 22:03:26 GMT",
5
+ "date": "Fri, 30 Aug 2024 18:39:54 GMT",
6
+ "version": "0.18.0",
7
+ "tag": "@lage-run/cli_v0.18.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "kchau@microsoft.com",
12
+ "package": "@lage-run/cli",
13
+ "commit": "962af15909d64159bbc5fef954e66b6bd4c410d1",
14
+ "comment": "adds an exec command that skips building a target graph."
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@lage-run/cli",
19
+ "comment": "Bump @lage-run/hasher to v1.3.0",
20
+ "commit": "not available"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@lage-run/cli",
25
+ "comment": "Bump @lage-run/scheduler to v1.2.9",
26
+ "commit": "not available"
27
+ }
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "date": "Wed, 28 Aug 2024 21:12:45 GMT",
33
+ "version": "0.17.8",
34
+ "tag": "@lage-run/cli_v0.17.8",
35
+ "comments": {
36
+ "patch": [
37
+ {
38
+ "author": "kchau@microsoft.com",
39
+ "package": "@lage-run/cli",
40
+ "commit": "8b27a04b8d5916457d1c8219edd1f2d216543954",
41
+ "comment": "moving runners to its own package, fixing up imports"
42
+ },
43
+ {
44
+ "author": "beachball",
45
+ "package": "@lage-run/cli",
46
+ "comment": "Bump @lage-run/config to v0.3.7",
47
+ "commit": "not available"
48
+ },
49
+ {
50
+ "author": "beachball",
51
+ "package": "@lage-run/cli",
52
+ "comment": "Bump @lage-run/reporters to v1.2.8",
53
+ "commit": "not available"
54
+ },
55
+ {
56
+ "author": "beachball",
57
+ "package": "@lage-run/cli",
58
+ "comment": "Bump @lage-run/runners to v1.0.1",
59
+ "commit": "not available"
60
+ },
61
+ {
62
+ "author": "beachball",
63
+ "package": "@lage-run/cli",
64
+ "comment": "Bump @lage-run/scheduler to v1.2.8",
65
+ "commit": "not available"
66
+ },
67
+ {
68
+ "author": "beachball",
69
+ "package": "@lage-run/cli",
70
+ "comment": "Bump @lage-run/scheduler-types to v0.3.14",
71
+ "commit": "not available"
72
+ }
73
+ ]
74
+ }
75
+ },
76
+ {
77
+ "date": "Tue, 25 Jun 2024 22:03:40 GMT",
6
78
  "version": "0.17.7",
7
79
  "tag": "@lage-run/cli_v0.17.7",
8
80
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,35 @@
1
1
  # Change Log - @lage-run/cli
2
2
 
3
- This log was last generated on Tue, 25 Jun 2024 22:03:26 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 30 Aug 2024 18:39:54 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.18.0
8
+
9
+ Fri, 30 Aug 2024 18:39:54 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - adds an exec command that skips building a target graph. (kchau@microsoft.com)
14
+ - Bump @lage-run/hasher to v1.3.0
15
+ - Bump @lage-run/scheduler to v1.2.9
16
+
17
+ ## 0.17.8
18
+
19
+ Wed, 28 Aug 2024 21:12:45 GMT
20
+
21
+ ### Patches
22
+
23
+ - moving runners to its own package, fixing up imports (kchau@microsoft.com)
24
+ - Bump @lage-run/config to v0.3.7
25
+ - Bump @lage-run/reporters to v1.2.8
26
+ - Bump @lage-run/runners to v1.0.1
27
+ - Bump @lage-run/scheduler to v1.2.8
28
+ - Bump @lage-run/scheduler-types to v0.3.14
29
+
7
30
  ## 0.17.7
8
31
 
9
- Tue, 25 Jun 2024 22:03:26 GMT
32
+ Tue, 25 Jun 2024 22:03:40 GMT
10
33
 
11
34
  ### Patches
12
35
 
package/lib/cli.js CHANGED
@@ -9,6 +9,7 @@ const _errors = require("./types/errors.js");
9
9
  const _index2 = require("./commands/affected/index.js");
10
10
  const _index3 = require("./commands/init/index.js");
11
11
  const _index4 = require("./commands/info/index.js");
12
+ const _index5 = require("./commands/exec/index.js");
12
13
  async function main() {
13
14
  const program = new _commander.Command();
14
15
  program.addCommand(_index.runCommand, {
@@ -18,6 +19,7 @@ async function main() {
18
19
  program.addCommand(_index2.affectedCommand);
19
20
  program.addCommand(_index3.initCommand);
20
21
  program.addCommand(_index4.infoCommand);
22
+ program.addCommand(_index5.execCommand);
21
23
  await program.parseAsync(process.argv);
22
24
  }
23
25
  main().catch((err)=>{
@@ -1,4 +1,4 @@
1
- import type { TargetRunner, TargetRunnerOptions } from "@lage-run/scheduler-types";
1
+ import type { TargetRunner, TargetRunnerOptions } from "@lage-run/runners";
2
2
  export declare class ClearCacheRunner implements TargetRunner {
3
3
  shouldRun(): Promise<boolean>;
4
4
  run(runOptions: TargetRunnerOptions): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { TargetRunner, TargetRunnerOptions } from "@lage-run/scheduler-types";
1
+ import type { TargetRunner, TargetRunnerOptions } from "@lage-run/runners";
2
2
  export declare class PruneCacheRunner implements TargetRunner {
3
3
  shouldRun(): Promise<boolean>;
4
4
  run(runOptions: TargetRunnerOptions): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import type { Command } from "commander";
2
+ import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
3
+ interface ExecOptions extends ReporterInitOptions {
4
+ cwd?: string;
5
+ nodeArg?: string[];
6
+ }
7
+ export declare function execAction(options: ExecOptions, command: Command): Promise<void>;
8
+ export {};
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "execAction", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return execAction;
9
+ }
10
+ });
11
+ const _filterArgsForTasks = require("../run/filterArgsForTasks.js");
12
+ const _config = require("@lage-run/config");
13
+ const _workspacetools = require("workspace-tools");
14
+ const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
15
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
16
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
17
+ const _targetgraph = require("@lage-run/target-graph");
18
+ const _initializeReporters = require("../initializeReporters.js");
19
+ const _runners = require("@lage-run/runners");
20
+ const _targetId = require("@lage-run/target-graph/lib/targetId.js");
21
+ function _interop_require_default(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
25
+ }
26
+ /**
27
+ * Parses the package and task from the command as quickly as possible:
28
+ *
29
+ * 1. if cwd overridden in args, use it to read the package.json directly
30
+ * 2. if cwd not overridden and root is not cwd, use the cwd to read the package.json directly
31
+ * 3. if root is cwd, assume the task is global
32
+ *
33
+ * @param options
34
+ * @param command
35
+ * @returns
36
+ */ function parsePackageInfoFromArgs(root, options, command) {
37
+ const { packageName , task } = (0, _targetId.getPackageAndTask)(command.args[0]);
38
+ if (packageName) {
39
+ const packageInfos = (0, _workspacetools.getPackageInfos)(root);
40
+ const info = packageInfos[packageName];
41
+ return {
42
+ info,
43
+ task,
44
+ isGlobal: false
45
+ };
46
+ }
47
+ if (options.cwd) {
48
+ const packageJsonPath = _path.default.join(options.cwd, "package.json");
49
+ const packageJson = JSON.parse(_fs.default.readFileSync(packageJsonPath, "utf-8"));
50
+ return {
51
+ info: {
52
+ ...packageJson,
53
+ packageJsonPath
54
+ },
55
+ task,
56
+ isGlobal: false
57
+ };
58
+ }
59
+ if (root !== process.cwd()) {
60
+ const packageJsonPath = _path.default.join(process.cwd(), "package.json");
61
+ if (_fs.default.existsSync(packageJsonPath)) {
62
+ const packageJson = JSON.parse(_fs.default.readFileSync(packageJsonPath, "utf-8"));
63
+ return {
64
+ info: {
65
+ ...packageJson,
66
+ packageJsonPath
67
+ },
68
+ task,
69
+ isGlobal: false
70
+ };
71
+ }
72
+ }
73
+ const packageJsonPath = _path.default.join(root, "package.json");
74
+ const packageJson = JSON.parse(_fs.default.readFileSync(packageJsonPath, "utf-8"));
75
+ return {
76
+ info: {
77
+ ...packageJson,
78
+ packageJsonPath
79
+ },
80
+ task,
81
+ isGlobal: true
82
+ };
83
+ }
84
+ function expandTargetDefinition(packageName, task, pipeline, outputs) {
85
+ const id = packageName ? `${packageName}#${task}` : task;
86
+ const emptyDefinition = {
87
+ cache: false,
88
+ dependsOn: [],
89
+ options: {},
90
+ outputs
91
+ };
92
+ const definition = id in pipeline ? pipeline[id] : `#${task}` in pipeline ? pipeline[`#${task}`] : `//${task}` in pipeline ? pipeline[`//${task}`] : task in pipeline ? pipeline[task] : emptyDefinition;
93
+ if (Array.isArray(definition)) {
94
+ return emptyDefinition;
95
+ } else {
96
+ return definition;
97
+ }
98
+ }
99
+ async function execAction(options, command) {
100
+ const cwd = process.cwd();
101
+ const config = await (0, _config.getConfig)(cwd);
102
+ const { pipeline } = config;
103
+ const logger = (0, _logger.default)();
104
+ options.logLevel = options.logLevel ?? "info";
105
+ options.reporter = options.reporter ?? "json";
106
+ (0, _initializeReporters.initializeReporters)(logger, options);
107
+ const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
108
+ const { info , task , isGlobal } = parsePackageInfoFromArgs(root, options, command);
109
+ const packageInfos = {
110
+ [info.name]: info
111
+ };
112
+ const resolve = ()=>{
113
+ return _path.default.dirname(info.packageJsonPath).replace(/\\/g, "/");
114
+ };
115
+ const { taskArgs } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
116
+ const factory = new _targetgraph.TargetFactory({
117
+ root,
118
+ resolve,
119
+ packageInfos
120
+ });
121
+ const definition = expandTargetDefinition(isGlobal ? undefined : info.name, task, pipeline, config.cacheOptions.outputGlob ?? []);
122
+ const target = isGlobal ? factory.createGlobalTarget(task, definition) : factory.createPackageTarget(info.name, task, definition);
123
+ const pickerOptions = {
124
+ npmScript: {
125
+ script: require.resolve("../run/runners/NpmScriptRunner.js"),
126
+ options: {
127
+ nodeArg: options.nodeArg,
128
+ taskArgs,
129
+ npmCmd: config.npmClient
130
+ }
131
+ },
132
+ worker: {
133
+ script: require.resolve("../run/runners/WorkerRunner.js"),
134
+ options: {
135
+ taskArgs
136
+ }
137
+ },
138
+ noop: {
139
+ script: require.resolve("../run/runners/NoOpRunner.js"),
140
+ options: {}
141
+ }
142
+ };
143
+ const runnerPicker = new _runners.TargetRunnerPicker(pickerOptions);
144
+ const runner = await runnerPicker.pick(target);
145
+ if (await runner.shouldRun(target)) {
146
+ logger.info("Running target", {
147
+ target
148
+ });
149
+ await runner.run({
150
+ target,
151
+ weight: 1,
152
+ abortSignal: new AbortController().signal
153
+ });
154
+ logger.info("Finished", {
155
+ target
156
+ });
157
+ }
158
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ declare const execCommand: Command;
3
+ export { execCommand };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "execCommand", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return execCommand;
9
+ }
10
+ });
11
+ const _commander = require("commander");
12
+ const _action = require("./action.js");
13
+ const _addLoggerOptions = require("../addLoggerOptions.js");
14
+ const execCommand = new _commander.Command("exec");
15
+ (0, _addLoggerOptions.addLoggerOptions)(execCommand).action(_action.execAction);
@@ -1 +1 @@
1
- export { NoOpRunner } from "@lage-run/scheduler";
1
+ export { NoOpRunner } from "@lage-run/runners";
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  Object.defineProperty(exports, "NoOpRunner", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return _scheduler.NoOpRunner;
8
+ return _runners.NoOpRunner;
9
9
  }
10
10
  });
11
- const _scheduler = require("@lage-run/scheduler");
11
+ const _runners = require("@lage-run/runners");
@@ -1 +1 @@
1
- export { NpmScriptRunner } from "@lage-run/scheduler";
1
+ export { NpmScriptRunner } from "@lage-run/runners";
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  Object.defineProperty(exports, "NpmScriptRunner", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return _scheduler.NpmScriptRunner;
8
+ return _runners.NpmScriptRunner;
9
9
  }
10
10
  });
11
- const _scheduler = require("@lage-run/scheduler");
11
+ const _runners = require("@lage-run/runners");
@@ -1 +1 @@
1
- export { WorkerRunner } from "@lage-run/scheduler";
1
+ export { WorkerRunner } from "@lage-run/runners";
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  Object.defineProperty(exports, "WorkerRunner", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return _scheduler.WorkerRunner;
8
+ return _runners.WorkerRunner;
9
9
  }
10
10
  });
11
- const _scheduler = require("@lage-run/scheduler");
11
+ const _runners = require("@lage-run/runners");
package/lib/index.d.ts CHANGED
@@ -3,5 +3,5 @@ export type { ConfigOptions } from "@lage-run/config";
3
3
  export type { Priority } from "@lage-run/config";
4
4
  export type { PipelineDefinition } from "@lage-run/config";
5
5
  export type { LoggerOptions } from "@lage-run/config";
6
- export type { TargetRunnerPickerOptions } from "@lage-run/scheduler-types";
6
+ export type { TargetRunnerPickerOptions } from "@lage-run/runners";
7
7
  export type { TargetConfig } from "@lage-run/target-graph";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/cli",
3
- "version": "0.17.7",
3
+ "version": "0.18.0",
4
4
  "description": "Command Line Interface for Lage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,12 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@lage-run/cache": "^1.3.1",
24
- "@lage-run/config": "^0.3.6",
25
- "@lage-run/hasher": "^1.2.1",
24
+ "@lage-run/config": "^0.3.7",
25
+ "@lage-run/hasher": "^1.3.0",
26
26
  "@lage-run/logger": "^1.3.0",
27
- "@lage-run/reporters": "^1.2.7",
28
- "@lage-run/scheduler": "^1.2.7",
29
- "@lage-run/scheduler-types": "^0.3.13",
27
+ "@lage-run/reporters": "^1.2.8",
28
+ "@lage-run/runners": "^1.0.1",
29
+ "@lage-run/scheduler": "^1.2.9",
30
+ "@lage-run/scheduler-types": "^0.3.14",
30
31
  "@lage-run/target-graph": "^0.8.9",
31
32
  "chokidar": "3.5.3",
32
33
  "commander": "9.5.0",