diff --git a/.vscode/settings.json b/.vscode/settings.json index f03125fbf..09def5be3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,7 +5,8 @@ "**/.git/subtree-cache/**": true, "**/node_modules/*/**": true, "**/dist/*/**": true, - "**/coverage/*/**": true + "**/coverage/*/**": true, + "**/.yarn/**": true }, "editor.codeActionsOnSave": { // For ESLint diff --git a/docs/faq.en-US.md b/docs/faq.en-US.md index 34db49a1d..78d418aad 100644 --- a/docs/faq.en-US.md +++ b/docs/faq.en-US.md @@ -61,18 +61,15 @@ Two situations: - Using `cnpm` to install dependencies, you will not be able to find style files. This is because `cnpm` is in the form of a soft link path, which causes the `ng-zorro-antd` folder name to change, so it is recommended to use the `yarn` install dependency package instead. - The `ng-zorro-antd` version is too old to cause some components to fail to load into the appropriate style -### How to use Taobao source correctly? +### How to use other mirror? -The simplest is to use the [networkEnv](/cli/plugin#networkEnv) plugin. - -Or manually repair: +Install the [nnrm](https://github.com/YunYouJun/nnrm/blob/main/README.zh-CN.md) plugin. ```bash -yarn config set registry https://registry.npmmirror.com -yarn config set sass_binary_site https://npmmirror.com/mirrors/node-sass -# restore -yarn config delete registry -yarn config delete sass_binary_site +# Install nnrm +npm install -g nnrm +# Switch Npm to Taobao mirror +nnrm use taobao ``` ## Configuration @@ -100,8 +97,8 @@ Online documents will only retain the data of the last three major version numbe ```bash git clone --depth 1 -b full https://github.com/ng-alain/archive-docs.git ng-alain-doc cd ng-alain-doc -yarn -yarn start +npm install +npm start ``` ### Fix the abnormal display of the lower part of the 360 browser diff --git a/docs/faq.zh-CN.md b/docs/faq.zh-CN.md index 75a524409..bb59cc8b3 100644 --- a/docs/faq.zh-CN.md +++ b/docs/faq.zh-CN.md @@ -61,18 +61,15 @@ bash delon.sh - 使用 `cnpm` 安装依赖包,会遇到无法找到样式文件。这是由于 `cnpm` 采用的是软链接路径形式,导致 `ng-zorro-antd` 文件夹名有所变动,因此建议改用 `yarn` 安装依赖包,如果是网络因素,请参考下方的如何正确使用淘宝源。 - `ng-zorro-antd` 版本过旧导致部分组件无法加载到相应样式 -### 如何正确使用淘宝源? +### 如何使用其他镜像源? -最简单是使用 [networkEnv](/cli/plugin#networkEnv) 插件。 - -或手动修复: +安装 [nnrm](https://github.com/YunYouJun/nnrm/blob/main/README.zh-CN.md) 插件。 ```bash -yarn config set registry https://registry.npmmirror.com -yarn config set sass_binary_site https://npmmirror.com/mirrors/node-sass -# 恢复 -yarn config delete registry -yarn config delete sass_binary_site +# 安装 nnrm +npm install -g nnrm +# 将Npm切换至淘宝源(不同 npm 源管理器命令有点不一样,更多细节请参考 nnrm 文档) +nnrm use taobao ``` ## 配置 @@ -100,8 +97,8 @@ yarn config delete sass_binary_site ```bash git clone --depth 1 -b full https://github.com/ng-alain/archive-docs.git ng-alain-doc cd ng-alain-doc -yarn -yarn start +npm install +npm start ``` ### 修复360浏览器下部分显示异常 diff --git a/docs/getting-started.en-US.md b/docs/getting-started.en-US.md index 8b25c59c8..3bf09c6d2 100644 --- a/docs/getting-started.en-US.md +++ b/docs/getting-started.en-US.md @@ -31,12 +31,12 @@ You will need [node](http://nodejs.org/) and [git](https://git-scm.com/). The pr Please make sure global Angular Cli is latest version via `ng version` command, please refer to [CLI Command Reference](https://angular.io/cli) for how to upgrade. ```bash -yarn global add @angular/cli -ng new my-project --style less --routing --package-manager yarn +npm install -g @angular/cli +ng new my-project --style less --routing cd my-project ng add ng-alain -yarn start -# Or use HMR mode by: yarn run hmr +npm start +# Or use HMR mode by: npm run hmr ``` > Please refer to [Schematics](/cli) for more details. @@ -46,9 +46,9 @@ yarn start ```bash git clone --depth=1 https://github.com/ng-alain/ng-alain.git my-project cd my-project -yarn -yarn start -# Or use HMR mode by: yarn run hmr +npm install +npm start +# Or use HMR mode by: npm run hmr ``` > Note: Installing with the CLI is a clean scaffolding; using clone the git repository include all example pages. @@ -89,7 +89,7 @@ NG-ALAIN is a standard Angular CLI project that includes common routes for admin ## Development ```bash -yarn start +npm start ``` This will automatically open [http://localhost:4200](http://localhost:4200). If you see the following page then you have succeeded. diff --git a/docs/getting-started.zh-CN.md b/docs/getting-started.zh-CN.md index ef9646f3e..dde9de129 100644 --- a/docs/getting-started.zh-CN.md +++ b/docs/getting-started.zh-CN.md @@ -11,25 +11,22 @@ NG-ALAIN 是一个企业级中后台前端/设计解决方案脚手架,我们 ## 环境搭建 -Angular 开发环境至少需要安装 [Node.js](https://nodejs.org/en/download/)(Node.js 内置了 [npm](https://www.npmjs.com/get-npm) 无须单独安装,但**推荐使用** [Yarn](https://yarnpkg.com/) 但你需要单独额外安装)、[VSCode编辑器](https://code.visualstudio.com/),其中 Node.js 建议安装 **LTS** 版本,安装完成后可以通过终端窗口中运行: +Angular 开发环境至少需要安装 [Node.js](https://nodejs.org/en/download/)(Node.js 内置了 [npm](https://www.npmjs.com/get-npm) 无须单独安装)、[VSCode编辑器](https://code.visualstudio.com/),其中 Node.js 建议安装 **LTS** 版本,安装完成后可以通过终端窗口中运行: ```bash node -v # 查看 Node.js 当前版本 -yarn -v # 查看 Yarn 当前版本 +npm -v # 查看 Npm 当前版本 ``` -Yarn 默认从国外源来下载包信息,鉴于国内环境因素,在开始下一步前先设定淘宝提供镜像: +Npm 默认从国外源来下载包信息,鉴于国内环境因素,在开始下一步前先安装 [nnrm](https://github.com/YunYouJun/nnrm/blob/main/README.zh-CN.md) 并切换至淘宝镜像: ```bash -yarn config set registry https://registry.npmmirror.com -yarn config set sass_binary_site https://npmmirror.com/mirrors/node-sass -# restore -yarn config delete registry -yarn config delete sass_binary_site +# 安装 nnrm +npm install -g nnrm +# 将Npm切换至淘宝源(不同 npm 源管理器命令有点不一样,更多细节请参考 nnrm 文档) +nnrm use taobao ``` -> 也可以使用 [nrm](https://www.npmjs.com/package/nrm) 包,可以快速切换不同国内镜像源。 - ## 安装 ### 全局 Angular Cli @@ -37,7 +34,7 @@ yarn config delete sass_binary_site 安装之前请先确保本地已经安装全局 Angular Cli,只有这样才能随时随地在终端使用 `ng` 命令,可以通过终端窗口中运行: ```bash -yarn global add @angular/cli +npm install -g @angular/cli ``` ### 创建NG-ALAIN项目 @@ -45,7 +42,7 @@ yarn global add @angular/cli NG-ALAIN 必须先创建一个全新的 Angular 项目,可以通过终端窗口中运行: ```bash -ng new my-project --style less --routing --package-manager yarn +ng new my-project --style less --routing ``` > 如果你想了解 `--style`、`--routing` 参数,请参考 [ng new](https://angular.io/cli/new#options) 文档。 @@ -63,13 +60,13 @@ NG-ALAIN 会询问是否需要一些额外的插件,一开始完全可以一 > ```bash > git clone --depth=1 https://github.com/ng-alain/ng-alain.git my-project > cd my-project -> yarn install +> npm install > ``` ### 运行 ```bash -yarn start +npm start ``` 启动完成后会打开浏览器访问 [http://localhost:4200](http://localhost:4200),若你看到如下页面则代表成功了。 diff --git a/docs/import.en-US.md b/docs/import.en-US.md index fe2bfb9b8..615f3002e 100644 --- a/docs/import.en-US.md +++ b/docs/import.en-US.md @@ -11,7 +11,7 @@ In addition to the NG-ALAIN base component and the @delon business component, so ### Installing dependencies ```bash -yarn add ngx-tinymce +npm i -S ngx-tinymce ``` ### Import module @@ -55,7 +55,7 @@ Referencing a non-Angular component is actually loading a JavaScript class libra ### Installing dependencies ```bash -yarn add qrious +npm i -S qrious ``` ### Import Scripts diff --git a/docs/import.zh-CN.md b/docs/import.zh-CN.md index 8e7f4b9d1..3d50856ac 100644 --- a/docs/import.zh-CN.md +++ b/docs/import.zh-CN.md @@ -11,7 +11,7 @@ type: Dev ### 安装依赖包 ```bash -yarn add ngx-tinymce +npm i -S ngx-tinymce ``` ### 注册 @@ -55,7 +55,7 @@ export class AppModule { } ### 安装依赖包 ```bash -yarn add qrious +npm i -S qrious ``` ### 导入脚本 diff --git a/packages/abc/count-down/index.en-US.md b/packages/abc/count-down/index.en-US.md index d2e395afe..ac032eac0 100644 --- a/packages/abc/count-down/index.en-US.md +++ b/packages/abc/count-down/index.en-US.md @@ -11,7 +11,7 @@ The countdown component depends on [ngx-countdown](https://github.com/cipchk/ngx ## Dependencies ``` -yarn add ngx-countdown +npm i -S ngx-countdown ``` ## API diff --git a/packages/abc/count-down/index.zh-CN.md b/packages/abc/count-down/index.zh-CN.md index 5594594ee..22c17507e 100644 --- a/packages/abc/count-down/index.zh-CN.md +++ b/packages/abc/count-down/index.zh-CN.md @@ -11,7 +11,7 @@ module: import { CountDownModule } from '@delon/abc/count-down'; ## 依赖 ``` -yarn add ngx-countdown +npm i -S ngx-countdown ``` ## API diff --git a/packages/abc/pdf/index.en-US.md b/packages/abc/pdf/index.en-US.md index 5723768d4..bc82a4053 100644 --- a/packages/abc/pdf/index.en-US.md +++ b/packages/abc/pdf/index.en-US.md @@ -16,7 +16,7 @@ pdf.js libary is lazy loading by default,you can change the default root CDN p **Use local path** ```bash -yarn add pdfjs-dist +npm i -S pdfjs-dist ``` ```json diff --git a/packages/abc/pdf/index.zh-CN.md b/packages/abc/pdf/index.zh-CN.md index 28c41e1ca..0c3e8cd16 100644 --- a/packages/abc/pdf/index.zh-CN.md +++ b/packages/abc/pdf/index.zh-CN.md @@ -16,7 +16,7 @@ module: import { PdfModule } from '@delon/abc/pdf'; **使用本地路径** ```bash -yarn add pdfjs-dist +npm i -S pdfjs-dist ``` ```json diff --git a/packages/acl/docs/getting-started.en-US.md b/packages/acl/docs/getting-started.en-US.md index 47b8b63f4..32455427f 100644 --- a/packages/acl/docs/getting-started.en-US.md +++ b/packages/acl/docs/getting-started.en-US.md @@ -15,7 +15,7 @@ The `ACLService` service class contains a set of methods based on role permissio Install `@delon/acl`: ```bash -yarn add @delon/acl +npm i -S @delon/acl ``` Import `DelonACLModule` module: diff --git a/packages/acl/docs/getting-started.zh-CN.md b/packages/acl/docs/getting-started.zh-CN.md index 1b6a08443..cd9fc0ea2 100644 --- a/packages/acl/docs/getting-started.zh-CN.md +++ b/packages/acl/docs/getting-started.zh-CN.md @@ -15,7 +15,7 @@ ACL 全称叫访问控制列表(Access Control List),是一种非常简单 安装 `@delon/acl` 依赖包: ```bash -yarn add @delon/acl +npm i -S @delon/acl ``` 导入 `DelonACLModule` 模块: diff --git a/packages/auth/docs/getting-started.en-US.md b/packages/auth/docs/getting-started.en-US.md index a3ef2c14b..7d578c563 100644 --- a/packages/auth/docs/getting-started.en-US.md +++ b/packages/auth/docs/getting-started.en-US.md @@ -41,7 +41,7 @@ There are currently two styles: Simple Web Token (using `SimpleTokenModel`) and Install `@delon/auth`: ```bash -yarn add @delon/auth +npm i -S @delon/auth ``` Import `DelonAuthModule` to your AppModule. diff --git a/packages/auth/docs/getting-started.zh-CN.md b/packages/auth/docs/getting-started.zh-CN.md index 714b33b3c..a8f3d3982 100644 --- a/packages/auth/docs/getting-started.zh-CN.md +++ b/packages/auth/docs/getting-started.zh-CN.md @@ -41,7 +41,7 @@ type: Documents 安装 `@delon/auth` 依赖包: ```bash -yarn add @delon/auth +npm i -S @delon/auth ``` 导入 `DelonAuthModule` 模块: diff --git a/packages/cache/docs/getting-started.md b/packages/cache/docs/getting-started.md index 6eea80a0e..cfab44d96 100644 --- a/packages/cache/docs/getting-started.md +++ b/packages/cache/docs/getting-started.md @@ -31,7 +31,7 @@ cacheService.set('/data/unit', [ '个', '件' ]); **安装** ```bash -yarn add @delon/cache +npm i -S @delon/cache ``` **注册** diff --git a/packages/form/docs/getting-started.en-US.md b/packages/form/docs/getting-started.en-US.md index db265c72e..46a2d87b1 100644 --- a/packages/form/docs/getting-started.en-US.md +++ b/packages/form/docs/getting-started.en-US.md @@ -30,7 +30,7 @@ This document uses the following conventions: Install `@delon/form` from `yarn`. ```bash -yarn add @delon/form +npm i -S @delon/form ``` Import `DelonFormModule` in to your root `AppModule`. diff --git a/packages/form/docs/getting-started.zh-CN.md b/packages/form/docs/getting-started.zh-CN.md index db1142dba..f7d7a1f9c 100644 --- a/packages/form/docs/getting-started.zh-CN.md +++ b/packages/form/docs/getting-started.zh-CN.md @@ -30,7 +30,7 @@ type: Documents 安装 `@delon/form` 依赖包: ```bash -yarn add @delon/form +npm i -S @delon/form ``` 导入 `DelonFormModule` 模块: diff --git a/packages/form/widgets-third/markdown/index.en-US.md b/packages/form/widgets-third/markdown/index.en-US.md index 9f33f7af6..bd8c40c7a 100644 --- a/packages/form/widgets-third/markdown/index.en-US.md +++ b/packages/form/widgets-third/markdown/index.en-US.md @@ -14,7 +14,7 @@ Markdown Editor Since the Markdown editor relies on a third-party plug-in [ngx-simplemde](https://github.com/cipchk/ngx-simplemde), the dependency should be installed first when using it -`yarn add ngx-simplemde` +`npm i -S ngx-simplemde` **Import module** diff --git a/packages/form/widgets-third/markdown/index.zh-CN.md b/packages/form/widgets-third/markdown/index.zh-CN.md index d7121219a..3af542c09 100644 --- a/packages/form/widgets-third/markdown/index.zh-CN.md +++ b/packages/form/widgets-third/markdown/index.zh-CN.md @@ -14,7 +14,7 @@ Markdown编辑器。 由于Markdown编辑器依赖第三方插件[ngx-simplemde](https://github.com/cipchk/ngx-simplemde),所以使用时应首先安装依赖 -`yarn add ngx-simplemde` +`npm i -S ngx-simplemde` **导入模块** diff --git a/packages/form/widgets-third/tinymce/index.en-US.md b/packages/form/widgets-third/tinymce/index.en-US.md index c5137895b..971f772c2 100644 --- a/packages/form/widgets-third/tinymce/index.en-US.md +++ b/packages/form/widgets-third/tinymce/index.en-US.md @@ -12,7 +12,7 @@ Tinymce rich text Since the Tinymce editor relies on a third-party plug-in [ngx-tinymce](https://github.com/cipchk/ngx-tinymce), the dependency should be installed first when using it -`yarn add ngx-tinymce` +`npm i -S ngx-tinymce` **Import module** diff --git a/packages/form/widgets-third/tinymce/index.zh-CN.md b/packages/form/widgets-third/tinymce/index.zh-CN.md index 674cc4347..8eff664e2 100644 --- a/packages/form/widgets-third/tinymce/index.zh-CN.md +++ b/packages/form/widgets-third/tinymce/index.zh-CN.md @@ -15,7 +15,7 @@ Tinymce富文本。 由于Tinymce编辑器依赖第三方插件[ngx-tinymce](https://github.com/cipchk/ngx-tinymce),所以使用时应首先安装依赖 -`yarn add ngx-tinymce` +`npm i -S ngx-tinymce` **导入模块** diff --git a/packages/mock/docs/getting-started.en-US.md b/packages/mock/docs/getting-started.en-US.md index 8a30f43cc..a4af7026e 100644 --- a/packages/mock/docs/getting-started.en-US.md +++ b/packages/mock/docs/getting-started.en-US.md @@ -20,7 +20,7 @@ type: Documents Install `@delon/mock` from `yarn`. ```bash -yarn add @delon/mock -D +npm i --save-dev @delon/mock ``` Please refer to [global-config.module.ts](https://github.com/ng-alain/ng-alain/blob/master/src/app/global-config.module.ts#L26-L30) import the [Mock Rule data](/mock/rule). diff --git a/packages/mock/docs/getting-started.zh-CN.md b/packages/mock/docs/getting-started.zh-CN.md index eff453749..2c8859293 100644 --- a/packages/mock/docs/getting-started.zh-CN.md +++ b/packages/mock/docs/getting-started.zh-CN.md @@ -20,7 +20,7 @@ Mock 是指通过生成模拟数据让前端开发人员独立于后端进行开 安装 `@delon/mock` 依赖包: ```bash -yarn add @delon/mock -D +npm i --save-dev @delon/mock ``` 参考 [global-config.module.ts](https://github.com/ng-alain/ng-alain/blob/master/src/app/global-config.module.ts#L26-L30) 导入[Mock 规则数据](/mock/rule)。 diff --git a/packages/theme/docs/customize-theme.en-US.md b/packages/theme/docs/customize-theme.en-US.md index dbb363f8a..56352176d 100644 --- a/packages/theme/docs/customize-theme.en-US.md +++ b/packages/theme/docs/customize-theme.en-US.md @@ -70,7 +70,7 @@ Note: Make sure theme variables exist in global styles, not in component scope s 1. Install Dependencies ```bash -yarn add ng-alain-plugin-theme -D +npm i --save-dev ng-alain-plugin-theme ``` > [ng-alain-plugin-theme](https://github.com/ng-alain/plugin-theme) is to generate `color.less` and theme CSS files for NG-ALAIN. diff --git a/packages/theme/docs/customize-theme.zh-CN.md b/packages/theme/docs/customize-theme.zh-CN.md index 5149e06dd..ece8076f4 100644 --- a/packages/theme/docs/customize-theme.zh-CN.md +++ b/packages/theme/docs/customize-theme.zh-CN.md @@ -70,7 +70,7 @@ Ant Design 的样式使用了 [Less](http://lesscss.org/) 作为开发语言, 1. 安装依赖 ```bash -yarn add ng-alain-plugin-theme -D +npm i --save-dev ng-alain-plugin-theme ``` > [ng-alain-plugin-theme](https://github.com/ng-alain/plugin-theme) 是专门针对 NG-ALAIN 生成 `color.less` 及主题CSS文件。 diff --git a/schematics/docs/add.en-US.md b/schematics/docs/add.en-US.md index d196a965c..b2fff8a27 100644 --- a/schematics/docs/add.en-US.md +++ b/schematics/docs/add.en-US.md @@ -22,8 +22,6 @@ ng add ng-alain --defaultLanguage=en | `--defaultLanguage` | `zh` | Default language, [Supported language list](/cli/plugin/en#Supported-language-list) | | `--codeStyle` | `false` | Whether include code style | | `--i18n` | `false` | Whether include i18n | -| `--npm` | `false` | Whether include `npm` taobao mirror configuration file (Chinese users) | -| `--yarn` | `false` | Whether include `yarn` taobao mirror configuration file (Chinese users) | For example, generate a project with i18n: diff --git a/schematics/docs/add.zh-CN.md b/schematics/docs/add.zh-CN.md index 73f557cf6..3207f484e 100644 --- a/schematics/docs/add.zh-CN.md +++ b/schematics/docs/add.zh-CN.md @@ -22,8 +22,6 @@ ng add ng-alain --defaultLanguage=en | `--defaultLanguage` | `zh` | 默认语言,[支持语言列表](/cli/plugin/zh#支持语言列表) | | `--codeStyle` | `false` | 是否需要代码风格 | | `--i18n` | `false` | 是否需要国际化支持 | -| `--npm` | `false` | 是否需要 npm 淘宝镜像配置文件 | -| `--yarn` | `false` | 是否需要 yarn 淘宝镜像配置文件 | 例如生成一个带有国际化项目: diff --git a/schematics/docs/plugin.en-US.md b/schematics/docs/plugin.en-US.md index bc3b01560..0f982d4b0 100644 --- a/schematics/docs/plugin.en-US.md +++ b/schematics/docs/plugin.en-US.md @@ -85,21 +85,6 @@ ng g ng-alain:plugin defaultLanguage --defaultLanguage=zh-tw | Spanish | es | es | es_ES | es_ES | | Italian | it | it | it_IT | it_IT | -### networkEnv - -Allow chinese users to add a taobao mirror configuration file `.npmrc` or `.yarnrc` to solve network problems. - -```bash -# add npm -ng g ng-alain:plugin networkEnv --packageManager=npm -# add yarn -ng g ng-alain:plugin networkEnv --packageManager=yarn -# remove npm -ng g ng-alain:plugin networkEnv --packageManager=npm -t=remove -# remove yarn -ng g ng-alain:plugin networkEnv --packageManager=yarn -t=remove -``` - ### sts [ng-alain-sts](https://github.com/ng-alain/sts) Plugins, Build Swagger APIs to list, edit pages, You can finish some interesting things. diff --git a/schematics/docs/plugin.zh-CN.md b/schematics/docs/plugin.zh-CN.md index 5a520f10e..2db89c89d 100644 --- a/schematics/docs/plugin.zh-CN.md +++ b/schematics/docs/plugin.zh-CN.md @@ -87,21 +87,6 @@ ng g ng-alain:plugin defaultLanguage --defaultLanguage=zh-tw | 西班牙语 | es | es | es_ES | es_ES | | 意大利语 | it | it | it_IT | it_IT | -### networkEnv - -在国内使用 npm 或 yarn 始终是一个“痛”,因此你可以增加一个使用淘宝镜像配置文件 `.npmrc` 或 `.yarnrc`,来解决网络问题。 - -```bash -# add npm -ng g ng-alain:plugin networkEnv --packageManager=npm -# add yarn -ng g ng-alain:plugin networkEnv --packageManager=yarn -# remove npm -ng g ng-alain:plugin networkEnv --packageManager=npm -t=remove -# remove yarn -ng g ng-alain:plugin networkEnv --packageManager=yarn -t=remove -``` - ### sts [ng-alain-sts](https://github.com/ng-alain/sts) 插件,构建 Swagger API 转换为列表、编辑页,更多有趣的玩法请自行想象。 diff --git a/schematics/ng-add/index.ts b/schematics/ng-add/index.ts index c15bb4a95..e1b9b3316 100644 --- a/schematics/ng-add/index.ts +++ b/schematics/ng-add/index.ts @@ -4,7 +4,7 @@ import * as colors from 'ansi-colors'; import { Schema as NgAddOptions } from './schema'; import { Schema as ApplicationOptions } from '../application/schema'; -import { DEFAULT_WORKSPACE_PATH, readJSON, readPackage } from '../utils'; +import { readPackage } from '../utils'; import { getNodeMajorVersion } from '../utils/node'; const V = 16; @@ -30,33 +30,13 @@ function genRules(options: NgAddOptions): Rule { ); } - if (options.npm) { - rules.push( - schematic('plugin', { - name: 'networkEnv', - type: 'add', - packageManager: 'npm' - }) - ); - } - - if (options.yarn) { - rules.push( - schematic('plugin', { - name: 'networkEnv', - type: 'add', - packageManager: 'yarn' - }) - ); - } - return chain(rules); }; } -function isYarn(tree: Tree): boolean { - return readJSON(tree, DEFAULT_WORKSPACE_PATH)?.cli?.packageManager === 'yarn'; -} +// function isYarn(tree: Tree): boolean { +// return readJSON(tree, DEFAULT_WORKSPACE_PATH)?.cli?.packageManager === 'yarn'; +// } function finished(): Rule { return (_: Tree, context: SchematicContext) => { @@ -74,9 +54,9 @@ NG-ALAIN documentation site: https://ng-alain.com export default function (options: NgAddOptions): Rule { return (tree: Tree, context: SchematicContext) => { - if (!isYarn(tree)) { - context.logger.warn(`TIPS:: Please use yarn instead of NPM to install dependencies`); - } + // if (!isYarn(tree)) { + // context.logger.warn(`TIPS:: Please use yarn instead of NPM to install dependencies`); + // } const nodeVersion = getNodeMajorVersion(); const allowNodeVersions = [14, 16, 18]; @@ -99,7 +79,7 @@ export default function (options: NgAddOptions): Rule { } if (!ngCoreVersion.startsWith(`${V}.`)) { throw new SchematicsException( - `Sorry, the current version only supports angular ${V}.x, pls downgrade the global Anguar-cli version: [yarn global add @angular/cli@${V}] (or via npm: [npm install -g @angular/cli@${V}])` + `Sorry, the current version only supports angular ${V}.x, pls downgrade the global Anguar-cli version: [npm install -g @angular/cli@${V}]` ); } diff --git a/schematics/ng-add/schema.json b/schematics/ng-add/schema.json index f76a08f36..f08dde575 100644 --- a/schematics/ng-add/schema.json +++ b/schematics/ng-add/schema.json @@ -74,16 +74,6 @@ "description": "Generate i18n plugin", "default": false, "x-prompt": "Would you like to add i18n plugin? (default: N)" - }, - "npm": { - "type": "boolean", - "description": "Generates .npmrc proxy to taobao.", - "default": false - }, - "yarn": { - "type": "boolean", - "description": "Generates .yarnrc proxy to taobao.", - "default": false } } } diff --git a/schematics/ng-add/schema.ts b/schematics/ng-add/schema.ts index 4ea858d7d..cc5336ee8 100644 --- a/schematics/ng-add/schema.ts +++ b/schematics/ng-add/schema.ts @@ -4,6 +4,4 @@ export interface Schema { defaultLanguage?: string; i18n?: boolean; codeStyle?: boolean; - npm?: boolean; - yarn?: boolean; } diff --git a/schematics/plugin/index.ts b/schematics/plugin/index.ts index 22c003848..1c0bc30ef 100644 --- a/schematics/plugin/index.ts +++ b/schematics/plugin/index.ts @@ -7,7 +7,6 @@ import { pluginCodeStyle } from './plugin.code-style'; import { pluginDefaultLanguage } from './plugin.default-language'; import { pluginDocker } from './plugin.docker'; import { pluginIcon } from './plugin.icon'; -import { pluginNetworkEnv } from './plugin.network-env'; import { pluginRTL } from './plugin.rtl'; import { pluginSTS } from './plugin.sts'; import { Schema as PluginSchema } from './schema'; @@ -37,9 +36,6 @@ export default function (options: PluginSchema): Rule { case 'codeStyle': rules.push(pluginCodeStyle(pluginOptions), installPackages()); break; - case 'networkEnv': - rules.push(pluginNetworkEnv({ ...pluginOptions, packageManager: options.packageManager })); - break; case 'docker': rules.push(pluginDocker(pluginOptions)); break; diff --git a/schematics/plugin/plugin.network-env.spec.ts b/schematics/plugin/plugin.network-env.spec.ts deleted file mode 100644 index 8eb0894b4..000000000 --- a/schematics/plugin/plugin.network-env.spec.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; - -import { createAlainApp } from '../utils/testing'; - -describe('NgAlainSchematic: plugin: networkEnv', () => { - let runner: SchematicTestRunner; - let tree: UnitTestTree; - - describe(`[npm]`, () => { - const npmrc = '/.npmrc'; - - beforeEach(async () => ({ runner, tree } = await createAlainApp({ npm: true }))); - - describe('when add', () => { - it(`should add .npmrc`, () => { - expect(tree.exists(npmrc)).toBe(true); - expect(tree.readContent(npmrc)).toContain(`registry=https://registry.npmmirror.com`); - }); - }); - - describe('when remove', () => { - beforeEach(async () => - runner.runSchematic('plugin', { name: 'networkEnv', type: 'remove', packageManager: 'npm' }, tree) - ); - - it(`should remove .npmrc`, () => { - expect(tree.exists(npmrc)).toBe(false); - }); - }); - }); - - describe(`[yarn]`, () => { - const yarnrc = '/.yarnrc'; - - beforeEach(async () => ({ runner, tree } = await createAlainApp({ yarn: true }))); - - describe('when add', () => { - it(`should add .yarnrc`, () => { - expect(tree.exists(yarnrc)).toBe(true); - expect(tree.readContent(yarnrc)).toContain(`registry "https://registry.npmmirror.com"`); - }); - }); - - describe('when remove', () => { - beforeEach(async () => - runner.runSchematic('plugin', { name: 'networkEnv', type: 'remove', packageManager: 'yarn' }, tree) - ); - - it(`should remove .yarnrc`, () => { - expect(tree.exists(yarnrc)).toBe(false); - }); - }); - }); -}); diff --git a/schematics/plugin/plugin.network-env.ts b/schematics/plugin/plugin.network-env.ts deleted file mode 100644 index bbf34f1d6..000000000 --- a/schematics/plugin/plugin.network-env.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Rule, SchematicsException, Tree } from '@angular-devkit/schematics'; - -import { PluginOptions } from './interface'; - -const CONFIG = { - npm: { - path: `./.npmrc`, - content: `sass_binary_site=https://npmmirror.com/mirrors/node-sass/ -phantomjs_cdnurl=https://npmmirror.com/mirrors/phantomjs/ -electron_mirror=https://npmmirror.com/mirrors/electron/ -registry=https://registry.npmmirror.com` - }, - yarn: { - path: `./.yarnrc`, - content: `sass_binary_site "https://npmmirror.com/mirrors/node-sass/" -phantomjs_cdnurl "https://npmmirror.com/mirrors/phantomjs/" -electron_mirror "https://npmmirror.com/mirrors/electron/" -registry "https://registry.npmmirror.com"` - } -}; - -export function pluginNetworkEnv(options: PluginOptions): Rule { - return (tree: Tree) => { - const item = CONFIG[options.packageManager || '']; - if (item == null) { - throw new SchematicsException(`Must be specified the "packageManager" parameter`); - } - if (tree.exists(item.path)) { - tree.delete(item.path); - } - - if (options.type === 'remove') { - return; - } - - tree.create(item.path, item.content); - }; -} diff --git a/schematics/plugin/schema.json b/schematics/plugin/schema.json index 0e687856a..b9ac7f4d6 100644 --- a/schematics/plugin/schema.json +++ b/schematics/plugin/schema.json @@ -23,11 +23,6 @@ "type": "string", "description": "The name of the project." }, - "packageManager": { - "description": "Specifies the packageManager of project. (only: networkEnv plugin)", - "enum": ["npm", "yarn"], - "type": "string" - }, "defaultLanguage": { "type": "string", "description": "Specify default language [https://ng-alain.com/docs/i18n]." diff --git a/schematics/plugin/schema.ts b/schematics/plugin/schema.ts index 960b7bd43..5a7373a8f 100644 --- a/schematics/plugin/schema.ts +++ b/schematics/plugin/schema.ts @@ -2,6 +2,5 @@ export interface Schema { name: string; type: 'add' | 'remove'; project?: string; - packageManager?: 'npm' | 'yarn'; defaultLanguage?: string; } diff --git a/src/app/core/code/files/readme-cli.ts b/src/app/core/code/files/readme-cli.ts index dc9246f44..cba72c758 100644 --- a/src/app/core/code/files/readme-cli.ts +++ b/src/app/core/code/files/readme-cli.ts @@ -7,9 +7,9 @@ This template was generated with [Angular CLI](https://github.com/angular/angula On the terminal on your bottom right there is a + you can click to open a new tab in it you can write any commands you want with: \`\`\` -yarn ng -yarn ng g ng-alain:module news -yarn ng g ng-alain:list list -m=news +npm ng +npm ng g ng-alain:module news +npm ng g ng-alain:list list -m=news \`\`\` ## QA