Skip to content

Commit

Permalink
Changes how release message works.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkmg committed Jul 5, 2016
1 parent 3215c08 commit 136da9c
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .release.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"set_release_message": true,
"release_message": true,
"pre_commit_commands": [
"npm test",
"rm main/* -rf",
Expand Down
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,17 @@ Options

run `generate-release --help` to see this as well.

-p, --package Path to package.json file. Default: ./package.json
-c, --current-version Current Version. Default: read from package.json
-t, --release-type Release Type: patch, minor, major. Default: prompt
-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation
-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull
-s, --skip-git-push Do not push to origin when complete. Default: Do push
-d, --release-file Path to your .release.json file. Default: ./.release.json
-m, --set-release-message Prompt to write a release message. Default: Do no prompt, use "Release {version}"
-o, --remote Change the remote. Default: origin
-q, --quiet Less output. Default: Do show output
-p, --package FILE Path to package.json file. Default: ./package.json
-c, --current-version VERSION Current Version. Default: read from package.json
-t, --release-type TYPE Release Type: patch, minor, major. Default: prompt
-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation
-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull
-s, --skip-git-push Do not push to origin when complete. Default: Do push
-d, --release-file FILE Path to your .release.json file. Default: ./.release.json
-o, --remote REMOTE Change the remote. Default: origin
-q, --quiet Less output. Default: Do show output
-m, release-message [MESSAGE] Set a release message. If no message given, prompt for one. Will replace
"{version}" with the next version. Default: Release {version}

**Release File**

Expand All @@ -102,7 +103,7 @@ is an example with all default options set.
"no_confirm": false,
"skip_git_pull": false,
"skip_git_push": false,
"set_release_message": true,
"release_message": true,
"remote": "origin",
"pre_commit_commands": [],
"post_commit_commands": [],
Expand All @@ -114,6 +115,8 @@ is an example with all default options set.
The `files_to_commit` and `files_to_version` use [node-glob](https://github.com/isaacs/node-glob). See the
documentation located there on how to format those options.

If `release_message` is true,

Building Assets, Running Tests, and Publishing Package
--------------------------------

Expand Down
4 changes: 2 additions & 2 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ module.exports = (args) ->

#Set/Get Release Message
.then ->
if @options.set_release_message is true
if @options.release_message is true
askReleaseMessage(@options.next_version)
else
@options.set_release_message.replace '{version}', @options.next_version
@options.release_message.replace '{version}', @options.next_version
.then (text) ->
@release_message = text

Expand Down
7 changes: 4 additions & 3 deletions src/lib/Options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ options =
switches: ['s', 'skip-git-push']
file_key: 'skip_git_push'
validate: (input) -> typeof input is 'boolean'
set_release_message:
release_message:
default: 'Release {version}'
switches: ['m', 'set-release-message']
file_key: 'set_release_message'
validate: (input) -> typeof input in ['boolean', 'string']
file_key: 'release_message'
filter: (input) -> if input is false then 'Release {version}' else input
validate: (input) -> input is true or typeof input is 'string'
pre_commit_commands:
default: []
switches: false
Expand Down
22 changes: 11 additions & 11 deletions src/lib/error/HelpError.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class HelpError extends Error
@message = """
generate-release
-p, --package Path to package.json file. Default: ./package.json
-c, --current-version Current Version. Default: read from package.json
-t, --release-type Release Type: patch, minor, major. Default: prompt
-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation
-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull
-s, --skip-git-push Do not push to origin when complete. Default: Do push
-d, --release-file Path to your .release.json file. Default: ./.release.json
-m, --set-release-message Prompt to write a release message. Default: Release {version}
-o, --remote Change the remote. Default: origin
-q, --quiet Less output. Default: Do show output
-p, --package FILE Path to package.json file. Default: ./package.json
-c, --current-version VERSION Current Version. Default: read from package.json
-t, --release-type TYPE Release Type: patch, minor, major. Default: prompt
-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation
-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull
-s, --skip-git-push Do not push to origin when complete. Default: Do push
-d, --release-file FILE Path to your .release.json file. Default: ./.release.json
-o, --remote REMOTE Change the remote. Default: origin
-q, --quiet Less output. Default: Do show output
-m, release-message [MESSAGE] Set a release message. If no message given, prompt for one. Will replace
"{version}" with the next version. Default: Release {version}
#{post or ''}"""

module.exports = HelpError
2 changes: 1 addition & 1 deletion test/helpers/setupTestRepo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ all_release_json = '''
"post_commit_commands": ["test2"],
"files_to_commit": ["test3"],
"files_to_version": ["test5"],
"set_release_message": true,
"release_message": "Testing Message {version}",
"remote": "test4"
}
'''
6 changes: 3 additions & 3 deletions test/specs/lib/Options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe 'Options', ->
assert.equal options.no_confirm, false
assert.equal options.skip_git_pull, false
assert.equal options.skip_git_push, false
assert.equal options.set_release_message, 'Release {version}'
assert.equal options.release_message, 'Release {version}'
assert.sameMembers options.files_to_version, ['README.md']


Expand All @@ -64,7 +64,7 @@ describe 'Options', ->
assert.equal options.no_confirm, true
assert.equal options.skip_git_pull, true
assert.equal options.skip_git_push, true
assert.equal options.set_release_message, true
assert.equal options.release_message, true

it 'should parse release file options correctly', ->
options = new Options [
Expand All @@ -77,7 +77,7 @@ describe 'Options', ->
assert.equal options.no_confirm, true
assert.equal options.skip_git_pull, true
assert.equal options.skip_git_push, true
assert.equal options.set_release_message, true
assert.equal options.release_message, 'Testing Message {version}'
assert.sameMembers options.pre_commit_commands, ['test1']
assert.sameMembers options.post_commit_commands, ['test2']
assert.sameMembers options.files_to_commit, ['test3']
Expand Down
22 changes: 20 additions & 2 deletions test/specs/run.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ GitCommands = require '../../src/lib/GitCommands'

main = require '../../src/index'

help_message = '''
generate-release
-p, --package FILE Path to package.json file. Default: ./package.json
-c, --current-version VERSION Current Version. Default: read from package.json
-t, --release-type TYPE Release Type: patch, minor, major. Default: prompt
-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation
-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull
-s, --skip-git-push Do not push to origin when complete. Default: Do push
-d, --release-file FILE Path to your .release.json file. Default: ./.release.json
-o, --remote REMOTE Change the remote. Default: origin
-q, --quiet Less output. Default: Do show output
-m, release-message [MESSAGE] Set a release message. If no message given, prompt for one. Will replace
"{version}" with the next version. Default: Release {version}
'''

describe 'run', ->
before ->
@run_arguments = ['node', 'script', '-t', 'patch', '-n', '-l', '-s', '-o', 'test']
Expand Down Expand Up @@ -80,7 +98,7 @@ describe 'run', ->
.try =>
main @help_arguments
.then =>
assert stdout_spy.calledWith('generate-release\n\n-p, --package Path to package.json file. Default: ./package.json\n-c, --current-version Current Version. Default: read from package.json\n-t, --release-type Release Type: patch, minor, major. Default: prompt\n-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation\n-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull\n-s, --skip-git-push Do not push to origin when complete. Default: Do push\n-d, --release-file Path to your .release.json file. Default: ./.release.json\n-m, --set-release-message Prompt to write a release message. Default: Release {version}\n-o, --remote Change the remote. Default: origin\n-q, --quiet Less output. Default: Do show output\n\n\n')
assert @exit_stub.calledWith(0)
assert.equal stdout_spy.args[0][0], help_message
assert @exit_stub.calledWith 0
.finally ->
stdout_spy.restore()

0 comments on commit 136da9c

Please sign in to comment.