Introduce authelia-cli to ease development cycle.

This commit is contained in:
Clement Michaud 2019-01-26 17:15:35 +01:00
parent 317611b099
commit 1bc0029651
9 changed files with 91 additions and 2880 deletions

View File

@ -15,4 +15,4 @@ VOLUME /usr/app/src
VOLUME /etc/authelia VOLUME /etc/authelia
VOLUME /var/lib/authelia VOLUME /var/lib/authelia
CMD ["npm", "run-script", "start"] CMD ["./node_modules/.bin/nodemon", "-e", "yml,js,ts,json", "--exec", "./scripts/run-dev-server.sh"]

View File

@ -1,46 +1,28 @@
module.exports = function (grunt) { module.exports = function (grunt) {
const buildDir = "dist"; const buildDir = "dist";
const schemaDir = "server/src/lib/configuration/Configuration.schema.json" const schemaDir = "server/src/lib/configuration/Configuration.schema.json"
var theme = grunt.option('theme') || 'default';
grunt.initConfig({ grunt.initConfig({
env: {
"env-test-server-unit": {
TS_NODE_PROJECT: "server/tsconfig.json"
},
"env-test-client-unit": {
TS_NODE_PROJECT: "client/tsconfig.json"
},
"env-test-shared-unit": {
TS_NODE_PROJECT: "server/tsconfig.json"
}
},
clean: { clean: {
dist: ['dist'], dist: ['dist'],
backup: ['backup'],
}, },
run: { run: {
"compile-server": { "compile-server": {
cmd: "./node_modules/.bin/tsc", cmd: "./node_modules/.bin/tsc",
args: ['-p', 'server/tsconfig.json'] args: ['-p', 'server/tsconfig.json']
}, },
"compile-client": {
exec: 'cd ./client && npm run build && mv build ../dist/client',
},
"generate-config-schema": { "generate-config-schema": {
cmd: "./node_modules/.bin/typescript-json-schema", cmd: "./node_modules/.bin/typescript-json-schema",
args: ["-o", schemaDir, "--strictNullChecks", args: ["-o", schemaDir, "--strictNullChecks",
"--required", "server/tsconfig.json", "Configuration"] "--required", "server/tsconfig.json", "Configuration"]
}, },
"compile-client": {
cmd: "./node_modules/.bin/tsc",
args: ['-p', 'client/tsconfig.json']
},
"lint-server": { "lint-server": {
cmd: "./node_modules/.bin/tslint", cmd: "./node_modules/.bin/tslint",
args: ['-c', 'server/tslint.json', '-p', 'server/tsconfig.json'] args: ['-c', 'server/tslint.json', '-p', 'server/tsconfig.json']
}, },
"lint-client": {
cmd: "./node_modules/.bin/tslint",
args: ['-c', 'client/tslint.json', '-p', 'client/tsconfig.json']
},
"test-server-unit": { "test-server-unit": {
cmd: "./node_modules/.bin/mocha", cmd: "./node_modules/.bin/mocha",
args: ['--colors', '--require', 'ts-node/register', 'server/src/**/*.spec.ts'] args: ['--colors', '--require', 'ts-node/register', 'server/src/**/*.spec.ts']
@ -49,10 +31,6 @@ module.exports = function (grunt) {
cmd: "./node_modules/.bin/mocha", cmd: "./node_modules/.bin/mocha",
args: ['--colors', '--require', 'ts-node/register', 'shared/**/*.spec.ts'] args: ['--colors', '--require', 'ts-node/register', 'shared/**/*.spec.ts']
}, },
"test-client-unit": {
cmd: "./node_modules/.bin/mocha",
args: ['--colors', '--require', 'ts-node/register', 'client/test/**/*.test.ts']
},
"test-cucumber": { "test-cucumber": {
cmd: "./scripts/run-cucumber.sh", cmd: "./scripts/run-cucumber.sh",
args: ["./test/features"] args: ["./test/features"]
@ -73,18 +51,10 @@ module.exports = function (grunt) {
cmd: "docker", cmd: "docker",
args: ['build', '-t', 'clems4ever/authelia', '.'] args: ['build', '-t', 'clems4ever/authelia', '.']
}, },
"minify": {
cmd: "./node_modules/.bin/uglifyjs",
args: [`${buildDir}/server/src/public_html/js/authelia.js`, '-o', `${buildDir}/server/src/public_html/js/authelia.min.js`]
},
"apidoc": { "apidoc": {
cmd: "./node_modules/.bin/apidoc", cmd: "./node_modules/.bin/apidoc",
args: ["-i", "src/server", "-o", "doc"] args: ["-i", "src/server", "-o", "doc"]
}, },
"include-minified-script": {
cmd: "sed",
args: ["-i", "s/authelia.\(js\|css\)/authelia.min.\1/", `${buildDir}/server/src/views/layout/layout.pug`]
}
}, },
copy: { copy: {
backup: { backup: {
@ -96,151 +66,38 @@ module.exports = function (grunt) {
}, },
resources: { resources: {
expand: true, expand: true,
cwd: 'themes/' + theme + '/server/src/resources', cwd: 'server/src/resources',
src: '**', src: '**',
dest: `${buildDir}/server/src/resources/` dest: `${buildDir}/server/src/resources/`
}, },
views: {
expand: true,
cwd: 'themes/' + theme + '/server/src/views',
src: '**',
dest: `${buildDir}/server/src/views/`
},
images: {
expand: true,
cwd: 'themes/' + theme + '/client/src/img',
src: '**',
dest: `${buildDir}/server/src/public_html/img/`
},
thirdparties: {
expand: true,
cwd: 'themes/' + theme + '/client/src/thirdparties',
src: '**',
dest: `${buildDir}/server/src/public_html/js/`
},
schema: { schema: {
src: schemaDir, src: schemaDir,
dest: `${buildDir}/${schemaDir}` dest: `${buildDir}/${schemaDir}`
} }
}, },
browserify: {
dist: {
src: ['dist/client/src/index.js'],
dest: `${buildDir}/server/src/public_html/js/authelia.js`,
options: {
browserifyOptions: {
standalone: 'authelia'
},
},
},
},
watch: {
views: {
files: ['server/src/views/**/*.pug'],
tasks: ['copy:views'],
options: {
interrupt: false,
atBegin: true
}
},
resources: {
files: ['server/src/resources/*.ejs'],
tasks: ['copy:resources'],
options: {
interrupt: false,
atBegin: true
}
},
images: {
files: ['client/src/img/**'],
tasks: ['copy:images'],
options: {
interrupt: false,
atBegin: true
}
},
css: {
files: ['client/src/**/*.css'],
tasks: ['concat:css', 'cssmin'],
options: {
interrupt: true,
atBegin: true
}
},
client: {
files: ['client/src/**/*.ts'],
tasks: ['build-dev'],
options: {
interrupt: true,
atBegin: true
}
},
server: {
files: ['server/src/**/*.ts'],
tasks: ['build-dev', 'run:docker-restart', 'run:make-dev-views' ],
options: {
interrupt: true,
atBegin: true
}
}
},
concat: {
css: {
src: ['themes/' + theme + '/client/src/css/*.css'],
dest: `${buildDir}/server/src/public_html/css/authelia.css`
},
},
cssmin: {
target: {
files: {
[`${buildDir}/server/src/public_html/css/authelia.min.css`]: [`${buildDir}/server/src/public_html/css/authelia.css`]
}
}
}
}); });
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-run'); grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-env');
grunt.registerTask('compile-server', ['run:lint-server', 'run:compile-server']) grunt.registerTask('compile-server', ['run:lint-server', 'run:compile-server'])
grunt.registerTask('compile-client', ['run:lint-client', 'run:compile-client']) grunt.registerTask('compile-client', ['run:lint-client', 'run:compile-client'])
grunt.registerTask('test-server', ['env:env-test-server-unit', 'run:test-server-unit']) grunt.registerTask('test-server', ['env:env-test-server-unit', 'run:test-server-unit'])
grunt.registerTask('test-shared', ['env:env-test-shared-unit', 'run:test-shared-unit']) grunt.registerTask('test-shared', ['env:env-test-shared-unit', 'run:test-shared-unit'])
grunt.registerTask('test-client', ['env:env-test-client-unit', 'run:test-client-unit'])
grunt.registerTask('test-unit', ['test-server', 'test-client', 'test-shared']); grunt.registerTask('test-unit', ['test-server', 'test-client', 'test-shared']);
grunt.registerTask('test-int', ['run:test-cucumber', 'run:test-minimal-config', 'run:test-complete-config', 'run:test-inactivity']); grunt.registerTask('test-int', ['run:test-cucumber', 'run:test-minimal-config', 'run:test-complete-config', 'run:test-inactivity']);
grunt.registerTask('copy-resources', ['copy:resources', 'copy:views', 'copy:images', 'copy:thirdparties', 'concat:css']);
grunt.registerTask('generate-config-schema', ['run:generate-config-schema', 'copy:schema']); grunt.registerTask('generate-config-schema', ['run:generate-config-schema', 'copy:schema']);
grunt.registerTask('build-client', ['compile-client', 'browserify']); grunt.registerTask('build-client', ['compile-client', 'browserify']);
grunt.registerTask('build-server', ['compile-server', 'copy-resources', 'generate-config-schema']); grunt.registerTask('build-server', ['compile-server', 'copy:resources', 'generate-config-schema']);
grunt.registerTask('build', ['build-client', 'build-server']); 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']); grunt.registerTask('build-dist', ['clean:dist', 'build']);
grunt.registerTask('schema', ['run:generate-config-schema']) grunt.registerTask('schema', ['run:generate-config-schema'])
grunt.registerTask('docker-build', ['run:docker-build']); grunt.registerTask('docker-build', ['run:docker-build']);
grunt.registerTask('check', function() {
if ((theme != 'default') && (theme != 'black') && (theme != 'matrix') && (theme != 'squares') && (theme != 'triangles')) {
grunt.warn('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');
}
});
grunt.registerTask('default', ['check', 'build-dist']);
}; };

View File

@ -10,6 +10,6 @@ services:
- ./client/src:/usr/app/client/src - ./client/src:/usr/app/client/src
- ./client/.env.development:/usr/app/client/.env.development - ./client/.env.development:/usr/app/client/.env.development
networks: networks:
example-network: authelianet:
aliases: aliases:
- authelia-frontend - authelia-frontend

View File

@ -20,7 +20,6 @@
"await-to-js": "^2.1.1", "await-to-js": "^2.1.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"connected-react-router": "^6.2.1", "connected-react-router": "^6.2.1",
"jss": "^9.8.7",
"node-sass": "^4.11.0", "node-sass": "^4.11.0",
"qrcode.react": "^0.9.2", "qrcode.react": "^0.9.2",
"query-string": "^6.2.0", "query-string": "^6.2.0",
@ -37,7 +36,7 @@
}, },
"scripts": { "scripts": {
"start": "SASS_PATH=./node_modules react-scripts start", "start": "SASS_PATH=./node_modules react-scripts start",
"build": "SASS_PATH=./node_modules react-scripts build", "build": "INLINE_RUNTIME_CHUNK=false SASS_PATH=./node_modules react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"
}, },

