@oclif/core 1.0.10 → 1.1.2
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/CHANGELOG.md +23 -0
- package/README.md +11 -6
- package/lib/config/config.js +5 -4
- package/lib/errors/errors/cli.d.ts +2 -2
- package/lib/errors/errors/cli.js +9 -13
- package/lib/help/util.js +2 -2
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.2](https://github.com/oclif/core/compare/v1.1.1...v1.1.2) (2022-01-10)
|
|
6
|
+
|
|
7
|
+
### [1.1.1](https://github.com/oclif/core/compare/v1.1.0...v1.1.1) (2022-01-06)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* regenerate yarn.lock ([#340](https://github.com/oclif/core/issues/340)) ([75bf208](https://github.com/oclif/core/commit/75bf20819f2af574004cb7fe698938b51c6f2e44))
|
|
13
|
+
|
|
14
|
+
## [1.1.0](https://github.com/oclif/core/compare/v1.0.11...v1.1.0) (2022-01-05)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add integration tests ([#339](https://github.com/oclif/core/issues/339)) ([2159c0b](https://github.com/oclif/core/commit/2159c0b970a0090f8bf21ff59e63dea1e788b5f9))
|
|
20
|
+
|
|
21
|
+
### [1.0.11](https://github.com/oclif/core/compare/v1.0.10...v1.0.11) (2021-12-17)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* update imports in errors/cli.ts ([#325](https://github.com/oclif/core/issues/325)) ([b3d6e9b](https://github.com/oclif/core/commit/b3d6e9bf34928ac59486807576a2ee2643b22464))
|
|
27
|
+
|
|
5
28
|
### [1.0.10](https://github.com/oclif/core/compare/v1.0.9...v1.0.10) (2021-12-08)
|
|
6
29
|
|
|
7
30
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@oclif/core
|
|
2
|
-
|
|
2
|
+
===========
|
|
3
3
|
|
|
4
4
|
base library for oclif CLIs
|
|
5
5
|
|
|
@@ -9,6 +9,11 @@ base library for oclif CLIs
|
|
|
9
9
|
[](https://github.com/oclif/core/blob/main/package.json)
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
Migrating
|
|
13
|
+
=====
|
|
14
|
+
|
|
15
|
+
If you're migrating from the old oclif libraries (`@oclif/config`, `@oclif/command`, `@oclif/error`, `@oclif/parser`), see the [migration guide](./MIGRATION.md).
|
|
16
|
+
|
|
12
17
|
Usage
|
|
13
18
|
=====
|
|
14
19
|
|
|
@@ -19,21 +24,21 @@ Without the generator, you can create a simple CLI like this:
|
|
|
19
24
|
#!/usr/bin/env ts-node
|
|
20
25
|
|
|
21
26
|
import * as fs from 'fs'
|
|
22
|
-
import {Command,
|
|
27
|
+
import {Command, Flags} from '@oclif/core'
|
|
23
28
|
|
|
24
29
|
class LS extends Command {
|
|
25
30
|
static flags = {
|
|
26
|
-
version:
|
|
27
|
-
help:
|
|
31
|
+
version: Flags.version(),
|
|
32
|
+
help: Flags.help(),
|
|
28
33
|
// run with --dir= or -d=
|
|
29
|
-
dir:
|
|
34
|
+
dir: Flags.string({
|
|
30
35
|
char: 'd',
|
|
31
36
|
default: process.cwd(),
|
|
32
37
|
}),
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
async run() {
|
|
36
|
-
const {flags} = this.parse(LS)
|
|
41
|
+
const {flags} = await this.parse(LS)
|
|
37
42
|
let files = fs.readdirSync(flags.dir)
|
|
38
43
|
for (let f of files) {
|
|
39
44
|
this.log(f)
|
package/lib/config/config.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toCached = exports.Config = void 0;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
|
-
const
|
|
5
|
+
const ejs = require("ejs");
|
|
6
6
|
const os = require("os");
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const url_1 = require("url");
|
|
@@ -304,7 +304,7 @@ class Config {
|
|
|
304
304
|
get commandIDs() {
|
|
305
305
|
if (this._commandIDs)
|
|
306
306
|
return this._commandIDs;
|
|
307
|
-
const ids =
|
|
307
|
+
const ids = this.commands.flatMap(c => [c.id, ...c.aliases]);
|
|
308
308
|
this._commandIDs = (0, util_3.uniq)(ids);
|
|
309
309
|
return this._commandIDs;
|
|
310
310
|
}
|
|
@@ -338,12 +338,13 @@ class Config {
|
|
|
338
338
|
return this._topics;
|
|
339
339
|
}
|
|
340
340
|
s3Key(type, ext, options = {}) {
|
|
341
|
+
var _a;
|
|
341
342
|
if (typeof ext === 'object')
|
|
342
343
|
options = ext;
|
|
343
344
|
else if (ext)
|
|
344
345
|
options.ext = ext;
|
|
345
|
-
const
|
|
346
|
-
return
|
|
346
|
+
const template = (_a = this.pjson.oclif.update.s3.templates[options.platform ? 'target' : 'vanilla'][type]) !== null && _a !== void 0 ? _a : '';
|
|
347
|
+
return ejs.render(template, { ...this, ...options });
|
|
347
348
|
}
|
|
348
349
|
s3Url(key) {
|
|
349
350
|
const host = this.pjson.oclif.update.s3.host;
|
|
@@ -17,11 +17,11 @@ export declare class CLIError extends Error implements OclifError {
|
|
|
17
17
|
* @return {string} returns a string representing the dispay of the error
|
|
18
18
|
*/
|
|
19
19
|
render(): string;
|
|
20
|
-
get bang(): string;
|
|
20
|
+
get bang(): string | undefined;
|
|
21
21
|
}
|
|
22
22
|
export declare namespace CLIError {
|
|
23
23
|
class Warn extends CLIError {
|
|
24
24
|
constructor(err: string | Error);
|
|
25
|
-
get bang(): string;
|
|
25
|
+
get bang(): string | undefined;
|
|
26
26
|
}
|
|
27
27
|
}
|
package/lib/errors/errors/cli.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// tslint:disable no-implicit-dependencies
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.CLIError = exports.addOclifExitCode = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const indent = require("indent-string");
|
|
6
|
+
const cs = require("clean-stack");
|
|
7
|
+
const wrap = require("wrap-ansi");
|
|
8
|
+
const screen = require("../../screen");
|
|
5
9
|
const config_1 = require("../config");
|
|
6
10
|
/**
|
|
7
11
|
* properties specific to internal oclif error handling
|
|
@@ -22,8 +26,7 @@ class CLIError extends Error {
|
|
|
22
26
|
this.code = options.code;
|
|
23
27
|
}
|
|
24
28
|
get stack() {
|
|
25
|
-
|
|
26
|
-
return clean(super.stack, { pretty: true });
|
|
29
|
+
return cs(super.stack, { pretty: true });
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
32
|
* @deprecated `render` Errors display should be handled by display function, like pretty-print
|
|
@@ -33,23 +36,18 @@ class CLIError extends Error {
|
|
|
33
36
|
if (config_1.config.debug) {
|
|
34
37
|
return this.stack;
|
|
35
38
|
}
|
|
36
|
-
const wrap = require('wrap-ansi');
|
|
37
|
-
const indent = require('indent-string');
|
|
38
39
|
let output = `${this.name}: ${this.message}`;
|
|
39
|
-
|
|
40
|
-
output = wrap(output, require('../screen').errtermwidth - 6, { trim: false, hard: true });
|
|
40
|
+
output = wrap(output, screen.errtermwidth - 6, { trim: false, hard: true });
|
|
41
41
|
output = indent(output, 3);
|
|
42
42
|
output = indent(output, 1, { indent: this.bang, includeEmptyLines: true });
|
|
43
43
|
output = indent(output, 1);
|
|
44
44
|
return output;
|
|
45
45
|
}
|
|
46
46
|
get bang() {
|
|
47
|
-
let red = ((s) => s);
|
|
48
47
|
try {
|
|
49
|
-
red
|
|
48
|
+
return chalk.red(process.platform === 'win32' ? '»' : '›');
|
|
50
49
|
}
|
|
51
50
|
catch { }
|
|
52
|
-
return red(process.platform === 'win32' ? '»' : '›');
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
exports.CLIError = CLIError;
|
|
@@ -60,12 +58,10 @@ exports.CLIError = CLIError;
|
|
|
60
58
|
this.name = 'Warning';
|
|
61
59
|
}
|
|
62
60
|
get bang() {
|
|
63
|
-
let yellow = ((s) => s);
|
|
64
61
|
try {
|
|
65
|
-
yellow
|
|
62
|
+
return chalk.yellow(process.platform === 'win32' ? '»' : '›');
|
|
66
63
|
}
|
|
67
64
|
catch { }
|
|
68
|
-
return yellow(process.platform === 'win32' ? '»' : '›');
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
67
|
CLIError.Warn = Warn;
|
package/lib/help/util.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.standardizeIDFromArgv = exports.toConfiguredId = exports.toStandardizedId = exports.template = exports.loadHelpClass = void 0;
|
|
4
|
-
const
|
|
4
|
+
const ejs = require("ejs");
|
|
5
5
|
const _1 = require(".");
|
|
6
6
|
const module_loader_1 = require("../module-loader");
|
|
7
7
|
function extractClass(exported) {
|
|
@@ -24,7 +24,7 @@ async function loadHelpClass(config) {
|
|
|
24
24
|
exports.loadHelpClass = loadHelpClass;
|
|
25
25
|
function template(context) {
|
|
26
26
|
function render(t) {
|
|
27
|
-
return
|
|
27
|
+
return ejs.render(t, context);
|
|
28
28
|
}
|
|
29
29
|
return render;
|
|
30
30
|
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/core",
|
|
3
3
|
"description": "base library for oclif CLIs",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@oclif/linewrap": "^1.0.0",
|
|
9
9
|
"chalk": "^4.1.2",
|
|
10
10
|
"clean-stack": "^3.0.1",
|
|
11
|
-
"cli-ux": "6.0.
|
|
11
|
+
"cli-ux": "^6.0.6",
|
|
12
12
|
"debug": "^4.3.3",
|
|
13
|
+
"ejs": "^3.1.6",
|
|
13
14
|
"fs-extra": "^9.1.0",
|
|
14
15
|
"get-package-type": "^0.1.0",
|
|
15
16
|
"globby": "^11.0.4",
|
|
16
17
|
"indent-string": "^4.0.0",
|
|
17
18
|
"is-wsl": "^2.2.0",
|
|
18
|
-
"lodash": "^4.17.21",
|
|
19
19
|
"semver": "^7.3.5",
|
|
20
20
|
"string-width": "^4.2.3",
|
|
21
21
|
"strip-ansi": "^6.0.1",
|
|
@@ -31,17 +31,16 @@
|
|
|
31
31
|
"@types/chai": "^4.2.22",
|
|
32
32
|
"@types/chai-as-promised": "^7.1.4",
|
|
33
33
|
"@types/clean-stack": "^2.1.1",
|
|
34
|
+
"@types/ejs": "^3.1.0",
|
|
34
35
|
"@types/fs-extra": "^9.0.13",
|
|
35
36
|
"@types/indent-string": "^4.0.1",
|
|
36
|
-
"@types/lodash": "^4.14.177",
|
|
37
|
-
"@types/lodash.template": "^4.5.0",
|
|
38
37
|
"@types/mocha": "^8.2.3",
|
|
39
38
|
"@types/nock": "^11.1.0",
|
|
40
39
|
"@types/node": "^15.14.9",
|
|
41
|
-
"@types/node-notifier": "^8.0.
|
|
40
|
+
"@types/node-notifier": "^8.0.2",
|
|
42
41
|
"@types/proxyquire": "^1.3.28",
|
|
43
|
-
"@types/read-pkg": "^5.1.0",
|
|
44
42
|
"@types/semver": "^7.3.9",
|
|
43
|
+
"@types/shelljs": "^0.8.10",
|
|
45
44
|
"@types/strip-ansi": "^5.2.1",
|
|
46
45
|
"@types/wrap-ansi": "^3.0.0",
|
|
47
46
|
"chai": "^4.3.4",
|
|
@@ -56,6 +55,7 @@
|
|
|
56
55
|
"mocha": "^8.4.0",
|
|
57
56
|
"nock": "^13.2.1",
|
|
58
57
|
"proxyquire": "^2.1.3",
|
|
58
|
+
"shelljs": "^0.8.4",
|
|
59
59
|
"shx": "^0.3.3",
|
|
60
60
|
"sinon": "^11.1.2",
|
|
61
61
|
"ts-node": "^9.1.1",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"posttest": "yarn lint",
|
|
99
99
|
"prepack": "yarn run build",
|
|
100
100
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
101
|
+
"test:e2e": "mocha \"test/**/*.e2e.ts\" --timeout 600000",
|
|
101
102
|
"pretest": "yarn build --noEmit && tsc -p test --noEmit"
|
|
102
103
|
},
|
|
103
104
|
"types": "lib/index.d.ts"
|