juice-email-cli 2.1.12 → 2.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juice-email-cli",
3
- "version": "2.1.12",
3
+ "version": "2.1.13",
4
4
  "description": "CLI tool to generate email-client-compatible HTML with juice (CSS inlining) + Mustache templating + minification",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -69,6 +69,29 @@ function regDelete(key) {
69
69
  return result.status === 0;
70
70
  }
71
71
 
72
+ /**
73
+ * 清理旧版本残留在 HKLM 的注册表项(v1 使用 HKCR/HKLM,需要管理员权限)
74
+ *
75
+ * 旧版本用管理员权限安装时写入 HKLM,升级到 HKCU 版本后这些残留不会被自动清理。
76
+ * Windows 合并 HKLM + HKCU 注册表视图时,HKLM 里的旧菜单名可能覆盖 HKCU 的新菜单名,
77
+ * 导致用户更新后重启电脑仍然看到旧版菜单。
78
+ *
79
+ * 没有管理员权限时 reg delete 静默失败,不影响后续 HKCU 写入。
80
+ */
81
+ function cleanLegacyHklmEntries() {
82
+ if (!isWindows) return;
83
+
84
+ // 清理旧版父菜单(HKLM\Software\Classes\SystemFileAssociations\.*\shell\JuiceEmail)
85
+ for (const root of LEGACY_HKLM_ROOTS) {
86
+ regDelete(`${root}\\${PARENT_KEY_NAME}`);
87
+ }
88
+
89
+ // 清理旧版子命令(HKLM\...\CommandStore\shell\JuiceEmail.*)
90
+ for (const name of Object.values(SUBCMDS)) {
91
+ regDelete(`${LEGACY_HKLM_SUBCMD_SPACE}\\${name}`);
92
+ }
93
+ }
94
+
72
95
  // ─── 菜单结构常量 ─────────────────────────────────────────────────────────────
73
96
 
74
97
  // 使用 HKCU,无需管理员权限
@@ -89,6 +112,17 @@ const YAML_ROOTS = [
89
112
  // CommandStore 子命令注册空间
90
113
  const SUBCMD_SPACE = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell';
91
114
 
115
+ // 旧版本可能残留在 HKLM 的路径(v1 使用 HKCR/HKLM,需要管理员权限)
116
+ // 这些残留不清理会导致 Windows 合并注册表视图时显示旧菜单名
117
+ const LEGACY_HKLM_ROOTS = [
118
+ 'HKEY_LOCAL_MACHINE\\Software\\Classes\\SystemFileAssociations\\.html\\shell',
119
+ 'HKEY_LOCAL_MACHINE\\Software\\Classes\\SystemFileAssociations\\.htm\\shell',
120
+ 'HKEY_LOCAL_MACHINE\\Software\\Classes\\SystemFileAssociations\\.yaml\\shell',
121
+ 'HKEY_LOCAL_MACHINE\\Software\\Classes\\SystemFileAssociations\\.yml\\shell',
122
+ ];
123
+
124
+ const LEGACY_HKLM_SUBCMD_SPACE = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell';
125
+
92
126
  // 子命令名称常量(register / unregister 共用,避免硬编码不一致)
93
127
  const SUBCMDS = {
94
128
  generate: 'JuiceEmail.Generate',
@@ -131,6 +165,9 @@ async function registerContextMenu() {
131
165
 
132
166
  console.log(chalk.cyan('\n 注册 juice 右键菜单(当前用户,无需管理员权限)...\n'));
133
167
 
168
+ // 先清理旧版本可能残留在 HKLM 的注册表项,避免新旧菜单名冲突
169
+ cleanLegacyHklmEntries();
170
+
134
171
  const nodePath = getNodePath();
135
172
  const scriptPath = getJuiceScript();
136
173
  const iconPath = getIconPath();
@@ -216,21 +253,24 @@ async function unregisterContextMenu() {
216
253
 
217
254
  let removed = 0;
218
255
 
219
- // 清理 HTML 父菜单
256
+ // 清理 HKCU 父菜单
220
257
  for (const root of HTML_ROOTS) {
221
258
  if (regDelete(`${root}\\${PARENT_KEY_NAME}`)) removed++;
222
259
  }
223
260
 
224
- // 清理 YAML 父菜单
261
+ // 清理 HKCU YAML 父菜单
225
262
  for (const root of YAML_ROOTS) {
226
263
  if (regDelete(`${root}\\${PARENT_KEY_NAME}`)) removed++;
227
264
  }
228
265
 
229
- // 清理子命令
266
+ // 清理 HKCU 子命令
230
267
  for (const name of Object.values(SUBCMDS)) {
231
268
  regDelete(`${SUBCMD_SPACE}\\${name}`);
232
269
  }
233
270
 
271
+ // 同时清理旧版本可能残留在 HKLM 的注册表项
272
+ cleanLegacyHklmEntries();
273
+
234
274
  if (removed > 0) {
235
275
  console.log(chalk.green(` ✔ 已移除 ${removed} 个右键菜单项。\n`));
236
276
  } else {