CLI belt: the Melfore tool belt
npm install @melfore/clibeltAdd required CLIs to your package.json, for example:
"scripts": {
"i18n": "i18n-msg",
"i18n:copy": "i18n-copy --from it --to fr",
"pwd2hash": "pwd2hash"
}There are three ways to configure a CLI.
Create a file .clibelt.json in project root.
Configuration example:
{
"i18nMsg": {
"input": "./resources/messages-all-langs.js",
"outMsg": "./src/messages",
"outTs": "./src/messages/i18nMessages.ts"
}
}Add arguments to script in package.json, for example:
"scripts": {
"i18n": "i18n-msg --input new/path --outTs new/constants.ts"
}Run script with CLI's specific env variables set.
i18n-msg:
- splits an input file containing all the translations into one file for each language
- creates a TypeScript source containing a constant for each message.
Add i18nMsg to .clibelt.json.
| .clibelt param | command line arg | env variable | Description | Example |
|---|---|---|---|---|
| input | i18n-input | I18N_INPUT | the input file containing all translations | ./resources/messages-all-langs |
| outMsg | i18n-out-msg | I18N_OUT_MSG | splitted messages output directory | ./src/messages |
| outTs | i18n-out-ts | I18N_OUT_TS | TypeScript constants output file | ./src/messages/i18nMessages.ts |
Example:
{
"i18nMsg": {
"input": "./resources/messages-all-langs.js",
"outMsg": "./src/messages",
"outTs": "./src/messages/i18nMessages.ts"
}
}pwd2hash generates an hash for input string
No configuration is required, just add to package.json script and run:
npm run pwd2hash string_to_hashtest