diff --git a/.gitignore b/.gitignore index 2a939eb..e9400a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /node_modules -/src/config.pug +/src/config.js /www/index.html +/www/index.prod.html /www/styles/ /www/scripts/ /www/lib/ diff --git a/Makefile b/Makefile index 6bbdda3..c695b4c 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,6 @@ default: build clean: git clean -fXd -e !src/config.pug - install: node_modules copy_lib copy_samples submodules submodules: @@ -38,13 +37,24 @@ copy_lib: @node copy_lib.js # samples -copy_samples: - @cp -n src/config.sample.pug src/config.pug +copy_samples: src/config.json + +src/config.json: + @cp -n src/config.sample.json src/config.json # 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: $< ➜ $@ - @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 $(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 $@ buildprod: build - export SDN="https://test-paris.happy-dev.fr"; \ - $(MAKE) $(DIST_DIR)/index.html -B + $(MAKE) $(DIST_DIR)/index.prod.html deploy: pull install build pull: git pull -sync: - rsync -rv www/* staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/ --exclude=www/oidc-client-config.json +sync: buildprod + 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/ .PHONY: default install submodules copy_lib copy_samples build watch serve clean sync buildprod pull deploy \ No newline at end of file diff --git a/src/config.integration.pug b/src/config.integration.pug deleted file mode 100644 index 787f6be..0000000 --- a/src/config.integration.pug +++ /dev/null @@ -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 diff --git a/src/config.json b/src/config.json new file mode 100644 index 0000000..085b314 --- /dev/null +++ b/src/config.json @@ -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" + } +} diff --git a/src/config.local.pug b/src/config.local.pug deleted file mode 100644 index 4ab4c7b..0000000 --- a/src/config.local.pug +++ /dev/null @@ -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 diff --git a/src/config.sample.json b/src/config.sample.json new file mode 100644 index 0000000..085b314 --- /dev/null +++ b/src/config.sample.json @@ -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" + } +} diff --git a/src/config.sample.pug b/src/config.sample.pug deleted file mode 100644 index 3afab8b..0000000 --- a/src/config.sample.pug +++ /dev/null @@ -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' diff --git a/src/get_config.pug b/src/get_config.pug new file mode 100644 index 0000000..befcb19 --- /dev/null +++ b/src/get_config.pug @@ -0,0 +1,6 @@ +- var __env = locals[process.env.ENV] + +- + for(k in __env){ + eval(`var ${k} = __env[${JSON.stringify(k)}]`); + } \ No newline at end of file diff --git a/src/index.pug b/src/index.pug index 60d534a..146c45c 100644 --- a/src/index.pug +++ b/src/index.pug @@ -1,4 +1,4 @@ -include config.pug +include get_config.pug html(lang="en") head