UNPKG

6.09 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### Verifying licenses
70
71If you want to verify that the licenses of your dependencies are compatible to your requirements, add the list of allowed licenses to your configuration.
72
73```javascript
74module.exports = tourism({
75 licenses: [ 'MIT', 'BSD' ]
76});
77```
78
79### Running the default task partially
80
81If you only want to run the default task partially, there are a number of commands you may use:
82
83 $ grunt analyse
84 $ grunt test
85 $ grunt outdated
86 $ grunt licenses
87
88### Using watch mode
89
90To use the watch mode, run the following command.
91
92 $ grunt watch
93
94### Creating a release
95
96To create a new release, run the following command.
97
98 $ grunt publish
99
100This 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.
101
102If you want to create a minor respectively a major release, run one of the following commands instead.
103
104 $ grunt publish:minor
105 $ grunt publish:major
106
107If, for whatever reason, you need to skip code analysis and test execution before publishing, use `grunt release` instead of `grunt publish`.
108
109### Using shell tasks
110
111Additionally 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.
112
113```javascript
114module.exports = tourism({
115 // ...
116 shell: {
117 start: 'echo "Hello world!"'
118 }
119});
120```
121
122If you need to run a parametrized shell task, provide a function instead of a string.
123
124```javascript
125module.exports = tourism({
126 // ...
127 shell: {
128 start: function (message) {
129 return 'echo "' + message + '"';
130 }
131 }
132});
133```
134
135#### Using built-in shell commands
136
137Unless 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.
138
139 $ grunt start
140
141To 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.
142
143 $ grunt update
144 $ grunt update:lodash
145
146Additionally, there are two commands that get registered depending on whether other commands have been registered.
147
148- If you register a `start` and a `stop` command, but no `restart` command, `stop && start` is registered.
149- If you register a `build` and a `clean` command, but no `rebuild` command, `clean && build` is registered.
150
151## Running the build
152
153This 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.
154
155 $ grunt
156
157## License
158
159The MIT License (MIT)
160Copyright (c) 2014-2015 the native web.
161
162Permission 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:
163
164The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
165
166THE 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.