Giter Club home page Giter Club logo

environment's Introduction

Welcome, Friend!

Yeoman is a robust and opinionated set of tools, libraries, and a workflow that can help developers quickly build beautiful, compelling web apps.

image

Code of Conduct

Everyone in this community (from core members to random committers and volunteers) are asked to please act in accordance with the Yeoman Community Contributor Code of Conduct. We encourage you to follow these social rules which help guide our interactions with each other, and ensure we provide a safe environment for everyone. We aim to make Yeoman a positive, welcoming, open and inclusive project and community.

Code of Conduct

Issue Submission

Make sure you've read the issue submission guidelines before you open a new issue.

Yeoman is composed of a number of different sub-projects, most of which have their own dedicated repository. If you are looking for a repo for a particular piece, you'll find it on the organization page.

Feature requests

Feature requests should be submitted to the repo it concerns. Submit to yeoman/yeoman if you're unsure, otherwise the repositories for our officially maintained generators can be found here.

Contribute

See the contributing docs

Support

Need help or have a question?

Please don't use the issue trackers for support/questions.

Links

Team

Yeoman is beautifully crafted by these people and a bunch of awesome contributors

Addy Osmani Sindre Sorhus Pascal Hartig Stephen Sawchuk Simon Boudrias
Addy Osmani Sindre Sorhus Pascal Hartig Stephen Sawchuk Simon Boudrias
Brian Ford Eddie Monge Paul Irish Hemanth.HM Revath S Kumar
Brian Ford Eddie Monge Paul Irish Hemanth.HM Revath S Kumar
Jimmy Moon Frederick Ros Mickael Daniel Eric Bidelman Matija Marohnić
Jimmy Moon Frederick Ros Mickael Daniel Eric Bidelman Matija Marohnić
Kevin Mårtensson Arthur Verschaeve Michael Kühnel Mehdy Dara Ulises Gascon
Kevin Mårtensson Arthur Verschaeve Michael Kühnel Mehdy Dara Ulises Gascon

Backers

Love Yeoman work and community? Help us keep it alive by donating funds to cover project expenses!
[Become a backer]

License

BSD license Copyright (c) Google

environment's People

Contributors

addyosmani avatar ahmednuaman avatar arthurvr avatar btford avatar dependabot[bot] avatar eddiemonge avatar floatdrop avatar gillesfabio avatar github-actions[bot] avatar greenkeeper[bot] avatar hemanth avatar jdespatis avatar jridgewell avatar kevva avatar mklabs avatar mshima avatar passy avatar paulkinlan avatar revathskumar avatar rjw57 avatar ruyadorno avatar sboudrias avatar sebv avatar sindresorhus avatar sleeper avatar smackesey avatar thaiat avatar timrwood avatar toilal avatar wesleytodd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

environment's Issues

Generator creates all app files in the root folder instead of specified [windows]

Platform : windows

I was checking out yeoman-app and found that when running a generator all the generator files are created in the folder where I run the app irrespective of whet folder I choose I raised an issue here yeoman/yeoman-app#104

But then I wrote a simple test and tried it out as below and the issue seems to be in yeoman-environment itself, say I executed this in a folder d:/app folder and i have a sub folder there testDir and I switched to the sub directory before invoking env.run() but still files were created in the d:/app folder instead of d:/app/testDir folder. But there is a empty set of all the folders alone created inside d:/app/testDir

Seems like the mkdir commands are executed on the current directory while copy files are executed on the directory where environment was initilized

var fs = require('fs');
var _ = require('lodash');
var yeoman = require('yeoman-environment');
var env = yeoman.createEnv();

var init = function () {
  //process.chdir('./testDir');
  console.log('init yeoman-environment');
  console.log(process.cwd());
  // Here we register a jhipster generator based on its path. Providing the namespace
  env.register(require.resolve('generator-jhipster'), 'jhipster:app');
};

var runApp = function () {
  console.log('running yo app');
  run('jhipster:app', './testDir')
};

function sendCommandToAppWindow(name, data) {
  if (data instanceof Error) {
    console.error(data);
    data = data.toString();
  }
}

