有官方角度生成器,许多用户为Angular 1提供了一些.但是我还没有找到Angular 2的生成器.
这样的自然生成器是否已存在?
所以只是为了给你一些上下文,我正在尝试创建一个生成器,它将创建一些文件(当然基于用户输入)以及更新项目中的一些现有文件(例如添加新路径).
使用创建文件this.template没有问题......问题是:有没有办法用Yeoman做这个,而不必使用Node读取文件并做一些奇特的查找和替换?
我正在编写我的第一个Yeoman生成器,它会提示用户输入各种输入并根据响应有条件地创建文件.我需要能够根据用户输入调用子程序(可能是Yeoman子生成器),并将参数传递给它.
我想使用命名函数(不自动运行)的原因是有时用户的响应应该调用多个函数组合,有时候该函数应该单独运行.
我尝试过的:
我认为子生成器是可行的方法,因为我只是在用户请求时创建文件集.但我无法有条件地调用它们并将它们传递给用户提供的输入.我尝试过使用hookFor,但是我得到了断言错误:hookFor must be used within the constructor only.(因为我不希望默认情况下运行它,我正在调用我的子发生器this.prompt(prompts, function (props)).
问题:
如何仅在用户请求(通过提示)时调用例程,并将该例程传递给用户提供的一些信息?
如果你很友好地回答,请不要认为我尝试了一些明显的东西;-).
我正在构建一个定制的Yeoman生成器,它安装了许多预处理的语言编译器,如CoffeeScript,LESS和Jade.在我的生成器创建的Gruntfile中,我有一个构建任务,可以编译所有内容.但是,在该构建任务至少运行一次之前,编译的HTML,CSS和Javascript文件不存在,如果我尝试在新建脚手架之后运行grunt watch/connect服务器,这可能会造成混淆.
在安装结束时让我的生成器运行Grunt构建步骤的最佳方法是什么?end已经习惯用来打电话的事件this.installDependencies似乎是正确的地方,但我应该如何与Grunt沟通?
我设置了一个开发环境,将Windows 8和Ubuntu作为虚拟机.为此,我使用VirtualBox.
我还设法在VirtualBox中创建一个共享文件夹.
在这个共享文件夹中,我尝试使用Yeoman的ember-generator启动一个项目.
yo ember --skip-install --karma
npm install --no-bin-links
Run Code Online (Sandbox Code Playgroud)
对于安装模块NPM,我使用选项"--no-bin-links"不创建符号链接.不幸的是,我仍然有错误创作符号链接...我使用虽然这个选项?他有错误吗?
我正在为一个相当典型的节点应用程序构建一个yeoman生成器:
/
|--package.json
|--.gitignore
|--.travis.yml
|--README.md
|--app/
|--index.js
|--models
|--views
|--controllers
Run Code Online (Sandbox Code Playgroud)
在我的yeoman生成器的templates文件夹中,我必须重命名dotfiles(和package.json)以防止它们作为生成器的一部分进行处理:
templates/
|--_package.json
|--_gitignore
|--_travis.yml
|--README.md
|--app/
|--index.js
|--models
|--views
|--controllers
Run Code Online (Sandbox Code Playgroud)
我看到很多生成器手动复制dotfiles:
this.copy('_package.json', 'package.json')
this.copy('_gitignore', '.gitignore')
this.copy('_gitattributes', '.gitattributes')
Run Code Online (Sandbox Code Playgroud)
我认为在添加新模板文件时手动更改生成器代码很麻烦.我想自动复制/ templates文件夹中的所有文件,并重命名前缀为_的文件.
最好的方法是什么?
如果我在想象的正则表达式中描述我的意图,那就是它的样子:
this.copy(/^_(.*)/, '.$1')
ths.copy(/^[^_]/)
Run Code Online (Sandbox Code Playgroud)
编辑 这是我能管理的最好的:
this.expandFiles('**', { cwd: this.sourceRoot() }).map(function() {
this.copy file, file.replace(/^_/, '.')
}, this);
Run Code Online (Sandbox Code Playgroud) 我试图yo angular在一个新的项目目录中运行,但它给了我一路上的ENOENT错误.是的我看过这个类似的问题,但它的解决方案对我不起作用.
我在运行前在空的新项目目录上运行了这些东西yo angular:
touch .npmignore
npm cache clear
npm cache clean
Run Code Online (Sandbox Code Playgroud)
但我仍然得到:
npm ERR! Error: ENOENT, lstat '/home/ubuntu/app_c/node_modules/grunt/ internal-tasks/bump.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Linux 3.2.0-54-virtual
npm ERR! command "/home/ubuntu/local/bin/node" "/home/ubuntu/local/bin/ npm" "install"
npm ERR! cwd /home/ubuntu/app_c
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /home/ubuntu/app_c/node_modules/grunt/internal-tasks/bump. …Run Code Online (Sandbox Code Playgroud) 在Gruntfile.js,我有:
watch: {
styles: {
files: [
'<%= yeoman.app %>/styles/{,*/}*.less'
],
tasks: ['copy:styles', 'autoprefixer']
}
}
Run Code Online (Sandbox Code Playgroud)
对于这条路,究竟{,*/}是什么意思呢?它与使用双星号**/有何不同?
我试着用以下方法安装yeoman角度发生器:
npm install -g generator-angular
Run Code Online (Sandbox Code Playgroud)
一切看起来都安装得恰到好处......
...
npm http GET https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/string_decoder
npm http GET https://registry.npmjs.org/event-emitter
npm http GET https://registry.npmjs.org/next-tick
npm http 304 https://registry.npmjs.org/event-emitter
npm http 304 https://registry.npmjs.org/next-tick
generator-angular@0.7.1 /Users/rich/.node/lib/node_modules/generator-angular
??? chalk@0.3.0 (has-color@0.1.4, ansi-styles@0.2.0)
??? wiredep@0.4.2 (chalk@0.1.1, lodash@1.3.1)
??? yeoman-generator@0.13.4 (dargs@0.1.0, diff@1.0.8, debug@0.7.4, rimraf@2.2.6, chalk@0.2.1, text-table@0.1.1, mime@1.2.11, async@0.2.10, mkdirp@0.3.5, isbinaryfile@0.1.9, shelljs@0.1.4, underscore.string@2.3.3, glob@3.2.9, iconv-lite@0.2.11, tar@0.1.19, findup-sync@0.1.3, lodash@1.3.1, request@2.25.0, cheerio@0.12.4, inquirer@0.3.5)
Run Code Online (Sandbox Code Playgroud)
完整登录:https: //dl.dropboxusercontent.com/s/hs5dgy1i6f90vu4/angular-generator-log.txt
但每次我这样做:yo angular我得到:You don't seem to have a generator with the …
我更新了我的JHipster安装按本页面运行命令
npm update -g generator-jhipster
Run Code Online (Sandbox Code Playgroud)
但是要更新我的应用程序,我不知道我应该在哪里运行下一个命令yo jhipster.
我尝试从现有项目的根目录运行它,但它要求我输入新项目的名称.

我尝试在现有项目的根目录之上运行它,然后它也问我新项目的名称.但是这次我输入了相同的名字并且jhipster生成过程运行了.但是,任何主要文件都没有变化,如package.json或Gruntfile.js或bower.json
一旦JHipster生成器更新,更新JHipster项目的正确方法是什么?