UNPKG

5.8 kBMarkdownView Raw
1# tourism
2
3tourism is a convenience wrapper for Grunt.
4
5## Installation
6
7 $ npm install tourism
8
9*NOTE: You only need to add tourism and `grunt` itself as dependencies to the `package.json` file. You do not have to add any plugins, tourism contains everything it needs to run internally.*
10
11## Quick Start
12
13First you need to create a file called `Gruntfile.js`. Then, instead of the usual content, use the following lines of code to enable code analysis and execution of unit tests.
14
15```javascript
16'use strict';
17
18var tourism = require('tourism');
19
20module.exports = tourism({
21 analyse: {
22 server: [ '**/*.js', '!node_modules/**/*.js' ]
23 },
24 test: {
25 server: [ 'test/**/*.js' ]
26 }
27});
28```
29
30### Using the default task
31
32To use tourism with the default tasks, run the following command.
33
34 $ grunt
35
36The `default` task will run the static code analysis, validate whitespace, execute unit tests and check for outdated packages.
37
38### Changing the language version for code analysis
39
40By default, code analysis uses rules that target the latest version of EcmaScript. If you want to change this, you can provide an additional `options` object and change the language version. Currently supported values are `es5`, `es6`, `es2015` (which is equivalent to `es6`) and `latest` (which is the default).
41
42```javascript
43module.exports = tourism({
44 analyse: {
45 server: [ '**/*.js', '!node_modules/**/*.js' ],
46 options: {
47 server: {
48 language: 'es5'
49 }
50 }
51 }
52});
53```
54
55### Calculating test coverage
56
57To calculate the test coverage run the following command.
58
59 $ grunt report
60
61The command stores the results in the `coverage` directory. Additionally, it opens a graphical overview within your web browser. If you only want to calculate the results without actually showing them, run the following command alternatively.
62
63 $ grunt coverage
64
65Then, you need to open the file `index.html` from the directory `coverage` manually.
66
67Additionally, tourism adds the file `cobertura-coverage.xml` to the `coverage` directory, so that you are able to integrate calculating the test coverage into your automated build.
68
69### Running the default task partially
70
71If you only want to run the default task partially, there are a number of commands you may use:
72
73 $ grunt analyse
74 $ grunt test
75 $ grunt outdated
76
77### Using watch mode
78
79To use the watch mode, run the following command.
80
81 $ grunt watch
82
83### Creating a release
84
85To create a new release, run the following command.
86
87 $ grunt publish
88
89This will upgrade the version number in the `package.json` file, create a Git tag, create a `.zip` file containing the release, commit and finally push everything to the appropriate GitHub repository.
90
91If you want to create a minor respectively a major release, run one of the following commands instead.
92
93 $ grunt publish:minor
94 $ grunt publish:major
95
96If, for whatever reason, you need to skip code analysis and test execution before publishing, use `grunt release` instead of `grunt publish`.
97
98### Using shell tasks
99
100Additionally to the previous tasks most often you need a number of shell commands, e.g. to start an application or to install dependencies. For that you can register named commands using the `shell` object.
101
102```javascript
103module.exports = tourism({
104 // ...
105 shell: {
106 start: 'echo "Hello world!"'
107 }
108});
109```
110
111If you need to run a parametrized shell task, provide a function instead of a string.
112
113```javascript
114module.exports = tourism({
115 // ...
116 shell: {
117 start: function (message) {
118 return 'echo "' + message + '"';
119 }
120 }
121});
122```
123
124#### Using built-in shell commands
125
126Unless you overwrite them by your own version, tourism comes with a number of built-in shell commands. To start your Node.js application using `node app.js` run the following command.
127
128 $ grunt start
129
130To update your dependencies you can use the `update` task. If you do not specify a module to update, all modules will be updated. Otherwise, only the specified one will be updated.
131
132 $ grunt update
133 $ grunt update:lodash
134
135Additionally, there are two commands that get registered depending on whether other commands have been registered.
136
137- If you register a `start` and a `stop` command, but no `restart` command, `stop && start` is registered.
138- If you register a `build` and a `clean` command, but no `rebuild` command, `clean && build` is registered.
139
140## Running the build
141
142This module can be built using [Grunt](http://gruntjs.com/). Besides running the tests, this also analyses the code. To run Grunt, go to the folder where you have installed tourism and run `grunt`. You need to have [grunt-cli](https://github.com/gruntjs/grunt-cli) installed.
143
144 $ grunt
145
146## License
147
148The MIT License (MIT)
149Copyright (c) 2014 the native web.
150
151Permission 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:
152
153The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
154
155THE 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.