mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-05 02:45:18 +02:00
Merge branch 'master' of https://github.com/pawelmalak/flame into merge_upstream_2020-12-06
This commit is contained in:
commit
021bd4e85a
266 changed files with 13470 additions and 7067 deletions
|
@ -1,9 +1,11 @@
|
|||
const initConfig = require('./initConfig');
|
||||
const initFiles = require('./initFiles');
|
||||
const initDockerSecrets = require('./initDockerSecrets');
|
||||
|
||||
const initApp = async () => {
|
||||
await initConfig();
|
||||
initDockerSecrets();
|
||||
await initFiles();
|
||||
await initConfig();
|
||||
};
|
||||
|
||||
module.exports = initApp;
|
||||
|
|
|
@ -1,39 +1,25 @@
|
|||
const { Op } = require('sequelize');
|
||||
const Config = require('../../models/Config');
|
||||
const { config } = require('./initialConfig.json');
|
||||
|
||||
const Logger = require('../Logger');
|
||||
const logger = new Logger();
|
||||
const { copyFile, readFile, writeFile } = require('fs/promises');
|
||||
const checkFileExists = require('../checkFileExists');
|
||||
const initialConfig = require('./initialConfig.json');
|
||||
|
||||
const initConfig = async () => {
|
||||
// Get config values
|
||||
const configPairs = await Config.findAll({
|
||||
where: {
|
||||
key: {
|
||||
[Op.or]: config.map((pair) => pair.key),
|
||||
},
|
||||
},
|
||||
});
|
||||
const configExists = await checkFileExists('data/config.json');
|
||||
|
||||
// Get key from each pair
|
||||
const configKeys = configPairs.map((pair) => pair.key);
|
||||
|
||||
// Create missing pairs
|
||||
config.forEach(async ({ key, value }) => {
|
||||
if (!configKeys.includes(key)) {
|
||||
await Config.create({
|
||||
key,
|
||||
value,
|
||||
valueType: typeof value,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV == 'development') {
|
||||
logger.log('Initial config created');
|
||||
if (!configExists) {
|
||||
await copyFile('utils/init/initialConfig.json', 'data/config.json');
|
||||
}
|
||||
|
||||
return;
|
||||
const existingConfig = await readFile('data/config.json', 'utf-8');
|
||||
const parsedConfig = JSON.parse(existingConfig);
|
||||
|
||||
// Add new config pairs if necessary
|
||||
for (let key in initialConfig) {
|
||||
if (!Object.keys(parsedConfig).includes(key)) {
|
||||
parsedConfig[key] = initialConfig[key];
|
||||
}
|
||||
}
|
||||
|
||||
await writeFile('data/config.json', JSON.stringify(parsedConfig));
|
||||
};
|
||||
|
||||
module.exports = initConfig;
|
||||
|
|
17
utils/init/initDockerSecrets.js
Normal file
17
utils/init/initDockerSecrets.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
const { getSecrets } = require('docker-secret');
|
||||
const Logger = require('../Logger');
|
||||
const logger = new Logger();
|
||||
|
||||
const initDockerSecrets = () => {
|
||||
const secrets = getSecrets();
|
||||
|
||||
for (const property in secrets) {
|
||||
const upperProperty = property.toUpperCase();
|
||||
|
||||
process.env[upperProperty] = secrets[property];
|
||||
|
||||
logger.log(`${upperProperty} was overwritten with docker secret value`);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = initDockerSecrets;
|
|
@ -1,88 +1,33 @@
|
|||
{
|
||||
"config": [
|
||||
{
|
||||
"key": "WEATHER_API_KEY",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"key": "lat",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"key": "long",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"key": "isCelsius",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"key": "customTitle",
|
||||
"value": "Flame"
|
||||
},
|
||||
{
|
||||
"key": "pinAppsByDefault",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"key": "pinBookmarksByDefault",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"key": "pinCategoriesByDefault",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"key": "hideHeader",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "useOrdering",
|
||||
"value": "createdAt"
|
||||
},
|
||||
{
|
||||
"key": "appsSameTab",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "bookmarksSameTab",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "searchSameTab",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "hideApps",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "hideBookmarks",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "hideSearch",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "defaultSearchProvider",
|
||||
"value": "l"
|
||||
},
|
||||
{
|
||||
"key": "dockerApps",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "dockerHost",
|
||||
"value": "localhost"
|
||||
},
|
||||
{
|
||||
"key": "kubernetesApps",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"key": "unpinStoppedApps",
|
||||
"value": false
|
||||
}
|
||||
]
|
||||
"WEATHER_API_KEY": "",
|
||||
"lat": 0,
|
||||
"long": 0,
|
||||
"isCelsius": true,
|
||||
"customTitle": "Flame",
|
||||
"pinAppsByDefault": true,
|
||||
"pinBookmarksByDefault": true,
|
||||
"pinCategoriesByDefault": true,
|
||||
"hideHeader": false,
|
||||
"useOrdering": "createdAt",
|
||||
"appsSameTab": false,
|
||||
"bookmarksSameTab": false,
|
||||
"searchSameTab": false,
|
||||
"hideApps": false,
|
||||
"hideBookmarks": false,
|
||||
"hideSearch": false,
|
||||
"defaultSearchProvider": "l",
|
||||
"dockerApps": false,
|
||||
"dockerHost": "localhost",
|
||||
"kubernetesApps": false,
|
||||
"unpinStoppedApps": false,
|
||||
"useAmericanDate": false,
|
||||
"disableAutofocus": false,
|
||||
"greetingsSchema": "Good evening!;Good afternoon!;Good morning!;Good night!",
|
||||
"daySchema": "Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday",
|
||||
"monthSchema": "January;February;March;April;May;June;July;August;September;October;November;December",
|
||||
"showTime": false,
|
||||
"defaultTheme": "tron",
|
||||
"isKilometer": true,
|
||||
"weatherData": "cloud",
|
||||
"hideDate": false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue