You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
#! /usr/bin/env node
|
|
|
|
const { join } = require('path');
|
|
const Graph = require("graph-data-structure");
|
|
const semver = require('semver');
|
|
const { readdirSync } = require('fs');
|
|
const { execSync } = require('child_process');
|
|
|
|
const version = process.argv[2];
|
|
|
|
if (!semver.valid(version)) {
|
|
console.error('Missing required valid version parameter');
|
|
process.exit(1);
|
|
}
|
|
|
|
execSync(`oao reset-all-versions ${version}`, { stdio: 'inherit' });
|
|
|
|
const packagesDir = join(__dirname, '../packages');
|
|
const packages = readdirSync(packagesDir);
|
|
const graph = packages.reduce((graph, pkg) => {
|
|
graph.addNode(pkg);
|
|
graph.addEdge('neutrino', pkg);
|
|
|
|
Object
|
|
.keys(require(join(packagesDir, `${pkg}/package.json`)).dependencies)
|
|
.filter(dep => dep.includes('neutrino'))
|
|
.forEach(dep => graph.addEdge(dep, pkg));
|
|
|
|
return graph;
|
|
}, new Graph());
|
|
|
|
graph
|
|
.topologicalSort()
|
|
.forEach(p => {
|
|
console.log(`Publishing ${p}@${version}`);
|
|
|
|
const cwd = join(packagesDir, p);
|
|
const pkgJson = join(cwd, 'package.json');
|
|
const pkg = require(pkgJson);
|
|
const upgradedDeps = Object
|
|
.keys(pkg.dependencies)
|
|
.filter(dep => dep.includes('neutrino-'));
|
|
|
|
if (upgradedDeps.length) {
|
|
console.log(` yarn upgrade ${upgradedDeps.join(' ')}`);
|
|
execSync(`yarn upgrade ${upgradedDeps.join(' ')}`, { cwd });
|
|
}
|
|
|
|
execSync(`npm publish`, { cwd });
|
|
});
|
|
|