Compare commits

..
249 Commits
Author SHA1 Message Date
Jacob WejendorpandPierre Vanduynslager f6aacd2fe0 fix: Log error messages on reject 2017-10-23 10:43:56 -04:00
Pierre-Denis VanduynslagerandGregor Martynus b0bc49063b fix: handle errors when verifyConditions and verifyRelease are a pipeline 2017-10-18 14:00:20 -07:00
Pierre-Denis VanduynslagerandGregor Martynus 580ad9c3d2 feat: Allow to recover from ENOTINHISTORY with a tag and handle detached head repo
- Tag sha will now be used also if there is a gitHead in last release and it's not in the history
- Use `git merge-base` to determine if a commit is in history, allowing to use CI creating detached head repo
- Mention recovery solution by creating a version tag in `ENOTINHISTORY` and `ENOGITHEAD` error messages
- Do not mention branches containing missing commit in `ENOTINHISTORY` and `ENOGITHEAD` error messages as it's not available by default on most CI
2017-10-11 20:54:10 -07:00
Pierre-Denis VanduynslagerandGregor Martynus 8e9d9f77f3 fix: Always pass pluginConfig to plugins as a defined object 2017-10-06 10:28:37 -07:00
Pierre-Denis Vanduynslager 90417c6ffe fix: Exit with 1 if unexpected error happens 2017-10-06 00:30:08 -04:00
Pierre-Denis Vanduynslager 85dd69b3a2 feat: Retrieve version gitHead from git tags and unshallow the repo if necessary
Add several fixes and improvements in the identification of the last release gitHead:
- If there is no last release, unshallow the repo in order to retrieve all existing commits
- If git head is not present in last release, try to retrieve it from git tag with format ‘v\<version\>’ or ‘\<version\>’
- If the last release git head cannot be determined and  found in commit history, unshallow the repo and try again
- Throw a ENOGITHEAD error if the gitHead for the last release cannot be found in the npm metadata nor in the git tags, preventing to make release based on the all the commits in the repo as before
- Add integration test for the scenario with a packed repo from which `npm republish` fails to read the git head

