mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor: Update symbol type to use lowercase 'symbol' in ColumnAccessControl files
This commit is contained in:
@@ -1,42 +1,42 @@
|
||||
// This script merges config.env.tpl to config.env
|
||||
|
||||
const fs = require('fs');
|
||||
const fs = require("fs");
|
||||
|
||||
const init = () => {
|
||||
const tempate = fs.readFileSync('./config.example.env', 'utf8');
|
||||
const env = fs.readFileSync('./config.env', 'utf8');
|
||||
const tempate = fs.readFileSync("./config.example.env", "utf8");
|
||||
const env = fs.readFileSync("./config.env", "utf8");
|
||||
|
||||
const linesInTemplate = tempate.split('\n');
|
||||
const linesInEnv= env.split('\n');
|
||||
const linesInTemplate = tempate.split("\n");
|
||||
const linesInEnv = env.split("\n");
|
||||
|
||||
for (const line of linesInTemplate) {
|
||||
// this is a comment, ignore.
|
||||
if (line.startsWith('//')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// comment. Ignore.
|
||||
if (line.startsWith('#')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if the line is present in template but is not present in env file then add it to the env file. We assume, values in template file are default values.
|
||||
if (line.split('=').length > 0) {
|
||||
if (
|
||||
linesInEnv.filter((envLine) => {
|
||||
return (
|
||||
envLine.split('=').length > 0 &&
|
||||
envLine.split('=')[0] === line.split('=')[0]
|
||||
);
|
||||
}).length === 0
|
||||
) {
|
||||
linesInEnv.push(line);
|
||||
}
|
||||
}
|
||||
for (const line of linesInTemplate) {
|
||||
// this is a comment, ignore.
|
||||
if (line.startsWith("//")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// write the file back to disk and exit.
|
||||
fs.writeFileSync('./config.env', linesInEnv.join('\n'));
|
||||
// comment. Ignore.
|
||||
if (line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if the line is present in template but is not present in env file then add it to the env file. We assume, values in template file are default values.
|
||||
if (line.split("=").length > 0) {
|
||||
if (
|
||||
linesInEnv.filter((envLine) => {
|
||||
return (
|
||||
envLine.split("=").length > 0 &&
|
||||
envLine.split("=")[0] === line.split("=")[0]
|
||||
);
|
||||
}).length === 0
|
||||
) {
|
||||
linesInEnv.push(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write the file back to disk and exit.
|
||||
fs.writeFileSync("./config.env", linesInEnv.join("\n"));
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
// This script merges config.env.tpl to config.env
|
||||
|
||||
const fs = require('fs');
|
||||
const fs = require("fs");
|
||||
|
||||
const init = () => {
|
||||
let env = '';
|
||||
try {
|
||||
env = fs.readFileSync('./config.env', 'utf8');
|
||||
} catch (err) {
|
||||
// do nothing.
|
||||
}
|
||||
const envValToReplace = process.argv[2];
|
||||
let env = "";
|
||||
try {
|
||||
env = fs.readFileSync("./config.env", "utf8");
|
||||
} catch (err) {
|
||||
// do nothing.
|
||||
}
|
||||
const envValToReplace = process.argv[2];
|
||||
|
||||
if (!envValToReplace) {
|
||||
// eslint-disable-next-line
|
||||
if (!envValToReplace) {
|
||||
// eslint-disable-next-line
|
||||
console.log('Please have env var to replace');
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const envValToReplaceWith= process.argv[3];
|
||||
const envValToReplaceWith = process.argv[3];
|
||||
|
||||
if (!envValToReplaceWith) {
|
||||
// eslint-disable-next-line
|
||||
if (!envValToReplaceWith) {
|
||||
// eslint-disable-next-line
|
||||
console.log('Please have env var to replace with');
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
const linesInEnv = env.split("\n");
|
||||
const linesToRender = [];
|
||||
let found = false;
|
||||
|
||||
for (let line of linesInEnv) {
|
||||
// this is a comment, ignore.
|
||||
if (!line.startsWith(envValToReplace)) {
|
||||
linesToRender.push(line);
|
||||
} else {
|
||||
found = true;
|
||||
const items = line.split("=");
|
||||
items[1] = envValToReplaceWith;
|
||||
line = items.join("=");
|
||||
linesToRender.push(line);
|
||||
}
|
||||
}
|
||||
|
||||
const linesInEnv = env.split('\n');
|
||||
const linesToRender = [];
|
||||
let found = false;
|
||||
if (!found) {
|
||||
linesToRender.push(envValToReplace + "=" + envValToReplaceWith);
|
||||
}
|
||||
|
||||
for (let line of linesInEnv) {
|
||||
// this is a comment, ignore.
|
||||
if (!line.startsWith(envValToReplace)) {
|
||||
linesToRender.push(line);
|
||||
} else {
|
||||
found = true;
|
||||
const items = line.split('=');
|
||||
items[1] = envValToReplaceWith;
|
||||
line = items.join('=');
|
||||
linesToRender.push(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
linesToRender.push(envValToReplace + '=' + envValToReplaceWith);
|
||||
}
|
||||
|
||||
// write the file back to disk and exit.
|
||||
fs.writeFileSync('./config.env', linesToRender.join('\n'));
|
||||
// write the file back to disk and exit.
|
||||
fs.writeFileSync("./config.env", linesToRender.join("\n"));
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
Reference in New Issue
Block a user