2017-05-25 20:09:29 +07:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
const buildDir = "dist";
|
2017-10-11 02:59:20 +07:00
|
|
|
const schemaDir = "server/src/lib/configuration/Configuration.schema.json"
|
2019-01-26 23:15:35 +07:00
|
|
|
|
2017-05-13 23:12:26 +07:00
|
|
|
grunt.initConfig({
|
2018-12-18 22:30:23 +07:00
|
|
|
clean: {
|
|
|
|
dist: ['dist'],
|
|
|
|
},
|
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']
|
|
|
|
},
|
2019-01-26 23:15:35 +07:00
|
|
|
"compile-client": {
|
|
|
|
exec: 'cd ./client && npm run build && mv build ../dist/client',
|
|
|
|
},
|
2017-10-10 06:14:36 +07:00
|
|
|
"generate-config-schema": {
|
|
|
|
cmd: "./node_modules/.bin/typescript-json-schema",
|
2017-10-11 02:59:20 +07:00
|
|
|
args: ["-o", schemaDir, "--strictNullChecks",
|
2018-07-08 22:02:28 +07:00
|
|
|
"--required", "server/tsconfig.json", "Configuration"]
|
2017-10-10 06:14:36 +07:00
|
|
|
},
|
2017-10-07 05:09:42 +07:00
|
|
|
"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
|
|
|
"test-server-unit": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
2018-07-08 22:02:28 +07:00
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'server/src/**/*.spec.ts']
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
2018-10-27 23:18:25 +07:00
|
|
|
"test-shared-unit": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'shared/**/*.spec.ts']
|
|
|
|
},
|
2018-08-10 03:24:02 +07:00
|
|
|
"test-cucumber": {
|
2017-10-17 05:38:10 +07:00
|
|
|
cmd: "./scripts/run-cucumber.sh",
|
|
|
|
args: ["./test/features"]
|
2017-07-16 19:55:01 +07:00
|
|
|
},
|
2018-08-19 21:51:36 +07:00
|
|
|
"test-complete-config": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'test/complete-config/**/*.ts']
|
|
|
|
},
|
2018-08-10 03:24:02 +07:00
|
|
|
"test-minimal-config": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'test/minimal-config/**/*.ts']
|
|
|
|
},
|
2018-10-22 14:35:06 +07:00
|
|
|
"test-inactivity": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'test/inactivity/**/*.ts']
|
|
|
|
},
|
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
|
|
|
},
|
|
|
|
"apidoc": {
|
|
|
|
cmd: "./node_modules/.bin/apidoc",
|
|
|
|
args: ["-i", "src/server", "-o", "doc"]
|
2017-06-15 04:34:11 +07:00
|
|
|
},
|
2017-05-13 23:12:26 +07:00
|
|
|
},
|
|
|
|
copy: {
|
2018-12-18 22:30:23 +07:00
|
|
|
backup: {
|
|
|
|
files: [{
|
2018-12-18 04:49:01 +07:00
|
|
|
expand: true,
|
2018-12-18 22:30:23 +07:00
|
|
|
src: ['dist/**'],
|
|
|
|
dest: 'backup'
|
|
|
|
}]
|
2018-12-18 04:49:01 +07:00
|
|
|
},
|
2018-12-18 22:30:23 +07:00
|
|
|
resources: {
|
2018-12-18 04:49:01 +07:00
|
|
|
expand: true,
|
2019-01-26 23:15:35 +07:00
|
|
|
cwd: 'server/src/resources',
|
2018-12-18 04:49:01 +07:00
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/resources/`
|
|
|
|
},
|
|
|
|
schema: {
|
|
|
|
src: schemaDir,
|
|
|
|
dest: `${buildDir}/${schemaDir}`
|
|
|
|
}
|
2017-05-25 20:09:29 +07:00
|
|
|
},
|
2017-05-13 23:12:26 +07:00
|
|
|
});
|
2018-12-18 04:49:01 +07:00
|
|
|
|
2017-05-25 20:09:29 +07:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
2018-12-18 05:27:58 +07:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
2017-05-13 23:12:26 +07:00
|
|
|
grunt.loadNpmTasks('grunt-run');
|
|
|
|
|
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
|
|
|
|
2018-04-27 04:20:10 +07:00
|
|
|
grunt.registerTask('test-server', ['env:env-test-server-unit', 'run:test-server-unit'])
|
2018-10-27 23:18:25 +07:00
|
|
|
grunt.registerTask('test-shared', ['env:env-test-shared-unit', 'run:test-shared-unit'])
|
|
|
|
grunt.registerTask('test-unit', ['test-server', 'test-client', 'test-shared']);
|
2018-10-22 14:35:06 +07:00
|
|
|
grunt.registerTask('test-int', ['run:test-cucumber', 'run:test-minimal-config', 'run:test-complete-config', 'run:test-inactivity']);
|
2017-05-25 20:09:29 +07:00
|
|
|
|
2018-12-18 14:32:04 +07:00
|
|
|
grunt.registerTask('generate-config-schema', ['run:generate-config-schema', 'copy:schema']);
|
2018-12-18 13:47:07 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('build-client', ['compile-client', 'browserify']);
|
2018-12-18 22:30:23 +07:00
|
|
|
|
2019-01-26 23:15:35 +07:00
|
|
|
grunt.registerTask('build-server', ['compile-server', 'copy:resources', 'generate-config-schema']);
|
2018-12-18 14:32:04 +07:00
|
|
|
|
2018-12-18 22:30:23 +07:00
|
|
|
grunt.registerTask('build', ['build-client', 'build-server']);
|
2019-01-26 23:15:35 +07:00
|
|
|
grunt.registerTask('build-dist', ['clean:dist', 'build']);
|
2017-10-17 05:35:34 +07:00
|
|
|
grunt.registerTask('schema', ['run:generate-config-schema'])
|
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('docker-build', ['run:docker-build']);
|
2017-05-13 23:12:26 +07:00
|
|
|
};
|