-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nx): add report function to @nrwl/workspace which lists versions…
… of select packages
- Loading branch information
1 parent
98fc5e0
commit 1d377ea
Showing
8 changed files
with
203 additions
and
8 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,21 @@ | ||
# report | ||
|
||
Reports useful version numbers to copy into the Nx issue template | ||
|
||
## Usage | ||
|
||
```bash | ||
nx report | ||
``` | ||
|
||
Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`. | ||
|
||
## Options | ||
|
||
### help | ||
|
||
Show help | ||
|
||
### version | ||
|
||
Show version number |
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,21 @@ | ||
# report | ||
|
||
Reports useful version numbers to copy into the Nx issue template | ||
|
||
## Usage | ||
|
||
```bash | ||
nx report | ||
``` | ||
|
||
Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`. | ||
|
||
## Options | ||
|
||
### help | ||
|
||
Show help | ||
|
||
### version | ||
|
||
Show version number |
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,21 @@ | ||
# report | ||
|
||
Reports useful version numbers to copy into the Nx issue template | ||
|
||
## Usage | ||
|
||
```bash | ||
nx report | ||
``` | ||
|
||
Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`. | ||
|
||
## Options | ||
|
||
### help | ||
|
||
Show help | ||
|
||
### version | ||
|
||
Show version number |
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,34 @@ | ||
import { packagesWeCareAbout } from '@nrwl/workspace/src/command-line/report'; | ||
import { ensureProject, forEachCli, runCLI } from './utils'; | ||
|
||
const testTimeout = 120000; | ||
|
||
forEachCli('nx', () => { | ||
describe('report', () => { | ||
it( | ||
`should report package versions`, | ||
async () => { | ||
ensureProject(); | ||
|
||
const reportOutput = runCLI('report'); | ||
|
||
packagesWeCareAbout.forEach(p => { | ||
expect(reportOutput).toContain(p); | ||
}); | ||
}, | ||
testTimeout | ||
); | ||
}); | ||
}); | ||
|
||
forEachCli('angular', () => { | ||
describe('report', () => { | ||
it( | ||
`shouldn't do anything at all`, | ||
async () => { | ||
// report is an Nx only command | ||
}, | ||
testTimeout | ||
); | ||
}); | ||
}); |
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
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,53 @@ | ||
import { terminal } from '@angular-devkit/core'; | ||
import { readFileSync } from 'fs'; | ||
import * as path from 'path'; | ||
import { appRootPath } from '../utils/app-root'; | ||
import { output } from './output'; | ||
|
||
export const packagesWeCareAbout = [ | ||
'@nrwl/angular', | ||
'@nrwl/cli', | ||
'@nrwl/cypress', | ||
'@nrwl/eslint-plugin-nx', | ||
'@nrwl/express', | ||
'@nrwl/jest', | ||
'@nrwl/linter', | ||
'@nrwl/nest', | ||
'@nrwl/next', | ||
'@nrwl/node', | ||
'@nrwl/react', | ||
'@nrwl/schematics', | ||
'@nrwl/tao', | ||
'@nrwl/web', | ||
'@nrwl/workspace', | ||
'typescript' | ||
]; | ||
|
||
/** | ||
* Reports relevant version numbers for adding to an Nx issue report | ||
* | ||
* @remarks | ||
* | ||
* Must be run within an Nx workspace | ||
* | ||
*/ | ||
export function report() { | ||
const nodeModulesDir = path.join(appRootPath, 'node_modules'); | ||
const bodyLines = []; | ||
|
||
packagesWeCareAbout.forEach(p => { | ||
let status = 'Not Found'; | ||
try { | ||
const packageJson = JSON.parse( | ||
readFileSync(path.join(nodeModulesDir, p, 'package.json')).toString() | ||
); | ||
status = packageJson.version; | ||
} catch {} | ||
bodyLines.push(`${terminal.green(p)} : ${terminal.bold(status)}`); | ||
}); | ||
|
||
output.log({ | ||
title: 'Report complete - copy this into the issue template', | ||
bodyLines | ||
}); | ||
} |