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"
|
2017-10-06 22:09:42 +00:00
|
|
|
}
|
|
|
|
},
|
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
|
|
|
},
|
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-09 20:24:02 +00:00
|
|
|
"test-minimal-config": {
|
|
|
|
cmd: "./node_modules/.bin/mocha",
|
|
|
|
args: ['--colors', '--require', 'ts-node/register', 'test/minimal-config/**/*.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: {
|
|
|
|
resources: {
|
|
|
|
expand: true,
|
2017-10-06 22:09:42 +00:00
|
|
|
cwd: 'server/src/resources/',
|
2017-05-13 16:12:26 +00:00
|
|
|
src: '**',
|
2017-10-06 22:09:42 +00:00
|
|
|
dest: `${buildDir}/server/src/resources/`
|
2017-05-13 16:12:26 +00:00
|
|
|
},
|
|
|
|
views: {
|
|
|
|
expand: true,
|
2017-10-06 22:09:42 +00:00
|
|
|
cwd: 'server/src/views/',
|
2017-05-25 13:09:29 +00:00
|
|
|
src: '**',
|
2017-10-06 22:09:42 +00:00
|
|
|
dest: `${buildDir}/server/src/views/`
|
2017-05-25 13:09:29 +00:00
|
|
|
},
|
|
|
|
images: {
|
|
|
|
expand: true,
|
2017-10-06 22:09:42 +00:00
|
|
|
cwd: 'client/src/img',
|
2017-05-13 16:12:26 +00:00
|
|
|
src: '**',
|
2017-10-06 22:09:42 +00:00
|
|
|
dest: `${buildDir}/server/src/public_html/img/`
|
2017-05-13 16:12:26 +00:00
|
|
|
},
|
2017-05-25 13:09:29 +00:00
|
|
|
thirdparties: {
|
2017-05-13 16:12:26 +00:00
|
|
|
expand: true,
|
2017-10-06 22:09:42 +00:00
|
|
|
cwd: 'client/src/thirdparties',
|
2017-05-13 16:12:26 +00:00
|
|
|
src: '**',
|
2017-10-06 22:09:42 +00:00
|
|
|
dest: `${buildDir}/server/src/public_html/js/`
|
2017-05-25 13:09:29 +00:00
|
|
|
},
|
2017-10-10 19:59:20 +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: {
|
|
|
|
css: {
|
2017-10-06 22:09:42 +00:00
|
|
|
src: ['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
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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');
|
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'])
|
|
|
|
grunt.registerTask('test-client', ['env:env-test-client-unit', 'run:test-client-unit'])
|
2017-10-06 22:09:42 +00:00
|
|
|
grunt.registerTask('test-unit', ['test-server', 'test-client']);
|
2018-08-09 20:24:02 +00:00
|
|
|
grunt.registerTask('test-int', ['run:test-cucumber', 'run:test-minimal-config']);
|
2017-05-25 13:09:29 +00:00
|
|
|
|
2017-10-06 22:09:42 +00:00
|
|
|
grunt.registerTask('copy-resources', ['copy:resources', 'copy:views', 'copy:images', 'copy:thirdparties', 'concat:css']);
|
2017-10-10 19:59:20 +00:00
|
|
|
grunt.registerTask('generate-config-schema', ['run:generate-config-schema', 'copy:schema']);
|
2017-05-13 16:12:26 +00:00
|
|
|
|
2017-10-06 22:09:42 +00:00
|
|
|
grunt.registerTask('build-client', ['compile-client', 'browserify']);
|
2017-10-10 19:59:20 +00:00
|
|
|
grunt.registerTask('build-server', ['compile-server', 'copy-resources', 'generate-config-schema']);
|
2017-07-26 21:45:26 +00:00
|
|
|
|
2017-10-06 22:09:42 +00:00
|
|
|
grunt.registerTask('build', ['build-client', 'build-server']);
|
|
|
|
grunt.registerTask('build-dist', ['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
|
|
|
};
|