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({
|
2017-10-07 05:09:42 +07:00
|
|
|
env: {
|
|
|
|
"env-test-server-unit": {
|
|
|
|
TS_NODE_PROJECT: "server"
|
|
|
|
},
|
|
|
|
"env-test-client-unit": {
|
|
|
|
TS_NODE_PROJECT: "client"
|
|
|
|
}
|
|
|
|
},
|
2017-05-13 23:12:26 +07:00
|
|
|
run: {
|
2017-10-07 05:09:42 +07:00
|
|
|
"compile-server": {
|
|
|
|
cmd: "./node_modules/.bin/tsc",
|
|
|
|
args: ['-p', 'server/tsconfig.json']
|
|
|
|
},
|
|
|
|
"compile-client": {
|
2017-06-28 20:57:58 +07:00
|
|
|
cmd: "./node_modules/.bin/tsc",
|
2017-10-07 05:09:42 +07:00
|
|
|
args: ['-p', 'client/tsconfig.json']
|
|
|
|
},
|
|
|
|
"lint-server": {
|
|
|
|
cmd: "./node_modules/.bin/tslint",
|
|
|
|
args: ['-c', 'server/tslint.json', '-p', 'server/tsconfig.json']
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
2017-10-07 05:09:42 +07:00
|
|
|
"lint-client": {
|
2017-06-28 20:57:58 +07:00
|
|
|
cmd: "./node_modules/.bin/tslint",
|
2017-10-07 05:09:42 +07:00
|
|
|
args: ['-c', 'client/tslint.json', '-p', 'client/tsconfig.json']
|
|
|
|
},
|
|
|
|
"test-server-unit": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--compilers', 'ts:ts-node/register', '--recursive', 'server/test']
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
2017-10-07 05:09:42 +07:00
|
|
|
"test-client-unit": {
|
2017-07-14 05:25:11 +07:00
|
|
|
cmd: "./node_modules/.bin/mocha",
|
2017-10-07 05:09:42 +07:00
|
|
|
args: ['--colors', '--compilers', 'ts:ts-node/register', '--recursive', 'client/test']
|
2017-07-14 05:25:11 +07:00
|
|
|
},
|
2017-10-07 05:09:42 +07:00
|
|
|
"test-int": {
|
2017-07-27 04:45:26 +07:00
|
|
|
cmd: "./node_modules/.bin/cucumber-js",
|
2017-10-07 05:09:42 +07:00
|
|
|
args: ["--colors", "--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
|
|
|
},
|
|
|
|
"minify": {
|
|
|
|
cmd: "./node_modules/.bin/uglifyjs",
|
2017-10-07 05:09:42 +07:00
|
|
|
args: [`${buildDir}/server/src/public_html/js/authelia.js`, '-o', `${buildDir}/server/src/public_html/js/authelia.min.js`]
|
2017-05-25 20:09:29 +07:00
|
|
|
},
|
|
|
|
"apidoc": {
|
|
|
|
cmd: "./node_modules/.bin/apidoc",
|
|
|
|
args: ["-i", "src/server", "-o", "doc"]
|
2017-06-15 04:34:11 +07:00
|
|
|
},
|
2017-10-07 05:09:42 +07:00
|
|
|
"include-minified-script": {
|
2017-06-15 04:34:11 +07:00
|
|
|
cmd: "sed",
|
2017-10-07 05:09:42 +07:00
|
|
|
args: ["-i", "s/authelia\.min/authelia/", `${buildDir}/server/src/views/layout/layout.pug`]
|
2017-05-13 23:12:26 +07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
copy: {
|
|
|
|
resources: {
|
|
|
|
expand: true,
|
2017-10-07 05:09:42 +07:00
|
|
|
cwd: 'server/src/resources/',
|
2017-05-13 23:12:26 +07:00
|
|
|
src: '**',
|
2017-10-07 05:09:42 +07:00
|
|
|
dest: `${buildDir}/server/src/resources/`
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
|
|
|
views: {
|
|
|
|
expand: true,
|
2017-10-07 05:09:42 +07:00
|
|
|
cwd: 'server/src/views/',
|
2017-05-25 20:09:29 +07:00
|
|
|
src: '**',
|
2017-10-07 05:09:42 +07:00
|
|
|
dest: `${buildDir}/server/src/views/`
|
2017-05-25 20:09:29 +07:00
|
|
|
},
|
|
|
|
images: {
|
|
|
|
expand: true,
|
2017-10-07 05:09:42 +07:00
|
|
|
cwd: 'client/src/img',
|
2017-05-13 23:12:26 +07:00
|
|
|
src: '**',
|
2017-10-07 05:09:42 +07:00
|
|
|
dest: `${buildDir}/server/src/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-10-07 05:09:42 +07:00
|
|
|
cwd: 'client/src/thirdparties',
|
2017-05-13 23:12:26 +07:00
|
|
|
src: '**',
|
2017-10-07 05:09:42 +07:00
|
|
|
dest: `${buildDir}/server/src/public_html/js/`
|
2017-05-25 20:09:29 +07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
browserify: {
|
|
|
|
dist: {
|
2017-10-07 05:09:42 +07:00
|
|
|
src: ['dist/client/src/index.js'],
|
|
|
|
dest: `${buildDir}/server/src/public_html/js/authelia.js`,
|
2017-05-25 20:09:29 +07:00
|
|
|
options: {
|
|
|
|
browserifyOptions: {
|
|
|
|
standalone: 'authelia'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
views: {
|
2017-10-07 05:09:42 +07:00
|
|
|
files: ['server/src/views/**/*.pug'],
|
2017-05-25 20:09:29 +07:00
|
|
|
tasks: ['copy:views'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
resources: {
|
2017-10-07 05:09:42 +07:00
|
|
|
files: ['server/src/resources/*.ejs'],
|
2017-05-25 20:09:29 +07:00
|
|
|
tasks: ['copy:resources'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
images: {
|
2017-10-07 05:09:42 +07:00
|
|
|
files: ['client/src/img/**'],
|
2017-05-25 20:09:29 +07:00
|
|
|
tasks: ['copy:images'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
2017-10-07 05:09:42 +07:00
|
|
|
files: ['client/src/**/*.css'],
|
2017-05-25 20:09:29 +07:00
|
|
|
tasks: ['concat:css', 'cssmin'],
|
|
|
|
options: {
|
|
|
|
interrupt: true,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
client: {
|
2017-10-07 05:09:42 +07:00
|
|
|
files: ['client/src/**/*.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: {
|
2017-10-07 05:09:42 +07:00
|
|
|
files: ['server/src/**/*.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: {
|
2017-10-07 05:09:42 +07:00
|
|
|
src: ['client/src/css/*.css'],
|
|
|
|
dest: `${buildDir}/server/src/public_html/css/authelia.css`
|
2017-05-25 20:09:29 +07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
cssmin: {
|
|
|
|
target: {
|
|
|
|
files: {
|
2017-10-07 05:09:42 +07:00
|
|
|
[`${buildDir}/server/src/public_html/css/authelia.min.css`]: [`${buildDir}/server/src/public_html/css/authelia.css`]
|
2017-05-25 20:09:29 +07:00
|
|
|
}
|
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-10-07 05:09:42 +07:00
|
|
|
grunt.loadNpmTasks('grunt-env');
|
2017-05-13 23:12:26 +07:00
|
|
|
|
2017-06-15 04:34:11 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('compile-server', ['run:lint-server', 'run:compile-server'])
|
|
|
|
grunt.registerTask('compile-client', ['run:lint-client', 'run:compile-client'])
|
2017-05-13 23:32:25 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('test-server', ['env:env-test-server-unit', 'run:test-server-unit'])
|
|
|
|
grunt.registerTask('test-client', ['env:env-test-client-unit', 'run:test-client-unit'])
|
|
|
|
grunt.registerTask('test-unit', ['test-server', 'test-client']);
|
|
|
|
grunt.registerTask('test-int', ['run:test-int']);
|
2017-05-25 20:09:29 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('copy-resources', ['copy:resources', 'copy:views', 'copy:images', 'copy:thirdparties', 'concat:css']);
|
2017-05-13 23:12:26 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('build-client', ['compile-client', 'browserify']);
|
|
|
|
grunt.registerTask('build-server', ['compile-server', 'copy-resources']);
|
2017-07-27 04:45:26 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('build', ['build-client', 'build-server']);
|
|
|
|
grunt.registerTask('build-dist', ['build', 'run:minify', 'cssmin', 'run:include-minified-script']);
|
|
|
|
|
|
|
|
grunt.registerTask('docker-build', ['run:docker-build']);
|
|
|
|
|
|
|
|
grunt.registerTask('default', ['build-dist']);
|
2017-05-13 23:12:26 +07:00
|
|
|
};
|