-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract config from common as a workspace
- Loading branch information
Showing
38 changed files
with
258 additions
and
317 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@kredeum/config", | ||
"version": "1.4.0", | ||
"description": "", | ||
"main": "index.ts", | ||
"scripts": { | ||
"clean": "rm -rf node_modules dist", | ||
"build": "pnpx ts-node scripts/build.ts" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/fs-extra": "^11.0.4", | ||
"@types/node": "^20.11.6", | ||
"fs-extra": "^11.2.0", | ||
"handlebars": "^4.7.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { runHandlebarsEnv, runHandlebarsConfig } from "./handlebars"; | ||
|
||
const main = async (): Promise<void> => { | ||
await runHandlebarsEnv("src/config.handlebars.json", "dist/config.json"); | ||
await runHandlebarsEnv("src/mainnets.handlebars.json", "dist/mainnets.json"); | ||
await runHandlebarsEnv("src/testnets.handlebars.json", "dist/testnets.json"); | ||
}; | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { outputFile, readFile } from "fs-extra"; | ||
import Handlebars from "handlebars"; | ||
|
||
const runHandlebars = (buffer: string, vars: any): string => { | ||
const template = Handlebars.compile(buffer); | ||
|
||
const result = template(vars); | ||
// console.log("runHandlebars ~ result:", result); | ||
|
||
return result; | ||
}; | ||
|
||
const runHandlebarsEnv = async (pathIN: string, pathOUT: string): Promise<void> => { | ||
const buffer = String(await readFile(pathIN)); | ||
|
||
const result = runHandlebars(buffer, process.env); | ||
|
||
await outputFile(pathOUT, result); | ||
|
||
console.log("runHandlebarsEnv ", pathIN, "=>", pathOUT); | ||
}; | ||
|
||
const runHandlebarsConfig = async (pathIN: string, pathOUT: string, config: any): Promise<void> => { | ||
const buffer = String(await readFile(pathIN)); | ||
|
||
const result = runHandlebars(buffer, config); | ||
|
||
await outputFile(pathOUT, result); | ||
|
||
console.log("runHandlebarsConfig", pathIN, "=>", pathOUT); | ||
}; | ||
|
||
export { runHandlebars, runHandlebarsConfig, runHandlebarsEnv }; |
File renamed without changes.
Oops, something went wrong.