-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0e8f96
commit 6fa1154
Showing
15 changed files
with
292 additions
and
6 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
import { InfoCommand } from '@lerna-lite/info'; | ||
|
||
/** | ||
* @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 new InfoCommand(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
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,47 @@ | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/) | ||
[![npm](https://img.shields.io/npm/v/@lerna-lite/info.svg?color=forest)](https://www.npmjs.com/package/@lerna-lite/info) | ||
[![npm](https://img.shields.io/npm/dy/@lerna-lite/info?color=forest)](https://www.npmjs.com/package/@lerna-lite/info) | ||
[![Actions Status](https://github.com/ghiscoding/lerna-lite/workflows/CI%20Build/badge.svg)](https://github.com/ghiscoding/lerna-lite/actions) | ||
|
||
# @lerna-lite/info | ||
## (`lerna info`) - Info command 💻 | ||
|
||
Print local environment information | ||
|
||
--- | ||
|
||
## Installation | ||
```sh | ||
# install globally | ||
npm install -g @lerna-lite/cli | ||
|
||
# then use it (see usage below) | ||
lerna info | ||
|
||
# OR use npx | ||
npx lerna info | ||
``` | ||
|
||
## 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,42 @@ | ||
{ | ||
"name": "@lerna-lite/info", | ||
"description": "Lerna-Lite - Prints local environnment information", | ||
"version": "1.0.5", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"/dist" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"build": "tsc --project tsconfig.bundle.json", | ||
"pack-tarball": "npm pack" | ||
}, | ||
"license": "MIT", | ||
"author": "Ghislain B.", | ||
"homepage": "https://github.com/ghiscoding/lerna-lite", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ghiscoding/lerna-lite.git", | ||
"directory": "packages/info" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/ghiscoding/lerna-lite/issues" | ||
}, | ||
"engines": { | ||
"node": ">=14.13.1", | ||
"npm": ">=8.0.0" | ||
}, | ||
"dependencies": { | ||
"@lerna-lite/core": "^1.0.5", | ||
"dedent": "^0.7.0", | ||
"envinfo": "^7.8.1", | ||
"yargs": "^17.4.1" | ||
}, | ||
"devDependencies": { | ||
"@types/envinfo": "^7.8.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,57 @@ | ||
jest.mock('envinfo'); | ||
|
||
const path = require('path'); | ||
const envinfo = require('envinfo'); | ||
|
||
envinfo.run.mockResolvedValue('MOCK_ENVINFO'); | ||
|
||
// mocked modules of @lerna-lite/core | ||
jest.mock('@lerna-lite/core', () => ({ | ||
...jest.requireActual('@lerna-lite/core') as any, // return the other real methods, below we'll mock only 2 of the methods | ||
logOutput: jest.requireActual('../../../core/src/__mocks__/output').logOutput, | ||
})); | ||
|
||
const { logOutput } = require('@lerna-lite/core'); | ||
|
||
// file under test | ||
const lernaInfo = require('@lerna-test/command-runner')(require('../../../cli/src/cli-commands/cli-info-commands')); | ||
import { InfoCommand } from '../index'; | ||
import { factory } from '../info-command'; | ||
|
||
describe('Info Command', () => { | ||
it('outputs result of envinfo() via CLI', async () => { | ||
// project fixture is irrelevant, no actual changes are made | ||
await lernaInfo(path.resolve(__dirname, '../../..'))(); | ||
|
||
expect(envinfo.run).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ | ||
npmPackages: ['lerna'], | ||
}) | ||
); | ||
expect(logOutput.logged()).toMatch('MOCK_ENVINFO'); | ||
}); | ||
|
||
it('outputs result of envinfo() via factory', async () => { | ||
// project fixture is irrelevant, no actual changes are made | ||
await new InfoCommand({}); | ||
|
||
expect(envinfo.run).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ | ||
npmPackages: ['lerna'], | ||
}) | ||
); | ||
expect(logOutput.logged()).toMatch('MOCK_ENVINFO'); | ||
}); | ||
|
||
it('outputs result of envinfo() via InfoCommand class', async () => { | ||
// project fixture is irrelevant, no actual changes are made | ||
await factory({}); | ||
|
||
expect(envinfo.run).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ | ||
npmPackages: ['lerna'], | ||
}) | ||
); | ||
expect(logOutput.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 @@ | ||
export * from './info-command'; |
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,29 @@ | ||
import { Command, logOutput, } from '@lerna-lite/core'; | ||
import envinfo from 'envinfo'; | ||
|
||
export function factory(argv) { | ||
return new InfoCommand(argv); | ||
} | ||
|
||
export class InfoCommand extends Command { | ||
/** command name */ | ||
name = 'info'; | ||
|
||
constructor(argv: any) { | ||
super(argv); | ||
} | ||
|
||
initialize() { } | ||
|
||
execute() { | ||
logOutput('\n Environment info:'); | ||
envinfo | ||
.run({ | ||
System: ['OS', 'CPU'], | ||
Binaries: ['Node', 'Yarn', 'npm'], | ||
Utilities: ['Git'], | ||
npmPackages: ['lerna'], | ||
}) | ||
.then(logOutput); | ||
} | ||
} |
Oops, something went wrong.