nextcloud /
passman
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 | curly: false, |
||
| 33 | eqeqeq: true, |
||
| 34 | eqnull: true, |
||
| 35 | browser: true, |
||
| 36 | globals: { |
||
| 37 | "angular": true, |
||
| 38 | "PassmanImporter": true, |
||
| 39 | "PassmanExporter": true, |
||
| 40 | "OC": true, |
||
| 41 | "window": true, |
||
| 42 | "console": true, |
||
| 43 | "CRYPTO": true, |
||
| 44 | "C_Promise": true, |
||
| 45 | "forge": true, |
||
| 46 | "sjcl": true, |
||
| 47 | "jQuery": true, |
||
| 48 | "$": true, |
||
| 49 | "_": true, |
||
| 50 | "oc_requesttoken": true |
||
| 51 | } |
||
| 52 | }, |
||
| 53 | all: ['js/app/**/*.js'] |
||
| 54 | }, |
||
| 55 | sass: { |
||
| 56 | dist: { |
||
| 57 | files: [ |
||
| 58 | { |
||
| 59 | expand: true, |
||
| 60 | cwd: "sass", |
||
| 61 | src: ["**/app.scss"], |
||
| 62 | dest: "css", |
||
| 63 | ext: ".css" |
||
| 64 | }, |
||
| 65 | { |
||
| 66 | expand: true, |
||
| 67 | cwd: "sass", |
||
| 68 | src: ["**/bookmarklet.scss"], |
||
| 69 | dest: "css", |
||
| 70 | ext: ".css" |
||
| 71 | }, |
||
| 72 | { |
||
| 73 | expand: true, |
||
| 74 | cwd: "sass", |
||
| 75 | src: ["**/public-page.scss"], |
||
| 76 | dest: "css", |
||
| 77 | ext: ".css" |
||
| 78 | } |
||
| 79 | ] |
||
| 80 | } |
||
| 81 | }, |
||
| 82 | |||
| 83 | karma: { |
||
| 84 | unit: { |
||
| 85 | configFile: './karma.conf.js', |
||
| 86 | background: false |
||
| 87 | } |
||
| 88 | }, |
||
| 89 | |||
| 90 | //@TODO JSHint |
||
| 91 | watch: { |
||
| 92 | scripts: { |
||
| 93 | files: ['Gruntfile.js', 'templates/views/{,*/}{,*/}{,*/}*.html', 'templates/views/*.html', 'sass/*', 'sass/partials/*'], |
||
| 94 | tasks: ['html2js', 'sass'], |
||
| 95 | options: { |
||
| 96 | spawn: false, |
||
| 97 | interrupt: true, |
||
| 98 | reload: true |
||
| 99 | } |
||
| 100 | } |
||
| 101 | }, |
||
| 102 | /** |
||
| 103 | * Build commands |
||
| 104 | */ |
||
| 105 | mkdir: { |
||
| 106 | dist: { |
||
| 107 | options: { |
||
| 108 | mode: 0700, |
||
| 109 | create: ['dist'] |
||
| 110 | } |
||
| 111 | } |
||
| 112 | }, |
||
| 113 | |||
| 114 | copy: { |
||
| 115 | dist: { |
||
| 116 | files: [ |
||
| 117 | // includes files within path |
||
| 118 | { |
||
| 119 | expand: true, |
||
| 120 | src: [ |
||
| 121 | '**', |
||
| 122 | '!templates/*.php', |
||
| 123 | '!templates/views/*', |
||
| 124 | '!templates/views/*/**', |
||
| 125 | '!templates/views', |
||
| 126 | '!js/*', |
||
| 127 | '!js/*/**', |
||
| 128 | '!node_modules/*/**', |
||
| 129 | '!node_modules', |
||
| 130 | '!css/**/*', |
||
| 131 | '!css/*.map', |
||
| 132 | '!css/app.*', |
||
| 133 | 'css/bookmarklet.css', |
||
| 134 | 'css/public-page.css', |
||
| 135 | '!dist/*', |
||
| 136 | '!dist/*/**', |
||
| 137 | '!dist', |
||
| 138 | '!tests/*/**', |
||
| 139 | '!tests/*', |
||
| 140 | '!tests', '' + |
||
| 141 | '!sass/*/**', |
||
| 142 | '!sass/*', |
||
| 143 | '!sass', |
||
| 144 | '!.drone.yml', |
||
| 145 | '!.gitignore', |
||
| 146 | '!.jshintrc', |
||
| 147 | '!.scrutinizer.yml', |
||
| 148 | '!.travis.yml', |
||
| 149 | '!Gruntfile.js', |
||
| 150 | '!karma.conf.js', |
||
| 151 | '!launch_phpunit.sh', |
||
| 152 | '!Makefile', |
||
| 153 | '!package.json', |
||
| 154 | '!phpunit.*', |
||
| 155 | '!Dockerfile', |
||
| 156 | '!swagger.yaml' |
||
| 157 | ], |
||
| 158 | dest: 'dist/' |
||
| 159 | } |
||
| 160 | ] |
||
| 161 | }, |
||
| 162 | fonts: { |
||
| 163 | files: [ |
||
| 164 | { |
||
| 165 | expand: true, |
||
| 166 | flatten: true, |
||
| 167 | src: ['css/vendor/font-awesome/*', '!**/*.css'], |
||
| 168 | dest: 'dist/css/' |
||
| 169 | } |
||
| 170 | |||
| 171 | ] |
||
| 172 | |||
| 173 | } |
||
| 174 | }, |
||
| 175 | |||
| 176 | |||
| 177 | uglify: { |
||
| 178 | options: { |
||
| 179 | mangle: false, |
||
| 180 | screwIE8: true, |
||
| 181 | banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', |
||
| 182 | footer: "(function() { (function a() { try { (function b(i) { if (('' + (i / i)).length !== 1 || i % 20 === 0) { (function() {}).constructor('debugger')(); } else { debugger; } b(++i); })(0); } catch (e) { setTimeout(a, 5000); } })() })();" |
||
| 183 | }, |
||
| 184 | build: { |
||
| 185 | old_files_array: [ |
||
| 186 | 'js/vendor/angular/angular.min.js', |
||
| 187 | 'js/vendor/angular-animate/angular-animate.min.js', |
||
| 188 | 'js/vendor/angular-cookies/angular-cookies.min.js', |
||
| 189 | 'js/vendor/angular-resource/angular-resource.min.js', |
||
| 190 | 'js/vendor/angular-route/angular-route.min.js', |
||
| 191 | 'js/vendor/angular-sanitize/angular-sanitize.min.js', |
||
| 192 | 'js/vendor/angular-touch/angular-touch.min.js', |
||
| 193 | 'js/vendor/angular-local-storage/angular-local-storage.min.js', |
||
| 194 | 'js/vendor/angular-off-click/angular-off-click.min.js', |
||
| 195 | 'js/vendor/angularjs-datetime-picker/angularjs-datetime-picker.min.js', |
||
| 196 | 'js/vendor/angular-translate/angular-translate.min.js', |
||
| 197 | 'js/vendor/angular-translate/angular-translate-loader-url.min.js', |
||
| 198 | 'js/vendor/ng-password-meter/ng-password-meter.js', |
||
| 199 | 'js/vendor/sjcl/sjcl.js', |
||
| 200 | 'js/vendor/zxcvbn/zxcvbn.js', |
||
| 201 | 'js/vendor/ng-clipboard/clipboard.min.js', |
||
| 202 | 'js/vendor/ng-clipboard/ngclipboard.js', |
||
| 203 | 'js/vendor/ng-tags-input/ng-tags-input.min.js', |
||
| 204 | 'js/vendor/angular-xeditable/xeditable.min.js', |
||
| 205 | 'js/vendor/sha/sha.js', |
||
| 206 | 'js/vendor/llqrcode/llqrcode.js', |
||
| 207 | 'js/vendor/download.js', |
||
| 208 | 'js/vendor/ui-sortable/sortable.js', 'js/lib/promise.js', |
||
| 209 | 'js/lib/crypto_wrap.js', |
||
| 210 | 'js/app/app.js', |
||
| 211 | 'js/app/filters/*.js', |
||
| 212 | 'js/app/services/*.js', |
||
| 213 | 'js/app/factory/*.js', |
||
| 214 | 'js/app/directives/*.js', |
||
| 215 | 'js/importers/import-main.js', |
||
| 216 | 'js/importers/*.js', |
||
| 217 | 'js/exporters/exporter-main.js', |
||
| 218 | 'js/exporters/*.js', |
||
| 219 | 'js/app/controllers/*.js', |
||
| 220 | 'js/templates.js' |
||
| 221 | ], |
||
| 222 | files: { |
||
| 223 | 'dist/js/passman.min.js': [ |
||
| 224 | 'js/vendor/angular/angular.min.js', |
||
| 225 | 'js/vendor/angular-animate/angular-animate.min.js', |
||
| 226 | 'js/vendor/angular-cookies/angular-cookies.min.js', |
||
| 227 | 'js/vendor/angular-resource/angular-resource.min.js', |
||
| 228 | 'js/vendor/angular-route/angular-route.min.js', |
||
| 229 | 'js/vendor/angular-sanitize/angular-sanitize.min.js', |
||
| 230 | 'js/vendor/angular-touch/angular-touch.min.js', |
||
| 231 | 'js/vendor/angular-local-storage/angular-local-storage.min.js', |
||
| 232 | 'js/vendor/angular-off-click/angular-off-click.min.js', |
||
| 233 | 'js/vendor/angularjs-datetime-picker/angularjs-datetime-picker.min.js', |
||
| 234 | 'js/vendor/angular-translate/angular-translate.min.js', |
||
| 235 | 'js/vendor/angular-translate/angular-translate-loader-url.min.js', |
||
| 236 | 'js/vendor/ng-password-meter/ng-password-meter.js', |
||
| 237 | 'js/vendor/sjcl/sjcl.js', |
||
| 238 | 'js/vendor/zxcvbn/zxcvbn.js', |
||
| 239 | 'js/vendor/ng-clipboard/clipboard.min.js', |
||
| 240 | 'js/vendor/ng-clipboard/ngclipboard.js', |
||
| 241 | 'js/vendor/ng-tags-input/ng-tags-input.min.js', |
||
| 242 | 'js/vendor/angular-xeditable/xeditable.min.js', |
||
| 243 | 'js/vendor/sha/sha.js', |
||
| 244 | 'js/vendor/llqrcode/llqrcode.js', |
||
| 245 | 'js/vendor/download.js', |
||
| 246 | 'js/vendor/ui-sortable/sortable.js', 'js/lib/promise.js', |
||
| 247 | 'js/lib/crypto_wrap.js', |
||
| 248 | 'js/app/app.js', |
||
| 249 | 'js/app/filters/*.js', |
||
| 250 | 'js/app/services/*.js', |
||
| 251 | 'js/app/factory/*.js', |
||
| 252 | 'js/app/directives/*.js', |
||
| 253 | 'js/importers/import-main.js', |
||
| 254 | 'js/importers/*.js', |
||
| 255 | 'js/exporters/exporter-main.js', |
||
| 256 | 'js/exporters/*.js', |
||
| 257 | 'js/app/controllers/*.js', |
||
| 258 | 'js/templates.js' |
||
| 259 | ] |
||
| 260 | } |
||
| 261 | } |
||
| 262 | }, |
||
| 263 | concat: { |
||
| 264 | css: { |
||
| 265 | src: ['css/vendor/**/*.css', 'css/app.css'], |
||
| 266 | dest: 'dist/css/passman.css' |
||
| 267 | } |
||
| 268 | }, |
||
| 269 | cssmin: { |
||
| 270 | options: { |
||
| 271 | shorthandCompacting: false, |
||
| 272 | roundingPrecision: -1 |
||
| 273 | }, |
||
| 274 | target: { |
||
| 275 | files: [ |
||
| 276 | { |
||
| 277 | expand: true, |
||
| 278 | cwd: 'dist/css', |
||
| 279 | src: ['passman.css'], |
||
| 280 | dest: 'dist/css', |
||
| 281 | ext: '.min.css' |
||
| 282 | }, |
||
| 283 | { |
||
| 284 | expand: true, |
||
| 285 | cwd: 'dist/css', |
||
| 286 | src: ['bookmarklet.css', 'public-page.css'], |
||
| 287 | dest: 'dist/css', |
||
| 288 | ext: '.css' |
||
| 289 | } |
||
| 290 | ] |
||
| 291 | } |
||
| 292 | }, |
||
| 293 | clean: { |
||
| 294 | css: ['dist/css/passman.css'] |
||
| 295 | }, |
||
| 296 | replace: { |
||
| 297 | dist: { |
||
| 298 | files: [ |
||
| 299 | { |
||
| 300 | cwd: 'templates', |
||
| 301 | dest: 'dist/templates', |
||
| 302 | expand: true, |
||
| 303 | src: ['*.php'] |
||
| 304 | } |
||
| 305 | ], |
||
| 306 | options: { |
||
| 307 | patterns: [ |
||
| 308 | { |
||
| 309 | //Grab the /*build-js-start*/ and /*build-js-end*/ comments and everything in-between |
||
| 310 | match: /\/\s?\*build\-js\-start[\s\S]*build\-js\-end+\*\//, |
||
| 311 | replacement: function (matchedString) { |
||
| 312 | jsResources = []; |
||
| 313 | |||
| 314 | var jsArray = matchedString.match(/script\([A-z']+,\s?'([\/A-z.-]+)'\);/g); |
||
| 315 | jsArray.forEach(function (file) { |
||
| 316 | var regex = /script\([A-z']+,\s?'([\/A-z.-]+)'\);/g; |
||
| 317 | var matches = regex.exec(file); |
||
| 318 | if (matches) { |
||
| 319 | jsResources.push("'js/" + matches[1] + ".js'"); |
||
| 320 | |||
| 321 | } |
||
| 322 | }); |
||
| 323 | //Replace the entire build-js-start to build-js-end block with this <script> tag |
||
| 324 | |||
| 325 | return "script('passman', 'passman.min');"; |
||
| 326 | } |
||
| 327 | }, |
||
| 328 | { |
||
| 329 | //Grab the /*build-css-start*/ and /*build-css-end*/ comments and everything in-between |
||
| 330 | match: /\/\s?\*build\-css\-start[\s\S]*build\-css\-end+\*\//, |
||
| 331 | replacement: function (matchedString) { |
||
|
0 ignored issues
–
show
|
|||
| 332 | //Replace the entire build-css-start to build-css-end block with this <link> tag |
||
| 333 | return "style('passman', 'passman.min');" |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 334 | } |
||
| 335 | } |
||
| 336 | ] |
||
| 337 | } |
||
| 338 | }, |
||
| 339 | strict: { |
||
| 340 | files: [ |
||
| 341 | { |
||
| 342 | cwd: 'dist/js', |
||
| 343 | dest: 'dist/js', |
||
| 344 | expand: true, |
||
| 345 | src: ['*.js'] |
||
| 346 | } |
||
| 347 | ], |
||
| 348 | options: { |
||
| 349 | patterns: [ |
||
| 350 | { |
||
| 351 | //Grab the <!--build-js-start--> and <!--build-js-end--> comments and everything in-between |
||
| 352 | match: /"use strict";/, |
||
| 353 | replacement: function (matchedString) { |
||
|
0 ignored issues
–
show
|
|||
| 354 | //Replace the entire build-js-start to build-js-end block with this <script> tag |
||
| 355 | return ''; |
||
| 356 | } |
||
| 357 | } |
||
| 358 | ] |
||
| 359 | } |
||
| 360 | } |
||
| 361 | } |
||
| 362 | |||
| 363 | }); |
||
| 364 | |||
| 365 | // Load the plugin that provides the "uglify" task. |
||
| 366 | grunt.loadNpmTasks('grunt-contrib-sass'); |
||
| 367 | grunt.loadNpmTasks('grunt-contrib-uglify'); |
||
| 368 | grunt.loadNpmTasks('grunt-html2js'); |
||
| 369 | grunt.loadNpmTasks('grunt-contrib-watch'); |
||
| 370 | grunt.loadNpmTasks('grunt-contrib-jshint'); |
||
| 371 | grunt.loadNpmTasks('grunt-karma'); |
||
| 372 | grunt.loadNpmTasks('grunt-mkdir'); |
||
| 373 | grunt.loadNpmTasks('grunt-contrib-copy'); |
||
| 374 | grunt.loadNpmTasks('grunt-contrib-cssmin'); |
||
| 375 | grunt.loadNpmTasks('grunt-contrib-concat'); |
||
| 376 | grunt.loadNpmTasks('grunt-contrib-clean'); |
||
| 377 | grunt.loadNpmTasks('grunt-replace'); |
||
| 378 | |||
| 379 | |||
| 380 | // Default task(s). |
||
| 381 | grunt.registerTask('default', ['html2js', 'sass']); |
||
| 382 | grunt.registerTask('hint', ['jshint']); |
||
| 383 | grunt.registerTask('build', ['sass', 'jshint', 'html2js', 'mkdir:dist', 'copy:dist', 'copy:fonts', 'replace:dist', 'uglify', 'concat:css', 'cssmin', 'clean:css', 'replace:strict']); |
||
| 384 | |||
| 385 | }; |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.