mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01: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,54 @@
|
||||
import { db, ObjectId, waitForDb } from '../app/src/infrastructure/mongodb.js'
|
||||
import minimist from 'minimist'
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const commit = argv.commit !== undefined
|
||||
const projectIds = argv._.map(x => {
|
||||
return new ObjectId(x)
|
||||
})
|
||||
|
||||
if (!commit) {
|
||||
console.log('Doing dry run without --commit')
|
||||
}
|
||||
console.log('checking', projectIds.length, 'projects')
|
||||
|
||||
await waitForDb()
|
||||
|
||||
const affectedProjects = await db.projects
|
||||
.find(
|
||||
{ _id: { $in: projectIds } },
|
||||
{
|
||||
projection: {
|
||||
_id: 1,
|
||||
owner_ref: 1,
|
||||
tokenAccessReadOnly_refs: 1,
|
||||
tokenAccessReadAndWrite_refs: 1,
|
||||
},
|
||||
}
|
||||
)
|
||||
.toArray()
|
||||
console.log('Found ' + affectedProjects.length + ' affected projects')
|
||||
affectedProjects.forEach(project => {
|
||||
console.log(JSON.stringify(project))
|
||||
})
|
||||
if (!commit) {
|
||||
console.log('dry run, not updating')
|
||||
process.exit(0)
|
||||
} else {
|
||||
try {
|
||||
const result = await db.projects.updateMany(
|
||||
{ _id: { $in: affectedProjects.map(project => project._id) } },
|
||||
{
|
||||
$set: {
|
||||
publicAccesLevel: 'private', // note the spelling in the db is publicAccesLevel (with one 's')
|
||||
tokenAccessReadOnly_refs: [],
|
||||
tokenAccessReadAndWrite_refs: [],
|
||||
},
|
||||
}
|
||||
)
|
||||
console.log('result', JSON.stringify(result))
|
||||
process.exit(0)
|
||||
} catch (err) {
|
||||
console.error('err', err)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user