@lage-run/cli 0.13.2 → 0.15.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,107 @@
2
2
  "name": "@lage-run/cli",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 14 Apr 2023 04:37:34 GMT",
5
+ "date": "Wed, 26 Apr 2023 04:56:07 GMT",
6
+ "tag": "@lage-run/cli_v0.15.0",
7
+ "version": "0.15.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "elcraig@microsoft.com",
12
+ "package": "@lage-run/cli",
13
+ "commit": "56910ce2ef67d9d3dc99b7a75df007820e9444c8",
14
+ "comment": "Add back the init command"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@lage-run/cli",
19
+ "comment": "Bump @lage-run/config to v0.2.0",
20
+ "commit": "56910ce2ef67d9d3dc99b7a75df007820e9444c8"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@lage-run/cli",
25
+ "comment": "Bump @lage-run/scheduler to v0.11.4",
26
+ "commit": "56910ce2ef67d9d3dc99b7a75df007820e9444c8"
27
+ }
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "date": "Tue, 25 Apr 2023 02:51:19 GMT",
33
+ "tag": "@lage-run/cli_v0.14.0",
34
+ "version": "0.14.0",
35
+ "comments": {
36
+ "minor": [
37
+ {
38
+ "author": "stchur@microsoft.com",
39
+ "package": "@lage-run/cli",
40
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801",
41
+ "comment": "Add support for --log-file (to be used in concert with --reporter vfl"
42
+ },
43
+ {
44
+ "author": "beachball",
45
+ "package": "@lage-run/cli",
46
+ "comment": "Bump @lage-run/config to v0.1.4",
47
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801"
48
+ },
49
+ {
50
+ "author": "beachball",
51
+ "package": "@lage-run/cli",
52
+ "comment": "Bump @lage-run/logger to v1.3.0",
53
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801"
54
+ },
55
+ {
56
+ "author": "beachball",
57
+ "package": "@lage-run/cli",
58
+ "comment": "Bump @lage-run/scheduler to v0.11.3",
59
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801"
60
+ },
61
+ {
62
+ "author": "beachball",
63
+ "package": "@lage-run/cli",
64
+ "comment": "Bump @lage-run/scheduler-types to v0.3.8",
65
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801"
66
+ },
67
+ {
68
+ "author": "beachball",
69
+ "package": "@lage-run/cli",
70
+ "comment": "Bump @lage-run/target-graph to v0.8.4",
71
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801"
72
+ },
73
+ {
74
+ "author": "beachball",
75
+ "package": "@lage-run/cli",
76
+ "comment": "Bump @lage-run/cache to v0.5.4",
77
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801"
78
+ },
79
+ {
80
+ "author": "beachball",
81
+ "package": "@lage-run/cli",
82
+ "comment": "Bump @lage-run/reporters to v1.2.0",
83
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801"
84
+ }
85
+ ],
86
+ "patch": [
87
+ {
88
+ "author": "elcraig@microsoft.com",
89
+ "package": "@lage-run/cli",
90
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801",
91
+ "comment": "Update repository and homepage"
92
+ },
93
+ {
94
+ "author": "stchur@microsoft.com",
95
+ "package": "@lage-run/cli",
96
+ "commit": "a2e112e8aafee26380684efca4db994a9c5e3801",
97
+ "comment": {
98
+ "title": "Add reporter cleanup to watchAction"
99
+ }
100
+ }
101
+ ]
102
+ }
103
+ },
104
+ {
105
+ "date": "Fri, 14 Apr 2023 04:37:54 GMT",
6
106
  "tag": "@lage-run/cli_v0.13.2",
7
107
  "version": "0.13.2",
8
108
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,42 @@
1
1
  # Change Log - @lage-run/cli
2
2
 
3
- This log was last generated on Fri, 14 Apr 2023 04:37:34 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 26 Apr 2023 04:56:07 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.15.0
8
+
9
+ Wed, 26 Apr 2023 04:56:07 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Add back the init command (elcraig@microsoft.com)
14
+ - Bump @lage-run/config to v0.2.0
15
+ - Bump @lage-run/scheduler to v0.11.4
16
+
17
+ ## 0.14.0
18
+
19
+ Tue, 25 Apr 2023 02:51:19 GMT
20
+
21
+ ### Minor changes
22
+
23
+ - Add support for --log-file (to be used in concert with --reporter vfl (stchur@microsoft.com)
24
+ - Bump @lage-run/config to v0.1.4
25
+ - Bump @lage-run/logger to v1.3.0
26
+ - Bump @lage-run/scheduler to v0.11.3
27
+ - Bump @lage-run/scheduler-types to v0.3.8
28
+ - Bump @lage-run/target-graph to v0.8.4
29
+ - Bump @lage-run/cache to v0.5.4
30
+ - Bump @lage-run/reporters to v1.2.0
31
+
32
+ ### Patches
33
+
34
+ - Update repository and homepage (elcraig@microsoft.com)
35
+ - [object Object] (stchur@microsoft.com)
36
+
7
37
  ## 0.13.2
8
38
 
9
- Fri, 14 Apr 2023 04:37:34 GMT
39
+ Fri, 14 Apr 2023 04:37:54 GMT
10
40
 
11
41
  ### Patches
12
42
 
package/lib/cli.js CHANGED
@@ -7,6 +7,7 @@ const _indexJs = require("./commands/run/index.js");
7
7
  const _indexJs1 = require("./commands/cache/index.js");
8
8
  const _errorsJs = require("./types/errors.js");
9
9
  const _indexJs2 = require("./commands/affected/index.js");
10
+ const _indexJs3 = require("./commands/init/index.js");
10
11
  async function main() {
11
12
  const program = new _commander.Command();
12
13
  program.addCommand(_indexJs.runCommand, {
@@ -14,6 +15,7 @@ async function main() {
14
15
  });
15
16
  program.addCommand(_indexJs1.cacheCommand);
16
17
  program.addCommand(_indexJs2.affectedCommand);
18
+ program.addCommand(_indexJs3.initCommand);
17
19
  await program.parseAsync(process.argv);
18
20
  }
19
21
  main().catch((err)=>{
@@ -19,5 +19,5 @@ function addLoggerOptions(program) {
19
19
  "error",
20
20
  "verbose",
21
21
  "silly"
22
- ]).conflicts("verbose")).option("--verbose", "verbose output", false);
22
+ ]).conflicts("verbose")).addOption(new _commander.Option("--log-file <file>", "when used with --reporter vfl, writes verbose, ungrouped logs to the specified file")).option("--verbose", "verbose output", false);
23
23
  }
