Giter Club home page Giter Club logo

tourism's Introduction

tourism

tourism is a convenience wrapper for Grunt.

Installation

$ npm install tourism

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.

Quick Start

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.

'use strict';

var tourism = require('tourism');

module.exports = tourism({
  analyse: {
    server: [ '**/*.js', '!node_modules/**/*.js' ]
  },
  test: {
    server: [ 'test/**/*.js' ]
  }
});

Using the default task

To use tourism with the default tasks, run the following command.

$ grunt

The default task will run the static code analysis, validate whitespace, execute unit tests and check for outdated packages.

Changing the language version for code analysis

By 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).

module.exports = tourism({
  analyse: {
    server: [ '**/*.js', '!node_modules/**/*.js' ],
    options: {
      server: {
        language: 'es5'
      }
    }
  }
});

Calculating test coverage

To calculate the test coverage run the following command.

$ grunt report

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.

$ grunt coverage

Then, you need to open the file index.html from the directory coverage manually.

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.

Verifying licenses

If you want to verify that the licenses of your dependencies are compatible to your requirements, add the list of allowed licenses to your configuration.

module.exports = tourism({
  licenses: [ 'MIT', 'BSD' ]
});

Running the default task partially

If you only want to run the default task partially, there are a number of commands you may use:

$ grunt analyse
$ grunt test
$ grunt outdated
$ grunt licenses

Using watch mode

To use the watch mode, run the following command.

$ grunt watch

Creating a release

To create a new release, run the following command.

$ grunt publish

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.

If you want to create a minor respectively a major release, run one of the following commands instead.

$ grunt publish:minor
$ grunt publish:major

If, for whatever reason, you need to skip code analysis and test execution before publishing, use grunt release instead of grunt publish.

Using shell tasks

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.

module.exports = tourism({
  // ...
  shell: {
    start: 'echo "Hello world!"'
  }
});

If you need to run a parametrized shell task, provide a function instead of a string.

module.exports = tourism({
  // ...
  shell: {
    start: function (message) {
      return 'echo "' + message + '"';
    }
  }
});

Using built-in shell commands

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.

$ grunt start

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.

$ grunt update
$ grunt update:lodash

Additionally, there are two commands that get registered depending on whether other commands have been registered.

  • If you register a start and a stop command, but no restart command, stop && start is registered.
  • If you register a build and a clean command, but no rebuild command, clean && build is registered.

Running the build

This module can be built using Grunt. 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 installed.

$ grunt

License

The MIT License (MIT) Copyright (c) 2014-2015 the native web.

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.

tourism's People

Contributors

goloroden avatar

Stargazers

Cat  avatar  avatar Che-Wei Lin avatar  avatar Michael Scherer avatar Stefan Scherer avatar

Watchers

Stefan Scherer avatar James Cloos avatar  avatar Susanna Roden avatar Markus Turber avatar  avatar

Forkers

the-cc-dev

tourism's Issues

Provide a way to let users add individual Grunt configuration

At the moment, tourism follows an all-or-nothing-approach.

It would be great if users could use tourism as base, but extend the configuration with classical Grunt configuration to be able to extend tourism for their own needs without the need to adjust tourism itself.

problem with grunt license

Thanks for adding license check. I use the following Gruntfile.js:

'use strict';

var tourism = require('tourism');

module.exports = tourism({
  analyse: {
    server: [ '**/*.js', '!node_modules/**/*.js', '!coverage/**' ],
    options: {
      server: {
        language: 'es5'
      }
    }
  },
  licenses: [ 'MIT', 'BSD' ],
  test: {
    server: [ 'test/**/*.js' ]
  }
});

But after calling grunt a lot of error messages are shown:

$ grunt
Running "eslint:server" (eslint) task


Running "mochacli:all" (mochacli) task


  0 passing (2ms)


Running "depcheck:files" (depcheck) task

Running "devUpdate:main" (devUpdate) task
Found 2 devDependencies to check for latest version
Found 2 dependencies to check for latest version
>> All packages are up to date

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?
...
Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?

Running "licensechecker" task
>> Local Npm module "grunt-license" not found. Is it installed?
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
...
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.

util.js:35
  var str = String(f).replace(formatRegExp, function(x) {
                      ^
RangeError: Maximum call stack size exceeded

Do you have any hints?

Add reinstall option

Two steps:

$ rm -rf node_modules
$ npm install

Additionally, check whether this can be integrated with git pull

Should start task automatically run build task as well?

Pro

Most probably, you need to run a build when starting the application. Also this would mean that a restart involves a new build.

Con

The build step may be quite complex, e.g. when building images or things like that. May slow down development time.

Should we introduce the --async-only switch for Mocha?

Pro

If we introduced --async-only it would no longer be possible to forget done on asynchronous tests (which increases test quality and avoids not-working, but green tests).

Con

If we introduce this parameter all existing tests of a project must be migrated to the asynchronous version once tourism is being updated.

Add a clean and a rebuild task

The clean task should be a shell task such as start and stop.

The rebuild task is an automatic task such as restart that first runs clean, then build.

Support multiple platforms in shell commands

Sometimes, shell commands require different syntaxes, depending on the underlying OS. Somehow, this should be supported by tourism.

An idea might be the following snippet:

{
  shell: {
    clean: {
      osx: 'rm -rf node_modules',
      win32: 'deltree node_modules'
    }
  }
}

Instead of the more simple:

{
  shell: {
    clean: 'rm -rf node_modules'
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.