UNPKG

5.07 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### Calculating test coverage
39
40To calculate the test coverage run the following command.
41
42 $ grunt report
43
44The 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.
45
46 $ grunt coverage
47
48Then, you need to open the file `index.html` from the directory `coverage` manually.
49
50### Running the default task partially
51
52If you only want to run the default task partially, there are a number of commands you may use:
53
54 $ grunt analyse
55 $ grunt test
56 $ grunt outdated
57
58### Using watch mode
59
60To use the watch mode, run the following command.
61
62 $ grunt watch
63
64### Creating a release
65
66To create a new release, run the following command.
67
68 $ grunt publish
69
70This 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.
71
72If you want to create a minor respectively a major release, run one of the following commands instead.
73
74 $ grunt publish:minor
75 $ grunt publish:major
76
77If, for whatever reason, you need to skip code analysis and test execution before publishing, use `grunt release` instead of `grunt publish`.
78
79### Using shell tasks
80
81Additionally 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.
82
83```javascript
84module.exports = tourism({
85 // ...
86 shell: {
87 start: 'echo "Hello world!"'
88 }
89});
90```
91
92If you need to run a parametrized shell task, provide a function instead of a string.
93
94```javascript
95module.exports = tourism({
96 // ...
97 shell: {
98 start: function (message) {
99 return 'echo "' + message + '"';
100 }
101 }
102});
103```
104
105#### Using built-in shell commands
106
107Unless 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.
108
109 $ grunt start
110
111To 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.
112
113 $ grunt update
114 $ grunt update:lodash
115
116Additionally, there are two commands that get registered depending on whether other commands have been registered.
117
118- If you register a `start` and a `stop` command, but no `restart` command, `stop && start` is registered.
119- If you register a `build` and a `clean` command, but no `rebuild` command, `clean && build` is registered.
120
121## Running the build
122
123This 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.
124
125 $ grunt
126
127## License
128
129The MIT License (MIT)
130Copyright (c) 2014 the native web.
131
132Permission 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:
133
134The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
135
136THE 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.