如何使用angular-cli(6.x)创建Mono-repo项目结构 [英] How to create a mono-repo project structure with angular-cli (6.x)
问题描述
我想使用angular-cli生成一个新的工作区
I'd like to use the angular-cli to generate a new workspace
目前唯一的方法是运行:
The only way to do this at the moment is to run:
ng new asdf
cd asdf
ng g application whatever
,但是所有src/
文件都保留了(以及现在不一致存储的项目的原始angular.json信息).没有src
文件夹就无法创建新的仓库...当我使用自定义原理图通过本质上复制angular-cli的ng-new
并删除
but then all of the src/
files remain (and the original angular.json info for a project that is now inconsistently stored). There's no way to create a new repo without the src
folder... and when I do this using a custom schematic by essentially duplicating angular-cli's ng-new
and removing https://github.com/angular/angular-cli/blob/6449a753641340d8fc19a752e1a1ced75f974efa/packages/schematics/angular/ng-new/index.ts#L61 schematic('application', applicationOptions),
每当我运行它...
$ ng new asdf -c=my-schematic
$ cd asdf
$ ng g application whatever
{"inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","style":"css","skipTests":false,"skipPackageJson":false,"name":"whatever"}
CREATE projects/whatever-e2e/protractor.conf.js (752 bytes)
CREATE projects/whatever-e2e/src/app.e2e-spec.ts (304 bytes)
CREATE projects/whatever-e2e/src/app.po.ts (208 bytes)
CREATE projects/whatever-e2e/tsconfig.e2e.json (219 bytes)
只有e2e文件放入projects/
中,而angular.json
文件大部分保持空白:
Only the e2e files get put into projects/
and the angular.json
file remains mostly empty:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {},
"cli": {
"defaultCollection": "my-schematic"
}
}
我怀疑这与应用程序原理图中的无提示失败或路径断开有关...但是我想首先检查是否存在更简单/更可取的方式.
I suspect this has to do with something silently failing in the application schematic or a path being off... but I wanted to check first if there was an easier / more preferred way.
$ ng --version
Angular CLI: 6.1.0-rc.0
Node: 10.1.0
OS: win32 x64
Angular: 6.0.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
------------------------------------------------------
@angular-devkit/architect 0.7.0-rc.0
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@angular/cdk 6.3.1
@angular/cli 6.1.0-rc.0
@angular/material 6.3.1
@schematics/angular 0.6.8
@schematics/update 0.7.0-rc.0
rxjs 6.2.1
typescript 2.7.2
编辑要注意,我对第三方库(例如Nrwl/Nx)很熟悉,但我正尝试避免使用这些库.我还将此问题发布到了GitHub: https://github.com/angular/angular- cli/issues/11402
Editing to note I'm familiar about 3rd-party libraries (e.g. Nrwl/Nx) but I'm trying to avoid those. I also posted this issue to GitHub: https://github.com/angular/angular-cli/issues/11402
推荐答案
目前还没有一种方法可以达到我的预期.
There currently isn't a way to do this the way I intend.
hacky解决方法要运行:
The hacky workaround is to run:
ng new <mono-repo name>
cd放入其中(cd <mono-repo name>
)
生成第一个应用名称(ng generate application <app-name>
)
generate the first app name (ng generate application <app-name>
)
,然后删除原始的src/e2e文件夹(rm -rf src e2e
)和angular.json中的相应条目.
and then remove the original src / e2e folders (rm -rf src e2e
) and the corresponding entry in angular.json.
从那时起,每当生成库/应用程序时,所有内容都将位于projects文件夹中.
From then on whenever libraries / applications are generated everything will be in the projects folder.
这篇关于如何使用angular-cli(6.x)创建Mono-repo项目结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!