Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a4ddd49
Showing
11 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
tmp/ | ||
test/tmp/ | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"bitwise": false, | ||
"camelcase": false, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"forin": false, | ||
"immed": true, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": true, | ||
"nonew": false, | ||
"plusplus": false, | ||
"quotmark": false, | ||
"regexp": false, | ||
"undef": true, | ||
"unused": true, | ||
"strict": true, | ||
"trailing": true, | ||
|
||
"asi": false, | ||
"boss": false, | ||
"debug": false, | ||
"eqnull": true, | ||
"es5": true, | ||
"esnext": false, | ||
"evil": false, | ||
"expr": false, | ||
"funcscope": false, | ||
"globalstrict": false, | ||
"iterator": false, | ||
"lastsemic": false, | ||
"laxbreak": false, | ||
"laxcomma": true, | ||
"loopfunc": false, | ||
"multistr": false, | ||
"onecase": true, | ||
"proto": false, | ||
"regexdash": false, | ||
"scripturl": false, | ||
"smarttabs": true, | ||
"shadow": false, | ||
"sub": false, | ||
"supernew": false, | ||
|
||
"node": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
src/ | ||
tmp/ | ||
test/ | ||
node_modules/ | ||
Gruntfile.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## Submitting an issue | ||
|
||
When reporting a bug, please describe it thoroughly, with attached code specyfying how are you using this task. | ||
|
||
## Contributions | ||
|
||
Contributions are welcome! But please, follow these few simple rules: | ||
|
||
**Maintain the coding style** used throughout the project, and defined in the `.editorconfig` file. You can use the | ||
[Editorconfig](http://editorconfig.org) plugin for your editor of choice: | ||
|
||
- [Sublime Text 2](https://github.com/sindresorhus/editorconfig-sublime) | ||
- [Textmate](https://github.com/Mr0grog/editorconfig-textmate) | ||
- [Notepad++](https://github.com/editorconfig/editorconfig-notepad-plus-plus) | ||
- [Emacs](https://github.com/editorconfig/editorconfig-emacs) | ||
- [Vim](https://github.com/editorconfig/editorconfig-vim) | ||
- [Visual Studio](https://github.com/editorconfig/editorconfig-visualstudio) | ||
- [... other editors](http://editorconfig.org/#download) | ||
|
||
--- | ||
|
||
**Code has to pass JSHint** with options defined in the `.jshintrc` file. You can use `grunt jshint` task to lint | ||
manually, or again, there are amazing plugins for a lot of popular editors consuming this file and linting as you code: | ||
|
||
- [Sublim Text 2](https://github.com/SublimeLinter/SublimeLinter) | ||
- [TextMate](http://rondevera.github.com/jslintmate/), or [alternative](http://fgnass.posterous.com/jslint-in-textmate) | ||
- [Notepad++](http://sourceforge.net/projects/jslintnpp/) | ||
- [Emacs](https://github.com/daleharvey/jshint-mode) | ||
- [Vim](https://github.com/walm/jshint.vim) | ||
- [Visual Studio](https://github.com/jamietre/SharpLinter), or [alternative](http://jslint4vs2010.codeplex.com/) | ||
- [... other editors](http://www.jshint.com/platforms/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* grunt-bumpup | ||
* https://github.com/Darsain/grunt-bumpup | ||
* | ||
* Licensed under the MIT license. | ||
* http://www.opensource.org/licenses/MIT | ||
*/ | ||
'use strict'; | ||
|
||
module.exports = function(grunt) { | ||
// Project configuration. | ||
grunt.initConfig({ | ||
jshint: { | ||
options: { | ||
jshintrc: '.jshintrc', | ||
}, | ||
all: [ | ||
'Gruntfile.js', | ||
'tasks/*.js', | ||
], | ||
}, | ||
|
||
// Configuration to be run. | ||
bumpup: { | ||
options: { | ||
dateformat: 'YYYY-MM-DD HH:mm', | ||
normalize: false | ||
}, | ||
files: ['test/v.json', 'test/d.json', 'test/vd.json'] | ||
} | ||
}); | ||
|
||
// Actually load this plugin's task(s). | ||
grunt.loadTasks('tasks'); | ||
|
||
// These plugins provide necessary tasks. | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
|
||
// Registering the testing task. | ||
grunt.registerTask('test', function (type) { | ||
type = type ? type : 'patch'; | ||
grunt.task.run('bumpup:' + type); | ||
}); | ||
|
||
// By default, lint and run all tests. | ||
grunt.registerTask('default', ['jshint', 'bumpup']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
# grunt-bumpup | ||
|
||
Updates the `version` and `date` properties in your JSON files. | ||
|
||
The properties are updated only when already present in the original JSON file. If a JSON file doesn't have `date` or | ||
`version` property, the plugin won't add it. | ||
|
||
The plugin also detects and preserves the indentation type in the original JSON file. | ||
|
||
This is a [Grunt](http://gruntjs.com/) 0.4 plugin. If you haven't used [Grunt](http://gruntjs.com/) before, be sure to | ||
check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a | ||
[Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. | ||
|
||
## Installation | ||
|
||
Use npm to install and save the plugin into `devDependencies`. | ||
|
||
```shell | ||
npm install grunt-bumpup --save-dev | ||
``` | ||
|
||
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: | ||
|
||
```js | ||
grunt.loadNpmTasks('grunt-bumpup'); | ||
``` | ||
|
||
## Configuration | ||
|
||
In your project's Gruntfile, add a section named `bumpup` to the data object passed into `grunt.initConfig()`. This is a | ||
simple task, and does not conform to multi task options & files input types! All available configuration styles are | ||
described below. | ||
|
||
This is the most verbose form of the configuration: | ||
|
||
```js | ||
grunt.initConfig({ | ||
bumpup: { | ||
options: { | ||
// Options go here. | ||
}, | ||
files: [ | ||
// JSON files go here. | ||
], | ||
}, | ||
}); | ||
``` | ||
|
||
### Configuration examples: | ||
|
||
Default options and one JSON file: | ||
|
||
```js | ||
grunt.initConfig({ | ||
bumpup: 'package.json' | ||
}); | ||
``` | ||
|
||
```js | ||
grunt.initConfig({ | ||
bumpup: { | ||
files: 'package.json' | ||
} | ||
}); | ||
``` | ||
|
||
Default options, and multiple JSON files: | ||
|
||
```js | ||
grunt.initConfig({ | ||
bumpup: ['package.json', 'component.json'] | ||
}); | ||
``` | ||
|
||
```js | ||
grunt.initConfig({ | ||
bumpup: { | ||
files: ['package.json', 'component.json'] | ||
} | ||
}); | ||
``` | ||
|
||
Custom options: | ||
|
||
```js | ||
grunt.initConfig({ | ||
bumpup: { | ||
options: { | ||
dateformat: 'YYYY-MM-DD HH:mm', | ||
normalize: false | ||
}, | ||
files: ['package.json', 'component.json'] | ||
} | ||
}); | ||
``` | ||
|
||
## Options | ||
|
||
#### options.dateformat | ||
Type: `String` | ||
Default: `YYYY-MM-DD HH:mm:ss Z` | ||
|
||
A date format string used by [moment.js'](http://momentjs.com) `.format()` method. To see all available format tokens, | ||
read the [moment.js' format documentation](http://momentjs.com/docs/#/displaying/format/). | ||
|
||
Following is the list of valid moment.js ISO-8601 (computer and human readable) date formats. | ||
|
||
``` | ||
YYYY-MM-DD | ||
YYYY-MM-DDTHH | ||
YYYY-MM-DD HH | ||
YYYY-MM-DDTHH:mm | ||
YYYY-MM-DD HH:mm | ||
YYYY-MM-DDTHH:mm:ss | ||
YYYY-MM-DD HH:mm:ss | ||
YYYY-MM-DDTHH:mm:ss.SSS | ||
YYYY-MM-DD HH:mm:ss.SSS | ||
YYYY-MM-DDTHH:mm:ss Z | ||
YYYY-MM-DD HH:mm:ss Z | ||
``` | ||
|
||
#### options.normalize | ||
Type: `Boolean` | ||
Default: `true` | ||
|
||
Whether to normalize all JSON files to have the same version. The version that is than bumped up and saved into all | ||
files is taken from the first file passed into the files array. | ||
|
||
## Usage | ||
|
||
You call this task from CLI with one argument, specifying the release type: | ||
|
||
```js | ||
grunt bump:type | ||
``` | ||
|
||
The type can be: | ||
|
||
- **major**: Will bump the major part of a version, resetting minor, patch, and build to 0. | ||
- **minor**: Will bump the minor part of a version, resetting patch, and build to 0. | ||
- **patch**: Will bump the patch part of a version, resetting build to 0. | ||
- **build**: Will bump the build part of a version. | ||
|
||
Version format: `major.minor.patch-build`. | ||
|
||
The build part is adjusted only when present. If you have a `1.0.0` version, the `-build` part won't be appended unless | ||
already present, or you've called the task with `build` argument: | ||
|
||
```shell | ||
grunt bumpup:build | ||
``` | ||
|
||
### Usage Examples | ||
|
||
#### Release task | ||
In this example, we create a release task that handles everything needed to build a new release of your project: | ||
|
||
```js | ||
// Task configurations | ||
grunt.initConfig({ | ||
jshint: ..., | ||
uglify: ..., | ||
bumpup: 'package.json' | ||
}); | ||
|
||
// Loading the plugins | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-bumpup'); | ||
|
||
// Alias task for release | ||
grunt.registerTask('release', function (release) { | ||
release = release ? release : 'patch'; | ||
grunt.task.run('jshint'); // Lint stuff | ||
grunt.task.run('uglify'); // Minify stuff | ||
grunt.task.run('bumpup:' + release); // Bump up the version | ||
}); | ||
``` | ||
|
||
And now you can call it from CLI like this: | ||
|
||
```shell | ||
grunt release:minor | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "grunt-bumpup", | ||
"description": "Update the version and date properties in JSON files while preserving indentation style.", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/Darsain/grunt-bumpup", | ||
"author": { | ||
"name": "Darsain", | ||
"url": "http://darsa.in" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/Darsain/grunt-bumpup.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Darsain/grunt-bumpup/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} | ||
], | ||
"main": "Gruntfile.js", | ||
"engines": { | ||
"node": ">=0.8.0" | ||
}, | ||
"scripts": { | ||
"test": "grunt test" | ||
}, | ||
"dependencies": { | ||
"moment": "~2.0.0", | ||
"semver": "~1.1.3" | ||
}, | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "~0.1.1", | ||
"grunt": "~0.4.0" | ||
}, | ||
"peerDependencies": { | ||
"grunt": "~0.4.0" | ||
}, | ||
"keywords": [ | ||
"gruntplugin" | ||
] | ||
} |
Oops, something went wrong.