mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-02 17:35:17 +02:00
Merge branch 'feature' into v1.7.0
This commit is contained in:
commit
55f192f664
53 changed files with 1172 additions and 385 deletions
32
utils/init/createFile.js
Normal file
32
utils/init/createFile.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const Logger = require('../Logger');
|
||||
const logger = new Logger();
|
||||
|
||||
const createFile = async (file) => {
|
||||
const { name, msg, template, isJSON, paths } = file;
|
||||
|
||||
const srcPath = join(__dirname, paths.src, name);
|
||||
const destPath = join(__dirname, paths.dest, name);
|
||||
|
||||
// Check if file exists
|
||||
if (fs.existsSync(srcPath)) {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
|
||||
if (process.env.NODE_ENV == 'development') {
|
||||
logger.log(msg.found);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Create file if not
|
||||
fs.writeFileSync(destPath, isJSON ? JSON.stringify(template) : template);
|
||||
|
||||
if (process.env.NODE_ENV == 'development') {
|
||||
logger.log(msg.created);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = createFile;
|
9
utils/init/index.js
Normal file
9
utils/init/index.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
const initConfig = require('./initConfig');
|
||||
const initFiles = require('./initFiles');
|
||||
|
||||
const initApp = async () => {
|
||||
await initConfig();
|
||||
await initFiles();
|
||||
};
|
||||
|
||||
module.exports = initApp;
|
39
utils/init/initConfig.js
Normal file
39
utils/init/initConfig.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
const { Op } = require('sequelize');
|
||||
const Config = require('../../models/Config');
|
||||
const { config } = require('./initialConfig.json');
|
||||
|
||||
const Logger = require('../Logger');
|
||||
const logger = new Logger();
|
||||
|
||||
const initConfig = async () => {
|
||||
// Get config values
|
||||
const configPairs = await Config.findAll({
|
||||
where: {
|
||||
key: {
|
||||
[Op.or]: config.map((pair) => pair.key),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// 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');
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
module.exports = initConfig;
|
8
utils/init/initFiles.js
Normal file
8
utils/init/initFiles.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
const createFile = require('./createFile');
|
||||
const { files } = require('./initialFiles.json');
|
||||
|
||||
const initFiles = async () => {
|
||||
files.forEach(async (file) => await createFile(file));
|
||||
};
|
||||
|
||||
module.exports = initFiles;
|
84
utils/init/initialConfig.json
Normal file
84
utils/init/initialConfig.json
Normal file
|
@ -0,0 +1,84 @@
|
|||
{
|
||||
"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": "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": "hideCategories",
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
32
utils/init/initialFiles.json
Normal file
32
utils/init/initialFiles.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"files": [
|
||||
{
|
||||
"name": "flame.css",
|
||||
"msg": {
|
||||
"created": "Created empty CSS file",
|
||||
"found": "Custom CSS file found"
|
||||
},
|
||||
"paths": {
|
||||
"src": "../../data",
|
||||
"dest": "../../public"
|
||||
},
|
||||
"template": "",
|
||||
"isJSON": false
|
||||
},
|
||||
{
|
||||
"name": "customQueries.json",
|
||||
"msg": {
|
||||
"created": "Created empty queries file",
|
||||
"found": "Custom queries file found"
|
||||
},
|
||||
"paths": {
|
||||
"src": "../../data",
|
||||
"dest": "../../data"
|
||||
},
|
||||
"template": {
|
||||
"queries": []
|
||||
},
|
||||
"isJSON": true
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue