44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
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));
|
|
}
|
|
}
|