npmjscli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +102 -0
- package/bin/npmjs-info.js +30 -0
- package/bin/npmjs-packages.js +44 -0
- package/bin/npmjs-publish.js +41 -0
- package/bin/npmjs-search.js +44 -0
- package/bin/npmjs-stats.js +36 -0
- package/bin/npmjs.js +44 -0
- package/lib/utils.js +128 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rocketor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# 📦 npmjscli
|
|
2
|
+
|
|
3
|
+
> Beautiful CLI for npm registry operations
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/npmjscli)
|
|
6
|
+
[](https://github.com/rocketor/npmjscli/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- 🔍 **Search** - Find packages in the npm registry
|
|
11
|
+
- 📊 **Stats** - View download statistics
|
|
12
|
+
- 📦 **Info** - Get detailed package information
|
|
13
|
+
- 🚀 **Publish** - Publish your packages with ease
|
|
14
|
+
- 📋 **Packages** - List all packages by a user
|
|
15
|
+
|
|
16
|
+
## 🚀 Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g npmjscli
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 📖 Usage
|
|
23
|
+
|
|
24
|
+
### Main command
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npmjs <command> [options]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Individual commands
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Get package info
|
|
34
|
+
npmjs-info express
|
|
35
|
+
npmjs-info express --json
|
|
36
|
+
|
|
37
|
+
# Search packages
|
|
38
|
+
npmjs-search react
|
|
39
|
+
npmjs-search react --limit 50
|
|
40
|
+
|
|
41
|
+
# Download stats
|
|
42
|
+
npmjs-stats express
|
|
43
|
+
npmjs-stats express --period last-week
|
|
44
|
+
|
|
45
|
+
# List user packages (requires auth)
|
|
46
|
+
export NPM_TOKEN=your_token_here
|
|
47
|
+
npmjs-packages
|
|
48
|
+
npmjs-packages --user rocketor
|
|
49
|
+
|
|
50
|
+
# Publish package (requires auth)
|
|
51
|
+
npmjs-publish
|
|
52
|
+
npmjs-publish --tag beta --access public
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 🔐 Authentication
|
|
56
|
+
|
|
57
|
+
Set your npm token as an environment variable:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
export NPM_TOKEN=npm_xxxxxxxxxxxx
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or add to your `~/.bashrc` or `~/.zshrc`:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
echo 'export NPM_TOKEN=your_token' >> ~/.bashrc
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 🛠️ Commands
|
|
70
|
+
|
|
71
|
+
| Command | Description | Auth Required |
|
|
72
|
+
|---------|-------------|---------------|
|
|
73
|
+
| `info` | Get package metadata | No |
|
|
74
|
+
| `search` | Search registry | No |
|
|
75
|
+
| `stats` | Download statistics | No |
|
|
76
|
+
| `packages` | List user packages | Yes |
|
|
77
|
+
| `publish` | Publish package | Yes |
|
|
78
|
+
|
|
79
|
+
## 📋 Examples
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Get info about Express
|
|
83
|
+
npmjs info express
|
|
84
|
+
|
|
85
|
+
# Search for React packages
|
|
86
|
+
npmjs search react --limit 10
|
|
87
|
+
|
|
88
|
+
# Check weekly downloads
|
|
89
|
+
npmjs stats express --period last-week
|
|
90
|
+
|
|
91
|
+
# List your packages
|
|
92
|
+
export NPM_TOKEN=your_token
|
|
93
|
+
npmjs packages
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 📝 License
|
|
97
|
+
|
|
98
|
+
MIT © [rocketor](https://github.com/rocketor)
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
Made with 💜 by Cake Command
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npmjs-info - Get package info
|
|
4
|
+
*/
|
|
5
|
+
const { getPackageInfo, formatPackage, colors } = require('../lib/utils');
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const pkgName = args[0];
|
|
10
|
+
const json = args.includes('--json');
|
|
11
|
+
|
|
12
|
+
if (!pkgName) {
|
|
13
|
+
console.log(`${colors.yellow}Usage: npmjs-info <package> [--json]${colors.reset}`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const data = await getPackageInfo(pkgName);
|
|
19
|
+
if (json) {
|
|
20
|
+
console.log(JSON.stringify(data, null, 2));
|
|
21
|
+
} else {
|
|
22
|
+
console.log(formatPackage(data));
|
|
23
|
+
}
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.log(`${colors.red}Error: ${err.message}${colors.reset}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npmjs-packages - List user packages
|
|
4
|
+
*/
|
|
5
|
+
const { getUserPackages, colors } = require('../lib/utils');
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const userIdx = args.indexOf('--user');
|
|
10
|
+
const user = userIdx >= 0 ? args[userIdx + 1] : null;
|
|
11
|
+
const json = args.includes('--json');
|
|
12
|
+
const token = process.env.NPM_TOKEN;
|
|
13
|
+
|
|
14
|
+
if (!token) {
|
|
15
|
+
console.log(`${colors.red}Error: NPM_TOKEN environment variable required${colors.reset}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const data = await getUserPackages(user, token);
|
|
21
|
+
if (json) {
|
|
22
|
+
console.log(JSON.stringify(data, null, 2));
|
|
23
|
+
} else {
|
|
24
|
+
const packages = data.objects || [];
|
|
25
|
+
const username = user || process.env.NPM_USERNAME || 'you';
|
|
26
|
+
|
|
27
|
+
console.log(`${colors.cyan}📦 Packages by ${username} (${packages.length} found)${colors.reset}\n`);
|
|
28
|
+
|
|
29
|
+
for (const item of packages) {
|
|
30
|
+
const pkg = item.package;
|
|
31
|
+
console.log(`${colors.green}${pkg.name}${colors.reset}@${colors.yellow}${pkg.version}${colors.reset}`);
|
|
32
|
+
if (pkg.description) {
|
|
33
|
+
console.log(` ${pkg.description.substring(0, 70)}${pkg.description.length > 70 ? '...' : ''}`);
|
|
34
|
+
}
|
|
35
|
+
console.log();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.log(`${colors.red}Error: ${err.message}${colors.reset}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npmjs-publish - Publish package
|
|
4
|
+
*/
|
|
5
|
+
const { spawn } = require('child_process');
|
|
6
|
+
const { colors } = require('../lib/utils');
|
|
7
|
+
|
|
8
|
+
function runNpm(args) {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const npm = spawn('npm', ['publish', ...args], {
|
|
11
|
+
stdio: 'inherit',
|
|
12
|
+
env: process.env
|
|
13
|
+
});
|
|
14
|
+
npm.on('close', code => {
|
|
15
|
+
if (code === 0) resolve();
|
|
16
|
+
else reject(new Error(`npm publish failed with code ${code}`));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function main() {
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
const token = process.env.NPM_TOKEN;
|
|
24
|
+
|
|
25
|
+
if (!token) {
|
|
26
|
+
console.log(`${colors.red}Error: NPM_TOKEN environment variable required${colors.reset}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log(`${colors.cyan}📤 Publishing package...${colors.reset}\n`);
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
await runNpm(args);
|
|
34
|
+
console.log(`\n${colors.green}✅ Published successfully!${colors.reset}`);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.log(`\n${colors.red}❌ Publish failed${colors.reset}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npmjs-search - Search npm registry
|
|
4
|
+
*/
|
|
5
|
+
const { searchPackages, colors } = require('../lib/utils');
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const query = args[0];
|
|
10
|
+
const limitIdx = args.indexOf('--limit');
|
|
11
|
+
const limit = limitIdx >= 0 ? parseInt(args[limitIdx + 1]) : 20;
|
|
12
|
+
const json = args.includes('--json');
|
|
13
|
+
|
|
14
|
+
if (!query) {
|
|
15
|
+
console.log(`${colors.yellow}Usage: npmjs-search <query> [--limit 20]${colors.reset}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const data = await searchPackages(query, limit);
|
|
21
|
+
if (json) {
|
|
22
|
+
console.log(JSON.stringify(data, null, 2));
|
|
23
|
+
} else {
|
|
24
|
+
console.log(`${colors.cyan}🔍 Results for "${query}" (${data.objects?.length || 0} found)${colors.reset}\n`);
|
|
25
|
+
|
|
26
|
+
for (const item of data.objects || []) {
|
|
27
|
+
const pkg = item.package;
|
|
28
|
+
console.log(`${colors.green}${pkg.name}${colors.reset}@${colors.yellow}${pkg.version}${colors.reset}`);
|
|
29
|
+
if (pkg.description) {
|
|
30
|
+
console.log(` ${pkg.description.substring(0, 70)}${pkg.description.length > 70 ? '...' : ''}`);
|
|
31
|
+
}
|
|
32
|
+
if (pkg.publisher?.username) {
|
|
33
|
+
console.log(` ${colors.dim}by ${pkg.publisher.username}${colors.reset}`);
|
|
34
|
+
}
|
|
35
|
+
console.log();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.log(`${colors.red}Error: ${err.message}${colors.reset}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npmjs-stats - Get download statistics
|
|
4
|
+
*/
|
|
5
|
+
const { getStats, colors } = require('../lib/utils');
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const pkgName = args[0];
|
|
10
|
+
const periodIdx = args.indexOf('--period');
|
|
11
|
+
const period = periodIdx >= 0 ? args[periodIdx + 1] : 'last-month';
|
|
12
|
+
const json = args.includes('--json');
|
|
13
|
+
|
|
14
|
+
if (!pkgName) {
|
|
15
|
+
console.log(`${colors.yellow}Usage: npmjs-stats <package> [--period last-day|last-week|last-month]${colors.reset}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const data = await getStats(pkgName, period);
|
|
21
|
+
if (json) {
|
|
22
|
+
console.log(JSON.stringify(data, null, 2));
|
|
23
|
+
} else {
|
|
24
|
+
console.log(`${colors.cyan}📊 ${data.package || pkgName}${colors.reset}`);
|
|
25
|
+
console.log(` Downloads (${period}): ${colors.green}${data.downloads?.toLocaleString() || 0}${colors.reset}`);
|
|
26
|
+
if (data.start && data.end) {
|
|
27
|
+
console.log(` Period: ${data.start} to ${data.end}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.log(`${colors.red}Error: ${err.message}${colors.reset}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main();
|
package/bin/npmjs.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npmjscli - Beautiful CLI for npm registry
|
|
4
|
+
* Main entry point
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { showHelp, showVersion, colors } = require('../lib/utils');
|
|
8
|
+
|
|
9
|
+
const commands = {
|
|
10
|
+
'info': 'Get package information',
|
|
11
|
+
'packages': 'List user packages',
|
|
12
|
+
'publish': 'Publish package',
|
|
13
|
+
'stats': 'Download statistics',
|
|
14
|
+
'search': 'Search registry',
|
|
15
|
+
'version': 'Bump version',
|
|
16
|
+
'help': 'Show help'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function main() {
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const cmd = args[0];
|
|
22
|
+
|
|
23
|
+
if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
|
|
24
|
+
showHelp(commands);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (cmd === '--version' || cmd === '-v') {
|
|
29
|
+
showVersion();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (commands[cmd]) {
|
|
34
|
+
// Delegate to subcommand
|
|
35
|
+
const subcmd = require(`../lib/${cmd}`);
|
|
36
|
+
subcmd.run(args.slice(1));
|
|
37
|
+
} else {
|
|
38
|
+
console.log(`${colors.red}Unknown command: ${cmd}${colors.reset}`);
|
|
39
|
+
console.log(`Run ${colors.cyan}npmjs help${colors.reset} for available commands`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main();
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for npmjscli
|
|
3
|
+
*/
|
|
4
|
+
const https = require('https');
|
|
5
|
+
|
|
6
|
+
const REGISTRY = 'https://registry.npmjs.org';
|
|
7
|
+
const API_BASE = 'https://api.npmjs.org';
|
|
8
|
+
|
|
9
|
+
// Pretty colors
|
|
10
|
+
const colors = {
|
|
11
|
+
reset: '\x1b[0m',
|
|
12
|
+
red: '\x1b[31m',
|
|
13
|
+
green: '\x1b[32m',
|
|
14
|
+
yellow: '\x1b[33m',
|
|
15
|
+
blue: '\x1b[34m',
|
|
16
|
+
magenta: '\x1b[35m',
|
|
17
|
+
cyan: '\x1b[36m',
|
|
18
|
+
white: '\x1b[37m',
|
|
19
|
+
dim: '\x1b[2m'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// HTTP fetch helper
|
|
23
|
+
function fetch(url, token) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const options = new URL(url);
|
|
26
|
+
const headers = {};
|
|
27
|
+
if (token) headers['Authorization'] = `Bearer ${token}`;
|
|
28
|
+
|
|
29
|
+
https.get(options, { headers }, (res) => {
|
|
30
|
+
let data = '';
|
|
31
|
+
res.on('data', chunk => data += chunk);
|
|
32
|
+
res.on('end', () => {
|
|
33
|
+
if (res.statusCode >= 400) {
|
|
34
|
+
reject(new Error(`HTTP ${res.statusCode}: ${res.statusMessage}`));
|
|
35
|
+
} else {
|
|
36
|
+
resolve(JSON.parse(data));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}).on('error', reject);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// API functions
|
|
44
|
+
function getPackageInfo(name, token) {
|
|
45
|
+
return fetch(`${REGISTRY}/${name}`, token);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getUserPackages(user, token) {
|
|
49
|
+
const username = user || '';
|
|
50
|
+
return fetch(`${REGISTRY}/-/v1/search?text=maintainer:${username}&size=250`, token);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getStats(pkg, period) {
|
|
54
|
+
return fetch(`${API_BASE}/downloads/point/${period}/${pkg}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function searchPackages(query, limit = 20) {
|
|
58
|
+
return fetch(`${REGISTRY}/-/v1/search?text=${encodeURIComponent(query)}&size=${limit}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Formatting
|
|
62
|
+
function formatPackage(data) {
|
|
63
|
+
const lines = [
|
|
64
|
+
`${colors.cyan}📦 ${data.name}${colors.reset}`,
|
|
65
|
+
` Latest: ${colors.yellow}${data['dist-tags']?.latest || 'N/A'}${colors.reset}`,
|
|
66
|
+
` Description: ${data.description || 'N/A'}`,
|
|
67
|
+
` Author: ${data.author?.name || data.author || 'N/A'}`,
|
|
68
|
+
` License: ${data.license || 'N/A'}`,
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const versions = Object.keys(data.versions || {});
|
|
72
|
+
lines.push(` Versions: ${versions.length} total`);
|
|
73
|
+
|
|
74
|
+
if (versions.length > 0) {
|
|
75
|
+
lines.push(` Recent: ${versions.slice(-5).join(', ')}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (data.time?.modified) {
|
|
79
|
+
lines.push(` Last updated: ${data.time.modified}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return lines.join('\n');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function showHelp(commands) {
|
|
86
|
+
console.log(`${colors.cyan}
|
|
87
|
+
╔══════════════════════════════════════════╗
|
|
88
|
+
║ 📦 npmjscli v1.0.0 ║
|
|
89
|
+
║ Beautiful CLI for npm registry ║
|
|
90
|
+
╚══════════════════════════════════════════╝
|
|
91
|
+
${colors.reset}
|
|
92
|
+
Usage: npmjs <command> [options]
|
|
93
|
+
|
|
94
|
+
Commands:`);
|
|
95
|
+
|
|
96
|
+
const maxLen = Math.max(...Object.keys(commands).map(c => c.length));
|
|
97
|
+
for (const [cmd, desc] of Object.entries(commands)) {
|
|
98
|
+
console.log(` ${colors.green}${cmd.padEnd(maxLen)}${colors.reset} ${desc}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log(`
|
|
102
|
+
Examples:
|
|
103
|
+
${colors.yellow}npmjs info express${colors.reset}
|
|
104
|
+
${colors.yellow}npmjs packages --user rocketor${colors.reset}
|
|
105
|
+
${colors.yellow}npmjs search react --limit 10${colors.reset}
|
|
106
|
+
${colors.yellow}npmjs stats express --period last-week${colors.reset}
|
|
107
|
+
|
|
108
|
+
Environment:
|
|
109
|
+
${colors.cyan}NPM_TOKEN${colors.reset} Your npm access token (for auth commands)
|
|
110
|
+
`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function showVersion() {
|
|
114
|
+
const pkg = require('../package.json');
|
|
115
|
+
console.log(`${colors.cyan}npmjscli${colors.reset} v${pkg.version}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = {
|
|
119
|
+
colors,
|
|
120
|
+
fetch,
|
|
121
|
+
getPackageInfo,
|
|
122
|
+
getUserPackages,
|
|
123
|
+
getStats,
|
|
124
|
+
searchPackages,
|
|
125
|
+
formatPackage,
|
|
126
|
+
showHelp,
|
|
127
|
+
showVersion
|
|
128
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "npmjscli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Beautiful CLI for npm registry operations",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"npmjs": "./bin/npmjs.js",
|
|
8
|
+
"npmjs-info": "./bin/npmjs-info.js",
|
|
9
|
+
"npmjs-packages": "./bin/npmjs-packages.js",
|
|
10
|
+
"npmjs-publish": "./bin/npmjs-publish.js",
|
|
11
|
+
"npmjs-stats": "./bin/npmjs-stats.js",
|
|
12
|
+
"npmjs-search": "./bin/npmjs-search.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"npm",
|
|
19
|
+
"registry",
|
|
20
|
+
"cli",
|
|
21
|
+
"package",
|
|
22
|
+
"publish",
|
|
23
|
+
"stats"
|
|
24
|
+
],
|
|
25
|
+
"author": "rocketor <rocketor@npmjs.com>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/rocketor/npmjscli.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/rocketor/npmjscli/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/rocketor/npmjscli#readme",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|