Giter VIP home page Giter VIP logo

vscode-yo's Introduction

vscode-yo

Scaffold projects using Yeoman.

Usage

Press F1 and type yo. Pick one of your generators from the list and answer all the questions.

Sub-Generator

The plugin also supports sub-generators. If a plugin has multiple generators, a list with all the available generators will pop-up. The default generator is marked by a โ˜….

Pre-requirements

License

MIT ยฉ Sam Verschueren

vscode-yo's People

Contributors

aguerotsovinty avatar bpasero avatar rafaelgorski avatar samverschueren avatar theel0ja avatar zuoez02 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

Watchers

 avatar  avatar  avatar  avatar  avatar

vscode-yo's Issues

Extension calls process.exit()

I noticed that your extension (probably Yo itself) is calling process.exit() at some point. I know some node JS libraries tent to abuse process.exit() as a way to do flow control in their program. I see this happening when I abort Yo after it found a conflict when applying file changes.

In the future VS Code will ignore process.exit() calls because otherwise the extension host goes down and you would have to restart VS Code.

I wonder how Atom behaves here I am sure they have the same problem, do you happen to know?

Not sure you can do anything about it but if Yo claims to be pluggable, they must also provide a way to avoid process.exit(). In fact, they should not even use it at all.

When VSCode is not opened on a folder, show a folder picker

It is possible to run Yo in VS Code when no folder is opened. In that case I suggest to either ask the user for the destination of where to install the generated files to or just inform that you first need to open a folder.

I would actually like to always be asked from where to run the generator (cwd) so that I am in charge where to install the generated files to. Currently it feels a bit weird that the files end up in my current workspace in a sub folder.

Extensibility: building on top of this package.

Is this project available as an npm package and does it support some sort of command extensibility?

