@oclif/plugin-version 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,13 @@
1
- import { Command } from '@oclif/core';
2
- export interface VersionDetail {
3
- cliVersion: string;
4
- architecture: string;
5
- nodeVersion: string;
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ export type VersionDetail = Omit<Interfaces.VersionDetails, 'pluginVersions'> & {
6
3
  pluginVersions?: string[];
7
- osVersion?: string;
8
- shell?: string;
9
- rootPath?: string;
10
- }
4
+ };
11
5
  export default class Version extends Command {
12
6
  static enableJsonFlag: boolean;
13
7
  static flags: {
14
- verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ verbose: Interfaces.BooleanFlag<boolean>;
15
9
  };
16
10
  run(): Promise<VersionDetail>;
11
+ private formatPlugins;
17
12
  private getFriendlyName;
18
13
  }
@@ -1,40 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
3
4
  const core_1 = require("@oclif/core");
4
5
  // eslint-disable-next-line unicorn/prefer-node-protocol
5
6
  const os_1 = require("os");
6
7
  class Version extends core_1.Command {
7
8
  async run() {
9
+ var _a, _b;
8
10
  const { flags } = await this.parse(Version);
9
- const [cliVersion, architecture, nodeVersion] = this.config.userAgent.split(' ');
10
- const versionDetail = { cliVersion, architecture, nodeVersion };
11
+ const _c = this.config.versionDetails, { pluginVersions } = _c, theRest = tslib_1.__rest(_c, ["pluginVersions"]);
12
+ const versionDetail = Object.assign({}, theRest);
11
13
  let output = `${this.config.userAgent}`;
12
14
  if (flags.verbose) {
13
- const pluginVersions = [];
14
- for (const plugin of this.config.plugins.sort((a, b) => a.name > b.name ? 1 : -1)) {
15
- if (this.config.name !== plugin.name) {
16
- pluginVersions.push(`${this.getFriendlyName(plugin.name)} ${plugin.version} (${plugin.type}) ${plugin.type === 'link' ? plugin.root : ''}`.trim());
17
- }
18
- }
19
- const osVersion = `${(0, os_1.type)()} ${(0, os_1.release)()}`;
20
- versionDetail.pluginVersions = pluginVersions;
21
- versionDetail.osVersion = osVersion;
22
- versionDetail.shell = this.config.shell;
23
- versionDetail.rootPath = this.config.root;
15
+ versionDetail.pluginVersions = this.formatPlugins(pluginVersions !== null && pluginVersions !== void 0 ? pluginVersions : {});
16
+ (_a = versionDetail.shell) !== null && _a !== void 0 ? _a : (versionDetail.shell = 'unknown');
24
17
  output = ` CLI Version:
25
- \t${cliVersion}
18
+ \t${versionDetail.cliVersion}
26
19
 
27
20
  Architecture:
28
- \t${architecture}
21
+ \t${versionDetail.architecture}
29
22
 
30
23
  Node Version:
31
- \t${nodeVersion}
24
+ \t${versionDetail.nodeVersion}
32
25
 
33
26
  Plugin Version:
34
- \t${pluginVersions.join(`${os_1.EOL}\t`)}
27
+ \t${flags.verbose ? ((_b = versionDetail.pluginVersions) !== null && _b !== void 0 ? _b : []).join(os_1.EOL + '\t') : ''}
35
28
 
36
29
  OS and Version:
37
- \t${osVersion}
30
+ \t${versionDetail.osVersion}
38
31
 
39
32
  Shell:
40
33
  \t${versionDetail.shell}
@@ -44,7 +37,19 @@ class Version extends core_1.Command {
44
37
  `;
45
38
  }
46
39
  this.log(output);
47
- return versionDetail;
40
+ return flags.verbose ?
41
+ versionDetail :
42
+ {
43
+ cliVersion: versionDetail.cliVersion,
44
+ architecture: versionDetail.architecture,
45
+ nodeVersion: versionDetail.nodeVersion,
46
+ };
47
+ }
48
+ formatPlugins(plugins) {
49
+ return Object.entries(plugins)
50
+ .map(([name, plugin]) => (Object.assign({ name }, plugin)))
51
+ .sort((a, b) => (a.name > b.name ? 1 : -1))
52
+ .map(plugin => `${this.getFriendlyName(plugin.name)} ${plugin.version} (${plugin.type}) ${plugin.type === 'link' ? plugin.root : ''}`.trim());
48
53
  }
49
54
  getFriendlyName(name) {
50
55
  const scope = this.config.pjson.oclif.scope;
@@ -1 +1 @@
1
- {"version":"1.2.1","commands":{"version":{"id":"version","strict":true,"pluginName":"@oclif/plugin-version","pluginAlias":"@oclif/plugin-version","pluginType":"core","aliases":[],"flags":{"json":{"name":"json","type":"boolean","description":"Format output as json.","helpGroup":"GLOBAL","allowNo":false},"verbose":{"name":"verbose","type":"boolean","summary":"Show additional information about the CLI.","description":"Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.","allowNo":false}},"args":[]}}}
1
+ {"version":"1.3.0","commands":{"version":{"id":"version","strict":true,"pluginName":"@oclif/plugin-version","pluginAlias":"@oclif/plugin-version","pluginType":"core","aliases":[],"flags":{"json":{"name":"json","type":"boolean","description":"Format output as json.","helpGroup":"GLOBAL","allowNo":false},"verbose":{"name":"verbose","type":"boolean","summary":"Show additional information about the CLI.","description":"Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.","allowNo":false}},"args":[]}}}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@oclif/plugin-version",
3
3
  "description": "A command that shows the CLI version",
4
- "version": "1.2.1",
4
+ "version": "1.3.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/plugin-version/issues",
7
7
  "dependencies": {
8
- "@oclif/core": "^2.0.3"
8
+ "@oclif/core": "^2.6.3"
9
9
  },
10
10
  "devDependencies": {
11
11
  "@commitlint/config-conventional": "^12.1.4",
12
12
  "@oclif/plugin-help": "5.1.12",
13
- "@oclif/test": "^2.1.1",
13
+ "@oclif/test": "^2.3.10",
14
14
  "@types/chai": "^4.3.1",
15
15
  "@types/mocha": "^8.0.0",
16
16
  "@types/node": "^16",
@@ -19,6 +19,7 @@
19
19
  "eslint": "^7.3.1",
20
20
  "eslint-config-oclif": "^4",
21
21
  "eslint-config-oclif-typescript": "^1.0.2",
22
+ "fancy-test": "^2.0.13",
22
23
  "husky": "6",
23
24
  "mocha": "^8.2.1",
24
25
  "oclif": "^3.4.6",