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"
|
2017-05-25 20:09:29 +07:00
|
|
|
|
2017-05-13 23:12:26 +07:00
|
|
|
grunt.initConfig({
|
2017-10-07 05:09:42 +07:00
|
|
|
env: {
|
|
|
|
"env-test-server-unit": {
|
2018-04-27 04:20:10 +07:00
|
|
|
TS_NODE_PROJECT: "server/tsconfig.json"
|
2017-10-07 05:09:42 +07:00
|
|
|
},
|
|
|
|
"env-test-client-unit": {
|
2018-04-27 04:20:10 +07:00
|
|
|
TS_NODE_PROJECT: "client/tsconfig.json"
|
2018-10-27 23:18:25 +07:00
|
|
|
},
|
|
|
|
"env-test-shared-unit": {
|
|
|
|
TS_NODE_PROJECT: "server/tsconfig.json"
|
2017-10-07 05:09:42 +07:00
|
|
|
}
|
|
|
|
},
|
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']
|
|
|
|
},
|
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
|
|
|
"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",
|
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']
|
|
|
|
},
|
2017-10-07 05:09:42 +07:00
|
|
|
"test-client-unit": {
|
2017-07-14 05:25:11 +07:00
|
|
|
cmd: "./node_modules/.bin/mocha",
|
2018-07-08 22:02:28 +07:00
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'client/test/**/*.test.ts']
|
2017-07-14 05:25:11 +07:00
|
|
|
},
|
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
|
|
|
},
|
|
|
|
"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-11 04:03:30 +07:00
|
|
|
args: ["-i", "s/authelia.\(js\|css\)/authelia.min.\1/", `${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
|
|
|
},
|
2017-10-11 02:59:20 +07:00
|
|
|
schema: {
|
|
|
|
src: schemaDir,
|
|
|
|
dest: `${buildDir}/${schemaDir}`
|
|
|
|
}
|
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
|
|
|
|
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'])
|
2018-04-27 04:20:10 +07:00
|
|
|
grunt.registerTask('test-client', ['env:env-test-client-unit', 'run:test-client-unit'])
|
2018-10-27 23:18:25 +07:00
|
|
|
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
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('copy-resources', ['copy:resources', 'copy:views', 'copy:images', 'copy:thirdparties', 'concat:css']);
|
2017-10-11 02:59:20 +07:00
|
|
|
grunt.registerTask('generate-config-schema', ['run:generate-config-schema', 'copy:schema']);
|
2017-05-13 23:12:26 +07:00
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
grunt.registerTask('build-client', ['compile-client', 'browserify']);
|
2017-10-11 02:59:20 +07:00
|
|
|
grunt.registerTask('build-server', ['compile-server', 'copy-resources', 'generate-config-schema']);
|
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']);
|
|
|
|
|
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']);
|
|
|
|
|
|
|
|
grunt.registerTask('default', ['build-dist']);
|
2017-05-13 23:12:26 +07:00
|
|
|
};
|