function run(generatorName, cwd) {

  if (!generatorName) {
    return sendCommandToAppWindow('generator:error', new Error('You must provide a generator name'));
  }

  if (!fs.existsSync(cwd)) {
    return sendCommandToAppWindow('generator:error', new Error('The given path does not exist or is not a directory'));
  }
  console.log(process.cwd());
  process.chdir(cwd);
  console.log(process.cwd());

  function done(err) {
    if (err) {
      return sendCommandToAppWindow('generator:error', err);
    }
  }

  // invoke generator
  env.run(generatorName, { 'skip-install': true }, done);
}

module.exports = {
  init : init,
  runApp : runApp
}

Namespace resolving incorrectly from Environment.prototype.namespace

Hi,

I've been working with yeoman-environment over the past couple of days as I'm wanting it scaffold out various bits from a Nodejs back end. Yeoman's been great so far.

However I'm having an issue when it's trying to resolve a namespace from a path.

The following path will resolve the namespace incorrectly (in environment.js:Environment.prototype.namespace)

c:\projects\yeoman\generators\generator-example\generators\app\index.js 
EXPECTED: example:app
ACTUAL: example:generators:app

Lookups:

['.', 'generators', 'lib/generators']

This happens because the first "generators" in the path is being replaced. I believe this should replace the last matched lookup in the reduce function like:

  // if `ns` contain a lookup dir in it's path, remove it.
  ns = lookups.reduce(function (ns, lookup) {
    // ensure that the lookup is removed from the lowest level folder, and that partial folder names aren't removed
    var folders = ns.split(path.sep);
    var replaceIndex = folders.lastIndexOf(lookup);
    if (replaceIndex > -1) {
        folders.splice(replaceIndex, 1);
    }
    var resolvedPath = folders.join(path.sep);
    return resolvedPath;
  }, ns);

This will also avoid it doing replaces like:
...\generator-example\generators-foo\app\index.js
...\generator-example-foo\app\index.js

Get arguments/options of sub-generator

Hi, I'm not sure if this is possible, so if not, just tell me and close the issue :).

So in a sub-generator, it's possible to define arguments and options as described in the section Arguments (and Options). Is it possible to retrieve those together with the generators metadata?

The reason I'm asking this is because I'm writing a VS Code plugin and I support sub-generators. But some sub-generators have arguments, which I'm not aware off. As you can see in this block off code, I'm running the sub-generator, if it throws an error with a specific message, I show an input box where the user can pass in it's argument. This feels very hacky and I was hoping for a better way.

The same goes for the options. If I could retrieve the options of a sub-generator, I can show a multi-select list where the user can pick the options he wants.

Any thoughts on this?

Build is currently failing

The build is currently failing in 0.10 and 0.12. It would be great to get these green again to have confidence that #61 is truly resolved.

1) Environment Resolver #lookup() "before all" hook:
     Error: timeout of 100000ms exceeded. Ensure the done() callback is being called in this test.

Simplify API

Just some thoughts and questions on things we can do to simplify the API. I'd be happy to open separate ticket for things, but want to hear them out first.

  • Why does this module depend on yeoman-generator? And shouldn't the usage example be var yeoman = require('yeoman-generator'); => var env = require('yeoman-environment');?
  • I think we should drop env.createEnv() as you can already do new Env()? Which is IMHO better.

// The #lookup() method will search the user computer for installed generators. The search
// if done from the current working directory.
env.lookup(function () {
  env.run('angular', { 'skip-install': true }, done);
});

Any reason we have to do the lookup first? Can't just env.run lazy trigger the lookup on the first run?

I would like to have a way to run a generator with a single method call.

The end event doesn't seem to work: https://github.com/yeoman/yo/blob/8f8d16e10c13d11faf7034ca2f1e59589a6081bd/cli.js#L78-L80 How is it different from the callback to env.run? Can we drop it?

Is the help method used at all

