@novas/cli-utility

NodeJS utilities and boilerplate for creating CLIs

Usage no npm install needed!

<script type="module">
  import novasCliUtility from 'https://cdn.skypack.dev/@novas/cli-utility';
</script>

README

@novas/cli-utility

NodeJS utilities and boilerplate for creating CLIs

Installation

yarn add @novas/cli-utility got tar semver commander fast-fuzzy inquirer inquirer-autocomplete-prompt

Functions

Modules are exported as both ESM and CJS

  • checkPackageVersion - Takes a package name and returns an object with metadata about the currently installed and latest published versions of the package.
const {
    installedVersion,
    latestVersion,
    isInstalled,
    isLatest,
    isOutdated,
    isExperimental,
} = checkPackageVersion('create-next-app')
  • downloadAndExtractGithub - Takes a Github tree or blob URL including branch name and downloads and extracts the .tar.gz file to the cwd.
try {
    await downloadAndExtractGithub(
        'https://github.com/codynova/eslint-config/tree/master'
    )
    console.log('success!')
} catch (error) {
    console.log(error)
}
  • installDependenciesNpm and installDependenciesYarn - Attempts to install dependencies with NPM or Yarn in the cwd.
try {
    installDependenciesYarn()
    console.log('success!')
} catch (error) {
    console.log(error)
}

Prior Art