# boar-tasks-client

> Boar Tasks for client side

Latest version **8.0.0** (published 2018-07-16) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install boar-tasks-client
pnpm add boar-tasks-client
yarn add boar-tasks-client
bun add boar-tasks-client
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 8.0.0 |
| Published | 2018-07-16 |
| First published | 2015-11-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 46 |
| Unpacked size | 43.6 KB |
| Known vulnerabilities | 0 (+13 in 4 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Emarsys |
| Maintainers | adambrunner, blacksonic, draven, emarsys-deployer, gszabo, joco, sviktor |

## Links

- npm: https://www.npmjs.com/package/boar-tasks-client
- Repository: https://github.com/emartech/boar-tasks-client
- Issues: https://github.com/emartech/boar-tasks-client/issues
- npm.io page: https://npm.io/package/boar-tasks-client

## Dependencies (46)

- [q](https://npm.io/package/q.md) 1.5.1
- [chai](https://npm.io/package/chai.md) 3.5.0
- [glob](https://npm.io/package/glob.md) 7.1.2
- [karma](https://npm.io/package/karma.md) 1.3.0
- [mocha](https://npm.io/package/mocha.md) 3.1.2
- [sinon](https://npm.io/package/sinon.md) 1.17.6
- [yargs](https://npm.io/package/yargs.md) 6.0.0
- [lodash](https://npm.io/package/lodash.md) 4.17.10
- [gulp-if](https://npm.io/package/gulp-if.md) 2.0.2
- [webpack](https://npm.io/package/webpack.md) 1.13.2
- [co-mocha](https://npm.io/package/co-mocha.md) 1.2.2
- [through2](https://npm.io/package/through2.md) 2.0.3
- [gulp-jade](https://npm.io/package/gulp-jade.md) 1.1.0
- [gulp-util](https://npm.io/package/gulp-util.md) 3.0.8
- [gulp-clone](https://npm.io/package/gulp-clone.md) 1.0.0
- [gulp-watch](https://npm.io/package/gulp-watch.md) 4.3.10
- [sinon-chai](https://npm.io/package/sinon-chai.md) 2.8.0
- [superagent](https://npm.io/package/superagent.md) 2.3.0
- [deep-extend](https://npm.io/package/deep-extend.md) 0.6.0
- [gulp-concat](https://npm.io/package/gulp-concat.md) 2.6.1
- [gulp-rename](https://npm.io/package/gulp-rename.md) 1.3.0
- [gulp-stylus](https://npm.io/package/gulp-stylus.md) 2.7.0
- [gulp-uglify](https://npm.io/package/gulp-uglify.md) 2.0.0
- [karma-mocha](https://npm.io/package/karma-mocha.md) 1.3.0
- [karma-sinon](https://npm.io/package/karma-sinon.md) 1.0.5
- [event-stream](https://npm.io/package/event-stream.md) 3.3.4
- [gulp-changed](https://npm.io/package/gulp-changed.md) 1.3.2
- [gulp-connect](https://npm.io/package/gulp-connect.md) 5.5.0
- [gulp-install](https://npm.io/package/gulp-install.md) 0.6.0
- [gulp-plumber](https://npm.io/package/gulp-plumber.md) 1.2.0
- [run-sequence](https://npm.io/package/run-sequence.md) 1.2.2
- [karma-webpack](https://npm.io/package/karma-webpack.md) 1.8.0
- [node-notifier](https://npm.io/package/node-notifier.md) 4.6.1
- [gulp-streamify](https://npm.io/package/gulp-streamify.md) 1.0.2
- [gulp-awspublish](https://npm.io/package/gulp-awspublish.md) 3.3.3
- [gulp-sourcemaps](https://npm.io/package/gulp-sourcemaps.md) 2.6.4
- [stylint-stylish](https://npm.io/package/stylint-stylish.md) 1.4.1
- [karma-sinon-chai](https://npm.io/package/karma-sinon-chai.md) 1.2.4
- [boar-tasks-common](https://npm.io/package/boar-tasks-common.md) 7.0.0
- [gulp-autoprefixer](https://npm.io/package/gulp-autoprefixer.md) 3.1.1
- [gulp-task-listing](https://npm.io/package/gulp-task-listing.md) 1.1.0
- [phantomjs-prebuilt](https://npm.io/package/phantomjs-prebuilt.md) 2.1.16
- [vinyl-source-stream](https://npm.io/package/vinyl-source-stream.md) 1.1.0
- [concurrent-transform](https://npm.io/package/concurrent-transform.md) 1.0.0
- [karma-phantomjs-launcher](https://npm.io/package/karma-phantomjs-launcher.md) 1.0.4
- [gulp-angular-templatecache](https://npm.io/package/gulp-angular-templatecache.md) 2.2.1

## Recent versions

- 8.0.0 (latest) — 2018-07-16
- 7.1.0 — 2017-07-09
- 7.0.0 — 2016-10-12
- 6.0.2 — 2016-07-27
- 6.0.1 — 2016-07-22
- 6.0.0 — 2016-07-13
- 5.0.0 — 2016-06-15
- 4.4.1 — 2016-06-08
- 4.4.0 — 2016-06-01
- 4.3.0 — 2016-04-20
- 4.2.1 — 2016-03-18
- 4.2.0 — 2016-03-17
- 4.1.0 — 2016-03-04
- 4.0.0 — 2016-03-02
- 3.1.1 — 2016-02-25
- … 11 more at https://npm.io/package/boar-tasks-client/versions

## README

# Boar Tasks for client side

[![npm version](https://badge.fury.io/js/boar-tasks-client.svg)](http://badge.fury.io/js/boar-tasks-client)
[![Dependency Status](https://david-dm.org/emartech/boar-tasks-client.svg)](https://david-dm.org/emartech/boar-tasks-client)
[![devDependency Status](https://david-dm.org/emartech/boar-tasks-client/dev-status.svg)](https://david-dm.org/emartech/boar-tasks-client#info=devDependencies)

This repository contains Gulp-based tasks to make client-side applications easier. It can be used with any client side framework which
 supports the CommonJS or AMD pattern.

These tasks are helpers, you have to define your build tasks in your project's `gulpfile.js`. You can find examples in our existing services or workshop material.

Usually we create a `tasks.config.js` file which is for override the default task settings.

### Sample config file

```javascript
// tasks.config.js

module.exports = {
  staticServer: {
    port: 8081
  },

  client: {
    app: {
      buildPattern: 'client/app/app.js',
      testPattern: 'client/app/**/*.spec.js'
    },
    stylesheets: {
      buildPattern: 'client/stylesheets/app.styl'
    }
  }
};
```

### Sample gulpfile

```javascript
// gulpfile.js

let gulp = require('gulp');
let runSequence = require('run-sequence');

let config = require('./tasks.config.js');
let tasks = require('boar-tasks-client').getTasks(gulp, config);

gulp.task('build', function(cb) {
  runSequence('build-clean', 'client-build', cb);
});

gulp.task('start', ['build'], function() {
  gulp.run('server');
  gulp.run('assets-watch');
  gulp.run('client-watch');
});

gulp.task('test', tasks.client.test);
gulp.task('code-style', ['client-jscs', 'check-tests', 'check-logs']);
gulp.task('build-clean', tasks.build.clean);
gulp.task('server', tasks.client.staticServer);
gulp.task('client-build', tasks.client.buildScripts);
gulp.task('client-watch', tasks.client.buildScriptsDenyErrors);
gulp.task('reload-static-server', tasks.client.reloadStaticServer);
gulp.task('assets-watch', function() {
  gulp.watch('dist/**/*', ['reload-static-server']);
});

```

## Available tasks

### Build tasks

#### Clean
It is used to remove files from the build target directory.

#### Deploy
Pushes the current codebase to the production branch. Usually it initiate a deploying process.

### Redirector tasks

#### Save
Saves the given revision to the Emarsys Redirector service - allowing to control user caches above Amazon S3 and Cloudfront.

*Default configuration*

```javascript
Config.redirector = {
  url: argv.redirectorUrl || process.env.REDIRECTOR_URL,
  name: argv.redirectorName || process.env.REDIRECTOR_NAME,
  target: argv.redirectorTarget || process.env.REDIRECTOR_TARGET,
  apiSecret: argv.redirectorApiSecret || process.env.REDIRECTOR_API_SECRET
};
```

*Usage*

```javascript
gulp.task('publish-redirector', tasks.redirector.save);

// Revision can be calculated before the task run
gulp.task('publish-redirector', function() { return tasks.redirector.save('myLatestRevision'); });
```

### S3 tasks

#### Publish
It gzip the current codebase and pushes to Amazon S3

*Default configuration*

```javascript
Config.s3 = {
  copyPattern: 'dist/**/*',
  bucket: argv.s3Bucket || process.env.S3_BUCKET,
  withGzip: true,
  headers: {
    'Cache-Control': 'max-age=315360000, no-transform, public',
    'x-amz-acl': 'bucket-owner-full-control'
  }
};
```

*Usage*

```javascript
gulp.task('publish-s3', tasks.s3.publish);
```

### Client tasks

#### Copy static
Copy static files into the `dist` folder.

*Default configuration*

```javascript
Config.client = {
  static: {
    copyPattern: 'client/static/**/*',
    target: Config.build.assetsPath
  }
}
```

*Usage*

```javascript
gulp.task('client-build-static', tasks.client.copyStatic);
```



#### Build stylesheets
Copying and pre-processing stylesheets using stylus.

*Default configuration*

```javascript
Config.client = {
  stylesheets: {
    buildPattern: 'client/stylesheets/*.styl',
    watchPattern: 'client/stylesheets/**/*',
    target: Config.build.assetsPath + 'stylesheets/',
    plugins: [],
    includeCSS: true,
    autoprefixer: {
      browsers: ['ie 9', 'ie 10', 'last 2 versions'],
      cascade: false
    }
  }
}
```

*Usage*

```javascript
gulp.task('client-build-stylesheets', tasks.client.buildStylesheets);
```



#### Build stylesheets with denying errors
It is the same as the `buildStylesheets` task but it is not exiting on stylesheet error. It is suggested to use for smooth development experience.

*Usage*

```javascript
gulp.task('client-build-stylesheets-continously', tasks.client.buildStylesheetsDenyErrors);
```



#### Build scripts
It is used to build JavaScript files. It uses Webpack and Babel to compile ES6 code to ES5. Finally it creates a single JavaScript file with all of required files.

*Default configuration*

```javascript
Config.client = {
  app: {
    path: 'client/app/',
    extensions: ['.js'],
    buildPattern: 'client/app/!(*.spec).js',
    testPattern: 'client/app/**/*.spec.js',
    testModules: [],
    watchPattern: 'client/app/**/*',
    viewPattern: 'client/app/views/**/*.jade',
    vendorPattern: 'client/vendors.js',
    target: Config.build.assetsPath + 'scripts/',
    vendors: [],
    codeStylePattern: 'client/app/**/*.js',
    loaders: [
      { test: /\.js$/, loader: 'babel', exclude: /(node_modules)/ },
      { test: /\.jade$/, loader: 'jade-loader?self' },
      { test: /\.json$/, loader: 'json-loader' }
    ]
  }
}
```

*Usage*

```javascript
gulp.task('client-build-scripts', tasks.client.buildScripts);
```



#### Build scripts with denying errors
It is the same as the `buildScripts` task but it is not exiting on script compilation error. It is suggested to use for smooth development experience.

*Usage*

```javascript
gulp.task('client-build-scripts-continously', tasks.client.buildScriptsDenyErrors);
```



#### Concatenate vendors
It concatenates all of the listed vendor files and create a `vendors.js` on the `client.app.target` path from the configuration.

*Default configuration*

```javascript
Config.client = {
  app: {
    target: Config.build.assetsPath + 'scripts/',
  }
  vendors: []
}
```

*Usage*

```javascript
gulp.task('client-concat-vendors', tasks.client.concatVendors);
```



#### Building an app with multiple entry points

If you have an app with multiple entry points, you can configure `buildPattern` as an array of strings.

```javascript
Config.client = {
  app: {
    buildPattern: [
      'client/app/!(*.spec).js',
      'other/dir/!(*.spec).js'
    ]
  }
};
```

If you have entry points used somewhere else where `vendors.js` is not available - eg. a web worker -, you can configure `buildPattern` to build those entry points with the webpack module loading logic included.

```javascript
Config.client = {
  app: {
    buildPattern: [
      'client/app/!(*.spec).js',
      {
        pattern: 'client/workers/!(*.spec).js',
        splitVendor: false
      }
    ]
  }
};
```




#### Test
Run all the tests found in the codebase using Karma.

*Default configuration*

```javascript
Config.client = {
  testConfigPath: process.cwd() + '/karma.conf.js'
}
```

*Usage*

```javascript
gulp.task('client-test', tasks.client.test);
```



#### Code style
Check code style using ESLint on the selected JavaScript files.

*Default configuration*

```javascript
Config.client = {
  app: {
    codeStylePattern: 'client/app/**/*.js'
  }
}
```

*Usage*

```javascript
gulp.task('client-codestyle', tasks.client.codeStyle);
```



#### Stylesheets code style
Check code style on the selected stylesheets using Stylint.

*Default configuration*

```javascript
Config.client = {
  stylesheets: {
    codeStyle: {
      pattern: 'client/stylesheets/**/*.styl',
      config: {
        rules: {
          depthLimit: 3,
          efficient: false,
          indentPref: 2,
          namingConvention: 'lowercase-dash',
          noImportant: true,
          quotePref: 'double',
          sortOrder: 'alphabetical',
          valid: false
        }
      }
    }
  }
}
```

*Usage*

```javascript
gulp.task('client-stylesheet-codestyle', tasks.client.stylesheetCodeStyle);
```



#### Template code style
Check code style on the selected template files using pug-lint.

*Default configuration*

```javascript
Config.client = {
  app: {
    templateCodeStylePattern: 'client/app/**/*.jade'
  }
}
```

*Code style rules*

Install `pug-lint-config-emarsys` to your project and create a file in your project's root called `.pug-lintrc` with the following content:

```
{
  "extends": "emarsys"
}
```

*Usage*

```javascript
gulp.task('client-template-code-style', tasks.client.templateCodeStyle);
```



#### Security checks
Check package.json's dependencies section against known vulnerable libraries. This will only generate warnings on the console.

*Usage*

```javascript
gulp.task('nsp', function(cb) { tasks.client.nsp(__dirname + '/package.json', cb) });
```



#### Dummy server to provide assets
It is for development purposes - serving static asset files.

*Default configuration*

```javascript
Config.staticServer = {
  port: process.env.PORT || 8080
};
```

*Usage*

```javascript
gulp.task('client-static-server', tasks.client.staticServer);

// It can be reloaded with reloadStaticServer
gulp.task('reload-static-server', tasks.client.reloadStaticServer);
```

---
_Source: https://npm.io/package/boar-tasks-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
