Skip to content

Releases: yeoman/generator

v0.18.3

04 Dec 21:09
Compare
Choose a tag to compare

Bug fixes

  • Fix helpers.mockPrompt default value handling for confirm prompts
  • Generator#template() now correctly escape <%%= x %> template notation. Note that it's probably best to start using Generator#fs.copyTpl().

Fixing events

Yeoman-generator have a very old event triggering system, and this was causing issues as it could triggers unexpected named events. This code have been cleaned up, it is not 100% backward compatible, but this is such an unused part of the code that we'll bump it in a patch version. Thing to know, now when running a generator, it'll trigger 3 kind of events:

  • run (generator.run() is called)
  • method:<method name> for each queue method running.
  • end (once the generator is done running)

For generator authors, don't use these events. The priority queue system is plenty enough to manage the life cycle of your generator. These events are used internally by our API, and might be useful for tools implementor (although I doubt it).

v0.18.2

02 Dec 17:51
Compare
Choose a tag to compare
  • helpers.mockPrompt() (used in RunContext#withPrompt()) now correctly select default values for list prompts. a0fee1c

v0.18.1

01 Dec 14:04
Compare
Choose a tag to compare

Lock down the glob dependency 3117e37 a newer version caused it to not return files on Windows which resultet in yeoman/yo#242.

v0.18.0

14 Nov 07:15
Compare
Choose a tag to compare

It's been multiple months since our last minor version bump. 0.18.0 bring lots of new features and strive at improving the composability features (first introduced in 0.17).

New features!

Storing prompt answers

Using the {store: true} property on a prompt will store the user answers in a machine global storage. This mean next time the user run a generator, the default answer will be filled with the value previously stored.

Careful notice, providing a default value prevent user from returning empty answers.

Huge thanks to @stefanbuck for the PR #688

New File System

Since version 0.17, the Yeoman file system proved to be poorly designed to attack composability issues. That's why with 0.18 we release a completely rethought file system abstraction. You can see the discussion and design process taking place in this issue.

Every legacy methods (this.write, this.copy, etc) have been back ported to use this new system. So updating to 0.18.0 should magically improve your generator.

New fs methods

The core system can be accessed on generator.fs. This object is an instance of mem-fs-editor and provide the same methods.

This system is way simpler than the current legacy method and doesn't do any kind of magic. It won't automatically compile templates (use this.fs.copyTpl() for this), it won't pass this as template context, and it won't automatically assume paths are relative to anything.

An example/usual usage would be:

 js
this.fs.copyTpl(
  this.templatePath('mocha/base-test.js'),
  this.destinationPath('test/index.js'),
  { projectName: 'my-awesome-module' }
)

As you can see, we also added two new paths helpers:

  1. this.templatePath() which is: path.join(this.sourceRoot(), ...rest)
  2. this.destinationPath() which is: path.join(this.destinationRoot(), ...rest)

Try it out and please give us feedback on how you like this new API. It is more verbose than our legacy methods, but it is clearer and less magical.

Note that the legacy system will remain available at least until version 1.0.0

What about the 0.17.0 this.src and this.dest file utils

These should be considered deprecated. The design decision they make isn't a good fit with composability and will you issues on the long run.

File writing filters

Ever wished to apply custom filters on every file write? Beautifying files, normalizing whitespace, etc, can be hand grabbed.

Once per Yeoman process, we will write every file to disk. This process is passed through a vinyl object stream (just like gulp). Any author can register a transformStream to modify the file path or content.

For example:

this.registerTransformStream(beautify({indentSize: 2 }));

Note that every file type will be passed through this stream. So make sure the transform stream you provide pass through files you don't modify.

This feature means you can basically use any gulp plugin to process yeoman files during writing. Tools like gulp-if or gulp-filter will help filter invalid type and pass them through.

Improvements

  • Tests using helpers.run() won't output to the console keeping the test output clean. Every log method is now a sinon.stub() making it easy to assert your generator outputted the correct content.
  • Testing run context now automatically run your tests in a unique tmpdir. No need to manually call helper.run().inDir() anymore.
  • assert.fileContent and assert.noFileContent accept a String as arguments (before we just accepted Regex)
  • The Conflicter have been refactored to be simple and easy to use.

Installation methods only running once

npm and bower installation helpers are now always running once per process. This was a change made in 0.17, but we extended the feature to cover every use/methods who could launch these process.

This was a breaking an edge case in 0.17. But for the sake of clarity, let's be clear. The following construct will break:

this.installDependencies({
  callback: this.async() // This will block the process forever, and node will fail
});

Every install method will be registered on the install run queue. Using this.async() as a callback will create a deadlock.

Fixes

  • Installation methods (npm, bower helpers) now correctly pass the options to the spawn process.
  • When a conflict occurs on a directory, we don't show the diff option anymore. (selecting diff on directory threw an error)
  • You can now correctly overwrite the stdio with generator.spawnCommand()
  • generator.composeWith() now correctly resolve the local option path.

Meta

  • We've extracted yeoman-environment on it's own repository. This mean these two core Yeoman parts can now evolve at their own pace.
  • All our tests now uses tmpdir for testing making them more reliable.
  • Completely remove network connection from our test suite - it is now way faster.

Potentially breaking change

  • We stopped manually mocking Inquirer in tests. Mainly because Inquirer parses values in ways we didn't imitate and this caused too much issue. Now we rely more on Inquirer and only mock the minimum. This also mean we don't create the magic errors property during test. You can listen for generator errors instead.
  • We removed require('yeoman-generator').inquirer. Require your own version from now on.
  • We removed generator.shell and generator.request. Require your own version.

v0.17.7

28 Sep 06:42
Compare
Choose a tag to compare

Feature

  • Log a message explaining Yeoman will scaffold the project in a parent directory if user have a .yo-rc.json file. Hopefully this will helps will all those issues opened about users scaffolding apps in their home directory.

Bug fixes

  • Fix invoke and hookFor race conditions. Note: When upgrading to 0.17, you should strive to use composeWith for all your composition mean.
  • extract() now doesn't strip paths by default (and now take options to define the desired behavior)

v0.17.6

14 Sep 04:59
Compare
Choose a tag to compare

Bug fixes

  • Wiring methods won't encode utf-8 character
  • helpers.decorate returns original fn result when stub is false
  • installDependencies now correctly schedule itself as part of the install priority

Some general cleanup, typos fixes.

v0.17.5

02 Sep 05:15
Compare
Choose a tag to compare

Re-add generator.request() module for backward compatibility reason (sorry for slipping that bug in!)

Note that you should ideally require your own version of request if you use this feature. We'll deprecate yeoman provided one in a future release.

v0.17.4

02 Sep 02:02
Compare
Choose a tag to compare
  • Update dependencies (notably Inquirer 0.7 which bring a slightly refreshed style to the prompt)
  • RunContext methods can now be called multiple times (Thanks @thaiat)

v0.17.3

19 Aug 06:35
Compare
Choose a tag to compare

Fixes

  • helper.mockPrompt() now support Inquirer's asynchronous methods.

Meta

  • Now uses cross-spawn internally for the spawn method.

v0.17.2

04 Aug 20:52
Compare
Choose a tag to compare

Fixes

  • Fix invoke not working when the initiating generator and the invoked generator where both based on 0.17 version.
  • In test we don't validate skipped prompt (because there's no answer, so validation always fail) - Thanks @bajtos
  • Expand logging (this.log) to not be limited to strings
  • Options now only use default if they're null