@@ -1,3 +1,3 @@
1
- import { JsonReporter, AdoReporter, LogReporter, ProgressReporter, ChromeTraceEventsReporter } from "@lage-run/reporters";
1
+ import { JsonReporter, AdoReporter, LogReporter, ProgressReporter, VerboseFileLogReporter, ChromeTraceEventsReporter } from "@lage-run/reporters";
2
2
  import type { ReporterInitOptions } from "../types/ReporterInitOptions.js";
3
- export declare function createReporter(reporter: string, options: ReporterInitOptions): ChromeTraceEventsReporter | JsonReporter | AdoReporter | LogReporter | ProgressReporter;
3
+ export declare function createReporter(reporter: string, options: ReporterInitOptions): ChromeTraceEventsReporter | JsonReporter | AdoReporter | LogReporter | VerboseFileLogReporter | ProgressReporter;
@@ -17,7 +17,7 @@ function _interopRequireDefault(obj) {
17
17
  };
18
18
  }
19
19
  function createReporter(reporter, options) {
20
- const { verbose , grouped , logLevel: logLevelName , concurrency , profile , progress } = options;
20
+ const { verbose , grouped , logLevel: logLevelName , concurrency , profile , progress , logFile } = options;
21
21
  const logLevel = _logger.LogLevel[logLevelName];
22
22
  const root = (0, _workspaceTools.findPackageRoot)(__filename);
23
23
  const packageJson = JSON.parse((0, _fs.readFileSync)(_path.default.join(root, "package.json"), "utf-8"));
@@ -44,6 +44,9 @@ function createReporter(reporter, options) {
44
44
  grouped,
45
45
  logLevel: verbose ? _logger.LogLevel.verbose : logLevel
46
46
  });
47
+ case "verboseFileLog":
48
+ case "vfl":
49
+ return new _reporters.VerboseFileLogReporter(logFile);
47
50
  default:
