@lage-run/cli 0.15.12 → 0.16.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 +73 -1
- package/CHANGELOG.md +25 -2
- package/lib/cli.js +2 -0
- package/lib/commands/info/action.d.ts +51 -0
- package/lib/commands/info/action.js +136 -0
- package/lib/commands/info/index.d.ts +3 -0
- package/lib/commands/info/index.js +16 -0
- package/package.json +9 -9
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,79 @@
|
|
|
2
2
|
"name": "@lage-run/cli",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 09 Aug 2023 18:41:10 GMT",
|
|
6
|
+
"tag": "@lage-run/cli_v0.16.0",
|
|
7
|
+
"version": "0.16.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "unpervertedkid@gmail.com",
|
|
12
|
+
"package": "@lage-run/cli",
|
|
13
|
+
"commit": "228357ca14429835006fe0bf7018e52ad551243e",
|
|
14
|
+
"comment": "Implemented info command in lage v2"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Mon, 17 Jul 2023 15:14:04 GMT",
|
|
21
|
+
"tag": "@lage-run/cli_v0.15.13",
|
|
22
|
+
"version": "0.15.13",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "email not defined",
|
|
27
|
+
"package": "@lage-run/cli",
|
|
28
|
+
"commit": "5f41b1db342b6d7a8492a46b68ca328a21e61ee6",
|
|
29
|
+
"comment": "Update lage core deps"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "beachball",
|
|
33
|
+
"package": "@lage-run/cli",
|
|
34
|
+
"comment": "Bump @lage-run/cache to v1.1.2",
|
|
35
|
+
"commit": "5f41b1db342b6d7a8492a46b68ca328a21e61ee6"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "beachball",
|
|
39
|
+
"package": "@lage-run/cli",
|
|
40
|
+
"comment": "Bump @lage-run/config to v0.3.2",
|
|
41
|
+
"commit": "5f41b1db342b6d7a8492a46b68ca328a21e61ee6"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"author": "beachball",
|
|
45
|
+
"package": "@lage-run/cli",
|
|
46
|
+
"comment": "Bump @lage-run/hasher to v1.0.4",
|
|
47
|
+
"commit": "5f41b1db342b6d7a8492a46b68ca328a21e61ee6"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"author": "beachball",
|
|
51
|
+
"package": "@lage-run/cli",
|
|
52
|
+
"comment": "Bump @lage-run/reporters to v1.2.5",
|
|
53
|
+
"commit": "5f41b1db342b6d7a8492a46b68ca328a21e61ee6"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"author": "beachball",
|
|
57
|
+
"package": "@lage-run/cli",
|
|
58
|
+
"comment": "Bump @lage-run/scheduler to v1.1.7",
|
|
59
|
+
"commit": "5f41b1db342b6d7a8492a46b68ca328a21e61ee6"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"author": "beachball",
|
|
63
|
+
"package": "@lage-run/cli",
|
|
64
|
+
"comment": "Bump @lage-run/scheduler-types to v0.3.11",
|
|
65
|
+
"commit": "5f41b1db342b6d7a8492a46b68ca328a21e61ee6"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"author": "beachball",
|
|
69
|
+
"package": "@lage-run/cli",
|
|
70
|
+
"comment": "Bump @lage-run/target-graph to v0.8.7",
|
|
71
|
+
"commit": "5f41b1db342b6d7a8492a46b68ca328a21e61ee6"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"date": "Tue, 11 Jul 2023 14:51:52 GMT",
|
|
6
78
|
"tag": "@lage-run/cli_v0.15.12",
|
|
7
79
|
"version": "0.15.12",
|
|
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
|
|
3
|
+
This log was last generated on Wed, 09 Aug 2023 18:41:10 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.16.0
|
|
8
|
+
|
|
9
|
+
Wed, 09 Aug 2023 18:41:10 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Implemented info command in lage v2 (unpervertedkid@gmail.com)
|
|
14
|
+
|
|
15
|
+
## 0.15.13
|
|
16
|
+
|
|
17
|
+
Mon, 17 Jul 2023 15:14:04 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Update lage core deps (email not defined)
|
|
22
|
+
- Bump @lage-run/cache to v1.1.2
|
|
23
|
+
- Bump @lage-run/config to v0.3.2
|
|
24
|
+
- Bump @lage-run/hasher to v1.0.4
|
|
25
|
+
- Bump @lage-run/reporters to v1.2.5
|
|
26
|
+
- Bump @lage-run/scheduler to v1.1.7
|
|
27
|
+
- Bump @lage-run/scheduler-types to v0.3.11
|
|
28
|
+
- Bump @lage-run/target-graph to v0.8.7
|
|
29
|
+
|
|
7
30
|
## 0.15.12
|
|
8
31
|
|
|
9
|
-
Tue, 11 Jul 2023 14:51:
|
|
32
|
+
Tue, 11 Jul 2023 14:51:52 GMT
|
|
10
33
|
|
|
11
34
|
### Patches
|
|
12
35
|
|
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,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.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Command Line Interface for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
"lint": "monorepo-scripts lint"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lage-run/cache": "^1.1.
|
|
24
|
-
"@lage-run/config": "^0.3.
|
|
23
|
+
"@lage-run/cache": "^1.1.2",
|
|
24
|
+
"@lage-run/config": "^0.3.2",
|
|
25
25
|
"@lage-run/find-npm-client": "^0.1.4",
|
|
26
|
-
"@lage-run/hasher": "^1.0.
|
|
26
|
+
"@lage-run/hasher": "^1.0.4",
|
|
27
27
|
"@lage-run/logger": "^1.3.0",
|
|
28
|
-
"@lage-run/reporters": "^1.2.
|
|
29
|
-
"@lage-run/scheduler": "^1.1.
|
|
30
|
-
"@lage-run/scheduler-types": "^0.3.
|
|
31
|
-
"@lage-run/target-graph": "^0.8.
|
|
28
|
+
"@lage-run/reporters": "^1.2.5",
|
|
29
|
+
"@lage-run/scheduler": "^1.1.7",
|
|
30
|
+
"@lage-run/scheduler-types": "^0.3.11",
|
|
31
|
+
"@lage-run/target-graph": "^0.8.7",
|
|
32
32
|
"chokidar": "3.5.3",
|
|
33
33
|
"commander": "^9.4.0",
|
|
34
34
|
"execa": "5.1.1",
|
|
35
35
|
"fast-glob": "^3.2.11",
|
|
36
|
-
"workspace-tools": "^0.
|
|
36
|
+
"workspace-tools": "^0.35.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@lage-run/monorepo-fixture": "*",
|