@black-flag/core
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -28,3 +28,3 @@ "use strict"; | ||
require("core-js/modules/esnext.iterator.some.js"); | ||
var _debugExtended = require("../debug-extended"); | ||
var _debugExtended = require("../debug-extended/index.js"); | ||
exports.extendedDebugFactory = _debugExtended.debugFactory; | ||
@@ -31,0 +31,0 @@ var _mergeDescriptors = _interopRequireDefault(require("merge-descriptors")); |
@@ -7,5 +7,5 @@ "use strict"; | ||
exports.getRootDebugLogger = getRootDebugLogger; | ||
var _rejoinder = require("../lib/rejoinder"); | ||
var _index = require("../lib/rejoinder/index.js"); | ||
var _package = require("../../package.json"); | ||
const rootDebugLogger = (0, _rejoinder.createDebugLogger)({ | ||
const rootDebugLogger = (0, _index.createDebugLogger)({ | ||
namespace: _package.name | ||
@@ -12,0 +12,0 @@ }); |
import type { ExecutionContext } from '../types/program'; | ||
/** | ||
* Recursively scans the filesystem for valid index files starting at | ||
* `basePath`. Upon encountering such a file, it is imported along with each | ||
* valid sibling file in the same directory, treating the raw results as | ||
* `basePath`, which can be a regular filesystem path or a `'file://...'`-style | ||
* URL. Upon encountering such a file, it is imported along with each valid | ||
* sibling file in the same directory, treating the raw results as | ||
* {@link ImportedConfigurationModule} objects. These are translated into | ||
@@ -7,0 +8,0 @@ * {@link Configuration} objects, which are then used to create and configure |
@@ -16,8 +16,9 @@ "use strict"; | ||
var _nodePath = _interopRequireDefault(require("node:path")); | ||
var _nodeUrl = _interopRequireDefault(require("node:url")); | ||
var _types = require("node:util/types"); | ||
var _yargs = _interopRequireDefault(require("yargs/yargs")); | ||
var _suppressWarnings = require("../lib/suppress-warnings"); | ||
var _constant = require("./constant"); | ||
var _util = require("./util"); | ||
var _error = require("./error"); | ||
var _index = require("../lib/suppress-warnings/index.js"); | ||
var _constant = require("./constant.js"); | ||
var _util = require("./util.js"); | ||
var _error = require("./error.js"); | ||
const _rewrite = (specifier, options) => { | ||
@@ -76,5 +77,8 @@ if (typeof specifier != 'string') { | ||
_rewrite_options = { | ||
"appendExtension": ".js", | ||
"recognizedExtensions": [".js", ".jsx", ".mjs", ".cjs", ".json"], | ||
"replaceExtensions": { | ||
"^../package.json$": "../../package.json" | ||
"^../package.json$": "../../package.json", | ||
"../debug-extended.js": "../debug-extended/index.js", | ||
"^(([^/]*/)?lib/[^/]+)$": "$1/index" | ||
} | ||
@@ -84,21 +88,22 @@ }; | ||
const hasSpacesRegExp = /\s+/; | ||
(0, _suppressWarnings.suppressNodeWarnings)('ExperimentalWarning'); | ||
(0, _index.suppressNodeWarnings)('ExperimentalWarning'); | ||
async function discoverCommands(basePath, context) { | ||
let alreadyLoadedRootCommand = false; | ||
const basePath_ = basePath?.startsWith?.('file://') ? _nodeUrl.default.fileURLToPath(basePath) : basePath; | ||
const debug = context.debug.extend('discover'); | ||
const debug_load = debug.extend('load'); | ||
debug('ensuring base path directory exists and is readable: "%O"', basePath); | ||
debug('ensuring base path directory exists and is readable: "%O"', basePath_); | ||
try { | ||
await _promises.default.access(basePath, _promises.default.constants.R_OK); | ||
if (!(await _promises.default.stat(basePath)).isDirectory()) { | ||
await _promises.default.access(basePath_, _promises.default.constants.R_OK); | ||
if (!(await _promises.default.stat(basePath_)).isDirectory()) { | ||
throw new Error('path is not a directory'); | ||
} | ||
} catch (error) { | ||
debug.error('failed due to invalid base path "%O": %O', basePath, error); | ||
throw new _error.AssertionFailedError(_error.ErrorMessage.AssertionFailureBadConfigurationPath(basePath)); | ||
debug.error('failed due to invalid base path "%O": %O', basePath_, error); | ||
throw new _error.AssertionFailedError(_error.ErrorMessage.AssertionFailureBadConfigurationPath(basePath_)); | ||
} | ||
debug('searching upwards for nearest package.json file starting at %O', basePath); | ||
debug('searching upwards for nearest package.json file starting at %O', basePath_); | ||
const pkg = { | ||
path: await (await import('pkg-up')).pkgUp({ | ||
cwd: basePath | ||
cwd: basePath_ | ||
}), | ||
@@ -137,4 +142,4 @@ name: undefined, | ||
} | ||
debug('beginning configuration module auto-discovery at %O', basePath); | ||
await discover(basePath); | ||
debug('beginning configuration module auto-discovery at %O', basePath_); | ||
await discover(basePath_); | ||
debug('configuration module auto-discovery completed'); | ||
@@ -145,3 +150,3 @@ if (context.commands.size) { | ||
} else { | ||
throw new _error.AssertionFailedError(_error.ErrorMessage.AssertionFailureNoConfigurationLoaded(basePath)); | ||
throw new _error.AssertionFailedError(_error.ErrorMessage.AssertionFailureNoConfigurationLoaded(basePath_)); | ||
} | ||
@@ -357,2 +362,13 @@ return; | ||
}; | ||
if (type === 'pure parent' && context.state.globalVersionOption?.name?.length) { | ||
const { | ||
name: versionOptionName, | ||
description: versionOptionDescription | ||
} = context.state.globalVersionOption; | ||
(0, _nodeAssert.default)(versionOptionName.length, _error.ErrorMessage.GuruMeditation()); | ||
[programs.helper, programs.effector].forEach(program => program.option(versionOptionName, { | ||
boolean: true, | ||
description: versionOptionDescription | ||
})); | ||
} | ||
programs.effector.strict(true); | ||
@@ -359,0 +375,0 @@ const usageText = config.usage.replaceAll('$000', config.command).replaceAll('$1', config.description || '').trim(); |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _namedAppErrors = require("named-app-errors"); | ||
var _constant = require("./constant"); | ||
var _constant = require("./constant.js"); | ||
const $type = exports.$type = Symbol.for('object-type-hint'); | ||
@@ -15,0 +15,0 @@ function isCliError(parameter) { |
@@ -7,10 +7,10 @@ "use strict"; | ||
exports.runProgram = exports.isGracefulEarlyExitError = exports.isCliError = exports.configureProgram = exports.GracefulEarlyExitError = exports.FrameworkExitCode = exports.CliError = exports.$executionContext = void 0; | ||
var _ = require("./.."); | ||
exports.configureProgram = _.configureProgram; | ||
var _util = require("../util"); | ||
var _index = require("./../index.js"); | ||
exports.configureProgram = _index.configureProgram; | ||
var _util = require("../util.js"); | ||
exports.runProgram = _util.runProgram; | ||
var _constant = require("../constant"); | ||
var _constant = require("../constant.js"); | ||
exports.$executionContext = _constant.$executionContext; | ||
exports.FrameworkExitCode = _constant.FrameworkExitCode; | ||
var _error = require("../error"); | ||
var _error = require("../error.js"); | ||
exports.CliError = _error.CliError; | ||
@@ -17,0 +17,0 @@ exports.GracefulEarlyExitError = _error.GracefulEarlyExitError; |
@@ -8,3 +8,3 @@ "use strict"; | ||
var _helpers = require("yargs/helpers"); | ||
var _util = require("../util"); | ||
var _util = require("../util.js"); | ||
exports.isArguments = _util.isArguments; | ||
@@ -15,3 +15,3 @@ exports.isAssertionSystemError = _util.isAssertionSystemError; | ||
exports.makeRunner = _util.makeRunner; | ||
var _constant = require("../constant"); | ||
var _constant = require("../constant.js"); | ||
exports.defaultHelpOptionName = _constant.defaultHelpOptionName; | ||
@@ -22,3 +22,3 @@ exports.defaultHelpTextDescription = _constant.defaultHelpTextDescription; | ||
exports.defaultVersionTextDescription = _constant.defaultVersionTextDescription; | ||
var _error = require("../error"); | ||
var _error = require("../error.js"); | ||
exports.AssertionFailedError = _error.AssertionFailedError; | ||
@@ -25,0 +25,0 @@ exports.CommandNotImplementedError = _error.CommandNotImplementedError; |
@@ -15,6 +15,13 @@ import type { Promisable } from 'type-fest'; | ||
*/ | ||
export declare function configureProgram<CustomContext extends ExecutionContext = ExecutionContext>(commandModulePath: string, configurationHooks?: Promisable<ConfigurationHooks>): Promise<PreExecutionContext>; | ||
export declare function configureProgram<CustomContext extends ExecutionContext = ExecutionContext>( | ||
/** | ||
* Command auto-discovery will occur at `commandModulePath`. An exception will | ||
* occur if no commands are loadable from the given `commandModulePath`. | ||
* | ||
* `'file://...'`-style URLs are also accepted. | ||
*/ | ||
commandModulePath: string, configurationHooks?: Promisable<ConfigurationHooks>): Promise<PreExecutionContext>; | ||
/** | ||
* @internal | ||
*/ | ||
export declare function defaultErrorHandlingEpilogueConfigurationHook(...[{ message, error }, _, { state: { didOutputHelpOrVersionText } }]: Parameters<ConfigureErrorHandlingEpilogue>): void; |
@@ -14,7 +14,7 @@ "use strict"; | ||
var _yargs = _interopRequireDefault(require("yargs/yargs")); | ||
var _debug = require("./debug"); | ||
var _discover = require("./discover"); | ||
var _util = require("./util"); | ||
var _error = require("./error"); | ||
var _constant = require("./constant"); | ||
var _debug = require("./debug.js"); | ||
var _discover = require("./discover.js"); | ||
var _util = require("./util.js"); | ||
var _error = require("./error.js"); | ||
var _constant = require("./constant.js"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -163,3 +163,3 @@ const debug = (0, _debug.getRootDebugLogger)().extend('index'); | ||
isAssertionSystemError | ||
} = await import("./util"); | ||
} = await import("./util.js"); | ||
if (typeof error === 'string') { | ||
@@ -166,0 +166,0 @@ message = error; |
@@ -17,6 +17,6 @@ "use strict"; | ||
var _types = require("node:util/types"); | ||
var _constant = require("./constant"); | ||
var _debug = require("./debug"); | ||
var _index = require("./index"); | ||
var _error = require("./error"); | ||
var _constant = require("./constant.js"); | ||
var _debug = require("./debug.js"); | ||
var _index = require("./index.js"); | ||
var _error = require("./error.js"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -23,0 +23,0 @@ const debug = (0, _debug.getRootDebugLogger)().extend('util'); |
{ | ||
"name": "@black-flag/core", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A declarative framework for building fluent, deeply hierarchical command line interfaces with yargs", | ||
@@ -91,3 +91,3 @@ "keywords": [ | ||
"alpha-sort": "^5.0.0", | ||
"core-js": "3.34.0", | ||
"core-js": "3.35.0", | ||
"debug": "^4.3.4", | ||
@@ -103,3 +103,3 @@ "merge-descriptors": "^2.0.0", | ||
"@babel/plugin-proposal-export-default-from": "^7.23.3", | ||
"@babel/preset-env": "^7.23.6", | ||
"@babel/preset-env": "^7.23.7", | ||
"@babel/preset-typescript": "^7.23.3", | ||
@@ -115,3 +115,3 @@ "@commitlint/cli": "^18.4.3", | ||
"@types/merge-descriptors": "^1.0.3", | ||
"@types/node": "^20.10.5", | ||
"@types/node": "^20.10.6", | ||
"@typescript-eslint/eslint-plugin": "^6.16.0", | ||
@@ -118,0 +118,0 @@ "@typescript-eslint/parser": "^6.16.0", |
Sorry, the diff of this file is too big to display
224893
2877
2014
+ Addedcore-js@3.35.0(transitive)
- Removedcore-js@3.34.0(transitive)
Updatedcore-js@3.35.0