feature: handle multiple configs
This commit is contained in:
parent
7b87f436a0
commit
deb3b25520
21
.gitignore
vendored
21
.gitignore
vendored
@ -1,13 +1,22 @@
|
|||||||
**/node_modules
|
**/node_modules
|
||||||
config.json
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.iml
|
*.iml
|
||||||
*.swp
|
*.swp
|
||||||
dist
|
.npm
|
||||||
|
|
||||||
|
# Test cache
|
||||||
|
cache
|
||||||
cypress/screenshots
|
cypress/screenshots
|
||||||
cypress/videos
|
cypress/videos
|
||||||
cache
|
|
||||||
.npm
|
# Built files
|
||||||
.DS_Store
|
|
||||||
src/manifest.webmanifest
|
|
||||||
.cache
|
.cache
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Config specific files
|
||||||
|
config.json
|
||||||
|
config.*.json
|
||||||
|
!config.sample.json
|
||||||
|
|
||||||
|
# PWA Generated file
|
||||||
|
src/manifest.webmanifest
|
81
README.md
81
README.md
@ -71,6 +71,22 @@ Serve, watch files & rebuild on change with this command:
|
|||||||
npm run watch
|
npm run watch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Multiple config.json
|
||||||
|
|
||||||
|
You can have as many `config.*.json` as you need.
|
||||||
|
|
||||||
|
Watch on a custom config file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CONFIG_PATH='config.customName.json' npm run watch
|
||||||
|
```
|
||||||
|
|
||||||
|
Build with a custom config file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CONFIG_PATH='config.customName.json' npm run build
|
||||||
|
```
|
||||||
|
|
||||||
## Mandatory modules
|
## Mandatory modules
|
||||||
|
|
||||||
By default, a Hubl includes only individual chat modules.
|
By default, a Hubl includes only individual chat modules.
|
||||||
@ -86,11 +102,16 @@ On `config.json`:
|
|||||||
"clientLogo": "/images/logo.webp",
|
"clientLogo": "/images/logo.webp",
|
||||||
"authority": "http://localhost:8000/",
|
"authority": "http://localhost:8000/",
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
|
"get": {
|
||||||
"skills": "http://server.url/skills/",
|
"skills": "http://server.url/skills/",
|
||||||
|
"users": "http://server.url/users/"
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
"users": "http://server.url/users/",
|
"users": "http://server.url/users/",
|
||||||
"uploads": "http://server.url/upload/"
|
"uploads": "http://server.url/upload/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Where:
|
Where:
|
||||||
@ -99,9 +120,9 @@ Where:
|
|||||||
* `clientLogo` is an URL to an image file
|
* `clientLogo` is an URL to an image file
|
||||||
* `xmppWebsocket` is your [Prosody](https://prosody.im/) with [appropriate modules](https://git.startinblox.com/infra/prosody-modules/) configured on.
|
* `xmppWebsocket` is your [Prosody](https://prosody.im/) with [appropriate modules](https://git.startinblox.com/infra/prosody-modules/) configured on.
|
||||||
* `authority` is the OpenID Provider. Usually, if you use `djangoldp-account` it's the same as your djangoldp server.
|
* `authority` is the OpenID Provider. Usually, if you use `djangoldp-account` it's the same as your djangoldp server.
|
||||||
* `endpoints.users` is the API endpoints for Users on your djangoldp server. (djangoldp-account)
|
* `endpoints.*.users` is the API endpoints for Users on your djangoldp server. (djangoldp-account)
|
||||||
* `endpoints.skills` is the API endpoints for Skills on your djangoldp server. (djangoldp-skill)
|
* `endpoints.*.skills` is the API endpoints for Skills on your djangoldp server. (djangoldp-skill)
|
||||||
* `endpoints.uploads` is the API endpoints for Uploads on your djangoldp server. (djangoldp-upload)
|
* `endpoints.*.uploads` is the API endpoints for Uploads on your djangoldp server. (djangoldp-upload)
|
||||||
|
|
||||||
### Communities
|
### Communities
|
||||||
|
|
||||||
@ -157,7 +178,12 @@ On `config.json`:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
|
"get": {
|
||||||
"circle": "http://server.url/circles/"
|
"circle": "http://server.url/circles/"
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"circle": "http://server.url/circles/"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -171,8 +197,10 @@ On `config.json`:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
|
"get": {
|
||||||
"dashboard": "http://server.url/dashboard/"
|
"dashboard": "http://server.url/dashboard/"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
A [sample fixture](https://git.startinblox.com/djangoldp-packages/djangoldp-dashboard/blob/master/djangoldp_dashboard/fixtures/sample.json) can be loaded with `./manage.py loaddata sample`.
|
A [sample fixture](https://git.startinblox.com/djangoldp-packages/djangoldp-dashboard/blob/master/djangoldp_dashboard/fixtures/sample.json) can be loaded with `./manage.py loaddata sample`.
|
||||||
@ -187,9 +215,9 @@ On `config.json`:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"joboffers": "http://server.url/job-offers/",
|
"get": {
|
||||||
"skills": "http://server.url/skills/",
|
"joboffers": "http://server.url/job-offers/"
|
||||||
"uploads": "http://server.url/upload/"
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -203,10 +231,12 @@ On `config.json`:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"projects": "http://server.url/projects/",
|
"get": {
|
||||||
"customers": "http://server.url/customers/",
|
"projects": "http://server.url/projects/"
|
||||||
"businessproviders": "http://server.url/businessproviders/",
|
},
|
||||||
"skills": "http://server.url/skills/"
|
"post": {
|
||||||
|
"projects": "http://server.url/projects/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -219,12 +249,7 @@ On Server: `djangoldp_skill`, `djangoldp_upload` packages
|
|||||||
On `config.json`:
|
On `config.json`:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"publicDirectory": true,
|
"publicDirectory": true
|
||||||
"endpoints": {
|
|
||||||
"groups": "http://server.url/groups/",
|
|
||||||
"skills": "http://server.url/skills/",
|
|
||||||
"uploads": "http://server.url/upload/"
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Optional community modules
|
## Optional community modules
|
||||||
@ -241,9 +266,14 @@ On `config.json`:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
|
"get": {
|
||||||
"events":"http://server.url/events/",
|
"events":"http://server.url/events/",
|
||||||
"typeevents":"http://server.url/typeevents/",
|
"typeevents":"http://server.url/typeevents/"
|
||||||
"uploads": "http://server.url/upload/"
|
},
|
||||||
|
"post": {
|
||||||
|
"events":"http://server.url/events/",
|
||||||
|
"typeevents":"http://server.url/typeevents/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -259,10 +289,16 @@ On `config.json`:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
|
"get": {
|
||||||
"resources":"http://server.url/resources/",
|
"resources":"http://server.url/resources/",
|
||||||
"resourceskeywords":"http://server.url/keywords/",
|
"resourceskeywords":"http://server.url/keywords/",
|
||||||
"resourcestypes":"http://server.url/types/",
|
"resourcestypes":"http://server.url/types/"
|
||||||
"uploads": "http://server.url/upload/"
|
},
|
||||||
|
"post": {
|
||||||
|
"resources":"http://server.url/resources/",
|
||||||
|
"resourceskeywords":"http://server.url/keywords/",
|
||||||
|
"resourcestypes":"http://server.url/types/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -276,7 +312,12 @@ On `config.json`:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
|
"get": {
|
||||||
"polls":"http://server.url/polls/"
|
"polls":"http://server.url/polls/"
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"polls":"http://server.url/polls/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -6,13 +6,11 @@
|
|||||||
"endpoints": {
|
"endpoints": {
|
||||||
"get": {
|
"get": {
|
||||||
"skills": "http://localhost:8000/skills/",
|
"skills": "http://localhost:8000/skills/",
|
||||||
"users": "http://localhost:8000/users/",
|
"users": "http://localhost:8000/users/"
|
||||||
"groups": "http://localhost:8000/groups/"
|
|
||||||
},
|
},
|
||||||
"post": {
|
"post": {
|
||||||
"skills": "http://localhost:8000/skills/",
|
|
||||||
"users": "http://localhost:8000/users/",
|
"users": "http://localhost:8000/users/",
|
||||||
"groups": "http://localhost:8000/groups/"
|
"upload": "http://localhost:8000/upload/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ const HTMLAsset = require('parcel-bundler/lib/assets/HTMLAsset')
|
|||||||
|
|
||||||
function shouldIgnore (file) {
|
function shouldIgnore (file) {
|
||||||
// Ignore img(src="${...}") on pug & keep the components folder pristine
|
// Ignore img(src="${...}") on pug & keep the components folder pristine
|
||||||
return /\${.+}/.test(file) || /components/.test(file);
|
return /\${.+}/.test(file) || /components/.test(file) || /\/lib\/solid-/.test(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SkipStartinbloxWidgetAsset extends HTMLAsset {
|
class SkipStartinbloxWidgetAsset extends HTMLAsset {
|
||||||
|
@ -26,12 +26,14 @@ const options = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
(async function() {
|
(async function() {
|
||||||
if(!fs.existsSync("config.json")) throw "[Error] (Mandatory) Missing config.json file";
|
let configPath = process.env.CONFIG_PATH || 'config.json';
|
||||||
|
if(!fs.existsSync(configPath)) throw `[Error] (Mandatory) Missing ${configPath} file`;
|
||||||
|
console.log(`Using ${configPath} config file`);
|
||||||
|
|
||||||
let config = JSON.parse(fs.readFileSync('config.json'));
|
let config = JSON.parse(fs.readFileSync(configPath));
|
||||||
|
|
||||||
if(!config.clientName) throw "[Error] (Mandatory) Missing clientName on config.json";
|
if(!config.clientName) throw `[Error] (Mandatory) Missing clientName on ${configPath}`;
|
||||||
if(!config.clientLogo) throw "[Error] (Mandatory) Missing clientLogo on config.json";
|
if(!config.clientLogo) throw `[Error] (Mandatory) Missing clientLogo on ${configPath}`;
|
||||||
|
|
||||||
let manifest = {
|
let manifest = {
|
||||||
"lang": "fr",
|
"lang": "fr",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const config = require("../config.json");
|
let configPath = process.env.CONFIG_PATH || 'config.json';
|
||||||
|
const config = require(`../${configPath}`);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
locals: config
|
locals: config
|
||||||
|
@ -30,6 +30,7 @@ self.addEventListener('activate', function (e) {
|
|||||||
self.clients.claim();
|
self.clients.claim();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(process.env.NODE_ENV === 'production'){
|
||||||
self.addEventListener('fetch', function (event) {
|
self.addEventListener('fetch', function (event) {
|
||||||
let requestURL = new URL(event.request.url);
|
let requestURL = new URL(event.request.url);
|
||||||
if (requestURL.origin == location.origin) {
|
if (requestURL.origin == location.origin) {
|
||||||
@ -111,3 +112,4 @@ self.addEventListener('fetch', function (event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user