@oclif/core 2.0.2-beta.6 → 2.0.2-beta.8
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.
- package/lib/config/config.js +3 -6
- package/lib/help/command.js +1 -1
- package/lib/help/docopts.js +2 -1
- package/lib/interfaces/parser.d.ts +1 -1
- package/lib/main.js +1 -1
- package/lib/util.d.ts +12 -0
- package/lib/util.js +14 -1
- package/package.json +3 -3
package/lib/config/config.js
CHANGED
|
@@ -698,12 +698,8 @@ async function toCached(c, plugin) {
|
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
-
// v1 commands have args as an array, so we need to normalize it to an object for backwards compatibility
|
|
702
|
-
const normalized = (Array.isArray(c.args) ? (c.args ?? []).reduce((x, y) => {
|
|
703
|
-
return { ...x, [y.name]: y };
|
|
704
|
-
}, {}) : c.args ?? {});
|
|
705
701
|
const args = {};
|
|
706
|
-
for (const [name, arg] of Object.entries(
|
|
702
|
+
for (const [name, arg] of Object.entries((0, util_3.ensureArgObject)(c.args))) {
|
|
707
703
|
args[name] = {
|
|
708
704
|
name,
|
|
709
705
|
description: arg.description,
|
|
@@ -731,7 +727,8 @@ async function toCached(c, plugin) {
|
|
|
731
727
|
flags,
|
|
732
728
|
args,
|
|
733
729
|
};
|
|
734
|
-
|
|
730
|
+
// do not include these properties in manifest
|
|
731
|
+
const ignoreCommandProperties = ['plugin', '_flags', '_enableJsonFlag', '_globalFlags', '_baseFlags'];
|
|
735
732
|
const stdKeys = Object.keys(stdProperties);
|
|
736
733
|
const keysToAdd = Object.keys(c).filter(property => ![...stdKeys, ...ignoreCommandProperties].includes(property));
|
|
737
734
|
const additionalProperties = {};
|
package/lib/help/command.js
CHANGED
|
@@ -31,7 +31,7 @@ class CommandHelp extends formatter_1.HelpFormatter {
|
|
|
31
31
|
v.name = k;
|
|
32
32
|
return v;
|
|
33
33
|
}), f => [!f.char, f.char, f.name]);
|
|
34
|
-
const args = Object.values(cmd.args
|
|
34
|
+
const args = Object.values((0, util_1.ensureArgObject)(cmd.args)).filter(a => !a.hidden);
|
|
35
35
|
const output = (0, util_1.compact)(this.sections().map(({ header, generate }) => {
|
|
36
36
|
const body = generate({ cmd, flags, args }, header);
|
|
37
37
|
// Generate can return a list of sections
|
package/lib/help/docopts.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DocOpts = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
4
5
|
/**
|
|
5
6
|
* DocOpts - See http://docopt.org/.
|
|
6
7
|
*
|
|
@@ -75,7 +76,7 @@ class DocOpts {
|
|
|
75
76
|
toString() {
|
|
76
77
|
const opts = this.cmd.id === '.' || this.cmd.id === '' ? [] : ['<%= command.id %>'];
|
|
77
78
|
if (this.cmd.args) {
|
|
78
|
-
const a = Object.values(this.cmd.args
|
|
79
|
+
const a = Object.values((0, util_1.ensureArgObject)(this.cmd.args)).map(arg => `[${arg.name.toUpperCase()}]`) || [];
|
|
79
80
|
opts.push(...a);
|
|
80
81
|
}
|
|
81
82
|
try {
|
package/lib/main.js
CHANGED
|
@@ -72,7 +72,7 @@ async function run(argv, options) {
|
|
|
72
72
|
// command id.
|
|
73
73
|
if (config.pjson.oclif.default === '.' && id === '.' && argv[0] === '.')
|
|
74
74
|
argvSlice = ['.', ...argvSlice];
|
|
75
|
-
|
|
75
|
+
return config.runCommand(id, argvSlice, cmd);
|
|
76
76
|
}
|
|
77
77
|
exports.run = run;
|
|
78
78
|
function getTsConfigPath(dir, type) {
|
package/lib/util.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Command } from './command';
|
|
2
|
+
import { ArgInput } from './interfaces/parser';
|
|
1
3
|
export declare function pickBy<T extends {
|
|
2
4
|
[s: string]: T[keyof T];
|
|
3
5
|
} | ArrayLike<T[keyof T]>>(obj: T, fn: (i: T[keyof T]) => boolean): Partial<T>;
|
|
@@ -15,4 +17,14 @@ export declare const fileExists: (input: string) => Promise<string>;
|
|
|
15
17
|
export declare function isTruthy(input: string): boolean;
|
|
16
18
|
export declare function isNotFalsy(input: string): boolean;
|
|
17
19
|
export declare function requireJson<T>(...pathParts: string[]): T;
|
|
20
|
+
/**
|
|
21
|
+
* Ensure that the provided args are an object. This is for backwards compatibility with v1 commands which
|
|
22
|
+
* defined args as an array.
|
|
23
|
+
*
|
|
24
|
+
* @param args Either an array of args or an object of args
|
|
25
|
+
* @returns ArgInput
|
|
26
|
+
*/
|
|
27
|
+
export declare function ensureArgObject(args?: any[] | ArgInput | {
|
|
28
|
+
[name: string]: Command.Arg.Cached;
|
|
29
|
+
}): ArgInput;
|
|
18
30
|
export {};
|
package/lib/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireJson = exports.isNotFalsy = exports.isTruthy = exports.fileExists = exports.dirExists = exports.capitalize = exports.sumBy = exports.maxBy = exports.isProd = exports.castArray = exports.sortBy = exports.uniqBy = exports.compact = exports.pickBy = void 0;
|
|
3
|
+
exports.ensureArgObject = exports.requireJson = exports.isNotFalsy = exports.isTruthy = exports.fileExists = exports.dirExists = exports.capitalize = exports.sumBy = exports.maxBy = exports.isProd = exports.castArray = exports.sortBy = exports.uniqBy = exports.compact = exports.pickBy = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
function pickBy(obj, fn) {
|
|
@@ -105,3 +105,16 @@ function requireJson(...pathParts) {
|
|
|
105
105
|
return JSON.parse(fs.readFileSync((0, path_1.join)(...pathParts), 'utf8'));
|
|
106
106
|
}
|
|
107
107
|
exports.requireJson = requireJson;
|
|
108
|
+
/**
|
|
109
|
+
* Ensure that the provided args are an object. This is for backwards compatibility with v1 commands which
|
|
110
|
+
* defined args as an array.
|
|
111
|
+
*
|
|
112
|
+
* @param args Either an array of args or an object of args
|
|
113
|
+
* @returns ArgInput
|
|
114
|
+
*/
|
|
115
|
+
function ensureArgObject(args) {
|
|
116
|
+
return (Array.isArray(args) ? (args ?? []).reduce((x, y) => {
|
|
117
|
+
return { ...x, [y.name]: y };
|
|
118
|
+
}, {}) : args ?? {});
|
|
119
|
+
}
|
|
120
|
+
exports.ensureArgObject = ensureArgObject;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/core",
|
|
3
3
|
"description": "base library for oclif CLIs",
|
|
4
|
-
"version": "2.0.2-beta.
|
|
4
|
+
"version": "2.0.2-beta.8",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@commitlint/config-conventional": "^12.1.4",
|
|
39
39
|
"@oclif/plugin-help": "^5.1.22",
|
|
40
40
|
"@oclif/plugin-plugins": "^2.1.12",
|
|
41
|
-
"@oclif/test": "^2.2.
|
|
41
|
+
"@oclif/test": "^2.2.20",
|
|
42
42
|
"@types/ansi-styles": "^3.2.1",
|
|
43
43
|
"@types/chai": "^4.3.4",
|
|
44
44
|
"@types/chai-as-promised": "^7.1.5",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"globby": "^11.1.0",
|
|
69
69
|
"husky": "6",
|
|
70
70
|
"mocha": "^8.4.0",
|
|
71
|
-
"nock": "^13.
|
|
71
|
+
"nock": "^13.3.0",
|
|
72
72
|
"proxyquire": "^2.1.3",
|
|
73
73
|
"shelljs": "^0.8.5",
|
|
74
74
|
"shx": "^0.3.4",
|