UNPKG

5.86 kBJavaScriptView Raw
1module.exports = function (grunt) {
2 'use strict';
3
4 // check task runtime
5 require('time-grunt')(grunt);
6
7 // load generic configs
8 var configs = require('dalek-build-tools');
9
10 // project config
11 grunt.initConfig({
12
13 // load module meta data
14 pkg: grunt.file.readJSON('package.json'),
15
16 // define a src set of files for other tasks
17 src: {
18 lint: ['Gruntfile.js', 'index.js', 'lib/**/*.js', 'test/*.js'],
19 complexity: ['index.js', 'lib/*.js', 'lib/comands/*.js'],
20 test: ['test/*.js'],
21 src: ['index.js', 'lib/**/*.js']
22 },
23
24 // clean automatically generated helper files & docs
25 clean: configs.clean,
26
27 // speed up build by defining concurrent tasks
28 concurrent: configs.concurrent,
29
30 // linting
31 jshint: configs.jshint,
32
33 // testing
34 mochaTest: configs.mocha,
35
36 // code metrics
37 complexity: configs.complexity,
38 plato: configs.plato(grunt.file.readJSON('.jshintrc')),
39
40 // api docs
41 yuidoc: configs.yuidocs(),
42
43 // user docs
44 documantix: {
45 options: {
46 header: 'dalekjs/dalekjs.com/master/assets/header.html',
47 footer: 'dalekjs/dalekjs.com/master/assets/footer.html',
48 target: 'report/docs',
49 vars: {
50 title: 'DalekJS - Documentation - Webdriver',
51 desc: 'DalekJS - Documentation - Webdriver',
52 docs: true
53 }
54 },
55 src: ['index.js']
56 },
57
58 // add current timestamp to the html document
59 includereplace: {
60 dist: {
61 options: {
62 globals: {
63 timestamp: '<%= grunt.template.today("dddd, mmmm dS, yyyy, h:MM:ss TT") %>'
64 },
65 },
66 src: 'report/docs/*.html',
67 dest: './'
68 }
69 },
70
71 // up version, tag & commit
72 bump: configs.bump({
73 pushTo: 'git@github.com:dalekjs/dalek-internal-webdriver.git',
74 files: ['package.json', 'CONTRIBUTORS.md', 'CHANGELOG.md']
75 }),
76
77 // generate contributors file
78 contributors: configs.contributors,
79
80 // compress artifacts
81 compress: configs.compress,
82
83 // prepare files for grunt-plato to
84 // avoid error messages (weird issue...)
85 preparePlato: {
86 options: {
87 folders: [
88 'coverage',
89 'report',
90 'report/coverage',
91 'report/complexity',
92 'report/complexity/files',
93 'report/complexity/files/index_js',
94 'report/complexity/files/lib_driver_js',
95 'report/complexity/files/lib_webdriver_js',
96 'report/complexity/files/lib_commands_cookie_js',
97 'report/complexity/files/lib_commands_element_js',
98 'report/complexity/files/lib_commands_execute_js',
99 'report/complexity/files/lib_commands_frame_js',
100 'report/complexity/files/lib_commands_ime_js',
101 'report/complexity/files/lib_commands_interaction_js',
102 'report/complexity/files/lib_commands_page_js',
103 'report/complexity/files/lib_commands_screenshot_js',
104 'report/complexity/files/lib_commands_session_js',
105 'report/complexity/files/lib_commands_storage_js',
106 'report/complexity/files/lib_commands_timeout_js',
107 'report/complexity/files/lib_commands_url_js',
108 'report/complexity/files/lib_commands_window_js'
109 ],
110 files: [
111 'report.history.json',
112 'files/index_js/report.history.json',
113 'files/lib_driver_js/report.history.json',
114 'files/lib_webdriver_js/report.history.json',
115 'files/lib_commands_cookie_js/report.history.json',
116 'files/lib_commands_element_js/report.history.json',
117 'files/lib_commands_execute_js/report.history.json',
118 'files/lib_commands_frame_js/report.history.json',
119 'files/lib_commands_ime_js/report.history.json',
120 'files/lib_commands_interaction_js/report.history.json',
121 'files/lib_commands_page_js/report.history.json',
122 'files/lib_commands_screenshot_js/report.history.json',
123 'files/lib_commands_session_js/report.history.json',
124 'files/lib_commands_storage_js/report.history.json',
125 'files/lib_commands_timeout_js/report.history.json',
126 'files/lib_commands_url_js/report.history.json',
127 'files/lib_commands_window_js/report.history.json'
128 ]
129 }
130 },
131
132 // prepare files & folders for coverage
133 prepareCoverage: {
134 options: {
135 folders: ['coverage', 'report', 'report/coverage'],
136 pattern: '[require("fs").realpathSync(__dirname + "/../index.js"), require("fs").realpathSync(__dirname + "/../lib/")]'
137 }
138 },
139
140 // list requires that need to be changed
141 // for generating a canary build
142 'release-canary': {
143 options: {
144 files: ['index.js']
145 }
146 },
147
148 // archives the docs if a new version appears
149 archive: {
150 options: {
151 file: 'webdriver.html'
152 }
153 }
154
155 });
156
157 // load 3rd party tasks
158 require('load-grunt-tasks')(grunt);
159 grunt.loadTasks('./node_modules/dalek-build-tools/tasks');
160
161 // define runner tasks
162 grunt.registerTask('lint', 'jshint');
163
164 // split test & docs for speed
165 grunt.registerTask('test', ['clean:coverage', 'prepareCoverage', 'concurrent:test', 'generateCoverageBadge']);
166 grunt.registerTask('docs', ['clean:reportZip', 'clean:report', 'preparePlato', 'documantix', 'includereplace', 'concurrent:docs', 'compress']);
167
168 // release tasks
169 grunt.registerTask('releasePatch', ['test', 'bump-only:patch', 'contributors', 'changelog', 'bump-commit']);
170 grunt.registerTask('releaseMinor', ['test', 'bump-only:minor', 'contributors', 'changelog', 'bump-commit']);
171 grunt.registerTask('releaseMajor', ['test', 'bump-only:major', 'contributors', 'changelog', 'bump-commit']);
172
173 // clean, test, generate docs (the CI task)
174 grunt.registerTask('all', ['clean', 'test', 'docs']);
175
176};
\No newline at end of file