mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
* Added missing params object to execUnlessDry call * Public package names are no longer hard-coded * Added "v" prefix to git tag * Show more accurate in-progress duration * Properly bucket-bridage params * Prettier * Publish command logs stack with error
41 lines
988 B
JavaScript
41 lines
988 B
JavaScript
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
const chalk = require('chalk');
|
|
const {execRead, logPromise} = require('../utils');
|
|
|
|
module.exports = async ({packages}) => {
|
|
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)),
|
|
`Checking ${chalk.yellow.bold(currentUser)}'s NPM permissions`
|
|
);
|
|
|
|
if (failedProjects.length) {
|
|
throw Error(
|
|
chalk`
|
|
Insufficient NPM permissions
|
|
|
|
{white NPM user {yellow.bold ${currentUser}} is not an owner for:}
|
|
{red ${failedProjects.join(', ')}}
|
|
|
|
{white Please contact a React team member to be added to the above project(s).}
|
|
`
|
|
);
|
|
}
|
|
};
|