@oclif/core 3.11.1-dev.0 → 3.12.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.
- package/lib/cli-ux/theme.d.ts +4 -5
- package/lib/cli-ux/theme.js +3 -5
- package/lib/config/config.d.ts +2 -3
- package/lib/config/config.js +7 -10
- package/lib/interfaces/index.d.ts +1 -1
- package/lib/interfaces/pjson.d.ts +0 -1
- package/lib/interfaces/theme.d.ts +16 -22
- package/lib/interfaces/theme.js +0 -1
- package/package.json +2 -2
package/lib/cli-ux/theme.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { StandardChalk, Theme, Themes } from '../interfaces/theme';
|
|
1
|
+
import { StandardChalk, Theme } from '../interfaces/theme';
|
|
3
2
|
/**
|
|
4
3
|
* Add color to text.
|
|
5
4
|
* @param color color to use. Can be hex code (e.g. `#ff0000`), rgb (e.g. `rgb(255, 255, 255)`) or a chalk color (e.g. `red`)
|
|
6
5
|
* @param text string to colorize
|
|
7
6
|
* @returns colorized string
|
|
8
7
|
*/
|
|
9
|
-
export declare function colorize(color:
|
|
10
|
-
export declare function parseTheme(theme:
|
|
11
|
-
export declare function getColor(color: string):
|
|
8
|
+
export declare function colorize(color: string | StandardChalk | undefined, text: string): string;
|
|
9
|
+
export declare function parseTheme(theme: Record<string, string>): Theme;
|
|
10
|
+
export declare function getColor(color: string): string;
|
|
12
11
|
export declare function getColor(color: StandardChalk): StandardChalk;
|
package/lib/cli-ux/theme.js
CHANGED
|
@@ -42,13 +42,11 @@ function isStandardChalk(color) {
|
|
|
42
42
|
function colorize(color, text) {
|
|
43
43
|
if (isStandardChalk(color))
|
|
44
44
|
return chalk_1.default[color](text);
|
|
45
|
-
return color ? chalk_1.default.hex(color
|
|
45
|
+
return color ? chalk_1.default.hex(color)(text) : text;
|
|
46
46
|
}
|
|
47
47
|
exports.colorize = colorize;
|
|
48
48
|
function parseTheme(theme) {
|
|
49
|
-
|
|
50
|
-
const selected = theme.selected ? themes[theme.selected] ?? {} : {};
|
|
51
|
-
return Object.fromEntries(Object.entries(selected)
|
|
49
|
+
return Object.fromEntries(Object.entries(theme)
|
|
52
50
|
.map(([key, value]) => [key, getColor(value)])
|
|
53
51
|
.filter(([_, value]) => value));
|
|
54
52
|
}
|
|
@@ -56,7 +54,7 @@ exports.parseTheme = parseTheme;
|
|
|
56
54
|
function getColor(color) {
|
|
57
55
|
try {
|
|
58
56
|
// eslint-disable-next-line new-cap
|
|
59
|
-
return isStandardChalk(color) ? color : new Color.default(color);
|
|
57
|
+
return isStandardChalk(color) ? color : new Color.default(color).hex();
|
|
60
58
|
}
|
|
61
59
|
catch { }
|
|
62
60
|
}
|
package/lib/config/config.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Command } from '../command';
|
|
|
2
2
|
import { Hook, Hooks, PJSON, Topic } from '../interfaces';
|
|
3
3
|
import { ArchTypes, Config as IConfig, LoadOptions, PlatformTypes, VersionDetails } from '../interfaces/config';
|
|
4
4
|
import { Plugin as IPlugin, Options } from '../interfaces/plugin';
|
|
5
|
-
import { Theme
|
|
5
|
+
import { Theme } from '../interfaces/theme';
|
|
6
6
|
export declare class Config implements IConfig {
|
|
7
7
|
options: Options;
|
|
8
8
|
arch: ArchTypes;
|
|
@@ -94,8 +94,7 @@ export declare class Config implements IConfig {
|
|
|
94
94
|
}): Promise<void>;
|
|
95
95
|
loadThemes(): Promise<{
|
|
96
96
|
file: string;
|
|
97
|
-
|
|
98
|
-
themes: Themes | undefined;
|
|
97
|
+
theme: Theme | undefined;
|
|
99
98
|
}>;
|
|
100
99
|
protected macosCacheDir(): string | undefined;
|
|
101
100
|
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable | null): Promise<T>;
|
package/lib/config/config.js
CHANGED
|
@@ -299,8 +299,8 @@ class Config {
|
|
|
299
299
|
this.binPath = this.scopedEnvVar('BINPATH');
|
|
300
300
|
this.npmRegistry = this.scopedEnvVar('NPM_REGISTRY') || this.pjson.oclif.npmRegistry;
|
|
301
301
|
if (!this.scopedEnvVarTrue('DISABLE_THEME')) {
|
|
302
|
-
const {
|
|
303
|
-
this.theme =
|
|
302
|
+
const { theme } = await this.loadThemes();
|
|
303
|
+
this.theme = theme;
|
|
304
304
|
}
|
|
305
305
|
this.pjson.oclif.update = this.pjson.oclif.update || {};
|
|
306
306
|
this.pjson.oclif.update.node = this.pjson.oclif.update.node || {};
|
|
@@ -358,15 +358,12 @@ class Config {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
async loadThemes() {
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const themes = await (0, fs_1.safeReadJson)(themesFile);
|
|
365
|
-
const activeTheme = themes ? (0, theme_1.parseTheme)(themes) : undefined;
|
|
361
|
+
const file = (0, node_path_1.resolve)(this.configDir, 'theme.json');
|
|
362
|
+
const themes = await (0, fs_1.safeReadJson)(file);
|
|
363
|
+
const theme = themes ? (0, theme_1.parseTheme)(themes) : undefined;
|
|
366
364
|
return {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
themes,
|
|
365
|
+
file,
|
|
366
|
+
theme,
|
|
370
367
|
};
|
|
371
368
|
}
|
|
372
369
|
macosCacheDir() {
|
|
@@ -10,6 +10,6 @@ export type { Arg, BooleanFlag, CustomOptions, Deprecation, Flag, FlagDefinition
|
|
|
10
10
|
export type { PJSON } from './pjson';
|
|
11
11
|
export type { Options, Plugin, PluginOptions } from './plugin';
|
|
12
12
|
export type { S3Manifest } from './s3-manifest';
|
|
13
|
-
export type { Theme
|
|
13
|
+
export type { Theme } from './theme';
|
|
14
14
|
export type { Topic } from './topic';
|
|
15
15
|
export type { TSConfig } from './ts-config';
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import * as Color from 'color';
|
|
2
1
|
export declare const STANDARD_CHALK: readonly ["white", "black", "blue", "yellow", "green", "red", "magenta", "cyan", "gray", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright", "bgBlack", "bgRed", "bgGreen", "bgYellow", "bgBlue", "bgMagenta", "bgCyan", "bgWhite", "bgGray", "bgBlackBright", "bgRedBright", "bgGreenBright", "bgYellowBright", "bgBlueBright", "bgMagentaBright", "bgCyanBright", "bgWhiteBright", "bold", "underline", "dim", "italic", "strikethrough"];
|
|
3
2
|
export type StandardChalk = (typeof STANDARD_CHALK)[number];
|
|
4
|
-
export declare const THEME_KEYS: readonly ["alias", "bin", "command", "commandSummary", "dollarSign", "flag", "flagDefaultValue", "flagOptions", "flagRequired", "flagSeparator", "
|
|
3
|
+
export declare const THEME_KEYS: readonly ["alias", "bin", "command", "commandSummary", "dollarSign", "flag", "flagDefaultValue", "flagOptions", "flagRequired", "flagSeparator", "sectionDescription", "sectionHeader", "topic", "version"];
|
|
5
4
|
export type ThemeKey = (typeof THEME_KEYS)[number];
|
|
6
5
|
export type Theme = {
|
|
7
|
-
[key: string | ThemeKey]:
|
|
8
|
-
alias?:
|
|
9
|
-
bin?:
|
|
10
|
-
command?:
|
|
11
|
-
commandSummary?:
|
|
12
|
-
dollarSign?:
|
|
13
|
-
flag?:
|
|
14
|
-
flagDefaultValue?:
|
|
15
|
-
flagOptions?:
|
|
16
|
-
flagRequired?:
|
|
17
|
-
flagSeparator?:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
version?: Color | StandardChalk;
|
|
23
|
-
};
|
|
24
|
-
export type Themes = {
|
|
25
|
-
selected?: string;
|
|
26
|
-
themes?: Record<string, Record<string, string>>;
|
|
6
|
+
[key: string | ThemeKey]: string | StandardChalk | undefined;
|
|
7
|
+
alias?: string | StandardChalk;
|
|
8
|
+
bin?: string | StandardChalk;
|
|
9
|
+
command?: string | StandardChalk;
|
|
10
|
+
commandSummary?: string | StandardChalk;
|
|
11
|
+
dollarSign?: string | StandardChalk;
|
|
12
|
+
flag?: string | StandardChalk;
|
|
13
|
+
flagDefaultValue?: string | StandardChalk;
|
|
14
|
+
flagOptions?: string | StandardChalk;
|
|
15
|
+
flagRequired?: string | StandardChalk;
|
|
16
|
+
flagSeparator?: string | StandardChalk;
|
|
17
|
+
sectionDescription?: string | StandardChalk;
|
|
18
|
+
sectionHeader?: string | StandardChalk;
|
|
19
|
+
topic?: string | StandardChalk;
|
|
20
|
+
version?: string | StandardChalk;
|
|
27
21
|
};
|
package/lib/interfaces/theme.js
CHANGED
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": "3.
|
|
4
|
+
"version": "3.12.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"wrap-ansi": "^7.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@commitlint/config-conventional": "^17.
|
|
37
|
+
"@commitlint/config-conventional": "^17.8.1",
|
|
38
38
|
"@oclif/plugin-help": "^5.2.20",
|
|
39
39
|
"@oclif/plugin-plugins": "^3.3.0",
|
|
40
40
|
"@oclif/prettier-config": "^0.2.1",
|