-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c97b25d
commit c5b6c6a
Showing
2 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |