mirror of
https://github.com/Retropex/mempool.git
synced 2025-05-28 13:02:32 +02:00

* initial version of the update config script * fix duplicated content * update cypress ci settings * add workflow to run e2e tests when pushing * record cypress results to the dashboard * pull the cypress record key and project id from the secrets * add start-server-and-test to replace concurrently * replace concurrently with start-server-and-test * remove concurrently * add new cypress target to record * update cypress to 7.7.0 * add tests for signet * add tests for testnet * run tests on chrome and firefox * update test matrix: add edge and run firefox on container * fix copypasta * update docker image for firefox * fix task name again * fix edge tests task name * improve bisq tests * update workflow config * enable cypress debug logs * add a manual trigger for the e2e tests * add config:defaults target * use more of the GHA options * fix config command * add cypress-fail-on-console-error * upgrade cypress to v8.0.0 * add helper to wait for the loader skeleton to be gone * use skeleton waiter on the tests * remove manual test trigger * fix tv test when only one mempool block is available * add waiter for pagination * add extra steps to debug firefox launch issue * remove whoami step * Revert "upgrade cypress to v8.0.0" This reverts commit cb3ff7d906c2a2219d7e2b2c16a92c311e3f6817. * remove userinfo debug step * enable test retries in run mode * update proxy config to reduce ECONNRESET errors * add mock-socket dev dependency * add helpers to mock websockets and detect page idleness * stabilize mainnet tests * fix tv mode test on Liquid * add basic tests for the mainnet status page * cleanup mainnet tests * update bisq tests * update signet tests * update testnet tests * add initial support for parameterized websocket mocks * move testing dependencies to optionalDependencies * comment out mempool size check until the live updates are fixed * comment out tx regex test * update fixture for the new difficulty adjustment component * fix the assertions on the status page
96 lines
3.0 KiB
JavaScript
96 lines
3.0 KiB
JavaScript
const fs = require('fs');
|
|
|
|
const CONFIG_FILE_NAME = 'mempool-frontend-config.json';
|
|
const GENERATED_CONFIG_FILE_NAME = 'generated-config.js';
|
|
|
|
let settings = [];
|
|
let configContent = {};
|
|
const packageSettings = ['GIT_COMMIT_HASH', 'PACKAGE_JSON_VERSION']; //These will be handled by generate-config
|
|
|
|
var args = process.argv.slice(2);
|
|
|
|
function addSetting(key, value) {
|
|
settings.push({
|
|
key: key,
|
|
value: value
|
|
});
|
|
}
|
|
|
|
function normalizedValue(value) {
|
|
if (Number(value)) {
|
|
value = Number(value);
|
|
} else if ((value === 'true') || (value !== 'true')) {
|
|
value = !!JSON.parse(String(value).toLowerCase());
|
|
}
|
|
return value;
|
|
}
|
|
|
|
function parseGeneratedFile() {
|
|
const generatedConfig = fs.readFileSync(GENERATED_CONFIG_FILE_NAME);
|
|
if (generatedConfig) {
|
|
const configContents = generatedConfig.toString();
|
|
const regexp = new RegExp(/window.__env.(\w+) = '(.*)'/,'g');
|
|
while ((match = regexp.exec(configContents)) !== null) {
|
|
// Do not add setting if it's the git hash or package json version
|
|
if (!packageSettings.includes(match[1])) {
|
|
const key = match[1];
|
|
const value = match[2];
|
|
console.log(typeof(value));
|
|
addSetting(key, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function saveSettingsJson() {
|
|
settings.forEach(setting => {
|
|
if (configContent.hasOwnProperty(setting['key']) && normalizedValue(configContent[setting['key']]) !== normalizedValue(setting['value'])) {
|
|
console.log(setting['key'] + " updated from " + configContent[setting['key']] + " to " + setting['value']);
|
|
} else if (configContent.hasOwnProperty(setting['key']) && normalizedValue(configContent[setting['key']]) === normalizedValue(setting['value'])) {
|
|
console.log(setting['key'] + " unchanged, skipping");
|
|
} else {
|
|
console.log(setting['key'] + " set to " + setting['value']);
|
|
}
|
|
configContent[setting['key']] = setting['value'];
|
|
});
|
|
fs.writeFileSync(CONFIG_FILE_NAME, JSON.stringify(configContent));
|
|
}
|
|
|
|
function configToJson() {
|
|
for (setting in configContent) {
|
|
settings.push({
|
|
key: setting,
|
|
value: configContent[setting]
|
|
});
|
|
}
|
|
}
|
|
|
|
try {
|
|
const rawConfig = fs.readFileSync(CONFIG_FILE_NAME);
|
|
configContent = JSON.parse(rawConfig);
|
|
console.log(`${CONFIG_FILE_NAME} file found, using provided config`);
|
|
} catch (e) {
|
|
if (e.code !== 'ENOENT') {
|
|
throw new Error(e);
|
|
} else {
|
|
|
|
if (fs.existsSync(GENERATED_CONFIG_FILE_NAME)) {
|
|
console.log(`${CONFIG_FILE_NAME} file not found, reading current config from generated-config.js`);
|
|
parseGeneratedFile();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if (args.length > 0) {
|
|
args.forEach(setting => {
|
|
setting = setting.split('=');
|
|
const key = setting[0];
|
|
let value = setting[1];
|
|
addSetting(key, normalizedValue(value));
|
|
});
|
|
}
|
|
|
|
saveSettingsJson();
|
|
console.log('new json', configContent);
|