Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oclif/plugin-commands

Package Overview
Dependencies
Maintainers
2
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/plugin-commands - npm Package Compare versions

Comparing version 2.2.28 to 3.0.1

oclif.lock

24

lib/commands/commands.d.ts

@@ -6,17 +6,17 @@ import { Command } from '@oclif/core';

static flags: {
columns: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
sort: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
filter: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
csv: import("@oclif/core/lib/interfaces").Flag<boolean>;
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
extended: import("@oclif/core/lib/interfaces").Flag<boolean>;
'no-truncate': import("@oclif/core/lib/interfaces").Flag<boolean>;
'no-header': import("@oclif/core/lib/interfaces").Flag<boolean>;
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
hidden: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
tree: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
columns: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined>;
csv: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
extended: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
filter: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined>;
'no-header': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
'no-truncate': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined>;
sort: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined>;
help: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<void>;
hidden: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
tree: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
};
run(): Promise<unknown[] | import("@oclif/core/lib/cli-ux/styled/tree").Tree | undefined>;
run(): Promise<unknown[] | import("@oclif/core/lib/cli-ux/styled/tree.js").Tree | undefined>;
private getCommands;
private removeCycles;
}

@@ -1,8 +0,17 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const _ = require("lodash");
const os_1 = require("os");
const tree_1 = require("../utils/tree");
class Commands extends core_1.Command {
import { Command, Flags, toConfiguredId, ux } from '@oclif/core';
import pickBy from 'lodash.pickby';
import sortBy from 'lodash.sortby';
import template from 'lodash.template';
import uniqBy from 'lodash.uniqby';
import { EOL } from 'node:os';
import createCommandTree from '../utils/tree.js';
export default class Commands extends Command {
static description = 'list all the commands';
static enableJsonFlag = true;
static flags = {
help: Flags.help({ char: 'h' }),
hidden: Flags.boolean({ description: 'show hidden commands' }),
tree: Flags.boolean({ description: 'show tree of commands' }),
...ux.table.flags(),
};
async run() {

@@ -12,11 +21,13 @@ const { flags } = await this.parse(Commands);

if (!flags.hidden) {
commands = commands.filter(c => !c.hidden);
commands = commands.filter((c) => !c.hidden);
}
const config = this.config;
commands = _.sortBy(commands, 'id').map(command => {
const { config } = this;
commands = sortBy(commands, 'id').map((command) => {
// Template supported fields.
command.description = (typeof command.description === 'string' && _.template(command.description)({ command, config })) || undefined;
command.summary = (typeof command.summary === 'string' && _.template(command.summary)({ command, config })) || undefined;
command.usage = (typeof command.usage === 'string' && _.template(command.usage)({ command, config })) || undefined;
command.id = (0, core_1.toConfiguredId)(command.id, this.config);
command.description =
(typeof command.description === 'string' && template(command.description)({ command, config })) || undefined;
command.summary =
(typeof command.summary === 'string' && template(command.summary)({ command, config })) || undefined;
command.usage = (typeof command.usage === 'string' && template(command.usage)({ command, config })) || undefined;
command.id = toConfiguredId(command.id, config);
return command;

@@ -26,4 +37,3 @@ });

const formatted = await Promise.all(commands.map(async (cmd) => {
// @ts-expect-error
let commandClass = {};
let commandClass;
try {

@@ -35,10 +45,10 @@ commandClass = await cmd.load();

}
const obj = Object.assign(Object.assign({}, cmd), commandClass);
const obj = { ...cmd, ...commandClass };
// Load all properties on all extending classes.
while (commandClass !== undefined) {
commandClass = Object.getPrototypeOf(commandClass) || undefined;
commandClass = Object.getPrototypeOf(commandClass) ?? undefined;
// ES2022 will return all unset static properties on the prototype as undefined. This is different from ES2021
// which only returns the static properties that are set by defaults. In order to prevent
// Object.assign from overwriting the properties on the object, we need to filter out the undefined values.
Object.assign(obj, _.pickBy(commandClass, v => v !== undefined));
Object.assign(obj, pickBy(commandClass, (v) => v !== undefined));
}

@@ -50,6 +60,6 @@ // The plugin property on the loaded class contains a LOT of information including all the commands again. Remove it.

}));
return _.uniqBy(formatted, 'id');
return uniqBy(formatted, 'id');
}
if (flags.tree) {
const tree = (0, tree_1.default)(commands, this.config.topicSeparator);
const tree = createCommandTree(commands, config.topicSeparator);
if (!this.jsonEnabled()) {

@@ -60,20 +70,19 @@ tree.display();

}
core_1.ux.table(commands.map(command => {
ux.table(commands.map((command) => {
// Massage some fields so it looks good in the table
command.description = (command.description || '').split(os_1.EOL)[0];
command.summary = (command.summary || (command.description || '').split(os_1.EOL)[0]);
command.description = (command.description ?? '').split(EOL)[0];
command.summary = command.summary ?? (command.description ?? '').split(EOL)[0];
command.hidden = Boolean(command.hidden);
command.usage = (command.usage || '');
command.usage ??= '';
return command;
}), {
id: {
header: 'Command',
},
summary: {},
description: {
extended: true,
},
usage: {
hidden: {
extended: true,
},
id: {
header: 'Command',
},
pluginName: {

@@ -87,6 +96,11 @@ extended: true,

},
hidden: {
summary: {},
usage: {
extended: true,
},
}, Object.assign({}, flags));
}, {
// to-do: investigate this oclif/core error when printLine is enabled
// printLine: this.log,
...flags, // parsed flags
});
}

@@ -104,6 +118,5 @@ getCommands() {

const dictionary = obj;
if (seenObjects.has(dictionary)) {
// Seen, return undefined to remove.
return undefined;
}
// Seen, return undefined to remove.
if (seenObjects.has(dictionary))
return;
seenObjects.set(dictionary, undefined);

@@ -130,5 +143,1 @@ for (const key in dictionary) {

}
exports.default = Commands;
Commands.description = 'list all the commands';
Commands.enableJsonFlag = true;
Commands.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), hidden: core_1.Flags.boolean({ description: 'show hidden commands' }), tree: core_1.Flags.boolean({ description: 'show tree of commands' }) }, core_1.ux.table.flags());

@@ -1,3 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {};
export default {};
import { Command } from '@oclif/core';
import { Tree } from '@oclif/core/lib/cli-ux/styled/tree';
declare const createCommandTree: (commands: Command.Loadable[], topicSeparator?: string) => Tree;
declare const createCommandTree: (commands: Command.Loadable[], topicSeparator?: string) => import("@oclif/core/lib/cli-ux/styled/tree.js").Tree;
export default createCommandTree;

@@ -1,4 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
import { ux } from '@oclif/core';
const addNodes = (tree, commandParts) => {

@@ -20,9 +18,9 @@ const existingNode = tree.search(commandParts[0]);

const createCommandTree = (commands, topicSeparator = ':') => {
const tree = core_1.ux.tree();
commands.forEach(command => {
const tree = ux.tree();
for (const command of commands) {
const commandParts = command.id.split(topicSeparator);
addNodes(tree, commandParts);
});
}
return tree;
};
exports.default = createCommandTree;
export default createCommandTree;
{
"version": "2.2.28",
"commands": {
"commands": {
"id": "commands",
"aliases": [],
"args": {},
"description": "list all the commands",
"strict": true,
"pluginName": "@oclif/plugin-commands",
"pluginAlias": "@oclif/plugin-commands",
"pluginType": "core",
"aliases": [],
"flags": {
"json": {
"name": "json",
"type": "boolean",
"description": "Format output as json.",
"helpGroup": "GLOBAL",
"allowNo": false
"name": "json",
"allowNo": false,
"type": "boolean"
},
"help": {
"name": "help",
"type": "boolean",
"char": "h",
"description": "Show CLI help.",
"allowNo": false
"name": "help",
"allowNo": false,
"type": "boolean"
},
"hidden": {
"description": "show hidden commands",
"name": "hidden",
"type": "boolean",
"description": "show hidden commands",
"allowNo": false
"allowNo": false,
"type": "boolean"
},
"tree": {
"description": "show tree of commands",
"name": "tree",
"type": "boolean",
"description": "show tree of commands",
"allowNo": false
"allowNo": false,
"type": "boolean"
},
"columns": {
"name": "columns",
"type": "option",
"description": "only show provided columns (comma-separated)",
"multiple": false,
"exclusive": [
"extended"
]
],
"name": "columns",
"hasDynamicHelp": false,
"multiple": false,
"type": "option"
},
"sort": {
"name": "sort",
"type": "option",
"description": "property to sort by (prepend '-' for descending)",
"multiple": false
},
"filter": {
"name": "filter",
"type": "option",
"description": "filter property by partial string matching, ex: name=foo",
"multiple": false
},
"csv": {
"name": "csv",
"type": "boolean",
"description": "output is csv format [alias: --output=csv]",
"allowNo": false,
"exclusive": [
"no-truncate"
]
},
"output": {
"name": "output",
"type": "option",
"description": "output in a more machine friendly format",
"multiple": false,
"options": [
"csv",
"json",
"yaml"
],
"exclusive": [
"no-truncate",
"csv"
]
"name": "csv",
"allowNo": false,
"type": "boolean"
},
"extended": {
"name": "extended",
"type": "boolean",
"char": "x",
"description": "show extra columns",
"allowNo": false,
"exclusive": [
"columns"
]
],
"name": "extended",
"allowNo": false,
"type": "boolean"
},
"filter": {
"description": "filter property by partial string matching, ex: name=foo",
"name": "filter",
"hasDynamicHelp": false,
"multiple": false,
"type": "option"
},
"no-header": {
"description": "hide table header from output",
"exclusive": [
"csv"
],
"name": "no-header",
"allowNo": false,
"type": "boolean"
},
"no-truncate": {
"name": "no-truncate",
"type": "boolean",
"description": "do not truncate output to fit screen",
"allowNo": false,
"exclusive": [
"csv"
]
],
"name": "no-truncate",
"allowNo": false,
"type": "boolean"
},
"no-header": {
"name": "no-header",
"type": "boolean",
"description": "hide table header from output",
"allowNo": false,
"output": {
"description": "output in a more machine friendly format",
"exclusive": [
"no-truncate",
"csv"
]
],
"name": "output",
"hasDynamicHelp": false,
"multiple": false,
"options": [
"csv",
"json",
"yaml"
],
"type": "option"
},
"sort": {
"description": "property to sort by (prepend '-' for descending)",
"name": "sort",
"hasDynamicHelp": false,
"multiple": false,
"type": "option"
}
},
"args": {}
"hasDynamicHelp": false,
"id": "commands",
"pluginAlias": "@oclif/plugin-commands",
"pluginName": "@oclif/plugin-commands",
"pluginType": "core",
"strict": true,
"enableJsonFlag": true,
"isESM": true,
"relativePath": [
"lib",
"commands",
"commands.js"
],
"aliasPermutations": [],
"permutations": [
"commands"
]
}
}
},
"version": "3.0.1"
}
{
"name": "@oclif/plugin-commands",
"description": "plugin to show the list of all the commands",
"version": "2.2.28",
"version": "3.0.1",
"author": "Salesforce",
"bugs": "https://github.com/oclif/plugin-commands/issues",
"dependencies": {
"@oclif/core": "^2.15.0",
"lodash": "^4.17.11"
"@oclif/core": "^3.0.9",
"lodash.pickby": "^4.6.0",
"lodash.sortby": "^4.7.0",
"lodash.template": "^4.5.0",
"lodash.uniqby": "^4.7.0"
},
"devDependencies": {
"@commitlint/config-conventional": "^17.7.0",
"@oclif/plugin-help": "^5.2.20",
"@oclif/test": "^2.5.6",
"@oclif/prettier-config": "^0.2.1",
"@oclif/test": "^3.0.2",
"@types/chai": "^4.3.6",
"@types/lodash": "^4.14.199",
"@types/mocha": "^8.0.0",
"@types/lodash.pickby": "^4.6.7",
"@types/lodash.sortby": "^4.7.7",
"@types/lodash.template": "^4.5.1",
"@types/lodash.uniqby": "^4.7.7",
"@types/mocha": "^10.0.2",
"@types/nock": "^11.1.0",
"@types/node": "^14.18.63",
"@types/node": "^18",
"chai": "^4.3.10",
"eslint": "^7.3.1",
"eslint-config-oclif": "^3.1.0",
"eslint-config-oclif-typescript": "^0.2.0",
"commitlint": "^17.7.2",
"eslint": "^8.51.0",
"eslint-config-oclif": "^5.0.0",
"eslint-config-oclif-typescript": "^3.0.5",
"eslint-config-prettier": "^9.0.0",
"globby": "^11",
"mocha": "^8",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"mocha": "^10.2.0",
"nock": "^13.3.3",
"nyc": "^15.1.0",
"oclif": "^3.17.2",
"oclif": "^4.0.2",
"prettier": "^3.0.3",
"shx": "^0.3.3",
"ts-node": "^9.1.1",
"tslib": "^2.6.2",
"typescript": "4.4.3"
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"engines": {
"node": ">=12.0.0"
"node": ">=18.0.0"
},
"exports": "./lib/index.js",
"files": [
"/lib",
"/oclif.manifest.json",
"/yarn.lock"
"/yarn.lock",
"/oclif.lock"
],

@@ -51,15 +65,18 @@ "homepage": "https://github.com/oclif/plugin-commands",

"@oclif/plugin-help"
]
],
"flexibleTaxonomy": true
},
"repository": "oclif/plugin-commands",
"scripts": {
"lint": "eslint . --ext .ts --config .eslintrc",
"build": "shx rm -rf lib && tsc",
"lint": "eslint . --ext .ts",
"postpack": "shx rm -f oclif.manifest.json oclif.lock",
"posttest": "yarn lint",
"prepack": "shx rm -rf lib && tsc && oclif lock && oclif manifest . && oclif readme",
"prepare": "husky install",
"pretest": "yarn build && tsc -p test --noEmit",
"test": "mocha \"test/**/*.test.ts\"",
"posttest": "yarn lint",
"prepack": "shx rm -rf lib && tsc && oclif manifest . && oclif readme",
"postpack": "shx rm -f oclif.manifest.json",
"version": "oclif readme && git add README.md",
"build": "shx rm -rf lib && tsc"
}
}
"version": "oclif readme && git add README.md"
},
"type": "module"
}

