Code Monkey home page Code Monkey logo

npm-author-packages's Introduction

About npm-author-packages

npm-author-packages is an npm package for accessing various npm author/package related information, such as

  • which packages has an author created
  • is a specific author the creator of a package
  • is an author involved in creation of any of the packages in a project

Why?

According to the documentation of npm-search it should be possible to search for an npm package with the npm username. However, this seems currently not to work (in April 2022), so I decided to create my own solution for accomplishing this. Initially my motivation was sparked by the peacenotwar npm malware and my desire to check if that specific author was involved in any of packages my projects are using.

How does it work

For reading the npm packages of an author, I use screenscraping techniques. Because of this the command for listing author packages may be slow when there are very many packages, like for user sindresorhus. For determining project dependencies npm-ls is used.

Installation and usage

As a terminal utility

To use this package anywhere from the terminal, install it globally

npm install -g @sasuw/npm-author-packages

Then you can list npm packages for a specific author by running

npmap [username]

To find out if any dependency (or sub-dependency) in your npm project involves a specicic author, run this in your project directory

npmap -a [username] -i

To find out if a specicic author is a (co)author of a specific package, execute

npmap -a [username] -p [package name]

For all options, run

npmap -h

In code

To use this package in your own project

npm i --save @sasuw/npm-author-packages

Code example to print all packages for an npm author with username sasuw

const npmAuthorPackages = require("@sasuw/npm-author-packages");

(async function () {
    let authorPackages = await npmAuthorPackages.readNpmPackageAuthors('sasuw');
    authorPackages.forEach(element => {
        console.log(element);
    });
})();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.