mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-06 07:39:02 +02:00
Merge pull request #21097 from overleaf/ls-scripts-to-esm-1
Migrate scripts folder to esm 1/x GitOrigin-RevId: 4a4bc9a161f144fdb40ce3f2a0a9313b36c6df81
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { waitForDb } from '../app/src/infrastructure/mongodb.js'
|
||||
import ProjectEntityRestoreHandler from '../app/src/Features/Project/ProjectEntityRestoreHandler.js'
|
||||
import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js'
|
||||
import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js'
|
||||
|
||||
const ARGV = process.argv.slice(2)
|
||||
const DEVELOPER_USER_ID = ARGV.shift()
|
||||
const PROJECT_ID = ARGV.shift()
|
||||
const DOC_IDS_TO_RESTORE = ARGV
|
||||
|
||||
async function main() {
|
||||
const allDocs = await DocstoreManager.promises.getAllDocs(PROJECT_ID)
|
||||
const docsToRestore = allDocs.filter(doc =>
|
||||
DOC_IDS_TO_RESTORE.includes(doc._id)
|
||||
)
|
||||
|
||||
const docPaths =
|
||||
await ProjectEntityHandler.promises.getAllDocPathsFromProjectById(
|
||||
PROJECT_ID
|
||||
)
|
||||
|
||||
for (const orphanedDoc of docsToRestore) {
|
||||
console.log('Restoring doc: ', orphanedDoc._id)
|
||||
if (docPaths[orphanedDoc._id]) {
|
||||
console.log(`Doc already exists, skipping ${docPaths[orphanedDoc._id]}`)
|
||||
continue
|
||||
}
|
||||
const newDoc = await ProjectEntityRestoreHandler.promises.restoreDeletedDoc(
|
||||
PROJECT_ID,
|
||||
orphanedDoc._id,
|
||||
`restored-${orphanedDoc._id}-rev-${orphanedDoc.rev}.tex`,
|
||||
DEVELOPER_USER_ID
|
||||
)
|
||||
console.log(newDoc)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await waitForDb()
|
||||
await main()
|
||||
process.exit(0)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
}
|
||||
Reference in New Issue
Block a user