clwy-express-generator 5.0.1 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/bin/express-cli.js +15 -32
- package/package.json +3 -3
- package/templates/prisma/schema.prisma +0 -14
package/README.md
CHANGED
|
@@ -12,10 +12,10 @@ Forked from [express-generator](https://github.com/expressjs/generator), this pr
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
14
|
- **🚀 Support for ES6 syntax**: The project now supports using ES6 syntax, making the code more modern and concise.
|
|
15
|
-
- **💾 Support for creating Prisma ORM project**: The project now supports integrating Prisma ORM, simplifying database operations.
|
|
16
15
|
- **🔀 Split routes**: The route files are now split into separate files, making them easier to manage and maintain.
|
|
17
16
|
- **📁 Added middleware folder**: A new middleware folder has been added to store various middleware, improving the modularity of the code.
|
|
18
17
|
- **🔧 Added environment variable configuration file**: The project now includes a configuration file for environment variables, making it easier to manage different environments.
|
|
18
|
+
- **🔄 nodemon has been added**: The project now uses nodemon by default, automatically restarting the server during development when file changes are detected.
|
|
19
19
|
|
|
20
20
|
## Quick Start
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ The quickest way to get started with express is to utilize the executable `expre
|
|
|
24
24
|
Create the app:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
$ npx clwy-express-generator --
|
|
27
|
+
$ npx clwy-express-generator --es6 es6-demo && cd es6-demo
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Install dependencies:
|
|
@@ -44,7 +44,7 @@ $ npm start
|
|
|
44
44
|
This generator can also be further configured with the following command line flags.
|
|
45
45
|
|
|
46
46
|
--version output the version number
|
|
47
|
-
-v, --view <engine> add view <engine> support (dust|ejs|hbs|hjs|
|
|
47
|
+
-v, --view <engine> add view <engine> support (dust|ejs|hbs|hjs|pug|twig|vash|api) (defaults to ejs)
|
|
48
48
|
--no-view use static html instead of view engine
|
|
49
49
|
-c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
|
|
50
50
|
--git add .gitignore
|
|
@@ -60,10 +60,10 @@ Forked from [express-generator](https://github.com/expressjs/generator),此项
|
|
|
60
60
|
## 功能特性
|
|
61
61
|
|
|
62
62
|
- **🚀 支持ES6语法**:项目现在支持使用ES6语法,使代码更加现代化和简洁。
|
|
63
|
-
- **💾 支持创建 Prisma ORM 项目**:项目现在支持集成 Prisma ORM,简化了数据库操作。
|
|
64
63
|
- **🔀 分割路由**:路由文件现在被拆分到单独的文件中,使它们更易于管理和维护。
|
|
65
64
|
- **📁 新增中间件文件夹**:添加了一个新的中间件文件夹来存放各种中间件,提高了代码的模块化。
|
|
66
65
|
- **🔧 添加环境变量配置文件**:项目现在包含一个环境变量的配置文件,使管理不同环境变得更加容易。
|
|
66
|
+
- **🔄 增加了 nodemon**: 项目现在默认使用 nodemon,在开发过程中,当文件发生变化时会自动重启服务。
|
|
67
67
|
|
|
68
68
|
## 快速开始
|
|
69
69
|
|
|
@@ -72,7 +72,7 @@ Forked from [express-generator](https://github.com/expressjs/generator),此项
|
|
|
72
72
|
创建应用:
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
$ npx clwy-express-generator --
|
|
75
|
+
$ npx clwy-express-generator --es6 es6-demo && cd es6-demo
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
安装依赖:
|
|
@@ -92,7 +92,7 @@ $ npm start
|
|
|
92
92
|
此生成器还可以通过以下命令行标志进行进一步配置。
|
|
93
93
|
|
|
94
94
|
--version 输出版本号
|
|
95
|
-
-v, --view <engine> 添加视图引擎 <engine> 支持 (dust|ejs|hbs|hjs|
|
|
95
|
+
-v, --view <engine> 添加视图引擎 <engine> 支持 (dust|ejs|hbs|hjs|pug|twig|vash|api)(默认为 ejs)
|
|
96
96
|
--no-view 使用静态html而不是视图引擎
|
|
97
97
|
-c, --css <engine> 添加样式表引擎 <engine> 支持 (less|stylus|compass|sass)(默认为纯 css)
|
|
98
98
|
--git 添加 .gitignore 文件
|
package/bin/express-cli.js
CHANGED
|
@@ -100,9 +100,9 @@ function createApplication (name, dir, options, done) {
|
|
|
100
100
|
start: 'nodemon ./bin/www'
|
|
101
101
|
},
|
|
102
102
|
dependencies: {
|
|
103
|
-
debug: '~
|
|
104
|
-
dotenv: '^16.
|
|
105
|
-
express: '~
|
|
103
|
+
debug: '~4.4.0',
|
|
104
|
+
dotenv: '^16.5.0',
|
|
105
|
+
express: '~5.1.0'
|
|
106
106
|
},
|
|
107
107
|
devDependencies: {
|
|
108
108
|
nodemon: '^3.1.9'
|
|
@@ -136,7 +136,7 @@ function createApplication (name, dir, options, done) {
|
|
|
136
136
|
// Cookie parser
|
|
137
137
|
app.locals.modules.cookieParser = 'cookie-parser'
|
|
138
138
|
app.locals.uses.push('cookieParser()')
|
|
139
|
-
pkg.dependencies['cookie-parser'] = '~1.4.
|
|
139
|
+
pkg.dependencies['cookie-parser'] = '~1.4.7'
|
|
140
140
|
|
|
141
141
|
// Env vars
|
|
142
142
|
env.locals.orm = options.orm
|
|
@@ -152,15 +152,6 @@ function createApplication (name, dir, options, done) {
|
|
|
152
152
|
mkdir(dir, 'middlewares')
|
|
153
153
|
mkdir(dir, 'utils')
|
|
154
154
|
|
|
155
|
-
// copy Prisma templates
|
|
156
|
-
if (options.orm) {
|
|
157
|
-
pkg.dependencies.prisma = '^6.2.1'
|
|
158
|
-
pkg.dependencies['@prisma/client'] = '^6.2.1'
|
|
159
|
-
|
|
160
|
-
mkdir(dir, 'prisma')
|
|
161
|
-
copyTemplateMulti('prisma', dir + '/prisma', '*.prisma')
|
|
162
|
-
}
|
|
163
|
-
|
|
164
155
|
// copy css templates
|
|
165
156
|
switch (options.css) {
|
|
166
157
|
case 'less':
|
|
@@ -196,7 +187,7 @@ function createApplication (name, dir, options, done) {
|
|
|
196
187
|
if (options.view) {
|
|
197
188
|
// Copy view templates
|
|
198
189
|
mkdir(dir, 'views')
|
|
199
|
-
pkg.dependencies['http-errors'] = '~
|
|
190
|
+
pkg.dependencies['http-errors'] = '~2.0.0'
|
|
200
191
|
copyTemplateMulti(
|
|
201
192
|
options.es6 ? 'mjs/middlewares' : 'js/middlewares',
|
|
202
193
|
dir + '/middlewares', '*.js'
|
|
@@ -215,9 +206,6 @@ function createApplication (name, dir, options, done) {
|
|
|
215
206
|
case 'hjs':
|
|
216
207
|
copyTemplateMulti('views', dir + '/views', '*.hjs')
|
|
217
208
|
break
|
|
218
|
-
case 'jade':
|
|
219
|
-
copyTemplateMulti('views', dir + '/views', '*.jade')
|
|
220
|
-
break
|
|
221
209
|
case 'pug':
|
|
222
210
|
copyTemplateMulti('views', dir + '/views', '*.pug')
|
|
223
211
|
break
|
|
@@ -238,22 +226,22 @@ function createApplication (name, dir, options, done) {
|
|
|
238
226
|
case 'compass':
|
|
239
227
|
app.locals.modules.compass = 'node-compass'
|
|
240
228
|
app.locals.uses.push("compass({ mode: 'expanded' })")
|
|
241
|
-
pkg.dependencies['node-compass'] = '0.2.
|
|
229
|
+
pkg.dependencies['node-compass'] = '~0.2.4'
|
|
242
230
|
break
|
|
243
231
|
case 'less':
|
|
244
232
|
app.locals.modules.lessMiddleware = 'less-middleware'
|
|
245
233
|
app.locals.uses.push("lessMiddleware(path.join(__dirname, 'public'))")
|
|
246
|
-
pkg.dependencies['less-middleware'] = '~
|
|
234
|
+
pkg.dependencies['less-middleware'] = '~3.1.0'
|
|
247
235
|
break
|
|
248
236
|
case 'sass':
|
|
249
237
|
app.locals.modules.sassMiddleware = 'node-sass-middleware'
|
|
250
238
|
app.locals.uses.push("sassMiddleware({\n src: path.join(__dirname, 'public'),\n dest: path.join(__dirname, 'public'),\n indentedSyntax: true, // true = .sass and false = .scss\n sourceMap: true\n})")
|
|
251
|
-
pkg.dependencies['node-sass-middleware'] = '
|
|
239
|
+
pkg.dependencies['node-sass-middleware'] = '~1.1.0'
|
|
252
240
|
break
|
|
253
241
|
case 'stylus':
|
|
254
242
|
app.locals.modules.stylus = 'stylus'
|
|
255
243
|
app.locals.uses.push("stylus.middleware(path.join(__dirname, 'public'))")
|
|
256
|
-
pkg.dependencies.stylus = '0.
|
|
244
|
+
pkg.dependencies.stylus = '~0.64.0'
|
|
257
245
|
break
|
|
258
246
|
}
|
|
259
247
|
|
|
@@ -269,31 +257,27 @@ function createApplication (name, dir, options, done) {
|
|
|
269
257
|
break
|
|
270
258
|
case 'ejs':
|
|
271
259
|
app.locals.view = { engine: 'ejs' }
|
|
272
|
-
pkg.dependencies.ejs = '~
|
|
260
|
+
pkg.dependencies.ejs = '~3.1.10'
|
|
273
261
|
break
|
|
274
262
|
case 'hbs':
|
|
275
263
|
app.locals.view = { engine: 'hbs' }
|
|
276
|
-
pkg.dependencies.hbs = '~4.0
|
|
264
|
+
pkg.dependencies.hbs = '~4.2.0'
|
|
277
265
|
break
|
|
278
266
|
case 'hjs':
|
|
279
267
|
app.locals.view = { engine: 'hjs' }
|
|
280
268
|
pkg.dependencies.hjs = '~0.0.6'
|
|
281
269
|
break
|
|
282
|
-
case 'jade':
|
|
283
|
-
app.locals.view = { engine: 'jade' }
|
|
284
|
-
pkg.dependencies.jade = '~1.11.0'
|
|
285
|
-
break
|
|
286
270
|
case 'pug':
|
|
287
271
|
app.locals.view = { engine: 'pug' }
|
|
288
|
-
pkg.dependencies.pug = '
|
|
272
|
+
pkg.dependencies.pug = '~3.0.3'
|
|
289
273
|
break
|
|
290
274
|
case 'twig':
|
|
291
275
|
app.locals.view = { engine: 'twig' }
|
|
292
|
-
pkg.dependencies.twig = '~
|
|
276
|
+
pkg.dependencies.twig = '~1.17.1'
|
|
293
277
|
break
|
|
294
278
|
case 'vash':
|
|
295
279
|
app.locals.view = { engine: 'vash' }
|
|
296
|
-
pkg.dependencies.vash = '~0.
|
|
280
|
+
pkg.dependencies.vash = '~0.13.0'
|
|
297
281
|
break
|
|
298
282
|
default:
|
|
299
283
|
app.locals.view = false
|
|
@@ -551,12 +535,11 @@ function usage () {
|
|
|
551
535
|
console.log(' --pug add pug engine support')
|
|
552
536
|
console.log(' --hbs add handlebars engine support')
|
|
553
537
|
console.log(' -H, --hogan add hogan.js engine support')
|
|
554
|
-
console.log(' -v, --view <engine> add view <engine> support (dust|ejs|hbs|hjs|
|
|
538
|
+
console.log(' -v, --view <engine> add view <engine> support (dust|ejs|hbs|hjs|pug|twig|vash) (defaults to ejs)')
|
|
555
539
|
console.log(' --no-view use static html instead of view engine')
|
|
556
540
|
console.log(' -c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)')
|
|
557
541
|
console.log(' --git add .gitignore')
|
|
558
542
|
console.log(' --es6 generate ES6 code and module-type project (requires Node 14.x or higher)')
|
|
559
|
-
console.log(' -o, --orm specify the ORM to use Prisma')
|
|
560
543
|
console.log(' -f, --force force on non-empty directory')
|
|
561
544
|
console.log(' --version output the version number')
|
|
562
545
|
console.log(' -h, --help output usage information')
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "clwy-express-generator",
|
|
3
3
|
"description": "Express' application generator",
|
|
4
4
|
"homepage": "https://github.com/clwy-cn/clwy-express-generator",
|
|
5
|
-
"version": "5.0.
|
|
5
|
+
"version": "5.0.3",
|
|
6
6
|
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
|
7
7
|
"contributors": [
|
|
8
8
|
"Aaron Heckmann <aaron.heckmann+github@gmail.com>",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"repository": "expressjs/generator",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"ejs": "
|
|
30
|
+
"ejs": "3.1.10",
|
|
31
31
|
"minimatch": "3.0.4",
|
|
32
32
|
"minimist": "1.2.5",
|
|
33
33
|
"mkdirp": "0.5.1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"main": "bin/express-cli.js",
|
|
37
37
|
"preferGlobal": true,
|
|
38
38
|
"bin": {
|
|
39
|
-
"express": "./bin/express-cli.js"
|
|
39
|
+
"clwy-express": "./bin/express-cli.js"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"eslint": "7.32.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// This is your Prisma schema file,
|
|
2
|
-
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
-
|
|
4
|
-
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
5
|
-
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
6
|
-
|
|
7
|
-
generator client {
|
|
8
|
-
provider = "prisma-client-js"
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
datasource db {
|
|
12
|
-
provider = "mysql"
|
|
13
|
-
url = env("DATABASE_URL")
|
|
14
|
-
}
|