UNPKG

3.15 kBJavaScriptView Raw
1module.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 grunt: ['grunt.js', 'tasks/*.js'],
9 scripts: ['scripts/init-dev-env.js']
10 },
11 browserify: {
12 client: {
13 files: {
14 'static/karma.js': ['client/main.js']
15 }
16 }
17 },
18 test: {
19 unit: 'mochaTest:unit',
20 client: 'test/client/karma.conf.js',
21 e2e: 'cucumberjs:ci'
22 },
23 watch: {
24 client: {
25 files: '<%= files.client %>',
26 tasks: 'browserify:client'
27 }
28 },
29 mochaTest: {
30 options: {
31 require: [
32 'babel/register'
33 ],
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/steps',
49 format: 'progress'
50 },
51 all: 'test/e2e/*.feature',
52 current: {
53 files: {
54 src: 'test/e2e/*.feature'
55 },
56 options: {
57 tags: '@current'
58 }
59 },
60 ci: {
61 files: {
62 src: 'test/e2e/*.feature'
63 },
64 options: {
65 tags: '~@not-jenkins'
66 }
67 }
68 },
69 eslint: {
70 options: {
71 quiet: true
72 },
73 target: [
74 '<%= files.server %>',
75 '<%= files.grunt %>',
76 '<%= files.scripts %>',
77 '<%= files.client %>',
78 'test/**/*.js',
79 'gruntfile.js'
80 ]
81 },
82 'npm-publish': {
83 options: {
84 requires: ['build'],
85 abortIfDirty: true,
86 tag: 'latest'
87 }
88 },
89 'npm-contributors': {
90 options: {
91 commitMessage: 'chore: update contributors'
92 }
93 },
94 conventionalChangelog: {
95 release: {
96 options: {
97 changelogOpts: {
98 preset: 'angular'
99 }
100 },
101 src: 'CHANGELOG.md'
102 }
103 },
104 conventionalGithubReleaser: {
105 release: {
106 options: {
107 auth: {
108 type: 'oauth',
109 token: process.env.GH_TOKEN
110 },
111 changelogOpts: {
112 preset: 'angular'
113 }
114 }
115 }
116 },
117 bump: {
118 options: {
119 updateConfigs: ['pkg'],
120 commitFiles: [
121 'package.json',
122 'CHANGELOG.md'
123 ],
124 commitMessage: 'chore: release v%VERSION%',
125 prereleaseName: 'rc'
126 }
127 }
128 })
129
130 grunt.loadTasks('tasks')
131 require('load-grunt-tasks')(grunt)
132
133 grunt.registerTask('build', ['browserify:client'])
134 grunt.registerTask('default', ['build', 'test', 'lint'])
135 grunt.registerTask('lint', ['eslint'])
136
137 grunt.registerTask('release', 'Build, bump and publish to NPM.', function (type) {
138 grunt.task.run([
139 'npm-contributors',
140 'bump:' + (type || 'patch') + ':bump-only',
141 'build',
142 'conventionalChangelog',
143 'bump-commit',
144 'conventionalGithubReleaser',
145 'npm-publish'
146 ])
147 })
148}