-
-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cz scopes to be the packages in bolt workspaces
- Loading branch information
1 parent
cd4161a
commit fab672d
Showing
2 changed files
with
64 additions
and
12 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,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); |