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