47f10301c8
* Set common package.json sideEffects: false * Configure SWC to modularize lodash imports * Import specific lodash functions instead of _ * Add an eslint rule to avoid full lodash import
27 lines
760 B
TypeScript
27 lines
760 B
TypeScript
import * as admin from 'firebase-admin'
|
|
|
|
import { initAdmin } from './script-init'
|
|
initAdmin()
|
|
|
|
import { Contract } from '../../../common/contract'
|
|
|
|
const firestore = admin.firestore()
|
|
|
|
async function makeContractsPublic() {
|
|
console.log('Updating contracts to be public')
|
|
|
|
const snapshot = await firestore.collection('contracts').get()
|
|
const contracts = snapshot.docs.map((doc) => doc.data() as Contract)
|
|
|
|
console.log('Loaded', contracts.length, 'contracts')
|
|
|
|
for (const contract of contracts) {
|
|
const contractRef = firestore.doc(`contracts/${contract.id}`)
|
|
|
|
console.log('Updating', contract.question)
|
|
await contractRef.update({ visibility: 'public' })
|
|
}
|
|
}
|
|
|
|
if (require.main === module) makeContractsPublic().then(() => process.exit())
|