Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Add new info command to output information about local environment #2106

Merged
merged 11 commits into from
Dec 15, 2019
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- [`lerna import`](./commands/import#readme)
- [`lerna link`](./commands/link#readme)
- [`lerna create`](./commands/create#readme)
- [`lerna info`](./commands/info#readme)
jamesgeorge007 marked this conversation as resolved.
Show resolved Hide resolved
- [Concepts](#concepts)
- [Lerna.json](#lernajson)
- [Global Flags](./core/global-options)
Expand Down
28 changes: 28 additions & 0 deletions commands/info/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# `@lerna/info`

> Print local environment information

Install [lerna](https://www.npmjs.com/package/lerna) for access to the `lerna` CLI.

## Usage

The `info` prints local environment information that proves to be useful especially while submitting bug reports.

`lerna info`

```bash
Environment Info:

System:
OS: Linux 4.18 Ubuntu 18.10 (Cosmic Cuttlefish)
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Binaries:
Node: 8.11.4 - /usr/bin/node
Yarn: 1.17.0-0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Browsers:
Chrome: 74.0.3729.157
Firefox: 66.0.5
npmPackages:
lerna: 3.14.1
```
12 changes: 12 additions & 0 deletions commands/info/__tests__/info-command.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

// mocked modules
// const output = require("@lerna/output");
jamesgeorge007 marked this conversation as resolved.
Show resolved Hide resolved
// const collectUpdates = require("@lerna/collect-updates");

// file under test
// const lernaLs = require("@lerna-test/command-runner")(require("../command"));

describe("lerna info", () => {
// ToDo
});
12 changes: 12 additions & 0 deletions commands/info/command.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

/**
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module
*/
exports.command = "info";

exports.describe = "Prints debugging information about the local environment";

exports.handler = function handler(argv) {
return require(".")(argv);
};
26 changes: 26 additions & 0 deletions commands/info/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";

const Command = require("@lerna/command");
const output = require("@lerna/output");
const envinfo = require("envinfo");

module.exports = factory;

function factory(argv) {
return new InfoCommand(argv);
}

class InfoCommand extends Command {
execute() {
jamesgeorge007 marked this conversation as resolved.
Show resolved Hide resolved
output("\n Environment info:");
jamesgeorge007 marked this conversation as resolved.
Show resolved Hide resolved
const info = await envinfo.run({
jamesgeorge007 marked this conversation as resolved.
Show resolved Hide resolved
System: ["OS", "CPU"],
Binaries: ["Node", "Yarn", "npm"],
Utilities: ["Git"],
npmPackages: ["lerna"],
});
output(info);
}
}

module.exports.InfoCommand = InfoCommand;
41 changes: 41 additions & 0 deletions commands/info/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

{
"name": "@lerna/info",
"version": "1.0.0",
"description": "Prints local environnment information",
"keywords": [
"lerna",
"command"
],
"homepage": "https://github.com/lerna/lerna/tree/master/commands/info#readme",
"license": "MIT",
"author": {
"name": "James George",
"url": "https://github.com/jamesgeorge007"
},
"files": [
"command.js",
"index.js"
],
"main": "index.js",
"engines": {
"node": ">= 6.9.0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lerna/lerna.git",
"directory": "commands/info"
},
"scripts": {
"test": "echo \"Run tests from root\" && exit 1"
},
"dependencies": {
"@lerna/command": "file:../../core/command",
"@lerna/output": "file:../../utils/output",
"envinfo": "^7.3.1"
}
}

2 changes: 2 additions & 0 deletions core/lerna/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const createCmd = require("@lerna/create/command");
const diffCmd = require("@lerna/diff/command");
const execCmd = require("@lerna/exec/command");
const importCmd = require("@lerna/import/command");
const infoCmd = require("@lerna/info/command");
const initCmd = require("@lerna/init/command");
const linkCmd = require("@lerna/link/command");
const listCmd = require("@lerna/list/command");
Expand All @@ -35,6 +36,7 @@ function main(argv) {
.command(diffCmd)
.command(execCmd)
.command(importCmd)
.command(infoCmd)
.command(initCmd)
.command(linkCmd)
.command(listCmd)
Expand Down
1 change: 1 addition & 0 deletions core/lerna/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@lerna/diff": "file:../../commands/diff",
"@lerna/exec": "file:../../commands/exec",
"@lerna/import": "file:../../commands/import",
"@lerna/info": "file:../../commands/info",
jamesgeorge007 marked this conversation as resolved.
Show resolved Hide resolved
"@lerna/init": "file:../../commands/init",
"@lerna/link": "file:../../commands/link",
"@lerna/list": "file:../../commands/list",
Expand Down