create-jnrs-template-vue 1.0.4 → 1.0.6

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 ADDED
@@ -0,0 +1,42 @@
1
+ # JNRS 项目模板
2
+
3
+ #### 介绍
4
+
5
+ JNRS 项目初始化模板
6
+
7
+ #### 软件架构
8
+
9
+ TypeScript、Vue3、Vite、Pinia、Element Plus
10
+
11
+ #### 安装教程
12
+
13
+ ```shell
14
+ pnpm create jnrs-template-vue@latest jnrs-vue-app
15
+ ```
16
+
17
+ #### 项目结构
18
+
19
+ ```md
20
+ src/
21
+ ├── assets/ # 静态资源(图片、字体)
22
+ ├── components/ # 通用组件(可复用)
23
+ ├── composables/ # 自定义 Hook(useFetch, useModal)
24
+ ├── layouts/ # 布局组件(如 Header、Sidebar)
25
+ ├── pages/ # 页面级组件(对应路由)
26
+ ├── router/ # 路由配置
27
+ ├── stores/ # Pinia 状态管理
28
+ ├── utils/ # 工具函数(request, date, etc)
29
+ ├── views/ # 视图层(可选,与 pages 类似)
30
+ ├── App.vue # 根组件
31
+ └── main.ts # 应用入口(createApp、use(router))
32
+ ```
33
+
34
+ #### 使用说明
35
+
36
+ my-project 是你的新项目名称
37
+
38
+ ```shell
39
+ pnpm create jnrs-template-vue@latest jnrs-vue-app
40
+ cd jnrs-vue-app
41
+ pnpm dev
42
+ ```
package/bin/create.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { fileURLToPath } from 'url'
2
2
  import { dirname, join, relative } from 'path'
3
- import { promises as fs, existsSync } from 'fs' // ✅ 同时导入 promises 和 existsSync
3
+ import { promises as fs, existsSync } from 'fs'
4
4
  import { execSync, spawnSync } from 'child_process'
5
5
  import minimist from 'minimist'
6
6
  import prompts from 'prompts'
