@oclif/core 3.11.1-dev.1 → 3.12.1

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,4 +1,4 @@
1
- import { StandardChalk, Theme, Themes } from '../interfaces/theme';
1
+ import { StandardChalk, Theme } from '../interfaces/theme';
2
2
  /**
3
3
  * Add color to text.
4
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,6 +6,6 @@ import { StandardChalk, Theme, Themes } from '../interfaces/theme';
6
6
  * @returns colorized string
7
7
  */
8
8
  export declare function colorize(color: string | StandardChalk | undefined, text: string): string;
9
- export declare function parseTheme(theme: Themes): Theme;
9
+ export declare function parseTheme(theme: Record<string, string>): Theme;
10
10
  export declare function getColor(color: string): string;
11
11
  export declare function getColor(color: StandardChalk): StandardChalk;
@@ -46,9 +46,7 @@ function colorize(color, 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
  }
@@ -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() {
package/lib/help/util.js CHANGED
@@ -43,7 +43,7 @@ function collateSpacedCmdIDFromArgs(argv, config) {
43
43
  const ids = (0, util_1.collectUsableIds)(config.commandIDs);
44
44
  const final = [];
45
45
  const idPresent = (id) => ids.has(id);
46
- const finalizeId = (s) => (s ? [...final, s].join(':') : final.join(':'));
46
+ const finalizeId = (s) => (s ? [...final, s] : final).filter(Boolean).join(':');
47
47
  const hasArgs = () => {
48
48
  const id = finalizeId();
49
49
  if (!id)
@@ -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,6 +1,6 @@
1
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"];
2
2
  export type StandardChalk = (typeof STANDARD_CHALK)[number];
3
- 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"];
4
4
  export type ThemeKey = (typeof THEME_KEYS)[number];
5
5
  export type Theme = {
6
6
  [key: string | ThemeKey]: string | StandardChalk | undefined;
@@ -14,13 +14,8 @@ export type Theme = {
14
14
  flagOptions?: string | StandardChalk;
15
15
  flagRequired?: string | StandardChalk;
16
16
  flagSeparator?: string | StandardChalk;
17
- flagType?: string | StandardChalk;
18
17
  sectionDescription?: string | StandardChalk;
19
18
  sectionHeader?: string | StandardChalk;
20
19
  topic?: string | StandardChalk;
21
20
  version?: string | StandardChalk;
22
21
  };
23
- export type Themes = {
24
- selected?: string;
25
- themes?: Record<string, Record<string, string>>;
26
- };
@@ -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.1",
4
+ "version": "3.12.1",
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",