added realm to jspg processing
This commit is contained in:
43
scripts/update_fixtures.js
Normal file
43
scripts/update_fixtures.js
Normal file
@ -0,0 +1,43 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function updateFile(filePath) {
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(content);
|
||||
} catch (e) {
|
||||
console.error("Failed to parse " + filePath, e);
|
||||
return;
|
||||
}
|
||||
|
||||
let changed = false;
|
||||
for (let suite of data) {
|
||||
if (suite.database && suite.database.schemas) {
|
||||
if (!suite.database.puncs) suite.database.puncs = [];
|
||||
for (let id of Object.keys(suite.database.schemas)) {
|
||||
let schema = suite.database.schemas[id];
|
||||
let puncType = {
|
||||
name: id,
|
||||
schemas: { [id]: schema }
|
||||
};
|
||||
suite.database.puncs.push(puncType);
|
||||
}
|
||||
delete suite.database.schemas;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
||||
console.log("Updated " + filePath);
|
||||
}
|
||||
}
|
||||
|
||||
let fixturesDir = 'fixtures';
|
||||
let files = fs.readdirSync(fixturesDir);
|
||||
for (let file of files) {
|
||||
if (file.endsWith('.json')) {
|
||||
updateFile(path.join(fixturesDir, file));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user