@bemoje/cli 0.0.4 → 0.0.6
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/.eslintrc.json +5 -0
- package/.swcrc +32 -0
- package/dist/cjs/_example/bFindIn.js +189 -0
- package/dist/cjs/_example/bFindIn.js.map +1 -0
- package/dist/cjs/arg/ArgumentBuilder.js +45 -0
- package/dist/cjs/arg/ArgumentBuilder.js.map +1 -0
- package/dist/cjs/arg/ArgumentParserSelector.js +15 -0
- package/dist/cjs/arg/ArgumentParserSelector.js.map +1 -0
- package/dist/cjs/arg/ArgumentReader.js +38 -0
- package/dist/cjs/arg/ArgumentReader.js.map +1 -0
- package/dist/cjs/arg/ArgumentValidatorSelector.js +16 -0
- package/dist/cjs/arg/ArgumentValidatorSelector.js.map +1 -0
- package/dist/cjs/cmd/CommandBuilder.js +1080 -0
- package/dist/cjs/cmd/CommandBuilder.js.map +1 -0
- package/dist/cjs/cmd/CommandBuilderMetaData.js +44 -0
- package/dist/cjs/cmd/CommandBuilderMetaData.js.map +1 -0
- package/dist/cjs/cmd/CommandFeatureSelector.js +112 -0
- package/dist/cjs/cmd/CommandFeatureSelector.js.map +1 -0
- package/dist/cjs/cmd/DefaultHelpConfig.js +141 -0
- package/dist/cjs/cmd/DefaultHelpConfig.js.map +1 -0
- package/dist/cjs/cmd/asdas.js +27 -0
- package/dist/cjs/cmd/asdas.js.map +1 -0
- package/dist/cjs/core/OutputManager.js +99 -0
- package/dist/cjs/core/OutputManager.js.map +1 -0
- package/dist/cjs/core/ParserSelector.js +36 -0
- package/dist/cjs/core/ParserSelector.js.map +1 -0
- package/dist/cjs/core/ValidatorSelector.js +36 -0
- package/dist/cjs/core/ValidatorSelector.js.map +1 -0
- package/dist/cjs/core/splitCombinedArgvShorts.js +15 -0
- package/dist/cjs/core/splitCombinedArgvShorts.js.map +1 -0
- package/dist/cjs/db/AbstractJsonFileSection.js +190 -0
- package/dist/cjs/db/AbstractJsonFileSection.js.map +1 -0
- package/dist/cjs/db/AppDataSection.js +48 -0
- package/dist/cjs/db/AppDataSection.js.map +1 -0
- package/dist/cjs/db/ConfigSection.js +71 -0
- package/dist/cjs/db/ConfigSection.js.map +1 -0
- package/dist/cjs/db/JsonFile.js +55 -0
- package/dist/cjs/db/JsonFile.js.map +1 -0
- package/dist/cjs/db/PresetsSection.js +92 -0
- package/dist/cjs/db/PresetsSection.js.map +1 -0
- package/dist/cjs/index.js +119 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/opt/OptionArgumentParserSelector.js +16 -0
- package/dist/cjs/opt/OptionArgumentParserSelector.js.map +1 -0
- package/dist/cjs/opt/OptionArgumentValidatorSelector.js +19 -0
- package/dist/cjs/opt/OptionArgumentValidatorSelector.js.map +1 -0
- package/dist/cjs/opt/OptionBuilder.js +88 -0
- package/dist/cjs/opt/OptionBuilder.js.map +1 -0
- package/dist/cjs/opt/OptionHelpers.js +57 -0
- package/dist/cjs/opt/OptionHelpers.js.map +1 -0
- package/dist/cjs/opt/OptionReader.js +66 -0
- package/dist/cjs/opt/OptionReader.js.map +1 -0
- package/dist/cjs/types/IConfig.js +3 -0
- package/dist/cjs/types/IConfig.js.map +1 -0
- package/dist/cjs/types/IPreset.js +3 -0
- package/dist/cjs/types/IPreset.js.map +1 -0
- package/dist/cjs/util/array/arrLast.js +21 -0
- package/dist/cjs/util/array/arrLast.js.map +1 -0
- package/dist/cjs/util/array/arrSome.js +26 -0
- package/dist/cjs/util/array/arrSome.js.map +1 -0
- package/dist/cjs/util/array/types/ArrayPredicate.js +3 -0
- package/dist/cjs/util/array/types/ArrayPredicate.js.map +1 -0
- package/dist/cjs/util/db/JsonDB.js +145 -0
- package/dist/cjs/util/db/JsonDB.js.map +1 -0
- package/dist/cjs/util/errors/ErrorParser.js +164 -0
- package/dist/cjs/util/errors/ErrorParser.js.map +1 -0
- package/dist/cjs/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.js +3 -0
- package/dist/cjs/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.js.map +1 -0
- package/dist/cjs/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.js +32 -0
- package/dist/cjs/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.js.map +1 -0
- package/dist/cjs/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.js +25 -0
- package/dist/cjs/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.js.map +1 -0
- package/dist/cjs/util/fs/readFile/readFileSafeSync.js +28 -0
- package/dist/cjs/util/fs/readFile/readFileSafeSync.js.map +1 -0
- package/dist/cjs/util/fs/readFile/readFileSync.js +20 -0
- package/dist/cjs/util/fs/readFile/readFileSync.js.map +1 -0
- package/dist/cjs/util/fs/readJsonFile/readJsonFileSafeSync.js +24 -0
- package/dist/cjs/util/fs/readJsonFile/readJsonFileSafeSync.js.map +1 -0
- package/dist/cjs/util/fs/removeFile/removeFile.js +6 -0
- package/dist/cjs/util/fs/removeFile/removeFile.js.map +1 -0
- package/dist/cjs/util/fs/tempFile/tempFileSync.js +28 -0
- package/dist/cjs/util/fs/tempFile/tempFileSync.js.map +1 -0
- package/dist/cjs/util/fs/types/IReadJsonFileOptions.js +3 -0
- package/dist/cjs/util/fs/types/IReadJsonFileOptions.js.map +1 -0
- package/dist/cjs/util/fs/writeFile/writeFileSafeSync.js +6 -0
- package/dist/cjs/util/fs/writeFile/writeFileSafeSync.js.map +1 -0
- package/dist/cjs/util/fs/writeFile/writeFileSync.js +6 -0
- package/dist/cjs/util/fs/writeFile/writeFileSync.js.map +1 -0
- package/dist/cjs/util/fs/writeJsonFile/writeJsonFileSafe.js +6 -0
- package/dist/cjs/util/fs/writeJsonFile/writeJsonFileSafe.js.map +1 -0
- package/dist/cjs/util/function/MethodDisabler.js +94 -0
- package/dist/cjs/util/function/MethodDisabler.js.map +1 -0
- package/dist/cjs/util/function/funSetName.js +21 -0
- package/dist/cjs/util/function/funSetName.js.map +1 -0
- package/dist/cjs/util/node/execInherit.js +19 -0
- package/dist/cjs/util/node/execInherit.js.map +1 -0
- package/dist/cjs/util/node/formatTableForTerminal.js +21 -0
- package/dist/cjs/util/node/formatTableForTerminal.js.map +1 -0
- package/dist/cjs/util/object/arrAssign.js +6 -0
- package/dist/cjs/util/object/arrAssign.js.map +1 -0
- package/dist/cjs/util/object/createArrayMerger.js +20 -0
- package/dist/cjs/util/object/createArrayMerger.js.map +1 -0
- package/dist/cjs/util/object/createObjectMerger.js +20 -0
- package/dist/cjs/util/object/createObjectMerger.js.map +1 -0
- package/dist/cjs/util/object/objAssign.js +6 -0
- package/dist/cjs/util/object/objAssign.js.map +1 -0
- package/dist/cjs/util/object/objUpdatePropertyDescriptors.js +28 -0
- package/dist/cjs/util/object/objUpdatePropertyDescriptors.js.map +1 -0
- package/dist/cjs/util/object/realizeLazyProperty.js +14 -0
- package/dist/cjs/util/object/realizeLazyProperty.js.map +1 -0
- package/dist/cjs/util/object/setNonEnumerable.js +25 -0
- package/dist/cjs/util/object/setNonEnumerable.js.map +1 -0
- package/dist/cjs/util/os/defaultOpenInEditorCommand.js +18 -0
- package/dist/cjs/util/os/defaultOpenInEditorCommand.js.map +1 -0
- package/dist/cjs/util/os/isOSX.js +13 -0
- package/dist/cjs/util/os/isOSX.js.map +1 -0
- package/dist/cjs/util/os/isVsCodeInstalled.js +19 -0
- package/dist/cjs/util/os/isVsCodeInstalled.js.map +1 -0
- package/dist/cjs/util/os/isWindows.js +16 -0
- package/dist/cjs/util/os/isWindows.js.map +1 -0
- package/dist/cjs/util/path/getTempDataPath.js +20 -0
- package/dist/cjs/util/path/getTempDataPath.js.map +1 -0
- package/dist/cjs/util/regex/regexEscapeString.js +18 -0
- package/dist/cjs/util/regex/regexEscapeString.js.map +1 -0
- package/dist/cjs/util/string/strEnsureStartsWith.js +19 -0
- package/dist/cjs/util/string/strEnsureStartsWith.js.map +1 -0
- package/dist/cjs/util/string/strFirstCharToUpperCase.js +16 -0
- package/dist/cjs/util/string/strFirstCharToUpperCase.js.map +1 -0
- package/dist/cjs/util/string/strIsLowerCase.js +18 -0
- package/dist/cjs/util/string/strIsLowerCase.js.map +1 -0
- package/dist/cjs/util/string/strIsUpperCase.js +18 -0
- package/dist/cjs/util/string/strIsUpperCase.js.map +1 -0
- package/dist/cjs/util/string/strSplitCamelCase.js +55 -0
- package/dist/cjs/util/string/strSplitCamelCase.js.map +1 -0
- package/dist/cjs/util/string-parsers/createBooleanParser.js +21 -0
- package/dist/cjs/util/string-parsers/createBooleanParser.js.map +1 -0
- package/dist/cjs/util/string-parsers/createTypedListParser.js +22 -0
- package/dist/cjs/util/string-parsers/createTypedListParser.js.map +1 -0
- package/dist/cjs/util/string-parsers/parseBoolean.js +15 -0
- package/dist/cjs/util/string-parsers/parseBoolean.js.map +1 -0
- package/dist/cjs/util/string-parsers/parseInteger.js +17 -0
- package/dist/cjs/util/string-parsers/parseInteger.js.map +1 -0
- package/dist/cjs/util/string-parsers/parseNumber.js +13 -0
- package/dist/cjs/util/string-parsers/parseNumber.js.map +1 -0
- package/dist/cjs/util/string-parsers/parseString.js +8 -0
- package/dist/cjs/util/string-parsers/parseString.js.map +1 -0
- package/dist/cjs/util/types/Any.js +3 -0
- package/dist/cjs/util/types/Any.js.map +1 -0
- package/dist/cjs/util/types/DeepArray.js +3 -0
- package/dist/cjs/util/types/DeepArray.js.map +1 -0
- package/dist/cjs/util/types/DeepObject.js +3 -0
- package/dist/cjs/util/types/DeepObject.js.map +1 -0
- package/dist/cjs/util/types/JsonArray.js +3 -0
- package/dist/cjs/util/types/JsonArray.js.map +1 -0
- package/dist/cjs/util/types/JsonDefinedPrimitive.js +6 -0
- package/dist/cjs/util/types/JsonDefinedPrimitive.js.map +1 -0
- package/dist/cjs/util/types/JsonObject.js +3 -0
- package/dist/cjs/util/types/JsonObject.js.map +1 -0
- package/dist/cjs/util/types/JsonRawPrimitive.js +3 -0
- package/dist/cjs/util/types/JsonRawPrimitive.js.map +1 -0
- package/dist/cjs/util/types/JsonValue.js +3 -0
- package/dist/cjs/util/types/JsonValue.js.map +1 -0
- package/dist/cjs/util/types/ObjectKey.js +3 -0
- package/dist/cjs/util/types/ObjectKey.js.map +1 -0
- package/dist/cjs/util/types/TConstructor.js +3 -0
- package/dist/cjs/util/types/TConstructor.js.map +1 -0
- package/dist/cjs/util/types/TFunction.js +3 -0
- package/dist/cjs/util/types/TFunction.js.map +1 -0
- package/dist/cjs/util/types/TFunctionNoNew.js +3 -0
- package/dist/cjs/util/types/TFunctionNoNew.js.map +1 -0
- package/dist/cjs/util/types/TPlainObject.js +3 -0
- package/dist/cjs/util/types/TPlainObject.js.map +1 -0
- package/dist/cjs/util/types/TPrimitive.js +3 -0
- package/dist/cjs/util/types/TPrimitive.js.map +1 -0
- package/dist/cjs/util/types/TStringParser.js +3 -0
- package/dist/cjs/util/types/TStringParser.js.map +1 -0
- package/dist/cjs/util/types/TValidator.js +3 -0
- package/dist/cjs/util/types/TValidator.js.map +1 -0
- package/dist/cjs/util/validation/createTypedArrayValidator.js +26 -0
- package/dist/cjs/util/validation/createTypedArrayValidator.js.map +1 -0
- package/dist/cjs/util/validation/ensureThat.js +12 -0
- package/dist/cjs/util/validation/ensureThat.js.map +1 -0
- package/dist/cjs/util/validation/isArray.js +5 -0
- package/dist/cjs/util/validation/isArray.js.map +1 -0
- package/dist/cjs/util/validation/isBoolean.js +8 -0
- package/dist/cjs/util/validation/isBoolean.js.map +1 -0
- package/dist/cjs/util/validation/isFunction.js +17 -0
- package/dist/cjs/util/validation/isFunction.js.map +1 -0
- package/dist/cjs/util/validation/isNamedFunction.js +11 -0
- package/dist/cjs/util/validation/isNamedFunction.js.map +1 -0
- package/dist/cjs/util/validation/isNamedFunctionArray.js +9 -0
- package/dist/cjs/util/validation/isNamedFunctionArray.js.map +1 -0
- package/dist/cjs/util/validation/isObject.js +22 -0
- package/dist/cjs/util/validation/isObject.js.map +1 -0
- package/dist/cjs/util/validation/isPlainObject.js +19 -0
- package/dist/cjs/util/validation/isPlainObject.js.map +1 -0
- package/dist/cjs/util/validation/isPrimitive.js +18 -0
- package/dist/cjs/util/validation/isPrimitive.js.map +1 -0
- package/dist/cjs/util/validation/isString.js +8 -0
- package/dist/cjs/util/validation/isString.js.map +1 -0
- package/dist/cjs/util/validation/isStringArray.js +12 -0
- package/dist/cjs/util/validation/isStringArray.js.map +1 -0
- package/dist/cjs/util/validation/isStringWithNoSpacesOrDashes.js +9 -0
- package/dist/cjs/util/validation/isStringWithNoSpacesOrDashes.js.map +1 -0
- package/dist/cjs/util/validation/numbers/isInteger.js +17 -0
- package/dist/cjs/util/validation/numbers/isInteger.js.map +1 -0
- package/dist/cjs/util/validation/numbers/isValidNumber.js +22 -0
- package/dist/cjs/util/validation/numbers/isValidNumber.js.map +1 -0
- package/dist/esm/_example/bFindIn.js +187 -0
- package/dist/esm/_example/bFindIn.js.map +1 -0
- package/dist/esm/arg/ArgumentBuilder.js +41 -0
- package/dist/esm/arg/ArgumentBuilder.js.map +1 -0
- package/dist/esm/arg/ArgumentParserSelector.js +11 -0
- package/dist/esm/arg/ArgumentParserSelector.js.map +1 -0
- package/dist/esm/arg/ArgumentReader.js +34 -0
- package/dist/esm/arg/ArgumentReader.js.map +1 -0
- package/dist/esm/arg/ArgumentValidatorSelector.js +12 -0
- package/dist/esm/arg/ArgumentValidatorSelector.js.map +1 -0
- package/dist/esm/cmd/CommandBuilder.js +1073 -0
- package/dist/esm/cmd/CommandBuilder.js.map +1 -0
- package/dist/esm/cmd/CommandBuilderMetaData.js +40 -0
- package/dist/esm/cmd/CommandBuilderMetaData.js.map +1 -0
- package/dist/esm/cmd/CommandFeatureSelector.js +108 -0
- package/dist/esm/cmd/CommandFeatureSelector.js.map +1 -0
- package/dist/esm/cmd/DefaultHelpConfig.js +135 -0
- package/dist/esm/cmd/DefaultHelpConfig.js.map +1 -0
- package/dist/esm/cmd/asdas.js +25 -0
- package/dist/esm/cmd/asdas.js.map +1 -0
- package/dist/esm/core/OutputManager.js +92 -0
- package/dist/esm/core/OutputManager.js.map +1 -0
- package/dist/esm/core/ParserSelector.js +32 -0
- package/dist/esm/core/ParserSelector.js.map +1 -0
- package/dist/esm/core/ValidatorSelector.js +32 -0
- package/dist/esm/core/ValidatorSelector.js.map +1 -0
- package/dist/esm/core/splitCombinedArgvShorts.js +11 -0
- package/dist/esm/core/splitCombinedArgvShorts.js.map +1 -0
- package/dist/esm/db/AbstractJsonFileSection.js +186 -0
- package/dist/esm/db/AbstractJsonFileSection.js.map +1 -0
- package/dist/esm/db/AppDataSection.js +44 -0
- package/dist/esm/db/AppDataSection.js.map +1 -0
- package/dist/esm/db/ConfigSection.js +67 -0
- package/dist/esm/db/ConfigSection.js.map +1 -0
- package/dist/esm/db/JsonFile.js +51 -0
- package/dist/esm/db/JsonFile.js.map +1 -0
- package/dist/esm/db/PresetsSection.js +88 -0
- package/dist/esm/db/PresetsSection.js.map +1 -0
- package/dist/esm/index.js +103 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/opt/OptionArgumentParserSelector.js +12 -0
- package/dist/esm/opt/OptionArgumentParserSelector.js.map +1 -0
- package/dist/esm/opt/OptionArgumentValidatorSelector.js +15 -0
- package/dist/esm/opt/OptionArgumentValidatorSelector.js.map +1 -0
- package/dist/esm/opt/OptionBuilder.js +84 -0
- package/dist/esm/opt/OptionBuilder.js.map +1 -0
- package/dist/esm/opt/OptionHelpers.js +54 -0
- package/dist/esm/opt/OptionHelpers.js.map +1 -0
- package/dist/esm/opt/OptionReader.js +62 -0
- package/dist/esm/opt/OptionReader.js.map +1 -0
- package/dist/esm/types/IConfig.js +2 -0
- package/dist/esm/types/IConfig.js.map +1 -0
- package/dist/esm/types/IPreset.js +2 -0
- package/dist/esm/types/IPreset.js.map +1 -0
- package/dist/esm/util/array/arrLast.js +17 -0
- package/dist/esm/util/array/arrLast.js.map +1 -0
- package/dist/esm/util/array/arrSome.js +22 -0
- package/dist/esm/util/array/arrSome.js.map +1 -0
- package/dist/esm/util/array/types/ArrayPredicate.js +2 -0
- package/dist/esm/util/array/types/ArrayPredicate.js.map +1 -0
- package/dist/esm/util/db/JsonDB.js +141 -0
- package/dist/esm/util/db/JsonDB.js.map +1 -0
- package/dist/esm/util/errors/ErrorParser.js +154 -0
- package/dist/esm/util/errors/ErrorParser.js.map +1 -0
- package/dist/esm/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.js +2 -0
- package/dist/esm/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.js.map +1 -0
- package/dist/esm/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.js +28 -0
- package/dist/esm/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.js.map +1 -0
- package/dist/esm/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.js +21 -0
- package/dist/esm/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.js.map +1 -0
- package/dist/esm/util/fs/readFile/readFileSafeSync.js +21 -0
- package/dist/esm/util/fs/readFile/readFileSafeSync.js.map +1 -0
- package/dist/esm/util/fs/readFile/readFileSync.js +13 -0
- package/dist/esm/util/fs/readFile/readFileSync.js.map +1 -0
- package/dist/esm/util/fs/readJsonFile/readJsonFileSafeSync.js +17 -0
- package/dist/esm/util/fs/readJsonFile/readJsonFileSafeSync.js.map +1 -0
- package/dist/esm/util/fs/removeFile/removeFile.js +2 -0
- package/dist/esm/util/fs/removeFile/removeFile.js.map +1 -0
- package/dist/esm/util/fs/tempFile/tempFileSync.js +21 -0
- package/dist/esm/util/fs/tempFile/tempFileSync.js.map +1 -0
- package/dist/esm/util/fs/types/IReadJsonFileOptions.js +2 -0
- package/dist/esm/util/fs/types/IReadJsonFileOptions.js.map +1 -0
- package/dist/esm/util/fs/writeFile/writeFileSafeSync.js +2 -0
- package/dist/esm/util/fs/writeFile/writeFileSafeSync.js.map +1 -0
- package/dist/esm/util/fs/writeFile/writeFileSync.js +2 -0
- package/dist/esm/util/fs/writeFile/writeFileSync.js.map +1 -0
- package/dist/esm/util/fs/writeJsonFile/writeJsonFileSafe.js +2 -0
- package/dist/esm/util/fs/writeJsonFile/writeJsonFileSafe.js.map +1 -0
- package/dist/esm/util/function/MethodDisabler.js +90 -0
- package/dist/esm/util/function/MethodDisabler.js.map +1 -0
- package/dist/esm/util/function/funSetName.js +17 -0
- package/dist/esm/util/function/funSetName.js.map +1 -0
- package/dist/esm/util/node/execInherit.js +15 -0
- package/dist/esm/util/node/execInherit.js.map +1 -0
- package/dist/esm/util/node/formatTableForTerminal.js +14 -0
- package/dist/esm/util/node/formatTableForTerminal.js.map +1 -0
- package/dist/esm/util/object/arrAssign.js +3 -0
- package/dist/esm/util/object/arrAssign.js.map +1 -0
- package/dist/esm/util/object/createArrayMerger.js +16 -0
- package/dist/esm/util/object/createArrayMerger.js.map +1 -0
- package/dist/esm/util/object/createObjectMerger.js +16 -0
- package/dist/esm/util/object/createObjectMerger.js.map +1 -0
- package/dist/esm/util/object/objAssign.js +3 -0
- package/dist/esm/util/object/objAssign.js.map +1 -0
- package/dist/esm/util/object/objUpdatePropertyDescriptors.js +24 -0
- package/dist/esm/util/object/objUpdatePropertyDescriptors.js.map +1 -0
- package/dist/esm/util/object/realizeLazyProperty.js +10 -0
- package/dist/esm/util/object/realizeLazyProperty.js.map +1 -0
- package/dist/esm/util/object/setNonEnumerable.js +21 -0
- package/dist/esm/util/object/setNonEnumerable.js.map +1 -0
- package/dist/esm/util/os/defaultOpenInEditorCommand.js +14 -0
- package/dist/esm/util/os/defaultOpenInEditorCommand.js.map +1 -0
- package/dist/esm/util/os/isOSX.js +9 -0
- package/dist/esm/util/os/isOSX.js.map +1 -0
- package/dist/esm/util/os/isVsCodeInstalled.js +15 -0
- package/dist/esm/util/os/isVsCodeInstalled.js.map +1 -0
- package/dist/esm/util/os/isWindows.js +12 -0
- package/dist/esm/util/os/isWindows.js.map +1 -0
- package/dist/esm/util/path/getTempDataPath.js +13 -0
- package/dist/esm/util/path/getTempDataPath.js.map +1 -0
- package/dist/esm/util/regex/regexEscapeString.js +14 -0
- package/dist/esm/util/regex/regexEscapeString.js.map +1 -0
- package/dist/esm/util/string/strEnsureStartsWith.js +15 -0
- package/dist/esm/util/string/strEnsureStartsWith.js.map +1 -0
- package/dist/esm/util/string/strFirstCharToUpperCase.js +12 -0
- package/dist/esm/util/string/strFirstCharToUpperCase.js.map +1 -0
- package/dist/esm/util/string/strIsLowerCase.js +14 -0
- package/dist/esm/util/string/strIsLowerCase.js.map +1 -0
- package/dist/esm/util/string/strIsUpperCase.js +14 -0
- package/dist/esm/util/string/strIsUpperCase.js.map +1 -0
- package/dist/esm/util/string/strSplitCamelCase.js +51 -0
- package/dist/esm/util/string/strSplitCamelCase.js.map +1 -0
- package/dist/esm/util/string-parsers/createBooleanParser.js +17 -0
- package/dist/esm/util/string-parsers/createBooleanParser.js.map +1 -0
- package/dist/esm/util/string-parsers/createTypedListParser.js +18 -0
- package/dist/esm/util/string-parsers/createTypedListParser.js.map +1 -0
- package/dist/esm/util/string-parsers/parseBoolean.js +12 -0
- package/dist/esm/util/string-parsers/parseBoolean.js.map +1 -0
- package/dist/esm/util/string-parsers/parseInteger.js +13 -0
- package/dist/esm/util/string-parsers/parseInteger.js.map +1 -0
- package/dist/esm/util/string-parsers/parseNumber.js +9 -0
- package/dist/esm/util/string-parsers/parseNumber.js.map +1 -0
- package/dist/esm/util/string-parsers/parseString.js +4 -0
- package/dist/esm/util/string-parsers/parseString.js.map +1 -0
- package/dist/esm/util/types/Any.js +2 -0
- package/dist/esm/util/types/Any.js.map +1 -0
- package/dist/esm/util/types/DeepArray.js +2 -0
- package/dist/esm/util/types/DeepArray.js.map +1 -0
- package/dist/esm/util/types/DeepObject.js +2 -0
- package/dist/esm/util/types/DeepObject.js.map +1 -0
- package/dist/esm/util/types/JsonArray.js +2 -0
- package/dist/esm/util/types/JsonArray.js.map +1 -0
- package/dist/esm/util/types/JsonDefinedPrimitive.js +5 -0
- package/dist/esm/util/types/JsonDefinedPrimitive.js.map +1 -0
- package/dist/esm/util/types/JsonObject.js +2 -0
- package/dist/esm/util/types/JsonObject.js.map +1 -0
- package/dist/esm/util/types/JsonRawPrimitive.js +2 -0
- package/dist/esm/util/types/JsonRawPrimitive.js.map +1 -0
- package/dist/esm/util/types/JsonValue.js +2 -0
- package/dist/esm/util/types/JsonValue.js.map +1 -0
- package/dist/esm/util/types/ObjectKey.js +2 -0
- package/dist/esm/util/types/ObjectKey.js.map +1 -0
- package/dist/esm/util/types/TConstructor.js +2 -0
- package/dist/esm/util/types/TConstructor.js.map +1 -0
- package/dist/esm/util/types/TFunction.js +2 -0
- package/dist/esm/util/types/TFunction.js.map +1 -0
- package/dist/esm/util/types/TFunctionNoNew.js +2 -0
- package/dist/esm/util/types/TFunctionNoNew.js.map +1 -0
- package/dist/esm/util/types/TPlainObject.js +2 -0
- package/dist/esm/util/types/TPlainObject.js.map +1 -0
- package/dist/esm/util/types/TPrimitive.js +2 -0
- package/dist/esm/util/types/TPrimitive.js.map +1 -0
- package/dist/esm/util/types/TStringParser.js +2 -0
- package/dist/esm/util/types/TStringParser.js.map +1 -0
- package/dist/esm/util/types/TValidator.js +2 -0
- package/dist/esm/util/types/TValidator.js.map +1 -0
- package/dist/esm/util/validation/createTypedArrayValidator.js +22 -0
- package/dist/esm/util/validation/createTypedArrayValidator.js.map +1 -0
- package/dist/esm/util/validation/ensureThat.js +8 -0
- package/dist/esm/util/validation/ensureThat.js.map +1 -0
- package/dist/esm/util/validation/isArray.js +2 -0
- package/dist/esm/util/validation/isArray.js.map +1 -0
- package/dist/esm/util/validation/isBoolean.js +4 -0
- package/dist/esm/util/validation/isBoolean.js.map +1 -0
- package/dist/esm/util/validation/isFunction.js +13 -0
- package/dist/esm/util/validation/isFunction.js.map +1 -0
- package/dist/esm/util/validation/isNamedFunction.js +7 -0
- package/dist/esm/util/validation/isNamedFunction.js.map +1 -0
- package/dist/esm/util/validation/isNamedFunctionArray.js +5 -0
- package/dist/esm/util/validation/isNamedFunctionArray.js.map +1 -0
- package/dist/esm/util/validation/isObject.js +18 -0
- package/dist/esm/util/validation/isObject.js.map +1 -0
- package/dist/esm/util/validation/isPlainObject.js +15 -0
- package/dist/esm/util/validation/isPlainObject.js.map +1 -0
- package/dist/esm/util/validation/isPrimitive.js +14 -0
- package/dist/esm/util/validation/isPrimitive.js.map +1 -0
- package/dist/esm/util/validation/isString.js +4 -0
- package/dist/esm/util/validation/isString.js.map +1 -0
- package/dist/esm/util/validation/isStringArray.js +8 -0
- package/dist/esm/util/validation/isStringArray.js.map +1 -0
- package/dist/esm/util/validation/isStringWithNoSpacesOrDashes.js +5 -0
- package/dist/esm/util/validation/isStringWithNoSpacesOrDashes.js.map +1 -0
- package/dist/esm/util/validation/numbers/isInteger.js +14 -0
- package/dist/esm/util/validation/numbers/isInteger.js.map +1 -0
- package/dist/esm/util/validation/numbers/isValidNumber.js +18 -0
- package/dist/esm/util/validation/numbers/isValidNumber.js.map +1 -0
- package/dist/types/_example/bFindIn.d.ts +1 -0
- package/{src → dist/types}/arg/ArgumentBuilder.d.ts +1 -1
- package/{src → dist/types}/arg/ArgumentParserSelector.d.ts +2 -2
- package/{src → dist/types}/arg/ArgumentReader.d.ts +3 -3
- package/{src → dist/types}/arg/ArgumentValidatorSelector.d.ts +2 -2
- package/{src → dist/types}/cmd/CommandBuilder.d.ts +32 -28
- package/{src → dist/types}/cmd/CommandBuilderMetaData.d.ts +8 -7
- package/{src → dist/types}/cmd/CommandFeatureSelector.d.ts +1 -1
- package/dist/types/cmd/DefaultHelpConfig.d.ts +28 -0
- package/dist/types/cmd/asdas.d.ts +6 -0
- package/{src → dist/types}/core/OutputManager.d.ts +1 -1
- package/{src → dist/types}/core/ParserSelector.d.ts +3 -3
- package/{src → dist/types}/core/ValidatorSelector.d.ts +2 -2
- package/{src → dist/types}/db/AbstractJsonFileSection.d.ts +3 -3
- package/{src → dist/types}/db/AppDataSection.d.ts +1 -1
- package/{src → dist/types}/db/ConfigSection.d.ts +4 -4
- package/{src → dist/types}/db/PresetsSection.d.ts +2 -2
- package/{src → dist/types}/index.d.ts +2 -2
- package/{src → dist/types}/opt/OptionArgumentParserSelector.d.ts +1 -1
- package/{src → dist/types}/opt/OptionArgumentValidatorSelector.d.ts +2 -2
- package/{src → dist/types}/opt/OptionBuilder.d.ts +2 -1
- package/{src → dist/types}/opt/OptionHelpers.d.ts +2 -2
- package/{src → dist/types}/opt/OptionReader.d.ts +7 -7
- package/{src → dist/types}/types/IConfig.d.ts +3 -3
- package/{src → dist/types}/types/IPreset.d.ts +4 -3
- package/{src → dist/types}/util/db/JsonDB.d.ts +2 -2
- package/{src → dist/types}/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.d.ts +1 -1
- package/{src → dist/types}/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.d.ts +1 -1
- package/{src → dist/types}/util/fs/readJsonFile/readJsonFileSafeSync.d.ts +1 -1
- package/{src → dist/types}/util/fs/tempFile/tempFileSync.d.ts +1 -1
- package/{src → dist/types}/util/function/MethodDisabler.d.ts +3 -3
- package/{src → dist/types}/util/object/createObjectMerger.d.ts +1 -1
- package/{src → dist/types}/util/object/objUpdatePropertyDescriptors.d.ts +1 -1
- package/{src → dist/types}/util/object/setNonEnumerable.d.ts +1 -1
- package/{src → dist/types}/util/string-parsers/createTypedListParser.d.ts +1 -1
- package/{src → dist/types}/util/types/DeepArray.d.ts +2 -2
- package/{src → dist/types}/util/types/DeepObject.d.ts +2 -2
- package/{src → dist/types}/util/types/JsonArray.d.ts +2 -2
- package/{src → dist/types}/util/types/JsonObject.d.ts +2 -2
- package/{src → dist/types}/util/types/JsonRawPrimitive.d.ts +1 -1
- package/{src → dist/types}/util/types/JsonValue.d.ts +3 -3
- package/{src → dist/types}/util/types/TConstructor.d.ts +1 -1
- package/dist/types/util/types/TFunction.d.ts +4 -0
- package/{src → dist/types}/util/types/TFunctionNoNew.d.ts +1 -1
- package/{src → dist/types}/util/types/TPlainObject.d.ts +1 -1
- package/dist/types/util/types/TValidator.d.ts +2 -0
- package/{src → dist/types}/util/validation/ensureThat.d.ts +2 -2
- package/{src → dist/types}/util/validation/isFunction.d.ts +1 -1
- package/{src → dist/types}/util/validation/isNamedFunction.d.ts +1 -1
- package/{src → dist/types}/util/validation/isPlainObject.d.ts +2 -2
- package/{src → dist/types}/util/validation/isPrimitive.d.ts +1 -1
- package/jest.config.ts +11 -0
- package/notes/tsc.md +1 -0
- package/package.json +13 -6
- package/project.json +44 -0
- package/scripts/currentBemojeUtils.txt +41 -0
- package/scripts/rollupUtils.ts +184 -0
- package/src/_example/CommandBuilder.example.ts +92 -0
- package/src/_example/CommandBuilder.example2.ts +30 -0
- package/src/_example/bFindIn.ts +200 -0
- package/src/arg/ArgumentBuilder.test.ts +102 -0
- package/src/arg/ArgumentBuilder.ts +47 -0
- package/src/arg/ArgumentParserSelector.test.ts +53 -0
- package/src/arg/ArgumentParserSelector.ts +14 -0
- package/src/arg/ArgumentReader.test.ts +60 -0
- package/src/arg/ArgumentReader.ts +33 -0
- package/src/arg/ArgumentValidatorSelector.test.ts +80 -0
- package/src/arg/ArgumentValidatorSelector.ts +14 -0
- package/src/cmd/CommandBuilder.test.ts +611 -0
- package/src/cmd/CommandBuilder.ts +1164 -0
- package/src/cmd/CommandBuilderMetaData.test.ts +54 -0
- package/src/cmd/CommandBuilderMetaData.ts +45 -0
- package/src/cmd/CommandFeatureSelector.test.ts +185 -0
- package/src/cmd/CommandFeatureSelector.ts +113 -0
- package/src/cmd/DefaultHelpConfig.test.ts +22 -0
- package/src/cmd/DefaultHelpConfig.ts +141 -0
- package/src/cmd/asdas.ts +40 -0
- package/src/core/OutputManager.test.ts +129 -0
- package/src/core/OutputManager.ts +103 -0
- package/src/core/ParserSelector.test.ts +7 -0
- package/src/core/ParserSelector.ts +38 -0
- package/src/core/ValidatorSelector.test.ts +7 -0
- package/src/core/ValidatorSelector.ts +38 -0
- package/src/core/splitCombinedArgvShorts.test.ts +9 -0
- package/src/core/splitCombinedArgvShorts.ts +10 -0
- package/src/db/AbstractJsonFileSection.test.ts +274 -0
- package/src/db/AbstractJsonFileSection.ts +218 -0
- package/src/db/AppDataSection.test.ts +69 -0
- package/src/db/AppDataSection.ts +46 -0
- package/src/db/ConfigSection.test.ts +95 -0
- package/src/db/ConfigSection.ts +74 -0
- package/src/db/JsonFile.test.ts +56 -0
- package/src/db/JsonFile.ts +52 -0
- package/src/db/PresetsSection.test.ts +130 -0
- package/src/db/PresetsSection.ts +92 -0
- package/src/index.ts +102 -0
- package/src/opt/OptionArgumentParserSelector.test.ts +55 -0
- package/src/opt/OptionArgumentParserSelector.ts +14 -0
- package/src/opt/OptionArgumentValidatorSelector.test.ts +89 -0
- package/src/opt/OptionArgumentValidatorSelector.ts +16 -0
- package/src/opt/OptionBuilder.test.ts +229 -0
- package/src/opt/OptionBuilder.ts +85 -0
- package/src/opt/OptionHelpers.test.ts +229 -0
- package/src/opt/OptionHelpers.ts +57 -0
- package/src/opt/OptionReader.test.ts +106 -0
- package/src/opt/OptionReader.ts +61 -0
- package/src/types/IConfig.ts +25 -0
- package/src/types/IPreset.ts +16 -0
- package/src/util/array/arrLast.test.ts +25 -0
- package/src/util/array/arrLast.ts +15 -0
- package/src/util/array/arrSome.test.ts +78 -0
- package/src/util/array/arrSome.ts +23 -0
- package/src/util/array/types/ArrayPredicate.ts +10 -0
- package/src/util/db/JsonDB.test.ts +214 -0
- package/src/util/db/JsonDB.ts +138 -0
- package/src/util/errors/ErrorParser.ts +165 -0
- package/src/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.ts +15 -0
- package/src/util/fs/promptUserEditInTextEditor/promptUserEditInTextEditorSync.ts +30 -0
- package/src/util/fs/promptUserEditInTextEditor/promptUserEditJsonInTextEditorSync.ts +25 -0
- package/src/util/fs/readFile/readFileSafeSync.ts +20 -0
- package/src/util/fs/readFile/readFileSync.ts +13 -0
- package/src/util/fs/readJsonFile/readJsonFileSafeSync.ts +17 -0
- package/src/util/fs/removeFile/removeFile.ts +1 -0
- package/src/util/fs/tempFile/tempFileSync.ts +21 -0
- package/src/util/fs/types/IReadJsonFileOptions.ts +1 -0
- package/src/util/fs/writeFile/writeFileSafeSync.ts +1 -0
- package/src/util/fs/writeFile/writeFileSync.ts +1 -0
- package/src/util/fs/writeJsonFile/writeJsonFileSafe.ts +1 -0
- package/src/util/function/MethodDisabler.test.ts +112 -0
- package/src/util/function/MethodDisabler.ts +94 -0
- package/src/util/function/funSetName.test.ts +12 -0
- package/src/util/function/funSetName.ts +16 -0
- package/src/util/node/execInherit.ts +14 -0
- package/src/util/node/formatTableForTerminal.ts +12 -0
- package/src/util/object/arrAssign.ts +3 -0
- package/src/util/object/createArrayMerger.test.ts +11 -0
- package/src/util/object/createArrayMerger.ts +15 -0
- package/src/util/object/createObjectMerger.test.ts +11 -0
- package/src/util/object/createObjectMerger.ts +17 -0
- package/src/util/object/objAssign.ts +3 -0
- package/src/util/object/objUpdatePropertyDescriptors.test.ts +40 -0
- package/src/util/object/objUpdatePropertyDescriptors.ts +29 -0
- package/src/util/object/realizeLazyProperty.ts +9 -0
- package/src/util/object/setNonEnumerable.test.ts +63 -0
- package/src/util/object/setNonEnumerable.ts +22 -0
- package/src/util/os/defaultOpenInEditorCommand.ts +14 -0
- package/src/util/os/isOSX.ts +9 -0
- package/src/util/os/isVsCodeInstalled.test.ts +7 -0
- package/src/util/os/isVsCodeInstalled.ts +14 -0
- package/src/util/os/isWindows.ts +12 -0
- package/src/util/path/getTempDataPath.test.ts +9 -0
- package/src/util/path/getTempDataPath.ts +14 -0
- package/src/util/regex/regexEscapeString.test.ts +35 -0
- package/src/util/regex/regexEscapeString.ts +13 -0
- package/src/util/string/strEnsureStartsWith.test.ts +13 -0
- package/src/util/string/strEnsureStartsWith.ts +14 -0
- package/src/util/string/strFirstCharToUpperCase.test.ts +33 -0
- package/src/util/string/strFirstCharToUpperCase.ts +11 -0
- package/src/util/string/strIsLowerCase.test.ts +42 -0
- package/src/util/string/strIsLowerCase.ts +13 -0
- package/src/util/string/strIsUpperCase.test.ts +48 -0
- package/src/util/string/strIsUpperCase.ts +13 -0
- package/src/util/string/strSplitCamelCase.test.ts +54 -0
- package/src/util/string/strSplitCamelCase.ts +51 -0
- package/src/util/string-parsers/createBooleanParser.test.ts +58 -0
- package/src/util/string-parsers/createBooleanParser.ts +21 -0
- package/src/util/string-parsers/createTypedListParser.test.ts +19 -0
- package/src/util/string-parsers/createTypedListParser.ts +19 -0
- package/src/util/string-parsers/parseBoolean.test.ts +30 -0
- package/src/util/string-parsers/parseBoolean.ts +12 -0
- package/src/util/string-parsers/parseInteger.test.ts +52 -0
- package/src/util/string-parsers/parseInteger.ts +9 -0
- package/src/util/string-parsers/parseNumber.test.ts +53 -0
- package/src/util/string-parsers/parseNumber.ts +6 -0
- package/src/util/string-parsers/parseString.test.ts +7 -0
- package/src/util/string-parsers/parseString.ts +3 -0
- package/src/util/types/Any.ts +2 -0
- package/src/util/types/DeepArray.ts +12 -0
- package/src/util/types/DeepObject.ts +16 -0
- package/src/util/types/JsonArray.ts +8 -0
- package/src/util/types/JsonDefinedPrimitive.ts +5 -0
- package/src/util/types/JsonObject.ts +8 -0
- package/src/util/types/JsonRawPrimitive.ts +7 -0
- package/src/util/types/JsonValue.ts +14 -0
- package/src/util/types/ObjectKey.ts +1 -0
- package/src/util/types/TConstructor.ts +6 -0
- package/src/util/types/TFunction.ts +5 -0
- package/src/util/types/TFunctionNoNew.ts +3 -0
- package/src/util/types/TPlainObject.ts +4 -0
- package/src/util/types/TPrimitive.ts +1 -0
- package/src/util/types/TStringParser.ts +1 -0
- package/src/util/types/TValidator.ts +3 -0
- package/src/util/validation/createTypedArrayValidator.test.ts +34 -0
- package/src/util/validation/createTypedArrayValidator.ts +25 -0
- package/src/util/validation/ensureThat.test.ts +37 -0
- package/src/util/validation/ensureThat.ts +14 -0
- package/src/util/validation/isArray.test.ts +7 -0
- package/src/util/validation/isArray.ts +1 -0
- package/src/util/validation/isBoolean.test.ts +31 -0
- package/src/util/validation/isBoolean.ts +3 -0
- package/src/util/validation/isFunction.test.ts +54 -0
- package/src/util/validation/isFunction.ts +14 -0
- package/src/util/validation/isNamedFunction.test.ts +28 -0
- package/src/util/validation/isNamedFunction.ts +8 -0
- package/src/util/validation/isNamedFunctionArray.test.ts +14 -0
- package/src/util/validation/isNamedFunctionArray.ts +5 -0
- package/src/util/validation/isObject.test.ts +57 -0
- package/src/util/validation/isObject.ts +17 -0
- package/src/util/validation/isPlainObject.test.ts +21 -0
- package/src/util/validation/isPlainObject.ts +14 -0
- package/src/util/validation/isPrimitive.ts +15 -0
- package/src/util/validation/isString.test.ts +23 -0
- package/src/util/validation/isString.ts +3 -0
- package/src/util/validation/isStringArray.test.ts +24 -0
- package/src/util/validation/isStringArray.ts +8 -0
- package/src/util/validation/isStringWithNoSpacesOrDashes.test.ts +28 -0
- package/src/util/validation/isStringWithNoSpacesOrDashes.ts +5 -0
- package/src/util/validation/numbers/isInteger.test.ts +25 -0
- package/src/util/validation/numbers/isInteger.ts +13 -0
- package/src/util/validation/numbers/isValidNumber.test.ts +20 -0
- package/src/util/validation/numbers/isValidNumber.ts +17 -0
- package/tsconfig.json +32 -0
- package/tsconfig.lib.json +18 -0
- package/tsconfig.spec.json +10 -0
- package/index.cjs.d.ts +0 -1
- package/index.cjs.js +0 -3231
- package/index.esm.js +0 -3119
- package/src/cmd/CLI.d.ts +0 -2
- package/src/cmd/DefaultHelpConfig.d.ts +0 -2
- package/src/proto/overrideCommanderPrototype.d.ts +0 -8
- package/src/util/types/TFunction.d.ts +0 -4
- package/src/util/types/TValidator.d.ts +0 -1
- /package/{src → dist/types}/core/splitCombinedArgvShorts.d.ts +0 -0
- /package/{src → dist/types}/db/JsonFile.d.ts +0 -0
- /package/{src → dist/types}/util/array/arrLast.d.ts +0 -0
- /package/{src → dist/types}/util/array/arrSome.d.ts +0 -0
- /package/{src → dist/types}/util/array/types/ArrayPredicate.d.ts +0 -0
- /package/{src → dist/types}/util/errors/ErrorParser.d.ts +0 -0
- /package/{src → dist/types}/util/fs/promptUserEditInTextEditor/IGetUserInputFromEditorOptions.d.ts +0 -0
- /package/{src → dist/types}/util/fs/readFile/readFileSafeSync.d.ts +0 -0
- /package/{src → dist/types}/util/fs/readFile/readFileSync.d.ts +0 -0
- /package/{src → dist/types}/util/fs/removeFile/removeFile.d.ts +0 -0
- /package/{src → dist/types}/util/fs/types/IReadJsonFileOptions.d.ts +0 -0
- /package/{src → dist/types}/util/fs/writeFile/writeFileSafeSync.d.ts +0 -0
- /package/{src → dist/types}/util/fs/writeFile/writeFileSync.d.ts +0 -0
- /package/{src → dist/types}/util/fs/writeJsonFile/writeJsonFileSafe.d.ts +0 -0
- /package/{src → dist/types}/util/function/funSetName.d.ts +0 -0
- /package/{src → dist/types}/util/node/execInherit.d.ts +0 -0
- /package/{src → dist/types}/util/node/formatTableForTerminal.d.ts +0 -0
- /package/{src → dist/types}/util/object/arrAssign.d.ts +0 -0
- /package/{src → dist/types}/util/object/createArrayMerger.d.ts +0 -0
- /package/{src → dist/types}/util/object/objAssign.d.ts +0 -0
- /package/{src → dist/types}/util/object/realizeLazyProperty.d.ts +0 -0
- /package/{src → dist/types}/util/os/defaultOpenInEditorCommand.d.ts +0 -0
- /package/{src → dist/types}/util/os/isOSX.d.ts +0 -0
- /package/{src → dist/types}/util/os/isVsCodeInstalled.d.ts +0 -0
- /package/{src → dist/types}/util/os/isWindows.d.ts +0 -0
- /package/{src → dist/types}/util/path/getTempDataPath.d.ts +0 -0
- /package/{src → dist/types}/util/regex/regexEscapeString.d.ts +0 -0
- /package/{src → dist/types}/util/string/strEnsureStartsWith.d.ts +0 -0
- /package/{src → dist/types}/util/string/strFirstCharToUpperCase.d.ts +0 -0
- /package/{src → dist/types}/util/string/strIsLowerCase.d.ts +0 -0
- /package/{src → dist/types}/util/string/strIsUpperCase.d.ts +0 -0
- /package/{src → dist/types}/util/string/strSplitCamelCase.d.ts +0 -0
- /package/{src → dist/types}/util/string-parsers/createBooleanParser.d.ts +0 -0
- /package/{src → dist/types}/util/string-parsers/parseBoolean.d.ts +0 -0
- /package/{src → dist/types}/util/string-parsers/parseInteger.d.ts +0 -0
- /package/{src → dist/types}/util/string-parsers/parseNumber.d.ts +0 -0
- /package/{src → dist/types}/util/string-parsers/parseString.d.ts +0 -0
- /package/{src → dist/types}/util/types/Any.d.ts +0 -0
- /package/{src → dist/types}/util/types/JsonDefinedPrimitive.d.ts +0 -0
- /package/{src → dist/types}/util/types/ObjectKey.d.ts +0 -0
- /package/{src → dist/types}/util/types/TPrimitive.d.ts +0 -0
- /package/{src → dist/types}/util/types/TStringParser.d.ts +0 -0
- /package/{src → dist/types}/util/validation/createTypedArrayValidator.d.ts +0 -0
- /package/{src → dist/types}/util/validation/isArray.d.ts +0 -0
- /package/{src → dist/types}/util/validation/isBoolean.d.ts +0 -0
- /package/{src → dist/types}/util/validation/isNamedFunctionArray.d.ts +0 -0
- /package/{src → dist/types}/util/validation/isObject.d.ts +0 -0
- /package/{src → dist/types}/util/validation/isString.d.ts +0 -0
- /package/{src → dist/types}/util/validation/isStringArray.d.ts +0 -0
- /package/{src → dist/types}/util/validation/isStringWithNoSpacesOrDashes.d.ts +0 -0
- /package/{src → dist/types}/util/validation/numbers/isInteger.d.ts +0 -0
- /package/{src → dist/types}/util/validation/numbers/isValidNumber.d.ts +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import colors from 'ansi-colors'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import type { Any } from '../types/Any'
|
|
4
|
+
import { isPlainObject } from '../validation/isPlainObject'
|
|
5
|
+
import { isPrimitive } from '../validation/isPrimitive'
|
|
6
|
+
import { regexEscapeString } from '../regex/regexEscapeString'
|
|
7
|
+
|
|
8
|
+
export class ErrorParser {
|
|
9
|
+
readonly error: Error
|
|
10
|
+
|
|
11
|
+
constructor(error: unknown) {
|
|
12
|
+
this.error = error instanceof Error ? error : new Error(String(error))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get name() {
|
|
16
|
+
return this.error.name
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get message() {
|
|
20
|
+
return this.error.message
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get stack(): string {
|
|
24
|
+
return this.error.stack || ''
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
summary() {
|
|
28
|
+
return this.name + ': ' + this.message
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
parseStackFrames() {
|
|
32
|
+
return errParseStack(this.stack)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
prettyStack(parsedStackFrames?: [string, string][]) {
|
|
36
|
+
return errPrettyStack(this.error, parsedStackFrames)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
toObject() {
|
|
40
|
+
return errToObject(this.error)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toJSON() {
|
|
44
|
+
return this.toObject()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function errPrettyStack(error: Error, parsedStackFrames?: [string, string][]) {
|
|
49
|
+
const frames = parsedStackFrames ?? errParseStack(error.stack || '')
|
|
50
|
+
|
|
51
|
+
// width of the first column = the longest frame.cell string
|
|
52
|
+
const offset = 2 + frames.reduce((acc: number, frame) => Math.max(acc, frame[0].length), 0)
|
|
53
|
+
|
|
54
|
+
// type and message
|
|
55
|
+
const result = [
|
|
56
|
+
colors.bold(colors.red(error.name)) +
|
|
57
|
+
': ' +
|
|
58
|
+
' '.repeat(Math.max(0, offset - error.name.length)) +
|
|
59
|
+
colors.red(error.message),
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
// stack trace
|
|
63
|
+
result.push(colors.yellow('stack') + ':')
|
|
64
|
+
result.push(
|
|
65
|
+
frames
|
|
66
|
+
.map((frame: [string, string]) => {
|
|
67
|
+
const [call, file] = frame
|
|
68
|
+
let s = ' '
|
|
69
|
+
let fp: string
|
|
70
|
+
if (file.startsWith('node:')) {
|
|
71
|
+
s += colors.gray(call)
|
|
72
|
+
fp = colors.gray(file)
|
|
73
|
+
} else if (file.includes('node_modules')) {
|
|
74
|
+
s += call
|
|
75
|
+
const base = path.basename(file.split(':')[0])
|
|
76
|
+
fp = file.replace(base, colors.yellow(base))
|
|
77
|
+
} else {
|
|
78
|
+
s += call
|
|
79
|
+
const base = path.basename(file.split(':')[0])
|
|
80
|
+
fp = file.replace(base, colors.red(base))
|
|
81
|
+
}
|
|
82
|
+
s += ' '.repeat(offset - call.length)
|
|
83
|
+
s += fp
|
|
84
|
+
return s
|
|
85
|
+
})
|
|
86
|
+
.join('\n')
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
// other properties
|
|
90
|
+
const ignore = ['name', 'message', 'frames', 'stack']
|
|
91
|
+
const keys = Object.getOwnPropertyNames(error).filter((key) => !ignore.includes(key))
|
|
92
|
+
for (const k of keys) {
|
|
93
|
+
if (typeof k === 'symbol') continue
|
|
94
|
+
const key = k as keyof typeof error
|
|
95
|
+
let s = colors.yellow(key.toString()) + ': '
|
|
96
|
+
if (isPlainObject(error[key])) {
|
|
97
|
+
const json = JSON.stringify(error[key], null, 2)
|
|
98
|
+
if (json.length < 350) {
|
|
99
|
+
s += JSON.stringify(error[key], null, 2)
|
|
100
|
+
.split('\n')
|
|
101
|
+
.map((line: string) => {
|
|
102
|
+
const arr = line.split('": ')
|
|
103
|
+
arr[0] = colors.gray(arr[0].replace('"', ''))
|
|
104
|
+
return arr.join(': ')
|
|
105
|
+
})
|
|
106
|
+
.join('\n')
|
|
107
|
+
} else {
|
|
108
|
+
s += JSON.stringify(error[key])
|
|
109
|
+
}
|
|
110
|
+
} else if (isPrimitive(error[key])) {
|
|
111
|
+
s += String(error[key])
|
|
112
|
+
} else if (error[key] != null && typeof error[key] === 'object') {
|
|
113
|
+
s += (error[key] as Any).toString()
|
|
114
|
+
} else {
|
|
115
|
+
s += JSON.stringify(error[key])
|
|
116
|
+
}
|
|
117
|
+
result.push(s.trim())
|
|
118
|
+
}
|
|
119
|
+
return '\n' + result.join('\n') + '\n'
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function errParseStack(stack: string): [string, string][] {
|
|
123
|
+
if (!stack) return []
|
|
124
|
+
const nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i
|
|
125
|
+
const recwd = new RegExp('^' + regexEscapeString(process.cwd() + path.sep), 'i')
|
|
126
|
+
const frames: [string, string][] = []
|
|
127
|
+
for (const line of stack.split('\n')) {
|
|
128
|
+
const parts = nodeRe.exec(line)
|
|
129
|
+
if (!parts) continue
|
|
130
|
+
frames.push([
|
|
131
|
+
parts[1] || '<unknown>',
|
|
132
|
+
`${(parts[2] || '').replace(recwd, '').replace(/\\\\?/g, '/')}:${+parts[3]}:${parts[4] ? +parts[4] : null}`,
|
|
133
|
+
])
|
|
134
|
+
}
|
|
135
|
+
return frames
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function errToObject(error: Error) {
|
|
139
|
+
const own = Object.getOwnPropertyNames(error).filter((key) => typeof key === 'string')
|
|
140
|
+
const keys = new Set(['name', 'message', 'frames', ...own])
|
|
141
|
+
keys.delete('stack')
|
|
142
|
+
const entries = Array.from(keys)
|
|
143
|
+
.filter((key) => error[key as keyof Error] !== undefined)
|
|
144
|
+
.map((key) => [key, error[key as keyof Error]])
|
|
145
|
+
return Object.fromEntries(entries)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// try {
|
|
149
|
+
// throw new TypeError('wow ok oops')
|
|
150
|
+
// } catch (error) {
|
|
151
|
+
// const err = new ErrorParser(error)
|
|
152
|
+
// console.log('----------------------')
|
|
153
|
+
// console.log({
|
|
154
|
+
// name: err.name,
|
|
155
|
+
// message: err.message,
|
|
156
|
+
// summary: err.summary,
|
|
157
|
+
// })
|
|
158
|
+
// console.log('----------------------')
|
|
159
|
+
// console.log(err.stack)
|
|
160
|
+
// console.log('----------------------')
|
|
161
|
+
// console.log(err.prettyStack())
|
|
162
|
+
// console.log('----------------------')
|
|
163
|
+
// console.log(err.toObject())
|
|
164
|
+
// console.log('----------------------')
|
|
165
|
+
// }
|
|
@@ -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,30 @@
|
|
|
1
|
+
import { defaultOpenInEditorCommand } from '../../os/defaultOpenInEditorCommand'
|
|
2
|
+
import { execSync } from 'child_process'
|
|
3
|
+
import type { IGetUserInputFromEditorOptions } from './IGetUserInputFromEditorOptions'
|
|
4
|
+
import { readFileSync } from '../readFile/readFileSync'
|
|
5
|
+
import { strEnsureStartsWith } from '../../string/strEnsureStartsWith'
|
|
6
|
+
import { tempFileSync } from '../tempFile/tempFileSync'
|
|
7
|
+
import { writeFileSync } from '../writeFile/writeFileSync'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Prompts the user to edit a string in the user's text editor.
|
|
11
|
+
*
|
|
12
|
+
* @example ```ts
|
|
13
|
+
* promptUserEditInTextEditor({ editor: 'notepad' })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export function promptUserEditInTextEditorSync(options?: IGetUserInputFromEditorOptions): string {
|
|
17
|
+
const { editor, content, extension } = applyDefaults(options)
|
|
18
|
+
return tempFileSync(extension, (tempfile) => {
|
|
19
|
+
writeFileSync(tempfile, content)
|
|
20
|
+
execSync(`${editor} ${tempfile}`, { stdio: 'inherit' })
|
|
21
|
+
return readFileSync(tempfile)
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function applyDefaults(options: IGetUserInputFromEditorOptions = {}) {
|
|
26
|
+
const content = options.content ?? ''
|
|
27
|
+
const extension = strEnsureStartsWith(options.extension ?? '.txt', '.')
|
|
28
|
+
const editor = options.editor ?? defaultOpenInEditorCommand()
|
|
29
|
+
return { content, extension, editor }
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { JsonValue } from '../../types/JsonValue'
|
|
2
|
+
import { promptUserEditInTextEditorSync } from './promptUserEditInTextEditorSync'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Edit a JSON-stringify-compatible value in the user's editor and return the (JSON.parse'd) result.
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to edit (NOT a json string). Defaults to an empty object.
|
|
8
|
+
* @param editor - Launch command to start your editor. Defaults to VSCode: 'code -w' (if installed).
|
|
9
|
+
* - Otherwise this logic: isWindows() ? 'notepad' : isOSX() ? 'open vi' : 'xdg-open'
|
|
10
|
+
*
|
|
11
|
+
* @example ```ts
|
|
12
|
+
* promptUserEditJsonInTextEditorSync([1, 2])
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function promptUserEditJsonInTextEditorSync<T extends JsonValue = JsonValue, R extends T = T>(
|
|
16
|
+
value: T = {} as T,
|
|
17
|
+
editor?: string
|
|
18
|
+
): R {
|
|
19
|
+
const json = promptUserEditInTextEditorSync({
|
|
20
|
+
editor,
|
|
21
|
+
content: JSON.stringify(value, null, 2),
|
|
22
|
+
extension: '.json',
|
|
23
|
+
})
|
|
24
|
+
return JSON.parse(json) as R
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reads a file and returns the file's contents.
|
|
5
|
+
*
|
|
6
|
+
* Identical to fs.readFileSync, except that:
|
|
7
|
+
* - it uses utf8 encoding by default
|
|
8
|
+
* - if operation fails, returns undefined instead of throwing
|
|
9
|
+
*
|
|
10
|
+
* @param filepath - The path to the file.
|
|
11
|
+
* @param encoding - The encoding to use when reading the file.
|
|
12
|
+
* @returns The file's contents or undefined if the file does not exist.
|
|
13
|
+
*/
|
|
14
|
+
export function readFileSafeSync(filepath: string, encoding: BufferEncoding = 'utf8'): string | undefined {
|
|
15
|
+
try {
|
|
16
|
+
return fs.readFileSync(filepath, encoding)
|
|
17
|
+
} catch (error) {
|
|
18
|
+
return undefined
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reads a file and returns the file's contents.
|
|
5
|
+
* Identical to fs.readFileSync, except that it uses utf8 encoding by default.
|
|
6
|
+
*
|
|
7
|
+
* @param filepath - The path to the file.
|
|
8
|
+
* @param encoding - The encoding to use when reading the file.
|
|
9
|
+
* @returns The file's contents.
|
|
10
|
+
*/
|
|
11
|
+
export function readFileSync(filepath: string, encoding: BufferEncoding = 'utf8'): string {
|
|
12
|
+
return fs.readFileSync(filepath, encoding)
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import type { IReadJsonFileOptions } from '../types/IReadJsonFileOptions'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reads a JSON file and then parses it into an object.
|
|
6
|
+
* If an error occurs, it returns undefined.
|
|
7
|
+
*
|
|
8
|
+
* @param filepath - The path to the JSON file.
|
|
9
|
+
* @param options - Options for reading the JSON file.
|
|
10
|
+
*/
|
|
11
|
+
export function readJsonFileSafeSync<T>(filepath: string, options?: IReadJsonFileOptions): T | undefined {
|
|
12
|
+
try {
|
|
13
|
+
return fs.readJsonSync(filepath, options) as T
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return undefined
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { remove as removeFile } from 'fs-extra'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import type { Any } from '../../types/Any'
|
|
3
|
+
import { getTempDataPath } from '../../path/getTempDataPath'
|
|
4
|
+
import { strEnsureStartsWith } from '../../string/strEnsureStartsWith'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Syncrhonously creates a temporary file and deletes it after the callback has finished.
|
|
8
|
+
* @param fileExtension - The file extension to use for the temporary file.
|
|
9
|
+
* @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.
|
|
10
|
+
*/
|
|
11
|
+
export function tempFileSync(fileExtension: string, callback: (fpath: string) => Any) {
|
|
12
|
+
const fpath = getTempDataPath('temp', Date.now() + strEnsureStartsWith(fileExtension, '.'))
|
|
13
|
+
fs.ensureFileSync(fpath)
|
|
14
|
+
try {
|
|
15
|
+
const retval = callback(fpath)
|
|
16
|
+
fs.remove(fpath)
|
|
17
|
+
return retval
|
|
18
|
+
} catch (error) {
|
|
19
|
+
fs.remove(fpath)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -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'
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { Any } from '../types/Any'
|
|
3
|
+
import { MethodDisabler } from './MethodDisabler'
|
|
4
|
+
import { ObjectKey } from '../types/ObjectKey'
|
|
5
|
+
|
|
6
|
+
describe(MethodDisabler.name, () => {
|
|
7
|
+
it('TSDOC @example', () => {
|
|
8
|
+
expect(() => {
|
|
9
|
+
const md = new MethodDisabler(process.stdout, 'write')
|
|
10
|
+
|
|
11
|
+
md.disable()
|
|
12
|
+
assert(!md.isEnabled)
|
|
13
|
+
console.log('This will not print')
|
|
14
|
+
|
|
15
|
+
md.enable()
|
|
16
|
+
assert(md.isEnabled)
|
|
17
|
+
// console.log('This will print')
|
|
18
|
+
|
|
19
|
+
assert(md.original === process.stdout.write)
|
|
20
|
+
}).not.toThrow()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
describe('constructor', () => {
|
|
24
|
+
it('instanceof ' + MethodDisabler.name, () => {
|
|
25
|
+
expect(new MethodDisabler(Array.prototype, 'sort')).toBeInstanceOf(MethodDisabler)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('throws if not function', () => {
|
|
29
|
+
expect(() => new MethodDisabler(Array.prototype, 'length')).toThrow()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('original', () => {
|
|
33
|
+
expect(new MethodDisabler(Array.prototype, 'sort').original).toBe(Array.prototype['sort'])
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('memoize', () => {
|
|
37
|
+
const ins = new MethodDisabler(Map.prototype, 'set')
|
|
38
|
+
expect(ins).toBe(new MethodDisabler(Map.prototype, 'set'))
|
|
39
|
+
expect(ins).not.toBe(new MethodDisabler(Map.prototype, 'get'))
|
|
40
|
+
expect(ins).not.toBe(new MethodDisabler(WeakMap.prototype, 'set'))
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
type Obj = Record<ObjectKey, Any>
|
|
45
|
+
type BfOpts = { obj: Obj; key: string }
|
|
46
|
+
type Opts = { ins: MethodDisabler; obj: Obj; key: string; spy?: jest.SpyInstance }
|
|
47
|
+
|
|
48
|
+
const createMock = (opts: BfOpts) => {
|
|
49
|
+
const { obj, key } = opts
|
|
50
|
+
jest.clearAllMocks()
|
|
51
|
+
const spy = jest.spyOn(obj, key)
|
|
52
|
+
spy.mockImplementation(() => false)
|
|
53
|
+
return spy
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const createInstance = (opts: BfOpts) => {
|
|
57
|
+
const { obj, key } = opts
|
|
58
|
+
jest.clearAllMocks()
|
|
59
|
+
return new MethodDisabler(obj, key)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const testIsEnabled = (opts: Opts) => () => {
|
|
63
|
+
const { ins, obj, key, spy } = opts
|
|
64
|
+
expect(ins.isEnabled).toBe(true)
|
|
65
|
+
obj[key]('')
|
|
66
|
+
if (spy) expect(spy).toHaveBeenCalledTimes(1)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const testDisable = (opts: Opts) => () => {
|
|
70
|
+
const { ins, obj, key, spy } = opts
|
|
71
|
+
ins.disable()
|
|
72
|
+
expect(obj[key]).not.toBe(ins.original)
|
|
73
|
+
expect(ins.isEnabled).toBe(false)
|
|
74
|
+
obj[key]('')
|
|
75
|
+
if (spy) expect(spy).not.toHaveBeenCalled()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const testEnable = (opts: Opts) => () => {
|
|
79
|
+
const { ins, obj, key, spy } = opts
|
|
80
|
+
ins.disable()
|
|
81
|
+
ins.enable()
|
|
82
|
+
expect(obj[key]).toBe(ins.original)
|
|
83
|
+
if (spy) createMock({ obj, key })
|
|
84
|
+
testIsEnabled(opts)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const runTest = (opts: Opts) => {
|
|
88
|
+
const bopts = { obj: opts.obj, key: opts.key }
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
opts.ins = createInstance(bopts)
|
|
91
|
+
if (opts.spy) opts.spy = createMock(bopts)
|
|
92
|
+
})
|
|
93
|
+
it('isEnabled', testIsEnabled(opts))
|
|
94
|
+
it('disable', testDisable(opts))
|
|
95
|
+
it('enable', testEnable(opts))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
describe('console.log (hasOwn)', () => {
|
|
99
|
+
const bopts = { obj: console, key: 'log' }
|
|
100
|
+
runTest({ ...bopts, ins: createInstance(bopts), spy: createMock(bopts) })
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
describe('process.stdout.write', () => {
|
|
104
|
+
const bopts = { obj: process.stdout, key: 'write' }
|
|
105
|
+
runTest({ ...bopts, ins: createInstance(bopts), spy: createMock(bopts) })
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
describe('[].push ', () => {
|
|
109
|
+
const bopts = { obj: [], key: 'join' }
|
|
110
|
+
runTest({ ...bopts, ins: createInstance(bopts) })
|
|
111
|
+
})
|
|
112
|
+
})
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Any } from '../types/Any'
|
|
2
|
+
import { ensureThat } from '../validation/ensureThat'
|
|
3
|
+
import { isFunction } from '../validation/isFunction'
|
|
4
|
+
import type { ObjectKey } from '../types/ObjectKey'
|
|
5
|
+
import type { TFunctionNoNew } from '../types/TFunctionNoNew'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A class that creates an object with methods for disabling/enabling a given method on a given object.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const md = new MethodDisabler(process.stdout, 'write')
|
|
12
|
+
*
|
|
13
|
+
* md.disable()
|
|
14
|
+
* assert(!md.isEnabled)
|
|
15
|
+
* console.log('This will not print')
|
|
16
|
+
*
|
|
17
|
+
* md.enable()
|
|
18
|
+
* assert(md.isEnabled)
|
|
19
|
+
* console.log('This will print')
|
|
20
|
+
*
|
|
21
|
+
* assert(md.original === process.stdout.write)
|
|
22
|
+
*/
|
|
23
|
+
export class MethodDisabler {
|
|
24
|
+
static #defaultDescriptor(value: Any): PropertyDescriptor {
|
|
25
|
+
return { value, writable: true, enumerable: true, configurable: true }
|
|
26
|
+
}
|
|
27
|
+
static #noop: TFunctionNoNew = (...args: any[]) => void 0
|
|
28
|
+
static #memoized = new WeakMap<Record<ObjectKey, Any>, Map<ObjectKey, MethodDisabler>>()
|
|
29
|
+
|
|
30
|
+
readonly #obj: Record<ObjectKey, Any>
|
|
31
|
+
readonly #key: string
|
|
32
|
+
readonly #original: TFunctionNoNew
|
|
33
|
+
readonly #hasOwn: boolean
|
|
34
|
+
readonly #originalDescriptor: PropertyDescriptor
|
|
35
|
+
readonly #noopDescriptor: PropertyDescriptor
|
|
36
|
+
#isEnabled = true
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param obj - The object on which the method is defined.
|
|
40
|
+
* @param key - The property name of the method.
|
|
41
|
+
*/
|
|
42
|
+
constructor(obj: Record<ObjectKey, Any>, key: string) {
|
|
43
|
+
ensureThat(obj[key], isFunction)
|
|
44
|
+
this.#obj = obj
|
|
45
|
+
this.#key = key
|
|
46
|
+
this.#original = obj[key]
|
|
47
|
+
this.#hasOwn = Object.hasOwn(obj, key)
|
|
48
|
+
this.#originalDescriptor = this.#hasOwn
|
|
49
|
+
? (Object.getOwnPropertyDescriptor(obj, key) as PropertyDescriptor)
|
|
50
|
+
: MethodDisabler.#defaultDescriptor(this.#original)
|
|
51
|
+
this.#noopDescriptor = Object.assign({}, this.#originalDescriptor, { value: MethodDisabler.#noop })
|
|
52
|
+
// return stored if memoized
|
|
53
|
+
if (MethodDisabler.#memoized.get(obj)?.has(key)) {
|
|
54
|
+
return MethodDisabler.#memoized.get(obj)?.get(key) as this
|
|
55
|
+
}
|
|
56
|
+
//memoize
|
|
57
|
+
if (!MethodDisabler.#memoized.has(obj)) MethodDisabler.#memoized.set(obj, new Map())
|
|
58
|
+
const methods = MethodDisabler.#memoized.get(obj) as Map<ObjectKey, MethodDisabler>
|
|
59
|
+
methods.set(key, this)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Disable the method.
|
|
64
|
+
*/
|
|
65
|
+
disable() {
|
|
66
|
+
if (!this.isEnabled) return
|
|
67
|
+
Object.defineProperty(this.#obj, this.#key, this.#noopDescriptor)
|
|
68
|
+
this.#isEnabled = false
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Enable the method.
|
|
73
|
+
*/
|
|
74
|
+
enable() {
|
|
75
|
+
if (this.isEnabled) return
|
|
76
|
+
if (this.#hasOwn) Object.defineProperty(this.#obj, this.#key, this.#originalDescriptor)
|
|
77
|
+
else delete this.#obj[this.#key]
|
|
78
|
+
this.#isEnabled = true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The original method before it was disabled.
|
|
83
|
+
*/
|
|
84
|
+
get original() {
|
|
85
|
+
return this.#original
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Whether the method is currently enabled.
|
|
90
|
+
*/
|
|
91
|
+
get isEnabled() {
|
|
92
|
+
return this.#isEnabled
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { funSetName } from './funSetName'
|
|
2
|
+
|
|
3
|
+
describe('funSetName', () => {
|
|
4
|
+
it('should set the name of a function', () => {
|
|
5
|
+
expect(
|
|
6
|
+
funSetName('myFunc', function () {
|
|
7
|
+
//
|
|
8
|
+
}).name,
|
|
9
|
+
).toBe('myFunc')
|
|
10
|
+
expect(funSetName('myFunc', () => 1).name).toBe('myFunc')
|
|
11
|
+
})
|
|
12
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
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 function funSetName<T>(name: string, fun: T): T {
|
|
14
|
+
Object.defineProperty(fun, 'name', { value: name, configurable: true, writable: true, enumerable: false })
|
|
15
|
+
return fun
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { execSync } from 'child_process'
|
|
2
|
+
|
|
3
|
+
export function execInherit(command: string): Promise<string> {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
try {
|
|
6
|
+
const buffer = execSync(command, { stdio: 'inherit' })
|
|
7
|
+
const string = buffer && buffer.toString ? buffer.toString().trim() : ''
|
|
8
|
+
resolve(string)
|
|
9
|
+
} catch (error) {
|
|
10
|
+
const oError = error instanceof Error ? error : new Error(String(error))
|
|
11
|
+
reject(oError)
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import colors from 'ansi-colors'
|
|
2
|
+
import Table from 'cli-table'
|
|
3
|
+
|
|
4
|
+
export function formatTableForTerminal(rows: string[][], headers?: string[]) {
|
|
5
|
+
if (!rows.length || !rows[0].length) return ''
|
|
6
|
+
const table = new Table()
|
|
7
|
+
if (headers && headers.length) {
|
|
8
|
+
table.push(headers.map((s) => colors.bold(colors.yellow(s))))
|
|
9
|
+
}
|
|
10
|
+
for (const row of rows) table.push(row)
|
|
11
|
+
return table.toString()
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createArrayMerger } from './createArrayMerger'
|
|
2
|
+
|
|
3
|
+
describe(createArrayMerger.name, () => {
|
|
4
|
+
it('should merge arrays based on the predicate function', () => {
|
|
5
|
+
const merge = createArrayMerger<number>((value) => value != null)
|
|
6
|
+
const target = [1, 3, 5, 7]
|
|
7
|
+
const source1 = [2, 4, 6]
|
|
8
|
+
const result = merge(target, source1)
|
|
9
|
+
expect(result).toEqual([2, 4, 6, 7])
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a function that merges arrays based on a predicate function.
|
|
3
|
+
*/
|
|
4
|
+
export function createArrayMerger<T>(predicate: (value: T, index: number, arr: T[]) => boolean) {
|
|
5
|
+
return function arrMerge<E extends T>(target: E[], ...sources: E[][]) {
|
|
6
|
+
for (const src of sources) {
|
|
7
|
+
for (let i = 0; i < src.length; i++) {
|
|
8
|
+
if (predicate(src[i], i, src)) {
|
|
9
|
+
target[i] = src[i]
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return target
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createObjectMerger } from './createObjectMerger'
|
|
2
|
+
|
|
3
|
+
describe(createObjectMerger.name, () => {
|
|
4
|
+
it('should merge objects based on the predicate function', () => {
|
|
5
|
+
const merge = createObjectMerger((value) => value != null)
|
|
6
|
+
const target = { a: 1, b: 2, c: 3 }
|
|
7
|
+
const source1 = { a: 5, b: null, c: undefined, d: 5 }
|
|
8
|
+
const result = merge(target, source1)
|
|
9
|
+
expect(result).toEqual({ a: 5, b: 2, c: 3, d: 5 })
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Any } from '../types/Any'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a function that merges objects based on a predicate function.
|
|
5
|
+
*/
|
|
6
|
+
export function createObjectMerger(predicate: (value: Any, key: string, obj: Record<string, Any>) => boolean) {
|
|
7
|
+
return function objMerge(target: Record<string, Any>, ...sources: Record<string, Any>[]) {
|
|
8
|
+
for (const src of sources) {
|
|
9
|
+
for (const [key, value] of Object.entries(src)) {
|
|
10
|
+
if (predicate(value, key, src)) {
|
|
11
|
+
target[key] = value
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return target
|
|
16
|
+
}
|
|
17
|
+
}
|