
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
create-from-template
Advanced tools
Create a component from a template.
From your favourite package manager:
yarn add -D create-custom-template
Now you should be able to create from templates
node node_modules/create-from-template
or add add a script to your package.json
{
// ...
"scripts": {
// ...
"cft": "node node_modules/create-from-template"
}
// ...
}
then
yarn cft
In order to configure cft, open your package.json, search (or add) "config", and create "cft" property with the following options.
package.json
{
// ...
"config": {
"cft": {
// Template name
// es. "Dumb component"
"name": "template_name",
// templatePath specifies the path, starting from your
// app root folder, of the templates folder
// es. "node_modules/cft_adapter"
//
// (default) "node_modules/create-from-template/src/template"
//
"srcPath": "path_to_template_folder",
// destPath specifies where to create your component
// It also starts from your root folder
// es. "src/common/components"
//
// (default) "app/components"
//
"destPath": "path_to_destination_folder"
}
}
// ...
}
Cft support multiple templates. When you run the script it will ask you which template you want to use.
To setup multiple templates, just set config/cft as array:
{
// ...
"config": {
"cft": [
{
"name": "Stateless components",
"templatePath": "path_to_stateless_template_folder",
"destPath": "path_to_stateless_destination_folder"
},
{
"name": "Containers",
"templatePath": "path_to_container_template_folder",
"destPath": "path_to_container_destination_folder"
},
{
"name": "Generic module",
"templatePath": "path_to_generic_modules_template_folder",
"destPath": "path_to_generic_modules_destination_folder"
}
]
}
// ...
}
You can place your custom template wherever you want. I suggest you to create a new repo and install it as dev dependency.
Ok, let's create a custom template.
A custom template is a template folder which contains a list of files. Each file must export a function.
es.
node_modules/
cft_adapter/
template/
file.js
my_other_file.scss
template/file.js
module.exports = params => `
class ${params.name} {
constructor() {
return this
}
}
`;
template/my_other_file.scss
module.exports = (params) => `
.root {
display: block
}
`
The string returned from the template function rapresents your output.
Within the function you can use some parameters.
FAQs
Create a component from a template
We found that create-from-template 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.