@inquirerer/utils
CLI lifecycle utilities
Utilities for building command-line applications with inquirerer
CLI lifecycle utilities for building command-line applications with inquirerer.
Installation
npm install @inquirerer/utils
Features
Extracts the first positional argument from argv for command routing:
import { extractFirst } from '@inquirerer/utils';
const { first, newArgv } = extractFirst(argv);
cliExitWithError
Exits the CLI with an error message and optional cleanup:
import { cliExitWithError } from '@inquirerer/utils';
await cliExitWithError(error, {
beforeExit: async () => {
await closeConnections();
}
});
checkForUpdates
Checks for package updates with caching:
import { checkForUpdates } from '@inquirerer/utils';
const result = await checkForUpdates({
pkgName: '@my/cli',
pkgVersion: '1.0.0',
registryBaseUrl: 'https://registry.npmjs.org'
});
if (result.hasUpdate) {
console.log(result.message);
}
getSelfPackageJson
Gets the package.json for the current package:
import { getSelfPackageJson, getSelfVersion, getSelfName } from '@inquirerer/utils';
const pkg = getSelfPackageJson(__dirname);
const version = getSelfVersion(__dirname);
const name = getSelfName(__dirname);
License
MIT
Development
Setup
git clone https://github.com/constructive-io/dev-utils.git
cd dev-utils
pnpm install
pnpm build
- Test the package of interest:
cd packages/<packagename>
pnpm test:watch
Credits
🛠 Built by the Constructive team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on GitHub.
Disclaimer
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.