@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.
@@ -1,12 +1,11 @@
1
- import * as Color from 'color';
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: Color | StandardChalk | undefined, text: string): string;
10
- export declare function parseTheme(theme: Themes): Theme;
11
- export declare function getColor(color: string): Color;
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;
@@ -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.hex())(text) : text;
45
+ return color ? chalk_1.default.hex(color)(text) : text;
46
46
  }
47
47
  exports.colorize = colorize;
48
48
  function parseTheme(theme) {
49
- const themes = theme.themes ?? {};
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
  }
@@ -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, Themes } from '../interfaces/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
- activeTheme: Theme | undefined;
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>;
@@ -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 { activeTheme } = await this.loadThemes();
303
- this.theme = activeTheme;
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 themesFile = this.pjson.oclif.themesFile
362
- ? (0, node_path_1.resolve)(this.root, this.pjson.oclif.themesFile)
363
- : (0, node_path_1.resolve)(this.configDir, 'themes.json');
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
- activeTheme,
368
- file: themesFile,
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, Themes } from './theme';
13
+ export type { Theme } from './theme';
14
14
  export type { Topic } from './topic';
15
15
  export type { TSConfig } from './ts-config';
@@ -49,7 +49,6 @@ export declare namespace PJSON {
49
49
  repositoryPrefix?: string;
50
50
  schema?: number;
51
51
  state?: 'beta' | 'deprecated' | string;
52
- themesFile?: string;
53
52
  topicSeparator?: ' ' | ':';
54
53
  topics?: {
55
54
  [k: string]: {
@@ -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", "flagType", "sectionDescription", "sectionHeader", "topic", "version"];
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]: Color | StandardChalk | undefined;
8
- alias?: Color | StandardChalk;
9
- bin?: Color | StandardChalk;
10
- command?: Color | StandardChalk;
11
- commandSummary?: Color | StandardChalk;
12
- dollarSign?: Color | StandardChalk;
13
- flag?: Color | StandardChalk;
14
- flagDefaultValue?: Color | StandardChalk;
15
- flagOptions?: Color | StandardChalk;
16
- flagRequired?: Color | StandardChalk;
17
- flagSeparator?: Color | StandardChalk;
18
- flagType?: Color | StandardChalk;
19
- sectionDescription?: Color | StandardChalk;
20
- sectionHeader?: Color | StandardChalk;
21
- topic?: Color | StandardChalk;
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
  };
@@ -54,7 +54,6 @@ exports.THEME_KEYS = [
54
54
  'flagOptions',
55
55
  'flagRequired',
56
56
  'flagSeparator',
57
- 'flagType',
58
57
  'sectionDescription',
59
58
  'sectionHeader',
60
59
  'topic',
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.11.1-dev.0",
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.7.0",
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",