npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nexssp/ensure

v1.1.28

Published

Install easy on multiple os, check also @nexssp/os for different functions..

Downloads

18

Readme

@nexssp/ensure

NEW: 02.04.2022 Added workflows + support for MacOS.

# or on js ensureInstalled('git')
nexssp-ensure git # will install git on any os you are. If it is installed it will return the path.

It's more then @nexssp/os function as it has translator. What it means? that for example on Gentoo to install git you need to put emerge dev-vcs/git (not git). We cover that in the @nexssp/extend. We will be building the database of what and which distro what kind of changes has. For example:

Translator file example

Git

Below is just: All Gentoos use 'dev-vcs/git'.

const os = require('@nexssp/os/legacy')
// first tag means all versions. We specified 1, because it does matter for the first tag
const GentooFirst = os.getTags(os.distros.GENTOO, 1).first()
module.exports = {
  [GentooFirst]: 'dev-vcs/git', // All gentoos will have this other systems has git
}
const result = ensureInstalled("git") => it will automatically install git on your machine
  • Function just make sure your program is installed (Linux, WSL, Windows) and macOS soon..

  • This package is used in many packages. For example in the @nexssp/languages where you can install over 50 programming languages. Try npx @nexssp/languages r install or npx @nexssp/languages php install.

API

Functions

  • ensureInstalled(command/package, installCommand, options)
  • which(command) - returns path of the command/program, false if does not exist.

Examples

const { ensureInstalled } = require('@nexssp/ensure')

const path = ensureInstalled('jq', 'apt install jq', {
  progress: cliArgs.progress,
})

// You can also pass 2 parameters and install command will be generated based on @nexssp/os and translators.
const path2 = ensureInstalled('lua', {
  progress: cliArgs.progress,
})

// Windows Subsystem for Linux
const path3 = ensureInstalled('wsl jq', 'wsl -u root apt install jq')

CLI tool

nexssp-ensure jq --install="apt install jq"

# Windows Subsystem for Linux
nexssp-ensure "wsl jq" --install="wsl -u root apt install jq"

Development

Translator files

Example 1

When ensure installing the packages it is looking at the translator files. Here are the examples:

const os = require('@nexssp/os/legacy')

// first tag means all versions. We specified 1, because it does matter for the first tag which is Windows
const Windows = os.getTags(os.distros.WINDOWS, 1).first() // first is always Windows. You could use also "win32", "linux", "darwin" .. all from https://nodejs.org/api/process.html#process_process_platform, but also distros based on @nexssp/os tags

module.exports = {
  [Windows]: {
    install: `powershell -command "Set-ExecutionPolicy RemoteSigned -scope CurrentUser" ; powershell -command "iex (new-object net.webclient).downloadstring('https://get.scoop.sh')"`,
  },
}

Example 2

const os = require('@nexssp/os/legacy')

const GentooFirst = os.getTags(os.distros.GENTOO, 1).first()

module.exports = {
  [GentooFirst]: 'dev-vcs/git', // All gentoos will have this other systems has git, other systems will have standard.
}