Fix #447, Fix #393, Fix #280, Fix #276
2017-10-02 19:43:46 -04:00
Pierre-Denis Vanduynslager cbb51a495b ci(codecov): Set default branch in codecov.yml 2017-09-30 16:00:50 -04:00
Pierre-Denis Vanduynslager a58d12d5e7 chore: Update badges 2017-09-30 13:30:41 -04:00
Pierre-Denis Vanduynslager 42b3382b0e ci(travis): Update .travis.yml
- Avoid double build on PR
- Add git fetch depth
- Remove cache
- Retry npm install
2017-09-30 13:30:41 -04:00
Pierre-Denis Vanduynslager cc3c8f2548 ci: Use codecov for code coverage 2017-09-30 13:30:41 -04:00
Pierre-Denis Vanduynslager abf92ad03d refactor: Use ES6, Test with AVA
- Use async/await instead of callbacks
- Use execa to run command line
- Use AVA for tests
- Add several assertions in the unit tests
- Add documentation (comments) in the tests
- Run tests with a real git repo instead of mocking child_process and add test helpers to create repos, commits and checkout
- Simplify test directory structure
- Simplify code readability (mostly with async/await)
- Use eslint for for linting, prettier for formatting
2017-09-30 13:30:41 -04:00
Pierre-Denis Vanduynslager 7fe0890350 chore: Remove editorconfig 2017-09-30 13:30:41 -04:00
Pierre-Denis Vanduynslager f10f157d79 chore: More generic .gitignore (Windows, Mac OS, Linux) 2017-09-30 13:30:41 -04:00
Pierre-Denis Vanduynslager 40e296b00d chore: Remove lockfiles 2017-09-30 13:30:41 -04:00
Pierre-Denis Vanduynslager 266a3f72dc chore: Add license file 2017-09-30 13:30:41 -04:00
greenkeeper[bot]andGregor Martynus 42456a32b3 chore(package): update coveralls to version 3.0.0 2017-09-28 10:25:35 -07:00
greenkeeper[bot]andPierre Vanduynslager 3a4334fbfd fix(package): update @semantic-release/error to version 2.0.0 2017-09-25 13:16:40 -04:00
Richard LittauerandPierre Vanduynslager 41d9b7e984 docs: fix grammatical error in README
Just a small fix to make this sentence parse.
2017-09-22 03:11:24 -04:00
Pierre VanduynslagerandGregor Martynus 9951cf7e00 fix(package): Set minimum node version to 4 (#442) 2017-09-21 11:24:18 -07:00
greenkeeper[bot]andGregor Martynus 2d14c53b11 fix(package): update @semantic-release/last-release-npm to version 2.0.0 2017-09-21 11:08:42 -07:00
greenkeeper[bot]andPierre Vanduynslager 277d9ab4e2 chore(package): update cz-conventional-changelog to version 2.0.0
https://greenkeeper.io/
2017-09-19 18:03:30 -04:00
Stephan SchneiderandPierre Vanduynslager 4612a056a3 chore(package): update commitizen config 2017-09-19 16:42:09 -04:00
greenkeeper[bot]andGregor 8c44c3176a fix(package): update @semantic-release/commit-analyzer to version 3.0.1 2017-09-17 20:31:46 -07:00
greenkeeper[bot] dd60b461a6 fix(package): update @semantic-release/release-notes-generator to version 4.0.0 2017-09-17 19:51:43 +00:00
Richard LittauerandGregor Martynus 88b5895f80 docs(README): update commit lint suggestion (#429)
validate-commit-msg is deprecated, and points to commitlint.
2017-09-14 21:22:18 -07:00
Patrick HeneiseandGregor Martynus 1ceae83ad9 docs(troubleshooting): initial version (#399) 2017-09-13 12:10:50 -07:00
Gregor 12b35396d8 fix(package): @semantic-release/condition-travis@6.0.0
This also introduces the new build leader detecation from https://github.com/semantic-release/travis-deploy-once/releases/tag/v2.0.0
2017-08-19 14:15:28 -07:00
Gregor 33dfcffe2c fix(bin): addapt build leader error to new leader detection algorithm 2017-08-19 14:15:28 -07:00
Stephan BönnemannandGregor Martynus f534c57215 fix: remove support for node < 8
BREAKING CHANGE: Remove support for publishing a package with node < 8. [Details](https://github.com/semantic-release/semantic-release#why-does-semantic-release-require-node-version-8).
2017-08-19 14:15:28 -07:00
Stephan BönnemannandGregor Martynus 9c5288460d chore: add package-lock 2017-08-19 14:15:28 -07:00
Kaito UdagawaandGregor Martynus 0c79a9b4bf fix(post): create git tag properly
refs/heads are for branches and refs/tags for tags.
2017-08-16 20:47:29 -07:00
Kaito UdagawaandGregor Martynus 3f8559731f fix(post): Create a tag before makeing a release 2017-08-13 20:29:49 -07:00
Kaito UdagawaandGregor Martynus f148a61339 fix(post): fix target_commitish to be the default branch
target_commitish in GitHub Releases has two different meanings:
* Target commit that a new associated tag will be created on
* Target branch to compute how many "commits to since this release"

target_commitish is usually the default branch (aka master), because the
distance between the release and the latest branch is the primary concern.

Before this change, target_commitish was left to be a hash and the
feature of GitHub Releases that shows how much time passed since the
release is ruined, because no tracking branch is given.

By this change, target_commitish is changed to be the default branch
given in the configuration (options.branch) via edit a release API after
the release and tag are created via crate a release API.
2017-08-13 20:29:49 -07:00
Gregor 5b3bdd226f chore: remove console.log 2017-08-13 12:10:36 -07:00
Gregor 64d84a0e84 chore(travis): drop builds in Node <4 2017-08-13 12:10:36 -07:00
greenkeeper[bot]andGregor Martynus 1fa6d50264 fix(package): update @semantic-release/release-notes-generator to version 3.0.1
BREAKING CHANGE: Dropped support for unmaintained Node.js versions (< v4)
2017-08-13 12:10:36 -07:00
Jan Peer StöcklmairandGregor Martynus 6145bc9ba5 docs(readme): add sgc (#386) 2017-08-12 15:59:01 -07:00
Piper ChesterandGregor Martynus 609b46f1cf docs(README): minor typo (#376) 2017-06-12 13:41:42 +02:00
greenkeeper[bot]andStephan Bönnemann 76cd99c3a5 chore(package): update standard to version 9.0.0
https://greenkeeper.io/
2017-03-06 10:13:19 +01:00
greenkeeper[bot]andStephan Bönnemann 22dc640117 chore(package): update tap to version 10.0.1
https://greenkeeper.io/
2017-02-03 11:37:47 +01:00
Stephan BönnemannandGitHub af90de989e Merge pull request #355 from semantic-release/dep-updates
Misc GK dep updates
2017-01-13 12:13:30 +01:00
Stephan Bönnemann aa012b3023 Merge branch 'greenkeeper/tap-9.0.0' into dep-updates
* greenkeeper/tap-9.0.0:
  chore(package): update tap to version 9.0.0
2017-01-13 12:04:45 +01:00
Stephan Bönnemann 5724b19e23 Merge branch 'greenkeeper/github-8.0.0' into dep-updates
* greenkeeper/github-8.0.0:
  fix(package): update github to version 8.0.0
2017-01-13 12:04:25 +01:00
Stephan BönnemannandGitHub 97a8e73b01 Merge branch 'caribou' into greenkeeper/nopt-4.0.0 2017-01-13 11:51:22 +01:00
Cory ReedandStephan Bönnemann 51e12a3a4b docs(package): fix 'home' link 2017-01-13 11:51:04 +01:00
greenkeeper[bot] afd6ab754d fix(package): update github to version 8.0.0
https://greenkeeper.io/
2017-01-11 17:54:30 +00:00
greenkeeper[bot] f80e056e13 chore(package): update tap to version 9.0.0
https://greenkeeper.io/
2017-01-08 07:14:51 +00:00
greenkeeper[bot] b10c8910fb fix(package): update nopt to version 4.0.0
https://greenkeeper.io/
2016-12-13 23:38:46 +00:00
greenkeeper[bot]andChristoph Witzko 3295f9570c fix(package): update github to version 7.0.0
https://greenkeeper.io/
2016-12-02 12:33:58 +01:00
Ryan KimberandChristoph Witzko 6a172e1720 docs(README.md): discourage use of pre-patch, pre-minor and pre-release 2016-11-28 17:20:18 +01:00
greenkeeper[bot]andChristoph Witzko 68f975382d chore(package): update dependencies
https://greenkeeper.io/
2016-11-28 16:55:34 +01:00
Christoph Witzko 462c51dc2a style: standard 2016-11-28 16:37:00 +01:00
Christoph Witzko cdf705cb8a chore: update dependencies 2016-11-28 16:37:00 +01:00
Christoph Witzko 9a51b0271d chore: update github client 2016-11-28 16:36:53 +01:00
develarandChristoph Witzko 14618c81c9 chore(package): parse-github-repo-url 2016-11-28 16:14:43 +01:00
develarandChristoph Witzko 35da08d074 test: fix "/bin/bash: NO_PROMPT=yes: command not found" 2016-11-28 16:14:43 +01:00
Ben GummerandStephan Bönnemann 73138f8a8f fix: use spawn instead of exec for 'git log' to avoid maxBuffer err 2016-11-28 15:50:59 +01:00
Mark DalgleishandChristoph Witzko d7f5d19073 docs(readme): fix link to how the CLI works 2016-11-28 11:34:33 +01:00
PAkerstrandandStephan Bönnemann f239f2f402 fix(commits): Use --no-color for git branch-command
When `git branch --contains ${commit}` has colored output the `inHistory` check failed
2016-11-21 09:46:44 -03:00
Stephan Bönnemann 2be6e5d34a fix: use travis-deploy-once to reenable travis-pro support 2016-11-17 15:40:21 -03:00
Joscha FethandStephan Bönnemann a5cb9ea7f7 fix(gitlog): increase maxBuffer
This is needed for repositories with a lot of commits and/or a big changelog.

Closes #286
2016-09-01 14:35:34 +02:00
Stephan BönnemannandGitHub 15e6daf7cc Merge pull request #262 from semantic-release/greenkeeper-npmlog-4.0.0
Update npmlog to version 4.0.0 🚀
2016-07-19 10:04:35 +02:00
greenkeeperio-bot 2326cda3f0 chore(package): update npmlog to version 4.0.0
https://greenkeeper.io/
2016-07-19 02:33:25 +02:00
GreenkeeperandStephan Bönnemann 4afb280bee chore(package): update tap to version 6.2.0 (#260)
https://greenkeeper.io/
2016-07-16 19:55:45 +02:00
GreenkeeperandStephan Bönnemann 7da7695ba1 chore(package): update nyc to version 7.0.0 (#255)
https://greenkeeper.io/
2016-07-09 16:53:56 +02:00
Cory HouseandStephan Bönnemann 41125ee8aa docs(readme): fix grammar 2016-06-28 19:27:43 +02:00
Stephan Bönnemann cca50ef154 Merge pull request #212 from semantic-release/greenkeeper-nock-8.0.0
Update nock to version 8.0.0 🚀
2016-05-27 23:52:24 +02:00
Stephan Bönnemann 4807dee1e2 Merge branch 'caribou' into greenkeeper-nock-8.0.0 2016-05-27 15:31:16 +02:00
Stephan Bönnemann f89792e25b Merge pull request #226 from semantic-release/greenkeeper-run-auto-2.0.0
Update run-auto to version 2.0.0 🚀
2016-05-27 15:30:51 +02:00
Stephan Bönnemann 4078638ce9 Merge branch 'caribou' into greenkeeper-run-auto-2.0.0 2016-05-27 15:17:34 +02:00
Stephan Bönnemann 89ded2d79c refactor(pre): adapt to new run-auto api 2016-05-27 12:52:56 +02:00
Stephan Bönnemann 0a89265ae7 Merge pull request #227 from aquavitae/caribou
Expose cafile from npm config
2016-05-27 12:39:13 +02:00
David Townshend ad2a61586e feat(ssl): expose cafile from npm config 2016-05-23 10:31:14 +02:00
greenkeeperio-bot 45e04be49a chore(package): update run-auto to version 2.0.0
https://greenkeeper.io/
2016-05-18 04:45:45 +02:00
Jake TrentandStephan Bönnemann d9b95940db fix(cli): fix typo in log message 2016-05-10 11:00:47 +02:00
Stephan Bönnemann 2e18266023 Merge pull request #221 from semantic-release/greenkeeper-standard-7.0.1
Update standard to version 7.0.1 🚀
2016-05-04 19:09:04 +02:00
greenkeeperio-bot 9aef361da9 chore(package): update standard to version 7.0.1
https://greenkeeper.io/
2016-05-04 16:55:30 +02:00
greenkeeperio-bot d57cb70c56 chore(package): update nock to version 8.0.0
http://greenkeeper.io/
2016-04-06 11:59:26 +02:00
Stephan Bönnemann 4b64afefe4 Merge pull request #204 from semantic-release/fix-no-readme
fix: only ever change version field in published package.json
2016-03-17 16:46:58 +01:00
Stephan Bönnemann bca89a5274 fix: only ever change version field in published package.json
Closes #203
2016-03-17 16:40:04 +01:00
Stephan Bönnemann f579d76596 Merge pull request #198 from semantic-release/greenkeeper-nyc-6.1.1
Update nyc to version 6.1.1 🚀
2016-03-17 16:36:45 +01:00
greenkeeperio-botandStephan Bönnemann 07eb9f845c chore(package): update nyc to version 6.1.1
http://greenkeeper.io/
2016-03-17 16:32:44 +01:00
Christoph Witzko 08b97e9a5f Merge pull request #201 from ColinEberhardt/ColinEberhardt-patch-1
docs(read): fixed typo
2016-03-16 22:30:16 +01:00
Colin Eberhardt 4b22426873 docs(read): fixed typo 2016-03-16 21:12:40 +00:00
Christoph Witzko c7686752ab Merge pull request #188 from coderbyheart/caribou
Fix link to explanation of commit message format
2016-02-13 20:50:27 +01:00
Markus Tacker 342064f198 docs(readme): fix link to explanation of commit message format
The conventions have been split off in ajoslin/conventional-changelog@48580b0391

One could also link to the pinned version, https://github.com/stevemao/conventional-changelog-angular/blob/f07464cd7577e3c0aab9d400e9ca8da219603bba/convention.md
2016-02-13 20:22:23 +01:00
Stephan Bönnemann 5b387657a7 Merge pull request #187 from semantic-release/greenkeeper-standard-6.0.3
Update standard to version 6.0.3 🚀
2016-02-07 14:25:08 +01:00
greenkeeperio-bot 3141a7616b chore(package): update standard to version 6.0.3
http://greenkeeper.io/
2016-02-07 05:41:55 +01:00
Stephan Bönnemann eec7c94b21 Merge pull request #179 from semantic-release/greenkeeper-nock-7.0.1
Update nock to version 7.0.1 🚀
2016-01-27 10:58:21 +01:00
greenkeeperio-bot 24f131adb4 chore(package): update nock to version 7.0.1
http://greenkeeper.io/
2016-01-27 10:34:37 +01:00
Stephan Bönnemann 95d9142d27 Merge pull request #174 from semantic-release/greenkeeper-nixt-0.5.0
Update nixt to version 0.5.0 🚀
2016-01-21 09:55:59 +01:00
greenkeeperio-bot 79b737e868 chore(package): update nixt to version 0.5.0
http://greenkeeper.io/
2016-01-21 08:27:10 +01:00
Stephan Bönnemann adc65e4950 Merge pull request #171 from jrwebdev/caribou
feat(post): Adds GitHub Enterprise support
2016-01-18 23:11:56 +01:00
jrwebdev 2644badeec feat(post): Adds GitHub Enterprise support
Adds githubApiPathPrefix option for GitHub Enterprise APIs. Removes parse-github-repo-url check from
verify to support custom GitHub URLs

closes #146
2016-01-18 18:29:15 +13:00
Stephan Bönnemann 6492693489 Merge pull request #169 from semantic-release/greenkeeper-lodash-4.0.0
Update lodash to version 4.0.0 🚀
2016-01-13 09:29:30 +01:00
Stephan Bönnemann 045909e7e5 Merge branch 'caribou' into greenkeeper-lodash-4.0.0 2016-01-13 09:22:36 +01:00
Gleb BahmutovandStephan Bönnemann 66454e7e46 feat(verify): added support for parsing hosted gitlab and other repo urls
Closes #114
2016-01-13 09:04:35 +01:00
greenkeeperio-bot 5e73831e6e chore(package): update lodash to version 4.0.0
http://greenkeeper.io/
2016-01-13 00:16:27 +01:00
Stephan Bönnemann 8491deb5c6 Merge pull request #167 from semantic-release/greenkeeper-nock-5.2.1
Update nock to version 5.2.1 🚀
2016-01-09 19:28:39 +01:00
greenkeeperio-bot e03ecfe0b4 chore(package): update nock to version 5.2.1
http://greenkeeper.io/
2016-01-08 10:49:35 +01:00
Stephan Bönnemann a1ab8ee34e Merge pull request #162 from semantic-release/greenkeeper-tap-5.0.0
Update tap to version 5.0.0 🚀
2016-01-04 12:03:46 +01:00
Stephan Bönnemann b1130efc5a Merge branch 'caribou' into greenkeeper-tap-5.0.0 2016-01-04 11:35:38 +01:00
Stephan Bönnemann 3ee0945995 Merge pull request #163 from semantic-release/greenkeeper-nock-4.0.0
Update nock to version 4.0.0 🚀
2016-01-04 11:33:03 +01:00
greenkeeperio-bot c76a8c8f2d chore(package): update nock to version 4.0.0
http://greenkeeper.io/
2016-01-04 10:45:43 +01:00
greenkeeperio-bot 7bd9e74aa7 chore(package): update tap to version 5.0.0
http://greenkeeper.io/
2016-01-04 08:57:57 +01:00
Stephan Bönnemann 6f5c9f0890 Merge pull request #159 from semantic-release/greenkeeper-tap-4.0.0
Update tap to version 4.0.0 🚀
2015-12-31 15:23:21 +01:00
Stephan Bönnemann bb63f9de41 Merge branch 'caribou' into greenkeeper-tap-4.0.0 2015-12-31 15:16:38 +01:00
Stephan Bönnemann 032b493696 Merge pull request #160 from semantic-release/chore-remove-babel
chore: remove babel, fix integration tests
2015-12-31 15:16:27 +01:00
Stephan Bönnemann 5cdc732b68 chore: remove babel, fix integration tests
This commit removes babel/es6 from all source and test files, because it was introducing a lot of overhead and only little gain.
This commit fixes and enables integration tests on Travis.
This commit fixes #153 and #151 along the way.

_Originally this commit should have only removed babel, but without working tests that's a bit too hairy._
_I only realized that half way into removing babel/es6, so things are all over the place now._

Closes #153, Closes #151
2015-12-31 15:11:54 +01:00
greenkeeperio-bot c8ec292e39 chore(package): update tap to version 4.0.0
http://greenkeeper.io/
2015-12-31 02:05:33 +01:00
Stephan Bönnemann 88334523e4 Merge pull request #144 from semantic-release/greenkeeper-nyc-5.0.0
Update nyc to version 5.0.0 🚀
2015-12-10 10:11:32 +01:00
greenkeeperio-bot 224c8048ac chore(package): update nyc to version 5.0.0
http://greenkeeper.io/
2015-12-10 08:08:55 +01:00
Christoph Witzko c5dd9121f7 Merge pull request #142 from Starefossen/patch-1
Run Travis tests under Node.js v4 (argon) and v5 (latest)
2015-12-04 13:38:57 +01:00
Hans Kristian Flaatten 07d2a1907a chore(travis): run tests under Node.js v4 (argon) and v5 (latest) 2015-12-04 10:40:04 +01:00
Stephan Bönnemann 006213b9ca Merge pull request #119 from hawkrives/normalize-package-metadata
Use normalize-package-metadata to normalize package.json info
2015-11-26 13:43:57 +01:00
Hawken Rives 9baeddf712 use normalize-package-metadata to normalize pkgs 2015-11-21 19:42:18 -06:00
Stephan Bönnemann ace79e745a Merge pull request #133 from semantic-release/greenkeeper-nock-3.0.0
Update nock to version 3.0.0 🚀
2015-11-16 21:02:43 +01:00
greenkeeperio-bot 877514799b chore(package): update nock to version 3.0.0
http://greenkeeper.io/
2015-11-16 10:36:07 +01:00
Stephan Bönnemann 8d7b787e4a Merge pull request #125 from semantic-release/greenkeeper-npmlog-2.0.0
Update npmlog to version 2.0.0 🚀
2015-11-05 10:25:51 +01:00
greenkeeperio-bot 3648cd21e1 chore(package): update npmlog to version 2.0.0
http://greenkeeper.io/
2015-11-05 08:19:25 +01:00
Matteo RonchiandStephan Bönnemann de4bd7750e docs(readme): update link to deprecated npm cli tag command 2015-10-13 12:03:30 +02:00
Stephan Bönnemann 143987d070 chore(package): consistently use carets again 2015-10-10 13:37:02 +02:00
Christoph Witzko 02c4992440 Merge pull request #113 from semantic-release/greenkeeper-rimraf-2.4.3
Update rimraf to version 2.4.3 🚀
2015-10-10 13:34:28 +02:00
greenkeeperio-botandStephan Bönnemann abe4da1aa3 chore(package): update rimraf to version 2.4.3
http://greenkeeper.io/
2015-10-10 01:03:06 +02:00
Stephan Bönnemann f2a94e50f1 Merge pull request #112 from semantic-release/greenkeeper-tap-2.1.1
Update tap to version 2.1.1 🚀
2015-10-09 16:23:10 +02:00
greenkeeperio-botandStephan Bönnemann 3c14c5747f chore(package): update tap to version 2.1.1
http://greenkeeper.io/
2015-10-09 15:07:36 +02:00
Stephan Bönnemann 8cc6e0ced9 Merge pull request #110 from semantic-release/greenkeeper-cz-conventional-changelog-1.1.4
Update cz-conventional-changelog to version 1.1.4 🚀
2015-10-08 21:04:54 +02:00
greenkeeperio-botandStephan Bönnemann 2613d5df91 chore(package): update cz-conventional-changelog to version 1.1.4
http://greenkeeper.io/
2015-10-08 20:04:25 +02:00
Stephan Bönnemann ce04093b12 Merge pull request #107 from semantic-release/greenkeeper-proxyquire-1.7.3
Updated proxyquire to version 1.7.3
2015-10-05 20:50:36 +02:00
greenkeeperio-botandStephan Bönnemann fea11ef155 chore(package): update proxyquire to version 1.7.3
http://greenkeeper.io/
2015-10-05 16:36:14 +02:00
Stephan Bönnemann 6702531770 Merge pull request #105 from semantic-release/greenkeeper-nock-2.13.0
Updated nock to version 2.13.0
2015-10-02 17:26:16 +02:00
greenkeeperio-botandStephan Bönnemann 3f64ee625e chore(package): update nock to version 2.13.0
http://greenkeeper.io/
2015-10-02 17:18:19 +02:00
Stephan Bönnemann 1b8a01472e Merge pull request #103 from semantic-release/greenkeeper-coveralls-2.11.4
Updated coveralls to version 2.11.4
2015-10-01 16:32:46 +02:00
greenkeeperio-botandStephan Bönnemann c1c3848d0b chore(package): update coveralls to version 2.11.4
http://greenkeeper.io/
2015-10-01 14:01:19 +02:00
Stephan Bönnemann 1a0b702002 Merge pull request #102 from semantic-release/greenkeeper-cz-conventional-changelog-1.1.2
Updated cz-conventional-changelog to version 1.1.2
2015-09-29 21:51:06 +02:00
Stephan Bönnemann 066e1dd4d1 Merge branch 'caribou' into greenkeeper-cz-conventional-changelog-1.1.2 2015-09-29 21:45:49 +02:00
Stephan Bönnemann e900d5eae7 Merge pull request #94 from semantic-release/greenkeeper-lodash-3.10.1
Updated lodash to version 3.10.1
2015-09-29 21:45:39 +02:00
greenkeeperio-botandStephan Bönnemann f4f783ba6f chore(package): update cz-conventional-changelog to version 1.1.2
http://greenkeeper.io/
2015-09-29 18:01:19 +02:00
Stephan Bönnemann 9eba8bf7c7 Merge branch 'caribou' into greenkeeper-lodash-3.10.1 2015-09-29 10:04:49 +02:00
Stephan Bönnemann 754ef3b12b Merge pull request #100 from semantic-release/greenkeeper-semver-5.0.3
Updated semver to version 5.0.3
2015-09-28 21:01:31 +02:00
greenkeeperio-botandStephan Bönnemann a1eb9a25bb chore(package): update semver to version 5.0.3
http://greenkeeper.io/
2015-09-28 20:53:41 +02:00
Stephan Bönnemann 268d5f37bf Merge pull request #96 from semantic-release/docs-readme
docs(README): fix mistake in headline
2015-09-27 12:27:06 +02:00
Stephan Bönnemann 269fb519bf docs(README): fix mistake in headline
Closes #95
2015-09-27 12:22:33 +02:00
greenkeeperio-botandStephan Bönnemann 172718df54 chore(package): updated lodash to version 3.10.1
http://greenkeeper.io/
2015-09-27 06:32:32 +02:00
Stephan Bönnemann 19150d84fb Merge pull request #93 from semantic-release/greenkeeper-pin
Pinned all dependencies
2015-09-26 20:38:47 +02:00
Stephan Bönnemann 26e2afc152 test: end tests properly 2015-09-26 20:22:11 +02:00
Stephan Bönnemann 927e930bb9 style(standard): fix ternaries 2015-09-26 12:45:11 +02:00
greenkeeperio-botandStephan Bönnemann 785140f80c chore(package): pinned dependencies
http://greenkeeper.io/
2015-09-25 13:17:54 +02:00
Stephan Bönnemann e19b1952d1 Merge pull request #90 from gr2m/patch-1
use correct condition-travis version
2015-09-21 23:19:43 +02:00
Gregor Martynus ef872e38fb fix(package): use correct condition-travis version 2015-09-21 19:24:36 +02:00
Stephan Bönnemann ba40ffe70d Merge pull request #88 from semantic-release/docs-commitizen-link
Docs commitizen link
2015-09-18 12:27:59 +02:00
Stephan Bönnemann c614fe4a74 docs(README): add example commits 2015-09-18 11:41:58 +02:00
Kent C. DoddsandStephan Bönnemann 81de8ae19b docs(readme): add convention links
Link to commitizen and validate-commit-msg for project maintainers to simplify contributing.
2015-09-18 11:24:55 +02:00
Stephan Bönnemann df5f8337e8 Merge pull request #85 from semantic-release/fix-git-contains
Fix git contains
2015-09-16 09:56:36 +02:00
Stephan Bönnemann cb3992595e fix(commits): handle failing git command correctly and show meaningful error
Closes #83
2015-09-16 09:52:09 +02:00
Stephan Bönnemann a3f561d1d1 test(mocks): correctly fail git command when ref not in history 2015-09-16 09:51:26 +02:00
Stephan Bönnemann 143457e03d docs(README): smaller fixes and clarifications 2015-09-16 09:25:04 +02:00
Stephan Bönnemann 2c17773c75 docs(README): add egghead.io tutorial 2015-09-08 10:07:39 +01:00
Stephan Bönnemann 0a17e8e780 chore: make repo "commitizen friendly"
Closes #74
2015-08-28 10:29:48 +02:00
Stephan Bönnemann a7270bb84c fix: write version to shrinkwrap if existent
Closes #11
2015-08-24 15:56:55 +02:00
Stephan Bönnemann 0e013c2dea docs(README): fix badge links 2015-08-24 14:59:24 +02:00
Stephan Bönnemann e1baf1892a chore: setup release branch 2015-08-24 12:00:59 +02:00
Stephan Bönnemann ef1623210b docs: breaking change
BREAKING CHANGE: If you run travis_after_all and travis-after-all at the same
time they'll keep waiting for each other until forever. You have to apply
this patch to your `.travis.yml`.

```diff
---
 .travis.yml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a5fbddb..c76091b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,9 +14,6 @@ before_install:
 - npm i -g npm@^2.0.0
 before_script:
 - npm prune
-- curl -Lo travis_after_all.py https://git.io/vLSON
 after_success:
-- python travis_after_all.py
-- export $(cat .to_export_back)
 - npm run semantic-release
--
```
2015-08-23 22:42:55 +02:00
Stephan Bönnemann ad9501540e docs(README): use equally sized, optimized talk thumbnails 2015-08-23 14:26:47 +02:00
Stephan Bönnemann 7af30f0ad4 docs(README): list plugins and more talks 2015-08-23 14:16:09 +02:00
Stephan Bönnemann 4aa908804c fix(condition-travis): remove need for python script travis_after_all 2015-08-23 00:53:04 +02:00
Stephan Bönnemann 451378117d fix(registry): be better at using the correct registry (relevant for npme)
Closes #53
2015-08-22 23:32:49 +02:00
Stephan Bönnemann 23221cc044 chore(package): update last-release-npm to 1.2.1 2015-08-22 21:48:00 +02:00
Stephan Bönnemann 7a4c89f131 feat: add fallbackTag functionality and map "next" to "latest"
You can now map dist-tags onto "fallbackTags". E.g. if you want a
development channel like "next" and no version is currently published as "next"
semantic-release will fallback to "latest" to determine the new "next" version.
This is now the default for "next" -> "latest", but you can specify your own
mappings by adding "fallbackTags" to your `package.json`'s "release" field.

BREAKING CHANGE: In cases where you pushed a new commit with a "dist-tag"
configuration of "next" and no version was previously published as "next",
semanitc-release failed and did not publish a new version. It will now
automatically fall back to to "latest".
2015-08-22 21:36:11 +02:00
Stephan Bönnemann 2405453f2d docs(README): nice badge pyramid 2015-08-22 19:53:36 +02:00
Stephan Bönnemann a16c36ed4d style: branch available in options not root of config 2015-08-22 19:49:09 +02:00
Stephan Bönnemann 5cc7da6035 fix(commits): add helpful error when lastRelease not in history
Closes #61, Closes #50
2015-08-22 19:31:29 +02:00
Stephan Bönnemann a2d6db2ce5 docs(README): document verification pipelines 2015-08-22 14:55:25 +02:00
Stephan Bönnemann 700ec9d4ca feat(plugins): run verifications in series
With this new feature you can pass an array of plugin locations/names to
both "verifyConditions" and "verifyRelease" in your `package.json`'s "release"
field. This will run multiple verification plugins in series.
2015-08-22 14:52:01 +02:00
Stephan Bönnemann 7b8f632396 fix: clearer logput 2015-08-22 12:01:42 +02:00
Stephan Bönnemann b47311d565 fix: correctly obfuscate githubToken with verbose loglevel 2015-08-22 11:34:50 +02:00
Stephan Bönnemann 810b3533dd refactor(nerf-dart): use module from npm 2015-08-20 14:31:18 +02:00
Stephan Bönnemann b397ffe91f Merge pull request #58 from tlvince/get-last-release
Document the getLastRelease plugin
2015-08-18 15:13:21 +02:00
Tom Vincent 471a67fc31 docs(readme): document the getLastRelease plugin 2015-08-18 14:04:56 +01:00
Tom Vincent 557c46b8dd docs(readme): enhance plugin section grammar 2015-08-18 13:58:38 +01:00
Ari PoradandStephan Bönnemann 7ceac76689 feat(plugins): add getLastRelease hook
The code to determine the last-release is now in its own repository: https://github.com/semantic-release/last-release-npm
One can overwrite that behavior by defining a "getLastRelease" plugin. This way
one can decouple semantic-release from npm, e.g. by implementing a git-tag
based version. This is already worked on: https://github.com/semantic-release/last-release-git-tag

Closes #56
2015-08-18 13:56:24 +02:00
Stephan Bönnemann 77349fcdf1 docs(readme): add badge section 2015-08-10 22:04:21 +02:00
Stephan Bönnemann aae79cab72 docs(readme): remove table around badges 2015-08-10 21:58:45 +02:00
Stephan Bönnemann 55364ded40 fix(package): remove dependency bundling
Removes dependency bundling, because it's broken for scoped modules with npm
right now. Keeps npm from logging four ugly warnings upon install.
Can be reverted once https://github.com/npm/npm/issues/9175 is closed.
2015-08-10 17:10:58 +02:00
Stephan Bönnemann 3a7be436e9 chore(package): update standard 2015-08-10 17:09:46 +02:00
The Gitter BadgerandStephan Bönnemann 2b284fcc90 docs(readme): added Gitter badge 2015-08-10 17:03:20 +02:00
Stephan Bönnemann fb1aa80f26 fix(package): fix version ranges for engines to include specified versions 2015-08-04 14:15:52 +02:00
Stephan Bönnemann 05490fe229 test(last-release): adapt registry-mock to how the registry actually behaves 2015-07-30 17:15:03 +01:00
Stephan Bönnemann 76d9e3d2be fix(last-release): encode scoped packages 2015-07-30 17:10:06 +01:00
Stephan Bönnemann 776ffd1256 docs(readme): further explanations and formatting improvements 2015-07-27 01:37:10 +02:00
Stephan Bönnemann 494f851ee7 docs(readme): more explanations for "what is this about" 2015-07-23 10:13:22 +02:00
Stephan Bönnemann 3bdeff3468 docs(readme): add cli and remove manual setup 2015-07-22 17:23:36 +02:00
Stephan Bönnemann 8dd79565d0 chore(package): add required engines 2015-07-22 17:20:05 +02:00
Stephan Bönnemann a344f32e36 Merge pull request #49 from lewiscowper/typos
docs(readme): various grammar fixes
2015-07-22 10:58:26 +02:00
Lewis Cowper e1c1b7419b docs(readme): various grammar fixes 2015-07-22 09:43:58 +01:00
Stephan Bönnemann 3eb842c297 docs(readme): initial documentation 2015-07-22 00:13:42 +02:00
Stephan Bönnemann ddaec4f2bf test(integration): make em at least run locally 2015-07-19 16:21:40 +02:00
Stephan Bönnemann 22a283a027 chore: prepare to move back to main repo#next 2015-07-19 16:05:03 +02:00
Stephan Bönnemann d9eeb3fcae refactor: use one config object instead of passing arguments to plugins on their own
This commit does a lot but it's all connected and tries to make everything more extensible and future proof.

1. CLI arguments and options from the "package.json" are no longer treated as two different things. You can now pass options either way.

BREAKING CHANGE: cli arguments are now normalized to camelCase, so e.g. `options['github-url']` is now `options.githubUrl`

2. Plugins no longer receive config they need one by one, but in one huge object. This way it's easier to pass more info in the future w/o breaking existing plugins that rely on the position of the callback in the arguments array.

BREAKING CHANGE: Plugins now need to read their passed options from one huge config object.

Old:
```js
module.exports = function (pluginConfig, foo, bar, cb) {…}
```

New:
```js
// ES5
module.exports = function(pluginConfig, config, cb) {
  var foo = config.foo
  var bar = config.bar
  …
}

// ES6
module.exports = function (pluginConfig, {foo, bar}, cb) {…}
```
2015-07-19 15:34:30 +02:00
Stephan Bönnemann 8892ec7f7a fix(plugins): typo in plugin name 2015-07-17 16:51:06 +02:00
Stephan Bönnemann cf27cd16cc chore(package): ignore config files 2015-07-17 15:10:10 +02:00
Stephan Bönnemann 152d1f6874 chore(travis): simplify config 2015-07-17 14:56:56 +02:00
Stephan Bönnemann 626315e9fe feat(package): update condition-travis 2015-07-17 14:56:44 +02:00
Stephan Bönnemann f5573f7494 chore(package): bump condition-travis 2015-07-17 10:01:52 +02:00
Stephan Bönnemann 2d3506cda1 chore: setup semantic-release 2015-07-17 09:35:53 +02:00
Stephan Bönnemann 72f9f8ea7c chore: rename to scripts 2015-07-16 19:36:42 +02:00
Stephan Bönnemann 59d852d6fb feat(post): initial 2015-07-16 17:30:23 +02:00
Stephan Bönnemann ed05101a61 test(post): initial 2015-07-16 17:30:14 +02:00
Stephan Bönnemann 431babb42e fix(verify): ensure repo url in package.json is well formed 2015-07-16 14:07:52 +02:00
Stephan Bönnemann dbea5cc1b1 feat(last-release): add custom dist-tag 2015-07-16 11:51:33 +02:00
Stephan Bönnemann 6cf1711151 test(last-release): add custom dist-tag 2015-07-16 11:51:22 +02:00
Stephan Bönnemann ba5222af52 chore(package): update semver 2015-07-14 21:13:36 +02:00
Stephan Bönnemann b1d9985ba3 test(plugins): test exported plugins 2015-07-14 21:13:36 +02:00
Stephan Bönnemann 13e2f5ce78 feat(cli): add verifyConditions hook 2015-07-14 21:13:36 +02:00
Stephan Bönnemann af15fb4c61 fix(last-release): normalized registry url 2015-07-14 21:13:36 +02:00
Stephan Bönnemann caf09c9be0 fix(cli): only write npmrc when necessary 2015-07-14 18:30:30 +02:00
Stephan Bönnemann 0316babf7a refactor(error): use error module 2015-07-14 12:25:36 +02:00
Stephan Bönnemann 43c8df0bfe fix(plugins): require user plugins relative to the cwd 2015-07-13 12:03:05 +02:00
Stephan Bönnemann 150273c8fe fix(plugins): rename plugins 2015-07-13 11:53:32 +02:00
Stephan Bönnemann f247ed8741 chore(package): remove integration tests from default test command 2015-07-09 15:33:59 +02:00
Stephan Bönnemann 2eff4a4467 style(type): add dot at end of sentence 2015-07-09 02:10:39 +02:00
Stephan Bönnemann e1d5da5864 fix(plugins): pass right path to generateNotes 2015-07-09 02:10:39 +02:00
Stephan Bönnemann a0190b7ad3 feat(bin): implement cli 2015-07-09 02:10:39 +02:00
Stephan Bönnemann c6f95e4870 test(pre): initial cli/integration suite 2015-07-09 02:10:39 +02:00
Stephan Bönnemann 6d84b66c05 test(test-module): creates integration test env on disk 2015-07-09 02:10:38 +02:00
Stephan Bönnemann 4d58af7145 test(base-scenario): creates nixt testing base 2015-07-09 02:10:38 +02:00
Stephan Bönnemann 9a3d9a9280 chore: add editorconfig 2015-07-09 02:10:38 +02:00
Stephan Bönnemann 32c1dcf75b test(registry): lib to start and stop an npm-registry-couchapp 2015-07-09 02:10:38 +02:00
Stephan Bönnemann 4093bb2dbe feat: initial 2015-07-08 20:41:36 +02:00
Stephan Bönnemann c59b5cac9c feat(nerf-dart): copy in nerf-dart module from npm 2015-06-19 18:35:25 -07:00
Stephan Bönnemann 44a18fd5cf chore(package): install commit analyzer and release note generator 2015-06-19 17:33:27 -07:00
Stephan Bönnemann e24c7c3833 chore(coverage): switch to coveralls 2015-06-18 16:48:28 -07:00
Stephan Bönnemann 057e8e9759 feat(plugins): normalize plugins and have unified function signature 2015-06-18 16:48:28 -07:00
Stephan Bönnemann da23c15ea5 test(plugins): initial suite 2015-06-18 16:10:55 -07:00
Stephan Bönnemann b63a43fa53 feat(verify): initial verification for pkg, options and env 2015-06-17 15:42:14 -07:00
Stephan Bönnemann c47ff97ab3 test(verify): initial suite 2015-06-17 15:41:26 -07:00
Stephan Bönnemann 689f37ae2e test(specs): how about running ALL tests? 2015-06-14 21:50:53 -07:00
Stephan Bönnemann a4fe18cade feat(pre): plugging last-release, commits and type together 2015-06-14 21:49:50 -07:00
Stephan Bönnemann 7412401d55 test(pre): initial suite 2015-06-14 21:49:50 -07:00
Stephan Bönnemann 6df67828fe refactor(commits,type): simplify interfaces 2015-06-14 21:49:39 -07:00
Stephan Bönnemann 66bf8ff710 refactor(mocks): extract from specs 2015-06-14 21:07:39 -07:00
Stephan Bönnemann a405021d08 feat(type): initial functionality 2015-06-14 19:40:05 -07:00
Stephan Bönnemann f79e26dcd6 test(type): initial suite 2015-06-14 19:39:38 -07:00
Stephan Bönnemann 861debb85e feat(commits): initial functionality 2015-06-14 18:17:25 -07:00
Stephan Bönnemann d6172b8767 test(commits): initial suite 2015-06-14 18:17:25 -07:00
Stephan Bönnemann f62525ad7e feat(last-release): initial functionality 2015-06-14 18:17:25 -07:00
Stephan Bönnemann cce860ec03 test(last-release): initial suite 2015-06-14 18:17:25 -07:00
Stephan Bönnemann 56238887d3 chore: config files 2015-06-14 18:17:25 -07:00
Stephan Bönnemann ac7037d948 chore: root 2015-06-12 18:55:23 -07:00
57 changed files with 2701 additions and 592 deletions
+136 -2
View File
@@ -1,3 +1,137 @@
node_modules
# Created by https://www.gitignore.io/api/macos,windows,linux,node
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Node ###
# Logs
logs
*.log
.tmp
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/macos,windows,linux,node
package-lock.json
yarn.lock
# Registry tests
test/helpers/registry/couch
test/helpers/registry/data
test/helpers/tmp
+1
View File
@@ -0,0 +1 @@
package-lock=false
+22 -17
View File
@@ -1,20 +1,25 @@
language: node_js
node_js:
- '0.10'
sudo: false
cache:
directories:
- node_modules
services:
- couchdb
notifications:
email: false
before_install:
- npm i -g npm@^2.0.0
deploy:
provider: npm
email: stephan@boennemann.me
skip_cleanup: true
api_key:
secure: Lq1FZweaNr/Ah8M7h3oWQ59HTswzvcksTUfzWb/dpqNn5FECN9I+4gi79EQPD62ZbJDCuDHY0EEEDLdnaB1z8N7kOj1RtmvC1k0teTEXFsGBPS4evXakRj+AfoBAGsTaXHqBYBOvYBxJT2Md/UoOgPSQjtAdZSNsmoFb1xkngQ0=
on:
branch: master
repo: boennemann/semantic-release
node_js:
- 8
# Trigger a push build on caribou and greenkeeper branches + PRs build on every branches
# Avoid double build on PRs (See https://github.com/travis-ci/travis-ci/issues/1147)
branches:
only:
- caribou
- /^greenkeeper.*$/
# Retry install on fail to avoid failing a build on network/disk/external errors
install:
- travis_retry npm install
script:
- npm run test
after_success:
- npm run codecov
- npm run semantic-release
+1
View File
@@ -0,0 +1 @@
--install.no-lockfile true
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+288 -12
View File
@@ -1,24 +1,300 @@
# semantic-release
[![Build Status](https://travis-ci.org/boennemann/semantic-release.svg)](https://travis-ci.org/boennemann/semantic-release)
[![Dependency Status](https://david-dm.org/boennemann/semantic-release.svg)](https://david-dm.org/boennemann/semantic-release)
[![devDependency Status](https://david-dm.org/boennemann/semantic-release/dev-status.svg)](https://david-dm.org/boennemann/semantic-release#info=devDependencies)
# :package::rocket: semantic-release
**fully automated package publishing**
> **Trust us, this will change your workflow for the better.**
> [egghead.io](https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-automating-releases-with-semantic-release)
[![Join the chat at https://gitter.im/semantic-release/semantic-release](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/semantic-release/semantic-release?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![npm](https://img.shields.io/npm/v/semantic-release.svg)](https://www.npmjs.com/package/semantic-release)
[![Greenkeeper badge](https://badges.greenkeeper.io/semantic-release/semantic-release.svg)](https://greenkeeper.io/)
[![license](https://img.shields.io/github/license/semantic-release/semantic-release.svg)](https://github.com/semantic-release/semantic-release/blob/master/LICENSE)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Travis](https://img.shields.io/travis/semantic-release/semantic-release/caribou.svg)](https://travis-ci.org/semantic-release/semantic-release)
[![Codecov](https://img.shields.io/codecov/c/github/semantic-release/semantic-release/caribou.svg)](https://codecov.io/gh/semantic-release/semantic-release)
Out of the box this is just about _commit-messages_, but you can do so much more.
* **Detect breaking changes** using the test suite of your last release: [cracks](https://github.com/semantic-release/cracks)
* Detect breaking changes using your dependents test suites: [Help out! Implement the **dont-break** plugin](https://github.com/semantic-release/semantic-release/issues/65)
* Detect breaking changes diffing your JSDoc interface: [Help out! Implement the **india** plugin](https://github.com/semantic-release/semantic-release/issues/66)
* Abort releases with **insufficient test coverage**: [Help out! Implement the **istanbul** plugin](https://github.com/semantic-release/semantic-release/issues/68)
* Abort releases with **vulnerable dependencies** in the tree: [Help out! Implement the **nsp** plugin](https://github.com/semantic-release/semantic-release/issues/67)
* Everything you can imagine: [Build Plugins!](https://github.com/semantic-release/semantic-release#plugins)
&nbsp; | Commands | Comment
--- | --- | ---
| **manual/before** | <pre><code><div>npm version major</div><div>git push origin master --tags</div><div>npm publish</div></code></pre> | You **manually decide** what the **next version** is. You have to remember what major, minor and patch means. You have to remember to push both commits and tags. You have to wait for the CI to pass. |
| **semantic-release/after** | <pre><code><div>git commit -m "fix: &lt;message&gt;"</div><div>git push</div></code></pre> | You **describe the changes** youve made. A new version is automatically published with the correct version number.
This removes the immediate connection between human emotions and version numbers, so strictly following the [SemVer](http://semver.org/) spec is not a problem anymore  and thats ultimately `semantic-release`s goal.
<table>
<tr>
<th colspan="2">
“How to Write a JavaScript Library - Automating Releases with semantic-release”  egghead.io
</th>
</tr>
<tr>
<td colspan="2">
<a href="https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-automating-releases-with-semantic-release"><img src="https://cloud.githubusercontent.com/assets/908178/9730739/7b1da5d8-5610-11e5-88b6-5c75fdda7ee2.png" alt="egghead.io session"></a>
</td>
</tr>
<tr>
<td colspan="2">
A free egghead.io tutorial series on how to write an open source library featuring semantic-release.
</td>
</tr>
<tr>
<th>
“We fail to follow SemVer and why it neednt matter”
</th>
<th>
“semantic-release Q&A with Kent C. Dodds”
</th>
</tr>
<tr>
<td>
<a href="https://www.youtube.com/watch?v=tc2UgG5L7WM&amp;index=6&amp;list=PLFZ5NyC0xHDaaTy6tY9p0C0jd_rRRl5Zm"><img alt="JSConfBP Talk" src="https://cloud.githubusercontent.com/assets/908178/9428178/c337ed26-49a2-11e5-8ad0-a602500a65bf.png"></a>
</td>
<td>
<a href="https://www.youtube.com/watch?v=g6y3DnhkjrI"><img alt="Hangout on Air with Kent C. Dodds" src="https://cloud.githubusercontent.com/assets/908178/9428179/c3387318-49a2-11e5-9f5f-dccd3fbb0c1d.png"></a>
</td>
</tr>
<tr>
<td>
This talk gives you a complete introduction to the underlying concepts of this module. 38:30
</td>
<td>
A “Hangouts on Air” conversation with hands on questions and answers about how to use semantic-release. 53:52
</td>
</tr>
</table>
## How does it work?
Instead of writing [meaningless commit messages](http://whatthecommit.com/), we can take our time to think about the changes in the codebase and write them down. Following formalized conventions it is then possible to generate a helpful changelog and to derive the next semantic version number from them.
When `semantic-release` is set up it will do that after every successful continuous integration build of your master branch (or any other branch you specify) and publish the new version for you. This way no human is directly involved in the release process and your releases are guaranteed to be [unromantic and unsentimental](http://sentimentalversioning.org/).
If you fear the loss of control over timing and marketing implications of software releases you should know that `semantic-release` supports [release channels](https://github.com/npm/npm/issues/2718) using `npm`s [dist-tags](https://docs.npmjs.com/cli/dist-tag). This way you can keep control over what your users end up using by default, you can decide when to promote an automatically released version to the stable channel, and you can choose which versions to write blogposts and tweets about. You can use the same mechanism to [support older versions of your software](https://gist.github.com/boennemann/54042374e49c7ade8910), for example with important security fixes.
This is what happens in series:
| 1. `git push` | 2. `semantic-release pre` | 3. `npm publish` | 4. `semantic-release post` |
| :--- | :--- | :--- | :---- |
| New code is pushed and triggers a CI build. | Based on all commits that happened since the last release, the new version number gets written to the `package.json`. | The new version gets published to `npm`. | A changelog gets generated and a [release](https://help.github.com/articles/about-releases/) (including a git tag) on GitHub gets created. |
_Note:_ The current release/tag implementation is tied to GitHub, but could be opened up to Bitbucket, GitLab, et al. Feel free to send PRs for these services.
## Default Commit Message Format
This module ships with the [AngularJS Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit) and changelog generator, but you can [define your own](#plugins) style.
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
format that includes a **type**, a **scope** and a **subject** ([full explanation](https://github.com/stevemao/conventional-changelog-angular/blob/master/convention.md)):
```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```
You can simplify using this convention for yourself and contributors by using [commitizen](https://github.com/commitizen/cz-cli) and [commitlint](https://github.com/marionebl/commitlint) or [semantic-git-commit-cli](https://github.com/JPeer264/node-semantic-git-commit-cli).
### Patch Release
```
fix(pencil): stop graphite breaking when too much pressure applied
```
### ~~Minor~~ Feature Release
```
feat(pencil): add 'graphiteWidth' option
```
### ~~Major~~ Breaking Release
```
perf(pencil): remove graphiteWidth option
BREAKING CHANGE: The graphiteWidth option has been removed. The default graphite width of 10mm is always used for performance reasons.
```
## Setup
[![NPM](https://nodei.co/npm/semantic-release.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/semantic-release/)
```bash
npm i semantic-release
npm install -g semantic-release-cli
cd your-module
semantic-release-cli setup
```
You *need* to set it up inside your `package.json`:
![dialogue](https://cloud.githubusercontent.com/assets/908178/9428123/3628dfec-499f-11e5-8bdd-8f3042dd95ed.png)
_[This is what happens under the hood.](https://github.com/semantic-release/cli#what-it-does)_
## Options
You can pass options either via command line (in [kebab-case](https://lodash.com/docs#kebabCase)) or in the `release` field of your `package.json` (in [camelCase](https://lodash.com/docs#camelCase)). The following two examples are the same, but CLI arguments take precedence.
| CLI | package.json |
| --- | --- |
| <pre><code>semantic-release pre --no-debug</code><pre> | <pre><code><div>//package.json</div><div>"release": {</div><div> "debug": false</div><div>}</div></code></pre><pre><code>semantic-release pre</code></pre> |
These options are currently available:
- `branch`: The branch on which releases should happen. Default: `'master'`
- `debug`: If true doesnt actually publish to npm or write things to file. Default: `!process.env.CI`
- `githubToken`: The token used to authenticate with GitHub. Default: `process.env.GH_TOKEN`
- `githubUrl`: Optional. Pass your GitHub Enterprise endpoint.
- `githubApiPathPrefix`: Optional. The path prefix for your GitHub Enterprise API.
_A few notes on `npm` config_:
1. The `npm` token can only be defined in the environment as `NPM_TOKEN`, because thats where `npm` itself is going to read it from.
2. In order to publish to a different `npm` registry you can specify that inside the `package.json`s [`publishConfig`](https://docs.npmjs.com/files/package.json#publishconfig) field.
3. If you want to use another dist-tag for your publishes than `'latest'` you can specify that inside the `package.json`s [`publishConfig`](https://docs.npmjs.com/files/package.json#publishconfig) field.
4. `semantic-release` generally tries to orientate itself towards `npm` it inherits the loglevel for example.
## Plugins
There are numerous steps where you can customize `semantic-release`s behaviour using plugins. A plugin is a regular [option](#options), but passed inside the `release` block of `package.json`:
```json
"scripts": {
"prepublish": "semantic-release pre",
"postpublish": "semantic-release post"
{
"release": {
"analyzeCommits": "npm-module-name",
"generateNotes": "./path/to/a/local/module",
"verifyConditions": {
"path": "./path/to/a/module",
"additional": "config"
}
}
```
Note: `semantic-release` works around a limitation in npm's "prepublish" hook. Once a version is published it prints an error that you can *safely ignore*.
See [npm/npm#7118](https://github.com/npm/npm/issues/7118).
```
semantic-release pre --analyze-commits="npm-module-name"
```
A plugin itself is an async function that always receives three arguments.
```js
module.exports = function (pluginConfig, config, callback) {}
```
- `pluginConfig`: If the user of your plugin specifies additional plugin config in the `package.json` (see the `verifyConditions` example above) then its this object.
- `config`: A config object containing a lot of information to act upon.
- `env`: All environment variables
- `npm`: Select npm configuration bits like `registry`, `tag` and `auth`
- `options`: `semantic-release` options like `debug`, or `branch`
- `pkg`: Parsed `package.json`
- For certain plugins the `config` object contains even more information. See below.
- `callback`: If an error occurs pass it as first argument. Otherwise pass your result as second argument.
### `analyzeCommits`
This plugin is responsible for determining the type of the next release. It additionally receives a `commits` array inside `config`. One commit is an object with a `message` and `hash` property. Call the callback with `'major'`, `'premajor'`, `'minor'`, `'preminor'`, `'patch'`, `'prepatch'`, `'prerelease'`, or `null` if nothing changed.
While it may be tempting to use `'prepatch'`, `'preminor'` & `'prerelease'` as part of a release process, this is strongly discouraged. A better approach is to use [dist-tags](https://docs.npmjs.com/cli/dist-tag) to create release channels (such as 'latest', 'next', 'stable') and to return only `'major'`, `'premajor'` and `'minor'` from the commit analyzer.
Have a look at the [default implementation](https://github.com/semantic-release/commit-analyzer/).
### `generateNotes`
This plugin is responsible for generating release notes. Call the callback with the notes as a string. Have a look at the [default implementation](https://github.com/semantic-release/release-notes-generator/).
### `verifyConditions`
This plugins is responsible for verifying that a release should happen in the first place. For example, the [default implementation](https://github.com/semantic-release/condition-travis/) verifies that the publish is happening on Travis, that its the right branch, and that all other build jobs succeeded. There are more use cases for this, e.g. verifying that test coverage is above a certain threshold or that there are no [vulnerabilities](https://nodesecurity.io/) in your dependencies. Be creative.
Passing an array of plugins will run them in series.
### `verifyRelease`
This plugin is responsible for verifying a release that was determined before and is about to be published. There is no default implementation. It additionally receives `nextRelease`, `lastRelease` and `commits` inside `config`. While `commits` is the same as with analyzeCommits, `nextRelease` contains a `type` (e.g. `'major'`) and the new version (e.g. `'1.0.0'`) and `lastRelease` contains the old `version`, the `gitHead` at the time of the release and the npm dist-`tag` (e.g. `'latest'`). Using this information you could [detect breaking changes](https://github.com/semantic-release/cracks) or hold back certain types of releases. Again: Be creative.
Passing an array of plugins will run them in series.
### `getLastRelease`
This plugin is responsible for determining a packages last release version. The [default implementation](https://github.com/semantic-release/last-release-npm) uses the last published version on a npm registry.
## ITYM*FAQ*LT
> I think you might frequently ask questions like these
### Why is the `package.json`s version not updated in my repository?
The `npm` docs even state:
> The most important things in your package.json are the name and version fields. Those are actually required, and your package wont install without them.
> [npm docs](https://docs.npmjs.com/files/package.json#version)
While this entirely true the version number doesnt have to be checked into source control. `semantic-release` takes care of the version field right before `npm publish` uses it and this is the only point where it _really_ is required.
### Is there a way to preview which version would currently get published?
If you run `npm run semantic-release` locally a dry run gets performed, which logs the version that would currently get published.
### Can I run this on my own machine rather than on a CI server?
Of course you can, but this doesnt necessarily mean you should. Running your tests on an independent machine before releasing software is a crucial part of this workflow. Also it is a pain to set this up locally, with tokens lying around and everything. That said, you can run the scripts with `--debug=false` explicitly. You have to export `GH_TOKEN=<your_token>` and `NPM_TOKEN=<your_other_token>`.
### Can I manually trigger the release of a specific version?
You can trigger a release by pushing to your GitHub repository. You deliberately cannot trigger a _specific_ version release, because this is the whole point of `semantic-release`. Start your packages with `1.0.0` and semver on.
### Is it _really_ a good idea to release on every push?
It is indeed a great idea because it _forces_ you to follow best practices. If you dont feel comfortable making every passing feature or fix on your master branch addressable via `npm` you might not treat your master right. Have a look at [branch workflows](https://guides.github.com/introduction/flow/index.html). If you still think you should have control over the exact point in time of your release, e.g. because you are following a release schedule, you can release only on the `production`/`deploy`/`release` branch and push your code there in certain intervals, or better yet use [dist-tags](https://docs.npmjs.com/cli/dist-tag).
### Why should I trust `semantic-release` with my releases?
`semantic-release` has a full unit- and integration-test-suite that tests _actual_ `npm` publishes against the [npm-registry-couchapp](https://github.com/npm/npm-registry-couchapp/). A new version wont get published if it doesnt pass on all these engines.
### Why does `semantic-release` require node version >= 8
Being able to write code for just the most recent node versions greatly simplifies development. More language features are available, no transpilation is required, less test builds are to be run, awaited and debugged.
For a special purpose tool like `semantic-release`, that's only meant to be used in controlled CI environments, we think it's okay to have such a high version requirement. As `semantic-release` handles package publishing we expect almost every project to have at least one build job running node 8 already and that's all it takes. Even if that's not that case `semantic-release` can still be executed with the help of [npx](https://www.npmjs.com/package/npx) (`npx -p node@8 npm run semantic-release`).
## Badge
Use this in one of your projects? Include one of these badges in your README.md to let people know that your package is published using `semantic-release`.
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
```md
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
```
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=plastic)](https://github.com/semantic-release/semantic-release)
```md
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=plastic)](https://github.com/semantic-release/semantic-release)
```
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
```md
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
```
## License
MIT License
2015 Stephan Bönnemann
2015 © Stephan Bönnemann and [contributors](https://github.com/semantic-release/semantic-release/graphs/contributors)
[![](https://cloud.githubusercontent.com/assets/908178/6091690/cc86f58c-aeb8-11e4-94cb-15f15f486cde.png)](https://twitter.com/trodrigues/status/509301317467373571)
+34
View File
@@ -0,0 +1,34 @@
# Troubleshooting semantic-release
### ENOTINHISTORY Commit not in history
```
semantic-release ERR! commits The commit the last release of this package was derived from is not in the direct history of the "master" branch.
semantic-release ERR! commits This means semantic-release can not extract the commits between now and then.
semantic-release ERR! commits This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name.
semantic-release ERR! commits You can recover from this error by publishing manually or restoring the commit "123".
semantic-release ERR! pre Failed to determine new version.
semantic-release ERR! pre ENOTINHISTORY Commit not in history
```
To restore semantic-release, follow these steps:
```
git pull
git reset --hard origin/master
npm version x.y.z # check your current version and set this based on semver rules manually
# if you have a PR workflow, create a new branch, otherwise commit to master
git checkout -B chore/release
git commit -am 'chore: release'
git push
# merge (not squash-merge) on github (this is important before running git push). This is only required when you work with branches
git checkout master
# definitely required
git pull
git push --tags
npm publish
```
-9
View File
@@ -1,9 +0,0 @@
#!/bin/sh
cat .tmp/sinopia.pid | xargs kill
cat .tmp/ghrs.pid | xargs kill
cp .tmp/.npmrc ~/.npmrc
rm -rf .tmp
-14
View File
@@ -1,14 +0,0 @@
#!/bin/sh
set -e
mkdir -p .tmp/modules
./node_modules/.bin/sinopia ./tests/config.yml & echo $! >> .tmp/sinopia.pid
./node_modules/.bin/github-release-fake-server -p 4343 & echo $! >> .tmp/ghrs.pid
sleep 0.5
cp ~/.npmrc .tmp/.npmrc
cp tests/.npmrc ~/.npmrc
-78
View File
@@ -1,78 +0,0 @@
#!/usr/bin/env node
'use strict'
var abbrev = require('abbrev')
var confirm = require('confirm-simple')
var minimist = require('minimist')
var efh = require('../lib/error').standard
var argv = minimist(process.argv.slice(2), {
alias: {
d: 'debug',
dry: 'debug',
t: 'token',
g: 'github-url'
},
default: {
token: process.env.GH_TOKEN || process.env.TOKEN || process.env.GITHUB_TOKEN,
'github-url': process.env.GH_URL
}
})
var npmArgv = process.env.npm_config_argv ?
minimist(JSON.parse(process.env.npm_config_argv).cooked) :
{_: []}
if (~argv._.indexOf('pre')) {
// see src/restart.js
if (npmArgv['semantic-release-rerun']) process.exit(0)
// the `prepublish` hook is also executed when the package is installed
// in this case we abort the command and do nothing.
if (isAbbrev(npmArgv, 'install')) process.exit(0)
return confirmCI(function () {
console.log('Determining new version')
var publish = false
if (isAbbrev(npmArgv, 'publish')) publish = true
require('../src/pre')(argv, efh(function (result) {
if (!result) {
console.log('Nothing changed. Not publishing.')
process.exit(1)
}
console.log('Publishing v' + result)
if (!publish) process.exit(0)
require('../src/restart')(efh(function () {
process.exit(1)
}))
}))
})
}
if (~argv._.indexOf('post')) {
return confirmCI(function () {
require('../src/post')(argv, efh(function () {
// see src/restart.js
if (npmArgv['semantic-release-rerun']) {
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
}
}))
})
}
function confirmCI (cb) {
if (process.env.CI || argv.ci === false) return cb(null, true)
confirm('Not running in a CI enviroment. Are you sure you want to run this hook?', function (ok) {
if (!ok) process.exit(1)
cb(null, ok)
})
}
function isAbbrev (argv, command) {
return argv._.some(Object.prototype.hasOwnProperty.bind(abbrev(command)))
}
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env node
// Bad news: We have to write plain ES5 in this file
// Good news: It's the only file of the entire project
var semver = require('semver');
if (semver.lt(process.version, '8.0.0')) {
console.error(
`semantic-release: node version >= 8 is required. Found ${process.version}.
If there is another job running on node version >= 8, it will be picked as
the build leader and you can safely ignore this message.
If you don't have node 8 in your build matrix you can use "npx" to restore
compatibility with minimal overhead:
$ npx -p node@8 npm run semantic-release
npx is bundled with npm >= 5.4, or available via npm. More info: npm.im/npx`
);
process.exit(1);
}
// node 8+ from this point on
require('../src')().catch(err => {
console.error('An error occurred while running semantic-release');
console.error(err);
process.exit(1);
});
+2
View File
@@ -0,0 +1,2 @@
codecov:
branch: caribou
-14
View File
@@ -1,14 +0,0 @@
'use strict'
var efh = require('error-first-handler')
module.exports = {
efh: efh,
standard: efh(function(err) {
console.log('Something went wrong:')
if (typeof err === 'string') return console.log(err)
if (err instanceof Error) return console.log(err.message)
if (err.message) return console.log(err.message)
console.log(err)
})
}
-20
View File
@@ -1,20 +0,0 @@
'use strict'
module.exports = function (commits) {
var type = null
commits.every(function (commit) {
if (commit.breaks.length) {
type = 'major'
return false
}
if (commit.type === 'feat') type = 'minor'
if (!type && commit.type === 'fix') type = 'patch'
return true
})
return type
}
-13
View File
@@ -1,13 +0,0 @@
'use strict'
var git = require('conventional-changelog/lib/git')
var efh = require('../error').efh
module.exports = function (cb) {
git.latestTag(efh(cb)(function (from) {
git.getCommits({from: from}, efh(cb)(function (commits) {
cb(null, commits)
}))
}))
}
-11
View File
@@ -1,11 +0,0 @@
'use strict'
var analyze = require('./analyze')
var commits = require('./commits')
var efh = require('../error').efh
module.exports = function (cb) {
commits(efh(cb)(function (commits) {
cb(null, analyze(commits))
}))
}
-17
View File
@@ -1,17 +0,0 @@
'use strict'
var exec = require('child_process').exec
var efh = require('./error').efh
module.exports = function (pkg, cb) {
if (!pkg.name) return cb(new Error('Package must have a name'))
exec('curl -s "' + process.env.npm_config_registry + pkg.name + '"', efh(cb)(function(stdout) {
var pkg = JSON.parse(stdout)
if (pkg.error) return cb(null, null, true)
cb(null, pkg['dist-tags'].latest)
}))
}
+109 -36
View File
@@ -1,58 +1,131 @@
{
"name": "semantic-release",
"description": "semantic semver compliant package publishing",
"version": "0.0.6",
"author": "Stephan Bönnemann <stephan@boennemann.me>",
"bin": "./bin/semantic-release",
"description": "Automated semver compliant package publishing",
"version": "0.0.0-placeholder",
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
"bin": {
"semantic-release": "bin/semantic-release.js"
},
"bugs": {
"url": "https://github.com/boennemann/semantic-release/issues"
"url": "https://github.com/semantic-release/semantic-release/issues"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"dependencies": {
"abbrev": "^1.0.5",
"confirm-simple": "^1.0.3",
"conventional-changelog": "0.0.11",
"error-first-handler": "^1.0.1",
"github": "^0.2.3",
"github-url-from-git": "^1.4.0",
"minimist": "^1.1.0",
"parse-github-repo-url": "^1.0.0",
"semver": "^4.2.0"
"@semantic-release/commit-analyzer": "^3.0.1",
"@semantic-release/condition-travis": "^6.0.0",
"@semantic-release/error": "^2.0.0",
"@semantic-release/last-release-npm": "^2.0.0",
"@semantic-release/release-notes-generator": "^4.0.0",
"execa": "^0.8.0",
"fs-extra": "^4.0.2",
"git-head": "^1.2.1",
"github": "^11.0.0",
"lodash": "^4.0.0",
"nerf-dart": "^1.0.0",
"nopt": "^4.0.0",
"normalize-package-data": "^2.3.4",
"npmconf": "^2.1.2",
"npmlog": "^4.0.0",
"p-series": "^1.0.0",
"parse-github-repo-url": "^1.3.0",
"require-relative": "^0.8.7",
"semver": "^5.4.1"
},
"devDependencies": {
"github-release-fake-server": "^1.1.1",
"lodash.defaults": "^3.0.0",
"nano-uid": "^0.2.0",
"nixt": "^0.4.1",
"sinopia": "^1.0.0",
"standard": "^2.3.1",
"tap-spec": "^2.2.0",
"tape": "^3.5.0"
"ava": "^0.22.0",
"codecov": "^2.3.0",
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.0.0",
"eslint": "^4.7.0",
"eslint-config-prettier": "^2.5.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-prettier": "^2.3.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"nock": "^9.0.2",
"npm-registry-couchapp": "^2.6.12",
"nyc": "^11.2.1",
"p-map-series": "^1.0.0",
"prettier": "^1.7.0",
"proxyquire": "^1.7.3",
"rimraf": "^2.5.0",
"sinon": "^4.0.0",
"tempy": "^0.2.1"
},
"engines": {
"node": "^0.10.0",
"npm": "^2.0.0"
"node": ">=4",
"npm": ">=2"
},
"homepage": "https://github.com/boennemann/semantic-release",
"eslintConfig": {
"extends": [
"standard",
"prettier"
],
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": 2
}
},
"files": [
"bin",
"src"
],
"homepage": "https://github.com/semantic-release/semantic-release#readme",
"keywords": [
"release",
"publish",
"author",
"automation",
"changelog",
"module",
"package",
"publish",
"release",
"semver",
"version",
"changelog"
"version"
],
"license": "MIT",
"main": "index.js",
"main": "bin/semantic-release.js",
"nyc": {
"include": [
"src/**/*.js"
],
"reporter": [
"json",
"text",
"html"
],
"all": true
},
"prettier": {
"printWidth": 120,
"singleQuote": true,
"bracketSpacing": false,
"trailingComma": "es5"
},
"publishConfig": {
"tag": "next"
},
"release": {
"branch": "caribou"
},
"repository": {
"type": "git",
"url": "https://github.com/boennemann/semantic-release.git"
"url": "git+https://github.com/semantic-release/semantic-release.git"
},
"scripts": {
"postpublish": "./bin/semantic-release post",
"posttest": "./bin/post-test",
"prepublish": "./bin/semantic-release pre",
"pretest": "./bin/pre-test",
"test": "standard && node tests | tap-spec"
"clean": "rimraf coverage && rimraf .nyc_output",
"cm": "git-cz",
"codecov": "codecov -f coverage/coverage-final.json",
"lint": "eslint .",
"pretest": "npm run clean && npm run lint",
"semantic-release": "./bin/semantic-release.js pre && npm publish && ./bin/semantic-release.js post",
"test": "nyc ava -v"
}
}
+153
View File
@@ -0,0 +1,153 @@
const path = require('path');
const {promisify} = require('util');
const url = require('url');
const {readJson, writeJson} = require('fs-extra');
const {cloneDeep, defaults, mapKeys, camelCase, assign} = require('lodash');
const log = require('npmlog');
const nopt = require('nopt');
const npmconf = require('npmconf');
const normalizeData = require('normalize-package-data');
module.exports = async () => {
log.heading = 'semantic-release';
const env = process.env;
const pkg = await readJson('./package.json');
const originalPkg = cloneDeep(pkg);
normalizeData(pkg);
const knownOptions = {
branch: String,
debug: Boolean,
'github-token': String,
'github-url': String,
'analyze-commits': [path, String],
'generate-notes': [path, String],
'verify-conditions': [path, String],
'verify-release': [path, String],
};
const options = defaults(
mapKeys(nopt(knownOptions), (value, key) => {
return camelCase(key);
}),
pkg.release,
{
branch: 'master',
fallbackTags: {next: 'latest'},
debug: !env.CI,
githubToken: env.GH_TOKEN || env.GITHUB_TOKEN,
githubUrl: env.GH_URL,
}
);
const plugins = require('../src/lib/plugins')(options);
let conf;
try {
conf = await promisify(npmconf.load)({});
} catch (err) {
log.error('init', 'Failed to load npm config.', err);
process.exit(1);
}
const npm = {
auth: {token: env.NPM_TOKEN},
cafile: conf.get('cafile'),
loglevel: conf.get('loglevel'),
registry: require('../src/lib/get-registry')(pkg, conf),
tag: (pkg.publishConfig || {}).tag || conf.get('tag') || 'latest',
};
// normalize trailing slash
npm.registry = url.format(url.parse(npm.registry));
log.level = npm.loglevel;
const config = {env: env, pkg: pkg, options: options, plugins: plugins, npm: npm};
const hide = {};
if (options.githubToken) hide.githubToken = '***';
log.verbose('init', 'options:', assign({}, options, hide));
log.verbose('init', 'Verifying config.');
const errors = require('../src/lib/verify')(config);
errors.forEach(err => {
log.error('init', err.message + ' ' + err.code);
});
if (errors.length) process.exit(1);
if (options.argv.remain[0] === 'pre') {
log.verbose('pre', 'Running pre-script.');
log.verbose('pre', 'Veriying conditions.');
try {
await plugins.verifyConditions(config);
} catch (err) {
log[options.debug ? 'warn' : 'error']('pre', err.message);
if (!options.debug) process.exit(1);
}
const nerfDart = require('nerf-dart')(npm.registry);
let wroteNpmRc = false;
if (env.NPM_OLD_TOKEN && env.NPM_EMAIL) {
// Using the old auth token format is not considered part of the public API
// This might go away anytime (i.e. once we have a better testing strategy)
conf.set('_auth', '${NPM_OLD_TOKEN}', 'project'); // eslint-disable-line no-template-curly-in-string
conf.set('email', '${NPM_EMAIL}', 'project'); // eslint-disable-line no-template-curly-in-string
wroteNpmRc = true;
} else if (env.NPM_TOKEN) {
conf.set(nerfDart + ':_authToken', '${NPM_TOKEN}', 'project'); // eslint-disable-line no-template-curly-in-string
wroteNpmRc = true;
}
try {
await promisify(conf.save.bind(conf))('project');
} catch (err) {
return log.error('pre', 'Failed to save npm config.', err);
}
if (wroteNpmRc) log.verbose('pre', 'Wrote authToken to .npmrc.');
let release;
try {
release = await require('../src/pre')(config);
} catch (err) {
log.error('pre', 'Failed to determine new version.');
const args = ['pre', (err.code ? err.code + ' ' : '') + err.message];
if (err.stack) args.push(err.stack);
log.error.apply(log, args);
process.exit(1);
}
const message = 'Determined version ' + release.version + ' as "' + npm.tag + '".';
log.verbose('pre', message);
if (options.debug) {
log.error('pre', message + ' Not publishing in debug mode.', release);
process.exit(1);
}
try {
const shrinkwrap = await readJson('./npm-shrinkwrap.json');
shrinkwrap.version = release.version;
await writeJson('./npm-shrinkwrap.json', shrinkwrap);
log.verbose('pre', 'Wrote version ' + release.version + 'to npm-shrinkwrap.json.');
} catch (e) {
log.silly('pre', "Couldn't find npm-shrinkwrap.json.");
}
await writeJson('./package.json', assign(originalPkg, {version: release.version}));
log.verbose('pre', 'Wrote version ' + release.version + ' to package.json.');
} else if (options.argv.remain[0] === 'post') {
log.verbose('post', 'Running post-script.');
let published, release;
try {
({published, release} = await require('../src/post')(config));
log.verbose('post', (published ? 'Published' : 'Generated') + ' release notes.', release);
} catch (err) {
log.error('post', 'Failed to publish release notes.', err);
process.exit(1);
}
} else {
log.error('post', 'Command "' + options.argv.remain[0] + '" not recognized. Use either "pre" or "post"');
}
};
+87
View File
@@ -0,0 +1,87 @@
const execa = require('execa');
const log = require('npmlog');
const getVersionHead = require('./get-version-head');
/**
* Commit message.
*
* @typedef {Object} Commit
* @property {string} hash The commit hash.
* @property {string} message The commit message.
*/
/**
* Retrieve the list of commits on the current branch since the last released version, or all the commits of the current branch if there is no last released version.
*
* The commit correspoding to the last released version is determined as follow:
* - Use `lastRelease.gitHead` if defined and present in `config.options.branch` history.
* - If `lastRelease.gitHead` is not in the `config.options.branch` history, unshallow the repository and try again.
* - If `lastRelease.gitHead` is still not in the `config.options.branch` history, search for a tag named `v<version>` or `<version>` and verify if it's associated commit sha is present in `config.options.branch` history.
*
* @param {Object} config
* @param {Object} config.lastRelease The lastRelease object obtained from the getLastRelease plugin.
* @param {string} [config.lastRelease.version] The version number of the last release.
* @param {string} [config.lastRelease.gitHead] The commit sha used to make the last release.
* @param {Object} config.options The semantic-relese options.
* @param {string} config.options.branch The branch to release from.
*
* @return {Promise<Array<Commit>>} The list of commits on the branch `config.options.branch` since the last release.
*
* @throws {SemanticReleaseError} with code `ENOTINHISTORY` if `config.lastRelease.gitHead` or the commit sha derived from `config.lastRelease.version` is not in the direct history of `config.options.branch`.
* @throws {SemanticReleaseError} with code `ENOGITHEAD` if `config.lastRelease.gitHead` is undefined and no commit sha can be found for the `config.lastRelease.version`.
*/
module.exports = async ({lastRelease: {version, gitHead}, options: {branch}}) => {
if (gitHead || version) {
try {
gitHead = await getVersionHead(gitHead, version, branch);
} catch (err) {
if (err.code === 'ENOTINHISTORY') {
log.error('commits', notInHistoryMessage(err.gitHead, branch, version));
} else {
log.error('commits', noGitHeadMessage(branch, version));
}
throw err;
}
} else {
// If there is no gitHead nor a version, there is no previous release. Unshallow the repo in order to retrieve all commits
await execa('git', ['fetch', '--unshallow', '--tags'], {reject: false});
}
try {
return (await execa('git', [
'log',
'--format=format:%H==SPLIT==%B==END==',
`${gitHead ? gitHead + '..' : ''}HEAD`,
])).stdout
.split('==END==')
.filter(raw => !!raw.trim())
.map(raw => {
const [hash, message] = raw.trim().split('==SPLIT==');
return {hash, message};
});
} catch (err) {
return [];
}
};
function noGitHeadMessage(branch, version) {
return `The commit the last release of this package was derived from cannot be determined from the release metadata not from the repository tags.
This means semantic-release can not extract the commits between now and then.
This is usually caused by releasing from outside the repository directory or with innaccessible git metadata.
You can recover from this error by creating a tag for the version "${version}" on the commit corresponding to this release:
$ git tag -f v${version} <commit sha1 corresponding to last release>
$ git push -f --tags origin ${branch}
`;
}
function notInHistoryMessage(gitHead, branch, version) {
return `The commit the last release of this package was derived from is not in the direct history of the "${branch}" branch.
This means semantic-release can not extract the commits between now and then.
This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name.
You can recover from this error by restoring the commit "${gitHead}" or by creating a tag for the version "${version}" on the commit corresponding to this release:
$ git tag -f v${version || '<version>'} <commit sha1 corresponding to last release>
$ git push -f --tags origin ${branch}
`;
}
+11
View File
@@ -0,0 +1,11 @@
module.exports = ({publishConfig, name}, conf) => {
if (publishConfig && publishConfig.registry) {
return publishConfig.registry;
}
if (name[0] !== '@') {
return conf.get('registry') || 'https://registry.npmjs.org/';
}
return conf.get(`${name.split('/')[0]}/registry`) || conf.get('registry') || 'https://registry.npmjs.org/';
};
+14
View File
@@ -0,0 +1,14 @@
const {promisify} = require('util');
const SemanticReleaseError = require('@semantic-release/error');
module.exports = async config => {
const {plugins, lastRelease} = config;
const type = await promisify(plugins.analyzeCommits)(config);
if (!type) {
throw new SemanticReleaseError('There are no relevant changes, so no new version is released.', 'ENOCHANGE');
}
if (!lastRelease.version) return 'initial';
return type;
};
+75
View File
@@ -0,0 +1,75 @@
const SemanticReleaseError = require('@semantic-release/error');
const execa = require('execa');
/**
* Get the commit sha for a given tag.
*
* @param {string} tagName Tag name for which to retrieve the commit sha.
*
* @return {string} The commit sha of the tag in parameter or `null`.
*/
async function gitTagHead(tagName) {
try {
return (await execa('git', ['rev-list', '-1', '--tags', tagName])).stdout;
} catch (err) {
return null;
}
}
/**
* Verify if the commist `sha` is in the direct history of the current branch.
*
* @param {string} sha The sha of the commit to look for.
*
* @return {boolean} `true` if the commit `sha` is in the history of the current branch, `false` otherwise.
*/
async function isCommitInHistory(sha) {
return (await execa('git', ['merge-base', '--is-ancestor', sha, 'HEAD'], {reject: false})).code === 0;
}
/**
* Get the commit sha for a given version, if it's contained in the given branch.
*
* @param {string} gitHead The commit sha to look for.
* @param {string} version The version corresponding to the commit sha to look for. Used to search in git tags.
*
* @return {Promise<string>} A Promise that resolves to the commit sha of the version, either `gitHead` of the commit associated with the `version` tag.
*
* @throws {SemanticReleaseError} with code `ENOTINHISTORY` if `gitHead` or the commit sha dereived from `version` is not in the direct history of `branch`.
* @throws {SemanticReleaseError} with code `ENOGITHEAD` if `gitHead` is undefined and no commit sha can be found for the `version`.
*/
module.exports = async (gitHead, version) => {
// Check if gitHead is defined and exists in release branch
if (gitHead && (await isCommitInHistory(gitHead))) {
return gitHead;
}
// Ushallow the repository
await execa('git', ['fetch', '--unshallow', '--tags'], {reject: false});
// Check if gitHead is defined and exists in release branch again
if (gitHead && (await isCommitInHistory(gitHead))) {
return gitHead;
}
let tagHead;
if (version) {
// If a version is defined search a corresponding tag
tagHead = (await gitTagHead(`v${version}`)) || (await gitTagHead(version));
// Check if tagHead is found and exists in release branch again
if (tagHead && (await isCommitInHistory(tagHead))) {
return tagHead;
}
}
// Either gitHead is defined or a tagHead has been found but none is in the branch history
if (gitHead || tagHead) {
const error = new SemanticReleaseError('Commit not in history', 'ENOTINHISTORY');
error.gitHead = gitHead || tagHead;
throw error;
}
// There is no gitHead in the last release and there is no tags correponsing to the last release version
throw new SemanticReleaseError('There is no commit associated with last release', 'ENOGITHEAD');
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (config, options, cb) => {
cb(null);
};
+43
View File
@@ -0,0 +1,43 @@
const {promisify} = require('util');
const relative = require('require-relative');
const pSeries = require('p-series');
module.exports = options => {
const plugins = {
analyzeCommits: normalize(options.analyzeCommits, '@semantic-release/commit-analyzer'),
generateNotes: normalize(options.generateNotes, '@semantic-release/release-notes-generator'),
getLastRelease: normalize(options.getLastRelease, '@semantic-release/last-release-npm'),
};
['verifyConditions', 'verifyRelease'].forEach(plugin => {
if (!Array.isArray(options[plugin])) {
plugins[plugin] = promisify(
normalize(
options[plugin],
plugin === 'verifyConditions' ? '@semantic-release/condition-travis' : './plugin-noop'
)
);
} else {
plugins[plugin] = async pluginOptions => {
return pSeries(
options[plugin].map(step => {
return () => promisify(normalize(step, './plugin-noop'))(pluginOptions);
})
);
};
}
});
return plugins;
};
const normalize = (pluginConfig, fallback) => {
if (typeof pluginConfig === 'string') return relative(pluginConfig).bind(null, {});
if (pluginConfig && typeof pluginConfig.path === 'string') {
return relative(pluginConfig.path).bind(null, pluginConfig);
}
return require(fallback).bind(null, pluginConfig || {});
};
module.exports.normalize = normalize;
+25
View File
@@ -0,0 +1,25 @@
const SemanticReleaseError = require('@semantic-release/error');
module.exports = ({pkg, options, env}) => {
const errors = [];
if (!pkg.name) {
errors.push(new SemanticReleaseError('No "name" found in package.json.', 'ENOPKGNAME'));
}
if (!pkg.repository || !pkg.repository.url) {
errors.push(new SemanticReleaseError('No "repository" found in package.json.', 'ENOPKGREPO'));
}
if (!options.debug) {
if (!options.githubToken) {
errors.push(new SemanticReleaseError('No github token specified.', 'ENOGHTOKEN'));
}
if (!(env.NPM_TOKEN || (env.NPM_OLD_TOKEN && env.NPM_EMAIL))) {
errors.push(new SemanticReleaseError('No npm token specified.', 'ENONPMTOKEN'));
}
}
return errors;
};
+31 -48
View File
@@ -1,55 +1,38 @@
'use strict'
const {promisify} = require('util');
const url = require('url');
const gitHead = require('git-head');
const GitHubApi = require('github');
const parseSlug = require('parse-github-repo-url');
var exec = require('child_process').exec
var readFile = require('fs').readFileSync
var url = require('url')
module.exports = async config => {
const {pkg, options: {branch, debug, githubUrl, githubToken, githubApiPathPrefix}, plugins} = config;
const [owner, repo] = parseSlug(pkg.repository.url);
const name = `v${pkg.version}`;
const tag = {owner, repo, ref: `refs/tags/${name}`, sha: await promisify(gitHead)()};
const body = await promisify(plugins.generateNotes)(config);
const release = {owner, repo, tag_name: name, name, target_commitish: branch, draft: !!debug, body};
var changelog = require('conventional-changelog')
var GitHubApi = require('github')
var parseSlug = require('parse-github-repo-url')
var parseUrl = require('github-url-from-git')
if (debug && !githubToken) {
return {published: false, release};
}
var efh = require('../lib/error').efh
const {port, protocol, hostname} = githubUrl ? url.parse(githubUrl) : {};
const github = new GitHubApi({
port,
protocol: (protocol || '').split(':')[0] || null,
host: hostname,
pathPrefix: githubApiPathPrefix || null,
});
module.exports = function (options, cb) {
var pkg = JSON.parse(readFile('./package.json'))
var repository = pkg.repository ? pkg.repository.url : null
github.authenticate({type: 'token', token: githubToken});
if (!repository) return cb(new Error('Package must have a repository'))
if (debug) {
await github.repos.createRelease(release);
return {published: true, release};
}
var config = options['github-url'] ? url.parse(options['github-url']) : {}
await github.gitdata.createReference(tag);
await github.repos.createRelease(release);
var github = new GitHubApi({
version: '3.0.0',
port: config.port,
protocol: (config.protocol || '').split(':')[0] || null,
host: config.hostname
})
changelog({
version: pkg.version,
repository: parseUrl(repository),
file: false
}, efh(cb)(function (log) {
exec('git rev-parse HEAD', efh(cb)(function (hash) {
var ghRepo = parseSlug(repository)
var release = {
owner: ghRepo[0],
repo: ghRepo[1],
tag_name: 'v' + pkg.version,
target_commitish: hash,
draft: options.debug,
body: log
}
github.authenticate({
type: 'oauth',
token: options.token
})
github.releases.createRelease(release, efh(cb)(function () {
cb(null, true)
}))
}))
}))
}
return {published: true, release};
};
+17 -18
View File
@@ -1,24 +1,23 @@
'use strict'
const {promisify} = require('util');
const {assign} = require('lodash');
const semver = require('semver');
var fs = require('fs')
const getCommits = require('./lib/get-commits');
const getReleaseType = require('./lib/get-release-type');
var semver = require('semver')
module.exports = async config => {
const {getLastRelease, verifyRelease} = config.plugins;
var type = require('../lib/type')
var version = require('../lib/version')
var efh = require('../lib/error').efh
const lastRelease = await promisify(getLastRelease)(config);
const commits = await getCommits(assign({lastRelease}, config));
const type = await getReleaseType(assign({commits, lastRelease}, config));
module.exports = function (options, cb) {
type(efh(cb)(function (type) {
if (!type) return cb(null, null)
const nextRelease = {
type: type,
version: type === 'initial' ? '1.0.0' : semver.inc(lastRelease.version, type),
};
var path = './package.json'
var pkg = JSON.parse(fs.readFileSync(path))
version(pkg, efh(cb)(function (version, unpublished) {
pkg.version = unpublished ? '1.0.0' : semver.inc(version, type)
if (!options.debug) fs.writeFileSync(path, JSON.stringify(pkg, null, 2))
await verifyRelease(assign({commits, lastRelease, nextRelease}, config));
cb(null, pkg.version)
}))
}))
}
return nextRelease;
};
-30
View File
@@ -1,30 +0,0 @@
'use strict'
var spawn = require('child_process').spawn
var exports = module.exports = function (cb) {
// npm loads package.json data before running the `prepublish` hook
// changing the version on `prepublish` has no effect
// see https://github.com/npm/npm/issues/7118
// to circumvent this behavior we are calling `npm publish` inside `prepublish`
// the package.json is then loaded again and the correct version will be published
var child = spawn('npm', ['publish', '--semantic-release-rerun'])
var handler = exports.handleCloseAndExit.bind(null, cb)
child.stdout.pipe(process.stdout)
child.stderr.pipe(process.stderr)
child.on('close', handler)
child.on('exit', handler)
child.on('error', cb)
}
exports.handleCloseAndExit = function (cb, code, signal) {
if (code === 0) return cb(null)
cb({
code: code,
signal: signal,
message: 'npm publish failed'
})
}
+3
View File
@@ -0,0 +1,3 @@
module.exports = function(config, options, cb) {
cb(new Error('a'));
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function(config, options, cb) {
cb(new Error('b'));
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function(config, options, cb) {
cb(null, 'a');
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function(config, options, cb) {
cb(null, 'b');
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function(pluginConfig, options, cb) {
cb(null, {pluginConfig, options});
};
+383
View File
@@ -0,0 +1,383 @@
import test from 'ava';
import {
gitRepo,
gitCommits,
gitCheckout,
gitTagVersion,
gitShallowClone,
gitTags,
gitLog,
gitDetachedHead,
} from './helpers/git-utils';
import proxyquire from 'proxyquire';
import {stub} from 'sinon';
import SemanticReleaseError from '@semantic-release/error';
// Stub to capture the log messages
const errorLog = stub();
// Module to test
const getCommits = proxyquire('../src/lib/get-commits', {npmlog: {error: errorLog}});
test.beforeEach(t => {
// Save the current working diretory
t.context.cwd = process.cwd();
// Reset the stub call history
errorLog.resetHistory();
});
test.afterEach.always(t => {
// Restore the current working directory
process.chdir(t.context.cwd);
});
test.serial('Get all commits when there is no last release', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second']);
// Retrieve the commits with the commits module
const result = await getCommits({lastRelease: {}, options: {branch: 'master'}});
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.is(result[0].hash.substring(0, 7), commits[0].hash);
t.is(result[0].message, commits[0].message);
t.is(result[1].hash.substring(0, 7), commits[1].hash);
t.is(result[1].message, commits[1].message);
});
test.serial('Get all commits when there is no last release, including the ones not in the shallow clone', async t => {
// Create a git repository, set the current working directory at the root of the repo
const repo = await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second']);
// Create a shallow clone with only 1 commit
await gitShallowClone(repo);
// Verify the shallow clone contains only one commit
t.is((await gitLog()).length, 1);
// Retrieve the commits with the commits module
const result = await getCommits({lastRelease: {}, options: {branch: 'master'}});
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.is(result[0].hash.substring(0, 7), commits[0].hash);
t.is(result[0].message, commits[0].message);
t.is(result[1].hash.substring(0, 7), commits[1].hash);
t.is(result[1].message, commits[1].message);
});
test.serial('Get all commits since gitHead (from lastRelease)', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second', 'Third']);
// Retrieve the commits with the commits module, since commit 'First'
const result = await getCommits({
lastRelease: {gitHead: commits[commits.length - 1].hash},
options: {branch: 'master'},
});
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.is(result[0].hash.substring(0, 7), commits[0].hash);
t.is(result[0].message, commits[0].message);
t.is(result[1].hash.substring(0, 7), commits[1].hash);
t.is(result[1].message, commits[1].message);
});
test.serial('Get all commits since gitHead (from lastRelease) on a detached head repo', async t => {
// Create a git repository, set the current working directory at the root of the repo
const repo = await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second', 'Third']);
// Create a detached head repo at commit 'feat: Second'
await gitDetachedHead(repo, commits[1].hash);
// Retrieve the commits with the commits module, since commit 'First'
const result = await getCommits({
lastRelease: {gitHead: commits[commits.length - 1].hash},
options: {branch: 'master'},
});
// Verify the module retrieved only the commit 'feat: Second' (included in the detached and after 'fix: First')
t.is(result.length, 1);
t.is(result[0].hash.substring(0, 7), commits[1].hash);
t.is(result[0].message, commits[1].message);
});
test.serial('Get all commits since gitHead (from tag) ', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
let commits = await gitCommits(['First']);
// Create the tag corresponding to version 1.0.0
await gitTagVersion('1.0.0');
// Add new commits to the master branch
commits = (await gitCommits(['Second', 'Third'])).concat(commits);
// Retrieve the commits with the commits module, since commit 'First' (associated with tag v1.0.0)
const result = await getCommits({lastRelease: {version: '1.0.0'}, options: {branch: 'master'}});
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.is(result[0].hash.substring(0, 7), commits[0].hash);
t.is(result[0].message, commits[0].message);
t.is(result[1].hash.substring(0, 7), commits[1].hash);
t.is(result[1].message, commits[1].message);
});
test.serial('Get all commits since gitHead (from tag) on a detached head repo', async t => {
// Create a git repository, set the current working directory at the root of the repo
const repo = await gitRepo();
// Add commits to the master branch
let commits = await gitCommits(['First']);
// Create the tag corresponding to version 1.0.0
await gitTagVersion('1.0.0');
// Add new commits to the master branch
commits = (await gitCommits(['Second', 'Third'])).concat(commits);
// Create a detached head repo at commit 'feat: Second'
await gitDetachedHead(repo, commits[1].hash);
// Retrieve the commits with the commits module, since commit 'First' (associated with tag 1.0.0)
const result = await getCommits({lastRelease: {version: '1.0.0'}, options: {branch: 'master'}});
// Verify the module retrieved only the commit 'feat: Second' (included in the detached and after 'fix: First')
t.is(result.length, 1);
t.is(result[0].hash.substring(0, 7), commits[1].hash);
t.is(result[0].message, commits[1].message);
});
test.serial('Get all commits since gitHead (from tag formatted like v<version>) ', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
let commits = await gitCommits(['First']);
// Create the tag corresponding to version 1.0.0
await gitTagVersion('v1.0.0');
// Add new commits to the master branch
commits = (await gitCommits(['Second', 'Third'])).concat(commits);
// Retrieve the commits with the commits module, since commit 'First' (associated with tag v1.0.0)
const result = await getCommits({lastRelease: {version: '1.0.0'}, options: {branch: 'master'}});
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.is(result[0].hash.substring(0, 7), commits[0].hash);
t.is(result[0].message, commits[0].message);
t.is(result[1].hash.substring(0, 7), commits[1].hash);
t.is(result[1].message, commits[1].message);
});
test.serial('Get commits when last release gitHead is missing but a tag match the version', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
let commits = await gitCommits(['First']);
// Create the tag corresponding to version 1.0.0
await gitTagVersion('v1.0.0');
// Add new commits to the master branch
commits = (await gitCommits(['Second', 'Third'])).concat(commits);
// Retrieve the commits with the commits module, since commit 'First' (associated with tag v1.0.0)
const result = await getCommits({lastRelease: {version: '1.0.0', gitHead: 'missing'}, options: {branch: 'master'}});
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.is(result[0].hash.substring(0, 7), commits[0].hash);
t.is(result[0].message, commits[0].message);
t.is(result[1].hash.substring(0, 7), commits[1].hash);
t.is(result[1].message, commits[1].message);
});
test.serial('Get all commits since gitHead, when gitHead are mising from the shallow clone', async t => {
// Create a git repository, set the current working directory at the root of the repo
const repo = await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second', 'Third']);
// Create a shallow clone with only 1 commit and no tags
await gitShallowClone(repo);
// Retrieve the commits with the commits module, since commit 'First'
const result = await getCommits({
lastRelease: {version: '1.0.0', gitHead: commits[commits.length - 1].hash},
options: {branch: 'master'},
});
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.is(result[0].hash.substring(0, 7), commits[0].hash);
t.is(result[0].message, commits[0].message);
t.is(result[1].hash.substring(0, 7), commits[1].hash);
t.is(result[1].message, commits[1].message);
});
test.serial('Get all commits since gitHead from tag, when tags are mising from the shallow clone', async t => {
// Create a git repository, set the current working directory at the root of the repo
const repo = await gitRepo();
// Add commits to the master branch
let commits = await gitCommits(['First']);
// Create the tag corresponding to version 1.0.0
await gitTagVersion('v1.0.0');
// Add new commits to the master branch
commits = (await gitCommits(['Second', 'Third'])).concat(commits);
// Create a shallow clone with only 1 commit and no tags
await gitShallowClone(repo);
// Verify the shallow clone does not contains any tags
t.is((await gitTags()).length, 0);
// Retrieve the commits with the commits module, since commit 'First' (associated with tag v1.0.0)
const result = await getCommits({lastRelease: {version: '1.0.0'}, options: {branch: 'master'}});
// Verify the commits created and retrieved by the module are identical
t.is(result.length, 2);
t.is(result[0].hash.substring(0, 7), commits[0].hash);
t.is(result[0].message, commits[0].message);
t.is(result[1].hash.substring(0, 7), commits[1].hash);
t.is(result[1].message, commits[1].message);
});
test.serial('Return empty array if lastRelease.gitHead is the last commit', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
const commits = await gitCommits(['First', 'Second']);
// Retrieve the commits with the commits module, since commit 'Second' (therefore none)
const result = await getCommits({lastRelease: {gitHead: commits[0].hash}, options: {branch: 'master'}});
// Verify no commit is retrieved
t.deepEqual(result, []);
});
test.serial('Return empty array if there is no commits', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Retrieve the commits with the commits module
const result = await getCommits({lastRelease: {}, options: {branch: 'master'}});
// Verify no commit is retrieved
t.deepEqual(result, []);
});
test.serial('Throws ENOGITHEAD error if the gitHead of the last release cannot be found', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
await gitCommits(['First', 'Second']);
// Retrieve the commits with the commits module
const error = await t.throws(getCommits({lastRelease: {version: '1.0.0'}, options: {branch: 'master'}}));
// Verify error code and message
t.is(error.code, 'ENOGITHEAD');
t.true(error instanceof SemanticReleaseError);
// Verify the log function has been called with a message explaining the error
t.regex(
errorLog.firstCall.args[1],
/The commit the last release of this package was derived from cannot be determined from the release metadata not from the repository tags/
);
});
test.serial('Throws ENOTINHISTORY error if gitHead is not in history', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
await gitCommits(['First', 'Second']);
// Retrieve the commits with the commits module
const error = await t.throws(getCommits({lastRelease: {gitHead: 'notinhistory'}, options: {branch: 'master'}}));
// Verify error code and message
t.is(error.code, 'ENOTINHISTORY');
t.true(error instanceof SemanticReleaseError);
// Verify the log function has been called with a message mentionning the branch
t.regex(errorLog.firstCall.args[1], /history of the "master" branch/);
// Verify the log function has been called with a message mentionning the missing gitHead
t.regex(errorLog.firstCall.args[1], /restoring the commit "notinhistory"/);
});
test.serial('Throws ENOTINHISTORY error if gitHead is not in branch history but present in others', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
await gitCommits(['First', 'Second']);
// Create the new branch 'other-branch' from master
await gitCheckout('other-branch');
// Add commits to the 'other-branch' branch
const commitsBranch = await gitCommits(['Third', 'Fourth']);
await gitCheckout('master', false);
// Retrieve the commits with the commits module
const error = await t.throws(
getCommits({lastRelease: {version: '1.0.1', gitHead: commitsBranch[0].hash}, options: {branch: 'master'}})
);
// Verify error code and message
t.is(error.code, 'ENOTINHISTORY');
t.true(error instanceof SemanticReleaseError);
// Verify the log function has been called with a message mentionning the branch
t.regex(errorLog.firstCall.args[1], /history of the "master" branch/);
// Verify the log function has been called with a message mentionning the missing gitHead
t.regex(errorLog.firstCall.args[1], new RegExp(`restoring the commit "${commitsBranch[0].hash}"`));
});
test.serial('Throws ENOTINHISTORY error if gitHead is not in detached head but present in other branch', async t => {
// Create a git repository, set the current working directory at the root of the repo
const repo = await gitRepo();
// Add commit to the master branch
await gitCommits(['First']);
// Create the new branch 'other-branch' from master
await gitCheckout('other-branch');
// Add commits to the 'other-branch' branch
const commitsBranch = await gitCommits(['Second', 'Third']);
await gitCheckout('master', false);
// Add new commit to master branch
const commitsMaster = await gitCommits(['Fourth']);
// Create a detached head repo at commit 'Fourth'
await gitDetachedHead(repo, commitsMaster[0].hash);
// Retrieve the commits with the commits module, since commit 'Second'
const error = await t.throws(
getCommits({lastRelease: {version: '1.0.1', gitHead: commitsBranch[0].hash}, options: {branch: 'master'}})
);
// Verify error code and message
t.is(error.code, 'ENOTINHISTORY');
t.true(error instanceof SemanticReleaseError);
// Verify the log function has been called with a message mentionning the branch
t.regex(errorLog.firstCall.args[1], /history of the "master" branch/);
// Verify the log function has been called with a message mentionning the missing gitHead
t.regex(errorLog.firstCall.args[1], new RegExp(`restoring the commit "${commitsBranch[0].hash}"`));
});
test.serial('Throws ENOTINHISTORY error when a tag is not in branch history but present in others', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
await gitCommits(['First', 'Second']);
// Create the new branch 'other-branch' from master
await gitCheckout('other-branch');
// Add commits to the 'other-branch' branch
await gitCommits(['Third']);
// Create the tag corresponding to version 1.0.0
const shaTag = await gitTagVersion('v1.0.0');
await gitCheckout('master', false);
// Add new commit to the master branch
await gitCommits(['Forth']);
// Retrieve the commits with the commits module
const error = await t.throws(getCommits({lastRelease: {version: '1.0.0'}, options: {branch: 'master'}}));
// Verify error code and message
t.is(error.code, 'ENOTINHISTORY');
t.true(error instanceof SemanticReleaseError);
// Verify the log function has been called with a message mentionning the branch
t.regex(errorLog.firstCall.args[1], /history of the "master" branch/);
// Verify the log function has been called with a message mentionning the missing gitHead
t.regex(errorLog.firstCall.args[1], new RegExp(`restoring the commit "${shaTag}"`));
});
+82
View File
@@ -0,0 +1,82 @@
import test from 'ava';
import {stub} from 'sinon';
const getRegistry = require('../src/lib/get-registry');
test('Get registry from package.json', t => {
// Retrieve the registry with the get-registry module and verify it returns the one from the package.json in parameter
t.is(getRegistry({name: 'publish-config', publishConfig: {registry: 'a'}}, {}), 'a');
});
test('Prioritize the package.json registry config', t => {
// Stub the npmconf object
const get = stub();
// Retrieve the registry with the get-registry module and verify it returns the one from the package.json in parameter
t.is(getRegistry({name: 'publish-config', publishConfig: {registry: 'b'}}, {get}), 'b');
// Verify the registry has been retrieved from the package.json without trying the stubbed npmconf
t.true(get.notCalled);
});
test('Get registry for regular package name', t => {
// Stub the npmconf object returns 'b' for 'registry' property
const get = stub()
.withArgs('registry')
.returns('b');
// Retrieve the registry with the get-registry module and verify it returns the one configured in the stubbed npmconf
t.is(getRegistry({name: 'normal'}, {get}), 'b');
// Verify the registry has been retrieved by calling the stubbed npmconf
t.true(get.calledWithExactly('registry'));
});
test('Get default registry', t => {
// Stub the npmconf object, returns 'null'
const get = stub().returns(null);
// Retrieve the registry with the get-registry module and verify it returns default one
t.is(getRegistry({name: 'normal'}, {get}), 'https://registry.npmjs.org/');
// Verify the module tried first to retrieve the registry by calling the stubbed npmconf
t.true(get.calledWithExactly('registry'));
});
test('Get registry for scoped package name', t => {
// Stub the npmconf object, returns 'c' for '@scoped/registry' property
const get = stub()
.withArgs('@scoped/registry')
.returns('c');
// Retrieve the registry with the get-registry module and verify it returns the one configured in the stubbed npmconf
t.is(getRegistry({name: '@scoped/foo'}, {get}), 'c');
// Verify the registry for the scope '@scoped' has been retrieved by calling the stubbed npmconf
t.true(get.calledWithExactly('@scoped/registry'));
});
test('Get regular registry for scoped package name', t => {
// Stub the npmconf object, returns 'd' for 'registry' property
const get = stub()
.withArgs('registry')
.returns('d');
// Retrieve the registry with the get-registry module and verify it returns the regular default one for `@scoped` packages
t.is(getRegistry({name: '@scoped/baz'}, {get}), 'd');
// Verify the module tried to retrieve the @scoped registry by calling the stubbed npmconf
t.true(get.calledWithExactly('@scoped/registry'));
});
test('Get default registry for scoped package name', t => {
// Stub the npmconf object, returns 'd' for 'registry' property
const get = stub().returns(null);
// Retrieve the registry with the get-registry module and verify it returns default one for `@scoped` packages
t.is(getRegistry({name: '@scoped/baz'}, {get}), 'https://registry.npmjs.org/');
// Verify the module tried to retrieve the @scoped registry by calling the stubbed npmconf
t.true(get.calledWithExactly('@scoped/registry'));
// Verify the module tried to retrieve the regular registry by calling the stubbed npmconf
t.true(get.calledWithExactly('registry'));
});
+87
View File
@@ -0,0 +1,87 @@
import {callbackify} from 'util';
import test from 'ava';
import {stub} from 'sinon';
import SemanticReleaseError from '@semantic-release/error';
import getReleaseType from '../src/lib/get-release-type';
test('Get commit types from commits', async t => {
// Stub the commitAnalyzer plugin, returns 'major' release type
const analyzeCommits = stub().resolves('major');
const commits = [{hash: '0', message: 'a'}];
// Call the get-release-type module
const releaseType = await getReleaseType({
commits,
lastRelease: {version: '1.0.0'},
plugins: {analyzeCommits: callbackify(analyzeCommits)},
});
// Verify the module return the release type obtain from the commitAnalyzer plugin
t.is(releaseType, 'major');
// Verify the commitAnalyzer plugin was called with the commits
t.true(analyzeCommits.calledOnce);
t.deepEqual(analyzeCommits.firstCall.args[0].commits, commits);
});
test('Throws error when no changes', async t => {
// Stub the commitAnalyzer plugin, returns 'null' release type
const analyzeCommits = stub().resolves(null);
const commits = [{hash: '0', message: 'a'}];
// Call the get-release-type module and verify it returns an error
const error = await t.throws(
getReleaseType({
commits,
lastRelease: {version: '1.0.0'},
plugins: {analyzeCommits: callbackify(analyzeCommits)},
})
);
// Verify the error code adn type
t.is(error.code, 'ENOCHANGE');
t.true(error instanceof SemanticReleaseError);
// Verify the commitAnalyzer plugin was called with the commits
t.true(analyzeCommits.calledOnce);
t.deepEqual(analyzeCommits.firstCall.args[0].commits, commits);
});
test('Return initial if there is no lastRelease', async t => {
// Stub the commitAnalyzer plugin, returns 'major' release type
const analyzeCommits = stub().resolves('major');
const commits = [{hash: '0', message: 'a'}];
// Call the get-release-type module
const releaseType = await getReleaseType({
commits,
lastRelease: {},
plugins: {analyzeCommits: callbackify(analyzeCommits)},
});
// Verify the module return an initial release type
t.is(releaseType, 'initial');
// Verify the commitAnalyzer plugin was called with the commits
t.true(analyzeCommits.calledOnce);
t.deepEqual(analyzeCommits.firstCall.args[0].commits, commits);
});
test('Throws error when no changes even if there is no lastRelease', async t => {
// Stub the commitAnalyzer plugin, returns 'null' release type
const analyzeCommits = stub().resolves(null);
const commits = [{hash: '0', message: 'a'}];
// Call the get-release-type module and verify it returns an error
const error = await t.throws(
getReleaseType({commits, lastRelease: {}, plugins: {analyzeCommits: callbackify(analyzeCommits)}})
);
// Verify the error code adn type
t.is(error.code, 'ENOCHANGE');
t.true(error instanceof SemanticReleaseError);
// Verify the commitAnalyzer plugin was called with the commits
t.true(analyzeCommits.calledOnce);
t.deepEqual(analyzeCommits.firstCall.args[0].commits, commits);
});
+144
View File
@@ -0,0 +1,144 @@
import {mkdir} from 'fs-extra';
import tempy from 'tempy';
import execa from 'execa';
import pMapSeries from 'p-map-series';
/**
* Commit message informations.
*
* @typedef {Object} Commit
* @property {string} branch The commit branch.
* @property {string} hash The commit hash.
* @property {string} message The commit message.
*/
/**
* Create a temporary git repository and change the current working directory to the repository root.
*
* @method gitCommits
* @param {Array<Commit>} commits the created commits.
*
* @return {string} The path of the repository.
*/
export async function gitRepo() {
const dir = tempy.directory();
process.chdir(dir);
await mkdir('git-templates');
await execa('git', ['init', '--template=./git-templates']);
await gitCheckout('master');
return dir;
}
/**
* Create commits on the current git repository.
*
* @param {Array<string>} messages commit messages.
*
* @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order).
*/
export async function gitCommits(messages) {
return (await pMapSeries(messages, async msg => {
const {stdout} = await execa('git', ['commit', '-m', msg, '--allow-empty', '--no-gpg-sign']);
const [, branch, hash, message] = /^\[(\w+)\(?.*?\)?(\w+)\] (.+)$/.exec(stdout);
return {branch, hash, message};
})).reverse();
}
/**
* Amend a commit (rewriting the sha) on the current git repository.
*
* @param {string} messages commit message.
*
* @returns {Array<Commit>} the created commits.
*/
export async function gitAmmendCommit(msg) {
const {stdout} = await execa('git', ['commit', '--amend', '-m', msg, '--allow-empty']);
const [, branch, hash, message] = /^\[(\w+)\(?.*?\)?(\w+)\] (.+)(.|\s)+$/.exec(stdout);
return {branch, hash, message};
}
/**
* Checkout a branch on the current git repository.
*
* @param {string} branch Branch name.
* @param {boolean} create `true` to create the branche ans switch, `false` to only switch.
*/
export async function gitCheckout(branch, create = true) {
await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch]);
}
/**
* @return {string} The sha of the head commit in the current git repository.
*/
export async function gitHead() {
return (await execa('git', ['rev-parse', 'HEAD'])).stdout;
}
/**
* Create a tag on the head commit in the current git repository.
*
* @param {string} tagName The tag name to create.
* @param {string} [sha] The commit on which to create the tag. If undefined the tag is created on the last commit.
*
* @return {string} The commit sha of the created tag.
*/
export async function gitTagVersion(tagName, sha) {
await execa('git', sha ? ['tag', '-f', tagName, sha] : ['tag', tagName]);
return (await execa('git', ['rev-list', '-1', '--tags', tagName])).stdout;
}
/**
* @return {Array<string>} The list of tags from the current git repository.
*/
export async function gitTags() {
return (await execa('git', ['tag'])).stdout.split('\n').filter(tag => !!tag);
}
/**
* @return {Array<string>} The list of commit sha from the current git repository.
*/
export async function gitLog() {
return (await execa('git', ['log', '--format=format:%H'])).stdout.split('\n').filter(sha => !!sha);
}
/**
* Create a shallow clone of a git repository and change the current working directory to the cloned repository root.
* The shallow will contain a limited number of commit and no tags.
*
* @param {string} origin The path of the repository to clone.
* @param {number} [depth=1] The number of commit to clone.
* @return {string} The path of the cloned repository.
*/
export async function gitShallowClone(origin, branch = 'master', depth = 1) {
const dir = tempy.directory();
process.chdir(dir);
await execa('git', ['clone', '--no-hardlinks', '--no-tags', '-b', branch, '--depth', depth, `file://${origin}`, dir]);
return dir;
}
/**
* Create a git repo with a detached head from another git repository and change the current working directory to the new repository root.
*
* @param {string} origin The path of the repository to clone.
* @param {number} head A commit sha of the origin repo that will become the detached head of the new one.
* @return {string} The path of the new repository.
*/
export async function gitDetachedHead(origin, head) {
const dir = tempy.directory();
process.chdir(dir);
await execa('git', ['init']);
await execa('git', ['remote', 'add', 'origin', origin]);
await execa('git', ['fetch']);
await execa('git', ['checkout', head]);
return dir;
}
/**
* Pack heads and tags of the current git repository.
*/
export async function gitPackRefs() {
await execa('git', ['pack-refs', '--all']);
}
+7
View File
@@ -0,0 +1,7 @@
import nock from 'nock';
export function authenticate(
{githubToken = 'GH_TOKEN', githubUrl = 'https://api.github.com', githubApiPathPrefix = ''} = {}
) {
return nock(`${githubUrl}/${githubApiPathPrefix}`, {reqheaders: {Authorization: `token ${githubToken}`}});
}
+14
View File
@@ -0,0 +1,14 @@
import execa from 'execa';
const opts = {cwd: __dirname};
export const uri =
'http://localhost:' + (process.env.TRAVIS === 'true' ? 5984 : 15986) + '/registry/_design/app/_rewrite/';
export function start() {
return execa('./start.sh', opts);
}
export function stop() {
return execa('./stop.sh', opts);
}
+20
View File
@@ -0,0 +1,20 @@
[couchdb]
database_dir = data
view_index_dir = data
delayed_commits = false
uuid = bf4ecd84a7c89d60b5b2540fdf8c322c
[couch_httpd_auth]
public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
users_db_public = true
[httpd]
port = 15986
bind_address = 127.0.0.1
secure_rewrites = false
[log]
file = couch/couch.log
[admins]
admin = -pbkdf2-89582b49cd2e8443e29a841f5a76d367956a8e58,1afa2f1531a17ac97f2ac9e334293753,10
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
# exit if an error occurs
set -e
cd $(dirname $0)
mkdir -p couch
if [[ $TRAVIS = true ]]
then
COUCH=http://admin:password@127.0.0.1:5984
curl -X PUT http://127.0.0.1:5984/_config/admins/admin -d '"password"'
curl -X PUT $COUCH/_config/couchdb/delayed_commits -d '"false"'
curl -X PUT $COUCH/_config/couch_httpd_auth/users_db_public -d '"true"'
curl -X PUT $COUCH/_config/couch_httpd_auth/public_fields -d '"appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev"'
curl -X PUT $COUCH/_config/httpd/secure_rewrites -d '"false"'
else
COUCH=http://admin:password@127.0.0.1:15986
couchdb -b -a local.ini -p couch/pid -o couch/stdout.log -e couch/stderr.log
# wait for couch to start
sleep 1
fi
# create "registry" database
curl -X PUT $COUCH/registry
# create sample npm user
curl -X PUT $COUCH/_users/org.couchdb.user:integration -H Content-Type:application/json --data-binary '{"_id": "org.couchdb.user:integration", "name": "integration", "roles": [], "type": "user", "password": "suchsecure", "email": "integration@test.com"}'
# npm-registry-couchpp needs this variable set to run
export DEPLOY_VERSION=nope
# setup npm-registry-couchapp
npm explore npm-registry-couchapp -- npm start --npm-registry-couchapp:couch=$COUCH/registry
npm explore npm-registry-couchapp -- npm run load --npm-registry-couchapp:couch=$COUCH/registry
export NO_PROMPT=yes
npm explore npm-registry-couchapp -- npm run copy --npm-registry-couchapp:couch=$COUCH/registry
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# close couchdb background process
couchdb -d
# delete data and logs
cd $(dirname $0)
cat couch/{couch,stdout,stderr}.log
cat couch/pid | xargs kill
rm -rf couch
rm -rf data
+304
View File
@@ -0,0 +1,304 @@
import test from 'ava';
import {writeJson, readJson} from 'fs-extra';
import {start, stop, uri} from './helpers/registry';
import {gitRepo, gitCommits, gitHead, gitTagVersion, gitPackRefs, gitAmmendCommit} from './helpers/git-utils';
import execa from 'execa';
// Environment variables used with cli
const env = {
CI: true,
npm_config_registry: uri,
GH_TOKEN: 'github_token',
NPM_OLD_TOKEN: 'aW50ZWdyYXRpb246c3VjaHNlY3VyZQ==',
NPM_EMAIL: 'integration@test.com',
};
test.before(async t => {
// Start the local NPM registry
await start();
});
test.beforeEach(async t => {
// Save the current working diretory
t.context.cwd = process.cwd();
});
test.afterEach.always(async t => {
// Restore the current working directory
process.chdir(t.context.cwd);
});
test.after.always(async t => {
// Stop the local NPM registry
await stop();
});
test.serial('Release patch, minor and major versions', async t => {
// Create a git repository, set the current working directory at the root of the repo
t.log('Create git repository');
await gitRepo();
// Create package.json in repository root
await writeJson('./package.json', {
name: 'test-module',
version: '0.0.0-dev',
repository: {url: 'git+https://github.com/semantic-release/test-module'},
release: {verifyConditions: require.resolve('../src/lib/plugin-noop')},
});
// Create a npm-shrinkwrap.json file
await execa('npm', ['shrinkwrap'], {env});
/** No release **/
t.log('Commit a chore');
await gitCommits(['chore: Init repository']);
t.log('$ semantic-release pre');
let {stdout, stderr, code} = await t.throws(execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
t.regex(stderr, /ENOCHANGE There are no relevant changes, so no new version is released/);
t.is(code, 1);
/** Minor release **/
t.log('Commit a feature');
await gitCommits(['feat: Initial commit']);
t.log('$ semantic-release pre');
({stdout, stderr, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
// Verify package.json and npm-shrinkwrap.json have been updated
t.is((await readJson('./package.json')).version, '1.0.0');
t.is((await readJson('./npm-shrinkwrap.json')).version, '1.0.0');
t.log('$ npm publish');
({stdout, stderr, code} = await execa('npm', ['publish'], {env}));
// Verify output of npm publish
t.regex(stdout, /test-module@1.0.0/);
t.is(code, 0);
// Retrieve the published package from the registry and check version and gitHead
let [, version, releaseGitHead] = /^version = '(.+)'\s+gitHead = '(.+)'$/.exec(
(await execa('npm', ['show', 'test-module', 'version', 'gitHead'], {env})).stdout
);
t.is(version, '1.0.0');
t.is(releaseGitHead, await gitHead());
t.log(`+ released ${version} with gitHead ${releaseGitHead}`);
/** Patch release **/
t.log('Commit a fix');
await gitCommits(['fix: bar']);
t.log('$ semantic-release pre');
({stdout, stderr, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
// Verify package.json and npm-shrinkwrap.json have been updated
t.is((await readJson('./package.json')).version, '1.0.1');
t.is((await readJson('./npm-shrinkwrap.json')).version, '1.0.1');
t.log('$ npm publish');
({stdout, stderr, code} = await execa('npm', ['publish'], {env}));
// Verify output of npm publish
t.regex(stdout, /test-module@1.0.1/);
t.is(code, 0);
// Retrieve the published package from the registry and check version and gitHead
[, version, releaseGitHead] = /^version = '(.+)'\s+gitHead = '(.+)'$/.exec(
(await execa('npm', ['show', 'test-module', 'version', 'gitHead'], {env})).stdout
);
t.is(version, '1.0.1');
t.is(releaseGitHead, await gitHead());
t.log(`+ released ${version} with gitHead ${releaseGitHead}`);
/** Minor release **/
t.log('Commit a feature');
await gitCommits(['feat: baz']);
t.log('$ semantic-release pre');
({stdout, stderr, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
// Verify package.json and npm-shrinkwrap.json have been updated
t.is((await readJson('./package.json')).version, '1.1.0');
t.is((await readJson('./npm-shrinkwrap.json')).version, '1.1.0');
t.log('$ npm publish');
({stdout, stderr, code} = await execa('npm', ['publish'], {env}));
// Verify output of npm publish
t.regex(stdout, /test-module@1.1.0/);
t.is(code, 0);
// Retrieve the published package from the registry and check version and gitHead
[, version, releaseGitHead] = /^version = '(.+)'\s+gitHead = '(.+)'$/.exec(
(await execa('npm', ['show', 'test-module', 'version', 'gitHead'], {env})).stdout
);
t.is(version, '1.1.0');
t.is(releaseGitHead, await gitHead());
t.log(`+ released ${version} with gitHead ${releaseGitHead}`);
/** Major release **/
t.log('Commit a breaking change');
await gitCommits(['feat: foo\n\n BREAKING CHANGE: bar']);
t.log('$ semantic-release pre');
({stdout, stderr, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
// Verify package.json and npm-shrinkwrap.json have been updated
t.is((await readJson('./package.json')).version, '2.0.0');
t.is((await readJson('./npm-shrinkwrap.json')).version, '2.0.0');
t.log('$ npm publish');
({stdout, stderr, code} = await execa('npm', ['publish'], {env}));
// Verify output of npm publish
t.regex(stdout, /test-module@2.0.0/);
t.is(code, 0);
// Retrieve the published package from the registry and check version and gitHead
[, version, releaseGitHead] = /^version = '(.+)'\s+gitHead = '(.+)'$/.exec(
(await execa('npm', ['show', 'test-module', 'version', 'gitHead'], {env})).stdout
);
t.is(version, '2.0.0');
t.is(releaseGitHead, await gitHead());
t.log(`+ released ${version} with gitHead ${releaseGitHead}`);
});
test.serial('Release versions from a packed git repository, using tags to determine last release gitHead', async t => {
// Create a git repository, set the current working directory at the root of the repo
t.log('Create git repository');
await gitRepo();
// Create package.json in repository root
await writeJson('./package.json', {
name: 'test-module-2',
version: '0.0.0-dev',
repository: {url: 'git+https://github.com/semantic-release/test-module-2'},
release: {verifyConditions: require.resolve('../src/lib/plugin-noop')},
});
/** Minor release **/
t.log('Commit a feature');
await gitCommits(['feat: Initial commit']);
t.log('$ git pack-refs --all');
await gitPackRefs();
t.log('$ semantic-release pre');
let {stdout, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env});
// Verify package.json has been updated
t.is((await readJson('./package.json')).version, '1.0.0');
t.log('$ npm publish');
({stdout, code} = await execa('npm', ['publish'], {env}));
// Verify output of npm publish
t.regex(stdout, /test-module-2@1.0.0/);
t.is(code, 0);
// Retrieve the published package from the registry and check version and gitHead
let version = (await execa('npm', ['show', 'test-module-2', 'version'], {env})).stdout;
t.is(version, '1.0.0');
t.log(`+ released ${version}`);
// Create a tag version so the tag can be used later to determine the commit associated with the version
await gitTagVersion('v1.0.0');
t.log('Create git tag v1.0.0');
/** Patch release **/
t.log('Commit a fix');
await gitCommits(['fix: bar']);
t.log('$ semantic-release pre');
({stdout, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
// Verify package.json has been updated
t.is((await readJson('./package.json')).version, '1.0.1');
t.log('$ npm publish');
({stdout, code} = await execa('npm', ['publish'], {env}));
// Verify output of npm publish
t.regex(stdout, /test-module-2@1.0.1/);
t.is(code, 0);
// Retrieve the published package from the registry and check version and gitHead
version = (await execa('npm', ['show', 'test-module-2', 'version'], {env})).stdout;
t.is(version, '1.0.1');
t.log(`+ released ${version}`);
});
test.serial('Exit with 1 in a plugin is not found', async t => {
// Environment variables used with cli
const env = {
CI: true,
npm_config_registry: uri,
GH_TOKEN: 'github_token',
NPM_OLD_TOKEN: 'aW50ZWdyYXRpb246c3VjaHNlY3VyZQ==',
NPM_EMAIL: 'integration@test.com',
};
// Create a git repository, set the current working directory at the root of the repo
t.log('Create git repository');
await gitRepo();
await writeJson('./package.json', {
name: 'test-module-3',
version: '0.0.0-dev',
repository: {url: 'git+https://github.com/semantic-release/test-module-4'},
release: {analyzeCommits: 'non-existing-path'},
});
const {code} = await t.throws(execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
t.is(code, 1);
});
test.serial('Create a tag as a recovery solution for "ENOTINHISTORY" error', async t => {
// Create a git repository, set the current working directory at the root of the repo
t.log('Create git repository');
await gitRepo();
// Create package.json in repository root
await writeJson('./package.json', {
name: 'test-module-4',
version: '0.0.0-dev',
repository: {url: 'git+https://github.com/semantic-release/test-module-2'},
release: {verifyConditions: require.resolve('../src/lib/plugin-noop')},
});
/** Minor release **/
t.log('Commit a feature');
await gitCommits(['feat: Initial commit']);
t.log('$ semantic-release pre');
let {stdout, stderr, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env});
// Verify package.json has been updated
t.is((await readJson('./package.json')).version, '1.0.0');
t.log('$ npm publish');
({stdout, code} = await execa('npm', ['publish'], {env}));
// Verify output of npm publish
t.regex(stdout, /test-module-4@1.0.0/);
t.is(code, 0);
// Retrieve the published package from the registry and check version and gitHead
let [, version, releaseGitHead] = /^version = '(.+)'\s+gitHead = '(.+)'$/.exec(
(await execa('npm', ['show', 'test-module-4', 'version', 'gitHead'], {env})).stdout
);
const head = await gitHead();
t.is(releaseGitHead, head);
t.log(`+ released ${version}`);
t.is(version, '1.0.0');
// Create a tag version so the tag can be used later to determine the commit associated with the version
await gitTagVersion('v1.0.0');
t.log('Create git tag v1.0.0');
/** Rewrite sha of commit used for release **/
t.log('Amend release commit');
const {hash} = await gitAmmendCommit('feat: Initial commit');
/** Patch release **/
t.log('Commit a fix');
await gitCommits(['fix: bar']);
t.log('$ semantic-release pre');
({stderr, stdout, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env, reject: false}));
t.log('Fail with "ENOTINHISTORY" error');
t.is(code, 1);
t.regex(
stderr,
new RegExp(
`You can recover from this error by restoring the commit "${head}" or by creating a tag for the version "1.0.0" on the commit corresponding to this release`
)
);
/** Create a tag to recover and redo release **/
t.log('Create git tag v1.0.0 to recover');
await gitTagVersion('v1.0.0', hash);
t.log('$ semantic-release pre');
({stderr, stdout, code} = await execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
// Verify package.json has been updated
t.is((await readJson('./package.json')).version, '1.0.1');
t.log('$ npm publish');
({stdout, code} = await execa('npm', ['publish'], {env}));
// Verify output of npm publish
t.regex(stdout, /test-module-4@1.0.1/);
t.is(code, 0);
// Retrieve the published package from the registry and check version and gitHead
version = (await execa('npm', ['show', 'test-module-4', 'version'], {env})).stdout;
t.is(version, '1.0.1');
t.log(`+ released ${version}`);
});
+103
View File
@@ -0,0 +1,103 @@
import {promisify} from 'util';
import test from 'ava';
import plugins from '../src/lib/plugins';
test('Export plugins', t => {
// Call the plugin module
const defaultPlugins = plugins({});
// Verify the module returns a function for each plugin
t.is(typeof defaultPlugins.analyzeCommits, 'function');
t.is(typeof defaultPlugins.generateNotes, 'function');
t.is(typeof defaultPlugins.verifyConditions, 'function');
t.is(typeof defaultPlugins.verifyRelease, 'function');
t.is(typeof defaultPlugins.getLastRelease, 'function');
});
test('Pipeline - Get all results', async t => {
// Call the plugin module with a verifyRelease plugin pipeline
const pipelinePlugins = plugins({
verifyRelease: ['./src/lib/plugin-noop', './test/fixtures/plugin-result-a', './test/fixtures/plugin-result-b'],
});
// Call the verifyRelease pipeline
const results = await pipelinePlugins.verifyRelease({});
// Verify the pipeline return the expected result for each plugin, in order
t.deepEqual(results, [undefined, 'a', 'b']);
});
test('Pipeline - Pass pluginConfig and options to each plugins', async t => {
// Plugin configuration with options (plugin-result-config is a mock plugin returning its pluginConfig and options parameters)
const pluginConfig = {path: './test/fixtures/plugin-result-config', pluginParam: 'param1'};
// Semantic-release global options
const options = {semanticReleaseParam: 'param2'};
// Call the plugin module with a verifyRelease plugin pipeline
const pipelinePlugins = plugins({
verifyRelease: [pluginConfig, './test/fixtures/plugin-result-config'],
});
// Call the verifyRelease pipeline
const results = await pipelinePlugins.verifyRelease(options);
// Verify the pipeline first result is the pluginConfig and options parameters (to verify the plugin was called with the defined pluginConfig and options parameters)
t.deepEqual(results, [{pluginConfig, options}, {pluginConfig: {}, options}]);
});
test('Pipeline - Get first error', async t => {
// Call the plugin module with a verifyRelease plugin pipeline
const pipelinePlugins = plugins({
verifyRelease: ['./src/lib/plugin-noop', './test/fixtures/plugin-error-a', './test/fixtures/plugin-error-b'],
});
// Call the verifyRelease pipeline and verify it returns the error thrown by './test/fixtures/plugin-error-a'
await t.throws(pipelinePlugins.verifyRelease({}), 'a');
});
test('Normalize and load plugin from string', t => {
// Call the normalize function with a path
const plugin = plugins.normalize('./src/lib/plugin-noop');
// Verify the plugin is loaded
t.is(typeof plugin, 'function');
});
test('Normalize and load plugin from object', t => {
// Call the normalize function with an object (with path property)
const plugin = plugins.normalize({path: './src/lib/plugin-noop'});
// Verify the plugin is loaded
t.is(typeof plugin, 'function');
});
test('Load from fallback', t => {
// Call the normalize function with a fallback
const plugin = plugins.normalize(null, '../lib/plugin-noop');
// Verify the fallback plugin is loaded
t.is(typeof plugin, 'function');
});
test('Always pass a defined "pluginConfig" for plugin defined with string', async t => {
// Call the normalize function with the path of a plugin that returns its config
const plugin = plugins.normalize('./test/fixtures/plugin-result-config');
const pluginResult = await promisify(plugin)({});
t.deepEqual(pluginResult.pluginConfig, {});
});
test('Always pass a defined "pluginConfig" for plugin defined with path', async t => {
// Call the normalize function with the path of a plugin that returns its config
const plugin = plugins.normalize({path: './test/fixtures/plugin-result-config'});
const pluginResult = await promisify(plugin)({});
t.deepEqual(pluginResult.pluginConfig, {path: './test/fixtures/plugin-result-config'});
});
test('Always pass a defined "pluginConfig" for fallback plugin', async t => {
// Call the normalize function with the path of a plugin that returns its config
const plugin = plugins.normalize(null, '../../test/fixtures/plugin-result-config');
const pluginResult = await promisify(plugin)({});
t.deepEqual(pluginResult.pluginConfig, {});
});
+151
View File
@@ -0,0 +1,151 @@
import {callbackify} from 'util';
import test from 'ava';
import {gitRepo, gitCommits, gitHead} from './helpers/git-utils';
import {stub} from 'sinon';
import nock from 'nock';
import {authenticate} from './helpers/mock-github';
import post from '../src/post';
test.beforeEach(t => {
// Save the current working diretory
t.context.cwd = process.cwd();
});
test.afterEach.always(t => {
// Restore the current working directory
process.chdir(t.context.cwd);
// Reset nock
nock.cleanAll();
});
test.serial('Post run with github token', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
await gitCommits(['fix: First fix', 'feat: Second feature']);
const sha = await gitHead();
const owner = 'test_user';
const repo = 'test_repo';
const githubUrl = 'https://testurl.com:443';
const githubToken = 'github_token';
const githubApiPathPrefix = 'prefix';
const releaseLog = 'Test release note body';
// Stub the generateNotes plugin
const generateNotes = stub().resolves(releaseLog);
const version = '1.0.0';
const branch = 'master';
const debug = false;
const tagName = `v${version}`;
const options = {branch, debug, githubUrl, githubToken, githubApiPathPrefix};
const pkg = {version, repository: {url: `git+https://othertesturl.com/${owner}/${repo}.git`}};
// Mock github API for releases and git/refs endpoints
const github = authenticate({githubUrl, githubToken, githubApiPathPrefix})
.post(`/repos/${owner}/${repo}/releases`, {
tag_name: tagName,
target_commitish: branch,
name: tagName,
body: releaseLog,
draft: debug,
})
.reply({})
.post(`/repos/${owner}/${repo}/git/refs`, {ref: `refs/tags/${tagName}`, sha})
.reply({});
// Call the post module
const result = await post({pkg, options, plugins: {generateNotes: callbackify(generateNotes)}});
// Verify the getLastRelease plugin has been called with 'options' and 'pkg'
t.true(generateNotes.calledOnce);
t.deepEqual(generateNotes.firstCall.args[0].options, options);
t.deepEqual(generateNotes.firstCall.args[0].pkg, pkg);
// Verify the published release note
t.deepEqual(result, {
published: true,
release: {owner, repo, tag_name: tagName, name: tagName, target_commitish: branch, draft: debug, body: releaseLog},
});
// Verify the releases and git/refs endpoint have been call with expected requests
t.true(github.isDone());
});
test.serial('Post dry run with github token', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
await gitCommits(['fix: First fix', 'feat: Second feature']);
const owner = 'test_user';
const repo = 'test_repo';
const githubToken = 'github_token';
const releaseLog = 'Test release note body';
// Stub the generateNotes plugin
const generateNotes = stub().resolves(releaseLog);
const version = '1.0.0';
const branch = 'master';
const debug = true;
const tagName = `v${version}`;
const options = {branch, debug, githubToken};
const pkg = {version, repository: {url: `git+https://othertesturl.com/${owner}/${repo}.git`}};
// Mock github API for releases endpoint
const github = authenticate({githubToken})
.post(`/repos/${owner}/${repo}/releases`, {
tag_name: tagName,
target_commitish: branch,
name: tagName,
body: releaseLog,
draft: debug,
})
.reply({});
// Call the post module
const result = await post({pkg, options, plugins: {generateNotes: callbackify(generateNotes)}});
// Verify the getLastRelease plugin has been called with 'options' and 'pkg'
t.true(generateNotes.calledOnce);
t.deepEqual(generateNotes.firstCall.args[0].options, options);
t.deepEqual(generateNotes.firstCall.args[0].pkg, pkg);
// Verify the published release note
t.deepEqual(result, {
published: true,
release: {owner, repo, tag_name: tagName, name: tagName, target_commitish: branch, draft: debug, body: releaseLog},
});
// Verify the releases and git/refs endpoint have been call with expected requests
t.true(github.isDone());
});
test.serial('Post dry run without github token', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
await gitCommits(['fix: First fix', 'feat: Second feature']);
const owner = 'test_user';
const repo = 'test_repo';
const releaseLog = 'Test release note body';
// Stub the generateNotes plugin
const generateNotes = stub().resolves(releaseLog);
const version = '1.0.0';
const branch = 'master';
const debug = true;
const tagName = `v${version}`;
const options = {branch, debug};
const pkg = {version, repository: {url: `git+https://othertesturl.com/${owner}/${repo}.git`}};
// Call the post module
const result = await post({pkg, options, plugins: {generateNotes: callbackify(generateNotes)}});
// Verify the getLastRelease plugin has been called with 'options' and 'pkg'
t.true(generateNotes.calledOnce);
t.deepEqual(generateNotes.firstCall.args[0].options, options);
t.deepEqual(generateNotes.firstCall.args[0].pkg, pkg);
// Verify the release note
t.deepEqual(result, {
published: false,
release: {owner, repo, tag_name: tagName, name: tagName, target_commitish: branch, draft: debug, body: releaseLog},
});
});
+163
View File
@@ -0,0 +1,163 @@
import {callbackify} from 'util';
import test from 'ava';
import {gitRepo, gitCommits} from './helpers/git-utils';
import proxyquire from 'proxyquire';
import {stub} from 'sinon';
// Stub to capture the log messages
const errorLog = stub();
// Module to test
const pre = proxyquire('../src/pre', {
'./lib/get-commits': proxyquire('../src/lib/get-commits', {npmlog: {error: errorLog}}),
});
test.beforeEach(t => {
// Save the current working diretory
t.context.cwd = process.cwd();
// Reset the stub call history
errorLog.resetHistory();
});
test.afterEach.always(t => {
// Restore the current working directory
process.chdir(t.context.cwd);
});
test.serial('Increase version', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
const cmts = await gitCommits(['fix: First fix', 'feat: Second feature']);
const options = {branch: 'master'};
const pkg = {name: 'available'};
const lastRelease = {version: '1.0.0', gitHead: cmts[cmts.length - 1].hash};
// Stub the getLastRelease, analyzeCommits and verifyRelease plugins
const getLastRelease = stub().resolves(lastRelease);
const analyzeCommits = stub().resolves('major');
const verifyRelease = stub().resolves();
// Call the pre module
const nextRelease = await pre({
options,
pkg,
plugins: {
getLastRelease: callbackify(getLastRelease),
analyzeCommits: callbackify(analyzeCommits),
verifyRelease: verifyRelease,
},
});
// Verify the pre module returns the 'type' returned by analyzeCommits and the 'version' returned by getLastRelease increamented with the 'type' (current version 1.0.0 => major release = version 2.0.0)
t.deepEqual(nextRelease, {type: 'major', version: '2.0.0'});
// Verify the getLastRelease plugin has been called with 'options' and 'pkg'
t.true(getLastRelease.calledOnce);
t.deepEqual(getLastRelease.firstCall.args[0].options, options);
t.deepEqual(getLastRelease.firstCall.args[0].pkg, pkg);
// Verify the analyzeCommits plugin has been called with the repo 'commits' since lastVersion githead
t.true(analyzeCommits.calledOnce);
t.is(analyzeCommits.firstCall.args[0].commits.length, 1);
t.is(analyzeCommits.firstCall.args[0].commits[0].hash.substring(0, 7), cmts[0].hash);
t.is(analyzeCommits.firstCall.args[0].commits[0].message, cmts[0].message);
// Verify the verifyRelease plugin has been called with 'lastRelease' and 'nextRelease'
t.true(verifyRelease.calledOnce);
t.deepEqual(verifyRelease.firstCall.args[0].lastRelease, lastRelease);
t.deepEqual(verifyRelease.firstCall.args[0].nextRelease, nextRelease);
});
test.serial('Initial version', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
const cmts = await gitCommits(['fix(scope1): First fix', 'feat(scope2): Second feature']);
const options = {branch: 'master'};
const pkg = {name: 'available'};
const lastRelease = {version: null, gitHead: undefined};
// Stub the getLastRelease, analyzeCommits and verifyRelease plugins
const getLastRelease = stub().resolves({version: null, gitHead: undefined});
const analyzeCommits = stub().resolves('major');
const verifyRelease = stub().resolves();
// Call the pre module
const nextRelease = await pre({
options,
pkg,
plugins: {
getLastRelease: callbackify(getLastRelease),
analyzeCommits: callbackify(analyzeCommits),
verifyRelease: verifyRelease,
},
});
// Verify the pre module returns the 'type' returned by analyzeCommits and the 'version' returned by getLastRelease increamented with the 'type' (no current version => initial release = version 1.0.0)
t.deepEqual(nextRelease, {type: 'initial', version: '1.0.0'});
// Verify the getLastRelease plugin has been called with 'options' and 'pkg'
t.true(getLastRelease.calledOnce);
t.deepEqual(getLastRelease.firstCall.args[0].options, options);
t.deepEqual(getLastRelease.firstCall.args[0].pkg, pkg);
// Verify the analyzeCommits plugin has been called with all the repo 'commits'
t.true(analyzeCommits.calledOnce);
t.is(analyzeCommits.firstCall.args[0].commits.length, 2);
t.is(analyzeCommits.firstCall.args[0].commits[0].hash.substring(0, 7), cmts[0].hash);
t.is(analyzeCommits.firstCall.args[0].commits[0].message, cmts[0].message);
t.is(analyzeCommits.firstCall.args[0].commits[1].hash.substring(0, 7), cmts[1].hash);
t.is(analyzeCommits.firstCall.args[0].commits[1].message, cmts[1].message);
// Verify the verifyRelease plugin has been called with 'lastRelease' and 'nextRelease'
t.true(verifyRelease.calledOnce);
t.deepEqual(verifyRelease.firstCall.args[0].lastRelease, lastRelease);
t.deepEqual(verifyRelease.firstCall.args[0].nextRelease, nextRelease);
});
test.serial('Throws error if verifyRelease fails', async t => {
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
const cmts = await gitCommits(['fix: First fix', 'feat: Second feature']);
const options = {branch: 'master'};
const pkg = {name: 'available'};
const lastRelease = {version: '1.0.0', gitHead: cmts[cmts.length - 1].hash};
// Stub the getLastRelease, analyzeCommits and verifyRelease plugins
const getLastRelease = stub().resolves(lastRelease);
const analyzeCommits = stub().resolves('major');
const verifyRelease = stub().rejects(new Error('verifyRelease failed'));
// Call the pre module and verify it returns the Error returned by verifyRelease
const error = await t.throws(
pre({
options,
pkg,
plugins: {
getLastRelease: callbackify(getLastRelease),
analyzeCommits: callbackify(analyzeCommits),
verifyRelease: verifyRelease,
},
})
);
// Verify the error message is the one returned by verifyRelease
t.is(error.message, 'verifyRelease failed');
// Verify the getLastRelease plugin has been called with 'options' and 'pkg'
t.true(getLastRelease.calledOnce);
t.deepEqual(getLastRelease.firstCall.args[0].options, options);
t.deepEqual(getLastRelease.firstCall.args[0].pkg, pkg);
// Verify the analyzeCommits plugin has been called with all the repo 'commits'
t.true(analyzeCommits.calledOnce);
t.is(analyzeCommits.firstCall.args[0].commits.length, 1);
t.is(analyzeCommits.firstCall.args[0].commits[0].hash.substring(0, 7), cmts[0].hash);
t.is(analyzeCommits.firstCall.args[0].commits[0].message, cmts[0].message);
// Verify the verifyRelease plugin has been called with 'lastRelease' and 'nextRelease'
t.true(verifyRelease.calledOnce);
t.deepEqual(verifyRelease.firstCall.args[0].lastRelease, lastRelease);
t.deepEqual(verifyRelease.firstCall.args[0].nextRelease, {type: 'major', version: '2.0.0'});
});
+71
View File
@@ -0,0 +1,71 @@
import test from 'ava';
import verify from '../src/lib/verify';
test('Dry run - Verify pkg, options and env', t => {
// Call the verify module with debug (Dry run), package name and repo URL
const errors = verify({
options: {debug: true},
pkg: {name: 'package', repository: {url: 'http://github.com/whats/up.git'}},
});
// Verify no error has been returned
t.is(errors.length, 0);
});
test('Dry run - Returns errors for missing package name and repo', t => {
// Call the verify module with debug (Dry run), no package name and no repo URL
const errors = verify({options: {debug: true}, pkg: {}});
// Verify the module return an error for each missing configuration
t.is(errors.length, 2);
t.is(errors[0].code, 'ENOPKGNAME');
t.is(errors[1].code, 'ENOPKGREPO');
});
test('Dry run - Verify pkg, options and env for gitlab repo', t => {
// Call the verify module with debug (Dry run), no package name and no repo URL
const errors = verify({
options: {debug: true},
pkg: {name: 'package', repository: {url: 'http://gitlab.corp.com/whats/up.git'}},
});
// Verify no error has been returned
t.is(errors.length, 0);
});
test('Publish - Verify pkg, options and env', t => {
// Call the verify module with package name, repo URL, npm token and github token
const errors = verify({
env: {NPM_TOKEN: 'yo'},
options: {githubToken: 'sup'},
pkg: {name: 'package', repository: {url: 'http://github.com/whats/up.git'}},
});
// Verify no error has been returned
t.is(errors.length, 0);
});
test('Publish - Returns errors for missing package name, repo github token and npm token', t => {
// Call the verify module with no package name, no repo URL, no NPM token and no github token
const errors = verify({env: {}, options: {}, pkg: {}});
// Verify the module return an error for each missing configuration
t.is(errors.length, 4);
t.is(errors[0].code, 'ENOPKGNAME');
t.is(errors[1].code, 'ENOPKGREPO');
t.is(errors[2].code, 'ENOGHTOKEN');
t.is(errors[3].code, 'ENONPMTOKEN');
});
test('Publish - Returns errors for missing email when using legacy npm token', t => {
// Call the verify module with package name, repo URL, old NPM token and github token and no npm email
const errors = verify({
env: {NPM_OLD_TOKEN: 'yo'},
options: {githubToken: 'sup'},
pkg: {name: 'package', repository: {url: 'http://github.com/whats/up.git'}},
});
// Verify the module return an error for each missing configuration
t.is(errors.length, 1);
t.is(errors[0].code, 'ENONPMTOKEN');
});
-1
View File
@@ -1 +0,0 @@
test:{SHA}C+7Hteo/D9vJXQ3UfzxbwnXaijM=
-3
View File
@@ -1,3 +0,0 @@
_auth=dGVzdDpmb28=
email=test@example.com
registry=http://127.0.0.1:4873/
-17
View File
@@ -1,17 +0,0 @@
storage: ../.tmp/.storage
auth:
htpasswd:
file: ./.htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
logs:
- {type: stdout, format: pretty, level: silent}
packages:
'*':
allow_access: all
allow_publish: all
-10
View File
@@ -1,10 +0,0 @@
'use strict'
var test = require('tape')
var createModule = require('./lib/create-module')
require('./scenarios/install')(test, createModule)
require('./scenarios/prepublish')(test, createModule)
require('./scenarios/postpublish')(test, createModule)
require('./scenarios/publish')(test, createModule)
-45
View File
@@ -1,45 +0,0 @@
'use strict'
var exec = require('child_process').exec
var join = require('path').join
var efh = require('error-first-handler')
var defaults = require('lodash.defaults')
var uid = require('nano-uid')()
module.exports = function (input) {
var cb = Array.prototype.pop.call(arguments)
uid.generate(5, efh(cb)(function (id) {
var pkg = defaults((typeof input === 'object' ? input : {}), {
name: id,
version: '0.0.0',
devDependencies: {
'semantic-release': 'file:../../../'
},
scripts: {
prepublish: 'semantic-release pre',
postpublish: 'semantic-release post'
},
publishConfig: {
registry: 'http://localhost:4873/'
}
})
id = pkg.name
var cwd = join(__dirname, '../../.tmp/modules', id)
exec(
'mkdir ' + cwd + ' && ' +
'cd ' + cwd + ' && ' +
'git init && ' +
'echo \'' + JSON.stringify(pkg, null, 2) + '\' >> package.json && ' +
'git add . && ' +
'git config user.email "integration@test" && ' +
'git config user.name "Integration Test" && ' +
'git commit -m "initial" && ' +
'npm install'
, efh(cb)(function (stdout) {
cb(null, id, cwd)
}))
}))
}
-33
View File
@@ -1,33 +0,0 @@
'use strict'
var fs = require('fs')
var efh = require('error-first-handler')
var nixt = require('nixt')
module.exports = function (test, createModule) {
createModule(efh()(function (name, cwd) {
test('install', function (t) {
installTest(t, 'npm install', 'not doing anything when the module is installed')
installTest(t, 'npm i', 'not doing anything when the module is installed with abbrevd command')
})
function installTest (t, command, name, last) {
t.test(name, function (t) {
t.plan(2)
var pkg = fs.readFileSync(cwd + '/package.json')
nixt()
.cwd(cwd)
.run(command)
.code(0)
.stdout(/> semantic-release pre\n$/m)
.end(function(err) {
t.is(pkg + '', fs.readFileSync(cwd + '/package.json') + '', 'package')
t.error(err, 'nixt')
})
})
}
}))
}
-57
View File
@@ -1,57 +0,0 @@
'use strict'
var efh = require('error-first-handler')
var GitHubApi = require('github')
var nixt = require('nixt')
var github = new GitHubApi({
version: '3.0.0',
port: 4343,
protocol: 'http',
host: '127.0.0.1'
})
github.authenticate({
type: 'oauth',
token: '***'
})
module.exports = function (test, createModule) {
createModule({
version: '2.0.0',
repository: {
type: 'git',
url: 'http://github.com/user/repo'
}
}, efh()(function (name, cwd) {
test('postpublish', function (t) {
t.test('publish new version to github releases', function (t) {
t.plan(1)
nixt()
.cwd(cwd)
.env('CI', true)
.env('GH_URL', 'http://127.0.0.1:4343/')
.env('GH_TOKEN', '***')
.exec('git commit --allow-empty -m "feat(cool): the next big thing"')
.run('npm run postpublish')
.code(0)
.stdout(/> semantic-release post\n\nGenerating changelog from.*\nParsed/m)
.end(function(err) {
t.error(err, 'nixt')
})
})
t.test('correct data published', function (t) {
t.plan(4)
github.releases.getRelease({ owner: 'user', repo: 'repo', id: 1}, function (err, res) {
t.error(err, 'github')
t.is(res.tag_name, 'v2.0.0', 'version')
t.is(res.author.login, 'user', 'user')
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\* the next big thing/.test(res.body), 'body')
})
})
})
}))
}
-50
View File
@@ -1,50 +0,0 @@
'use strict'
var fs = require('fs')
var exec = require('child_process').exec
var efh = require('error-first-handler')
var nixt = require('nixt')
module.exports = function (test, createModule) {
createModule(efh()(function (name, cwd) {
test('prepublish', function (t) {
prepublishTest(t, 'refactor: change', '0.0.0', 1, 'abort publish w/o changes')
prepublishTest(t, 'fix: change', '1.0.0', 0, 'release 1.0.0 if unpublished')
prepublishTest(t, 'fix: change', '1.0.1', 0, 'bump patch for fix')
prepublishTest(t, 'feat: change', '1.1.0', 0, 'bump minor for feature')
prepublishTest(t, 'fix: BREAKING CHANGE: change', '2.0.0', 0, 'bump major for breaking change')
})
function prepublishTest (t, message, version, code, name) {
t.test(name, function (t) {
t.plan(3)
nixt()
.cwd(cwd)
.env('CI', true)
.env('npm_config_registry', 'http://127.0.0.1:4873/')
.exec('git commit --allow-empty -m "' + message + '"')
.run('npm run prepublish')
.code(code)
.stdout(/> semantic-release pre\n\nDetermining new version\n/m)
.end(function(err) {
t.error(err, 'nixt')
var pkg = JSON.parse(fs.readFileSync(cwd + '/package.json'))
t.is(pkg.version, version, 'version')
if (code === 1) {
return t.error(null, 'no publish')
}
exec('npm publish --ignore-scripts', {cwd: cwd}, function(err) {
setTimeout(function() {
t.error(err, 'publish')
}, 300)
})
})
})
}
}))
}
-37
View File
@@ -1,37 +0,0 @@
'use strict'
var efh = require('error-first-handler')
var nixt = require('nixt')
module.exports = function (test, createModule) {
test('publish', function (t) {
publishTest(t, 'npm publish', 'pre and post hooks work as a part of publish')
publishTest(t, 'npm pub', 'pre and post hooks work as a part of publish with abbrevd command')
function publishTest (t, command, testname, last) {
createModule({
repository: {
type: 'git',
url: 'http://github.com/user/repo'
}
}, efh()(function (name, cwd) {
t.test(testname, function (t) {
t.plan(1)
nixt()
.cwd(cwd)
.env('CI', true)
.env('GH_URL', 'http://127.0.0.1:4343/')
.env('GH_TOKEN', '***')
.exec('git commit --allow-empty -m "feat: super"')
.run(command)
.code(1)
.stdout(/Everything is alright/)
.end(function(err) {
t.error(err, 'nixt')
})
})
}))
}
})
}