@@ -68,13 +68,13 @@ async function main() {
68
68
  const { name } = await prompts({
69
69
  type: 'text',
70
70
  name: 'name',
71
- message: 'Project name:',
72
- initial: 'my-vue-app',
71
+ message: '项目名称:',
72
+ initial: 'jnrs-vue-app',
73
73
  validate: (input) => {
74
- if (!input) return 'Project name is required.'
75
- if (existsSync(input)) return 'Directory already exists.' // ✅ 使用 existsSync
74
+ if (!input) return '请输入项目名称!'
75
+ if (existsSync(input)) return '目录已存在!'
76
76
  if (!isValidPackageName(input)) {
77
- return 'Invalid package name. Use lowercase, hyphens, and no special characters.'
77
+ return '包名称无效!请使用小写字母、连字符,不要使用特殊字符'
78
78
  }
79
79
  return true
80
80
  }
@@ -84,13 +84,13 @@ async function main() {
84
84
  } else {
85
85
  // 非交互模式:校验包名和目录
86
86
  if (!isValidPackageName(targetDir)) {
87
- console.error('❌ Invalid project name:', targetDir)
88
- console.error(' Package name must be valid (lowercase, no spaces, etc.)')
87
+ console.error('❌ 无效的项目名称:', targetDir)
88
+ console.error(' 包名称必须有效(小写、无空格等)')
89
89
  process.exit(1)
90
90
  }
91
91
  if (existsSync(join(process.cwd(), targetDir))) {
92
92
  // ✅ 同步检查
93
- console.error(`❌ Directory "${targetDir}" already exists.`)
93
+ console.error(`❌ 目录 "${targetDir}" 已存在!`)
94
94
  process.exit(1)
95
95
  }
96
96
  }
@@ -112,8 +112,8 @@ async function main() {
112
112
 
113
113
  // 安装依赖
114
114
  const packageManager = detectPackageManager()
115
- console.log(`\n📦 Detected package manager: ${packageManager}`)
116
- console.log(`Installing dependencies with ${packageManager}...\n`)
115
+ console.log(`\n📦 检测到包管理器: ${packageManager}`)
116
+ console.log(`准备通过 ${packageManager} 安装依赖项中...\n`)
117
117
 
118
118
  const [cmd, ...args] = getInstallCommand(packageManager)
119
119
  try {
@@ -124,7 +124,7 @@ async function main() {
124
124
  })
125
125
  } catch (e) {
126
126
  console.error(
127
- `\n⚠️ Failed to install dependencies. Run manually:\n cd ${relative(process.cwd(), root)} && ${cmd} ${args.join(' ')}`
127
+ `\n⚠️ 安装依赖项失败。请手动运行:\n cd ${relative(process.cwd(), root)} && ${cmd} ${args.join(' ')}`
128
128
  )
129
129
  process.exit(1)
130
130
  }
@@ -133,13 +133,13 @@ async function main() {
133
133
  const relativePath = relative(process.cwd(), root)
134
134
  const devCmd = getRunCommand(packageManager, 'dev')
135
135
 
136
- console.log(`\n✅ Done!`)
136
+ console.log(`\n✅ 项目创建成功! 👌`)
137
137
  console.log(`\n👉 cd ${relativePath}`)
138
138
  console.log(` ${devCmd}\n`)
139
139
  }
140
140
 
141
141
  main().catch((err) => {
142
142
  console.error(`\n🚨 Error: ${err.message}`)
143
- console.trace(err) // 可选:开发时显示堆栈
143
+ console.trace(err)
144
144
  process.exit(1)
145
145
  })
@@ -1,17 +1,17 @@
1
- # JNRS 框架通用包
1
+ # JNRS 项目模板
2
2
 
3
3
  #### 介绍
4
4
 
5
- 适配 system-general-framework-ts 系列所有项目
5
+ JNRS 项目初始化模板
6
6
 
7
7
  #### 软件架构
8
8
 
9
- Vue3、TypeScript、Vite、Pinia、Element Plus
9
+ TypeScript、Vue3、Vite、Pinia、Element Plus
10
10
 
11
11
  #### 安装教程
12
12
 
13
13
  ```shell
14
- pnpm add @jnrs/vue-core
14
+ pnpm create jnrs-template-vue@latest jnrs-vue-app
15
15
  ```
16
16
 
17
17
  #### 项目结构
@@ -36,5 +36,7 @@ src/
36
36
  my-project 是你的新项目名称
37
37
 
38
38
  ```shell
39
- pnpm create jnrs-template@latest my-project
39
+ pnpm create jnrs-template-vue@latest jnrs-vue-app
40
+ cd jnrs-vue-app
41
+ pnpm dev
40
42
  ```
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jnrs-template-vue",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "As the name suggests.",
5
5
  "author": "Talia-Tan",
6
6
  "private": true,
@@ -21,9 +21,9 @@
21
21
  "format": "prettier --write src/"
22
22
  },
23
23
  "dependencies": {
24
- "@jnrs/shared": "workspace:*",
25
- "@jnrs/core": "workspace:*",
26
- "@jnrs/vue-core": "workspace:*",
24
+ "@jnrs/shared": "*",
25
+ "@jnrs/core": "*",
26
+ "@jnrs/vue-core": "*",
27
27
  "@element-plus/icons-vue": "^2.3.2",
28
28
  "async-validator": "^4.2.5",
29
29
  "element-plus": "^2.11.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jnrs-template-vue",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "A Vue3 + Vite + TS project template with monorepo packages for JNRS.",
5
5
  "keywords": [
6
6
  "vue",
@@ -33,6 +33,6 @@
33
33
  "fs-extra": "^11.2.0"
34
34
  },
35
35
  "scripts": {
36
- "release": "node ./bin/release.mjs"
36
+ "release": "node ./scripts/release.mjs"
37
37
  }
38
38
  }
package/bin/release.mjs DELETED
@@ -1,97 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : release.mjs
5
- * @Date : 2025/10/12
6
- * @Desc. : 发布脚本:自动化版本更新、发布及提交
7
- */
8
-
9
- import { execSync } from 'node:child_process'
10
- import fs from 'node:fs/promises'
11
- import path from 'node:path'
12
- import { fileURLToPath } from 'node:url'
13
-
14
- function run(cmd, options = {}) {
15
- console.log(`> ${cmd}`)
16
- try {
17
- const result = execSync(cmd, {
18
- stdio: ['pipe', 'pipe', 'pipe'], // 关键:捕获 stderr
19
- ...options
20
- })
21
- return result.toString().trim()
22
- } catch (e) {
23
- // 提取 stderr 和 stdout
24
- const stderr = e.stderr?.toString().trim() || ''
25
- const stdout = e.stdout?.toString().trim() || ''
26
- const fullError = [stderr, stdout].filter(Boolean).join('\n') || e.message
27
- throw new Error(fullError)
28
- }
29
- }
30
-
31
- function hasUncommittedChanges() {
32
- const status = run('git status --porcelain --ignore-submodules=all .')
33
- return status.length > 0
34
- }
35
-
36
- function incrementPatchVersion(version) {
37
- const [major, minor, patch] = version.split('.').map(Number)
38
- return `${major}.${minor}.${patch + 1}`
39
- }
40
-
41
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
42
- const pkgPath = path.resolve(__dirname, '..', 'package.json')
43
-
44
- try {
45
- // 读取原始 package.json
46
- const pkgContent = await fs.readFile(pkgPath, 'utf8')
47
- const pkg = JSON.parse(pkgContent)
48
- const originalVersion = pkg.version
49
-
50
- console.log(`📦 当前包: ${pkg.name}@${originalVersion}`)
51
-
52
- if (hasUncommittedChanges()) {
53
- console.error('❌ 有未提交的更改,请先提交或暂存更改!')
54
- process.exit(1)
55
- }
56
-
57
- // 手动计算新版本
58
- const newVersion = incrementPatchVersion(originalVersion)
59
- console.log(`🆕 新版本: ${newVersion}`)
60
-
61
- // 写入新版本
62
- pkg.version = newVersion
63
- await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
64
-
65
- // 尝试发布
66
- let published = false
67
- try {
68
- console.log('🚀 正在发布到 npm...')
69
- run('pnpm publish --no-git-checks')
70
- published = true
71
- } catch (err) {
72
- console.error('❌ npm 发布失败:', err.message)
73
- }
74
-
75
- if (published) {
76
- try {
77
- console.log('💾 正在提交版本变更...')
78
- run('git add package.json')
79
- const commitMsg = `🅒🅘🅒🅓 ${pkg.name}@${newVersion} 发布成功!👌`
80
- run(`git commit -m "${commitMsg}"`)
81
- console.log(`\n✅ 包 ${pkg.name} 发布流程已完成!🎉🎉🎉`)
82
- } catch (err) {
83
- console.error('⚠️ 提交失败,但发布已成功。请手动提交 package.json:', err.message)
84
- console.log(`\n✅ 包 ${pkg.name} 发布流程已完成!🎉🎉🎉`)
85
- }
86
- } else {
87
- // 回滚
88
- console.log('↩️ 正在回滚 version 修改...')
89
- pkg.version = originalVersion
90
- await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
91
- console.log('✅ 已还原 package.json 到原始版本')
92
- process.exit(1)
93
- }
94
- } catch (err) {
95
- console.error('💥 脚本执行出错:', err.message)
96
- process.exit(1)
97
- }