create-skweb 3.3.0 → 3.3.2

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/dist/cli.js CHANGED
@@ -36,10 +36,6 @@ async function createProject(options) {
36
36
  if (/\.auth-(static|jwks)(\.[^.]+)?$/.test(fileName)) {
37
37
  continue;
38
38
  }
39
- // 跳过无 auth 后缀的 .env.example(改用条件模板)
40
- if (fileName === '.env.example' || fileName.endsWith('/.env.example')) {
41
- continue;
42
- }
43
39
  const outputName = fileName;
44
40
  let content = await fs.readFile(srcPath, 'utf-8');
45
41
  // 处理条件块:{{#if_eq auth "static"}}...{{else}}...{{/if_eq}}
@@ -50,6 +46,8 @@ async function createProject(options) {
50
46
  .replace(/\{\{name\}\}/g, name)
51
47
  .replace(/\{\{description\}\}/g, description)
52
48
  .replace(/\{\{auth\}\}/g, auth);
49
+ // 移除 ts-nocheck 标记
50
+ content = content.replace(/^\/\/ @ts-nocheck\s*\n/gm, '');
53
51
  const destPath = path.join(targetDir, outputName);
54
52
  await fs.writeFile(destPath, content);
55
53
  }
@@ -83,44 +81,15 @@ function printBanner() {
83
81
  function printSuccess(name, dest) {
84
82
  const projectPath = path.join(path.resolve(dest), name);
85
83
  console.log(`
86
- ╔════════════════════════════════════════════════════════════════════╗
87
- ║ 项目创建成功! ║
88
- ╚════════════════════════════════════════════════════════════════════╝
89
-
90
- 项目名称: ${name}
91
- 项目路径: ${projectPath}
84
+ 项目创建成功!
92
85
 
93
- 接下来可以执行:
86
+ 名称: ${name}
87
+ 路径: ${projectPath}
94
88
 
89
+ 接下来执行:
95
90
  cd ${name}
96
-
97
- # 复制环境变量模板并按需修改
98
91
  cp .env.example .env
99
-
100
- # 开发模式运行
101
- npm run start:dev
102
-
103
- # 生产模式运行 (需要先构建)
104
- npm run build
105
- npm run start
106
-
107
- # 查看日志
108
- npm run logs
109
-
110
- # 停止服务
111
- npm run stop
112
-
113
- # 重启服务
114
- npm run restart
115
-
116
- 项目特性:
117
- ✅ TypeScript/MJS/CJS 支持
118
- ✅ @dotenvx/dotenvx 环境变量管理
119
- ✅ PM2 进程管理
120
- ✅ SKWeb Express 集成
121
- ✅ Keycloak/JWKS 鉴权 (可选)
122
- ✅ ESLint 代码检查
123
- ✅ Mocha 测试框架
92
+ npm run web:dev
124
93
  `);
125
94
  }
126
95
 
package/dist/index.js CHANGED
@@ -31,10 +31,6 @@ async function createProject(options) {
31
31
  if (/\.auth-(static|jwks)(\.[^.]+)?$/.test(fileName)) {
32
32
  continue;
33
33
  }
34
- // 跳过无 auth 后缀的 .env.example(改用条件模板)
35
- if (fileName === '.env.example' || fileName.endsWith('/.env.example')) {
36
- continue;
37
- }
38
34
  const outputName = fileName;
39
35
  let content = await fs.readFile(srcPath, 'utf-8');
40
36
  // 处理条件块:{{#if_eq auth "static"}}...{{else}}...{{/if_eq}}
@@ -45,6 +41,8 @@ async function createProject(options) {
45
41
  .replace(/\{\{name\}\}/g, name)
46
42
  .replace(/\{\{description\}\}/g, description)
47
43
  .replace(/\{\{auth\}\}/g, auth);
44
+ // 移除 ts-nocheck 标记
45
+ content = content.replace(/^\/\/ @ts-nocheck\s*\n/gm, '');
48
46
  const destPath = path.join(targetDir, outputName);
49
47
  await fs.writeFile(destPath, content);
50
48
  }
@@ -78,44 +76,15 @@ function printBanner() {
78
76
  function printSuccess(name, dest) {
79
77
  const projectPath = path.join(path.resolve(dest), name);
80
78
  console.log(`
81
- ╔════════════════════════════════════════════════════════════════════╗
82
- ║ 项目创建成功! ║
83
- ╚════════════════════════════════════════════════════════════════════╝
84
-
85
- 项目名称: ${name}
86
- 项目路径: ${projectPath}
79
+ 项目创建成功!
87
80
 
88
- 接下来可以执行:
81
+ 名称: ${name}
82
+ 路径: ${projectPath}
89
83
 
84
+ 接下来执行:
90
85
  cd ${name}
91
-
92
- # 复制环境变量模板并按需修改
93
86
  cp .env.example .env
94
-
95
- # 开发模式运行
96
- npm run start:dev
97
-
98
- # 生产模式运行 (需要先构建)
99
- npm run build
100
- npm run start
101
-
102
- # 查看日志
103
- npm run logs
104
-
105
- # 停止服务
106
- npm run stop
107
-
108
- # 重启服务
109
- npm run restart
110
-
111
- 项目特性:
112
- ✅ TypeScript/MJS/CJS 支持
113
- ✅ @dotenvx/dotenvx 环境变量管理
114
- ✅ PM2 进程管理
115
- ✅ SKWeb Express 集成
116
- ✅ Keycloak/JWKS 鉴权 (可选)
117
- ✅ ESLint 代码检查
118
- ✅ Mocha 测试框架
87
+ npm run web:dev
119
88
  `);
120
89
  }
121
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skweb",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "Create a new SKWeb project with TypeScript, CJS, or MJS support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -47,11 +47,6 @@ export async function createProject(options: CreateOptions): Promise<void> {
47
47
  continue
48
48
  }
49
49
 
50
- // 跳过无 auth 后缀的 .env.example(改用条件模板)
51
- if (fileName === '.env.example' || fileName.endsWith('/.env.example')) {
52
- continue
53
- }
54
-
55
50
  const outputName = fileName
56
51
 
57
52
  let content = await fs.readFile(srcPath, 'utf-8')
@@ -69,6 +64,9 @@ export async function createProject(options: CreateOptions): Promise<void> {
69
64
  .replace(/\{\{description\}\}/g, description)
70
65
  .replace(/\{\{auth\}\}/g, auth)
71
66
 
67
+ // 移除 ts-nocheck 标记
68
+ content = content.replace(/^\/\/ @ts-nocheck\s*\n/gm, '')
69
+
72
70
  const destPath = path.join(targetDir, outputName)
73
71
  await fs.writeFile(destPath, content)
74
72
  }
@@ -110,43 +108,14 @@ export function printBanner(): void {
110
108
  export function printSuccess(name: string, dest: string): void {
111
109
  const projectPath = path.join(path.resolve(dest), name)
112
110
  console.log(`
113
- ╔════════════════════════════════════════════════════════════════════╗
114
- ║ 项目创建成功! ║
115
- ╚════════════════════════════════════════════════════════════════════╝
116
-
117
- 项目名称: ${name}
118
- 项目路径: ${projectPath}
111
+ 项目创建成功!
119
112
 
120
- 接下来可以执行:
113
+ 名称: ${name}
114
+ 路径: ${projectPath}
121
115
 
116
+ 接下来执行:
122
117
  cd ${name}
123
-
124
- # 复制环境变量模板并按需修改
125
118
  cp .env.example .env
126
-
127
- # 开发模式运行
128
- npm run start:dev
129
-
130
- # 生产模式运行 (需要先构建)
131
- npm run build
132
- npm run start
133
-
134
- # 查看日志
135
- npm run logs
136
-
137
- # 停止服务
138
- npm run stop
139
-
140
- # 重启服务
141
- npm run restart
142
-
143
- 项目特性:
144
- ✅ TypeScript/MJS/CJS 支持
145
- ✅ @dotenvx/dotenvx 环境变量管理
146
- ✅ PM2 进程管理
147
- ✅ SKWeb Express 集成
148
- ✅ Keycloak/JWKS 鉴权 (可选)
149
- ✅ ESLint 代码检查
150
- ✅ Mocha 测试框架
119
+ npm run web:dev
151
120
  `)
152
121
  }
@@ -5,10 +5,6 @@ module.exports = {
5
5
  script: 'src/web-app.js',
6
6
  instances: 'max',
7
7
  exec_mode: 'cluster',
8
- env: {
9
- NODE_ENV: 'production',
10
- PORT: 3000
11
- },
12
8
  max_memory_restart: '512M',
13
9
  error_file: 'logs/web-err.log',
14
10
  out_file: 'logs/web-out.log',
@@ -20,9 +16,6 @@ module.exports = {
20
16
  instances: 1,
21
17
  exec_mode: 'fork',
22
18
  autorestart: true,
23
- env: {
24
- NODE_ENV: 'production'
25
- },
26
19
  max_memory_restart: '512M',
27
20
  error_file: 'logs/cron-err.log',
28
21
  out_file: 'logs/cron-out.log',
@@ -15,7 +15,6 @@ async function runMigrate() {
15
15
  database: process.env.DB_NAME || 'test-project',
16
16
  dialect: process.env.DB_DIALECT || 'mysql',
17
17
  charset: process.env.DB_CHARSET || 'utf8mb4',
18
- underscored: true,
19
18
  logging: process.env.DEBUG_DB === 'true' ? (msg) => logger.debug(msg) : false
20
19
  })
21
20
 
@@ -16,7 +16,6 @@ async function runSeed() {
16
16
  database: process.env.DB_NAME || 'test-project',
17
17
  dialect: process.env.DB_DIALECT || 'mysql',
18
18
  charset: process.env.DB_CHARSET || 'utf8mb4',
19
- underscored: true,
20
19
  logging: process.env.DEBUG_DB === 'true' ? (msg) => logger.debug(msg) : false
21
20
  })
22
21
 
@@ -5,7 +5,7 @@ const { framework } = require('./cron-framework.js')
5
5
  const { logger } = require('./utils/logger.js')
6
6
  const { checkRequiredEnv } = require('./utils/config.js')
7
7
 
8
- async function startCronWorker() {
8
+ async function bootstrap() {
9
9
  logger.info('[cron-worker] Starting cron worker process...')
10
10
 
11
11
  if (!checkRequiredEnv()) {
@@ -31,10 +31,10 @@ async function startCronWorker() {
31
31
  }
32
32
 
33
33
  if (require.main === module) {
34
- startCronWorker().catch((err) => {
34
+ bootstrap().catch((err) => {
35
35
  logger.error('[cron-worker] Fatal error:', err)
36
36
  process.exit(1)
37
37
  })
38
38
  }
39
39
 
40
- module.exports = { startCronWorker }
40
+ module.exports = { bootstrap }
@@ -11,7 +11,6 @@ const framework = new CronFramework({
11
11
  database: process.env.DB_NAME || 'test-project',
12
12
  dialect: process.env.DB_DIALECT || 'mysql',
13
13
  charset: process.env.DB_CHARSET || 'utf8mb4',
14
- underscored: true,
15
14
  logging: process.env.DEBUG_DB === 'true'
16
15
  },
17
16
  redis: {
@@ -10,7 +10,6 @@ const framework = new WebFramework({
10
10
  database: process.env.DB_NAME || 'test-project',
11
11
  dialect: process.env.DB_DIALECT || 'mysql',
12
12
  charset: process.env.DB_CHARSET || 'utf8mb4',
13
- underscored: true,
14
13
  logging: process.env.DEBUG_DB === 'true'
15
14
  },
16
15
  redis: {
@@ -5,10 +5,6 @@ module.exports = {
5
5
  script: 'src/web-app.js',
6
6
  instances: 'max',
7
7
  exec_mode: 'cluster',
8
- env: {
9
- NODE_ENV: 'production',
10
- PORT: 3000
11
- },
12
8
  max_memory_restart: '512M',
13
9
  error_file: 'logs/web-err.log',
14
10
  out_file: 'logs/web-out.log',
@@ -20,9 +16,6 @@ module.exports = {
20
16
  instances: 1,
21
17
  exec_mode: 'fork',
22
18
  autorestart: true,
23
- env: {
24
- NODE_ENV: 'production'
25
- },
26
19
  max_memory_restart: '512M',
27
20
  error_file: 'logs/cron-err.log',
28
21
  out_file: 'logs/cron-out.log',
@@ -19,7 +19,6 @@ async function runMigrate() {
19
19
  database: process.env.DB_NAME || 'test-project',
20
20
  dialect: process.env.DB_DIALECT || 'mysql',
21
21
  charset: process.env.DB_CHARSET || 'utf8mb4',
22
- underscored: true,
23
22
  logging: process.env.DEBUG_DB === 'true' ? (msg) => logger.debug(msg) : false
24
23
  })
25
24
 
@@ -19,7 +19,6 @@ async function runSeed() {
19
19
  database: process.env.DB_NAME || 'test-project',
20
20
  dialect: process.env.DB_DIALECT || 'mysql',
21
21
  charset: process.env.DB_CHARSET || 'utf8mb4',
22
- underscored: true,
23
22
  logging: process.env.DEBUG_DB === 'true' ? (msg) => logger.debug(msg) : false
24
23
  })
25
24
 
@@ -9,7 +9,7 @@ import { checkRequiredEnv } from './utils/config.js'
9
9
  const __filename = fileURLToPath(import.meta.url)
10
10
  const __dirname = path.dirname(__filename)
11
11
 
12
- async function startCronWorker() {
12
+ async function bootstrap() {
13
13
  logger.info('[cron-worker] Starting cron worker process...')
14
14
 
15
15
  if (!checkRequiredEnv()) {
@@ -36,10 +36,10 @@ async function startCronWorker() {
36
36
 
37
37
  const isMainModule = import.meta.url === `file://${process.argv[1]}`
38
38
  if (isMainModule) {
39
- startCronWorker().catch((err) => {
39
+ bootstrap().catch((err) => {
40
40
  logger.error('[cron-worker] Fatal error:', err)
41
41
  process.exit(1)
42
42
  })
43
43
  }
44
44
 
45
- export { startCronWorker }
45
+ export { bootstrap }
@@ -11,7 +11,6 @@ const framework = new CronFramework({
11
11
  database: process.env.DB_NAME || 'test-project',
12
12
  dialect: process.env.DB_DIALECT || 'mysql',
13
13
  charset: process.env.DB_CHARSET || 'utf8mb4',
14
- underscored: true,
15
14
  logging: process.env.DEBUG_DB === 'true'
16
15
  },
17
16
  redis: {
@@ -10,7 +10,6 @@ const framework = new WebFramework({
10
10
  database: process.env.DB_NAME || 'test-project',
11
11
  dialect: process.env.DB_DIALECT || 'mysql',
12
12
  charset: process.env.DB_CHARSET || 'utf8mb4',
13
- underscored: true,
14
13
  logging: process.env.DEBUG_DB === 'true'
15
14
  },
16
15
  redis: {
@@ -7,10 +7,6 @@ module.exports = {
7
7
  interpreter_args: 'tsx',
8
8
  instances: 'max',
9
9
  exec_mode: 'cluster',
10
- env: {
11
- NODE_ENV: 'production',
12
- PORT: 3000
13
- },
14
10
  max_memory_restart: '512M',
15
11
  error_file: 'logs/web-err.log',
16
12
  out_file: 'logs/web-out.log',
@@ -24,9 +20,6 @@ module.exports = {
24
20
  instances: 1,
25
21
  exec_mode: 'fork',
26
22
  autorestart: true,
27
- env: {
28
- NODE_ENV: 'production'
29
- },
30
23
  max_memory_restart: '512M',
31
24
  error_file: 'logs/cron-err.log',
32
25
  out_file: 'logs/cron-out.log',
@@ -19,7 +19,6 @@ async function runMigrate(): Promise<void> {
19
19
  database: process.env.DB_NAME || 'test-project',
20
20
  dialect: (process.env.DB_DIALECT as 'mysql' | 'postgres' | 'sqlite' | 'mariadb') || 'mysql',
21
21
  charset: process.env.DB_CHARSET || 'utf8mb4',
22
- underscored: true,
23
22
  logging: process.env.DEBUG_DB === 'true' ? (msg: string) => logger.debug(msg) : false
24
23
  })
25
24
 
@@ -19,7 +19,6 @@ async function runSeed(): Promise<void> {
19
19
  database: process.env.DB_NAME || 'test-project',
20
20
  dialect: (process.env.DB_DIALECT as 'mysql' | 'postgres' | 'sqlite' | 'mariadb') || 'mysql',
21
21
  charset: process.env.DB_CHARSET || 'utf8mb4',
22
- underscored: true,
23
22
  logging: process.env.DEBUG_DB === 'true' ? (msg: string) => logger.debug(msg) : false
24
23
  })
25
24
 
@@ -9,7 +9,7 @@ import { checkRequiredEnv } from './utils/config.js'
9
9
  const __filename = fileURLToPath(import.meta.url)
10
10
  const __dirname = path.dirname(__filename)
11
11
 
12
- async function startCronWorker(): Promise<void> {
12
+ async function bootstrap(): Promise<void> {
13
13
  logger.info('[cron-worker] Starting cron worker process...')
14
14
 
15
15
  if (!checkRequiredEnv()) {
@@ -36,10 +36,10 @@ async function startCronWorker(): Promise<void> {
36
36
 
37
37
  const isMainModule = import.meta.url === `file://${process.argv[1]}`
38
38
  if (isMainModule) {
39
- startCronWorker().catch((err) => {
39
+ bootstrap().catch((err) => {
40
40
  logger.error('[cron-worker] Fatal error:', err)
41
41
  process.exit(1)
42
42
  })
43
43
  }
44
44
 
45
- export { startCronWorker }
45
+ export { bootstrap }
@@ -11,7 +11,6 @@ const framework = new CronFramework({
11
11
  database: process.env.DB_NAME || 'test-project',
12
12
  dialect: (process.env.DB_DIALECT as any) || 'mysql',
13
13
  charset: process.env.DB_CHARSET || 'utf8mb4',
14
- underscored: true,
15
14
  logging: process.env.DEBUG_DB === 'true'
16
15
  },
17
16
  redis: {
@@ -10,7 +10,6 @@ const framework = new WebFramework({
10
10
  database: process.env.DB_NAME || 'test-project',
11
11
  dialect: (process.env.DB_DIALECT as any) || 'mysql',
12
12
  charset: process.env.DB_CHARSET || 'utf8mb4',
13
- underscored: true,
14
13
  logging: process.env.DEBUG_DB === 'true'
15
14
  },
16
15
  redis: {