Skip to content

Commit

Permalink
Add cz scopes to be the packages in bolt workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Apr 16, 2018
1 parent cd4161a commit fab672d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 12 deletions.
28 changes: 16 additions & 12 deletions .cz.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
const fs = require('fs');
const path = require('path');

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

const packages = [];
for (const subDir of fs.readdirSync(PACKAGES_DIR)) {
for (const packageDir of fs.readdirSync(path.resolve(PACKAGES_DIR, subDir))) {
const pj = JSON.parse(fs.readFileSync(path.resolve(PACKAGES_DIR, subDir, packageDir, 'package.json')));
const name = pj.name.substr('@electron-forge/'.length);
packages.push(name);
}
}

module.exports = {
types: [
{value: 'feat', name: 'feat: A new feature'},
Expand All @@ -11,18 +26,7 @@ module.exports = {
{value: 'revert', name: 'revert: Revert to a commit'},
{value: 'WIP', name: 'WIP: Work in progress'},
],
scopes: [
{ name: 'maker' },
{ name: 'packager' },
{ name: 'linter' },
{ name: 'starter' },
{ name: 'importer' },
{ name: 'tests' },
{ name: 'initializer' },
{ name: 'publisher' },
{ name: 'installer' },
{ name: 'generic' },
],
scopes: packages.map(package => ({ name: package })),
allowCustomScopes: true,
allowBreakingChanges: ['feat', 'fix'],
}
48 changes: 48 additions & 0 deletions tools/bump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require('colors');
const childProcess = require('child_process');
const fs = require('fs-extra');
const path = require('path');
const semver = require('semver');

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 version bumping`.red;
// }

const version = process.argv[2];
if (!version) {
throw `Must provide a version in argv[1]`.red;
}
if (!semver.valid(version)) {
throw `Must provide a valid semver version in argv[1]. Got ${version}`.red;
}
console.info(`Setting version of all dependencies: ${version.cyan}`)
const packages = [];

for (const subDir of await fs.readdir(PACKAGES_DIR)) {
for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
const absPackageDir = path.resolve(PACKAGES_DIR, subDir, packageDir);
const existingPJ = await fs.readJson(path.resolve(absPackageDir, 'package.json'));
existingPJ.version = version;
await fs.writeJson(path.resolve(absPackageDir, 'package.json'), existingPJ, {
spaces: 2,
});
childProcess.execSync(`git add "${path.relative(BASE_DIR, absPackageDir)}"`, {
cwd: BASE_DIR,
});
}
}

childProcess.execSync(`git commit -m "Version Bump: ${version}"`, {
cwd: BASE_DIR,
});
childProcess.execSync(`git tag v${version}`, {
cwd: BASE_DIR,
});
})().catch(console.error);

0 comments on commit fab672d

Please sign in to comment.