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
1 line
2.9 KiB
Plaintext
1 line
2.9 KiB
Plaintext
{"version":3,"sources":["../../../src/database/migrations/writeMigrationIndex.ts"],"sourcesContent":["import fs from 'fs'\nimport { getTsconfig } from 'get-tsconfig'\nimport path from 'path'\n\n// Function to get all migration files (TS or JS) excluding 'index'\nconst getMigrationFiles = (dir: string) => {\n return fs\n .readdirSync(dir)\n .filter(\n (file) =>\n (file.endsWith('.ts') || file.endsWith('.js')) &&\n file !== 'index.ts' &&\n file !== 'index.js',\n )\n .sort()\n}\n\n// Function to generate the index.ts content\nconst generateIndexContent = (files: string[]) => {\n const tsconfig = getTsconfig()\n const importExt = tsconfig?.config?.compilerOptions?.moduleResolution === 'NodeNext' ? '.js' : ''\n\n let imports = ''\n let exportsArray = 'export const migrations = [\\n'\n\n files.forEach((file, index) => {\n const fileNameWithoutExt = file.replace(/\\.[^/.]+$/, '')\n imports += `import * as migration_${fileNameWithoutExt} from './${fileNameWithoutExt}${importExt}';\\n`\n exportsArray += ` {\n up: migration_${fileNameWithoutExt}.up,\n down: migration_${fileNameWithoutExt}.down,\n name: '${fileNameWithoutExt}'${index !== files.length - 1 ? ',' : ''}\\n },\\n`\n })\n\n exportsArray += '];\\n'\n return imports + '\\n' + exportsArray\n}\n\n// Main function to create the index.ts file\nexport const writeMigrationIndex = (args: { migrationsDir: string }) => {\n const migrationFiles = getMigrationFiles(args.migrationsDir)\n const indexContent = generateIndexContent(migrationFiles)\n\n fs.writeFileSync(path.join(args.migrationsDir, 'index.ts'), indexContent)\n}\n"],"names":["fs","getTsconfig","path","getMigrationFiles","dir","readdirSync","filter","file","endsWith","sort","generateIndexContent","files","tsconfig","importExt","config","compilerOptions","moduleResolution","imports","exportsArray","forEach","index","fileNameWithoutExt","replace","length","writeMigrationIndex","args","migrationFiles","migrationsDir","indexContent","writeFileSync","join"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,SAASC,WAAW,QAAQ,eAAc;AAC1C,OAAOC,UAAU,OAAM;AAEvB,mEAAmE;AACnE,MAAMC,oBAAoB,CAACC;IACzB,OAAOJ,GACJK,WAAW,CAACD,KACZE,MAAM,CACL,CAACC,OACC,AAACA,CAAAA,KAAKC,QAAQ,CAAC,UAAUD,KAAKC,QAAQ,CAAC,MAAK,KAC5CD,SAAS,cACTA,SAAS,YAEZE,IAAI;AACT;AAEA,4CAA4C;AAC5C,MAAMC,uBAAuB,CAACC;IAC5B,MAAMC,WAAWX;IACjB,MAAMY,YAAYD,UAAUE,QAAQC,iBAAiBC,qBAAqB,aAAa,QAAQ;IAE/F,IAAIC,UAAU;IACd,IAAIC,eAAe;IAEnBP,MAAMQ,OAAO,CAAC,CAACZ,MAAMa;QACnB,MAAMC,qBAAqBd,KAAKe,OAAO,CAAC,aAAa;QACrDL,WAAW,CAAC,sBAAsB,EAAEI,mBAAmB,SAAS,EAAEA,qBAAqBR,UAAU,IAAI,CAAC;QACtGK,gBAAgB,CAAC;kBACH,EAAEG,mBAAmB;oBACnB,EAAEA,mBAAmB;WAC9B,EAAEA,mBAAmB,CAAC,EAAED,UAAUT,MAAMY,MAAM,GAAG,IAAI,MAAM,GAAG,QAAQ,CAAC;IAChF;IAEAL,gBAAgB;IAChB,OAAOD,UAAU,OAAOC;AAC1B;AAEA,4CAA4C;AAC5C,OAAO,MAAMM,sBAAsB,CAACC;IAClC,MAAMC,iBAAiBvB,kBAAkBsB,KAAKE,aAAa;IAC3D,MAAMC,eAAelB,qBAAqBgB;IAE1C1B,GAAG6B,aAAa,CAAC3B,KAAK4B,IAAI,CAACL,KAAKE,aAAa,EAAE,aAAaC;AAC9D,EAAC"} |