-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce lerna-release plugin
- Loading branch information
Sergey Bekrin
committed
Apr 3, 2019
1 parent
db36974
commit 1e46acf
Showing
14 changed files
with
620 additions
and
357 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
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
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
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,68 @@ | ||
# spire-plugin-lerna-release | ||
|
||
[lerna publish](https://github.com/lerna/lerna/tree/master/commands/publish) | ||
plugin for [Spire](../spire/README.md). | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [Quick start](#quick-start) | ||
- [Hooks](#hooks) | ||
- [Options](#options) | ||
- [License](#license) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
## Quick start | ||
|
||
1. Install `spire-plugin-lerna-release` | ||
|
||
```sh | ||
yarn add --dev spire-plugin-lerna-release | ||
``` | ||
|
||
2. Add `spire-plugin-lerna-release` to list of plugins | ||
|
||
```json | ||
{ | ||
"spire": { | ||
"plugins": ["spire-plugin-lerna-release"] | ||
} | ||
} | ||
``` | ||
|
||
## Hooks | ||
|
||
- `setup` Adds `release` command and prepares lerna arguments. | ||
- `run` Runs `lerna publish`. | ||
|
||
## Options | ||
|
||
- Plugin `['spire-plugin-lerna-release', options]` | ||
|
||
- `command` \<[string]\> Command to run semantic-release on. Defaults to | ||
`release`. | ||
- `gitAuthorName` \<[string]\> Git author and commiter name. Defaults to | ||
`undefined`, which falls back to default value of [lerna]. | ||
- `gitAuthorEmail` \<[string]\> Git author and commiter email. Defaults to | ||
`undefined`, which falls back to default value of [lerna]. | ||
- `allowBranch` \<[string]\> Allowed branch to be released. Defaults to | ||
`master`. | ||
- `githubRelease` \<[boolean]\> Whether to create a GitHub release or not. | ||
- `extraArgs` \<[Array]\<[string]\>\> Array of extra argumnets to pass to | ||
`lerna publish`. Defaults to `[]`. | ||
|
||
- CLI `npx spire release` | ||
- Passes all arguments after `--` as-is to lerna. | ||
|
||
## License | ||
|
||
MIT © [ResearchGate](https://github.com/researchgate) | ||
|
||
[lerna]: https://github.com/lerna/lerna | ||
[boolean]: | ||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type | ||
[string]: | ||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type | ||
[array]: | ||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array |
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,62 @@ | ||
const execa = require('execa'); | ||
|
||
function lernaRelease( | ||
{ setCommand, getCommand, setState, getState }, | ||
{ | ||
command = 'release', | ||
gitAuthorName = undefined, | ||
gitAuthorEmail = undefined, | ||
allowBranch = 'master', | ||
githubRelease = true, | ||
extraArgs = [], | ||
} | ||
) { | ||
const RELEASE_COMMAND = Symbol.for(`lerna-${command}`); | ||
return { | ||
name: 'spire-plugin-lerna-release', | ||
async setup({ cli }) { | ||
cli.command( | ||
command, | ||
'run lerna publish', | ||
() => {}, | ||
() => setCommand(RELEASE_COMMAND) | ||
); | ||
setState({ | ||
lernaPublishArgs: [ | ||
'--conventional-commits', | ||
'--allow-branch', | ||
allowBranch, | ||
'--github-release', | ||
githubRelease, | ||
'--yes', | ||
...extraArgs, | ||
], | ||
}); | ||
}, | ||
async skip() { | ||
return getCommand() !== RELEASE_COMMAND; | ||
}, | ||
async run({ options, cwd, logger }) { | ||
const { lernaPublishArgs } = getState(); | ||
const userProvidedArgs = options._.slice(1); | ||
const finalLernaPublishArgs = [...lernaPublishArgs, ...userProvidedArgs]; | ||
logger.debug( | ||
'Using lerna publish arguments: %s', | ||
finalLernaPublishArgs.join(' ') | ||
); | ||
const env = { | ||
GIT_AUTHOR_NAME: gitAuthorName, | ||
GIT_AUTHOR_EMAIL: gitAuthorEmail, | ||
GIT_COMMITTER_NAME: gitAuthorName, | ||
GIT_COMMITTER_EMAIL: gitAuthorEmail, | ||
}; | ||
await execa('lerna', ['publish', ...finalLernaPublishArgs], { | ||
env, | ||
cwd, | ||
stdio: 'inherit', | ||
}); | ||
}, | ||
}; | ||
} | ||
|
||
module.exports = lernaRelease; |
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,14 @@ | ||
{ | ||
"name": "spire-plugin-lerna-release", | ||
"version": "1.4.1", | ||
"description": "Lerna publish plugin for Spire", | ||
"repository": "researchgate/spire", | ||
"author": "Sergey Bekrin <sergey@bekrin.me> (https://bekrin.me)", | ||
"license": "MIT", | ||
"dependencies": { | ||
"lerna": "^3.13.1" | ||
}, | ||
"peerDependencies": { | ||
"spire": "^1.0.0" | ||
} | ||
} |
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
Oops, something went wrong.