update: simplify config

This commit is contained in:
Clément 2018-12-17 15:20:36 +01:00
parent b840c2fdb6
commit d3c3d6d921
9 changed files with 58 additions and 23 deletions

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
/node_modules /node_modules
/src/config.pug /src/config.js
/www/index.html /www/index.html
/www/index.prod.html
/www/styles/ /www/styles/
/www/scripts/ /www/scripts/
/www/lib/ /www/lib/

View File

@ -9,7 +9,6 @@ default: build
clean: clean:
git clean -fXd -e !src/config.pug git clean -fXd -e !src/config.pug
install: node_modules copy_lib copy_samples submodules install: node_modules copy_lib copy_samples submodules
submodules: submodules:
@ -38,13 +37,24 @@ copy_lib:
@node copy_lib.js @node copy_lib.js
# samples # samples
copy_samples: copy_samples: src/config.json
@cp -n src/config.sample.pug src/config.pug
src/config.json:
@cp -n src/config.sample.json src/config.json
# pug # pug
$(DIST_DIR)/index.html: src/index.pug $(wildcard src/*.pug src/*/*.pug) $(DIST_DIR)/index.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
@echo pug: $< ➜ $@ @echo pug: $< ➜ $@
@node_modules/.bin/pug --pretty $< --out $(dir $@) || touch $@
@export ENV="dev"; \
node_modules/.bin/pug --pretty $< --out $(dir $@) -O src/config.json || touch $@
# pug (prod)
$(DIST_DIR)/index.prod.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
@echo pug: $< ➜ $@
@export ENV="prod"; \
node_modules/.bin/pug --pretty $< --out $(dir $@) -E prod.html -O src/config.json || touch $@
# sass # sass
$(DIST_DIR)/styles/index.css: src/styles/index.scss $(wildcard src/*.scss src/*/*.scss) $(DIST_DIR)/styles/index.css: src/styles/index.scss $(wildcard src/*.scss src/*/*.scss)
@ -58,16 +68,16 @@ $(DIST_DIR)/%.js: src/%.js .babelrc
@node_modules/.bin/babel $< --out-file $@ --source-maps || touch $@ @node_modules/.bin/babel $< --out-file $@ --source-maps || touch $@
buildprod: build buildprod: build
export SDN="https://test-paris.happy-dev.fr"; \ $(MAKE) $(DIST_DIR)/index.prod.html
$(MAKE) $(DIST_DIR)/index.html -B
deploy: pull install build deploy: pull install build
pull: pull:
git pull git pull
sync: sync: buildprod
rsync -rv www/* staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/ --exclude=www/oidc-client-config.json rsync -rv www/* staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/ --exclude=www/index.html --exclude=www/index.prod.html
rsync --no-R --no-implied-dirs www/index.prod.html staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/index.aaa.html
rsync -v www/.htaccess staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/ rsync -v www/.htaccess staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/
.PHONY: default install submodules copy_lib copy_samples build watch serve clean sync buildprod pull deploy .PHONY: default install submodules copy_lib copy_samples build watch serve clean sync buildprod pull deploy

View File

@ -1,4 +0,0 @@
- var sdn = process.env.SDN || 'https://test-paris.happy-dev.fr'
- var cdn = process.env.CDN || 'staging-app.happy-dev.fr'
- var xmpp = 'https://jabber.happy-dev.fr/http-bind/'
- var client_id = 833925

15
src/config.json Normal file
View File

@ -0,0 +1,15 @@
{
"dev": {
"sdn": "http://127.0.0.1:8000",
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://jabber.happy-dev.fr/http-bind/",
"client_id": "833925"
},
"prod": {
"sdn": "https://test-paris.happy-dev.fr",
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://jabber.happy-dev.fr/http-bind/",
"client_id": "833925"
}
}

View File

@ -1,4 +0,0 @@
- var sdn = process.env.SDN || 'http://127.0.0.1:8000'
- var cdn = process.env.CDN || 'staging-app.happy-dev.fr'
- var xmpp = 'https://jabber.happy-dev.fr/http-bind/'
- var client_id = 863031

15
src/config.sample.json Normal file
View File

@ -0,0 +1,15 @@
{
"dev": {
"sdn": "http://127.0.0.1:8000",
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://jabber.happy-dev.fr/http-bind/",
"client_id": "833925"
},
"prod": {
"sdn": "https://test-paris.happy-dev.fr",
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://jabber.happy-dev.fr/http-bind/",
"client_id": "833925"
}
}

View File

@ -1,4 +0,0 @@
- var sdn = process.env.SDN || 'http://127.0.0.1:8000'
- var cdn = process.env.CDN || 'https://cdn.happy-dev.fr'
- var xmpp = 'https://jabber.happy-dev.fr/http-bind/'
- var client_id = '833925'

6
src/get_config.pug Normal file
View File

@ -0,0 +1,6 @@
- var __env = locals[process.env.ENV]
-
for(k in __env){
eval(`var ${k} = __env[${JSON.stringify(k)}]`);
}

View File

@ -1,4 +1,4 @@
include config.pug include get_config.pug
<!DOCTYPE html> <!DOCTYPE html>
html(lang="en") html(lang="en")
head head