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"
|
2018-12-18 15:30:23 +00:00
|
|
|
var theme = grunt.option('theme') || 'default';
|
|
|
|
|
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-18 15:30:23 +00:00
|
|
|
clean: {
|
|
|
|
dist: ['dist'],
|
|
|
|
backup: ['backup'],
|
|
|
|
},
|
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-18 15:30:23 +00:00
|
|
|
backup: {
|
|
|
|
files: [{
|
2018-12-17 21:49:01 +00:00
|
|
|
expand: true,
|
2018-12-18 15:30:23 +00:00
|
|
|
src: ['dist/**'],
|
|
|
|
dest: 'backup'
|
|
|
|
}]
|
2018-12-17 21:49:01 +00:00
|
|
|
},
|
2018-12-18 15:30:23 +00:00
|
|
|
resources: {
|
2018-12-17 21:49:01 +00:00
|
|
|
expand: true,
|
2018-12-18 15:30:23 +00:00
|
|
|
cwd: 'themes/' + theme + '/server/src/resources',
|
2018-12-17 21:49:01 +00:00
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/resources/`
|
|
|
|
},
|
2018-12-18 15:30:23 +00:00
|
|
|
views: {
|
2018-12-17 21:49:01 +00:00
|
|
|
expand: true,
|
2018-12-18 15:30:23 +00:00
|
|
|
cwd: 'themes/' + theme + '/server/src/views',
|
2018-12-17 21:49:01 +00:00
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/views/`
|
|
|
|
},
|
2018-12-18 15:30:23 +00:00
|
|
|
images: {
|
2018-12-17 21:49:01 +00:00
|
|
|
expand: true,
|
2018-12-18 15:30:23 +00:00
|
|
|
cwd: 'themes/' + theme + '/client/src/img',
|
2018-12-17 21:49:01 +00:00
|
|
|
src: '**',
|
|
|
|
dest: `${buildDir}/server/src/public_html/img/`
|
|
|
|
},
|
2018-12-18 15:30:23 +00:00
|
|
|
thirdparties: {
|
2018-12-17 21:49:01 +00:00
|
|
|
expand: true,
|
2018-12-18 15:30:23 +00:00
|
|
|
cwd: 'themes/' + theme + '/client/src/thirdparties',
|
2018-12-18 07:32:04 +00:00
|
|
|
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-18 15:30:23 +00:00
|
|
|
css: {
|
|
|
|
src: ['themes/' + theme + '/client/src/css/*.css'],
|
2018-12-18 07:32:04 +00:00
|
|
|
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
|
|
|
|
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-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-18 15:30:23 +00:00
|
|
|
grunt.registerTask('copy-resources', ['copy:resources', 'copy:views', 'copy:images', 'copy:thirdparties', 'concat:css']);
|
2018-12-18 07:32:04 +00:00
|
|
|
|
|
|
|
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-18 15:30:23 +00:00
|
|
|
|
|
|
|
grunt.registerTask('build-server', ['compile-server', 'copy-resources', 'generate-config-schema']);
|
2018-12-18 07:32:04 +00:00
|
|
|
|
2018-12-18 15:30:23 +00:00
|
|
|
grunt.registerTask('build', ['build-client', 'build-server']);
|
|
|
|
grunt.registerTask('build-dist', ['clean:backup', 'copy:backup', 'clean:dist', 'build', 'run:minify', 'cssmin', 'run:include-minified-script']);
|
2018-12-17 22:27:58 +00:00
|
|
|
|
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']);
|
2018-12-18 15:30:23 +00:00
|
|
|
|
|
|
|
grunt.registerTask('check', function() {
|
|
|
|
if (grunt.option('theme') == 'undefined') {
|
|
|
|
grunt.log.writeln('1- Valid argmuents are just "grunt" (will use default) or "grunt --theme=|default|black|matrix|squares|triangles"');
|
|
|
|
}
|
|
|
|
if ((theme != 'default') && (theme != 'black') && (theme != 'matrix') && (theme != 'squares') && (theme != 'triangles')) {
|
|
|
|
grunt.warn('2- Valid argmuents are just "grunt" (will use default) or "grunt --theme=|default|black|matrix|squares|triangles"');
|
|
|
|
}
|
|
|
|
if (grunt.option('theme') == 'default' || 'black' || 'matrix' || 'squares' || 'triangles') {
|
|
|
|
grunt.log.ok();
|
|
|
|
grunt.log.writeln('Building "'+ theme +'" theme');
|
|
|
|
}
|
|
|
|
});
|
2017-10-06 22:09:42 +00:00
|
|
|
|
2018-12-18 15:30:23 +00:00
|
|
|
grunt.registerTask('default', ['check', 'build-dist']);
|
2017-05-13 16:12:26 +00:00
|
|
|
};
|