I am tinkering with an idea to generate project scaffolding as one liner (similar to #40).
E.g: aspnet new (instead of yo, aspnet, console app)

ofcourse, such simple verbs may not encompass all the wide range of template options, but for my use case I'm happy with these terse one liners.

so, i was wondering if i could somehow add this package as a dependency and extend on top of this? Would uploading to npm as a package work for you in that case?

Add password prompt

A password input is now shown as a normal input. Add support for this by using the password property in the options object.

List of generators empty

After extension installation no generators displayed.
ode
I tried to reinstall extension, but nothing helps.

Visual Studio Code
Version 0.10.1
Commit df352367df2efcfa9d602d471e4e2f42140a0f05
Date 2015-11-17T15:25:33.342Z
Shell 0.34.1
Renderer 45.0.2454.85
Node 4.1.1

yo 0.4.0

Adapter#prompt doesn't return a promise

I am running in a type error as shown below and believe that's because vscode-yo doesn't return a promise from prompt but yeoman-generator expects that

Uncaught Exception:  TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
    at Base.prompt (/Users/jrieken/Code/collab/generator-code-javascript/node_modules/yeoman-generator/lib/base.js:240:44)
    at prompting (/Users/jrieken/Code/collab/generator-code-javascript/generators/app/index.js:111:21)
    at Object.<anonymous> (/Users/jrieken/Code/collab/generator-code-javascript/node_modules/yeoman-generator/lib/base.js:439:23)
    at /Users/jrieken/Code/collab/generator-code-javascript/node_modules/run-async/index.js:26:25

Set generator execution folder to the folder currently selected in the source explorer

At the moment when executing a generator within VSCode with vscode-yo, the root folder used by the generator is the project's root folder. It would be interesting to be able to use the current selected folder in the source explorer so that my generator doesn't have to know the target folder structure to generate items at the correct place.

For instance I have the following project struture opened in VSCode:

Root
|- src
| |- home
| |- about
|- test
| |-etc

I want generated files to endup within a custom folder structure under the src folder.

The execution folder is always Root when running a generator. Therefore I have no other choice than handle in my generator the fact that I have to add an extra src folder. But then what about other projects structures where they have a different hierarchy?

It'd be nice to use the currently selected folder in Source Explorer as the generator's execution folder.

Implement proper diff strategy

If a file already exists, people can show the difference between the actual and the expected file. It would be nice to handle this properly.

How do Yeoman generators get resolved?

We'd like to hook up a Yeoman generator so that users of the PowerShell extension can easily create new PowerShell projects. What do we need to do have our generator show up in the quick pick list?

Does your generator resolution depend on the workspace itself having a package.json file with the generator installed as a dependency? Is there any way that our extension could include the generator so that it shows up in the list without the workspace needing a package.json?

Thanks!

cc @rkeithhill

Fix issue when user pressed escape

The plugin does not execute a new generator if the user pressed escape in the previous flow.

When the user starts a new generation and presses esc at some question, the flow is stopped. When he triggers a new generator, the environment is executed correctly on line 67, but the prompt method is not fired.

Does this have something to do with not calling the callback here?

this.appname as default does not work the first time

generator-nm uses this.appname as default application name. The first time the generator is executed, the app name is empty. When quitting the generator (by pressing escape) and running generator-nm again, the app name is correct.

The adapter is just getting the question here.

When I put a breakpoint here, the first question in the array is

{
    "default": "",
    "filter": x => _s.slugify(x),
    "description": "What do you want to name your module?",
    "name": "moduleName"
}

The second time I run the generator, the default value is correct.

{
    "default": "yo-test",
    "filter": x => _s.slugify(x),
    "description": "What do you want to name your module?",
    "name": "moduleName"
}

Any idea how this is possible? @sindresorhus @SBoudrias

List type support

Currently we only support lists with object values like {name: 'foo', value: 'bar'}. PR #49 will add string support as well. But according to the docs of Inquirer.js, we will have to add support for some others as well.

choices: (Array|Function) Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers. Array values can be simple strings, or objects containing a name (to display in list), a value (to save in the answers hash) and a short (to display after selection) properties. The choices array can also contain a Separator.

So this is what should be done, and what we already have

  • Support functions
  • Support strings (#49)
  • Support objects
  • Add support for separator (do not show them)

@SBoudrias Sorry for the interruption but could you explain what that short is? When is it shown? For instance if we had a list of one item [{name: 'foo', value: 'bar', short: 'fb'}]. How does/should that render?

// @zuoez02

Support for npm link

This is primarily for development purposes. Setting npm link to a local working directory allows for local development . Would be nice to be able to do something like yo link c:/foo/foobar/fooprojectdir and then when you go yo again the local yeoman project would be available.

Support async functions

Inquirer.js supports this.async() in most of its functions.

default, choices (if defined as functions), validate, filter and when functions can be called asynchronously using this.async(). You just have to pass the value you'd normally return to the callback option.

Only when is supported for now.

More info #26

Version 0.9.3 complains no generators installed

I have VS Code 1.7.2 and the Yo extension 0.9.3 installed. I also have few generators installed. However, when I try to invoke yo it complains with the following message:

Make sure to install some generators first.

Trying yo command in a terminal does give me generators available.

Is this a known issue?

Thanks!

"There are no entries to pick from"

First extension I installed in vscode. The instructions are very vague though, it doesn't mention if I have to install generators first or...
I do have a Bootstrap generator I never use, but it's there, and when I run yo in vscode I get this:

http://i.imgur.com/nV6UScr.png

Cannot see npm install progress

When I use within VS Code, the extension works but it does not show the npm install progress that happens. Is this a known issue? I tested this with multiple generators and got the same.

Thanks!

Implement conditional questions

It's possible to only prompt for questions depending on the answer of other questions. This can be done with the when function.

At this moment, the when function is being ignored.

When Yo opens, it brings up output panel and opens again

Noticed this today, when I open Yo, it shows the picker, opens the output panel and then seems to open the picker again? Is this because of focus issues? If so, there should be API to open the panel without passing focus into it.

package.json is missing postinstall script

Any reason why the postinstall script is not configured for package.json:

"postinstall": "node ./node_modules/vscode/bin/install"

If you do not use this, otherwise the vscode module cannot be resolved because vscode.d.ts is missing unless you have this postinstall script.

One line scaffolding

Is it possible to support entering a one-liner to scaffold?

For example: yo aspnet:MvcController MyController

Currently I do

yo ENTER
aspnet ENTER
MvcController ENTER
MyController ENTER

Does not work with nvm?

I'm seeing that with nvm to manage nodejs/npm installations, vscode-yo when invoked says "install some generators first".
I'm confident my generators are alright because they seem to work when invoked from command line. So, it looks like vscode-yo couldn't find npm install path?

with nvm, my npm path is no longer at %USERPROFILE%\AppData\Roaming\npm but its at %USERPROFILE%\AppData\Roaming\nvm\v7.6.0\

Is this a known issue or do i need to change some default setting to get this to work. Please help.

Show picker earlier with promise for progress

I think it would be a nicer experience if the resolving of available yo-generators and the loading of a specific generator happens without the picker closing all the time and then reopen after a second or so.

You can always add a promise into the picker API and you will get progress while you resolve the things in the background.

Quit when user presses esc

If the user presses the Esc, it is handled as an enter keypress at the moment. This is due to a bug in VSCode where you can't determine the difference between an empty input field + enter and an Esc keypress. They will fix it in the next build.

Does it work with scoped generators?

Hi there,

The SharePoint Yeoman Generator to scaffold web part projects is currently into a npm scope, which means, I will have to run the yo as:

yo @microsoft/sharepoint

Does the yo extension support this? When I use the extension in VS code, it just shows sharepoint as the generator and not @microsoft/sharepoint. The next step of showing sub generators also succeeds. But then once I select the default app sub-generator, it throws the following error:

You don't seem to have a generator with the name "sharepoint:app" installed.

The generator as such when used in the command line works without any issues.

Any help much appreciated.

Thanks,
Chaks

Error this.async is not a function

Hi @SamVerschueren ,

First, great initiative to wrap yo inside the vscode!
I got a error when I use it, I will try to explain the scenario.

When I try to use generator-generator from vscode the following error:

Error this.async is not a function

Steps:

  1. yo
  2. generator
  3. <enter, confirming the suggestion>
  4. error presented: Error this.async is not a function

Using the normal yo works fine:

yo
? 'Allo GORSKI! What would you like to do? Generator

Make sure you are in the directory you want to scaffold into.
This generator can also be run with: yo generator

? Your generator name generator-exploratory-test-cases-yo
Your generator must be inside a folder named generator-exploratory-test-cases-yo
I'll automatically create this folder.
? Description 

Versions:
npm -v --> 3.3.12
node -v --> v5.3.0

Print all output to the outputchannel

Only the write and writeln of the logger are directed to the output channel. We should write everything to the outputchannel to inform the user correctly.

Use the diff editor to show file diffs

It would be nice to ad color support for file diff (red for removed lines and green for added lines).

This is currently not supported by VS Code core.

silent fail on npm/yarn install

generator.runInstall('yarn', [], () => { generator.spawnCommandSync('npm', ['run', 'test']); });

When my generator fires these commands I silently fail through the plugin. Anyone know if I'm doing anything crazy? It works fine on my command line.

Escaping shows error

Because the new yeoman-generator expects a promise that resolves the answers, it doesn't look like I can escape decently out of a generator. Have to investigate this further.

atom / code integration collaboration

Taking this from twitter to here, just to see what we can do!

I'd love to have a core npm module that wraps most of the functionality up, so that both atom and code can just pull from the same feature set.

Right now atom-yeoman has the following features:

  • Generator Service
    • Allows package authors the ability to call a specific generator.
  • yo command
    • Lists all generators
  • Loads from various locations that generators can be found (in atom we can't trust some of the NODE paths, code may be very similar)
  • Parses files added, removed, changed, etc, and forwards that onto the service (for package authors to react to those files).

Proposal

Thoughts and ideas below.

Node Module

  • Generator class
    • Constructor
      • Accepts a factory function that takes a list of generators and returns a Promise<IGenerator[]> which resolves when the generator has been selected.
      • Accepts a factory function that takes an input question, and returns a Promise<IAnswer> which resolves when that question is completed.
        • This is where the editor specific package can inject it's UI elements.
      • Sets search locations, configurable using options.
    • Method for listing generators
      list(pathToDirectory: string, prefix?: string): Promise<IGenerator[]>
      • Search prefix (only list specific generators). Might not be required, can always be done after it returns.
    • Method for running a specific generator
      run(pathToDirectory: string, generator: string): Promise<IResult>
      Shortcut that calls generator.run() under the covers.

Example atom/code usage:

let yeomanService = new YeomanService((q: IQuestion) => showQuestionForUser(q));
yeomanService.list(process.cwd())
    .then((generators) => listGeneratorsForUser())
    .then(generator => generator.run())
    .then(result => doSomethingWithResult())

This would make it much simpler for people to use yeoman in an electron like application, so it may have uses outside of just atom/code.

Atom

Has CSP issues, there are clear work around that is already handled. Hopefully this could be handled outside of the node module, so we don't have to worry about the nasty CSP code everywhere.

Code

Not sure if CSP is enabled, it's entirely possible it is not currently enabled.

Exception when running yo command in VSCode

When I press F1, type in 'yo' then [Enter] I get the following Exception:

Uncaught Exception:  TypeError: Cannot read property 'split' of undefined
TypeError: Cannot read property 'split' of undefined
    at new Range (C:\Users\Anthony\.vscode\extensions\samverschueren.yo-0.8.4\node_modules\semver\semver.js:720:19)
    at outside (C:\Users\Anthony\.vscode\extensions\samverschueren.yo-0.8.4\node_modules\semver\semver.js:1123:11)
    at Function.ltr (C:\Users\Anthony\.vscode\extensions\samverschueren.yo-0.8.4\node_modules\semver\semver.js:1111:10)
    at C:\Users\Anthony\.vscode\extensions\samverschueren.yo-0.8.4\out\yo\yo.js:37:49
    at Array.map (native)
    at Yeoman.getGenerators (C:\Users\Anthony\.vscode\extensions\samverschueren.yo-0.8.4\out\yo\yo.js:25:21)
    at C:\Users\Anthony\.vscode\extensions\samverschueren.yo-0.8.4\out\extension.js:90:37
    at Environment.resolver.lookup (C:\Users\Anthony\.vscode\extensions\samverschueren.yo-0.8.4\node_modules\yeoman-environment\lib\resolver.js:50:12)
    at Immediate._onImmediate (C:\Users\Anthony\.vscode\extensions\samverschueren.yo-0.8.4\out\extension.js:89:33)
    at processImmediate [as _immediateCallback] (timers.js:374:17)

Digging in the code led me to the following line in yo.js: 37 :
=> generatorMeta.isCompatible = semver.ltr('0.17.6', generatorVersion);
generatorVersion's value is ~0.20.3

I had to patch the offending code in semver to handle the case where range object is null with a (range||'') to get it working (L720):

I also tried to upgrade semver to the latest version (5.1.0) but with no luck.

Feel free to let me know if you need further details.

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.