@bemoje/cli 0.0.2 → 0.0.3
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/index.cjs.js +2338 -1764
- package/index.esm.js +2243 -1659
- package/package.json +5 -3
- package/src/{core/CommandBuilder → arg}/ArgumentBuilder.d.ts +5 -6
- package/src/arg/ArgumentParserSelector.d.ts +8 -0
- package/src/{core/CommandBuilder → arg}/ArgumentReader.d.ts +1 -2
- package/src/arg/ArgumentValidatorSelector.d.ts +7 -0
- package/src/cmd/CLI.d.ts +2 -0
- package/src/cmd/CommandBuilder.d.ts +238 -0
- package/src/cmd/CommandBuilderMetaData.d.ts +23 -0
- package/src/cmd/CommandFeatureSelector.d.ts +79 -0
- package/src/cmd/DefaultHelpConfig.d.ts +2 -0
- package/src/core/OutputManager.d.ts +63 -0
- package/src/{parsers/selector/AbstractStringParserSelector.d.ts → core/ParserSelector.d.ts} +5 -6
- package/src/core/ValidatorSelector.d.ts +16 -0
- package/src/core/counter.d.ts +3 -0
- package/src/db/AbstractJsonFileSection.d.ts +136 -0
- package/src/db/AppDataSection.d.ts +29 -0
- package/src/db/ConfigSection.d.ts +47 -0
- package/src/db/JsonFile.d.ts +35 -0
- package/src/db/PresetsSection.d.ts +44 -0
- package/src/index.d.ts +102 -112
- package/src/opt/OptionArgumentParserSelector.d.ts +7 -0
- package/src/opt/OptionArgumentValidatorSelector.d.ts +7 -0
- package/src/{core/CommandBuilder → opt}/OptionBuilder.d.ts +6 -5
- package/src/opt/OptionHelpers.d.ts +32 -0
- package/src/{core/CommandBuilder → opt}/OptionReader.d.ts +2 -3
- package/src/proto/overrideCommanderPrototype.d.ts +8 -0
- package/src/types/IConfig.d.ts +21 -0
- package/src/types/IPreset.d.ts +6 -7
- package/src/util/array/arrLast.d.ts +12 -0
- package/src/util/array/arrSome.d.ts +15 -0
- package/src/util/array/types/ArrayPredicate.d.ts +10 -0
- package/src/util/db/JsonDB.d.ts +65 -0
- package/src/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.d.ts +15 -0
- package/src/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.d.ts +9 -0
- package/src/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.d.ts +13 -0
- package/src/util/fs/readFile/readFileSafeSync.d.ts +13 -0
- package/src/util/fs/readFile/readFileSync.d.ts +10 -0
- package/src/util/fs/readJsonFile/readJsonFileSafeSync.d.ts +9 -0
- package/src/util/fs/removeFile/removeFile.d.ts +1 -0
- package/src/util/fs/tempFile/tempFileSync.d.ts +7 -0
- package/src/util/fs/types/IReadJsonFileOptions.d.ts +1 -0
- package/src/util/fs/writeFile/writeFileSafeSync.d.ts +1 -0
- package/src/util/fs/writeFile/writeFileSync.d.ts +1 -0
- package/src/util/fs/writeJsonFile/writeJsonFileSafe.d.ts +1 -0
- package/src/{core/util → util/function}/MethodDisabler.d.ts +4 -3
- package/src/util/function/funSetName.d.ts +13 -0
- package/src/util/node/execInherit.d.ts +1 -0
- package/src/{core/util → util/object}/createArrayMerger.d.ts +3 -0
- package/src/{core/util → util/object}/createObjectMerger.d.ts +4 -1
- package/src/util/object/objUpdatePropertyDescriptors.d.ts +16 -0
- package/src/util/object/setNonEnumerable.d.ts +15 -0
- package/src/util/os/defaultOpenInEditorCommand.d.ts +5 -0
- package/src/util/os/isOSX.d.ts +6 -0
- package/src/util/os/isVsCodeInstalled.d.ts +5 -0
- package/src/util/os/isWindows.d.ts +8 -0
- package/src/util/path/getTempDataPath.d.ts +6 -0
- package/src/util/regex/regexEscapeString.d.ts +11 -0
- package/src/util/string/strEnsureStartsWith.d.ts +12 -0
- package/src/util/string/strFirstCharToUpperCase.d.ts +9 -0
- package/src/util/string/strIsLowerCase.d.ts +11 -0
- package/src/util/string/strIsUpperCase.d.ts +11 -0
- package/src/util/string/strSplitCamelCase.d.ts +11 -0
- package/src/util/types/Any.d.ts +1 -0
- package/src/util/types/DeepArray.d.ts +10 -0
- package/src/util/types/DeepObject.d.ts +14 -0
- package/src/util/types/JsonArray.d.ts +6 -0
- package/src/util/types/JsonDefinedPrimitive.d.ts +4 -0
- package/src/util/types/JsonObject.d.ts +6 -0
- package/src/util/types/JsonRawPrimitive.d.ts +5 -0
- package/src/util/types/JsonValue.d.ts +7 -0
- package/src/util/types/ObjectKey.d.ts +1 -0
- package/src/util/types/TConstructor.d.ts +5 -0
- package/src/util/types/TFunction.d.ts +4 -0
- package/src/util/types/TFunctionNoNew.d.ts +2 -0
- package/src/util/types/TPlainObject.d.ts +2 -0
- package/src/util/types/TPrimitive.d.ts +1 -0
- package/src/util/types/TValidator.d.ts +1 -0
- package/src/{validators → util/validation}/createTypedArrayValidator.d.ts +1 -3
- package/src/util/validation/ensureThat.d.ts +6 -0
- package/src/util/validation/isFunction.d.ts +11 -0
- package/src/{validators → util/validation}/isNamedFunction.d.ts +1 -1
- package/src/util/validation/isObject.d.ts +15 -0
- package/src/util/validation/isPlainObject.d.ts +6 -0
- package/src/util/validation/isPrimitive.d.ts +12 -0
- package/src/util/validation/numbers/isInteger.d.ts +13 -0
- package/src/util/validation/numbers/isValidNumber.d.ts +15 -0
- package/src/core/CommandBuilder/Base.d.ts +0 -5
- package/src/core/CommandBuilder/CommandBuilder.d.ts +0 -80
- package/src/core/CommandBuilder/CommandBuilder.example.d.ts +0 -1
- package/src/core/CommandBuilder/CommandBuilderMetaData.d.ts +0 -17
- package/src/core/CommandBuilder/CommandFeatureSelector.d.ts +0 -26
- package/src/core/CommandBuilder/OutputManager.d.ts +0 -47
- package/src/core/CommandBuilder/assertCommandNameNotReserved.d.ts +0 -1
- package/src/core/CommandBuilder/ensureBackRefToCommandBuilder.d.ts +0 -7
- package/src/core/CommandBuilder/features/action/actionWrapper.d.ts +0 -5
- package/src/core/CommandBuilder/features/action/combineVariadicArgs.d.ts +0 -3
- package/src/core/CommandBuilder/features/action/debugLogArgsOpts.d.ts +0 -4
- package/src/core/CommandBuilder/features/action/deleteOptionsWithDefaultOrNoValue.d.ts +0 -3
- package/src/core/CommandBuilder/features/action/getPresetArgsAndOpts.d.ts +0 -3
- package/src/core/CommandBuilder/features/action/handleError.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/handleOutputOptions.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/optsWithGlobalsParsed.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/padArgsWithUndefinedUntilExpectedLength.d.ts +0 -3
- package/src/core/CommandBuilder/features/action/parseArguments.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/parseOptions.d.ts +0 -6
- package/src/core/CommandBuilder/features/action/parsedValidArgsOptsWithPresets.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/parsedValidArgsWithPresets.d.ts +0 -2
- package/src/core/CommandBuilder/features/action/parsedValidOptsWithPresets.d.ts +0 -3
- package/src/core/CommandBuilder/features/addConfigCommands.d.ts +0 -3
- package/src/core/CommandBuilder/features/addPresetsCommands.d.ts +0 -3
- package/src/core/CommandBuilder/features/addUtilCommands.d.ts +0 -2
- package/src/core/CommandBuilder/features/assertNoDuplicateCommandNames.d.ts +0 -2
- package/src/core/CommandBuilder/features/assertNoDuplicateOptionNames.d.ts +0 -2
- package/src/core/CommandBuilder/features/autoAssignMissingOptionFlags.d.ts +0 -14
- package/src/core/CommandBuilder/features/autoAssignSubCommandAliases.d.ts +0 -13
- package/src/core/CommandBuilder/features/getClosestNonNativeParent.d.ts +0 -2
- package/src/core/CommandBuilder/getGlobalOptions.d.ts +0 -3
- package/src/core/CommandBuilder/getOwnAndGlobalOptions.d.ts +0 -3
- package/src/core/CommandBuilder/initializeCommand.d.ts +0 -2
- package/src/core/db/AbstractJsonFileSection.d.ts +0 -45
- package/src/core/db/ConfigSection.d.ts +0 -19
- package/src/core/db/JsonDB.d.ts +0 -19
- package/src/core/db/JsonFile.d.ts +0 -25
- package/src/core/db/JsonFileError.d.ts +0 -6
- package/src/core/db/PresetsSection.d.ts +0 -14
- package/src/core/help/configureHelp.d.ts +0 -2
- package/src/core/util/assertPresetArgsOptional.d.ts +0 -3
- package/src/core/util/assertValidArguments.d.ts +0 -6
- package/src/core/util/assertValidOptions.d.ts +0 -6
- package/src/core/util/assertValidPreset.d.ts +0 -3
- package/src/core/util/commandExists.d.ts +0 -5
- package/src/core/util/commandLocation.d.ts +0 -5
- package/src/core/util/errorToString.d.ts +0 -1
- package/src/core/util/escapeShellCommandArgument.d.ts +0 -5
- package/src/core/util/forEachChildRecursive.d.ts +0 -4
- package/src/core/util/getARGV.d.ts +0 -1
- package/src/core/util/getAncestors.d.ts +0 -7
- package/src/core/util/getChildren.d.ts +0 -4
- package/src/core/util/getJsonFilepath.d.ts +0 -2
- package/src/core/util/getOptionArgumentName.d.ts +0 -5
- package/src/core/util/getRootCommand.d.ts +0 -5
- package/src/core/util/getSiblings.d.ts +0 -5
- package/src/core/util/hasVariadicArguments.d.ts +0 -5
- package/src/core/util/objDestroy.d.ts +0 -2
- package/src/core/util/optHasArgument.d.ts +0 -2
- package/src/core/util/prefixArray.d.ts +0 -5
- package/src/core/util/prefixString.d.ts +0 -5
- package/src/core/util/prefixStringsRecursive.d.ts +0 -5
- package/src/core/util/renderOptionFlags.d.ts +0 -6
- package/src/core/util/setOptionLongName.d.ts +0 -6
- package/src/core/util/setOptionShortName.d.ts +0 -6
- package/src/core/util/walkAncestors.d.ts +0 -7
- package/src/core/util/walkChildren.d.ts +0 -4
- package/src/core/util/walkSiblings.d.ts +0 -5
- package/src/parsers/createTupleListParser.d.ts +0 -11
- package/src/parsers/selector/ArgumentParserSelector.d.ts +0 -7
- package/src/parsers/selector/OptionArgumentParserSelector.d.ts +0 -7
- package/src/types/IDefinePropertyOptions.d.ts +0 -9
- package/src/types/IPresets.d.ts +0 -6
- package/src/types/TValidator.d.ts +0 -2
- package/src/validators/createLengthValidator.d.ts +0 -7
- package/src/validators/isInteger.d.ts +0 -1
- package/src/validators/isIntegerArray.d.ts +0 -4
- package/src/validators/isNull.d.ts +0 -1
- package/src/validators/isNumber.d.ts +0 -1
- package/src/validators/isNumberArray.d.ts +0 -4
- package/src/validators/isNumericString.d.ts +0 -1
- package/src/validators/selector/ArgumentValidatorSelector.d.ts +0 -6
- package/src/validators/selector/OptionArgumentValidatorSelector.d.ts +0 -6
- package/src/validators/selector/ValidatorSelector.d.ts +0 -17
- /package/src/core/{util/splitCombinedArgvShorts.d.ts → splitCombinedArgvShorts.d.ts} +0 -0
- /package/src/{core/CommandBuilder → util/errors}/ErrorParser.d.ts +0 -0
- /package/src/{core/CommandBuilder/features → util/node}/formatTableForTerminal.d.ts +0 -0
- /package/src/{core/util → util/object}/arrAssign.d.ts +0 -0
- /package/src/{core/util → util/object}/objAssign.d.ts +0 -0
- /package/src/{core/util → util/object}/realizeLazyProperty.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/createBooleanParser.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/createTypedListParser.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/parseBoolean.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/parseInteger.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/parseNumber.d.ts +0 -0
- /package/src/{parsers → util/string-parsers}/parseString.d.ts +0 -0
- /package/src/{types → util/types}/TStringParser.d.ts +0 -0
- /package/src/{validators → util/validation}/isArray.d.ts +0 -0
- /package/src/{validators → util/validation}/isBoolean.d.ts +0 -0
- /package/src/{validators → util/validation}/isNamedFunctionArray.d.ts +0 -0
- /package/src/{validators → util/validation}/isString.d.ts +0 -0
- /package/src/{validators → util/validation}/isStringArray.d.ts +0 -0
- /package/src/{validators → util/validation}/isStringWithNoSpacesOrDashes.d.ts +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IGetUserInputFromEditorOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The content to put in the temp file so that the user can edit it. Defaults to an empty file.
|
|
4
|
+
*/
|
|
5
|
+
content?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Launch command to start your editor. Defaults to VSCode: 'code -w' (if installed).
|
|
8
|
+
* Otherwise this logic: isWindows() ? 'notepad' : isOSX() ? 'open vi' : 'xdg-open'
|
|
9
|
+
*/
|
|
10
|
+
editor?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The file extension to use for the temporary file. Defaults to '.txt'.
|
|
13
|
+
*/
|
|
14
|
+
extension?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IGetUserInputFromEditorOptions } from './IGetUserInputFromEditorOptions';
|
|
2
|
+
/**
|
|
3
|
+
* Prompts the user to edit a string in the user's text editor.
|
|
4
|
+
*
|
|
5
|
+
* @example ```ts
|
|
6
|
+
* promptUserEditInTextEditor({ editor: 'notepad' })
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export declare function promptUserEditInTextEditorSync(options?: IGetUserInputFromEditorOptions): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JsonValue } from '../../types/JsonValue';
|
|
2
|
+
/**
|
|
3
|
+
* Edit a JSON-stringify-compatible value in the user's editor and return the (JSON.parse'd) result.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The value to edit (NOT a json string). Defaults to an empty object.
|
|
6
|
+
* @param editor - Launch command to start your editor. Defaults to VSCode: 'code -w' (if installed).
|
|
7
|
+
* - Otherwise this logic: isWindows() ? 'notepad' : isOSX() ? 'open vi' : 'xdg-open'
|
|
8
|
+
*
|
|
9
|
+
* @example ```ts
|
|
10
|
+
* promptUserEditJsonInTextEditorSync([1, 2])
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function promptUserEditJsonInTextEditorSync<T extends JsonValue = JsonValue, R extends T = T>(value?: T, editor?: string): R;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Reads a file and returns the file's contents.
|
|
4
|
+
*
|
|
5
|
+
* Identical to fs.readFileSync, except that:
|
|
6
|
+
* - it uses utf8 encoding by default
|
|
7
|
+
* - if operation fails, returns undefined instead of throwing
|
|
8
|
+
*
|
|
9
|
+
* @param filepath - The path to the file.
|
|
10
|
+
* @param encoding - The encoding to use when reading the file.
|
|
11
|
+
* @returns The file's contents or undefined if the file does not exist.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readFileSafeSync(filepath: string, encoding?: BufferEncoding): string | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Reads a file and returns the file's contents.
|
|
4
|
+
* Identical to fs.readFileSync, except that it uses utf8 encoding by default.
|
|
5
|
+
*
|
|
6
|
+
* @param filepath - The path to the file.
|
|
7
|
+
* @param encoding - The encoding to use when reading the file.
|
|
8
|
+
* @returns The file's contents.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readFileSync(filepath: string, encoding?: BufferEncoding): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IReadJsonFileOptions } from '../types/IReadJsonFileOptions';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a JSON file and then parses it into an object.
|
|
4
|
+
* If an error occurs, it returns undefined.
|
|
5
|
+
*
|
|
6
|
+
* @param filepath - The path to the JSON file.
|
|
7
|
+
* @param options - Options for reading the JSON file.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readJsonFileSafeSync<T>(filepath: string, options?: IReadJsonFileOptions): T | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { remove as removeFile } from 'fs-extra';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Any } from '../../types/Any';
|
|
2
|
+
/**
|
|
3
|
+
* Syncrhonously creates a temporary file and deletes it after the callback has finished.
|
|
4
|
+
* @param fileExtension - The file extension to use for the temporary file.
|
|
5
|
+
* @param callback - The callback to execute with the temporary file path. The callback can return a promise and the temporary file will not be deleted until the promise has resolved or rejected.
|
|
6
|
+
*/
|
|
7
|
+
export declare function tempFileSync(fileExtension: string, callback: (fpath: string) => Any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { JFReadOptions as IReadJsonFileOptions } from 'jsonfile';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { outputFileSync as writeFileSafeSync } from 'fs-extra';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { writeFileSync } from 'fs-extra';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { outputJson as writeJsonFileSafe } from 'fs-extra';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Any
|
|
2
|
-
import {
|
|
1
|
+
import { Any } from '../types/Any';
|
|
2
|
+
import { ObjectKey } from '../types/ObjectKey';
|
|
3
|
+
import { TFunctionNoNew } from '../types/TFunctionNoNew';
|
|
3
4
|
/**
|
|
4
5
|
* A class that creates an object with methods for disabling/enabling a given method on a given object.
|
|
5
6
|
*
|
|
@@ -16,7 +17,7 @@ import { Base } from '../CommandBuilder/Base';
|
|
|
16
17
|
*
|
|
17
18
|
* assert(md.original === process.stdout.write)
|
|
18
19
|
*/
|
|
19
|
-
export declare class MethodDisabler
|
|
20
|
+
export declare class MethodDisabler {
|
|
20
21
|
#private;
|
|
21
22
|
/**
|
|
22
23
|
* @param obj - The object on which the method is defined.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function sets the name of a function and returns the function with the new name.
|
|
3
|
+
* @template T - The type of the function.
|
|
4
|
+
* @param name The new name to be set for the function.
|
|
5
|
+
* @param fun The function whose name is to be set.
|
|
6
|
+
* @returns The function with the new name.
|
|
7
|
+
* @example ```ts
|
|
8
|
+
* const myFun = () => 'Hello World';
|
|
9
|
+
* funSetName('newFun', myFun).name;;
|
|
10
|
+
* //=> 'newFun'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function funSetName<T>(name: string, fun: T): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function execInherit(command: string): Promise<string>;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import { Any } from '
|
|
1
|
+
import { Any } from '../types/Any';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that merges objects based on a predicate function.
|
|
4
|
+
*/
|
|
2
5
|
export declare function createObjectMerger(predicate: (value: Any, key: string, obj: Record<string, Any>) => boolean): (target: Record<string, Any>, ...sources: Record<string, Any>[]) => Record<string, any>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ObjectKey } from '../types/ObjectKey';
|
|
2
|
+
/**
|
|
3
|
+
* Updates the property descriptors of the specified properties on the given object.
|
|
4
|
+
* @param object - The object whose property descriptors are to be updated.
|
|
5
|
+
* @param properties - An array of property names for which the descriptors are to be updated.
|
|
6
|
+
* @param update - A function that takes a property descriptor and a property name, and returns a new property descriptor.
|
|
7
|
+
* @throws Will throw an error if any of the specified properties do not exist on the object.
|
|
8
|
+
* @example ```ts
|
|
9
|
+
* const obj = { a: 1, b: 2 };
|
|
10
|
+
* objUpdatePropertyDescriptors(obj, ['a', 'b'], (descriptor, property) => {
|
|
11
|
+
* descriptor.writable = true;
|
|
12
|
+
* return obj;
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function objUpdatePropertyDescriptors<V>(object: Record<ObjectKey, V>, properties: string[], update: <T extends PropertyDescriptor>(descriptor: T, property: string) => T): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ObjectKey } from '../types/ObjectKey';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the specified properties of an object as non-enumerable.
|
|
4
|
+
* @remarks This function modifies the original object by setting the specified properties as non-enumerable.
|
|
5
|
+
* If the object or any of the property names are not valid, it throws an error.
|
|
6
|
+
* @param object The object whose properties are to be set as non-enumerable.
|
|
7
|
+
* @param properties The names of the properties to be set as non-enumerable.
|
|
8
|
+
* @throws Will throw an error if any of the specified properties do not exist on the object.
|
|
9
|
+
* @example ```ts
|
|
10
|
+
* setNonEnumerable({ a: 1, b: 2, c: 3 }, 'a', 'b');
|
|
11
|
+
* Object.keys({ a: 1, b: 2, c: 3 });;
|
|
12
|
+
* //=> ['c']
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function setNonEnumerable(object: Record<ObjectKey, any>, ...properties: string[]): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the current platform is OSX.
|
|
3
|
+
* It checks the 'process' object and the 'platform' property to determine if the platform is 'darwin'.
|
|
4
|
+
* @returns A boolean indicating whether the current platform is OSX.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isOSX(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the current platform is Windows.
|
|
3
|
+
* @remarks
|
|
4
|
+
* It checks the 'process' object and the 'platform' property to determine if the platform is 'win32'.
|
|
5
|
+
* It also checks the 'OSTYPE' environment variable to see if it matches 'msys' or 'cygwin'.
|
|
6
|
+
* @returns A boolean indicating whether the current platform is Windows.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isWindows(): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes special characters in a string to be used in a regular expression.
|
|
3
|
+
* @param str The input string to escape.
|
|
4
|
+
* @returns The escaped string.
|
|
5
|
+
* @example ```ts
|
|
6
|
+
* const input = 'Hello, world!';
|
|
7
|
+
* regexEscapeString(input);;
|
|
8
|
+
* //=> 'Hello, world!'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function regexEscapeString(str: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures that a string starts with a specified substring. If the string already starts with the specified substring, it is returned as is. Otherwise, the substring is appended to the end of the string.
|
|
3
|
+
* @param string The string to be processed.
|
|
4
|
+
* @param startsWith The substring that the string should end with.
|
|
5
|
+
* @example ```ts
|
|
6
|
+
* strEnsureStartsWith('json', '.');
|
|
7
|
+
* //=> '.json'
|
|
8
|
+
* strEnsureStartsWith('.json', '.');
|
|
9
|
+
* //=> '.json'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function strEnsureStartsWith(string: string, startsWith: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts the first character of a string to uppercase.
|
|
3
|
+
* @param string The string to be converted.
|
|
4
|
+
* @example ```ts
|
|
5
|
+
* strFirstCharToUpperCase('hello');
|
|
6
|
+
* //=> 'Hello'
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export declare function strFirstCharToUpperCase(string: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given string is in lower case.
|
|
3
|
+
* @param input The string to be checked.
|
|
4
|
+
* @example ```ts
|
|
5
|
+
* strIsLowerCase('hello');
|
|
6
|
+
* //=> true
|
|
7
|
+
* strIsLowerCase('Hello');
|
|
8
|
+
* //=> false
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function strIsLowerCase(input: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given string is in upper case.
|
|
3
|
+
* @param input The string to be checked.
|
|
4
|
+
* @example ```ts
|
|
5
|
+
* strIsUpperCase('HELLO');;
|
|
6
|
+
* //=> true
|
|
7
|
+
* strIsUpperCase('HEllo');;
|
|
8
|
+
* //=> false
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function strIsUpperCase(input: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns an array of words in the string
|
|
3
|
+
* @param word The camel case word to split.
|
|
4
|
+
* @throws Throws an error if the input is not a string.
|
|
5
|
+
* @param input input string
|
|
6
|
+
* @example ```ts
|
|
7
|
+
* strSplitCamelCase('someCamel10Case')
|
|
8
|
+
* //=> ['some', 'Camel10', 'Case']
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function strSplitCamelCase(word: string): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Any = any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DeepObject } from './DeepObject';
|
|
2
|
+
import { ObjectKey } from './ObjectKey';
|
|
3
|
+
/**
|
|
4
|
+
* Recursively defined array that can contain objects+arrays with values of a given type V.
|
|
5
|
+
*/
|
|
6
|
+
export type DeepArray<V, K extends ObjectKey = string | symbol> = Array<V | DeepObject<V, K> | DeepArray<V, K>> | [];
|
|
7
|
+
/**
|
|
8
|
+
* Recursively defined array that can contain only arrays (excl. objects) with values of a given type V.
|
|
9
|
+
*/
|
|
10
|
+
export type StrictlyDeepArray<V> = Array<V | StrictlyDeepArray<V>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DeepArray } from './DeepArray';
|
|
2
|
+
import { ObjectKey } from './ObjectKey';
|
|
3
|
+
/**
|
|
4
|
+
* Recursively defined object with objects+arrays with values of a given type V.
|
|
5
|
+
*/
|
|
6
|
+
export type DeepObject<V, K extends ObjectKey = string | symbol> = {
|
|
7
|
+
[_ in K]?: V | DeepObject<V, K> | DeepArray<V, K>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Recursively defined array that can contain only objects (excl. arrays) with values of a given type V.
|
|
11
|
+
*/
|
|
12
|
+
export type StrictlyDeepObject<V, K extends string | symbol = string | symbol> = {
|
|
13
|
+
[_ in K]?: V | StrictlyDeepObject<V, K>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JsonArray } from './JsonArray';
|
|
2
|
+
import { JsonObject } from './JsonObject';
|
|
3
|
+
import { JsonRawPrimitive } from './JsonRawPrimitive';
|
|
4
|
+
/**
|
|
5
|
+
* Any JSON value. Any JSON.parse() return value.
|
|
6
|
+
*/
|
|
7
|
+
export type JsonValue<P extends JsonRawPrimitive = JsonRawPrimitive> = P | JsonObject<P> | JsonArray<P> | P[] | Record<string, P>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ObjectKey = string | number | symbol;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Any } from './Any';
|
|
2
|
+
/**
|
|
3
|
+
* This type represents a constructor function. It is a function that can be called with the `new` keyword to create an instance of a certain type.
|
|
4
|
+
*/
|
|
5
|
+
export type TConstructor<R = Any, A extends Any[] = Any[]> = new (...args: A) => R;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TPrimitive = null | undefined | bigint | boolean | number | string | symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TValidator<T> = (value: T) => boolean;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { JsonValue } from '@bemoje/util';
|
|
2
|
-
import { TValidator } from '../types/TValidator';
|
|
3
1
|
/**
|
|
4
2
|
* Creates a validator function that checks whether the input is an array where all elements are valid according to every validator provided.
|
|
5
3
|
*
|
|
@@ -8,4 +6,4 @@ import { TValidator } from '../types/TValidator';
|
|
|
8
6
|
*
|
|
9
7
|
* @throws TypeError - if no name is provided and not all validators are named functions.
|
|
10
8
|
*/
|
|
11
|
-
export declare function createTypedArrayValidator<O
|
|
9
|
+
export declare function createTypedArrayValidator<O>(validators: ((value: O) => boolean)[], name?: string): (array: unknown) => boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Any } from '../types/Any';
|
|
2
|
+
import { TConstructor } from '../types/TConstructor';
|
|
3
|
+
export declare function ensureThat<T>(value: T, validator: ((value: T, ...args: any[]) => boolean | string) | ((value: T, ...args: any[]) => boolean), options?: {
|
|
4
|
+
Err?: TConstructor;
|
|
5
|
+
args?: Any[];
|
|
6
|
+
}): T;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TFunction } from '../types/TFunction';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given value is a function.
|
|
4
|
+
*
|
|
5
|
+
* @example ```ts
|
|
6
|
+
* isFunction(class {}); //=> true
|
|
7
|
+
* isFunction(function () {}); //=> true
|
|
8
|
+
* isFunction(() => {}); //=> true
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function isFunction(value: unknown): value is TFunction;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the provided value is an object (null, arrays and functions not included).
|
|
3
|
+
* @template T - The type of the value to check.
|
|
4
|
+
* @param value The value to check.
|
|
5
|
+
* @returns A boolean indicating whether the provided value is an object.
|
|
6
|
+
* @example ```ts
|
|
7
|
+
* isObject({});;
|
|
8
|
+
* //=> true
|
|
9
|
+
* isObject([1]);;
|
|
10
|
+
* //=> false
|
|
11
|
+
* isObject(123);;
|
|
12
|
+
* //=> false
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function isObject(value: unknown): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ObjectKey } from '../types/ObjectKey';
|
|
2
|
+
import { TPlainObject } from '../types/TPlainObject';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the provided value is a plain object, i.e. an object created by the native base `Object` constructor.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isPlainObject<K extends ObjectKey = ObjectKey, V = unknown>(value: unknown): value is TPlainObject<K, V>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TPrimitive } from '../types/TPrimitive';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the provided value is a primitive type (null, undefined, bigint, boolean, number, string or symbol).
|
|
4
|
+
* @param value The value to check.
|
|
5
|
+
* @returns A boolean indicating whether the provided value is a primitive type.
|
|
6
|
+
* @example
|
|
7
|
+
* isPrimitive(123);
|
|
8
|
+
* //=> true
|
|
9
|
+
* isPrimitive({});
|
|
10
|
+
* //=> false
|
|
11
|
+
*/
|
|
12
|
+
export declare function isPrimitive(value: unknown): value is TPrimitive;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the provided number is an integer.
|
|
3
|
+
* @remarks This function uses the built-in `Number.isInteger` method.
|
|
4
|
+
* @param int The number to check.
|
|
5
|
+
* @returns A boolean indicating whether the provided number is an integer.
|
|
6
|
+
* @example ```ts
|
|
7
|
+
* isInteger(5);
|
|
8
|
+
* //=> true
|
|
9
|
+
* isInteger(5.5);
|
|
10
|
+
* //=> false
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const isInteger: (number: unknown) => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the provided value is a valid number.
|
|
3
|
+
* @remarks This function checks if the provided value is a finite number and not NaN.
|
|
4
|
+
* @param number The value to check.
|
|
5
|
+
* @returns A boolean indicating whether the provided value is a valid number.
|
|
6
|
+
* @example ```ts
|
|
7
|
+
* isValidNumber(123);
|
|
8
|
+
* //=> true
|
|
9
|
+
* isValidNumber(NaN);
|
|
10
|
+
* //=> false
|
|
11
|
+
* isValidNumber(Infinity);
|
|
12
|
+
* //=> false
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function isValidNumber(number: number): boolean;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Any, JsonValue } from '@bemoje/util';
|
|
2
|
-
import { ArgumentBuilder } from './ArgumentBuilder';
|
|
3
|
-
import { Base } from './Base';
|
|
4
|
-
import { Command, CommanderError, ErrorOptions } from 'commander';
|
|
5
|
-
import { CommandBuilderMetaData } from './CommandBuilderMetaData';
|
|
6
|
-
import { CommandFeatureSelector } from './CommandFeatureSelector';
|
|
7
|
-
import { IConfigDefinePropertyOptions } from '../../types/IDefinePropertyOptions';
|
|
8
|
-
import { IPresetPartial } from '../../types/IPreset';
|
|
9
|
-
import { JsonFile } from '../db/JsonFile';
|
|
10
|
-
import { OptionBuilder } from './OptionBuilder';
|
|
11
|
-
/**
|
|
12
|
-
* Wrapper around the @see Command class, for more intuitive construction.
|
|
13
|
-
*/
|
|
14
|
-
export declare class CommandBuilder extends Base {
|
|
15
|
-
static dataDirectory: string;
|
|
16
|
-
readonly $: Command;
|
|
17
|
-
readonly parent: CommandBuilder | null;
|
|
18
|
-
readonly meta: CommandBuilderMetaData;
|
|
19
|
-
readonly get: CommandReader;
|
|
20
|
-
readonly features: CommandFeatureSelector;
|
|
21
|
-
constructor(name: string, callback?: (cmd: CommandBuilder) => void, parent?: CommandBuilder | null);
|
|
22
|
-
get db(): JsonFile;
|
|
23
|
-
get name(): string;
|
|
24
|
-
version(string: string): this;
|
|
25
|
-
alias(alias: string): this;
|
|
26
|
-
aliases(...aliases: string[]): this;
|
|
27
|
-
get isRoot(): boolean;
|
|
28
|
-
get arguments(): readonly import("commander").Argument[];
|
|
29
|
-
get options(): readonly import("commander").Option[];
|
|
30
|
-
enableBuiltinOptions(options?: {
|
|
31
|
-
help?: true;
|
|
32
|
-
debug?: true;
|
|
33
|
-
disableColor?: true;
|
|
34
|
-
disableStderr?: true;
|
|
35
|
-
disableStdout?: true;
|
|
36
|
-
}): void;
|
|
37
|
-
outputHelp(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Display error message and exit (or call exitOverride).
|
|
40
|
-
*/
|
|
41
|
-
outputUserError(message: string, options?: ErrorOptions): void;
|
|
42
|
-
description(...lines: string[]): this;
|
|
43
|
-
allowExcessArguments(bool?: boolean): this;
|
|
44
|
-
allowUnknownOption(bool?: boolean): this;
|
|
45
|
-
/**
|
|
46
|
-
* Register callback to use as replacement for calling process.exit.
|
|
47
|
-
*/
|
|
48
|
-
exitOverride(callback?: (err: CommanderError) => never | void): this;
|
|
49
|
-
get root(): CommandBuilder;
|
|
50
|
-
/**
|
|
51
|
-
* Display error message and exit (or call exitOverride).
|
|
52
|
-
*/
|
|
53
|
-
outputDebugInfo(event: string, getProps?: () => Record<string, unknown>): void;
|
|
54
|
-
hideGlobalOptions(...names: string[]): this;
|
|
55
|
-
unhideGlobalOptions(...names: string[]): this;
|
|
56
|
-
argument(name: string, description?: string): this;
|
|
57
|
-
argument(name: string, cb: (opt: ArgumentBuilder, cmd: this) => void): this;
|
|
58
|
-
option(flags: string, description?: string): this;
|
|
59
|
-
option(flags: string, cb?: (opt: OptionBuilder, cmd: this) => void): this;
|
|
60
|
-
globalOption(flags: string, description?: string): this;
|
|
61
|
-
globalOption(flags: string, cb?: (opt: OptionBuilder, cmd: this) => void): this;
|
|
62
|
-
command(name: string, cb: (cmd: CommandBuilder) => void): this;
|
|
63
|
-
nativeCommand(name: string, cb: (cmd: CommandBuilder) => void): this;
|
|
64
|
-
action<T extends (...args: Any[]) => Promise<void>>(fn: T): this;
|
|
65
|
-
config(key: string, entry: IConfigDefinePropertyOptions<JsonValue>): this;
|
|
66
|
-
preset(name: string, preset: IPresetPartial): this;
|
|
67
|
-
createMain(): (argv?: string[]) => Promise<void>;
|
|
68
|
-
}
|
|
69
|
-
export declare function CLI(name: string, callback: (cmd: CommandBuilder) => void): CommandBuilder;
|
|
70
|
-
export declare class CommandReader extends Base {
|
|
71
|
-
protected readonly cmd: CommandBuilder;
|
|
72
|
-
constructor(cmd: CommandBuilder);
|
|
73
|
-
get action(): ((...args: any[]) => Promise<void>) | undefined;
|
|
74
|
-
get description(): string;
|
|
75
|
-
get summary(): string;
|
|
76
|
-
get version(): string | undefined;
|
|
77
|
-
get alias(): string;
|
|
78
|
-
get aliases(): string[];
|
|
79
|
-
get renderHelp(): string;
|
|
80
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Any } from '@bemoje/util';
|
|
2
|
-
import { Base } from './Base';
|
|
3
|
-
import { CommandBuilder } from './CommandBuilder';
|
|
4
|
-
import { Option } from 'commander';
|
|
5
|
-
import { TStringParser } from '../../types/TStringParser';
|
|
6
|
-
import { TValidator } from '../../types/TValidator';
|
|
7
|
-
export declare class CommandBuilderMetaData extends Base {
|
|
8
|
-
subcommands: CommandBuilder[];
|
|
9
|
-
globalOptions: Option[];
|
|
10
|
-
hiddenGlobalOptions: Set<Option>;
|
|
11
|
-
isNative: boolean;
|
|
12
|
-
actionHandler?: (...args: Any[]) => Promise<void>;
|
|
13
|
-
get argParsers(): TStringParser<Any>[];
|
|
14
|
-
get argValidators(): TValidator<Any>[][];
|
|
15
|
-
get optParsers(): Record<string, TStringParser<Any>>;
|
|
16
|
-
get optValidators(): Record<string, TValidator<Any>[]>;
|
|
17
|
-
}
|