2017-05-25 20:09:29 +07:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
const buildDir = "dist";
|
|
|
|
|
2017-05-13 23:12:26 +07:00
|
|
|
grunt.initConfig({
|
|
|
|
run: {
|
|
|
|
options: {},
|
2017-05-25 20:09:29 +07:00
|
|
|
"build": {
|
2017-06-28 20:57:58 +07:00
|
|
|
cmd: "./node_modules/.bin/tsc",
|
|
|
|
args: ['-p', 'tsconfig.json']
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
|
|
|
"tslint": {
|
2017-06-28 20:57:58 +07:00
|
|
|
cmd: "./node_modules/.bin/tslint",
|
|
|
|
args: ['-c', 'tslint.json', '-p', 'tsconfig.json']
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
2017-07-27 04:45:26 +07:00
|
|
|
"unit-tests": {
|
2017-07-14 05:25:11 +07:00
|
|
|
cmd: "./node_modules/.bin/mocha",
|
2017-07-16 19:55:01 +07:00
|
|
|
args: ['--compilers', 'ts:ts-node/register', '--recursive', 'test/unit']
|
2017-07-14 05:25:11 +07:00
|
|
|
},
|
2017-07-27 04:45:26 +07:00
|
|
|
"integration-tests": {
|
|
|
|
cmd: "./node_modules/.bin/cucumber-js",
|
|
|
|
args: ["--compiler", "ts:ts-node/register", "./test/features"]
|
2017-07-16 19:55:01 +07:00
|
|
|
},
|
2017-05-13 23:32:25 +07:00
|
|
|
"docker-build": {
|
|
|
|
cmd: "docker",
|
|
|
|
args: ['build', '-t', 'clems4ever/authelia', '.']
|
2017-05-25 20:09:29 +07:00
|
|
|
},
|
|
|
|
"docker-restart": {
|
2017-07-18 03:37:34 +07:00
|
|
|
cmd: "./scripts/dc-dev.sh",
|
2017-07-14 05:25:11 +07:00
|
|
|
args: ['up', '-d']
|
2017-05-25 20:09:29 +07:00
|
|
|
},
|
|
|
|
"minify": {
|
|
|
|
cmd: "./node_modules/.bin/uglifyjs",
|
|
|
|
args: [`${buildDir}/src/server/public_html/js/authelia.js`, '-o', `${buildDir}/src/server/public_html/js/authelia.min.js`]
|
|
|
|
},
|
|
|
|
"apidoc": {
|
|
|
|
cmd: "./node_modules/.bin/apidoc",
|
|
|
|
args: ["-i", "src/server", "-o", "doc"]
|
2017-06-15 04:34:11 +07:00
|
|
|
},
|
|
|
|
"make-dev-views": {
|
|
|
|
cmd: "sed",
|
|
|
|
args: ["-i", "s/authelia\.min/authelia/", `${buildDir}/src/server/views/layout/layout.pug`]
|
2017-05-13 23:12:26 +07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
copy: {
|
|
|
|
resources: {
|
|
|
|
expand: true,
|
2017-05-25 20:09:29 +07:00
|
|
|
cwd: 'src/server/resources/',
|
2017-05-13 23:12:26 +07:00
|
|
|
src: '**',
|
2017-05-25 20:09:29 +07:00
|
|
|
dest: `${buildDir}/src/server/resources/`
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
|
|
|
views: {
|
|
|
|
expand: true,
|
2017-05-25 20:09:29 +07:00
|
|
|
cwd: 'src/server/views/',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/src/server/views/`
|
|
|
|
},
|
|
|
|
images: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'src/client/img',
|
2017-05-13 23:12:26 +07:00
|
|
|
src: '**',
|
2017-05-25 20:09:29 +07:00
|
|
|
dest: `${buildDir}/src/server/public_html/img/`
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
2017-05-25 20:09:29 +07:00
|
|
|
thirdparties: {
|
2017-05-13 23:12:26 +07:00
|
|
|
expand: true,
|
2017-05-25 20:09:29 +07:00
|
|
|
cwd: 'src/client/thirdparties',
|
2017-05-13 23:12:26 +07:00
|
|
|
src: '**',
|
2017-05-25 20:09:29 +07:00
|
|
|
dest: `${buildDir}/src/server/public_html/js/`
|
|
|
|
},
|
|
|
|
},
|
|
|
|
browserify: {
|
|
|
|
dist: {
|
|
|
|
src: ['dist/src/client/index.js'],
|
|
|
|
dest: `${buildDir}/src/server/public_html/js/authelia.js`,
|
|
|
|
options: {
|
|
|
|
browserifyOptions: {
|
|
|
|
standalone: 'authelia'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
views: {
|
|
|
|
files: ['src/server/views/**/*.pug'],
|
|
|
|
tasks: ['copy:views'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
resources: {
|
|
|
|
files: ['src/server/resources/*.ejs'],
|
|
|
|
tasks: ['copy:resources'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
images: {
|
|
|
|
files: ['src/client/img/**'],
|
|
|
|
tasks: ['copy:images'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
files: ['src/client/**/*.css'],
|
|
|
|
tasks: ['concat:css', 'cssmin'],
|
|
|
|
options: {
|
|
|
|
interrupt: true,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
client: {
|
|
|
|
files: ['src/client/**/*.ts', 'test/client/**/*.ts'],
|
2017-07-03 03:24:51 +07:00
|
|
|
tasks: ['build-dev'],
|
2017-05-25 20:09:29 +07:00
|
|
|
options: {
|
|
|
|
interrupt: true,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
files: ['src/server/**/*.ts', 'test/server/**/*.ts'],
|
2017-07-03 03:24:51 +07:00
|
|
|
tasks: ['build-dev', 'run:docker-restart', 'run:make-dev-views' ],
|
2017-05-25 20:09:29 +07:00
|
|
|
options: {
|
|
|
|
interrupt: true,
|
2017-07-03 03:24:51 +07:00
|
|
|
atBegin: true
|
2017-05-25 20:09:29 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
concat: {
|
|
|
|
css: {
|
|
|
|
src: ['src/client/css/*.css'],
|
|
|
|
dest: `${buildDir}/src/server/public_html/css/authelia.css`
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cssmin: {
|
|
|
|
target: {
|
|
|
|
files: {
|
|
|
|
[`${buildDir}/src/server/public_html/css/authelia.min.css`]: [`${buildDir}/src/server/public_html/css/authelia.css`]
|
|
|
|
}
|
2017-05-13 23:12:26 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-05-25 20:09:29 +07:00
|
|
|
grunt.loadNpmTasks('grunt-browserify');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
2017-05-13 23:12:26 +07:00
|
|
|
grunt.loadNpmTasks('grunt-run');
|
|
|
|
|
2017-06-15 04:34:11 +07:00
|
|
|
grunt.registerTask('default', ['build-dist']);
|
|
|
|
|
|
|
|
grunt.registerTask('build-resources', ['copy:resources', 'copy:views', 'copy:images', 'copy:thirdparties', 'concat:css']);
|
2017-05-13 23:32:25 +07:00
|
|
|
|
2017-07-15 00:05:42 +07:00
|
|
|
grunt.registerTask('build-common', ['run:tslint', 'run:build', 'browserify:dist', 'build-resources']);
|
|
|
|
grunt.registerTask('build-dev', ['build-common', 'run:make-dev-views']);
|
|
|
|
grunt.registerTask('build-dist', ['build-common', 'run:minify', 'cssmin']);
|
2017-05-25 20:09:29 +07:00
|
|
|
|
2017-05-13 23:32:25 +07:00
|
|
|
grunt.registerTask('docker-build', ['run:docker-build']);
|
2017-05-25 20:09:29 +07:00
|
|
|
grunt.registerTask('docker-restart', ['run:docker-restart']);
|
2017-05-13 23:12:26 +07:00
|
|
|
|
2017-07-27 04:45:26 +07:00
|
|
|
grunt.registerTask('unit-tests', ['run:unit-tests']);
|
|
|
|
grunt.registerTask('integration-tests', ['run:unit-tests']);
|
|
|
|
|
|
|
|
grunt.registerTask('test', ['unit-tests']);
|
2017-05-13 23:12:26 +07:00
|
|
|
};
|