NPM API for application workflow
{Boolean} Does this package exist?
const {exists} = require('jsnpm');
await exists('@me/my-package') // true | false
await exists('@me/my-package', 'next') // true | false
{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'
{String} Get the latest version of a package
const {latest} = require('jsnpm');
await latest('@me/my-package') // '3.3.3'
{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)
}
{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/[email protected]
console.log('Unpublished successfully')
} catch (error) {
console.error(error)
}
{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']
{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']
{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/')