Files
klz-cables.com/.pnpm-store/v10/files/01/bbbe07a4801428abca8e5e36036c65936d9f717aa338fef39a17da64dca4a90a05014eb906556df2cf4e0d6e53b4fee2e6aaf5902dc90a5446dc4efd993f8b
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

32 lines
1.5 KiB
Plaintext

import fs from 'fs';
import { getTsconfig } from 'get-tsconfig';
import path from 'path';
// Function to get all migration files (TS or JS) excluding 'index'
const getMigrationFiles = (dir)=>{
return fs.readdirSync(dir).filter((file)=>(file.endsWith('.ts') || file.endsWith('.js')) && file !== 'index.ts' && file !== 'index.js').sort();
};
// Function to generate the index.ts content
const generateIndexContent = (files)=>{
const tsconfig = getTsconfig();
const importExt = tsconfig?.config?.compilerOptions?.moduleResolution === 'NodeNext' ? '.js' : '';
let imports = '';
let exportsArray = 'export const migrations = [\n';
files.forEach((file, index)=>{
const fileNameWithoutExt = file.replace(/\.[^/.]+$/, '');
imports += `import * as migration_${fileNameWithoutExt} from './${fileNameWithoutExt}${importExt}';\n`;
exportsArray += ` {
up: migration_${fileNameWithoutExt}.up,
down: migration_${fileNameWithoutExt}.down,
name: '${fileNameWithoutExt}'${index !== files.length - 1 ? ',' : ''}\n },\n`;
});
exportsArray += '];\n';
return imports + '\n' + exportsArray;
};
// Main function to create the index.ts file
export const writeMigrationIndex = (args)=>{
const migrationFiles = getMigrationFiles(args.migrationsDir);
const indexContent = generateIndexContent(migrationFiles);
fs.writeFileSync(path.join(args.migrationsDir, 'index.ts'), indexContent);
};
//# sourceMappingURL=writeMigrationIndex.js.map