├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .npmrc ├── cli.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 21 14 | - 20 15 | - 18 16 | steps: 17 | - uses: actions/checkout@v4 18 | - uses: actions/setup-node@v4 19 | with: 20 | node-version: ${{ matrix.node-version }} 21 | - run: npm install 22 | - run: npm test 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import process from 'node:process'; 3 | import meow from 'meow'; 4 | import npmUser from 'npm-user'; 5 | import logSymbols from 'log-symbols'; 6 | 7 | const cli = meow(` 8 | Usage 9 | $ npm-user 10 | 11 | Example 12 | $ npm-user sindresorhus 13 | Name: Sindre Sorhus 14 | Email: sindresorhus@gmail.com 15 | GitHub: sindresorhus 16 | Twitter: sindresorhus 17 | `, { 18 | importMeta: import.meta, 19 | }); 20 | 21 | const [username] = cli.input; 22 | 23 | if (!username) { 24 | console.error('Specify an npm username'); 25 | process.exit(1); 26 | } 27 | 28 | try { 29 | const user = await npmUser(username); 30 | const rows = []; 31 | 32 | const createRow = (prefix, key) => { 33 | if (user[key]) { 34 | rows.push(`${logSymbols.info} ${prefix}: ${user[key]}`); 35 | } 36 | }; 37 | 38 | createRow('Name', 'name'); 39 | createRow('Email', 'email'); 40 | createRow('GitHub', 'github'); 41 | createRow('Twitter', 'twitter'); 42 | 43 | console.log(rows.join('\n')); 44 | } catch (error) { 45 | if (error.code === 'ERR_NO_NPM_USER') { 46 | console.error(`${logSymbols.error} ${error.message}.`); 47 | process.exit(1); 48 | } 49 | 50 | throw error; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "npm-user-cli", 3 | "version": "4.0.0", 4 | "description": "Get user info of an npm user", 5 | "license": "MIT", 6 | "repository": "sindresorhus/npm-user-cli", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "type": "module", 14 | "bin": { 15 | "npm-user": "./cli.js" 16 | }, 17 | "sideEffects": false, 18 | "engines": { 19 | "node": ">=18" 20 | }, 21 | "scripts": { 22 | "test": "xo && ava" 23 | }, 24 | "files": [ 25 | "cli.js" 26 | ], 27 | "keywords": [ 28 | "cli-app", 29 | "cli", 30 | "npm", 31 | "user", 32 | "username", 33 | "homepage", 34 | "email", 35 | "get", 36 | "website", 37 | "scrape", 38 | "info", 39 | "profile" 40 | ], 41 | "dependencies": { 42 | "log-symbols": "^6.0.0", 43 | "meow": "^13.2.0", 44 | "npm-user": "^6.1.0" 45 | }, 46 | "devDependencies": { 47 | "ava": "^6.1.1", 48 | "execa": "^8.0.1", 49 | "xo": "^0.57.0" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # npm-user-cli 2 | 3 | > Get user info of an npm user 4 | 5 | ## Install 6 | 7 | ```sh 8 | npm install --global npm-user-cli 9 | ``` 10 | 11 | ## Usage 12 | 13 | ``` 14 | $ npm-user --help 15 | 16 | Usage 17 | $ npm-user 18 | 19 | Example 20 | $ npm-user sindresorhus 21 | Name: Sindre Sorhus 22 | Email: sindresorhus@gmail.com 23 | GitHub: sindresorhus 24 | Twitter: sindresorhus 25 | ``` 26 | 27 | ## Related 28 | 29 | - [npm-user](https://github.com/sindresorhus/npm-user) - API for this module 30 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import {execa} from 'execa'; 2 | import test from 'ava'; 3 | 4 | // Note: Not a full implementation, don't use elsewhere 5 | const dedent = string_ => string_.split('\n').slice(1, -1).map(x => x.trim()).join('\n'); 6 | 7 | const verify = test.macro(async (t, {args, expected, error}) => { 8 | const {stdout, stderr} = await execa('./cli.js', args.split(' '), {reject: false, env: {NO_COLOR: '1'}}); 9 | 10 | if (error) { 11 | t.is(stderr, error); 12 | } else { 13 | t.is(stdout, expected); 14 | } 15 | }); 16 | 17 | test('main', verify, { 18 | args: 'sindresorhus', 19 | expected: dedent(` 20 | ℹ Name: Sindre Sorhus 21 | ℹ Email: sindresorhus@gmail.com 22 | ℹ GitHub: sindresorhus 23 | ℹ Twitter: sindresorhus 24 | `), 25 | }); 26 | 27 | test('no username', verify, { 28 | args: '', 29 | error: 'Specify an npm username', 30 | }); 31 | 32 | test('non-existant user', verify, { 33 | args: 'nnnope', 34 | error: '✖ User `nnnope` could not be found.', 35 | }); 36 | --------------------------------------------------------------------------------