<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ yeoman - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ yeoman - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 27 Jul 2026 15:23:19 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/yeoman/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Creating Yeoman generators easily with yeoman-easily ]]>
                </title>
                <description>
                    <![CDATA[ By Krist Wongsuphasawat I’ve used Yeoman to start many of my projects. It’s an amazing web scaffolding tool. But after creating my own generators several times, I saw the repetitive tasks, somewhat lengthy code, and part of the generator code that co... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/creating-yeoman-generators-easily-with-yeoman-easily-cf552aef0d2f/</link>
                <guid isPermaLink="false">66c348240fa3812cdd5ea9b1</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ open source ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ yeoman ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 01 Aug 2016 16:44:51 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*80vnFUltjdnV38Owrjr95g.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Krist Wongsuphasawat</p>
<p>I’ve used <a target="_blank" href="http://yeoman.io/">Yeoman</a> to start many of my projects. It’s an amazing web scaffolding tool.</p>
<p>But after creating my own generators several times, I saw the repetitive tasks, somewhat lengthy code, and part of the generator code that confused me every time.</p>
<p>At one point, I ended up hacking a small utility that I kept copying over and over from project to project. I spent a weekend organizing it and adding several more features to take care of repetitive tasks.</p>
<h3 id="heading-and-yeoman-easily-was-born">And yeoman-easily was born.</h3>
<p><a target="_blank" href="https://github.com/kristw/yeoman-easily">yeoman-easily</a> helps with the following tasks when creating a generator with Yeoman:</p>
<h4 id="heading-advantage-1-confirmation">Advantage #1: Confirmation</h4>
<p>Often you would like to ask for user confirmation before proceeding. The first code block below shows how to write this with plain Yeoman. The second code block shows how to write it with the help of yeoman-easily.</p>
<p>With yeoman-easily, you can ask for confirmation before proceeding in one line. <code>easily.confirmBeforeStart(message)</code> then <code>easily.checkForConfirmation()</code> returns the result.</p>
<h4 id="heading-advantage-2-prompting"><strong>Advantage #2: Prompting</strong></h4>
<p>Handling results from the prompt, then choosing which prompt to display used to be complicated.</p>
<ul>
<li><code>this.prompt()</code> returns a promise which needs to be handled to obtain the answers and store them. The answers are commonly stored into <code>this.props</code>. This block of code has to be written again and again.</li>
<li>A parent generator often passes the parameters to the child generator via options. From what I have seen, many generators will hide the prompts for fields that are present in the options. (Yes, you have to write code to check that.) Then combine answers from prompts and options into <code>this.props</code>.</li>
</ul>
<p>For convenience, yeoman-easily:</p>
<ul>
<li>Handles storing user’s answers from the prompts into <code>this.props</code>. Just call <code>easily.prompt(prompts)</code> instead of <code>this.prompt(prompts)</code></li>
<li>Can automatically skip a prompt if an option with the same name is present. It will also copy the value of existing <code>this.options[field]</code> into <code>this.props[field]</code>.</li>
<li>Can register common prompts via <code>easily.learnPrompts(prompts)</code> and allow looking up prompts by name while calling <code>easily.prompt()</code>. This can save a lot of time if you create multiple generators that ask similar questions.</li>
</ul>
<h4 id="heading-advantage-3-composing"><strong>Advantage #3: Composing</strong></h4>
<p>Yeoman generator can call (<code>composeWith</code>) another generator from another package or local subgenerator, but the current syntax for doing so is somewhat long. I am still not sure what the <em>local</em> field means.</p>
<p>yeoman-easily simplifies the syntax to <code>easily.composeWithLocal(name, namespace, options)</code> and <code>easily.composeWithExternal(package, namespace, options)</code>.</p>
<h4 id="heading-advantage-4-file-handling"><strong>Advantage #4: File handling</strong></h4>
<p>Yeoman provides flexible APIs for file handling to cover many scenarios. But it takes a few lines to perform common task such as copying a file from the template directory to the destination directory. A function for bulk copying also exists, but it’s discouraged.</p>
<p>To address the above issues, yeoman-easily:</p>
<ul>
<li>Provides I/O functions that wraps <code>this.fs.xxx</code> and also resolves <em>template</em> and <em>destination</em> directory for common cases (from template to destination). These functions include <code>read</code>, <code>write</code>, <code>writeJSON</code>, <code>extendJSON</code>, <code>exists</code>, <code>copy</code>, and <code>copyTemplate</code>. I have a full list in my <a target="_blank" href="https://github.com/kristw/yeoman-easily/blob/master/docs/api.md">API documentation</a>.</li>
<li>Provides functions for mass copying both static and dynamic files based on glob pattern. See <code>easily.copyFiles(…)</code> in the example below.</li>
</ul>
<h4 id="heading-advantage-5-method-chaining">Advantage #5: Method chaining</h4>
<p>yeoman-easily was created with chaining in mind and support method chaining for fluent coding.</p>
<h3 id="heading-putting-it-all-together">Putting it all together</h3>
<p>Here’s an example that demonstrates all of these advantages together into one generator:</p>
<p>The yeoman-easily package is now available on npm. Visit the <a target="_blank" href="https://github.com/kristw/yeoman-easily">github repo</a> for more details, <a target="_blank" href="https://github.com/kristw/yeoman-easily/blob/master/docs/api.md">API documentation</a> and examples. I welcome your pull requests and bug reports.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
