|
@@ -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 argv = minimist(process.argv.slice(2))
|
|
|
const commit = argv.commit !== undefined
|
|
const commit = argv.commit !== undefined
|
|
|
const ignoreNulls = !!argv['ignore-nulls']
|
|
const ignoreNulls = !!argv['ignore-nulls']
|
|
@@ -17,10 +14,6 @@ if (!commit) {
|
|
|
const userEntitlements = loadUserEntitlements(argv['user-entitlements'])
|
|
const userEntitlements = loadUserEntitlements(argv['user-entitlements'])
|
|
|
const cachedEntitlements = loadCachedEntitlements(argv['cached-entitlements'])
|
|
const cachedEntitlements = loadCachedEntitlements(argv['cached-entitlements'])
|
|
|
|
|
|
|
|
-syncUserEntitlements(userEntitlements, cachedEntitlements)
|
|
|
|
|
- .catch(err => console.error(err.stack))
|
|
|
|
|
- .then(() => process.exit())
|
|
|
|
|
-
|
|
|
|
|
async function syncUserEntitlements(userEntitlements, cachedEntitlements) {
|
|
async function syncUserEntitlements(userEntitlements, cachedEntitlements) {
|
|
|
// check for user entitlements in mongo but not in postgres
|
|
// check for user entitlements in mongo but not in postgres
|
|
|
for (const key of Object.keys(userEntitlements)) {
|
|
for (const key of Object.keys(userEntitlements)) {
|
|
@@ -194,3 +187,10 @@ function loadCachedEntitlements(cachedEntitlementsFilename) {
|
|
|
|
|
|
|
|
return cachedEntitlements
|
|
return cachedEntitlements
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+try {
|
|
|
|
|
+ await syncUserEntitlements(userEntitlements, cachedEntitlements)
|
|
|
|
|
+} catch (error) {
|
|
|
|
|
+ console.error(error.stack)
|
|
|
|
|
+}
|
|
|
|
|
+process.exit()
|