Skip to content
Permalink
Browse files

chore(tooling): add publish script

  • Loading branch information
MarshallOfSound committed Apr 16, 2018
1 parent c97b25d commit c5b6c6a319ae5e96bbb8052daf5401b9b6c9e1a9
Showing with 46 additions and 5 deletions.
  1. +5 −5 tools/bump.js
  2. +41 −0 tools/publish.js
@@ -9,11 +9,11 @@ const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');

(async () => {
// Check clean working dir
// if (childProcess.execSync('git status -s', {
// cwd: BASE_DIR,
// }).toString() !== '') {
// throw `Your working directory is not clean, please ensure you have a clean working directory before version bumping`.red;
// }
if (childProcess.execSync('git status -s', {
cwd: BASE_DIR,
}).toString() !== '') {
throw 'Your working directory is not clean, please ensure you have a clean working directory before version bumping'.red;
}

const version = process.argv[2];
if (!version) {
@@ -0,0 +1,41 @@
require('colors');
const childProcess = require('child_process');
const fs = require('fs-extra');
const path = require('path');
const spawnPromise = require('cross-spawn-promise');

const BASE_DIR = path.resolve(__dirname, '..');
const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');

(async () => {
// Check clean working dir
if (childProcess.execSync('git status -s', {
cwd: BASE_DIR,
}).toString() !== '') {
throw 'Your working directory is not clean, please ensure you have a clean working directory before publishing'.red;
}

console.info('Building all packages');
await spawnPromise('bolt', ['build'], {
cwd: BASE_DIR,
});

console.info('Publishing all packages');

const dirsToPublish = [];

for (const subDir of await fs.readdir(PACKAGES_DIR)) {
for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
dirsToPublish.push(path.resolve(PACKAGES_DIR, subDir, packageDir));
}
}

for (const dir of dirsToPublish) {
const { name, version } = await fs.readJson(path.resolve(dir, 'package.json'));
const isBeta = version.includes('beta');
console.info(` * Publishing: ${`${name}@${version}`.cyan} (beta=${isBeta ? 'true'.green : 'red'.red})`);
childProcess.execSync(`npm publish --access=public${isBeta ? ' --tag=beta' : ''}`, {
cwd: dir,
});
}
})().catch(console.error);

0 comments on commit c5b6c6a

Please sign in to comment.
You can’t perform that action at this time.