@oclif/core 2.0.2-beta.5 → 2.0.2-beta.7
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 +1 -5
- package/lib/help/command.js +1 -1
- package/lib/help/docopts.js +2 -1
- package/lib/help/util.d.ts +1 -2
- package/lib/help/util.js +1 -0
- 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,
|
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/help/util.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import * as ejs from 'ejs';
|
|
2
1
|
import { Config as IConfig, HelpOptions, Deprecation } from '../interfaces';
|
|
3
2
|
import { HelpBase } from '.';
|
|
4
3
|
interface HelpBaseDerived {
|
|
5
4
|
new (config: IConfig, opts?: Partial<HelpOptions>): HelpBase;
|
|
6
5
|
}
|
|
7
6
|
export declare function loadHelpClass(config: IConfig): Promise<HelpBaseDerived>;
|
|
8
|
-
export declare function template(context:
|
|
7
|
+
export declare function template(context: any): (t: string) => string;
|
|
9
8
|
export declare function toStandardizedId(commandID: string, config: IConfig): string;
|
|
10
9
|
export declare function toConfiguredId(commandID: string, config: IConfig): string;
|
|
11
10
|
export declare function standardizeIDFromArgv(argv: string[], config: IConfig): string[];
|
package/lib/help/util.js
CHANGED
|
@@ -23,6 +23,7 @@ async function loadHelpClass(config) {
|
|
|
23
23
|
return _1.Help;
|
|
24
24
|
}
|
|
25
25
|
exports.loadHelpClass = loadHelpClass;
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
26
27
|
function template(context) {
|
|
27
28
|
function render(t) {
|
|
28
29
|
return ejs.render(t, context);
|
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,10 +1,11 @@
|
|
|
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.7",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@types/cli-progress": "^3.11.0",
|
|
8
9
|
"ansi-escapes": "^4.3.2",
|
|
9
10
|
"ansi-styles": "^4.3.0",
|
|
10
11
|
"cardinal": "^2.1.1",
|
|
@@ -42,7 +43,6 @@
|
|
|
42
43
|
"@types/chai": "^4.3.4",
|
|
43
44
|
"@types/chai-as-promised": "^7.1.5",
|
|
44
45
|
"@types/clean-stack": "^2.1.1",
|
|
45
|
-
"@types/cli-progress": "^3.11.0",
|
|
46
46
|
"@types/ejs": "^3.1.0",
|
|
47
47
|
"@types/fs-extra": "^9.0.13",
|
|
48
48
|
"@types/indent-string": "^4.0.1",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"lint": "eslint . --ext .ts --config .eslintrc",
|
|
110
110
|
"posttest": "yarn lint",
|
|
111
111
|
"prepack": "yarn run build",
|
|
112
|
-
"test": "mocha \"test/**/*.test.ts\"",
|
|
112
|
+
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
113
113
|
"test:e2e": "mocha \"test/**/*.e2e.ts\" --timeout 1200000",
|
|
114
114
|
"pretest": "yarn build --noEmit && tsc -p test --noEmit --skipLibCheck"
|
|
115
115
|
},
|