New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

np

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

np - npm Package Compare versions

Comparing version 2.8.0 to 2.9.0

76

index.js

@@ -13,2 +13,3 @@ 'use strict';

const VERSIONS = ['major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch', 'prerelease'];
const PRERELEASE_VERSIONS = ['premajor', 'preminor', 'prepatch', 'prerelease'];

@@ -25,2 +26,59 @@ const exec = (cmd, args) => {

const prerequisiteCheckTasks = (input, pkg, opts) => {
const newVersion = VERSIONS.indexOf(input) === -1 ? input : semver.inc(pkg.version, input);
const tasks = [
{
title: 'Validate version',
task: () => {
if (VERSIONS.indexOf(input) === -1 && !semver.valid(input)) {
return Promise.reject(new Error(`Version should be either ${VERSIONS.join(', ')}, or a valid semver version.`));
}
if (semver.gte(pkg.version, newVersion)) {
return Promise.reject(new Error(`New version \`${newVersion}\` should be higher than current version \`${pkg.version}\``));
}
}
},
{
title: 'Check for pre-release version',
task: () => {
if ((PRERELEASE_VERSIONS.indexOf(input) !== -1 || semver.prerelease(input)) && !opts.tag) {
return Promise.reject(new Error('You must specify a dist-tag using --tag when publishing a pre-release version. This prevents accidentally tagging unstable versions as "latest". https://docs.npmjs.com/cli/dist-tag'));
}
}
},
{
title: 'Check npm version',
task: () => execa.stdout('npm', ['version', '--json']).then(json => {
const versions = JSON.parse(json);
if (semver.gte(process.version, '6.0.0') && !semver.satisfies(versions.npm, '>=2.15.8 <3.0.0 || >=3.10.1')) {
return Promise.reject(new Error(`npm@${versions.npm} has known issues publishing when running Node.js 6. Please upgrade npm or downgrade Node and publish again. https://github.com/npm/npm/issues/5082`));
}
})
},
{
title: 'Check git tag existence',
task: () => execa('git', ['fetch'])
.then(() => execa.stdout('git', ['rev-parse', '--quiet', '--verify', `refs/tags/v${newVersion}`]))
.then(
output => {
if (output) {
throw new Error(`Git tag \`v${newVersion}\` already exists.`);
}
},
err => {
// Command fails with code 1 and no output if the tag does not exist, even though `--quiet` is provided
// https://github.com/sindresorhus/np/pull/73#discussion_r72385685
if (err.stdout !== '' || err.stderr !== '') {
throw err;
}
}
)
}
];
return new Listr(tasks);
};
const gitTasks = opts => {

@@ -45,6 +103,2 @@ const tasks = [

{
title: 'Fetch remote changes',
task: () => execa('git', ['fetch'])
},
{
title: 'Check remote history',

@@ -72,16 +126,8 @@ task: () => execa.stdout('git', ['rev-list', '--count', '--left-only', '@{u}...HEAD']).then(result => {

const runCleanup = !opts.skipCleanup && !opts.yolo;
const pkg = readPkgUp.sync().pkg;
if (VERSIONS.indexOf(input) === -1 && !semver.valid(input)) {
return Promise.reject(new Error(`Version should be either ${VERSIONS.join(', ')}, or a valid semver version.`));
}
const tasks = new Listr([
{
title: 'Prerequisite check',
task: () => execa.stdout('npm', ['version', '--json']).then(json => {
const versions = JSON.parse(json);
if (semver.gte(process.version, '6.0.0') && !semver.satisfies(versions.npm, '>=2.15.8 <3.0.0 || >=3.10.1')) {
return Promise.reject(new Error(`npm@${versions.npm} has known issues publishing when running Node.js 6. Please upgrade npm or downgrade Node and publish again. https://github.com/npm/npm/issues/5082`));
}
})
task: () => prerequisiteCheckTasks(input, pkg, opts)
},

@@ -125,3 +171,3 @@ {

skip: () => {
if (readPkgUp.sync().pkg.private) {
if (pkg.private) {
return 'Private package: not publishing to npm.';

@@ -128,0 +174,0 @@ }

{
"name": "np",
"version": "2.8.0",
"version": "2.9.0",
"description": "A better `npm publish`",

@@ -12,2 +12,9 @@ "license": "MIT",

},
"maintainers": [
{
"name": "Sam Verschueren",
"email": "sam.verschueren@gmail.com",
"url": "github.com/SamVerschueren"
}
],
"bin": "cli.js",

@@ -14,0 +21,0 @@ "engines": {

@@ -15,3 +15,4 @@ # np [![Build Status](https://travis-ci.org/sindresorhus/np.svg?branch=master)](https://travis-ci.org/sindresorhus/np)

- Bumps the version in package.json and npm-shrinkwrap.json (if present) and creates a git tag
- Publishes the new version to npm, optionally under a [dist-tag](https://docs.npmjs.com/cli/dist-tag)
- Prevents [accidental publishing](https://github.com/npm/npm/issues/13248) of pre-release versions under the `latest` [dist-tag](https://docs.npmjs.com/cli/dist-tag)
- Publishes the new version to npm, optionally under a dist-tag
- Pushes commits and tags to GitHub

@@ -100,4 +101,10 @@

## Created by
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Sam Verschueren](https://github.com/SamVerschueren)
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc