Skip to content

Commit 13b9bdd

Browse files
authored
Merge pull request #219 from performant-software/feature/cdp218_labels
CDP #218 - Labels
2 parents 263990f + f94f197 commit 13b9bdd

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

scripts/build.config.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export const fetchConfig = async () => {
66
if (configUrl) {
77
const response = await fetch(configUrl);
88
const config = await response.json();
9-
const content = JSON.stringify(config, null, 2);
109

10+
const content = JSON.stringify(config, null, 2);
1111
fs.writeFileSync('./public/config.json', content, 'utf8');
1212

1313
console.info('Using remote config.json');
@@ -17,4 +17,7 @@ export const fetchConfig = async () => {
1717
} else {
1818
console.info('Using local config.json');
1919
}
20+
21+
const data = fs.readFileSync('./public/config.json');
22+
return JSON.parse(data);
2023
};

scripts/build.fields.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import fs from 'fs';
2-
import config from '../public/config.json' with { type: 'json' };
32

43
const CONTEXT_SEPARATOR = '->';
54

@@ -19,9 +18,11 @@ const getLabel = (field) => {
1918
/**
2019
* Pull in fields/labels from "/projects/:project_id/descriptors".
2120
*
21+
* @param config
22+
*
2223
* @returns {Promise<void>}
2324
*/
24-
export const buildUserDefinedFields = async () => {
25+
export const buildUserDefinedFields = async (config) => {
2526
const fields = {};
2627

2728
for (const projectId of config.core_data.project_ids) {

scripts/build.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import { buildSearch } from './build.search.mjs';
99
dotenv.config();
1010

1111
console.log('Fetching config.json...');
12-
await fetchConfig();
12+
const config = await fetchConfig();
1313

1414
console.log('Building userDefinedFields.json from Core Data descriptors...');
15-
await buildUserDefinedFields();
15+
await buildUserDefinedFields(config);
1616

1717
console.log('Fetching content from repository...');
1818
await fetchContent();
1919

2020
console.log('Building search.json from configuration...');
21-
await buildSearch();
21+
await buildSearch(config);
2222
}());

scripts/build.search.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import fs from 'fs';
2-
import config from '../public/config.json' with { type: 'json' };
32

4-
export const buildSearch = async () => {
3+
/**
4+
* Pulls in the search indexes from `config.json`.
5+
*
6+
* @param config
7+
*
8+
* @returns {Promise<void>}
9+
*/
10+
export const buildSearch = async (config) => {
511
const searches = {};
612

713
for (const search of config.search) {

0 commit comments

Comments
 (0)