2017-05-25 13:09:29 +00:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
const buildDir = "dist";
|
2017-10-10 19:59:20 +00:00
|
|
|
const schemaDir = "server/src/lib/configuration/Configuration.schema.json"
|
2017-05-25 13:09:29 +00:00
|
|
|
|
2017-05-13 16:12:26 +00:00
|
|
|
grunt.initConfig({
|
2017-10-06 22:09:42 +00:00
|
|
|
env: {
|
|
|
|
"env-test-server-unit": {
|
2018-04-26 21:20:10 +00:00
|
|
|
TS_NODE_PROJECT: "server/tsconfig.json"
|
2017-10-06 22:09:42 +00:00
|
|
|
},
|
|
|
|
"env-test-client-unit": {
|
2018-04-26 21:20:10 +00:00
|
|
|
TS_NODE_PROJECT: "client/tsconfig.json"
|
2018-10-27 16:18:25 +00:00
|
|
|
},
|
|
|
|
"env-test-shared-unit": {
|
|
|
|
TS_NODE_PROJECT: "server/tsconfig.json"
|
2017-10-06 22:09:42 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-17 22:27:58 +00:00
|
|
|
clean: ['dist'],
|
2017-05-13 16:12:26 +00:00
|
|
|
run: {
|
2017-10-06 22:09:42 +00:00
|
|
|
"compile-server": {
|
|
|
|
cmd: "./node_modules/.bin/tsc",
|
|
|
|
args: ['-p', 'server/tsconfig.json']
|
|
|
|
},
|
2017-10-09 23:14:36 +00:00
|
|
|
"generate-config-schema": {
|
|
|
|
cmd: "./node_modules/.bin/typescript-json-schema",
|
2017-10-10 19:59:20 +00:00
|
|
|
args: ["-o", schemaDir, "--strictNullChecks",
|
2018-07-08 15:02:28 +00:00
|
|
|
"--required", "server/tsconfig.json", "Configuration"]
|
2017-10-09 23:14:36 +00:00
|
|
|
},
|
2017-10-06 22:09:42 +00:00
|
|
|
"compile-client": {
|
2017-06-28 13:57:58 +00:00
|
|
|
cmd: "./node_modules/.bin/tsc",
|
2017-10-06 22:09:42 +00: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 16:12:26 +00:00
|
|
|
},
|
2017-10-06 22:09:42 +00:00
|
|
|
"lint-client": {
|
2017-06-28 13:57:58 +00:00
|
|
|
cmd: "./node_modules/.bin/tslint",
|
2017-10-06 22:09:42 +00:00
|
|
|
args: ['-c', 'client/tslint.json', '-p', 'client/tsconfig.json']
|
|
|
|
},
|
|
|
|
"test-server-unit": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
2018-07-08 15:02:28 +00:00
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'server/src/**/*.spec.ts']
|
2017-05-13 16:12:26 +00:00
|
|
|
},
|
2018-10-27 16:18:25 +00:00
|
|
|
"test-shared-unit": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'shared/**/*.spec.ts']
|
|
|
|
},
|
2017-10-06 22:09:42 +00:00
|
|
|
"test-client-unit": {
|
2017-07-13 22:25:11 +00:00
|
|
|
cmd: "./node_modules/.bin/mocha",
|
2018-07-08 15:02:28 +00:00
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'client/test/**/*.test.ts']
|
2017-07-13 22:25:11 +00:00
|
|
|
},
|
2018-08-09 20:24:02 +00:00
|
|
|
"test-cucumber": {
|
2017-10-16 22:38:10 +00:00
|
|
|
cmd: "./scripts/run-cucumber.sh",
|
|
|
|
args: ["./test/features"]
|
2017-07-16 12:55:01 +00:00
|
|
|
},
|
2018-08-19 14:51:36 +00:00
|
|
|
"test-complete-config": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'test/complete-config/**/*.ts']
|
|
|
|
},
|
2018-08-09 20:24:02 +00:00
|
|
|
"test-minimal-config": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'test/minimal-config/**/*.ts']
|
|
|
|
},
|
2018-10-22 07:35:06 +00:00
|
|
|
"test-inactivity": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'test/inactivity/**/*.ts']
|
|
|
|
},
|
2017-05-13 16:32:25 +00:00
|
|
|
"docker-build": {
|
|
|
|
cmd: "docker",
|
|
|
|
args: ['build', '-t', 'clems4ever/authelia', '.']
|
2017-05-25 13:09:29 +00:00
|
|
|
},
|
|
|
|
"minify": {
|
|
|
|
cmd: "./node_modules/.bin/uglifyjs",
|
2017-10-06 22:09:42 +00:00
|
|
|
args: [`${buildDir}/server/src/public_html/js/authelia.js`, '-o', `${buildDir}/server/src/public_html/js/authelia.min.js`]
|
2017-05-25 13:09:29 +00:00
|
|
|
},
|
|
|
|
"apidoc": {
|
|
|
|
cmd: "./node_modules/.bin/apidoc",
|
|
|
|
args: ["-i", "src/server", "-o", "doc"]
|
2017-06-14 21:34:11 +00:00
|
|
|
},
|
2017-10-06 22:09:42 +00:00
|
|
|
"include-minified-script": {
|
2017-06-14 21:34:11 +00:00
|
|
|
cmd: "sed",
|
2017-10-10 21:03:30 +00:00
|
|
|
args: ["-i", "s/authelia.\(js\|css\)/authelia.min.\1/", `${buildDir}/server/src/views/layout/layout.pug`]
|
2017-05-13 16:12:26 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
copy: {
|
2018-12-17 21:49:01 +00:00
|
|
|
main_resources: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/main/server/src/resources',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/resources/`
|
|
|
|
},
|
|
|
|
main_views: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/main/server/src/views',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/views/`
|
|
|
|
},
|
|
|
|
main_images: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/main/client/src/img',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/img/`
|
|
|
|
},
|
|
|
|
main_thirdparties: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/main/client/src/thirdparties',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/js/`
|
|
|
|
},
|
|
|
|
matrix_resources: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/matrix/server/src/resources',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/resources/`
|
|
|
|
},
|
|
|
|
matrix_views: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/matrix/server/src/views',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/views/`
|
|
|
|
},
|
|
|
|
matrix_images: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/matrix/client/src/img',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/img/`
|
|
|
|
},
|
|
|
|
matrix_thirdparties: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/matrix/client/src/thirdparties',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/js/`
|
|
|
|
},
|
2018-12-18 06:47:07 +00:00
|
|
|
black_resources: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/black/server/src/resources',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/resources/`
|
|
|
|
},
|
|
|
|
black_views: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/black/server/src/views',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/views/`
|
|
|
|
},
|
|
|
|
black_images: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/black/client/src/img',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/img/`
|
|
|
|
},
|
|
|
|
black_thirdparties: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/black/client/src/thirdparties',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/js/`
|
|
|
|
},
|
2018-12-18 07:32:04 +00:00
|
|
|
squares_resources: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/squares/server/src/resources',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/resources/`
|
|
|
|
},
|
|
|
|
squares_views: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/squares/server/src/views',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/views/`
|
|
|
|
},
|
|
|
|
squares_images: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/squares/client/src/img',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/img/`
|
|
|
|
},
|
|
|
|
squares_thirdparties: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/squares/client/src/thirdparties',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/js/`
|
|
|
|
},
|
|
|
|
triangles_resources: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/triangles/server/src/resources',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/resources/`
|
|
|
|
},
|
|
|
|
triangles_views: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/triangles/server/src/views',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/views/`
|
|
|
|
},
|
|
|
|
triangles_images: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/triangles/client/src/img',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/img/`
|
|
|
|
},
|
|
|
|
triangles_thirdparties: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'themes/triangles/client/src/thirdparties',
|
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/js/`
|
|
|
|
},
|
2018-12-17 21:49:01 +00:00
|
|
|
schema: {
|
|
|
|
src: schemaDir,
|
|
|
|
dest: `${buildDir}/${schemaDir}`
|
|
|
|
}
|
2017-05-25 13:09:29 +00:00
|
|
|
},
|
|
|
|
browserify: {
|
|
|
|
dist: {
|
2017-10-06 22:09:42 +00:00
|
|
|
src: ['dist/client/src/index.js'],
|
|
|
|
dest: `${buildDir}/server/src/public_html/js/authelia.js`,
|
2017-05-25 13:09:29 +00:00
|
|
|
options: {
|
|
|
|
browserifyOptions: {
|
|
|
|
standalone: 'authelia'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
views: {
|
2017-10-06 22:09:42 +00:00
|
|
|
files: ['server/src/views/**/*.pug'],
|
2017-05-25 13:09:29 +00:00
|
|
|
tasks: ['copy:views'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
resources: {
|
2017-10-06 22:09:42 +00:00
|
|
|
files: ['server/src/resources/*.ejs'],
|
2017-05-25 13:09:29 +00:00
|
|
|
tasks: ['copy:resources'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
images: {
|
2017-10-06 22:09:42 +00:00
|
|
|
files: ['client/src/img/**'],
|
2017-05-25 13:09:29 +00:00
|
|
|
tasks: ['copy:images'],
|
|
|
|
options: {
|
|
|
|
interrupt: false,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
2017-10-06 22:09:42 +00:00
|
|
|
files: ['client/src/**/*.css'],
|
2017-05-25 13:09:29 +00:00
|
|
|
tasks: ['concat:css', 'cssmin'],
|
|
|
|
options: {
|
|
|
|
interrupt: true,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
client: {
|
2017-10-06 22:09:42 +00:00
|
|
|
files: ['client/src/**/*.ts'],
|
2017-07-02 20:24:51 +00:00
|
|
|
tasks: ['build-dev'],
|
2017-05-25 13:09:29 +00:00
|
|
|
options: {
|
|
|
|
interrupt: true,
|
|
|
|
atBegin: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
server: {
|
2017-10-06 22:09:42 +00:00
|
|
|
files: ['server/src/**/*.ts'],
|
2017-07-02 20:24:51 +00:00
|
|
|
tasks: ['build-dev', 'run:docker-restart', 'run:make-dev-views' ],
|
2017-05-25 13:09:29 +00:00
|
|
|
options: {
|
|
|
|
interrupt: true,
|
2017-07-02 20:24:51 +00:00
|
|
|
atBegin: true
|
2017-05-25 13:09:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
concat: {
|
2018-12-17 21:49:01 +00:00
|
|
|
main_css: {
|
|
|
|
src: ['themes/main/client/src/css/*.css'],
|
|
|
|
dest: `${buildDir}/server/src/public_html/css/authelia.css`
|
|
|
|
},
|
|
|
|
matrix_css: {
|
|
|
|
src: ['themes/matrix/client/src/css/*.css'],
|
2017-10-06 22:09:42 +00:00
|
|
|
dest: `${buildDir}/server/src/public_html/css/authelia.css`
|
2017-05-25 13:09:29 +00:00
|
|
|
},
|
2018-12-18 06:47:07 +00:00
|
|
|
black_css: {
|
|
|
|
src: ['themes/black/client/src/css/*.css'],
|
|
|
|
dest: `${buildDir}/server/src/public_html/css/authelia.css`
|
|
|
|
},
|
2018-12-18 07:32:04 +00:00
|
|
|
squares_css: {
|
|
|
|
src: ['themes/squares/client/src/css/*.css'],
|
|
|
|
dest: `${buildDir}/server/src/public_html/css/authelia.css`
|
|
|
|
},
|
|
|
|
triangles_css: {
|
|
|
|
src: ['themes/triangles/client/src/css/*.css'],
|
|
|
|
dest: `${buildDir}/server/src/public_html/css/authelia.css`
|
|
|
|
},
|
2017-05-25 13:09:29 +00:00
|
|
|
},
|
|
|
|
cssmin: {
|
|
|
|
target: {
|
|
|
|
files: {
|
2017-10-06 22:09:42 +00:00
|
|
|
[`${buildDir}/server/src/public_html/css/authelia.min.css`]: [`${buildDir}/server/src/public_html/css/authelia.css`]
|
2017-05-25 13:09:29 +00:00
|
|
|
}
|
2017-05-13 16:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-12-17 21:49:01 +00:00
|
|
|
var target = grunt.option('target') || 'main';
|
|
|
|
|
2017-05-25 13:09:29 +00: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');
|
2018-12-17 22:27:58 +00:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
2017-05-13 16:12:26 +00:00
|
|
|
grunt.loadNpmTasks('grunt-run');
|
2017-10-06 22:09:42 +00:00
|
|
|
grunt.loadNpmTasks('grunt-env');
|
2017-05-13 16:12:26 +00:00
|
|
|
|
2017-06-14 21:34:11 +00:00
|
|
|
|
2017-10-06 22:09:42 +00:00
|
|
|
grunt.registerTask('compile-server', ['run:lint-server', 'run:compile-server'])
|
|
|
|
grunt.registerTask('compile-client', ['run:lint-client', 'run:compile-client'])
|
2017-05-13 16:32:25 +00:00
|
|
|
|
2018-04-26 21:20:10 +00:00
|
|
|
grunt.registerTask('test-server', ['env:env-test-server-unit', 'run:test-server-unit'])
|
2018-10-27 16:18:25 +00:00
|
|
|
grunt.registerTask('test-shared', ['env:env-test-shared-unit', 'run:test-shared-unit'])
|
2018-04-26 21:20:10 +00:00
|
|
|
grunt.registerTask('test-client', ['env:env-test-client-unit', 'run:test-client-unit'])
|
2018-10-27 16:18:25 +00:00
|
|
|
grunt.registerTask('test-unit', ['test-server', 'test-client', 'test-shared']);
|
2018-10-22 07:35:06 +00:00
|
|
|
grunt.registerTask('test-int', ['run:test-cucumber', 'run:test-minimal-config', 'run:test-complete-config', 'run:test-inactivity']);
|
2017-05-25 13:09:29 +00:00
|
|
|
|
2018-12-17 21:49:01 +00:00
|
|
|
grunt.registerTask('copy-resources-main', ['copy:main_resources', 'copy:main_views', 'copy:main_images', 'copy:main_thirdparties', 'concat:main_css']);
|
2017-05-13 16:12:26 +00:00
|
|
|
|
2018-12-17 21:49:01 +00:00
|
|
|
grunt.registerTask('copy-resources-matrix', ['copy:matrix_resources', 'copy:matrix_views', 'copy:matrix_images', 'copy:matrix_thirdparties', 'concat:matrix_css']);
|
|
|
|
|
2018-12-18 06:47:07 +00:00
|
|
|
grunt.registerTask('copy-resources-black', ['copy:black_resources', 'copy:black_views', 'copy:black_images', 'copy:black_thirdparties', 'concat:black_css']);
|
2018-12-18 07:32:04 +00:00
|
|
|
|
|
|
|
grunt.registerTask('copy-resources-squares', ['copy:squares_resources', 'copy:squares_views', 'copy:squares_images', 'copy:squares_thirdparties', 'concat:squares_css']);
|
|
|
|
|
|
|
|
grunt.registerTask('copy-resources-triangles', ['copy:triangles_resources', 'copy:triangles_views', 'copy:triangles_images', 'copy:triangles_thirdparties', 'concat:triangles_css']);
|
|
|
|
|
|
|
|
grunt.registerTask('generate-config-schema', ['run:generate-config-schema', 'copy:schema']);
|
2018-12-18 06:47:07 +00:00
|
|
|
|
2017-10-06 22:09:42 +00:00
|
|
|
grunt.registerTask('build-client', ['compile-client', 'browserify']);
|
2018-12-17 21:49:01 +00:00
|
|
|
grunt.registerTask('build-server-main', ['compile-server', 'copy-resources-main', 'generate-config-schema']);
|
|
|
|
grunt.registerTask('build-server-matrix', ['compile-server', 'copy-resources-matrix', 'generate-config-schema']);
|
2018-12-18 06:47:07 +00:00
|
|
|
grunt.registerTask('build-server-black', ['compile-server', 'copy-resources-black', 'generate-config-schema']);
|
2018-12-18 07:32:04 +00:00
|
|
|
grunt.registerTask('build-server-squares', ['compile-server', 'copy-resources-squares', 'generate-config-schema']);
|
|
|
|
grunt.registerTask('build-server-triangles', ['compile-server', 'copy-resources-triangles', 'generate-config-schema']);
|
|
|
|
|
2018-12-17 21:49:01 +00:00
|
|
|
grunt.registerTask('build', ['build-client', 'build-server-'+target]);
|
2018-12-17 22:27:58 +00:00
|
|
|
grunt.registerTask('build-dist', ['clean', 'build', 'run:minify', 'cssmin', 'run:include-minified-script']);
|
|
|
|
|
2017-10-16 22:35:34 +00:00
|
|
|
grunt.registerTask('schema', ['run:generate-config-schema'])
|
|
|
|
|
2017-10-06 22:09:42 +00:00
|
|
|
grunt.registerTask('docker-build', ['run:docker-build']);
|
|
|
|
|
|
|
|
grunt.registerTask('default', ['build-dist']);
|
2017-05-13 16:12:26 +00:00
|
|
|
};
|