brantje /
nextnote
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | module.exports = function (grunt) { |
||
| 2 | var jsResources = []; |
||
| 3 | // Project configuration. |
||
| 4 | grunt.initConfig({ |
||
| 5 | jsResources: [], |
||
| 6 | cssResources: [], |
||
| 7 | pkg: grunt.file.readJSON('package.json'), |
||
| 8 | html2js: { |
||
| 9 | options: { |
||
| 10 | // custom options, see below |
||
| 11 | base: 'templates', |
||
| 12 | quoteChar: '\'', |
||
| 13 | useStrict: true, |
||
| 14 | htmlmin: { |
||
| 15 | collapseBooleanAttributes: false, |
||
| 16 | collapseWhitespace: true, |
||
| 17 | removeAttributeQuotes: false, |
||
| 18 | removeComments: true, |
||
| 19 | removeEmptyAttributes: false, |
||
| 20 | removeRedundantAttributes: false, |
||
| 21 | removeScriptTypeAttributes: false, |
||
| 22 | removeStyleLinkTypeAttributes: false |
||
| 23 | } |
||
| 24 | }, |
||
| 25 | main: { |
||
| 26 | src: ['templates/views/**/*.html'], |
||
| 27 | dest: 'js/templates.js' |
||
| 28 | } |
||
| 29 | }, |
||
| 30 | jshint: { |
||
| 31 | options: { |
||
| 32 | reporter: require('jshint-stylish'), |
||
| 33 | curly: false, |
||
| 34 | eqeqeq: true, |
||
| 35 | eqnull: true, |
||
| 36 | browser: true, |
||
| 37 | globals: { |
||
| 38 | "angular": true, |
||
| 39 | "OC": true, |
||
| 40 | "window": true, |
||
| 41 | "console": true, |
||
| 42 | "jQuery": true, |
||
| 43 | "$": true, |
||
| 44 | "_": true, |
||
| 45 | "oc_requesttoken": true |
||
| 46 | } |
||
| 47 | }, |
||
| 48 | all: ['js/app/**/*.js'] |
||
| 49 | }, |
||
| 50 | sass: { |
||
| 51 | dist: { |
||
| 52 | files: [ |
||
| 53 | { |
||
| 54 | expand: true, |
||
| 55 | cwd: "sass", |
||
| 56 | src: ["**/app.scss"], |
||
| 57 | dest: "css", |
||
| 58 | ext: ".css" |
||
| 59 | }, |
||
| 60 | { |
||
| 61 | expand: true, |
||
| 62 | cwd: "sass", |
||
| 63 | src: ["**/admin.scss"], |
||
| 64 | dest: "css", |
||
| 65 | ext: ".css" |
||
| 66 | } |
||
| 67 | ] |
||
| 68 | } |
||
| 69 | }, |
||
| 70 | |||
| 71 | karma: { |
||
| 72 | unit: { |
||
| 73 | configFile: './karma.conf.js', |
||
| 74 | background: false |
||
| 75 | } |
||
| 76 | }, |
||
| 77 | |||
| 78 | //@TODO JSHint |
||
| 79 | watch: { |
||
| 80 | scripts: { |
||
| 81 | files: ['Gruntfile.js', 'templates/views/{,*/}{,*/}{,*/}*.html', 'templates/views/*.html', 'sass/*', 'sass/partials/*'], |
||
| 82 | tasks: ['html2js', 'sass'], |
||
| 83 | options: { |
||
| 84 | spawn: true, |
||
| 85 | interrupt: true, |
||
| 86 | reload: true |
||
| 87 | } |
||
| 88 | } |
||
| 89 | }, |
||
| 90 | /** |
||
| 91 | * Build commands |
||
| 92 | */ |
||
| 93 | mkdir: { |
||
| 94 | dist: { |
||
| 95 | options: { |
||
| 96 | mode: 0700, |
||
| 97 | create: ['dist'] |
||
| 98 | } |
||
| 99 | } |
||
| 100 | }, |
||
| 101 | |||
| 102 | copy: { |
||
| 103 | dist: { |
||
| 104 | files: [ |
||
| 105 | // includes files within path |
||
| 106 | { |
||
| 107 | expand: true, |
||
| 108 | src: [ |
||
| 109 | '**', |
||
| 110 | '!templates/*.php', |
||
| 111 | '!templates/views/*', |
||
| 112 | '!templates/views/*/**', |
||
| 113 | '!templates/views', |
||
| 114 | '!js/*', |
||
| 115 | '!js/*/**', |
||
| 116 | '!node_modules/*/**', |
||
| 117 | '!node_modules', |
||
| 118 | '!css/**/*', |
||
| 119 | '!css/*.map', |
||
| 120 | '!css/app.*', |
||
| 121 | 'css/public-page.css', |
||
| 122 | 'css/admin.css', |
||
| 123 | '!dist/*', |
||
| 124 | '!dist/*/**', |
||
| 125 | '!dist', |
||
| 126 | '!tests/*/**', |
||
| 127 | '!tests/*', |
||
| 128 | '!tests', '' + |
||
| 129 | '!sass/*/**', |
||
| 130 | '!sass/*', |
||
| 131 | '!sass', |
||
| 132 | '!.drone.yml', |
||
| 133 | '!.gitignore', |
||
| 134 | '!.jshintrc', |
||
| 135 | '!.scrutinizer.yml', |
||
| 136 | '!.travis.yml', |
||
| 137 | '!Gruntfile.js', |
||
| 138 | '!karma.conf.js', |
||
| 139 | '!launch_phpunit.sh', |
||
| 140 | '!Makefile', |
||
| 141 | '!package.json', |
||
| 142 | '!phpunit.*', |
||
| 143 | '!Dockerfile', |
||
| 144 | '!swagger.yaml' |
||
| 145 | ], |
||
| 146 | dest: 'dist/' |
||
| 147 | } |
||
| 148 | ] |
||
| 149 | }, |
||
| 150 | fonts: { |
||
| 151 | files: [ |
||
| 152 | { |
||
| 153 | expand: true, |
||
| 154 | flatten: false, |
||
| 155 | src: ['css/vendor/font-awesome/*'], |
||
| 156 | dest: 'dist/' |
||
| 157 | } |
||
| 158 | |||
| 159 | ] |
||
| 160 | |||
| 161 | }, |
||
| 162 | settingsJs: { |
||
| 163 | files: [ |
||
| 164 | { |
||
| 165 | expand: true, |
||
| 166 | flatten: true, |
||
| 167 | src: ['js/settings-admin.js'], |
||
| 168 | dest: 'dist/js/' |
||
| 169 | } |
||
| 170 | |||
| 171 | ] |
||
| 172 | } |
||
| 173 | }, |
||
| 174 | |||
| 175 | |||
| 176 | uglify: { |
||
| 177 | options: { |
||
| 178 | mangle: false, |
||
| 179 | screwIE8: true, |
||
| 180 | banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', |
||
| 181 | }, |
||
| 182 | build: { |
||
| 183 | files: { |
||
| 184 | 'dist/js/nextnote.min.js': [ |
||
| 185 | 'js/vendor/angular/angular.min.js', |
||
| 186 | 'js/vendor/angular-animate/angular-animate.min.js', |
||
| 187 | 'js/vendor/angular-cookies/angular-cookies.min.js', |
||
| 188 | 'js/vendor/angular-resource/angular-resource.min.js', |
||
| 189 | 'js/vendor/angular-route/angular-route.min.js', |
||
| 190 | 'js/vendor/angular-sanitize/angular-sanitize.min.js', |
||
| 191 | 'js/vendor/angular-touch/angular-touch.min.js', |
||
| 192 | 'js/app/app.js', |
||
| 193 | 'js/app/filters/*.js', |
||
| 194 | 'js/app/services/*.js', |
||
| 195 | 'js/app/factory/*.js', |
||
| 196 | 'js/app/directives/*.js', |
||
| 197 | 'js/app/controllers/*.js', |
||
| 198 | 'js/templates.js', |
||
| 199 | 'js/settings-admin.js' |
||
| 200 | ] |
||
| 201 | } |
||
| 202 | } |
||
| 203 | }, |
||
| 204 | concat: { |
||
| 205 | css: { |
||
| 206 | src: ['css/vendor/**/*.css', 'css/app.css'], |
||
| 207 | dest: 'dist/css/nextnote.css' |
||
| 208 | } |
||
| 209 | }, |
||
| 210 | cssmin: { |
||
| 211 | options: { |
||
| 212 | shorthandCompacting: false, |
||
| 213 | roundingPrecision: -1 |
||
| 214 | }, |
||
| 215 | target: { |
||
| 216 | files: [ |
||
| 217 | { |
||
| 218 | expand: true, |
||
| 219 | cwd: 'dist/css', |
||
| 220 | src: ['nextnote.css'], |
||
| 221 | dest: 'dist/css', |
||
| 222 | ext: '.min.css' |
||
| 223 | } |
||
| 224 | ] |
||
| 225 | } |
||
| 226 | }, |
||
| 227 | clean: { |
||
| 228 | css: ['dist/css/nextnote.css'] |
||
| 229 | }, |
||
| 230 | replace: { |
||
| 231 | dist: { |
||
| 232 | files: [ |
||
| 233 | { |
||
| 234 | cwd: 'templates', |
||
| 235 | dest: 'dist/templates', |
||
| 236 | expand: true, |
||
| 237 | src: ['*.php'] |
||
| 238 | } |
||
| 239 | ], |
||
| 240 | options: { |
||
| 241 | patterns: [ |
||
| 242 | { |
||
| 243 | //Grab the /*build-js-start*/ and /*build-js-end*/ comments and everything in-between |
||
| 244 | match: /\/\s?\*build\-js\-start[\s\S]*build\-js\-end+\*\//, |
||
| 245 | replacement: function (matchedString) { |
||
| 246 | jsResources = []; |
||
| 247 | |||
| 248 | var jsArray = matchedString.match(/script\([A-z']+,\s?'([\/A-z.-]+)'\);/g); |
||
| 249 | jsArray.forEach(function (file) { |
||
| 250 | var regex = /script\([A-z']+,\s?'([\/A-z.-]+)'\);/g; |
||
| 251 | var matches = regex.exec(file); |
||
| 252 | if (matches) { |
||
| 253 | jsResources.push("'js/" + matches[1] + ".js'"); |
||
| 254 | |||
| 255 | } |
||
| 256 | }); |
||
| 257 | //Replace the entire build-js-start to build-js-end block with this <script> tag |
||
| 258 | |||
| 259 | return "script('passman', 'nextnote.min');"; |
||
| 260 | } |
||
| 261 | }, |
||
| 262 | { |
||
| 263 | //Grab the /*build-css-start*/ and /*build-css-end*/ comments and everything in-between |
||
| 264 | match: /\/\s?\*build\-css\-start[\s\S]*build\-css\-end+\*\//, |
||
| 265 | replacement: function (matchedString) { |
||
| 266 | //Replace the entire build-css-start to build-css-end block with this <link> tag |
||
| 267 | return "style('passman', 'nextnote.min');" |
||
|
0 ignored issues
–
show
|
|||
| 268 | } |
||
| 269 | } |
||
| 270 | ] |
||
| 271 | } |
||
| 272 | }, |
||
| 273 | strict: { |
||
| 274 | files: [ |
||
| 275 | { |
||
| 276 | cwd: 'dist/js', |
||
| 277 | dest: 'dist/js', |
||
| 278 | expand: true, |
||
| 279 | src: ['*.js'] |
||
| 280 | } |
||
| 281 | ], |
||
| 282 | options: { |
||
| 283 | patterns: [ |
||
| 284 | { |
||
| 285 | //Grab the <!--build-js-start--> and <!--build-js-end--> comments and everything in-between |
||
| 286 | match: /"use strict";/, |
||
| 287 | replacement: function (matchedString) { |
||
| 288 | //Replace the entire build-js-start to build-js-end block with this <script> tag |
||
| 289 | return ''; |
||
| 290 | } |
||
| 291 | } |
||
| 292 | ] |
||
| 293 | } |
||
| 294 | } |
||
| 295 | } |
||
| 296 | |||
| 297 | }); |
||
| 298 | |||
| 299 | // Load the plugin that provides the "uglify" task. |
||
| 300 | grunt.loadNpmTasks('grunt-contrib-sass'); |
||
| 301 | grunt.loadNpmTasks('grunt-contrib-uglify'); |
||
| 302 | grunt.loadNpmTasks('grunt-html2js'); |
||
| 303 | grunt.loadNpmTasks('grunt-contrib-watch'); |
||
| 304 | grunt.loadNpmTasks('grunt-contrib-jshint'); |
||
| 305 | grunt.loadNpmTasks('grunt-karma'); |
||
| 306 | grunt.loadNpmTasks('grunt-mkdir'); |
||
| 307 | grunt.loadNpmTasks('grunt-contrib-copy'); |
||
| 308 | grunt.loadNpmTasks('grunt-contrib-cssmin'); |
||
| 309 | grunt.loadNpmTasks('grunt-contrib-concat'); |
||
| 310 | grunt.loadNpmTasks('grunt-contrib-clean'); |
||
| 311 | grunt.loadNpmTasks('grunt-replace'); |
||
| 312 | |||
| 313 | |||
| 314 | // Default task(s). |
||
| 315 | grunt.registerTask('default', ['html2js', 'sass']); |
||
| 316 | grunt.registerTask('hint', ['jshint']); |
||
| 317 | grunt.registerTask('build', ['sass', 'jshint', 'html2js', 'mkdir:dist', 'copy:dist', 'copy:fonts', 'replace:dist', 'uglify', 'concat:css', 'cssmin', 'clean:css', 'replace:strict', 'copy:settingsJs']); |
||
| 318 | |||
| 319 | }; |
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.
Further Readings: