Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions scripts/publish-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,32 @@ function markTaskAsDone(task, releaseDirPath) {
fs.writeFileSync(taskDoneFilePath(task, releaseDirPath), '');
}

function checkUserPermissionsToPublish() {
const lerna = path.resolve(rootPath, 'node_modules', '.bin', 'lerna');

const userPackagesAccess = JSON.parse(execSync(`npm access ls-packages`).toString().trim())
const lernaPackages = JSON.parse(execFileSync(lerna,
['list', '--json', '--no-private', '--loglevel=error']).toString().trim());

const missingAccess = [];

for (const repo of lernaPackages) {
if (userPackagesAccess[repo.name] !== 'read-write') {
missingAccess.push(repo.name);
}
}

if (missingAccess.length) {
throw new Error(
`Required write access missing for the following packages: ${missingAccess.join(', ')}`
);
}
}

async function publish() {
const segmentApiKey = requireSegmentApiKey();
checkUserPermissionsToPublish();

const remoteUrl = getGitRemoteUrl();
const remoteHeadSha = getGitRemoteHeadSHA(remoteUrl);
const releaseDirPath = path.resolve(rootPath, 'tmp', 'releases', remoteHeadSha);
Expand Down