2020-03-23 00:04:49 +00:00
|
|
|
const { execSync } = require('child_process');
|
|
|
|
const { readFileSync } = require('fs');
|
|
|
|
const { join } = require('path');
|
|
|
|
|
|
|
|
const allPackages = JSON.parse(execSync(
|
|
|
|
'npx lerna ls --all --json',
|
|
|
|
{cwd: join(__dirname, '..'), stdio: ['pipe', 'pipe', 'ignore']}
|
|
|
|
).toString().trim());
|
|
|
|
|
|
|
|
const allPackagesNames = new Set(allPackages.map(pkg => pkg.name));
|
2020-02-20 23:47:01 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const yarnLock = readFileSync(join(__dirname, '..', 'yarn.lock')).toString();
|
2020-03-23 00:04:49 +00:00
|
|
|
const embarkPkgs = yarnLock
|
|
|
|
.match(/embark(js)?(-\S+)?@|@embarklabs\/\S+@/g)
|
|
|
|
.map(match => match.slice(0, -1));
|
|
|
|
const badPkgTest = pkgName => allPackagesNames.has(pkgName);
|
|
|
|
if (embarkPkgs && embarkPkgs.some(badPkgTest)) {
|
|
|
|
let badPkgNames = [...(new Set(embarkPkgs))].filter(badPkgTest);
|
|
|
|
const plur = badPkgNames.length > 1;
|
2020-02-20 23:47:01 +00:00
|
|
|
console.error();
|
|
|
|
console.error(
|
|
|
|
[
|
2020-03-23 00:04:49 +00:00
|
|
|
`Found specifier${plur ? 's' : ''} for ${badPkgNames.join(', ')} in`,
|
|
|
|
`the root yarn.lock file.\n\nThis probably happened because some`,
|
|
|
|
`package's version and/or dev/Deps specifiers need to be adjusted`,
|
|
|
|
`relative to the current versions in the master branch.`
|
2020-02-20 23:47:01 +00:00
|
|
|
].join(' ')
|
|
|
|
);
|
|
|
|
console.error();
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
process.exit(0);
|
|
|
|
} catch(e) {
|
|
|
|
console.error(e);
|
|
|
|
process.exit(1);
|
|
|
|
}
|