Skip to content

Commit

Permalink
chore(tooling): add publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Apr 16, 2018
1 parent c97b25d commit c5b6c6a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
41 changes: 41 additions & 0 deletions tools/publish.js
Original file line number Diff line number Diff line change
@@ -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.