View File

@ -1,4 +1,6 @@
version: '2' version: '2'
networks: networks:
authelianet:
external: true
example-network: example-network:
driver: bridge driver: bridge

2754
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,10 +6,10 @@
"authelia": "./dist/server/src/index.js" "authelia": "./dist/server/src/index.js"
}, },
"scripts": { "scripts": {
"start": "./node_modules/.bin/nodemon -e js,ts,json --exec ./scripts/run-dev-server.sh", "start": "./scripts/authelia-cli start",
"build": "echo build",
"test": "./node_modules/.bin/grunt test-unit", "test": "./node_modules/.bin/grunt test-unit",
"cover": "NODE_ENV=test nyc npm t", "cover": "NODE_ENV=test nyc npm t"
"serve": "node dist/server/index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -41,7 +41,6 @@
"nodemailer-direct-transport": "^3.3.2", "nodemailer-direct-transport": "^3.3.2",
"nodemailer-smtp-transport": "^2.7.4", "nodemailer-smtp-transport": "^2.7.4",
"object-path": "^0.11.3", "object-path": "^0.11.3",
"pug": "^2.0.0-rc.2",
"randomatic": "^3.1.0", "randomatic": "^3.1.0",
"randomstring": "^1.1.5", "randomstring": "^1.1.5",
"redis": "^2.8.0", "redis": "^2.8.0",
@ -54,16 +53,12 @@
"devDependencies": { "devDependencies": {
"@types/bluebird": "^3.5.4", "@types/bluebird": "^3.5.4",
"@types/body-parser": "^1.16.3", "@types/body-parser": "^1.16.3",
"@types/bootstrap": "^4.0.1",
"@types/connect-redis": "0.0.7", "@types/connect-redis": "0.0.7",
"@types/cors": "^2.8.1",
"@types/cucumber": "^4.0.1", "@types/cucumber": "^4.0.1",
"@types/ejs": "^2.3.33", "@types/ejs": "^2.3.33",
"@types/express": "^4.0.35", "@types/express": "^4.0.35",
"@types/express-session": "1.15.8", "@types/express-session": "1.15.8",
"@types/helmet": "0.0.37", "@types/helmet": "0.0.37",
"@types/jquery": "^3.3.1",
"@types/jsdom": "^11.0.4",
"@types/ldapjs": "^1.0.3", "@types/ldapjs": "^1.0.3",
"@types/mocha": "^5.0.0", "@types/mocha": "^5.0.0",
"@types/mockdate": "^2.0.0", "@types/mockdate": "^2.0.0",
@ -73,7 +68,6 @@
"@types/nodemailer-direct-transport": "^1.0.31", "@types/nodemailer-direct-transport": "^1.0.31",
"@types/nodemailer-smtp-transport": "^2.7.4", "@types/nodemailer-smtp-transport": "^2.7.4",
"@types/object-path": "^0.9.28", "@types/object-path": "^0.9.28",
"@types/proxyquire": "^1.3.27",
"@types/query-string": "^5.1.0", "@types/query-string": "^5.1.0",
"@types/randomstring": "^1.1.5", "@types/randomstring": "^1.1.5",
"@types/redis": "^2.6.0", "@types/redis": "^2.6.0",
@ -86,29 +80,19 @@
"@types/winston": "^2.3.2", "@types/winston": "^2.3.2",
"@types/yamljs": "^0.2.30", "@types/yamljs": "^0.2.30",
"apidoc": "^0.17.6", "apidoc": "^0.17.6",
"bootstrap": "^4.1.3",
"browserify": "^16.1.1",
"chromedriver": "^2.37.0", "chromedriver": "^2.37.0",
"commander": "^2.19.0",
"cucumber": "^4.0.0", "cucumber": "^4.0.0",
"grunt": "^1.0.3", "grunt": "^1.0.3",
"grunt-browserify": "^5.0.0",
"grunt-contrib-clean": "^2.0.0", "grunt-contrib-clean": "^2.0.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^2.2.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-env": "^0.4.4",
"grunt-run": "^0.8.0", "grunt-run": "^0.8.0",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"jquery": "^3.2.1", "jquery": "^3.2.1",
"js-logger": "^1.3.0",
"jsdom": "^11.0.0",
"mocha": "^5.0.5", "mocha": "^5.0.5",
"mockdate": "^2.0.1", "mockdate": "^2.0.1",
"nodemon": "^1.18.9", "nodemon": "^1.18.9",
"nyc": "^13.1.0", "nyc": "^13.1.0",
"power-assert": "^1.4.4",
"proxyquire": "^2.0.1",
"query-string": "^6.0.0", "query-string": "^6.0.0",
"readable-stream": "^2.3.3", "readable-stream": "^2.3.3",
"request": "^2.88.0", "request": "^2.88.0",
@ -120,8 +104,7 @@
"ts-node": "^6.0.1", "ts-node": "^6.0.1",
"tslint": "^5.2.0", "tslint": "^5.2.0",
"typescript": "^2.3.2", "typescript": "^2.3.2",
"typescript-json-schema": "^0.23.0", "typescript-json-schema": "^0.23.0"
"uglify-es": "^3.0.15"
}, },
"nyc": { "nyc": {
"include": [ "include": [

11
scripts/authelia-cli Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env node
var program = require('commander');
program
.version('0.1.0')
.command('start', 'Start development environment');
program.parse(process.argv);

13
scripts/authelia-cli-start Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
bridge_exists=`docker network ls | grep " authelianet " | wc -l`
if [ "$bridge_exists" != "1" ];
then
docker network create -d bridge --subnet 192.168.240.0/24 --gateway 192.168.240.1 authelianet
else
echo "Bridge authelianet already exist."
fi
./scripts/dc-dev.sh build && ./scripts/dc-dev.sh up -d