Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
yeoman-generator
Advanced tools
Rails-inspired generator system that provides scaffolding for your apps
Yeoman Generator is a scaffolding tool for building web applications. It provides a powerful and flexible way to create and manage project templates, allowing developers to quickly set up new projects with a consistent structure and configuration.
Creating a Basic Generator
This feature allows you to create a basic Yeoman generator that copies a template file to the destination directory. The `copyTpl` method is used to process the template with provided data.
const Generator = require('yeoman-generator');
module.exports = class extends Generator {
writing() {
this.fs.copyTpl(
this.templatePath('index.html'),
this.destinationPath('index.html'),
{ title: 'Templated HTML' }
);
}
};
Prompting User Input
This feature allows you to prompt the user for input during the generator's execution. The `prompt` method is used to ask questions and store the answers.
const Generator = require('yeoman-generator');
module.exports = class extends Generator {
async prompting() {
this.answers = await this.prompt([{
type: 'input',
name: 'name',
message: 'Your project name',
default: this.appname // Default to current folder name
}]);
}
};
Composing with Other Generators
This feature allows you to compose your generator with other generators. The `composeWith` method is used to integrate another generator into your own.
const Generator = require('yeoman-generator');
module.exports = class extends Generator {
initializing() {
this.composeWith(require.resolve('generator-other/generators/app'));
}
};
Plop is a micro-generator framework that makes it easy to create code generators that are specific to your project. It is simpler and more lightweight compared to Yeoman Generator, focusing on generating files based on templates and user prompts.
Hygen is a fast and lightweight code generator that is designed to be easy to use and integrate into existing projects. It emphasizes simplicity and speed, making it a good alternative to Yeoman Generator for smaller or more focused tasks.
Slush is a scaffolding tool that uses Gulp for its build system. It allows you to create and run generators similar to Yeoman Generator but leverages the Gulp ecosystem for task automation and file manipulation.
A Rails-inspired generator system that provides scaffolding for your apps.
If you're interested in writing your own Yeoman generator we recommend reading the official getting started guide.
There are typically two types of generators - simple boilerplate 'copiers' and more advanced generators which can use custom prompts, remote dependencies, wiring and much more.
The docs cover how to create generators from scratch as well as recommending command-line generators for making other generators.
For deeper research, read the code source or visit our API documentation.
To debug a generator, you can pass Node.js debug's flags by running it like this:
# OS X / Linux
node --debug `which yo` <generator> [arguments]
# Windows
node --debug <path to yo binary> <generator> [arguments]
Yeoman generators also use a debug mode to log relevant informations. You can activate it by setting the DEBUG
environment variable to the desired scope (for the generator system scope is generators:*
).
# OS X / Linux
DEBUG=generators/*
# Windows
set DEBUG=generators/*
BSD license Copyright (c) Google
FAQs
Rails-inspired generator system that provides scaffolding for your apps
We found that yeoman-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.