Merge pull request #21282 from overleaf/ls-scripts-to-esm-5

Migrate rest of the scripts to esm

GitOrigin-RevId: 421f3ccd15342d34113be8d22e343d08533177ea
This commit is contained in:
Liangjun Song
2024-10-25 08:05:41 +00:00
committed by Copybot
parent e3b93f0a22
commit 14cd8f5479
13 changed files with 140 additions and 125 deletions
@@ -1,11 +1,8 @@
'use strict'
const fs = require('fs')
const minimist = require('minimist')
const InstitutionsAPI =
require('../../app/src/Features/Institutions/InstitutionsAPI').promises
import fs from 'fs'
import minimist from 'minimist'
import InstitutionsAPIModule from '../../app/src/Features/Institutions/InstitutionsAPI.js'
const { promises: InstitutionsAPI } = InstitutionsAPIModule
const argv = minimist(process.argv.slice(2))
const commit = argv.commit !== undefined
const ignoreNulls = !!argv['ignore-nulls']
@@ -17,10 +14,6 @@ if (!commit) {
const userEntitlements = loadUserEntitlements(argv['user-entitlements'])
const cachedEntitlements = loadCachedEntitlements(argv['cached-entitlements'])
syncUserEntitlements(userEntitlements, cachedEntitlements)
.catch(err => console.error(err.stack))
.then(() => process.exit())
async function syncUserEntitlements(userEntitlements, cachedEntitlements) {
// check for user entitlements in mongo but not in postgres
for (const key of Object.keys(userEntitlements)) {
@@ -194,3 +187,10 @@ function loadCachedEntitlements(cachedEntitlementsFilename) {
return cachedEntitlements
}
try {
await syncUserEntitlements(userEntitlements, cachedEntitlements)
} catch (error) {
console.error(error.stack)
}
process.exit()