44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
/* eslint-disable no-console */
|
|
const fs = require('fs')
|
|
|
|
const find1 = `
|
|
CreatedAtAsc = '_createdAt_ASC',
|
|
CreatedAtDesc = '_createdAt_DESC',
|
|
CreatedAtAsc = 'createdAt_ASC',
|
|
CreatedAtDesc = 'createdAt_DESC',`
|
|
|
|
const replace1 = `
|
|
CreatedAtAsc = 'createdAt_ASC',
|
|
CreatedAtDesc = 'createdAt_DESC',`
|
|
|
|
const find2 = `
|
|
UpdatedAtAsc = '_updatedAt_ASC',
|
|
UpdatedAtDesc = '_updatedAt_DESC',
|
|
UpdatedAtAsc = 'updatedAt_ASC',
|
|
UpdatedAtDesc = 'updatedAt_DESC',`
|
|
|
|
const replace2 = `
|
|
UpdatedAtAsc = 'updatedAt_ASC',
|
|
UpdatedAtDesc = 'updatedAt_DESC',`
|
|
|
|
const filePath = './src/lib/cms/generated.ts'
|
|
|
|
fs.readFile(filePath, 'utf8', function (err, data) {
|
|
if (err) {
|
|
return console.error(err)
|
|
}
|
|
|
|
let result = data
|
|
let found = true
|
|
while (found) {
|
|
found = result.includes(find1) || result.includes(find2)
|
|
result = result.replace(find1, replace1)
|
|
result = result.replace(find2, replace2)
|
|
}
|
|
|
|
fs.writeFile(filePath, result, 'utf8', function (err) {
|
|
if (err) return console.error(err)
|
|
else console.log('Codegen fixed successfully ✨')
|
|
})
|
|
})
|