-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
234 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: Principle | ||
--- | ||
|
||
edam | ||
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: "执行流程" | ||
order: 1 | ||
--- | ||
|
||
本文将讲解 Edam 的内部原理。流程如下图: | ||
![](../imgs/edam-process.svg) | ||
|
||
1. 读取用户配置 | ||
2. [插件](./write-plugin_zh.md)注册 | ||
3. 校验配置是否合法(使用[walli](https://github.com/imcuttle/walli)) | ||
4. 获取模板来源 | ||
5. 安装模板中的依赖 | ||
6. 读取模板配置 | ||
7. 用户交互输入 | ||
8. 载入模板文件资源 | ||
9. [处理转换](./write-loader_zh.md)模板文件资源文本,触发生命钩子 | ||
10. 输出文件 | ||
11. 触发 usefulHooks, post 钩子 | ||
12. 结束 | ||
|
||
### 用户配置 | ||
|
||
该配置用于用户,用于定义一下模板来源`source/alias`。 | ||
|
||
详细的定义在[选项一节](../usage/options_zh.md). | ||
|
||
### 模板(开发者)配置 | ||
|
||
该配置用于一个模板中,详细请看[如何书写模板](./write-template_zh.md) | ||
|
||
### 三种预设模板拉取方式 | ||
|
||
1. git | ||
2. npm | ||
3. 本地文件 | ||
|
||
更多介绍参看[特性一节](../features_zh.md)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: "书写模板" | ||
order: 2 | ||
--- | ||
|
||
模板是 Edam 一个重要的概念,可以说核心就是模板的处理。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: "书写模板" | ||
order: 2 | ||
--- | ||
|
||
模板是 Edam 一个重要的概念,可以说核心就是模板的处理。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: "书写Loader" | ||
order: 3 | ||
--- | ||
|
||
模板配置中与Loader相关的字段有 `mappers` `loaders` | ||
|
||
- loaders 形如 | ||
|
||
{ | ||
loaderName: 'sss' | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: "书写模板" | ||
order: 2 | ||
--- | ||
|
||
模板是 Edam 一个重要的概念,可以说核心就是模板处理。 | ||
|
||
流程如下: | ||
|
||
1. 根据模板配置中的 `prompts` 数组字段来进行用户输入交互,获取用户输入; | ||
使用 [inquirer.js](https://github.com/SBoudrias/Inquirer.js/) | ||
|
||
2. 模板配置中的 `root` 值,root 为模板文件夹的目录,默认为 `./template`; | ||
3. 读取 `root` 中的文件数据 | ||
4. 分析配置中的 loader,对文件数据进行处理转换 | ||
关于 Loader 描述请转至[书写 Loader](./write-loader_zh.md) | ||
* 规则一(最高优先):文件文本,如首行匹配如下任意一种语法: | ||
```text | ||
// @loader ${LOADER_NAME}?${QUERY} | ||
/* @loader ${LOADER_NAME}?${QUERY} */ | ||
# @loader ${LOADER_NAME}?${QUERY} | ||
<!-- @loader ${LOADER_NAME}?${QUERY} --> | ||
``` | ||
则将使用 LOADER_NAME 进行处理,LOADER_NAME 对应与 `loaders` 中定义的 loader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/** | ||
* @file main.spec | ||
* @author Cuttle Cong | ||
* @date 2018/3/31 | ||
* @description | ||
*/ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.