Home / File/ check-npm-permissions.js — react Source File

check-npm-permissions.js — react Source File

Architecture documentation for check-npm-permissions.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

#!/usr/bin/env node

'use strict';

const {execRead, logPromise} = require('../utils');
const theme = require('../theme');

const run = async ({cwd, packages, version}) => {
  const currentUser = await execRead('npm whoami');
  const failedProjects = [];

  const checkProject = async project => {
    const owners = (await execRead(`npm owner ls ${project}`))
      .split('\n')
      .filter(owner => owner)
      .map(owner => owner.split(' ')[0]);

    if (!owners.includes(currentUser)) {
      failedProjects.push(project);
    }
  };

  await logPromise(
    Promise.all(packages.map(checkProject)),
    theme`Checking NPM permissions for {underline ${currentUser}}.`
  );

  if (failedProjects.length) {
    console.error(
      theme`
      {error Insufficient NPM permissions}
      \nNPM user {underline ${currentUser}} is not an owner for: ${failedProjects
        .map(name => theme.package(name))
        .join(', ')}
      \nPlease contact a React team member to be added to the above project(s).
      `
        .replace(/\n +/g, '\n')
        .trim()
    );
    process.exit(1);
  }
};

module.exports = run;

Domain

Subdomains

Functions

Frequently Asked Questions

What does check-npm-permissions.js do?
check-npm-permissions.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in check-npm-permissions.js?
check-npm-permissions.js defines 1 function(s): run.
Where is check-npm-permissions.js in the architecture?
check-npm-permissions.js is located at scripts/release/publish-commands/check-npm-permissions.js (domain: BabelCompiler, subdomain: Optimization, directory: scripts/release/publish-commands).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free