Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
rollup-plugin-app-utils
Advanced tools
Common application build utils: i18n strings bundler, html injects, prepare and clean directories
import Utils from 'rollup-plugin-app-utils'
Utils.i18nBundler({
target: localesDir,
baseLanguage: 'en',
// Optional
transformer: (lang, data) => {
return data
}
})
then in your JS import translations using below line
import translations from 'i18n.translations'
console.log(translations.en)
i18n bundler reads json files from the specified directory and prepares a JSON structure. It uses base language directory as reference directory and
en
folder but not in te
folder, then when you build, the i18nBundler will create file and copy the content from base language folder for you. In a same way, if te
folder contains test.json
but en
folder does not, then test.json
will be removed from the te
folderFor example, if you have locales folder with this structure and content,
{
"en": {
"onlyEng.json": {
"wasInENonly": "yes"
},
"test.json": {
"willbeAdded": "willbeAdded",
"willnotOverride": "en text"
}
},
"te": {
"test.json": {
"willbeRemoved": "willbeRemoved",
"willnotOverride": "te text"
}
}
}
it will be transformed to below:
{
"en": {
"onlyEng": {
"wasInENonly": "yes"
},
"test": {
"willbeAdded": "willbeAdded",
"willnotOverride": "en text"
}
},
"te": {
"onlyEng": {
"wasInENonly": "yes"
},
"test": {
"willbeAdded": "willbeAdded",
"willnotOverride": "te text"
}
}
}
Please check test-data
folder for example structure. Then run npm test
and take a look at test-data-copy/output.js
and test-data-copy/locales
for a better understanding.
Helps to copy static content from during build, this does the job in a synchronous way.
Utils.copyAssets({
// Source -> Target.
'./test-data': './test-data-copy',
'./test': './test-new'
}, filterFun) // uses fs-extra `copySync`. You can also pass filter function
Helps to prepare directories during build, this does the job in a synchronous way. For example, during thee build if you want to use dynamically named folder name, this method can be used to create directories. We use this to create a folder with unique name and then put static content in it.
Utils.prepareDirectories(somedir1)
// or
Utils.prepareDirectories([somedir2, somedir3])
Helps to cleanup directories during build, this does the job in a synchronous way. We use this to clean the dist folder before rollup write the output to dist folder.
Utils.emptyDirectories(somedir1)
// or
Utils.emptyDirectories([somedir2, somedir3])
Helps to generate a html page from template and write to a target html file. This does the job in a synchronous way.
For example you have below html:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>{title}</title>
</head>
<body>
{keyOne}
</body>
</html>
Then in your rollup config if you do below:
Utils.htmlInjector({
template: './test-data-copy/test.template.html',
target: './test-data-copy/tdir/index.html',
injects: {
title: '___title___',
keyOne: '___keyOne____'
}
}),
The output looks like this:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>___title___</title>
</head>
<body>
___keyOne____
</body>
</html>
Please check guidelines for more details.
FAQs
Common application build utils: i18n strings bundler, html injects, prepare and clean directories
We found that rollup-plugin-app-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.