↩︎

jsnpm

NPM API for application workflow

exists

{Boolean} Does this package exist?

const {exists} = require('jsnpm');

async exists('@me/my-package') // true | false
async exists('@me/my-package', 'next') // true | false

getVersion

{String} Get the version of a tag in a package

const {getVersion} = require('jsnpm');

async getVersion('@me/my-package', 'next') // '1.7.9-rc-5fca53d'

latest

{String} Get the latest version of a package

const {latest} = require('jsnpm');

async latest('@me/my-package') // '3.3.3'

publish

{void} Publish the hosting package we're running in (runtime directory). Throws error when publish fails

const {publish} = require('jsnpm');

try {
    async publish()
    console.log('Published successfully')
} catch (error) {
    console.error(error)
}

setTag

{void} Set a version to a tag

const {setTag} = require('jsnpm');

async setTag('@me/my-package', '2.2.2', 'latest') // ['0.0.0', '1.1.1', '2.2.2', '3.3.3']

versions

{Array} Get all published versions of a package

const {latest} = require('jsnpm');

async latest('@me/my-package') // ['0.0.0', '1.1.1', '2.2.2', '3.3.3']

config

{void} Set a configuration for the "npm" instance we're working on

const {config} = require('jsnpm');

await config('registry', 'https://company.jfrog.io/company/api/npm/npm-company/')