Skip to content

Commit

Permalink
chore: add build script to package.json + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
azech-hqs committed May 30, 2023
1 parent 7882c2a commit 069a0e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions build_entities.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ function validateConfig(config, debug = false) {

/**
* Generates URL path based model or method categories and parameters.
* Note: Paths contain 'undefined' whenever a tier or type is `null` or `undefined`.
* @param {Object} data - model or unit method config
* @return {string} - entity path
*/
function encodeDataAsURLPath(data) {
const placeholder = 'unknown';
const placeholder = "undefined";

const path = ['tier1', 'tier2', 'tier3', 'type', 'subtype'].map(key => {
const path = ["tier1", "tier2", "tier3", "type", "subtype"].map(key => {
return lodash.get(data.categories, key, placeholder);
}).join('/');
}).join("/");

const params = new URLSearchParams();
for (let key in data.parameters) {
Expand Down Expand Up @@ -104,7 +105,7 @@ try {
const modelAssetFiles = getFilesInDirectory(MODEL_ASSETS_PATH, [".yml", ".yaml"], true);
const modelConfigs = modelAssetFiles.flatMap((asset) => createModelConfigs(asset, LOG_CONFIG_NAMES));
fs.writeFileSync("./model_list.js", `module.exports = ${JSON.stringify(modelConfigs)}`, "utf8");
console.log(`Created ${modelConfigs.length} model configs.`)
console.log(`Created ${modelConfigs.length} model configs.`);
} catch (e) {
console.error(e);
}
Expand All @@ -114,7 +115,7 @@ try {
const methodAssetFiles = getFilesInDirectory(METHOD_ASSETS_PATH, [".yml", ".yaml"], true);
const methodConfigs = methodAssetFiles.flatMap((asset) => createMethodConfigs(asset, LOG_CONFIG_NAMES));
fs.writeFileSync("./method_list.js", `module.exports = ${JSON.stringify(methodConfigs)}`, "utf8");
console.log(`Created ${methodConfigs.length} method configs.`)
console.log(`Created ${methodConfigs.length} method configs.`);
} catch (e) {
console.error(e);
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"test": "nyc --reporter=text mocha --recursive --bail --require @babel/register/lib --require tests/setup.js tests",
"lint": "eslint src tests && prettier --write src tests",
"lint:fix": "eslint --fix --cache src tests && prettier --write src tests",
"build:assets": "node build_entities.mjs",
"build:assets": "node build_entities.mjs && node build_filter.mjs",
"transpile": "babel --out-dir dist src",
"postinstall": "npm run transpile && npm run build:assets",
"prettier": "prettier --check src tests",
Expand All @@ -22,7 +22,8 @@
"/dist",
"/src",
".babelrc",
"build_entities.mjs"
"build_entities.mjs",
"build_filter.mjs"
],
"author": "Exabyte Inc.",
"bugs": {
Expand Down

0 comments on commit 069a0e5

Please sign in to comment.