This is a tool for monorepo management and publishing, now with vscode extension support !
Repo-cooker helps running commands in all projects, linking binaries to run commands in directories and supports auto-semver versionning based on commits since last release (commitizen type).
There is no pre-required monorepo style or folder structure.
Things to check before gettings started:
- Monorepo has correct 'repository' entry in package.json
- Names in individual packages package.json file is correct (matches glob path). For example, a package in 'packages/@foo/bar' should have '@foo/bar' as name.
- REPO_COOKER_GITHUB_TOKEN is set in the environment where the script runs.
- .npmrc has an authToken (npm login) and REPO_COOKER_NPM_OTP is set if you have two factor authentication
- git login if publishing release (see .travis.yml as example)
- 'latest' npm tag for packages already released use a semver version matching /^\d+.\d+. (any version with appe)
{
"scripts": {
// Creates a symlink from /[package path]/node-modules/.bin --> /node_modules/.bin
// Creates a symlink from /node_modules/[package-name] --> [package path]
"link": "repo-cooker --link",
// Link on npm install.
"install": "npm run link",
// Build all modules, respecting cross-dependencies.
"build": "repo-cooker --build",
// Run the default release (semver, npm, github release)
"release": "repo-cooker --release",
"release:preview": "repo-cooker --dry-run --release --print-release",
// Run the "test" script in all packages (if available).
"test": "repo-cooker test"
// If there is a ./repo-cooker/doThis.js file, run this
// custom script otherwise, run the "doThis" script from
// all packages.
"doThis": "repo-cooker doThis",
}
}
This is the settings file.
import {Cooker} from 'repo-cooker'
// We need to pass process.argv as first argument so that we can set
// --dry-run or other options. For example:
// > npm run publish -- --dry-run
const cooker = Cooker(process.argv, {
// Devtools settings
devtools: {
host: 'localhost:9797'
},
// Use devtools.
// Same as command line option '--devtools'.
useDevtools: true,
// Do not execute any command, just show what would be run.
// Same as command line option '--dry-run'.
dryRun: true,
// If your repo is located at some path other than
// project root.
path: '.',
// Additional providers for the actions
providers: []
// For monorepo repositories with multiple packages, specify
// the subpath to each package. A package should
// then be in [path]/[packagesPath]/[packageName]
packagesPath: 'packages/node_modules'
})
import { cooker } from './'
cooker.cook('publish', [
cook.getLatestReleaseHash,
cook.getHistoryFromHash,
// ... and so on
cook.fireworks
])
For now look at publish.test.js for a full example with comments.