Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"packages-version": "lerna version --no-private --no-push -m \"chore(release): bump package versions\"",
"postpackages-version": "npm run amend-compass-version && git push && git push --tags",
"packages-publish": "node scripts/monorepo/publish-all.js",
"postpackages-publish": "git add packages/*/package-lock.json && git commit -m \"chore(release): Update package-lock files after a release\" && git push",
"packages-test-version": "lerna version --no-private --allow-branch=* --no-git-tag-version --no-push",
"postpackages-test-version": "node scripts/bump-compass-dependencies.js",
"packages-test-publish": "node scripts/monorepo/publish-all.js --local --no-pristine-check --no-branch-check",
Expand Down
34 changes: 31 additions & 3 deletions scripts/monorepo/publish-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,32 @@ function main() {
fail('The repo is not pristine');
}

const packages = JSON.parse(childProcess.execSync('lerna list --json --toposort'))
.filter(package => !package.private);
const packages = JSON.parse(childProcess.execSync('lerna list --json --toposort'));
let i = 0;
for (const package of packages) {
publishPackage(package, [++i, packages.length].join(' of '));
}
}

function publishPackage(
{ location: packageLocation, name: packageName, version: packageVersion },
{
location: packageLocation,
name: packageName,
version: packageVersion,
private: isPackagePrivate
},
progress
) {
console.log('\n');
const packageNameAndVersion = `${packageName}@${packageVersion}`;

console.log(packageNameAndVersion, `(${progress})`);

if (isPackagePrivate) {
console.log('Updating package-lock only ...');
updatePackageLockOnly(packageLocation);
return;
}

if (alreadyPublished(packageLocation, packageNameAndVersion)) {
console.log('Already published, skipping ...');
Expand Down Expand Up @@ -86,6 +96,24 @@ function installAndPublish(packageLocation) {
}
}

function updatePackageLockOnly(packageLocation) {
const proc = childProcess.spawnSync(
'npm',
['install', '--package-lock-only', ...npmRegistrySpawnArgs],
{
cwd: packageLocation,
stdio: 'inherit',
stdin: 'inherit'
}
);

const { status: installExitCode } = proc;

if (installExitCode !== 0) {
throw new Error(`npm install failed with exit code = ${installExitCode}`);
}
}

function alreadyPublished(packageLocation, packageNameAndVersion) {
try {
const stdout = childProcess.execSync(`npm view ${packageNameAndVersion} --json`, { cwd: packageLocation });
Expand Down