Environment.prototype.help = function help(name) {
?

env.getGeneratorsMeta() is weird as it only works after env.lookup. Could we instead pass generator metadata in the env.lookup callback?

I'm not a big fan of the aliasing functionality. It complicates things a lot. Is there a way we can drop or simplify this?

https://github.com/yeoman/yo/blob/8f8d16e10c13d11faf7034ca2f1e59589a6081bd/cli.js#L75-L76

Anything anyone else think can be improved?

"Arguments with spaces" don't flow to options

I can run the following command successfully and get the proper name of Example Service in this.options.name:
yo my-generator:generate service "Example Service"

However, when I run the following command, the name is truncated as "Example in this.options.name:
env.run('yo my-generator:generate service "Example Service"', {'skip-install': true}, function (err) {});

My package.json contains:
"yeoman-environment": "^1.6.6"
"yeoman-generator": "^1.0.1"

API to get list of possible options

Currently there is no way to get all possible options for an yeoman generator (I mean '--coffee' and etc). I think this functionality can be very useful

Incorrect documentation on JSDoc usage example

This page currently says:

var yeoman = require('yeoman-generator');

var env = yeoman.createEnv();

// The #lookup() method will search the user computer for installed generators. The search
// if done from the current working directory.
env.lookup(function () {
  env.run('angular', { 'skip-install': true }, done);
});

where that first line should be:

var yeoman = require('yeoman-environment');

Fix and enhance resolver.getNpmPaths

The resolver.getNpmPaths() method makes some basically wrong assumptions.

The entire block from line 123 to line 142 (comments included) it's too based on the experience/environment of the developer who implemented the code.

Npm allows to configure a custom path for global node_modules directory and the default one can also be different from one platform to another.

This can lead to unexpected behaviour: I configured a custom npm prefix, installed the generator-webapp globally without problems and now I can't find it in the list of available generators.

It would be better to take advantage of npm api to programmatically get the global node_modules path, in order to ensure a more "environment-agnostic" way to search for generators.

Check out these resources:

The programmatic api seems to be supported from npm version 2.0.1 (the oldest one on Github).


This is a simple snippet that shows how to get it with npm api:

var npm = require('npm');

function npmGlobalDir(cb) {
  npm.load({}, function(err) {
    if (err) {
      throw err;
    }

    cb(npm.globalDir);
  });
}

Obviously, the getNpmPaths() should no longer be a synchronous method that returns a value, but one which expects a callback.
Also the lookup() method should change accordingly.

Extracting resolver.getNpmPaths() to a separate node module

In a project that I'm working on, I'm implementing plugin support using the approach that Yeoman uses:

  • Scan all npm paths for a matching pattern (like generator- but related to my project).
  • Require them accordingly.

I found yeoman-environment's getNpmPaths() while attempting to write a similar function. In order to reuse this code, I'm requiring the whole yeoman-environment, but I feel this function could be a candidate for a separate module, as other people might be trying to resolve this issue as well, and they could rely on the experimentation you put in when implementing that function.

What do you think about extracting this function as a separate node module (maybe something like npm-path-find)?

Can you please follow semver?

Hello,
Dear Yeoman maintainers,

A while ago I submitted a PR (landed in 72c91a8) which implemented a new method. A while ago I woke up and noticed that there was a release: 1.2.7. That's a patch version bump. Really cool, thanks for the quick release, though, why a patch version bump?

So I have a question: does the yeoman team follow semver? If not, is there a possibility to do so, please? If you don't want to use semver (which is the default convention on npm), I think you will have to warn for that in the documentation.

I see many people using the ^ when it comes to deps developed by the yeoman team. That would then be invalid as npm assumes semver by default.

Thanks in advance.
东 栋

What's up Yeoman-Environment

To be good semver citizens I guess our first release will be 1.0 (plus the system have been pretty stable as it's only extracted from yeoman-generator).

So, it's a good occasion to drop the bad parts. I open this thread as a free discussion. I'd prefer we keep changes small and focused, but bigger ideas are welcomed too.

Todos for 1.0

  • Remove property aliases (args <> arguments, etc) - These are just confusing. Let's stick with one version.
  • Remove multiple kind of data expected. We often allow Strings with spaces or Array as parameter - let's just accept array.
  • Generate Environment API doc
  • Port yeoman-generator to use this module (of course)
  • Port yo to use this module

Cannot find module when using Environment.getByPath

I am trying to embed my generator in my project using the getByPath method that was introduced here in PR #11

My folder structure looks like this:

- /generators
--- /adrizer     <---- My embeded generator
------- /generators
---------- /app
------------- index.js
---------- /test
------------- index.js
------- package.json

I am trying to test running this generator using this command:

./node_modules/.bin/yo ./generators/adrizer adrizer

And I get this error:

module.js:471
    throw err;
    ^

Error: Cannot find module '/Users/adamduro/Workspace/projects/adrizer-dashboard/generators/adrizer/'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.resolve (internal/module.js:27:19)
    at Environment.resolveModulePath (/Users/adamduro/Workspace/projects/adrizer-dashboard/node_modules/yeoman-environment/lib/environment.js:461:18)
    at Environment.register (/Users/adamduro/Workspace/projects/adrizer-dashboard/node_modules/yeoman-environment/lib/environment.js:161:25)
    at Environment.getByPath (/Users/adamduro/Workspace/projects/adrizer-dashboard/node_modules/yeoman-environment/lib/environment.js:276:10)
    at Environment.get (/Users/adamduro/Workspace/projects/adrizer-dashboard/node_modules/yeoman-environment/lib/environment.js:265:10)
    at Environment.create (/Users/adamduro/Workspace/projects/adrizer-dashboard/node_modules/yeoman-environment/lib/environment.js:296:24)
    at Environment.run (/Users/adamduro/Workspace/projects/adrizer-dashboard/node_modules/yeoman-environment/lib/environment.js:372:24)
    at /Users/adamduro/Workspace/projects/adrizer-dashboard/node_modules/yo/lib/cli.js:140:11
    at Array.forEach (native)

Any idea what I am doing wrong? Or was there a change to the way that require.resolve work in Node 6?

Tests failing on OS X

[19:36:14] Using gulpfile ~/dev/environment/gulpfile.js
[19:36:14] Starting 'static'...
[19:36:14] Starting 'test'...
Skipping tests for global generators. Please setup `NODE_PATH` environment variable to run it.


  TerminalAdapter
    #prompt()
      ✓ pass its arguments to inquirer 
    #diff()
[19:36:15] Finished 'static' after 1.1 s

removed added

letvar

      ✓ returns properly colored diffs 
    #log()
      ✓ calls console.error and perform strings interpolation 
      ✓ substitutes strings correctly when context argument is falsey 
      ✓ boolean values 
      ✓ #write() numbers 
      ✓ #write() objects 
    #log
      ✓ #write() pass strings as they are 
      ✓ #write() accepts utile#format style arguments 
dummy
      ✓ #writeln() adds a \n at the end 
✔ dummy
      ✓ #ok() adds a green "✔ " at the beginning and \n at the end 
✖ dummy
      ✓ #error() adds a green "✗ " at the beginning and \n at the end 
      statuses
        - #skip()
        - #force()
        - #create()
        - #invoke()
        - #conflict()
        - #identical()
        - #info()

  Environment
    ✓ is an instance of EventEmitter 
    constructor
      ✓ take arguments option 
      ✓ take arguments parameter option as string 
      ✓ take options parameter 
      ✓ instantiates a TerminalAdapter if none provided 
      ✓ uses the provided object as adapter if any 
      ✓ instantiates a mem-fs instance 
    #help()
      ✓ output the general help 
      ✓ output the help with a custom bin name 
    #create()
      ✓ instantiate a generator 
      ✓ instantiate a scoped generator 
      ✓ pass options.arguments 
      ✓ pass options.arguments as string 
      ✓ pass options.args (as `arguments` alias) 
      ✓ prefer options.arguments over options.args 
      ✓ default arguments to `env.arguments` 
      ✓ pass options.options 
      ✓ default options to `env.options` content 
      ✓ throws if Generator is not registered 
      ✓ add the env as property on the options 
      ✓ add the Generator resolved path on the options 
      ✓ adds the namespace on the options 
      ✓ adds the namespace as called on the options 
    #run()
      ✓ runs a registered generator 
      ✓ pass args and options to the runned generator 
      ✓ without options, it default to env.options 
      ✓ without args, it default to env.arguments 
      ✓ can take string as args 
      ✓ can take no arguments 
      ✓ launch error if generator is not found 
      ✓ returns the generator 
    #register()
      ✓ store registered generators 
      ✓ determine registered Generator namespace and resolved path 
      ✓ throw when String is not passed as first parameter 
    #registerStub()
      ✓ register a function under a namespace 
      ✓ extend simple function with Base 
[19:36:15] Plumber found unhandled error:
 Error in plugin 'gulp-mocha'
Message:
    You must provide a stub function to register.
Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false
Stack:
Error: You must provide a stub function to register.
    at Environment.registerStub (/Users/sindresorhus/dev/environment/lib/environment.js:9:6430)
    at Function._throws (assert.js:292:5)
    at Function.assert.throws (assert.js:318:11)
    at Context.<anonymous> (/Users/sindresorhus/dev/environment/test/environment.js:302:14)
    at callFn (/Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runnable.js:250:21)
    at Test.Runnable.run (/Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runnable.js:243:7)
    at Runner.runTest (/Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:373:10)
    at /Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:451:12
    at next (/Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:298:14)
    at /Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:308:7
      ✓ throws if invalid generator 
[19:36:16] Plumber found unhandled error:
 Error in plugin 'gulp-mocha'
Message:
    You must provide a namespace to register.
Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false
Stack:
Error: You must provide a namespace to register.
    at Environment.registerStub (/Users/sindresorhus/dev/environment/lib/environment.js:9:6704)
    at Function._throws (assert.js:292:5)
    at Function.assert.throws (assert.js:318:11)
    at Context.<anonymous> (/Users/sindresorhus/dev/environment/test/environment.js:306:14)
    at callFn (/Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runnable.js:250:21)
    at Test.Runnable.run (/Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runnable.js:243:7)
    at Runner.runTest (/Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:373:10)
    at /Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:451:12
    at next (/Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:298:14)
    at /Users/sindresorhus/dev/environment/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:308:7
      ✓ throws if invalid namespace 
    #namespaces()
      ✓ get the list of namespaces 
    #getGeneratorsMeta()
      ✓ get the registered Generators metadatas 
    #namespace()
      ✓ create namespace from path 
      ✓ create namespace from scoped path 
      ✓ handle relative paths 
      ✓ handles weird paths 
      ✓ works with Windows' paths 
      ✓ remove lookups from namespace 
      ✓ remove path before the generator name 
    #get()
      ✓ get a specific generator 
      ✓ walks recursively the namespace to get the closest match 
      ✓ returns undefined if namespace is not found 
    #error()
      ✓ delegate error handling to the listener 
      ✓ throws error if no listener is set 
      ✓ returns the error 
    #alias()
      ✓ apply regex and replace with alternative value 
      ✓ apply multiple regex 
      ✓ apply latest aliases first 
      ✓ alias empty namespace to `:app` by default 
    .enforceUpdate()
      ✓ add an adapter 
      ✓ add a runLoop 
      ✓ add a shared mem-fs instance 
    .createEnv()
      ✓ create an environment 

  Environment Resolver
    #lookup()
      ✓ register local generators (194ms)
      ✓ register generators in scoped packages 
      ✓ register non-dependency local generator (586ms)
      ✓ local generators prioritized over global 
      - register global generators
      ✓ register symlinked generators 
      when there's ancestor node_modules/ folder
        ✓ register generators in ancestor node_modules directory 
        ✓ local generators are prioritized over ancestor 
    #getNpmPaths()
      with NODE_PATH
        ✓ walk up the CWD lookups dir 
        ✓ append NODE_PATH 
      without NODE_PATH
        ✓ walk up the CWD lookups dir 
        ✓ append best bet if NODE_PATH is unset 
        ✓ append default NPM dir depending on your OS 

  Store
    #add() / #get()
      ✓ normalize Generators 
      storing as module
        ✓ store and return the module 
        ✓ assign meta data to the module 
        ✓ assign dummy resolved value (can't determine the path of an instantiated) 
      storing as module path
        ✓ store and returns the required module 
        ✓ assign meta data to the module 
    #namespaces()
      ✓ return stored module namespaces 

  util
    ✓ is exposed on the Environment object 
    .duplicateEnv()
      ✓ copy environment 


  94 passing (1m)
  8 pending

---------------------|-----------|-----------|-----------|-----------|
File                 |   % Stmts |% Branches |   % Funcs |   % Lines |
---------------------|-----------|-----------|-----------|-----------|
   lib/              |     96.18 |     82.41 |        98 |     96.18 |
      adapter.js     |     95.65 |        75 |     83.33 |     95.65 |
      environment.js |     95.71 |     82.05 |       100 |     95.71 |
      resolver.js    |     95.16 |        80 |       100 |     95.16 |
      store.js       |       100 |       100 |       100 |       100 |
   lib/util/         |     77.61 |     56.25 |        60 |     77.61 |
      log.js         |        75 |     56.25 |     57.14 |        75 |
      util.js        |       100 |       100 |       100 |       100 |
---------------------|-----------|-----------|-----------|-----------|
All files            |      92.4 |     79.03 |     89.23 |      92.4 |
---------------------|-----------|-----------|-----------|-----------|


=============================== Coverage summary ===============================
Statements   : 92.4% ( 304/329 )
Branches     : 79.03% ( 98/124 )
Functions    : 89.23% ( 58/65 )
Lines        : 92.4% ( 304/329 )
================================================================================
[19:37:23] Finished 'test' after 1.13 min
[19:37:23] Starting 'coveralls'...
[19:37:23] Finished 'coveralls' after 2.96 ms
[19:37:23] Starting 'default'...
[19:37:23] Finished 'default' after 4.69 μs

Ability to use other require function in resolveModulePath

I was trying to use yeoman-environment in project that was built with webpack and encountered a problem with generators registration.
Webpack replace original require function with it's own, so trying to require a generator absolute path caused an error 'Cannot find module'.
My proposal is to allow to user to pass it's own require function to createEnv method with options parameter and use this function in resolveModulePath.

If you think my proposal is good I would happy to make PR (Changes that I propose are follows: https://github.com/anta-semenov/environment/commit/4505b7813913961cc2e151f7da82b98550d67440 )

registerGeneratorsIn function

Currently Environment provides the function findGeneratorsIn, which searches a list of paths and returns a list of generators within those paths. From what I can tell, the user still has to loop through each found module, registering any generators found within. If I am mistaken by all means correct me.

I would like to propose the addition of a registerGeneratorsIn method which receives a list of paths, uses the findGeneratorsIn function to find all the modules within these paths, and then registers all of the generators/sub-generators in the found modules. Namespaces could be generated using the namespace method.

If this addition makes sense I would be happy to start working on a PR.

Sub-sub-generators

When reading some code or doc, I came across stuff like yo name:sub:more (cf here), but reading some other code source, it looks like it will never be able to handle such a sub-sub-generator (see here) but I'm not 100% sure...

So... is there a way to handle sub-sub-generators? Is there a meaning to do something like yo angular:common:all? If not, would it be a good idea to consider supporting deeper level of sub-generators?

Fix gulp-jshint

jshint throws hard on our tests about undefined globals. They are in the .jshintrc so really I have no idea what is going on there...

dependency missing on fresh yo install

probably related to #67, I'm trying to do a fresh install of yo and when running it get the following error:

Error: Cannot find module 'yeoman-environment'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/Cellar/nvm/0.25.4/versions/node/v4.4.7/lib/node_modules/yo/lib/router.js:9:23)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

I looked in the node_modules folder and yeoman-environment is missing on the new install. manually installing 1.6.1 resolves the above error.

Node.js version: 4.4.7
npm version: 3.10.3

Remove Makefile

looks like make was used because gulp-mocha was broken. Should probably just run mocha directly no?

Yeoman shouldn't default to generator:app if subgenerator doesn't exist

The way we run a generator currently, is that we'll check at the generator namespace provided, and get rid of any namespace one by one until we find a match:

$ yo my:cool:generator
try > my:cool:generator
try > my:cool
try > my

This mean if someone typoed the subgenerator name, we'll always end up running the app generator.

This is a buggy behavior and we should fix it.

Improve #lookup() test performance

The #lookup() test install generators for real and is taking quite a while to run. We could probably speed this test a lot by stopping using npm and mocking the full environment to run the test in.

API to show previous step

Hi! Yeoman environment has a great API for integration with an external tool. I miss just one functionality : I need an ability to get (to show) a previous step. Something like 'goBack' if user want to change previous answer.

Running local generators by paths

We should support running a generators that are part of a project.

I see two solutions:

  1. Allow paths as generator name (e.g.: yo ./generators/generator-local)
  2. Add a standard local directory to the generators lookup (like always lookup for $PWD/yeoman - or similar)

Adding a lookup should be easy enough. Running via paths could be more difficult as that would probably require to change the way alias/namespace is working.

composeWith ignores priority groups when force is added as an option and force is ignored in the CLI.

From what I understand about composeWith, the method follows the priority group execution in the runLoop. For instance, if you call composeWith under install the composed generator and main generator should call install and any priority group lower (e.g. end).

This behavior seems to be ignored if the force option is passed in like the following:

 this.composeWith(require.resolve('../turbo'),{ force: true});

In addition, if you call the generator in the CLI and pass the force option like so

yo generator-something  --force true

The prompt still asks if you want to overwrite which shouldn't given the option.

I have two questions. Is there a way where we can attach an EventEmitter to the IO procedures so that if a copying fails or does not happen (a priority group is not run) the user knows about it?

Can't discover generators compiled with Babel6

I really like ES6 and build a generator using ES6 syntax in source.
I use Babel to transpile source to ES5.
Since Babel upgrade to 6.0 and Kill CommonJS default export behaviour

export default MyGenerator;

will be transformed to:

exports.default = MyGenerator;

and module.exports = exports["default"] will no longer exist

yeoman-environment can't discover my generator for me.

Consider add support to require('generator-xxx').default for all generators compiled with Babel?

Backwards incompatibility due to untildify requiring node4

I just re-installed one of my packages that depends on yeoman-test and have started getting an error because this package relies on @sindresorhus's https://github.com/sindresorhus/untildify version 3.0.1 which now requires node 4 and uses const. The semver tree has broken causing my once stable build to now fail.

I am currently using node 0.12.13 and my package has a dev dep on "yeoman-test": "1.0.0"

mygenerator/node_modules/yeoman-test/node_modules/yeoman-environment/node_modules/untildify/index.js:2
const osHomedir = require('os-homedir');
^^^^^
SyntaxError: Use of const in strict mode.

Finding global generators on io.js

For some reason global generator cannot be found on io.js - this also cause a test failure on Travis when using io.js.

Note: I have not reproduce this myself of a system, I need to investigate and reproduce. We know we have a test failure. That doesn't mean it is not working.

Copy error when trying to run a generator in the same environment twice

Hello there,

I'm not sure if this is supposed to work like this or if this is an error. But, when you call the same environment to run a generator again, it causes an assertion error for copy and copyTpl with glob patterns:

AssertionError: Trying to copy from a source that does not exist: envir-test/node_modules/generator-generator/subgenerator/templates/templates/**

Example :

const yeoman = require('yeoman-environment');
const env = yeoman.createEnv();

env.lookup(() => {
  env.run('generator', {'skip-install': true}, err => {
    console.log('done');
    env.run('generator', {'skip-install': true}, err => {
        console.log('done');
    });
  });
});

Everything works fine if I create a new environment each time I execute the generator.

Versions:

  • yeoman-environment: "^1.6.6"
  • generator-generator: "^3.1.0",
  • Node v7.10.0
  • Windows 10

resolve.getNpmPaths - nvm prefix

Might be related to #52


I'm running into an issue when trying to load installed generators with env#getGeneratorsMeta(), and I think it's related to nvm and npm prefix being different than the defaults.

My test sample is something like:

var env = require('yeoman-environment').createEnv();
env.lookup((err) => {
  console.log(env.getGeneratorsMeta());
});

Looking at the getNpmPaths() method, I can see that $NODE_PATH is used when defined, and I can get the env lookup working with:

NODE_PATH="/home/user/.nvm/versions/nodes/v6.0.0/lib/node_modules" node test.js

My question is, would you agree on adding the result of npm prefix to the lookup paths automatically ?

env.lookup() is asynchronous, so we might be able to introduce a call to .exec('npm prefix -g') if you don't mind the performance penalty it might introduce.

Alternatively, if you don't want it to be the default behavior, would it be possible to define custom paths? something like:

// env.lookup([paths, ], cb);

env.lookup(['/home/user/.nvm/versions/node/v6.0.0/lib/node_modules'], function() {});

Either way, it would fix the lookup for nvm installed yeoman and generators. This doesn't apply when yeoman-environment is installed globally, yo works fine in this case.

Add support for es6 module

I want to use es2015 module style to create generator. I tried this style, code failed. I think the reason might be babel transform the follow code to module.exports.default = function AppGenerator() {}.

export default class AppGenerator extends Base {
}

Remove env#help() method

This help method is command line specific and should be removed from this module.

To do so, we'll need to reimplement this method inside yo

Generator not found if it's under a namespace

I'm currently using npm enterprise and I've published a generator to it. When I install it globally via:

npm install -g @mycompany/mygenerator

yeoman doesn't find the package because it is under the folder

@mycompany

I'll work on a PR that also calls findGeneratorsIn for each @namespace folder that is found.

Unable to call 'yo.cmd' command in Java after upgrading yeoman to 1.3.3 (Windows)

In my project, I need to call the yeoman command in a Java class. It worked fine before(version 1.2.0) but after I upgrade it to 1.3.3, I get an error when running the 'yo.cmd' command. The yeoman command works fine when running it in a command windows directly.

Env:
Windows 7 64bit
Java 1.7.0_51 64bit
node v0.10.36
yo 1.3.3

When running the test code: java RunYo, the error message is:

fs.js:439
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory 'C:\dev\tty'
    at Object.fs.openSync (fs.js:439:18)
    at Object.<anonymous> (C:\Users\myuser\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\node_modules\inquirer\node_modules\ttys\index.js:9:18)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Users\myuser\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\node_modules\inquirer\lib\ui\baseUI.js:8:12)
    at Module._compile (module.js:456:26)

Below is the java test code:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class RunYo {

    public static void main(String[] args) {
        String cmd = "yo.cmd";

        try {
            Process process = Runtime.getRuntime().exec(cmd, null, null);
            readProcessOutput(process);
        } catch( IOException e ) {
            e.printStackTrace();
        }
    }

    private static void readProcessOutput(final Process process) {
        read(process.getInputStream(), System.out);
        read(process.getErrorStream(), System.err);
    }

    private static void read(InputStream inputStream, PrintStream out) {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));

            String line;
            while( (line = reader.readLine()) != null ) {
                out.println(line);
            }

        } catch( IOException e ) {
            e.printStackTrace();
        } finally {

            try {
                inputStream.close();
            } catch( IOException e ) {
                e.printStackTrace();
            }
        }
    }

}

There is a similar issue in stack overflow reported recently:
http://stackoverflow.com/questions/28077848/windows-7-yeoman-generator-gulp-angular-not-finding-creating-directory-erro

Allow passing text-table formatting options to log.table()

this.log.table() wraps table() provided by the text-table package. The second argument for text-table's table() would allow for passing alignment and separator options (docs).

Would you consider updating the method signature to allow passing formatting options along, e.g. like:

log.table = function (opts, fmt) {
  var tableData = [];

  opts = Array.isArray(opts) ? { rows: opts } : opts;
  opts.rows = opts.rows || [];

  fmt = fmt || {};

  opts.rows.forEach(function (row) {
    tableData.push(row);
  });

  return table(tableData, fmt);
};

On a related note, the docstring mentions that table is a wrapper around cli-table instead of text-table. Might have historical reasons?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.