Get unlimited public & private packages + team-based management with npm Teams.Learn more »

jsnpm

0.4.0 • Public • Published

jsnpm

NPM API for application workflow

exists

{Boolean} Does this package exist?

const {exists} = require('jsnpm');
 
await exists('@me/my-package') // true | false
await exists('@me/my-package', 'next') // true | false

getVersion

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

const {getVersion} = require('jsnpm');
 
await getVersion('@me/my-package', 'next') // '1.7.9-rc-5fca53d'

latest

{String} Get the latest version of a package

const {latest} = require('jsnpm');
 
await 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 {
    await publish()
    console.log('Published successfully')
} catch (error) {
    console.error(error)
}

unpublish

{String} Unpublish an existing package. Optionally add a versioe to unpublish. Returns unpublished version.

const {unpublish} = require('jsnpm');
 
try {
    async unpublish('@me/my-package', '1.1.1') // - @me/my-package@1.1.1
    console.log('Unpublished successfully')
} catch (error) {
    console.error(error)
}

setTag

{void} Set a version to a tag

const {setTag} = require('jsnpm');
 
await 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');
 
await 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/')

Keywords

none

Install

npm i jsnpm

DownloadsWeekly Downloads

280

Version

0.4.0

License

MIT

Unpacked Size

5.36 kB

Total Files

13

Last publish

Collaborators

  • avatar