@lage-run/cli 0.15.13 → 0.16.1

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,43 @@
2
2
  "name": "@lage-run/cli",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 17 Jul 2023 15:13:19 GMT",
5
+ "date": "Tue, 05 Sep 2023 22:19:01 GMT",
6
+ "tag": "@lage-run/cli_v0.16.1",
7
+ "version": "0.16.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "beachball",
12
+ "package": "@lage-run/cli",
13
+ "comment": "Bump @lage-run/cache to v1.1.3",
14
+ "commit": "1b921746f45e232095c13e35039b2f425ff74f8e"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@lage-run/cli",
19
+ "comment": "Bump @lage-run/scheduler to v1.1.8",
20
+ "commit": "1b921746f45e232095c13e35039b2f425ff74f8e"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "date": "Wed, 09 Aug 2023 18:41:19 GMT",
27
+ "tag": "@lage-run/cli_v0.16.0",
28
+ "version": "0.16.0",
29
+ "comments": {
30
+ "minor": [
31
+ {
32
+ "author": "unpervertedkid@gmail.com",
33
+ "package": "@lage-run/cli",
34
+ "commit": "228357ca14429835006fe0bf7018e52ad551243e",
35
+ "comment": "Implemented info command in lage v2"
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ {
41
+ "date": "Mon, 17 Jul 2023 15:14:04 GMT",
6
42
  "tag": "@lage-run/cli_v0.15.13",
7
43
  "version": "0.15.13",
8
44
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,29 @@
1
1
  # Change Log - @lage-run/cli
2
2
 
3
- This log was last generated on Mon, 17 Jul 2023 15:13:19 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 05 Sep 2023 22:19:01 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.16.1
8
+
9
+ Tue, 05 Sep 2023 22:19:01 GMT
10
+
11
+ ### Patches
12
+
13
+ - Bump @lage-run/cache to v1.1.3
14
+ - Bump @lage-run/scheduler to v1.1.8
15
+
16
+ ## 0.16.0
17
+
18
+ Wed, 09 Aug 2023 18:41:19 GMT
19
+
20
+ ### Minor changes
21
+
22
+ - Implemented info command in lage v2 (unpervertedkid@gmail.com)
23
+
7
24
  ## 0.15.13
8
25
 
9
- Mon, 17 Jul 2023 15:13:19 GMT
26
+ Mon, 17 Jul 2023 15:14:04 GMT
10
27
 
11
28
  ### Patches
12
29
 
package/lib/cli.js CHANGED
@@ -8,6 +8,7 @@ const _index1 = require("./commands/cache/index.js");
8
8
  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
+ const _index4 = require("./commands/info/index.js");
11
12
  async function main() {
12
13
  const program = new _commander.Command();
13
14
  program.addCommand(_index.runCommand, {
@@ -16,6 +17,7 @@ async function main() {
16
17
  program.addCommand(_index1.cacheCommand);
17
18
  program.addCommand(_index2.affectedCommand);
18
19
  program.addCommand(_index3.initCommand);
20
+ program.addCommand(_index4.infoCommand);
19
21
  await program.parseAsync(process.argv);
20
22
  }
21
23
  main().catch((err)=>{
@@ -0,0 +1,51 @@
1
+ import type { Command } from "commander";
2
+ import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
3
+ interface RunOptions extends ReporterInitOptions {
4
+ dependencies: boolean;
5
+ dependents: boolean;
6
+ since: string;
7
+ scope: string[];
8
+ to: string[];
9
+ cache: boolean;
10
+ nodeArg: string;
11
+ ignore: string[];
12
+ }
13
+ /**
14
+ * (UNSTABLE) The info command displays information about a target graph in a workspace.
15
+ * The generated output can be read and used by other task runners, such as BuildXL.
16
+ *
17
+ * Expected format:
18
+ * [
19
+ * {
20
+ * "id": "bar##build",
21
+ * "package": "bar",
22
+ * "task": "build",
23
+ * "command": "npm run build --blah",
24
+ * "workingDirectory": "packages/bar",
25
+ * "dependencies": []
26
+ * },
27
+ * {
28
+ * "id": "foo##build",
29
+ * "package": "foo",
30
+ * "task": "build",
31
+ * "command": "npm run build --blah",
32
+ * "workingDirectory": "packages/foo",
33
+ * "dependencies": [
34
+ * "bar##build"
35
+ * ]
36
+ * },
37
+ * {
38
+ * "id": "foo##test",
39
+ * "package": "foo",
40
+ * "task": "test",
41
+ * "command": "npm run test --blah",
42
+ * "workingDirectory": "packages/foo",
43
+ * "dependencies": [
44
+ * "foo##build"
45
+ * ]
46
+ * },
47
+ * ...
48
+ * ]
49
+ */
50
+ export declare function infoAction(options: RunOptions, command: Command): Promise<void>;
51
+ export {};
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "infoAction", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return infoAction;
9
+ }
10
+ });
11
+ const _createTargetGraph = require("../run/createTargetGraph.js");
12
+ const _filterArgsForTasks = require("../run/filterArgsForTasks.js");
13
+ const _config = require("@lage-run/config");
14
+ const _workspacetools = require("workspace-tools");
15
+ const _getFilteredPackages = require("../../filter/getFilteredPackages.js");
16
+ const _logger = /*#__PURE__*/ _interop_require_default(require("@lage-run/logger"));
17
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
18
+ const _targetgraph = require("@lage-run/target-graph");
19
+ const _initializeReporters = require("../initializeReporters.js");
20
+ function _interop_require_default(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+ async function infoAction(options, command) {
26
+ const cwd = process.cwd();
27
+ const config = await (0, _config.getConfig)(cwd);
28
+ const logger = (0, _logger.default)();
29
+ options.logLevel = options.logLevel ?? "info";
30
+ options.reporter = options.reporter ?? "json";
31
+ (0, _initializeReporters.initializeReporters)(logger, options);
32
+ const root = (0, _workspacetools.getWorkspaceRoot)(cwd);
33
+ const packageInfos = await (0, _workspacetools.getPackageInfosAsync)(root);
34
+ const targetGraph = prepareAndCreateTargetGraph(config, logger, root, options, packageInfos, command);
35
+ const scope = prepareAndGetFilteredPackages(config, logger, root, options, packageInfos);
36
+ const packageTasks = processTargets(targetGraph.targets, packageInfos, config);
37
+ logger.info("info", {
38
+ command: command.args,
39
+ scope,
40
+ packageTasks: [
41
+ ...packageTasks.values()
42
+ ].flat()
43
+ });
44
+ }
45
+ function prepareAndCreateTargetGraph(config, logger, root, options, packageInfos, command) {
46
+ const { tasks } = (0, _filterArgsForTasks.filterArgsForTasks)(command.args);
47
+ const targetGraph = (0, _createTargetGraph.createTargetGraph)({
48
+ logger,
49
+ root,
50
+ dependencies: options.dependencies,
51
+ dependents: options.dependents && !options.to,
52
+ ignore: options.ignore.concat(config.ignore),
53
+ pipeline: config.pipeline,
54
+ repoWideChanges: config.repoWideChanges,
55
+ scope: (options.scope ?? []).concat(options.to ?? []),
56
+ since: options.since,
57
+ outputs: config.cacheOptions.outputGlob,
58
+ tasks,
59
+ packageInfos
60
+ });
61
+ return targetGraph;
62
+ }
63
+ function prepareAndGetFilteredPackages(config, logger, root, options, packageInfos) {
64
+ const scope = (0, _getFilteredPackages.getFilteredPackages)({
65
+ root,
66
+ packageInfos,
67
+ logger,
68
+ includeDependencies: options.dependencies,
69
+ includeDependents: options.dependents && !options.to,
70
+ since: options.since,
71
+ scope: (options.scope ?? []).concat(options.to ?? []),
72
+ repoWideChanges: config.repoWideChanges,
73
+ sinceIgnoreGlobs: options.ignore.concat(config.ignore)
74
+ });
75
+ return scope;
76
+ }
77
+ function processTargets(targets, packageInfos, config) {
78
+ const packageTasks = new Map(); // Initialize the map with the correct type
79
+ for (const target of targets.values()){
80
+ if (shouldSkipTarget(target, packageInfos)) {
81
+ continue;
82
+ }
83
+ const startIdIndex = target.dependencies.indexOf((0, _targetgraph.getStartTargetId)());
84
+ target.dependencies.splice(startIdIndex, 1);
85
+ const packageTask = generatePackageTask(target, config);
86
+ if (packageTask) {
87
+ // Check if the packageTask is defined before accessing its properties
88
+ const packageName = packageTask.package;
89
+ if (!packageTasks.has(packageName)) {
90
+ packageTasks.set(packageName, []);
91
+ }
92
+ packageTasks.get(packageName).push(packageTask); // Use the non-null assertion operator to avoid type errors
93
+ }
94
+ }
95
+ return packageTasks;
96
+ }
97
+ function shouldSkipTarget(target, packageInfos) {
98
+ return target.id === (0, _targetgraph.getStartTargetId)() || !packageInfos[target.packageName ?? ""]?.scripts?.[target.task];
99
+ }
100
+ function generatePackageTask(target, config) {
101
+ const command = generateCommand(target, config);
102
+ const workingDirectory = getWorkingDirectory(target);
103
+ const packageTask = {
104
+ id: target.id,
105
+ command,
106
+ dependencies: target.dependencies,
107
+ workingDirectory,
108
+ package: target.packageName,
109
+ task: target.task
110
+ };
111
+ return packageTask;
112
+ }
113
+ function generateCommand(target, config) {
114
+ const npmClient = config.npmClient ?? "npm";
115
+ const command = [
116
+ npmClient,
117
+ ...getNpmArgs(target.task, target.taskArgs)
118
+ ];
119
+ return command;
120
+ }
121
+ function getWorkingDirectory(target) {
122
+ const cwd = process.cwd();
123
+ const workingDirectory = _path.default.relative((0, _workspacetools.getWorkspaceRoot)(cwd) ?? "", target.cwd).replace(/\\/g, "/");
124
+ return workingDirectory;
125
+ }
126
+ function getNpmArgs(task, taskTargs) {
127
+ const extraArgs = taskTargs != undefined && taskTargs.length > 0 ? [
128
+ "--",
129
+ ...taskTargs
130
+ ] : [];
131
+ return [
132
+ "run",
133
+ task,
134
+ ...extraArgs
135
+ ];
136
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ declare const infoCommand: Command;
3
+ export { infoCommand };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "infoCommand", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return infoCommand;
9
+ }
10
+ });
11
+ const _commander = require("commander");
12
+ const _action = require("./action.js");
13
+ const _addFilterOptions = require("../addFilterOptions.js");
14
+ const _addLoggerOptions = require("../addLoggerOptions.js");
15
+ const infoCommand = new _commander.Command("info");
16
+ (0, _addFilterOptions.addFilterOptions)((0, _addLoggerOptions.addLoggerOptions)(infoCommand)).action(_action.infoAction);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/cli",
3
- "version": "0.15.13",
3
+ "version": "0.16.1",
4
4
  "description": "Command Line Interface for Lage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,13 +20,13 @@
20
20
  "lint": "monorepo-scripts lint"
21
21
  },
22
22
  "dependencies": {
23
- "@lage-run/cache": "^1.1.2",
23
+ "@lage-run/cache": "^1.1.3",
24
24
  "@lage-run/config": "^0.3.2",
25
25
  "@lage-run/find-npm-client": "^0.1.4",
26
26
  "@lage-run/hasher": "^1.0.4",
27
27
  "@lage-run/logger": "^1.3.0",
28
28
  "@lage-run/reporters": "^1.2.5",
29
- "@lage-run/scheduler": "^1.1.7",
29
+ "@lage-run/scheduler": "^1.1.8",
30
30
  "@lage-run/scheduler-types": "^0.3.11",
31
31
  "@lage-run/target-graph": "^0.8.7",
32
32
  "chokidar": "3.5.3",