cli: fix build issue and tweak info output format
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -57,7 +57,7 @@ postpack Restores the changes made by the prepack command
|
||||
|
||||
create-github-app Create new GitHub App in your organization (experimental)
|
||||
|
||||
info Outputs versions of all dependencies for debugging purposes
|
||||
info Show helpful information for debugging and reporting bugs
|
||||
help [command] display help for command
|
||||
```
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ export function registerCommands(program: CommanderStatic) {
|
||||
|
||||
program
|
||||
.command('info')
|
||||
.description('Debug info of all dependencies.')
|
||||
.description('Show helpful information for debugging and reporting bugs')
|
||||
.action(lazy(() => import('./info').then(m => m.default)));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,51 +19,28 @@ import os from 'os';
|
||||
import { runPlain } from '../lib/run';
|
||||
import { paths } from '../lib/paths';
|
||||
import { Lockfile } from '../lib/versioning';
|
||||
import path from 'path';
|
||||
|
||||
export default async () => {
|
||||
await new Promise(async () => {
|
||||
const yarnVersion = await runPlain('yarn --version');
|
||||
const npmVersion = await runPlain('npm --version');
|
||||
|
||||
console.log(
|
||||
`Operating System - ${os.type}(${os.release}) - ${os.platform}/${os.arch}`,
|
||||
);
|
||||
|
||||
console.log('\n------------------\n');
|
||||
|
||||
console.log('Node.js environment:\n');
|
||||
console.log(`Node.js - ${process.version}`);
|
||||
console.log(`@backstage/cli- ${cliVersion}`);
|
||||
|
||||
console.log('\n------------------\n');
|
||||
|
||||
console.log('Global environment:\n');
|
||||
console.log(`yarn - ${yarnVersion}`);
|
||||
console.log(`npm - ${npmVersion}`);
|
||||
|
||||
console.log('\n------------------\n');
|
||||
|
||||
console.log('Backstage CLI type :\n');
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
const isLocal = require('fs').existsSync(paths.resolveOwn('./src'));
|
||||
console.log(
|
||||
isLocal
|
||||
? 'CLI is running in backstage repo'
|
||||
: 'CLI is running as a dependency',
|
||||
);
|
||||
|
||||
console.log('\n------------------\n');
|
||||
|
||||
console.log('Backstage deps:\n');
|
||||
console.log(`OS: ${os.type} ${os.release} - ${os.platform}/${os.arch}`);
|
||||
console.log(`node: ${process.version}`);
|
||||
console.log(`yarn: ${yarnVersion}`);
|
||||
console.log(`cli: ${cliVersion} (${isLocal ? 'local' : 'installed'})`);
|
||||
console.log();
|
||||
console.log('Dependencies:');
|
||||
const lockfilePath = paths.resolveTargetRoot('yarn.lock');
|
||||
const lockfile = await Lockfile.load(lockfilePath);
|
||||
const deps = lockfile.keys();
|
||||
|
||||
const deps = [...lockfile.keys()].filter(n => n.startsWith('@backstage/'));
|
||||
const maxLength = Math.max(...deps.map(d => d.length));
|
||||
|
||||
for (const dep of deps) {
|
||||
if (dep.indexOf('@backstage/') !== -1) {
|
||||
console.log(dep, lockfile.get(dep)![0].version);
|
||||
}
|
||||
const versions = new Set(lockfile.get(dep)!.map(i => i.version));
|
||||
console.log(` ${dep.padEnd(maxLength)} ${[...versions].join(', ')}`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user