mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-28 22:13:20 -05:00
eea27a36a4
* Add `unicorn/prefer-node-protocol` * Revert non-web changes * Run `npm run lint:fix` (prefer-node-protocol) GitOrigin-RevId: c3cdd88ff9e6b3de6a4397d45935c4d026c1c1ed
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import readline from 'node:readline'
|
|
import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js'
|
|
import ProjectGetter from '../app/src/Features/Project/ProjectGetter.js'
|
|
import Errors from '../app/src/Features/Errors/Errors.js'
|
|
|
|
async function countFiles() {
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
})
|
|
|
|
for await (const projectId of rl) {
|
|
try {
|
|
const project = await ProjectGetter.promises.getProject(projectId)
|
|
if (!project) {
|
|
throw new Errors.NotFoundError('project not found')
|
|
}
|
|
const { files, docs } =
|
|
ProjectEntityHandler.getAllEntitiesFromProject(project)
|
|
console.error(
|
|
projectId,
|
|
files.length,
|
|
(project.deletedFiles && project.deletedFiles.length) || 0,
|
|
docs.length,
|
|
(project.deletedDocs && project.deletedDocs.length) || 0
|
|
)
|
|
} catch (err) {
|
|
if (err instanceof Errors.NotFoundError) {
|
|
console.error(projectId, 'NOTFOUND')
|
|
} else {
|
|
console.log(projectId, 'ERROR', err.name, err.message)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
try {
|
|
await countFiles()
|
|
process.exit(0)
|
|
} catch (error) {
|
|
console.log('Aiee, something went wrong!', error)
|
|
process.exit(1)
|
|
}
|