Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

npm-name-cli

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-name-cli - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

50

cli.js

@@ -6,2 +6,3 @@ #!/usr/bin/env node

const chalk = require('chalk');
const squatter = require('squatter');
const npmName = require('npm-name');

@@ -16,28 +17,49 @@

${logSymbols.error} ${chalk.bold('chalk')} is unavailable
$ npm-name abc123
${logSymbols.warning} ${chalk.bold('abc123')} is squatted
$ npm-name unicorn-cake
${logSymbols.success} ${chalk.bold('unicorn-cake')} is available
$ npm-name chalk unicorn-cake
${logSymbols.error} ${chalk.bold('chalk')} is unavailable
$ npm-name @sindresorhus/is unicorn-cake
${logSymbols.error} ${chalk.bold('@sindresorhus/is')} is unavailable
${logSymbols.success} ${chalk.bold('unicorn-cake')} is available
Exits with code 0 when all names are available or 2 when any names are taken
`, {
string: ['_']
});
`);
const input = cli.input;
const {input} = cli;
if (input.length === 0) {
console.error('Specify a package name');
console.error('Specify one or more package names');
process.exit(1);
}
function log(val, key) {
const name = chalk.bold(key);
console.log(val ? `${logSymbols.success} ${name} is available` : `${logSymbols.error} ${name} is unavailable`);
function log(pkg) {
const name = chalk.bold(pkg.name);
if (pkg.isAvailable) {
console.log(`${logSymbols.success} ${name} is available`);
} else if (pkg.isSquatter) {
console.log(`${logSymbols.warning} ${name} is squatted`);
} else {
console.log(`${logSymbols.error} ${name} is unavailable`);
}
}
npmName.many(input).then(available => {
available.forEach(log);
process.exit(Array.from(available.values()).every(Boolean) ? 0 : 2);
});
(async () => {
const result = await npmName.many(input);
const packages = await Promise.all([...result].map(async ([name, isAvailable]) => {
const ret = {name, isAvailable};
if (!isAvailable) {
ret.isSquatter = await squatter(name);
}
return ret;
}));
for (const pkg of packages) {
log(pkg);
}
process.exit(packages.every(pkg => Boolean(pkg.isAvailable || pkg.isSquatter)) ? 0 : 2);
})();
{
"name": "npm-name-cli",
"version": "1.2.0",
"description": "Check whether a package name is available on npm",
"license": "MIT",
"repository": "sindresorhus/npm-name-cli",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bin": {
"npm-name": "cli.js"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"cli.js"
],
"keywords": [
"cli-app",
"cli",
"app",
"npm",
"package",
"pkg",
"name",
"check",
"available",
"unavailable",
"taken",
"find"
],
"dependencies": {
"chalk": "^1.1.1",
"log-symbols": "^1.0.2",
"meow": "^3.4.2",
"npm-name": "^3.0.0"
},
"devDependencies": {
"ava": "*",
"execa": "^0.2.2",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "npm-name-cli",
"version": "2.0.0",
"description": "Check whether a package name is available on npm",
"license": "MIT",
"repository": "sindresorhus/npm-name-cli",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bin": {
"npm-name": "cli.js"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"cli.js"
],
"keywords": [
"cli-app",
"cli",
"app",
"npm",
"package",
"pkg",
"name",
"check",
"available",
"unavailable",
"taken",
"find"
],
"dependencies": {
"chalk": "^2.3.2",
"log-symbols": "^2.2.0",
"meow": "^4.0.0",
"npm-name": "^3.2.0",
"squatter": "^0.1.1"
},
"devDependencies": {
"ava": "*",
"execa": "^0.10.0",
"xo": "*"
}
}

@@ -7,3 +7,5 @@ # npm-name-cli [![Build Status](https://travis-ci.org/sindresorhus/npm-name-cli.svg?branch=master)](https://travis-ci.org/sindresorhus/npm-name-cli)

*Feedback about the squatter detection should be opened on the [`squatter`](https://github.com/sholladay/squatter) repo.*
## Install

@@ -27,6 +29,8 @@

✖ chalk is unavailable
$ npm-name abc123
⚠ abc123 is squatted
$ npm-name unicorn-cake
✔ unicorn-cake is available
$ npm-name chalk unicorn-cake
✖ chalk is unavailable
$ npm-name @sindresorhus/is unicorn-cake
✖ @sindresorhus/is is unavailable
✔ unicorn-cake is available

@@ -38,2 +42,26 @@

## FAQ
### Why would I use `npm-name` rather than npm's built-in search?
1. Nicer & simpler output
2. [npm search is only supported on npm 4](https://github.com/npm/npm/issues/14649#issuecomment-262820415), which is only bundled with Node.js 7.4+
3. [Squatter detection](https://github.com/sholladay/squatter)
4. Performance
Using npm 4.0.2
```
$ time npm search unicorn-cake
No matches found for "unicorn-cake"
npm search unicorn-cake 55.50s user 0.82s system 101% cpu 55.380 total
$ time npm-name unicorn-cake
✔ unicorn-cake is available
npm-name unicorn-cake 0.17s user 0.02s system 35% cpu 0.535 total
```
## Related

@@ -40,0 +68,0 @@

Sorry, the diff of this file is not supported yet

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