48
51
  if (progress && !(logLevel >= _logger.LogLevel.verbose || verbose || grouped)) {
49
52
  return new _reporters.ProgressReporter({
@@ -0,0 +1 @@
1
+ export declare function initAction(): Promise<void>;
@@ -0,0 +1,119 @@
1
+ /* eslint-disable no-console -- logger doesn't work in this context */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "initAction", {
6
+ enumerable: true,
7
+ get: ()=>initAction
8
+ });
9
+ const _config = require("@lage-run/config");
10
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
11
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
12
+ const _execa = /*#__PURE__*/ _interopRequireDefault(require("execa"));
13
+ function _interopRequireDefault(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ var _packageJson, _packageJson1;
19
+ async function initAction() {
20
+ const cwd = process.cwd();
21
+ const config = await (0, _config.readConfigFile)(cwd);
22
+ if (config) {
23
+ console.error("lage is already initialized in this workspace");
24
+ process.exitCode = 1;
25
+ return;
26
+ }
27
+ console.info("Installing lage and creating a default configuration file");
28
+ let workspaceManager = "yarn";
29
+ try {
30
+ workspaceManager = whichWorkspaceManager(cwd);
31
+ } catch (e) {
32
+ console.error("lage requires you to be using a workspace - make sure you are using yarn workspaces, npm workspaces, pnpm workspaces, or rush");
33
+ process.exitCode = 1;
34
+ return;
35
+ }
36
+ const pipeline = {
37
+ build: [
38
+ "^build"
39
+ ],
40
+ test: [
41
+ "build"
42
+ ],
43
+ lint: []
44
+ };
45
+ const lageConfig = {
46
+ pipeline,
47
+ npmClient: workspaceManager === "yarn" ? "yarn" : "npm"
48
+ };
49
+ const lageConfigFile = _path.default.join(cwd, "lage.config.js");
50
+ _fs.default.writeFileSync(lageConfigFile, "module.exports = " + JSON.stringify(lageConfig, null, 2) + ";");
51
+ installLage(cwd, workspaceManager, pipeline);
52
+ console.info(`Lage is initialized! You can now run: ${getBuildCommand(workspaceManager)}`);
53
+ }
54
+ function getBuildCommand(workspaceManager) {
55
+ switch(workspaceManager){
56
+ case "yarn":
57
+ return "yarn lage build";
58
+ case "pnpm":
59
+ return "pnpm run lage build";
60
+ case "rush":
61
+ case "npm":
62
+ return "npm run lage build";
63
+ }
64
+ }
65
+ function whichWorkspaceManager(cwd) {
66
+ const packageJson = readPackageJson(cwd);
67
+ if (_fs.default.existsSync(_path.default.join(cwd, "rush.json"))) {
68
+ return "rush";
69
+ }
70
+ if (_fs.default.existsSync(_path.default.join(cwd, "yarn.lock")) && packageJson.workspaces) {
71
+ return "yarn";
72
+ }
73
+ if (_fs.default.existsSync(_path.default.join(cwd, "pnpm-workspace.yaml"))) {
74
+ return "pnpm";
75
+ }
76
+ if (_fs.default.existsSync(_path.default.join(cwd, "package-lock.json")) && packageJson.workspaces) {
77
+ return "npm";
78
+ }
79
+ throw new Error("not a workspace");
80
+ }
81
+ async function installLage(cwd, workspaceManager, pipeline) {
82
+ const lageVersion = getLageVersion();
83
+ const packageJson = readPackageJson(cwd);
84
+ (_packageJson = packageJson).scripts ?? (_packageJson.scripts = {});
85
+ for (const script of Object.keys(pipeline)){
86
+ packageJson.scripts[script] = `lage ${script}`;
87
+ }
88
+ if (workspaceManager === "rush") {
89
+ packageJson.scripts.lage = `node common/scripts/install-run.js lage@${lageVersion} lage`;
90
+ writePackageJson(cwd, packageJson);
91
+ } else {
92
+ packageJson.scripts.lage = "lage";
93
+ (_packageJson1 = packageJson).devDependencies ?? (_packageJson1.devDependencies = {});
94
+ packageJson.devDependencies.lage = lageVersion;
95
+ writePackageJson(cwd, packageJson);
96
+ await (0, _execa.default)(workspaceManager, [
97
+ "install"
98
+ ], {
99
+ stdio: "inherit"
100
+ });
101
+ }
102
+ }
103
+ function getLageVersion() {
104
+ const lagePackageJsonFile = require.resolve("../../package.json", {
105
+ paths: [
106
+ __dirname
107
+ ]
108
+ });
109
+ const lagePackageJson = JSON.parse(_fs.default.readFileSync(lagePackageJsonFile, "utf-8"));
110
+ return lagePackageJson.version;
111
+ }
112
+ function writePackageJson(cwd, packageJson) {
113
+ const packageJsonFile = _path.default.join(cwd, "package.json");
114
+ _fs.default.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
115
+ }
116
+ function readPackageJson(cwd) {
117
+ const packageJsonFile = _path.default.join(cwd, "package.json");
118
+ return JSON.parse(_fs.default.readFileSync(packageJsonFile, "utf-8"));
119
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ declare const initCommand: Command;
3
+ export { initCommand };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "initCommand", {
6
+ enumerable: true,
7
+ get: ()=>initCommand
8
+ });
9
+ const _commander = require("commander");
10
+ const _addFilterOptionsJs = require("../addFilterOptions.js");
11
+ const _actionJs = require("./action.js");
12
+ const initCommand = new _commander.Command("init");
13
+ (0, _addFilterOptionsJs.addFilterOptions)(initCommand).description("Install lage in a workspace and create a config file").action(_actionJs.initAction);
@@ -67,6 +67,10 @@ Choosing a different reporter while logging (e.g. nice outputs for Azure DevOps)
67
67
 
68
68
  $ lage build test lint --reporter=azureDevOps
69
69
 
70
+ Or combine multiple reporters (e.g. Azure DepOps with VerboseFileLog)
71
+
72
+ $ lage build test lint --reporter azureDevOps --reporter vfl --log-file /my/verbose/log.file
73
+
70
74
  Ignoring files when calculating the scope with --since in addition to files specified in lage.config:
71
75
 
72
76
  $ lage build test lint --since origin/master --ignore "package.json" "yarn.lock" "**/.azure-pipelines/**"
@@ -29,7 +29,7 @@ async function runAction(options, command) {
29
29
  const allowNoTargetRuns = options.allowNoTargetRuns || config.allowNoTargetRuns;
30
30
  // Configure logger
31
31
  const logger = (0, _logger.default)();
32
- (0, _initializeReportersJs.initializeReporters)(logger, {
32
+ const reporters = (0, _initializeReportersJs.initializeReporters)(logger, {
33
33
  ...options,
34
34
  concurrency
35
35
  });
@@ -96,6 +96,9 @@ async function runAction(options, command) {
96
96
  const summary = await scheduler.run(root, targetGraph);
97
97
  await scheduler.cleanup();
98
98
  displaySummaryAndExit(summary, logger.reporters);
99
+ for (const reporter of reporters){
100
+ await reporter.cleanup?.();
101
+ }
99
102
  }
100
103
  function displaySummaryAndExit(summary, reporters) {
101
104
  if (summary.results !== "success") {
@@ -154,5 +154,6 @@ async function watchAction(options, command) {
154
154
  function displaySummary(summary, reporters) {
155
155
  for (const reporter of reporters){
156
156
  reporter.summarize(summary);
157
+ reporter.cleanup?.();
157
158
  }
158
159
  }
@@ -7,4 +7,5 @@ export interface ReporterInitOptions {
7
7
  concurrency: number;
8
8
  logLevel: keyof typeof LogLevel;
9
9
  profile?: boolean | string;
10
+ logFile?: string;
10
11
  }
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@lage-run/cli",
3
- "version": "0.13.2",
3
+ "version": "0.15.0",
4
4
  "description": "Command Line Interface for Lage",
5
5
  "repository": {
6
+ "type": "git",
6
7
  "url": "https://github.com/microsoft/lage"
7
8
  },
9
+ "homepage": "https://microsoft.github.io/lage/",
8
10
  "bin": {
9
11
  "lage": "./bin/lage"
10
12
  },
@@ -18,22 +20,23 @@
18
20
  "lint": "monorepo-scripts lint"
19
21
  },
20
22
  "dependencies": {
21
- "@lage-run/config": "^0.1.3",
23
+ "@lage-run/cache": "^0.5.4",
24
+ "@lage-run/config": "^0.2.0",
22
25
  "@lage-run/find-npm-client": "^0.1.4",
23
- "@lage-run/logger": "^1.2.2",
24
- "@lage-run/scheduler": "^0.11.2",
25
- "@lage-run/scheduler-types": "^0.3.7",
26
- "@lage-run/target-graph": "^0.8.3",
27
- "@lage-run/cache": "^0.5.3",
28
- "@lage-run/reporters": "^1.1.2",
29
- "commander": "^9.4.0",
30
- "workspace-tools": "^0.34.0",
26
+ "@lage-run/logger": "^1.3.0",
27
+ "@lage-run/reporters": "^1.2.0",
28
+ "@lage-run/scheduler": "^0.11.4",
29
+ "@lage-run/scheduler-types": "^0.3.8",
30
+ "@lage-run/target-graph": "^0.8.4",
31
31
  "chokidar": "3.5.3",
32
- "fast-glob": "^3.2.11"
32
+ "commander": "^9.4.0",
33
+ "execa": "5.1.1",
34
+ "fast-glob": "^3.2.11",
35
+ "workspace-tools": "^0.34.0"
33
36
  },
34
37
  "devDependencies": {
35
- "monorepo-scripts": "*",
36
- "@lage-run/monorepo-fixture": "*"
38
+ "@lage-run/monorepo-fixture": "*",
39
+ "monorepo-scripts": "*"
37
40
  },
38
41
  "publishConfig": {
39
42
  "access": "public"