mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
* chore: replace Prettier with oxfmt and add oxlint - Replace Prettier with oxfmt (Prettier-compatible formatter from OXC project) - Add oxlint for fast linting alongside ESLint - Add eslint-plugin-oxlint to disable ESLint rules covered by oxlint - Update lint scripts to run oxfmt, oxlint, then eslint - Update lint-staged configuration for pre-commit hooks - Create .oxfmtrc.json and .oxlintrc.json configuration files - Remove .prettierrc.json and .prettierignore - Reformat codebase with oxfmt * chore: update dependencies in yarn.lock * chore: update oxlint configuration to disable additional rules * chore: update oxfmt and oxlint configurations, enhance test readability
60 lines
1.7 KiB
JavaScript
60 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// overview:
|
|
// 1. Identify the migrations in packages/loot-core/migrations/* on `master` and HEAD
|
|
// 2. Make sure that any new migrations on HEAD are dated after the latest migration on `master`.
|
|
|
|
const path = require('path');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const migrationsDir = path.join(
|
|
__dirname,
|
|
'..',
|
|
'..',
|
|
'packages',
|
|
'loot-core',
|
|
'migrations',
|
|
);
|
|
|
|
function readMigrations(ref) {
|
|
const { stdout } = spawnSync('git', [
|
|
'ls-tree',
|
|
'--name-only',
|
|
ref,
|
|
migrationsDir + '/',
|
|
]);
|
|
const files = stdout.toString().split('\n').filter(Boolean);
|
|
console.log(`Found ${files.length} migrations on ${ref}.`);
|
|
return files
|
|
.map(file => path.basename(file))
|
|
.filter(file => !file.startsWith('.'))
|
|
.map(name => ({
|
|
date: parseInt(name.split('_')[0]),
|
|
name: name.match(/^\d+_(.+?)(\.sql)?$/)?.[1] ?? '***' + name,
|
|
}));
|
|
}
|
|
|
|
spawnSync('git', ['fetch', 'origin', 'master']);
|
|
let masterMigrations = readMigrations('origin/master');
|
|
let headMigrations = readMigrations('HEAD');
|
|
|
|
let latestMasterMigration = masterMigrations[masterMigrations.length - 1].date;
|
|
let newMigrations = headMigrations.filter(
|
|
migration => !masterMigrations.find(m => m.name === migration.name),
|
|
);
|
|
let badMigrations = newMigrations.filter(
|
|
migration => migration.date <= latestMasterMigration,
|
|
);
|
|
|
|
if (badMigrations.length) {
|
|
console.error(
|
|
`The following migrations are dated before the latest migration on master:`,
|
|
);
|
|
badMigrations.forEach(migration => {
|
|
console.error(` ${migration.name}`);
|
|
});
|
|
process.exit(1);
|
|
} else {
|
|
console.log(`All migrations are dated after the latest migration on master.`);
|
|
}
|