@@ -1,3 +0,2 @@

@oclif/plugin-commands
======================
# @oclif/plugin-commands

@@ -7,4 +6,2 @@ plugin to show the list of all the commands

[![Version](https://img.shields.io/npm/v/@oclif/plugin-commands.svg)](https://npmjs.org/package/@oclif/plugin-commands)
[![CircleCI](https://circleci.com/gh/oclif/plugin-commands/tree/main.svg?style=shield)](https://circleci.com/gh/oclif/plugin-commands/tree/main)
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/oclif/plugin-commands?branch=main&svg=true)](https://ci.appveyor.com/project/oclif/plugin-commands/branch/main)
[![Downloads/week](https://img.shields.io/npm/dw/@oclif/plugin-commands.svg)](https://npmjs.org/package/@oclif/plugin-commands)

@@ -14,6 +11,9 @@ [![License](https://img.shields.io/npm/l/@oclif/plugin-commands.svg)](https://github.com/oclif/plugin-commands/blob/main/package.json)

<!-- toc -->
* [@oclif/plugin-commands](#oclifplugin-commands)
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->

@@ -25,3 +25,3 @@ ```sh-session

$ oclif-example (--version)
@oclif/plugin-commands/2.2.28 linux-x64 node-v18.18.0
@oclif/plugin-commands/3.0.1 linux-x64 node-v18.18.0
$ oclif-example --help [COMMAND]

@@ -33,3 +33,5 @@ USAGE

<!-- usagestop -->
# Commands
<!-- commands -->

@@ -44,4 +46,4 @@ * [`oclif-example commands`](#oclif-example-commands)

USAGE
$ oclif-example commands [--json] [-h] [--hidden] [--tree] [--columns <value> | -x] [--sort <value>]
[--filter <value>] [--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
$ oclif-example commands [--json] [-h] [--hidden] [--tree] [--columns <value> | -x] [--filter <value>]
[--no-header | [--csv | --no-truncate]] [--output csv|json|yaml | | ] [--sort <value>]

@@ -69,3 +71,3 @@ FLAGS

_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v2.2.28/src/commands/commands.ts)_
_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v3.0.1/src/commands/commands.ts)_
<!-- commandsstop -->
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc