@oclif/core 1.13.9 → 1.14.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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
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.14.0](https://github.com/oclif/core/compare/v1.13.11...v1.14.0) (2022-08-16)
6
+
7
+
8
+ ### Features
9
+
10
+ * all oclif flag types support custom parsers ([ad86faf](https://github.com/oclif/core/commit/ad86faf08f7a6d7984afe356819df458aaf04674))
11
+
12
+ ### [1.13.11](https://github.com/oclif/core/compare/v1.13.10...v1.13.11) (2022-08-16)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * more custom flag type overloads ([#471](https://github.com/oclif/core/issues/471)) ([ac4baf2](https://github.com/oclif/core/commit/ac4baf260f8e87bb5618c7b790f35372d55096c7))
18
+
19
+ ### [1.13.10](https://github.com/oclif/core/compare/v1.13.9...v1.13.10) (2022-08-09)
20
+
5
21
  ### [1.13.9](https://github.com/oclif/core/compare/v1.13.8...v1.13.9) (2022-08-09)
6
22
 
7
23
 
@@ -32,6 +32,6 @@ export declare const ux: {
32
32
  log(format?: string | undefined, ...args: string[]): void;
33
33
  url(text: string, uri: string, params?: {}): void;
34
34
  annotation(text: string, annotation: string): void;
35
- flush(): Promise<void>;
35
+ flush(ms?: number): Promise<void>;
36
36
  };
37
37
  export { config, ActionBase, Config, ExitError, IPromptOptions, Table, };
@@ -120,8 +120,8 @@ exports.ux = {
120
120
  this.log(text);
121
121
  }
122
122
  },
123
- async flush() {
124
- await timeout(flush(), 10000);
123
+ async flush(ms = 10000) {
124
+ await timeout(flush(), ms);
125
125
  },
126
126
  };
127
127
  const cliuxProcessExitHandler = async () => {
package/lib/index.d.ts CHANGED
@@ -11,5 +11,5 @@ import { Hook } from './interfaces/hooks';
11
11
  import { settings, Settings } from './settings';
12
12
  import { HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable } from './help/formatter';
13
13
  import * as cliUx from './cli-ux';
14
- declare const flush: () => Promise<void>;
14
+ declare const flush: (ms?: number) => Promise<void>;
15
15
  export { Command, CommandHelp, Config, Errors, Flags, loadHelpClass, Help, HelpBase, HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable, Hook, Interfaces, Parser, Plugin, run, toCached, tsPath, toStandardizedId, toConfiguredId, settings, Settings, flush, cliUx as CliUx, };
@@ -146,7 +146,14 @@ export declare type OptionFlag<T> = FlagBase<T, string> & OptionFlagProps & {
146
146
  export declare type Definition<T> = {
147
147
  (options: {
148
148
  multiple: true;
149
- } & Partial<OptionFlag<T[]>>): OptionFlag<T[]>;
149
+ } & ({
150
+ required: true;
151
+ } | {
152
+ default: Default<T>;
153
+ }) & Partial<OptionFlag<T>>): OptionFlag<T[]>;
154
+ (options: {
155
+ multiple: true;
156
+ } & Partial<OptionFlag<T[]>>): OptionFlag<T[] | undefined>;
150
157
  (options: ({
151
158
  required: true;
152
159
  } | {
@@ -6,6 +6,22 @@ export declare function build<T>(defaults: {
6
6
  } & Partial<OptionFlag<T>>): Definition<T>;
7
7
  export declare function build(defaults: Partial<OptionFlag<string>>): Definition<string>;
8
8
  export declare function boolean<T = boolean>(options?: Partial<BooleanFlag<T>>): BooleanFlag<T>;
9
+ export declare function integer(opts: Partial<OptionFlag<number>> & {
10
+ min?: number;
11
+ max?: number;
12
+ } & {
13
+ multiple: true;
14
+ } & ({
15
+ required: true;
16
+ } | {
17
+ default: Default<number>;
18
+ })): OptionFlag<number[]>;
19
+ export declare function integer(opts: Partial<OptionFlag<number>> & {
20
+ min?: number;
21
+ max?: number;
22
+ } & {
23
+ multiple: true;
24
+ }): OptionFlag<number[] | undefined>;
9
25
  export declare function integer(opts: Partial<OptionFlag<number>> & {
10
26
  min?: number;
11
27
  max?: number;
@@ -18,6 +34,20 @@ export declare function integer(opts?: Partial<OptionFlag<number>> & {
18
34
  min?: number;
19
35
  max?: number;
20
36
  }): OptionFlag<number | undefined>;
37
+ export declare function directory(opts: Partial<OptionFlag<string>> & {
38
+ exists?: boolean;
39
+ } & {
40
+ multiple: true;
41
+ } & ({
42
+ required: true;
43
+ } | {
44
+ default: Default<string>;
45
+ })): OptionFlag<string[]>;
46
+ export declare function directory(opts: Partial<OptionFlag<string>> & {
47
+ exists?: boolean;
48
+ } & {
49
+ multiple: true;
50
+ }): OptionFlag<string[] | undefined>;
21
51
  export declare function directory(opts: {
22
52
  exists?: boolean;
23
53
  } & Partial<OptionFlag<string>> & ({
@@ -28,6 +58,20 @@ export declare function directory(opts: {
28
58
  export declare function directory(opts?: {
29
59
  exists?: boolean;
30
60
  } & Partial<OptionFlag<string>>): OptionFlag<string | undefined>;
61
+ export declare function file(opts: Partial<OptionFlag<string>> & {
62
+ exists?: boolean;
63
+ } & {
64
+ multiple: true;
65
+ } & ({
66
+ required: true;
67
+ } | {
68
+ default: Default<string>;
69
+ })): OptionFlag<string[]>;
70
+ export declare function file(opts: Partial<OptionFlag<string>> & {
71
+ exists?: boolean;
72
+ } & {
73
+ multiple: true;
74
+ }): OptionFlag<string[] | undefined>;
31
75
  export declare function file(opts: {
32
76
  exists?: boolean;
33
77
  } & Partial<OptionFlag<string>> & ({
@@ -37,7 +37,7 @@ function integer(opts = {}) {
37
37
  throw new Error(`Expected an integer greater than or equal to ${opts.min} but received: ${input}`);
38
38
  if (opts.max !== undefined && num > opts.max)
39
39
  throw new Error(`Expected an integer less than or equal to ${opts.max} but received: ${input}`);
40
- return num;
40
+ return opts.parse ? opts.parse(input, 1) : num;
41
41
  },
42
42
  })();
43
43
  }
@@ -45,14 +45,26 @@ exports.integer = integer;
45
45
  function directory(opts = {}) {
46
46
  return build({
47
47
  ...opts,
48
- parse: async (input) => opts.exists ? dirExists(input) : input,
48
+ parse: async (input) => {
49
+ if (opts.exists) {
50
+ // 2nd "context" arg is required but unused
51
+ return opts.parse ? opts.parse(await dirExists(input), true) : dirExists(input);
52
+ }
53
+ return opts.parse ? opts.parse(input, true) : input;
54
+ },
49
55
  })();
50
56
  }
51
57
  exports.directory = directory;
52
58
  function file(opts = {}) {
53
59
  return build({
54
60
  ...opts,
55
- parse: async (input) => opts.exists ? fileExists(input) : input,
61
+ parse: async (input) => {
62
+ if (opts.exists) {
63
+ // 2nd "context" arg is required but unused
64
+ return opts.parse ? opts.parse(await fileExists(input), true) : fileExists(input);
65
+ }
66
+ return opts.parse ? opts.parse(input, true) : input;
67
+ },
56
68
  })();
57
69
  }
58
70
  exports.file = file;
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": "1.13.9",
4
+ "version": "1.14.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {