/
Gruntfile.js
144 lines (142 loc) · 5.31 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat_in_order: {
your_target: {
options: {
banner: '/*!\n<%= pkg.name %>\nVersion: <%= pkg.version %>\n<%= pkg.homepage %>\nGIT: <%= pkg.repository %>/commit/<%= meta.revision %>\nLicense: <%= pkg.license %>\n<%= grunt.template.today("UTC:dddd, mmmm dS, yyyy, h:MM:ss TT Z", true) %>\n*/\n',
extractRequired: function(filepath, filecontent) {
var augments = this.getMatches(/@augments[\s]+([^\s]+)/g, filecontent);
var requires = this.getMatches(/@requires[\s]+([^\s]+)/g, filecontent);
return augments.concat(requires);
},
extractDeclared: function(filepath, filecontent) {
return this.getMatches(/@class[\s]+([^\s]+)/g, filecontent);
},
exportConcatenationOrder: 'concatOrder'
},
files: {
'thefragebogen.js': ['build/*.js']
}
}
},
jsdoc: {
dist: {
src: ['src/*.js'],
options: {
destination: 'doc'
}
}
},
includereplace: {
dist: {
options: {
globals: {},
},
files: [{
src: '*.js',
dest: 'build/',
expand: true,
cwd: 'src/'
}, ]
}
},
jsbeautifier: {
files: ['src/*.js', 'examples/*', 'examples_feasibility/*/src/*.js', 'examples_feasibility/*/*.html', 'tests/*', 'Gruntfile.js', 'package.json'],
options: {
js: {
indent_size: 4,
preserve_newlines: true,
wrap_line_length: 0,
end_with_newline: true
},
css: {
indent_size: 4,
preserve_newlines: false,
max_preserve_newlines: 2,
end_with_newline: true
},
html: {
indent_size: 4,
preserve_newlines: true,
max_preserve_newlines: 2,
end_with_newline: true,
indent_inner_html: true,
indent_scripts: "keep",
extra_liners: ["head", "body", "/html", "script", "style"]
}
}
},
jshint: {
all: ['src/*.js', 'examples/*.js', 'examples-feasibility/*/src/*.js', 'tests/*.js', 'Gruntfile.js', 'package.json'],
options: {
esversion: 6
}
},
qunit: {
dev: ['tests/qunit.html'],
es5: ['tests/qunit_es5.html'],
options: {
puppeteer: {
headless: true,
//Disable Chrome's security features to be executed on (older) Linux; needed for TravisCI
args: ['--no-sandbox', '--disable-setuid-sandbox']
}
}
},
revision: {
options: {
property: 'meta.revision',
ref: 'HEAD',
short: false
}
},
run: {
jsdoc: {
exec: 'jsdoc --private -d doc thefragebogen.js'
},
help: {
exec: 'grunt --help'
}
},
babel: {
options: {
sourceMap: true,
presets: ['@babel/preset-env']
},
dist: {
files: {
'dist/thefragebogen.es5.js': 'thefragebogen.js'
}
}
},
uglify: {
options: {
banner: '/*!\n<%= pkg.name %>\nVersion: <%= pkg.version %>\n<%= pkg.homepage %>\nGIT: <%= pkg.repository %>/commit/<%= meta.revision %>\nLicense: <%= pkg.license %>\n<%= grunt.template.today("UTC:dddd, mmmm dS, yyyy, h:MM:ss TT Z", true) %>\n*/\n',
},
dist: {
files: {
'dist/thefragebogen.es5-min.js': ['dist/thefragebogen.es5.js'] //'<%= concat_in_order.dist.dest %>'
}
}
}
});
grunt.loadNpmTasks('grunt-concat-in-order');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks('grunt-git-revision');
grunt.loadNpmTasks('grunt-include-replace');
grunt.loadNpmTasks("grunt-jsbeautifier");
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-run');
require("load-grunt-tasks")(grunt);
//Task(s)
grunt.registerTask('default', ['includereplace', 'revision', 'concat_in_order']);
grunt.registerTask('doc', ['jsdoc']);
grunt.registerTask('dist', ['default', 'babel', 'uglify', 'doc', 'qunit:es5']);
grunt.registerTask('format', ['jsbeautifier']);
grunt.registerTask('help', ['run:help']);
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('test', ['default', 'qunit:dev']);
};