create-jnrs-template-vue 1.0.4 → 1.0.5
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/bin/release.mjs +64 -7
- package/jnrs-template-vue/package.json +4 -4
- package/package.json +1 -1
package/bin/release.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author : TanRui
|
|
3
3
|
* @WeChat : Tan578853789
|
|
4
4
|
* @File : release.mjs
|
|
5
|
-
* @Date : 2025/
|
|
5
|
+
* @Date : 2025/11/12
|
|
6
6
|
* @Desc. : 发布脚本:自动化版本更新、发布及提交
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -40,6 +40,8 @@ function incrementPatchVersion(version) {
|
|
|
40
40
|
|
|
41
41
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
42
42
|
const pkgPath = path.resolve(__dirname, '..', 'package.json')
|
|
43
|
+
// 新增:模板 package.json 路径
|
|
44
|
+
const templatePkgPath = path.resolve(__dirname, '..', 'jnrs-template-vue', 'package.json')
|
|
43
45
|
|
|
44
46
|
try {
|
|
45
47
|
// 读取原始 package.json
|
|
@@ -54,11 +56,60 @@ try {
|
|
|
54
56
|
process.exit(1)
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
//
|
|
59
|
+
// ========== 新增逻辑开始:处理 jnrs-template-vue/package.json ==========
|
|
60
|
+
console.log('📦🔧 正在处理模板包 jnrs-template-vue/package.json...')
|
|
61
|
+
|
|
62
|
+
// 1. 读取模板 package.json
|
|
63
|
+
const templatePkgContent = await fs.readFile(templatePkgPath, 'utf8')
|
|
64
|
+
const templatePkg = JSON.parse(templatePkgContent)
|
|
65
|
+
const originalTemplateVersion = templatePkg.version
|
|
66
|
+
let hasModifiedTemplate = false
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
// 2. 替换所有 "workspace:*" 为 "*"
|
|
70
|
+
const replaceWorkspaceRefs = (obj) => {
|
|
71
|
+
for (const key in obj) {
|
|
72
|
+
if (typeof obj[key] === 'string' && obj[key] === 'workspace:*') {
|
|
73
|
+
obj[key] = '*'
|
|
74
|
+
} else if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
75
|
+
replaceWorkspaceRefs(obj[key])
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 执行替换
|
|
81
|
+
replaceWorkspaceRefs(templatePkg.dependencies || {})
|
|
82
|
+
replaceWorkspaceRefs(templatePkg.devDependencies || {})
|
|
83
|
+
replaceWorkspaceRefs(templatePkg.optionalDependencies || {})
|
|
84
|
+
hasModifiedTemplate = true
|
|
85
|
+
|
|
86
|
+
// 3. version +1
|
|
87
|
+
templatePkg.version = incrementPatchVersion(originalTemplateVersion)
|
|
88
|
+
|
|
89
|
+
// 4. 写入修改后的模板 package.json
|
|
90
|
+
await fs.writeFile(templatePkgPath, JSON.stringify(templatePkg, null, 2) + '\n')
|
|
91
|
+
console.log(`📦 模板包版本已更新至 ${templatePkg.version},workspace:* 已替换为 *`)
|
|
92
|
+
} catch (err) {
|
|
93
|
+
// 回滚模板修改
|
|
94
|
+
console.log('↩️ 正在回滚 jnrs-template-vue/package.json 的修改...')
|
|
95
|
+
try {
|
|
96
|
+
if (hasModifiedTemplate) {
|
|
97
|
+
// 恢复 workspace:* 和原始 version
|
|
98
|
+
const rollbackPkg = JSON.parse(templatePkgContent)
|
|
99
|
+
await fs.writeFile(templatePkgPath, JSON.stringify(rollbackPkg, null, 2) + '\n')
|
|
100
|
+
}
|
|
101
|
+
} catch (e2) {
|
|
102
|
+
console.error('❌ 回滚模板文件时出错:', e2.message)
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`处理模板包失败: ${err.message}`)
|
|
105
|
+
}
|
|
106
|
+
// ========== 新增逻辑结束 ==========
|
|
107
|
+
|
|
108
|
+
// 手动计算新版本(主包)
|
|
58
109
|
const newVersion = incrementPatchVersion(originalVersion)
|
|
59
110
|
console.log(`🆕 新版本: ${newVersion}`)
|
|
60
111
|
|
|
61
|
-
//
|
|
112
|
+
// 写入新版本(主包)
|
|
62
113
|
pkg.version = newVersion
|
|
63
114
|
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
64
115
|
|
|
@@ -76,19 +127,25 @@ try {
|
|
|
76
127
|
try {
|
|
77
128
|
console.log('💾 正在提交版本变更...')
|
|
78
129
|
run('git add package.json')
|
|
130
|
+
run(`git add ${templatePkgPath.replace(/\\/g, '/')}`) // 确保路径兼容 Windows
|
|
79
131
|
const commitMsg = `🅒🅘🅒🅓 ${pkg.name}@${newVersion} 发布成功!👌`
|
|
80
132
|
run(`git commit -m "${commitMsg}"`)
|
|
81
133
|
console.log(`\n✅ 包 ${pkg.name} 发布流程已完成!🎉🎉🎉`)
|
|
82
134
|
} catch (err) {
|
|
83
|
-
console.error('⚠️ 提交失败,但发布已成功。请手动提交 package.json
|
|
135
|
+
console.error('⚠️ 提交失败,但发布已成功。请手动提交 package.json 和模板包:', err.message)
|
|
84
136
|
console.log(`\n✅ 包 ${pkg.name} 发布流程已完成!🎉🎉🎉`)
|
|
85
137
|
}
|
|
86
138
|
} else {
|
|
87
|
-
//
|
|
88
|
-
console.log('↩️
|
|
139
|
+
// 回滚主包
|
|
140
|
+
console.log('↩️ 正在回滚主包 version 修改...')
|
|
89
141
|
pkg.version = originalVersion
|
|
90
142
|
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
91
|
-
|
|
143
|
+
|
|
144
|
+
// 回滚模板包
|
|
145
|
+
console.log('↩️ 正在回滚模板包修改...')
|
|
146
|
+
await fs.writeFile(templatePkgPath, templatePkgContent)
|
|
147
|
+
|
|
148
|
+
console.log('📦 已还原 package.json 和模板包到原始状态')
|
|
92
149
|
process.exit(1)
|
|
93
150
|
}
|
|
94
151
|
} catch (err) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-jnrs-template-vue",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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": "
|
|
25
|
-
"@jnrs/core": "
|
|
26
|
-
"@jnrs/vue-core": "
|
|
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",
|