-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathbuildAvailablePortals.js
58 lines (51 loc) · 1.4 KB
/
buildAvailablePortals.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* This file reads from the list of portals and combines all the configs into a single JSON file (git ignored).
* This file is set up to run as an NPM script on 'postinstall' and 'prestart'.
* This should ensure that the availablePortals.json file is present in CI
* environments, and updates to the file will be available in your local
* environment after restarting the dev server.
*/
const fs = require('fs')
// When adding a new portal, add your config file to the `portals` directory, and
// list the name of the portal here. The order does not matter, but please keep
// them sorted alphabetically!
const portals = [
'above',
'ai-ml',
'airmoss',
'amd',
'carve',
'casei',
'cwic',
'default',
'edsc',
'example',
'ghrc',
'idn',
'obdaac',
'ornldaac',
'podaac',
'podaac-cloud',
'seabass',
'snwg',
'soos',
'standardproducts',
'suborbital'
]
const availablePortals = {}
// Loop through each portal config and add contents to the `availablePortals` object
portals.forEach((portalId) => {
// eslint-disable-next-line import/no-dynamic-require, global-require
const config = require(`../portals/${portalId}/config.json`)
availablePortals[portalId] = {
...config,
portalId
}
})
try {
// Write the availablePortals.json file
fs.writeFileSync('portals/availablePortals.json', JSON.stringify(availablePortals))
} catch (error) {
console.error(error)
throw error
}