forked from lerna/lerna
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): Add new
info
command to output information about local e…
…nvironment (lerna#2106)
- Loading branch information
1 parent
bd19a34
commit 7abfe43
Showing
9 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use strict"; | ||
|
||
jest.mock("envinfo"); | ||
|
||
const path = require("path"); | ||
const envinfo = require("envinfo"); | ||
|
||
envinfo.run.mockResolvedValue("MOCK_ENVINFO"); | ||
|
||
// helper | ||
const output = require("@lerna/output"); | ||
|
||
// file under test | ||
const lernaInfo = require("@lerna-test/command-runner")(require("../command")); | ||
|
||
it("outputs result of envinfo()", async () => { | ||
// project fixture is irrelevant, no actual changes are made | ||
await lernaInfo(path.resolve(__dirname, "../../.."))(); | ||
|
||
expect(envinfo.run).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ | ||
npmPackages: ["lerna"], | ||
}) | ||
); | ||
expect(output.logged()).toMatch("MOCK_ENVINFO"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"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 { | ||
// eslint-disable-next-line | ||
initialize() {} | ||
// eslint-disable-next-line | ||
execute() { | ||
output("\n Environment info:"); | ||
envinfo | ||
.run({ | ||
System: ["OS", "CPU"], | ||
Binaries: ["Node", "Yarn", "npm"], | ||
Utilities: ["Git"], | ||
npmPackages: ["lerna"], | ||
}) | ||
.then(output); | ||
} | ||
} | ||
|
||
module.exports.InfoCommand = InfoCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.