1 | module.exports = function (grunt) {
|
2 | grunt.initConfig({
|
3 | pkg: grunt.file.readJSON('package.json'),
|
4 | pkgFile: 'package.json',
|
5 | files: {
|
6 | server: ['lib/**/*.js'],
|
7 | client: ['client/**/*.js'],
|
8 | common: ['common/**/*.js'],
|
9 | context: ['context/**/*.js'],
|
10 | grunt: ['grunt.js', 'tasks/*.js'],
|
11 | scripts: ['scripts/init-dev-env.js']
|
12 | },
|
13 | browserify: {
|
14 | client: {
|
15 | files: {
|
16 | 'static/karma.js': ['client/main.js'],
|
17 | 'static/context.js': ['context/main.js']
|
18 | }
|
19 | }
|
20 | },
|
21 | test: {
|
22 | unit: 'mochaTest:unit',
|
23 | client: 'test/client/karma.conf.js',
|
24 | e2e: 'cucumberjs:ci'
|
25 | },
|
26 | watch: {
|
27 | client: {
|
28 | files: '<%= files.client %>',
|
29 | tasks: 'browserify:client'
|
30 | }
|
31 | },
|
32 | mochaTest: {
|
33 | options: {
|
34 | reporter: 'dot',
|
35 | ui: 'bdd',
|
36 | quiet: false,
|
37 | colors: true
|
38 | },
|
39 | unit: {
|
40 | src: [
|
41 | 'test/unit/mocha-globals.js',
|
42 | 'test/unit/**/*.spec.js'
|
43 | ]
|
44 | }
|
45 | },
|
46 | cucumberjs: {
|
47 | options: {
|
48 | steps: 'test/e2e/step_definitions',
|
49 | format: 'progress',
|
50 | require: ['test/e2e/support/env.js', 'test/e2e/support/world.js']
|
51 | },
|
52 | all: 'test/e2e/*.feature',
|
53 | current: {
|
54 | files: {
|
55 | src: 'test/e2e/*.feature'
|
56 | },
|
57 | options: {
|
58 | tags: '@current'
|
59 | }
|
60 | },
|
61 | ci: {
|
62 | files: {
|
63 | src: 'test/e2e/*.feature'
|
64 | },
|
65 | options: {
|
66 | tags: 'not @not-jenkins'
|
67 | }
|
68 | }
|
69 | },
|
70 | eslint: {
|
71 | options: {
|
72 | quiet: true
|
73 | },
|
74 | target: [
|
75 | '<%= files.server %>',
|
76 | '<%= files.grunt %>',
|
77 | '<%= files.scripts %>',
|
78 | '<%= files.client %>',
|
79 | '<%= files.common %>',
|
80 | '<%= files.context %>',
|
81 | 'static/debug.js',
|
82 | 'test/**/*.js',
|
83 | 'gruntfile.js'
|
84 | ]
|
85 | },
|
86 | 'npm-publish': {
|
87 | options: {
|
88 | requires: ['build'],
|
89 | abortIfDirty: true,
|
90 | tag: 'latest'
|
91 | }
|
92 | },
|
93 | 'npm-contributors': {
|
94 | options: {
|
95 | commitMessage: 'chore: update contributors'
|
96 | }
|
97 | },
|
98 | conventionalChangelog: {
|
99 | release: {
|
100 | options: {
|
101 | changelogOpts: {
|
102 | preset: 'angular'
|
103 | }
|
104 | },
|
105 | src: 'CHANGELOG.md'
|
106 | }
|
107 | },
|
108 | conventionalGithubReleaser: {
|
109 | release: {
|
110 | options: {
|
111 | auth: {
|
112 | type: 'oauth',
|
113 | token: process.env.GH_TOKEN
|
114 | },
|
115 | changelogOpts: {
|
116 | preset: 'angular'
|
117 | }
|
118 | }
|
119 | }
|
120 | },
|
121 | bump: {
|
122 | options: {
|
123 | updateConfigs: ['pkg'],
|
124 | commitFiles: [
|
125 | 'package.json',
|
126 | 'CHANGELOG.md'
|
127 | ],
|
128 | commitMessage: 'chore: release v%VERSION%',
|
129 | prereleaseName: 'rc'
|
130 | }
|
131 | }
|
132 | })
|
133 |
|
134 | grunt.loadNpmTasks('grunt-check-clean')
|
135 | grunt.loadTasks('tasks')
|
136 | require('load-grunt-tasks')(grunt)
|
137 |
|
138 | grunt.registerTask('lint', ['eslint'])
|
139 | grunt.registerTask('build', ['browserify:client'])
|
140 | grunt.registerTask('default', ['build', 'lint', 'test'])
|
141 | grunt.registerTask('test-appveyor', ['test:unit', 'test:client'])
|
142 |
|
143 | grunt.registerTask('release', 'Build, bump and publish to NPM.', function (type) {
|
144 | grunt.task.run([
|
145 | 'check_clean',
|
146 | 'npm-contributors',
|
147 | 'bump:' + (type || 'patch') + ':bump-only',
|
148 | 'build',
|
149 | 'conventionalChangelog',
|
150 | 'bump-commit',
|
151 | 'conventionalGithubReleaser',
|
152 | 'npm-publish'
|
153 | ])
|
154 | })
|
155 | }
|