2016-09-10 19:29:23 +08:00
|
|
|
module.exports = function (grunt) {
|
2016-12-22 06:00:35 +08:00
|
|
|
var jsResources = [];
|
2016-09-10 19:29:23 +08:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
2016-12-22 06:00:35 +08:00
|
|
|
jsResources: [],
|
|
|
|
cssResources: [],
|
2016-09-10 19:29:23 +08:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
html2js: {
|
|
|
|
options: {
|
|
|
|
// custom options, see below
|
2016-09-10 20:02:54 +08:00
|
|
|
base: 'templates',
|
|
|
|
quoteChar: '\'',
|
|
|
|
useStrict: true,
|
|
|
|
htmlmin: {
|
2016-09-11 05:30:17 +08:00
|
|
|
collapseBooleanAttributes: false,
|
2016-09-10 20:02:54 +08:00
|
|
|
collapseWhitespace: true,
|
|
|
|
removeAttributeQuotes: false,
|
|
|
|
removeComments: true,
|
|
|
|
removeEmptyAttributes: false,
|
2016-09-11 05:30:17 +08:00
|
|
|
removeRedundantAttributes: false,
|
2016-09-10 20:02:54 +08:00
|
|
|
removeScriptTypeAttributes: false,
|
|
|
|
removeStyleLinkTypeAttributes: false
|
|
|
|
}
|
2016-09-10 19:29:23 +08:00
|
|
|
},
|
|
|
|
main: {
|
|
|
|
src: ['templates/views/**/*.html'],
|
|
|
|
dest: 'js/templates.js'
|
|
|
|
}
|
|
|
|
},
|
2016-10-08 01:56:29 +08:00
|
|
|
jshint: {
|
|
|
|
options: {
|
2017-02-20 07:01:01 +08:00
|
|
|
reporter: require('jshint-stylish'),
|
2016-10-08 01:56:29 +08:00
|
|
|
curly: false,
|
|
|
|
eqeqeq: true,
|
|
|
|
eqnull: true,
|
|
|
|
browser: true,
|
|
|
|
globals: {
|
|
|
|
"angular": true,
|
|
|
|
"PassmanImporter": true,
|
2016-10-08 19:26:48 +08:00
|
|
|
"PassmanExporter": true,
|
2016-10-08 01:56:29 +08:00
|
|
|
"OC": true,
|
|
|
|
"window": true,
|
|
|
|
"console": true,
|
|
|
|
"CRYPTO": true,
|
|
|
|
"C_Promise": true,
|
|
|
|
"forge": true,
|
|
|
|
"sjcl": true,
|
|
|
|
"jQuery": true,
|
2016-10-08 05:50:16 +08:00
|
|
|
"$": true,
|
2016-10-08 01:56:29 +08:00
|
|
|
"_": true,
|
|
|
|
"oc_requesttoken": true
|
|
|
|
}
|
|
|
|
},
|
2016-12-22 06:00:35 +08:00
|
|
|
all: ['js/app/**/*.js']
|
2016-10-08 01:56:29 +08:00
|
|
|
},
|
2016-09-10 20:02:54 +08:00
|
|
|
sass: {
|
|
|
|
dist: {
|
2016-12-22 06:00:35 +08:00
|
|
|
files: [
|
2016-09-10 20:02:54 +08:00
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: "sass",
|
|
|
|
src: ["**/app.scss"],
|
|
|
|
dest: "css",
|
|
|
|
ext: ".css"
|
2016-10-01 23:21:24 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: "sass",
|
|
|
|
src: ["**/bookmarklet.scss"],
|
|
|
|
dest: "css",
|
|
|
|
ext: ".css"
|
2016-10-03 17:42:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: "sass",
|
|
|
|
src: ["**/public-page.scss"],
|
|
|
|
dest: "css",
|
|
|
|
ext: ".css"
|
2017-02-19 22:13:40 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: "sass",
|
|
|
|
src: ["**/admin.scss"],
|
|
|
|
dest: "css",
|
|
|
|
ext: ".css"
|
2016-09-10 20:02:54 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-10-17 17:28:48 +08:00
|
|
|
karma: {
|
|
|
|
unit: {
|
|
|
|
configFile: './karma.conf.js',
|
|
|
|
background: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-09-15 06:11:59 +08:00
|
|
|
//@TODO JSHint
|
2016-09-10 19:29:23 +08:00
|
|
|
watch: {
|
|
|
|
scripts: {
|
2016-12-22 06:00:35 +08:00
|
|
|
files: ['Gruntfile.js', 'templates/views/{,*/}{,*/}{,*/}*.html', 'templates/views/*.html', 'sass/*', 'sass/partials/*'],
|
|
|
|
tasks: ['html2js', 'sass'],
|
2016-09-10 19:29:23 +08:00
|
|
|
options: {
|
|
|
|
spawn: false,
|
|
|
|
interrupt: true,
|
|
|
|
reload: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-12-22 06:00:35 +08:00
|
|
|
/**
|
|
|
|
* Build commands
|
|
|
|
*/
|
|
|
|
mkdir: {
|
|
|
|
dist: {
|
|
|
|
options: {
|
|
|
|
mode: 0700,
|
|
|
|
create: ['dist']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
copy: {
|
|
|
|
dist: {
|
|
|
|
files: [
|
|
|
|
// includes files within path
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
src: [
|
|
|
|
'**',
|
|
|
|
'!templates/*.php',
|
|
|
|
'!templates/views/*',
|
|
|
|
'!templates/views/*/**',
|
|
|
|
'!templates/views',
|
|
|
|
'!js/*',
|
|
|
|
'!js/*/**',
|
|
|
|
'!node_modules/*/**',
|
|
|
|
'!node_modules',
|
|
|
|
'!css/**/*',
|
|
|
|
'!css/*.map',
|
|
|
|
'!css/app.*',
|
|
|
|
'css/bookmarklet.css',
|
|
|
|
'css/public-page.css',
|
2017-02-19 22:13:40 +08:00
|
|
|
'css/admin.css',
|
2016-12-22 06:00:35 +08:00
|
|
|
'!dist/*',
|
|
|
|
'!dist/*/**',
|
|
|
|
'!dist',
|
|
|
|
'!tests/*/**',
|
|
|
|
'!tests/*',
|
|
|
|
'!tests', '' +
|
|
|
|
'!sass/*/**',
|
|
|
|
'!sass/*',
|
|
|
|
'!sass',
|
|
|
|
'!.drone.yml',
|
|
|
|
'!.gitignore',
|
|
|
|
'!.jshintrc',
|
|
|
|
'!.scrutinizer.yml',
|
|
|
|
'!.travis.yml',
|
|
|
|
'!Gruntfile.js',
|
|
|
|
'!karma.conf.js',
|
|
|
|
'!launch_phpunit.sh',
|
|
|
|
'!Makefile',
|
|
|
|
'!package.json',
|
|
|
|
'!phpunit.*',
|
|
|
|
'!Dockerfile',
|
|
|
|
'!swagger.yaml'
|
|
|
|
],
|
|
|
|
dest: 'dist/'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
fonts: {
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
expand: true,
|
2017-04-17 18:30:11 +08:00
|
|
|
flatten: false,
|
|
|
|
src: ['css/vendor/font-awesome/*'],
|
|
|
|
dest: 'dist/'
|
2016-12-22 06:00:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2017-02-06 04:20:16 +08:00
|
|
|
},
|
|
|
|
settingsJs: {
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
flatten: true,
|
|
|
|
src: ['js/settings-admin.js'],
|
|
|
|
dest: 'dist/js/'
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
2016-12-22 06:00:35 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
uglify: {
|
|
|
|
options: {
|
|
|
|
mangle: false,
|
|
|
|
screwIE8: true,
|
|
|
|
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
old_files_array: [
|
|
|
|
'js/vendor/angular/angular.min.js',
|
|
|
|
'js/vendor/angular-animate/angular-animate.min.js',
|
|
|
|
'js/vendor/angular-cookies/angular-cookies.min.js',
|
|
|
|
'js/vendor/angular-resource/angular-resource.min.js',
|
|
|
|
'js/vendor/angular-route/angular-route.min.js',
|
|
|
|
'js/vendor/angular-sanitize/angular-sanitize.min.js',
|
|
|
|
'js/vendor/angular-touch/angular-touch.min.js',
|
|
|
|
'js/vendor/angular-local-storage/angular-local-storage.min.js',
|
|
|
|
'js/vendor/angular-off-click/angular-off-click.min.js',
|
|
|
|
'js/vendor/angularjs-datetime-picker/angularjs-datetime-picker.min.js',
|
|
|
|
'js/vendor/angular-translate/angular-translate.min.js',
|
|
|
|
'js/vendor/angular-translate/angular-translate-loader-url.min.js',
|
|
|
|
'js/vendor/ng-password-meter/ng-password-meter.js',
|
|
|
|
'js/vendor/sjcl/sjcl.js',
|
|
|
|
'js/vendor/zxcvbn/zxcvbn.js',
|
|
|
|
'js/vendor/ng-clipboard/clipboard.min.js',
|
|
|
|
'js/vendor/ng-clipboard/ngclipboard.js',
|
|
|
|
'js/vendor/ng-tags-input/ng-tags-input.min.js',
|
|
|
|
'js/vendor/angular-xeditable/xeditable.min.js',
|
|
|
|
'js/vendor/sha/sha.js',
|
|
|
|
'js/vendor/llqrcode/llqrcode.js',
|
|
|
|
'js/vendor/download.js',
|
|
|
|
'js/vendor/ui-sortable/sortable.js', 'js/lib/promise.js',
|
|
|
|
'js/lib/crypto_wrap.js',
|
|
|
|
'js/app/app.js',
|
|
|
|
'js/app/filters/*.js',
|
|
|
|
'js/app/services/*.js',
|
|
|
|
'js/app/factory/*.js',
|
|
|
|
'js/app/directives/*.js',
|
|
|
|
'js/importers/import-main.js',
|
|
|
|
'js/importers/*.js',
|
|
|
|
'js/exporters/exporter-main.js',
|
|
|
|
'js/exporters/*.js',
|
|
|
|
'js/app/controllers/*.js',
|
|
|
|
'js/templates.js'
|
|
|
|
],
|
|
|
|
files: {
|
|
|
|
'dist/js/passman.min.js': [
|
|
|
|
'js/vendor/angular/angular.min.js',
|
|
|
|
'js/vendor/angular-animate/angular-animate.min.js',
|
|
|
|
'js/vendor/angular-cookies/angular-cookies.min.js',
|
|
|
|
'js/vendor/angular-resource/angular-resource.min.js',
|
|
|
|
'js/vendor/angular-route/angular-route.min.js',
|
|
|
|
'js/vendor/angular-sanitize/angular-sanitize.min.js',
|
|
|
|
'js/vendor/angular-touch/angular-touch.min.js',
|
|
|
|
'js/vendor/angular-local-storage/angular-local-storage.min.js',
|
|
|
|
'js/vendor/angular-off-click/angular-off-click.min.js',
|
|
|
|
'js/vendor/angularjs-datetime-picker/angularjs-datetime-picker.min.js',
|
|
|
|
'js/vendor/angular-translate/angular-translate.min.js',
|
|
|
|
'js/vendor/angular-translate/angular-translate-loader-url.min.js',
|
|
|
|
'js/vendor/ng-password-meter/ng-password-meter.js',
|
|
|
|
'js/vendor/sjcl/sjcl.js',
|
|
|
|
'js/vendor/zxcvbn/zxcvbn.js',
|
2017-02-06 04:55:25 +08:00
|
|
|
'js/vendor/forge.0.6.9.min.js',
|
|
|
|
'js/vendor/download.js',
|
2016-12-22 06:00:35 +08:00
|
|
|
'js/vendor/ng-clipboard/clipboard.min.js',
|
|
|
|
'js/vendor/ng-clipboard/ngclipboard.js',
|
|
|
|
'js/vendor/ng-tags-input/ng-tags-input.min.js',
|
|
|
|
'js/vendor/angular-xeditable/xeditable.min.js',
|
|
|
|
'js/vendor/sha/sha.js',
|
|
|
|
'js/vendor/llqrcode/llqrcode.js',
|
|
|
|
'js/vendor/download.js',
|
2017-01-09 21:14:20 +08:00
|
|
|
'js/vendor/ui-sortable/sortable.js',
|
|
|
|
'js/vendor/papa-parse/papaparse.min.js',
|
|
|
|
'js/lib/promise.js',
|
2016-12-22 06:00:35 +08:00
|
|
|
'js/lib/crypto_wrap.js',
|
|
|
|
'js/app/app.js',
|
|
|
|
'js/app/filters/*.js',
|
|
|
|
'js/app/services/*.js',
|
|
|
|
'js/app/factory/*.js',
|
|
|
|
'js/app/directives/*.js',
|
|
|
|
'js/importers/import-main.js',
|
|
|
|
'js/importers/*.js',
|
|
|
|
'js/exporters/exporter-main.js',
|
|
|
|
'js/exporters/*.js',
|
|
|
|
'js/app/controllers/*.js',
|
2017-01-19 01:38:28 +08:00
|
|
|
'js/templates.js',
|
|
|
|
'js/settings-admin.js'
|
2016-12-22 06:00:35 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
concat: {
|
|
|
|
css: {
|
|
|
|
src: ['css/vendor/**/*.css', 'css/app.css'],
|
|
|
|
dest: 'dist/css/passman.css'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
cssmin: {
|
|
|
|
options: {
|
|
|
|
shorthandCompacting: false,
|
|
|
|
roundingPrecision: -1
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: 'dist/css',
|
|
|
|
src: ['passman.css'],
|
|
|
|
dest: 'dist/css',
|
|
|
|
ext: '.min.css'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: 'dist/css',
|
|
|
|
src: ['bookmarklet.css', 'public-page.css'],
|
|
|
|
dest: 'dist/css',
|
|
|
|
ext: '.css'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clean: {
|
2016-12-22 09:03:09 +08:00
|
|
|
css: ['dist/css/passman.css']
|
2016-12-22 06:00:35 +08:00
|
|
|
},
|
|
|
|
replace: {
|
|
|
|
dist: {
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
cwd: 'templates',
|
|
|
|
dest: 'dist/templates',
|
|
|
|
expand: true,
|
|
|
|
src: ['*.php']
|
|
|
|
}
|
|
|
|
],
|
|
|
|
options: {
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
//Grab the /*build-js-start*/ and /*build-js-end*/ comments and everything in-between
|
|
|
|
match: /\/\s?\*build\-js\-start[\s\S]*build\-js\-end+\*\//,
|
|
|
|
replacement: function (matchedString) {
|
|
|
|
jsResources = [];
|
|
|
|
|
|
|
|
var jsArray = matchedString.match(/script\([A-z']+,\s?'([\/A-z.-]+)'\);/g);
|
|
|
|
jsArray.forEach(function (file) {
|
|
|
|
var regex = /script\([A-z']+,\s?'([\/A-z.-]+)'\);/g;
|
|
|
|
var matches = regex.exec(file);
|
|
|
|
if (matches) {
|
|
|
|
jsResources.push("'js/" + matches[1] + ".js'");
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//Replace the entire build-js-start to build-js-end block with this <script> tag
|
|
|
|
|
|
|
|
return "script('passman', 'passman.min');";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
//Grab the /*build-css-start*/ and /*build-css-end*/ comments and everything in-between
|
|
|
|
match: /\/\s?\*build\-css\-start[\s\S]*build\-css\-end+\*\//,
|
|
|
|
replacement: function (matchedString) {
|
|
|
|
//Replace the entire build-css-start to build-css-end block with this <link> tag
|
|
|
|
return "style('passman', 'passman.min');"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
strict: {
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
cwd: 'dist/js',
|
|
|
|
dest: 'dist/js',
|
|
|
|
expand: true,
|
|
|
|
src: ['*.js']
|
|
|
|
}
|
|
|
|
],
|
|
|
|
options: {
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
//Grab the <!--build-js-start--> and <!--build-js-end--> comments and everything in-between
|
|
|
|
match: /"use strict";/,
|
|
|
|
replacement: function (matchedString) {
|
|
|
|
//Replace the entire build-js-start to build-js-end block with this <script> tag
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-10 19:29:23 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Load the plugin that provides the "uglify" task.
|
2016-09-10 20:02:54 +08:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-sass');
|
2016-09-10 19:29:23 +08:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
|
|
|
grunt.loadNpmTasks('grunt-html2js');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
2016-10-08 01:56:29 +08:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
2016-10-17 17:28:48 +08:00
|
|
|
grunt.loadNpmTasks('grunt-karma');
|
2016-12-22 06:00:35 +08:00
|
|
|
grunt.loadNpmTasks('grunt-mkdir');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
|
|
|
grunt.loadNpmTasks('grunt-replace');
|
|
|
|
|
|
|
|
|
2016-09-10 19:29:23 +08:00
|
|
|
// Default task(s).
|
2016-09-10 21:26:51 +08:00
|
|
|
grunt.registerTask('default', ['html2js', 'sass']);
|
2016-10-08 01:56:29 +08:00
|
|
|
grunt.registerTask('hint', ['jshint']);
|
2017-02-06 04:20:16 +08:00
|
|
|
grunt.registerTask('build', ['sass', 'jshint', 'html2js', 'mkdir:dist', 'copy:dist', 'copy:fonts', 'replace:dist', 'uglify', 'concat:css', 'cssmin', 'clean:css', 'replace:strict', 'copy:settingsJs']);
|
2016-09-10 19:29:23 +08:00
|
|
|
|
|
|
|
};
|