Skip to content

Commit fd411b1

Browse files
committed
docs(README): 更新文档内容和结构
- 修改项目描述为"A scaffolding creation tool" - 优化文档结构,统一列表符号使用短横线 - 更新示例代码和说明,使其更加清晰和准确 - 添加处理特殊点文件的方法,解决 .gitignore 和 .npmignore 文件在 npm 发布时被忽略的问题 - 修正部分翻译不一致的问题,确保中英文文档同步
1 parent 08bf664 commit fd411b1

File tree

2 files changed

+40
-53
lines changed

2 files changed

+40
-53
lines changed

README-en.md

+30-37
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
[![dependency-review](https://github.com/FrontEndDev-org/create-creator/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/FrontEndDev-org/create-creator/actions/workflows/dependency-review.yml)
77
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4fa1acaeb717469caddfe21a84c50bb2)](https://app.codacy.com/gh/FrontEndDev-org/create-creator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
88
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/4fa1acaeb717469caddfe21a84c50bb2)](https://app.codacy.com/gh/FrontEndDev-org/create-creator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
9-
[![npm version](https://img.shields.io/npm/v/create-creator?labelColor=5D5D5D&color=00CD39)](https://npmjs.com/package/create-creator)
9+
[![npm version](https://img.shields.io/npm/v/create-creator)](https://npmjs.com/package/create-creator)
1010

11-
A scaffolding generator.
11+
A scaffolding creation tool.
1212

1313
## Features
1414

15-
- 🗝 Simple and easy to use, clean design
15+
- 🗝 Simple and easy to use with clean design
1616
- 🛠️ Template-based project generation
1717
- ⚙️ Interactive CLI configuration
18-
- 📦 Multiple template support
18+
- 📦 Support for multiple templates
1919
- 🧩 EJS template rendering
2020

2121
## Installation & Usage
@@ -60,22 +60,22 @@ my-creator
6060
├── .nvmrc
6161
├── README.md
6262
├── bin
63-
   └── index.cjs
63+
└── index.cjs
6464
├── biome.jsonc
6565
├── commitlint.config.mjs
6666
├── lefthook.yml
6767
├── package.json
6868
├── src
69-
   ├── const.ts
70-
   ├── dts
71-
   │   ├── global.d.ts
72-
   │   └── types.d.ts
73-
   └── index.ts
69+
├── const.ts
70+
├── dts
71+
├── global.d.ts
72+
└── types.d.ts
73+
└── index.ts
7474
├── templates
75-
   └── default
76-
   └── README.md.ejs
75+
└── default
76+
└── README.md.ejs
7777
├── test
78-
   └── sample.test.ts
78+
└── sample.test.ts
7979
├── tsconfig.json
8080
└── vite.config.mts
8181
```
@@ -98,7 +98,7 @@ export async function createCLI() {
9898
### Open `templates` to write template files
9999
- templates is the root directory for templates
100100
- templates/default is a specific template directory, can be any name
101-
- If there are multiple directories under templates, they will be available for user selection during project creation
101+
- If there are multiple directories under templates, users can choose during project creation
102102

103103
## Examples
104104

@@ -129,7 +129,7 @@ Created by: <%= author %>
129129
Created at: <%= timestamp %>
130130
```
131131

132-
### Conditionally render different template files
132+
### Render different template files based on conditions
133133

134134
```ts
135135
// src/index.ts
@@ -152,7 +152,7 @@ export async function createCLI() {
152152
}
153153
```
154154

155-
### Logging
155+
### Print related logs
156156

157157
```ts
158158
// src/index.ts
@@ -165,7 +165,7 @@ export async function createCLI() {
165165
});
166166

167167
creator.on('before', ({prompts}) => {
168-
prompts.log.info('Display some banner information');
168+
prompts.log.info('Output some banner information');
169169
});
170170

171171
creator.on('start', ({prompts}) => {
@@ -184,7 +184,7 @@ export async function createCLI() {
184184
}
185185
```
186186

187-
### Custom CLI selection
187+
### Custom CLI selection interaction
188188
```ts
189189
// src/index.ts
190190
import { promptSafe } from 'create-creator';
@@ -216,22 +216,16 @@ export async function createCLI() {
216216
}
217217
```
218218

219-
### Dot files
220-
To create dot files (e.g., .gitignore, .npmrc) in templates/default directory, prefix the filename with `_` since dot files are hidden in file systems.
221-
```bash
222-
templates/default/
223-
├── _gitignore -> .gitignore
224-
├── _npmrc -> .npmrc
225-
└── README.md
226-
```
219+
### Special dot files
220+
When publishing npm packages, `.gitignore` and `.npmignore` files are ignored by default. The conventional approach is:
227221

228-
### Underscore files
229-
In `templates`, creating dot files requires `_*` prefix, so creating underscore (`_*`) files requires double underscore prefix (`__*`).
230-
```bash
231-
templates/default/
232-
├── __gitignore -> _gitignore
233-
├── __npmrc -> _npmrc
234-
└── README.md
222+
1. Rename `.gitignore` and `.npmignore` to `_gitignore` and `_npmignore`
223+
2. Add custom interceptors for special handling
224+
```ts
225+
// Rename _gitignore and _npmignore files in any directory to .gitignore and .npmignore
226+
creator.writeIntercept(['**/_gitignore', '**/_npmignore'], (meta) => ({
227+
targetFileName: meta.targetFileName.replace('_', '.'),
228+
}));
235229
```
236230

237231
## API
@@ -465,12 +459,12 @@ Triggered when creation ends
465459

466460
### Interceptors
467461
#### `writeIntercept(paths: string | string[], interceptor: WriteInterceptor)`
468-
Intercept file writing. Example:
462+
Intercept file writing. For example:
469463

470464
- If `ssr` is configured, generate `src/client.ts` and `src/server.ts`
471465
- Otherwise
472466
- If source file is `client.ts`, rename to `index.ts`
473-
- If source file is `server.ts`, skip generation
467+
- If source file is `server.ts`, don't generate
474468

475469
```ts
476470
creator.writeIntercept(['*/src/client.ts', '*/src/server.ts'], (fileMeta, data) => {
@@ -481,7 +475,7 @@ creator.writeIntercept(['*/src/client.ts', '*/src/server.ts'], (fileMeta, data)
481475
? {
482476
targetFileName: 'index.ts'
483477
}
484-
// skip server.ts
478+
// Don't write server.ts
485479
: {
486480
disableWrite: true
487481
}
@@ -549,7 +543,6 @@ export const prompts = Prompts;
549543
export const colors = Colors;
550544
```
551545

552-
553546
## License
554547

555548
MIT

README.md

+10-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![dependency-review](https://github.com/FrontEndDev-org/create-creator/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/FrontEndDev-org/create-creator/actions/workflows/dependency-review.yml)
77
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4fa1acaeb717469caddfe21a84c50bb2)](https://app.codacy.com/gh/FrontEndDev-org/create-creator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
88
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/4fa1acaeb717469caddfe21a84c50bb2)](https://app.codacy.com/gh/FrontEndDev-org/create-creator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
9-
[![npm version](https://img.shields.io/npm/v/create-creator?labelColor=5D5D5D&color=00CD39)](https://npmjs.com/package/create-creator)
9+
[![npm version](https://img.shields.io/npm/v/create-creator)](https://npmjs.com/package/create-creator)
1010

1111
创建一个脚手架。
1212

@@ -216,22 +216,16 @@ export async function createCLI() {
216216
}
217217
```
218218

219-
### 点文件
220-
在 templates/default 目录下创建点(`.*`)文件,例如 .gitignore 和 .npmrc。注意,由于点文件在文件系统中是隐藏文件,需要在文件名前加上 `_` 前缀,以便在模板中正确处理。
221-
```bash
222-
templates/default/
223-
├── _gitignore -> .gitignore
224-
├── _npmrc -> .npmrc
225-
└── README.md
226-
```
219+
### 特殊点文件
220+
在发布 npm 包的时候,`.gitignore``.npmignore` 两个文件会默认被忽略打包。此时,常规做法是
227221

228-
### 下划线文件
229-
`templates` 中,创建点文件需要 `_*` 开头,那么创建下划线(`_*`)开头的文件,则需要两个下划线开头(`__*`)。
230-
```bash
231-
templates/default/
232-
├── __gitignore -> _gitignore
233-
├── __npmrc -> _npmrc
234-
└── README.md
222+
1.`.gitignore``.npmignore` 文件重命名为 `_gitignore``_npmignore`
223+
2. 添加自定义拦截器进行特殊处理
224+
```ts
225+
// 将任意目录下的 _gitignore 和 _npmignore 文件重命名为 .gitignore 和 .npmignore
226+
creator.writeIntercept(['**/_gitignore', '**/_npmignore'], (meta) => ({
227+
targetFileName: meta.targetFileName.replace('_', '.'),
228+
}));
235229
```
236230

237231
## API

0 commit comments

Comments
 (0)