Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions change/change-d96ec333-08ff-4c18-b36d-b1ab9679d0cf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"type": "minor",
"comment": "Add extra info to lage info for #815",
"packageName": "@lage-run/cli",
"email": "dannyvv@microsoft.com",
"dependentChangeType": "patch"
}
]
}
24 changes: 23 additions & 1 deletion packages/cli/src/commands/info/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ interface PackageTask {
workingDirectory: string;
package: string;
task: string;
inputs?: string[];
outputs?: string[];
options?: Record<string, any>;
weight?: number;
}

/**
Expand All @@ -61,7 +65,15 @@ interface PackageTask {
* "workingDirectory": "packages/foo",
* "dependencies": [
* "bar##build"
* ]
* ],
* "weight": 3,
* "inputs": ["src//**/ /*.ts"],
* "inputs": ["lib//**/ /*.js", "lib//**/ /*.d.ts]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of weird to have duplicate things here? did you mean "outputs"?

* "options": {
* "environment": {
* "custom_env_var": "x",
* }
* }
* },
* {
* "id": "foo##test",
Expand Down Expand Up @@ -154,8 +166,18 @@ function generatePackageTask(
workingDirectory,
package: target.packageName ?? "",
task: target.task,
inputs: target.inputs,
outputs: target.outputs,
};

if (target.weight && target.weight !== 1) {
packageTask.weight = target.weight;
}

if (target.options && Object.keys(target.options).length != 0) {
packageTask.options = target.options;
}

return packageTask;
}

Expand Down
220 changes: 220 additions & 0 deletions packages/e2e-tests/src/__snapshots__/info.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,226 @@ exports[`info command basic info test case 1`] = `
]
`;

exports[`info command custom inputs, outputs and weight value 1`] = `
[
{
"data": {
"command": [
"test",
"build",
],
"packageTasks": [
{
"command": [],
"dependencies": [],
"id": "__start",
"package": "",
"task": "__start",
"workingDirectory": "",
},
{
"command": [
"node",
"./test.js",
],
"dependencies": [
"a#build",
],
"id": "a#test",
"inputs": [
"src/**/*.test.ts",
"*",
"^lib/**",
],
"package": "a",
"task": "test",
"weight": 5,
"workingDirectory": "packages/a",
},
{
"command": [
"node",
"./test.js",
],
"dependencies": [
"b#build",
],
"id": "b#test",
"inputs": [
"src/**/*.test.ts",
"*",
"^lib/**",
],
"package": "b",
"task": "test",
"weight": 5,
"workingDirectory": "packages/b",
},
{
"command": [
"node",
"./build.js",
],
"dependencies": [
"b#build",
],
"id": "a#build",
"inputs": [
"src/**",
"*",
],
"outputs": [
"lib/**",
],
"package": "a",
"task": "build",
"workingDirectory": "packages/a",
},
{
"command": [
"node",
"./build.js",
],
"dependencies": [
"__start",
],
"id": "b#build",
"inputs": [
"src/**",
"*",
],
"outputs": [
"lib/**",
],
"package": "b",
"task": "build",
"workingDirectory": "packages/b",
},
],
"scope": [
"a",
"b",
],
},
"level": 30,
"msg": "info",
},
]
`;

exports[`info command custom options 1`] = `
[
{
"data": {
"command": [
"test",
"build",
],
"packageTasks": [
{
"command": [],
"dependencies": [],
"id": "__start",
"package": "",
"task": "__start",
"workingDirectory": "",
},
{
"command": [
"node",
"./test.js",
],
"dependencies": [
"a#build",
],
"id": "a#test",
"options": {
"environment": {
"custom_env_var_array": [
1,
true,
"string",
{
"x": 1,
},
[],
],
"custom_env_var_bool": true,
"custom_env_var_number": 1,
"custom_env_var_string": "string",
},
},
"package": "a",
"task": "test",
"workingDirectory": "packages/a",
},
{
"command": [
"node",
"./test.js",
],
"dependencies": [
"b#build",
],
"id": "b#test",
"options": {
"environment": {
"custom_env_var_array": [
1,
true,
"string",
{
"x": 1,
},
[],
],
"custom_env_var_bool": true,
"custom_env_var_number": 1,
"custom_env_var_string": "string",
},
},
"package": "b",
"task": "test",
"workingDirectory": "packages/b",
},
{
"command": [
"node",
"./build.js",
],
"dependencies": [
"b#build",
],
"id": "a#build",
"package": "a",
"task": "build",
"workingDirectory": "packages/a",
},
{
"command": [
"node",
"./build.js",
],
"dependencies": [
"__start",
],
"id": "b#build",
"package": "b",
"task": "build",
"workingDirectory": "packages/b",
},
],
"scope": [
"a",
"b",
],
},
"level": 30,
"msg": "info",
},
]
`;

exports[`info command scoped info test case 1`] = `
[
{
Expand Down
71 changes: 71 additions & 0 deletions packages/e2e-tests/src/info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,75 @@ describe("info command", () => {

await repo.cleanup();
});

it("custom inputs, outputs and weight value", async () => {
const repo = new Monorepo("scoped-info");

repo.init();
repo.setLageConfig(
`module.exports = {
pipeline: {
build: {
inputs: ["src/**", "*"],
outputs: ["lib/**"],
dependsOn: ["^build"],
},
outputs: ["log/**"],
test: {
inputs: ["src/**/*.test.ts", "*", "^lib/**"],
dependsOn: ["build"],
weight: 5
}
},
cache: true,
};`
);

repo.addPackage("a", ["b"]);
repo.addPackage("b");
repo.install();
const results = repo.run("writeInfo", ["test", "build"]);
const output = results.stdout + results.stderr;
const jsonOutput = parseNdJson(output);
expect(jsonOutput).toMatchSnapshot();

await repo.cleanup();
});

it("custom options", async () => {
const repo = new Monorepo("scoped-info");

repo.init();
repo.setLageConfig(
`module.exports = {
pipeline: {
build: ["^build"],
test: {
dependsOn: ["build"],
options: {
environment: {
custom_env_var_number: 1,
custom_env_var_string: "string",
custom_env_var_bool: true,
custom_env_var_array: [1, true, "string", {x:1}, []],
}
}
}
},
cache: true,
};`
);

repo.addPackage("a", ["b"]);
repo.addPackage("b");

repo.install();

const results = repo.run("writeInfo", ["test", "build"]);
const output = results.stdout + results.stderr;
const jsonOutput = parseNdJson(output);
expect(jsonOutput).toMatchSnapshot();

await repo.cleanup();
});
});