@holic512/slothtool 1.0.2 → 1.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 +330 -31
- package/bin/slothtool.js +60 -31
- package/lib/commands/config.js +35 -0
- package/lib/commands/index.js +14 -4
- package/lib/commands/install.js +9 -9
- package/lib/commands/interactive.js +498 -0
- package/lib/commands/list.js +16 -14
- package/lib/commands/run.js +38 -35
- package/lib/commands/uninstall-all.js +78 -0
- package/lib/commands/uninstall.js +9 -9
- package/lib/commands/update-all.js +10 -0
- package/lib/commands/update.js +20 -0
- package/lib/i18n.js +329 -0
- package/lib/official-plugins.json +24 -0
- package/lib/plugin-manager.js +276 -78
- package/lib/registry.js +43 -43
- package/lib/settings.js +85 -0
- package/lib/utils.js +46 -18
- package/package.json +5 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {uninstallPlugin} = require('../plugin-manager');
|
|
2
2
|
|
|
3
3
|
function uninstall(args) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
if (args.length === 0) {
|
|
5
|
+
console.error('Error: Please specify a plugin to uninstall.');
|
|
6
|
+
console.log('Usage: slothtool uninstall <plugin-alias>');
|
|
7
|
+
console.log('Example: slothtool uninstall loc');
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const alias = args[0];
|
|
12
|
+
uninstallPlugin(alias);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
module.exports = uninstall;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const {updatePlugin} = require('../plugin-manager');
|
|
2
|
+
const {t} = require('../i18n');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 更新插件命令
|
|
6
|
+
* @param {string[]} args - 命令参数
|
|
7
|
+
*/
|
|
8
|
+
function update(args) {
|
|
9
|
+
const alias = args[0];
|
|
10
|
+
|
|
11
|
+
if (!alias) {
|
|
12
|
+
console.error(t('specifyPluginToUpdate'));
|
|
13
|
+
console.log('\n' + t('updateUsage'));
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
updatePlugin(alias);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = update;
|
package/lib/i18n.js
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
const settings = require('./settings');
|
|
2
|
+
|
|
3
|
+
const messages = {
|
|
4
|
+
zh: {
|
|
5
|
+
// 通用
|
|
6
|
+
pluginManager: '🐌 SlothTool - 插件管理器',
|
|
7
|
+
|
|
8
|
+
// 帮助信息
|
|
9
|
+
usage: '用法:',
|
|
10
|
+
examples: '示例:',
|
|
11
|
+
commands: {
|
|
12
|
+
install: '安装插件',
|
|
13
|
+
uninstall: '卸载插件',
|
|
14
|
+
update: '更新插件',
|
|
15
|
+
updateAll: '更新所有插件',
|
|
16
|
+
list: '列出已安装的插件',
|
|
17
|
+
run: '运行插件',
|
|
18
|
+
runShorthand: '运行插件(简写)',
|
|
19
|
+
config: '配置语言设置',
|
|
20
|
+
interactive: '交互式模式',
|
|
21
|
+
uninstallAll: '完全卸载 SlothTool(删除所有数据)'
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
// 安装
|
|
25
|
+
installing: '正在安装插件:',
|
|
26
|
+
alreadyInstalled: '插件 "{alias}" 已经安装。',
|
|
27
|
+
uninstallFirst: '如果要重新安装,请先运行 "slothtool uninstall {alias}"。',
|
|
28
|
+
installingTo: '安装到:',
|
|
29
|
+
installSuccess: '\n✓ 插件 "{alias}" 安装成功!',
|
|
30
|
+
installRun: ' 运行:slothtool {alias} --help',
|
|
31
|
+
installFailed: '\n✗ 安装插件 "{packageName}" 失败:',
|
|
32
|
+
|
|
33
|
+
// 卸载
|
|
34
|
+
uninstalling: '正在卸载插件:',
|
|
35
|
+
notInstalled: '插件 "{alias}" 未安装。',
|
|
36
|
+
uninstallSuccess: '✓ 插件 "{alias}" 卸载成功!',
|
|
37
|
+
uninstallFailed: '✗ 卸载插件 "{alias}" 失败:',
|
|
38
|
+
uninstallWillRemove: '\n将删除以下内容:',
|
|
39
|
+
uninstallPluginDir: ' • 插件目录:{dir}',
|
|
40
|
+
uninstallConfigFile: ' • 配置文件:{file}',
|
|
41
|
+
uninstallRegistryEntry: ' • 注册表条目',
|
|
42
|
+
uninstallNoConfig: ' • 无配置文件',
|
|
43
|
+
|
|
44
|
+
// 更新
|
|
45
|
+
updating: '正在更新插件:',
|
|
46
|
+
currentVersion: '当前版本:',
|
|
47
|
+
checkingUpdates: '正在检查更新...',
|
|
48
|
+
alreadyLatest: '✓ 插件 "{alias}" 已经是最新版本 {version}',
|
|
49
|
+
updateSuccess: '✓ 插件 "{alias}" 更新成功!{oldVersion} → {newVersion}',
|
|
50
|
+
updateFailed: '✗ 更新插件 "{alias}" 失败:',
|
|
51
|
+
specifyPluginToUpdate: '错误:请指定要更新的插件。',
|
|
52
|
+
updateUsage: '用法:slothtool update <插件别名>',
|
|
53
|
+
|
|
54
|
+
// 更新所有插件
|
|
55
|
+
updateAll: {
|
|
56
|
+
title: '\n📦 更新所有插件',
|
|
57
|
+
foundPlugins: '找到 {count} 个已安装的插件',
|
|
58
|
+
summary: '\n更新摘要:',
|
|
59
|
+
totalPlugins: ' 总插件数:{count}',
|
|
60
|
+
updated: ' ✓ 已更新:{count}',
|
|
61
|
+
alreadyLatest: ' ✓ 已是最新:{count}',
|
|
62
|
+
failed: ' ✗ 更新失败:{count}'
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
// 完全卸载
|
|
66
|
+
uninstallAll: {
|
|
67
|
+
title: '\n🗑️ 完全卸载 SlothTool',
|
|
68
|
+
warning: '\n⚠️ 警告:此操作将删除所有 SlothTool 数据!',
|
|
69
|
+
willRemove: '\n将删除以下内容:',
|
|
70
|
+
slothtoolDir: ' • SlothTool 目录:{dir}',
|
|
71
|
+
allPlugins: ' • 所有已安装的插件 ({count} 个)',
|
|
72
|
+
allConfigs: ' • 所有插件配置文件',
|
|
73
|
+
registry: ' • 插件注册表',
|
|
74
|
+
settings: ' • 用户设置',
|
|
75
|
+
confirm: '\n确认删除所有数据?',
|
|
76
|
+
confirmPrompt: '输入 "yes" 确认:',
|
|
77
|
+
cancelled: '\n操作已取消。',
|
|
78
|
+
removing: '\n正在删除 SlothTool 数据...',
|
|
79
|
+
success: '\n✓ SlothTool 数据已完全删除!',
|
|
80
|
+
nextStep: '\n如需卸载 SlothTool 命令行工具,请运行:',
|
|
81
|
+
npmUninstall: ' npm uninstall -g @holic512/slothtool',
|
|
82
|
+
failed: '\n✗ 删除失败:',
|
|
83
|
+
noData: '\nSlothTool 数据目录不存在:{dir}',
|
|
84
|
+
alreadyClean: '系统已经是干净的状态。'
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
// 列表
|
|
88
|
+
installedPlugins: '已安装的插件:',
|
|
89
|
+
noPlugins: '未安装任何插件。',
|
|
90
|
+
installExample: '\n安装插件示例:',
|
|
91
|
+
|
|
92
|
+
// 运行
|
|
93
|
+
specifyPlugin: '错误:请指定要运行的插件。',
|
|
94
|
+
pluginNotFound: '错误:未找到插件 "{pluginAlias}"。',
|
|
95
|
+
seeInstalled: '\n运行 "slothtool list" 查看已安装的插件。',
|
|
96
|
+
orInstall: '或使用以下命令安装:slothtool install <插件名>',
|
|
97
|
+
failedToRun: '运行插件 "{pluginAlias}" 失败:',
|
|
98
|
+
|
|
99
|
+
// 配置
|
|
100
|
+
currentLanguage: '当前语言:',
|
|
101
|
+
languageSet: '语言已设置为:',
|
|
102
|
+
invalidLanguage: '无效的语言。请使用 "zh" 或 "en"。',
|
|
103
|
+
configUsage: '用法:slothtool config language <zh|en>',
|
|
104
|
+
|
|
105
|
+
// 交互式模式
|
|
106
|
+
interactive: {
|
|
107
|
+
mainMenu: '请选择操作:',
|
|
108
|
+
installPlugin: '安装插件',
|
|
109
|
+
installOfficial: '安装官方插件',
|
|
110
|
+
installCustom: '安装自定义插件',
|
|
111
|
+
uninstallPlugin: '卸载插件',
|
|
112
|
+
updatePlugin: '更新插件',
|
|
113
|
+
updateAllPlugins: '更新所有插件',
|
|
114
|
+
listPlugins: '查看已安装的插件',
|
|
115
|
+
runPlugin: '运行插件',
|
|
116
|
+
configLanguage: '配置语言',
|
|
117
|
+
uninstallAll: '完全卸载 SlothTool(删除所有数据)',
|
|
118
|
+
exit: '退出',
|
|
119
|
+
|
|
120
|
+
selectPlugin: '选择插件:',
|
|
121
|
+
selectOfficialPlugin: '选择要安装的官方插件:',
|
|
122
|
+
selectPluginToUpdate: '选择要更新的插件:',
|
|
123
|
+
enterPackageName: '请输入插件包名(如 @scope/plugin-name):',
|
|
124
|
+
enterPluginAlias: '请输入插件别名:',
|
|
125
|
+
selectLanguage: '选择语言:',
|
|
126
|
+
|
|
127
|
+
noPluginsToUninstall: '没有已安装的插件可以卸载。',
|
|
128
|
+
noPluginsToUpdate: '没有已安装的插件可以更新。',
|
|
129
|
+
noPluginsToRun: '没有已安装的插件可以运行。',
|
|
130
|
+
|
|
131
|
+
pluginInfo: '插件信息',
|
|
132
|
+
features: '功能特性:',
|
|
133
|
+
author: '作者:',
|
|
134
|
+
version: '版本:',
|
|
135
|
+
|
|
136
|
+
confirmInstall: '确认安装 {name}?',
|
|
137
|
+
confirmUninstall: '确认卸载 {alias}?',
|
|
138
|
+
confirmUpdate: '确认更新 {alias}?',
|
|
139
|
+
confirmUpdateAll: '确认更新所有 {count} 个插件?',
|
|
140
|
+
|
|
141
|
+
runWithArgs: '是否要运行此插件?',
|
|
142
|
+
enterArgs: '请输入运行参数(留空表示无参数):',
|
|
143
|
+
|
|
144
|
+
operationCancelled: '操作已取消。',
|
|
145
|
+
pressEnterToContinue: '\n按回车键继续...'
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
en: {
|
|
150
|
+
// Common
|
|
151
|
+
pluginManager: '🐌 SlothTool - Plugin Manager',
|
|
152
|
+
|
|
153
|
+
// Help
|
|
154
|
+
usage: 'Usage:',
|
|
155
|
+
examples: 'Examples:',
|
|
156
|
+
commands: {
|
|
157
|
+
install: 'Install a plugin',
|
|
158
|
+
uninstall: 'Uninstall a plugin',
|
|
159
|
+
update: 'Update a plugin',
|
|
160
|
+
updateAll: 'Update all plugins',
|
|
161
|
+
list: 'List installed plugins',
|
|
162
|
+
run: 'Run a plugin',
|
|
163
|
+
runShorthand: 'Run a plugin (shorthand)',
|
|
164
|
+
config: 'Configure language settings',
|
|
165
|
+
interactive: 'Interactive mode',
|
|
166
|
+
uninstallAll: 'Complete uninstall (remove all data)'
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
// Install
|
|
170
|
+
installing: 'Installing plugin:',
|
|
171
|
+
alreadyInstalled: 'Plugin "{alias}" is already installed.',
|
|
172
|
+
uninstallFirst: 'Run "slothtool uninstall {alias}" first if you want to reinstall.',
|
|
173
|
+
installingTo: 'Installing to:',
|
|
174
|
+
installSuccess: '\n✓ Plugin "{alias}" installed successfully!',
|
|
175
|
+
installRun: ' Run: slothtool {alias} --help',
|
|
176
|
+
installFailed: '\n✗ Failed to install plugin "{packageName}":',
|
|
177
|
+
|
|
178
|
+
// Uninstall
|
|
179
|
+
uninstalling: 'Uninstalling plugin:',
|
|
180
|
+
notInstalled: 'Plugin "{alias}" is not installed.',
|
|
181
|
+
uninstallSuccess: '✓ Plugin "{alias}" uninstalled successfully!',
|
|
182
|
+
uninstallFailed: '✗ Failed to uninstall plugin "{alias}":',
|
|
183
|
+
uninstallWillRemove: '\nThe following will be removed:',
|
|
184
|
+
uninstallPluginDir: ' • Plugin directory: {dir}',
|
|
185
|
+
uninstallConfigFile: ' • Config file: {file}',
|
|
186
|
+
uninstallRegistryEntry: ' • Registry entry',
|
|
187
|
+
uninstallNoConfig: ' • No config file',
|
|
188
|
+
|
|
189
|
+
// Update
|
|
190
|
+
updating: 'Updating plugin:',
|
|
191
|
+
currentVersion: 'Current version:',
|
|
192
|
+
checkingUpdates: 'Checking for updates...',
|
|
193
|
+
alreadyLatest: '✓ Plugin "{alias}" is already at the latest version {version}',
|
|
194
|
+
updateSuccess: '✓ Plugin "{alias}" updated successfully! {oldVersion} → {newVersion}',
|
|
195
|
+
updateFailed: '✗ Failed to update plugin "{alias}":',
|
|
196
|
+
specifyPluginToUpdate: 'Error: Please specify a plugin to update.',
|
|
197
|
+
updateUsage: 'Usage: slothtool update <plugin-alias>',
|
|
198
|
+
|
|
199
|
+
// Update all plugins
|
|
200
|
+
updateAll: {
|
|
201
|
+
title: '\n📦 Update All Plugins',
|
|
202
|
+
foundPlugins: 'Found {count} installed plugins',
|
|
203
|
+
summary: '\nUpdate Summary:',
|
|
204
|
+
totalPlugins: ' Total plugins: {count}',
|
|
205
|
+
updated: ' ✓ Updated: {count}',
|
|
206
|
+
alreadyLatest: ' ✓ Already latest: {count}',
|
|
207
|
+
failed: ' ✗ Failed: {count}'
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// Complete uninstall
|
|
211
|
+
uninstallAll: {
|
|
212
|
+
title: '\n🗑️ Complete SlothTool Uninstallation',
|
|
213
|
+
warning: '\n⚠️ Warning: This will delete all SlothTool data!',
|
|
214
|
+
willRemove: '\nThe following will be removed:',
|
|
215
|
+
slothtoolDir: ' • SlothTool directory: {dir}',
|
|
216
|
+
allPlugins: ' • All installed plugins ({count} plugins)',
|
|
217
|
+
allConfigs: ' • All plugin configuration files',
|
|
218
|
+
registry: ' • Plugin registry',
|
|
219
|
+
settings: ' • User settings',
|
|
220
|
+
confirm: '\nConfirm deletion of all data?',
|
|
221
|
+
confirmPrompt: 'Type "yes" to confirm: ',
|
|
222
|
+
cancelled: '\nOperation cancelled.',
|
|
223
|
+
removing: '\nRemoving SlothTool data...',
|
|
224
|
+
success: '\n✓ SlothTool data completely removed!',
|
|
225
|
+
nextStep: '\nTo uninstall the SlothTool CLI tool, run:',
|
|
226
|
+
npmUninstall: ' npm uninstall -g @holic512/slothtool',
|
|
227
|
+
failed: '\n✗ Removal failed:',
|
|
228
|
+
noData: '\nSlothTool data directory does not exist: {dir}',
|
|
229
|
+
alreadyClean: 'System is already clean.'
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
// List
|
|
233
|
+
installedPlugins: 'Installed plugins:',
|
|
234
|
+
noPlugins: 'No plugins installed.',
|
|
235
|
+
installExample: '\nInstall a plugin example:',
|
|
236
|
+
|
|
237
|
+
// Run
|
|
238
|
+
specifyPlugin: 'Error: Please specify a plugin to run.',
|
|
239
|
+
pluginNotFound: 'Error: Plugin "{pluginAlias}" not found.',
|
|
240
|
+
seeInstalled: '\nRun "slothtool list" to see installed plugins.',
|
|
241
|
+
orInstall: 'Or install it with: slothtool install <plugin-name>',
|
|
242
|
+
failedToRun: 'Failed to run plugin "{pluginAlias}":',
|
|
243
|
+
|
|
244
|
+
// Config
|
|
245
|
+
currentLanguage: 'Current language:',
|
|
246
|
+
languageSet: 'Language set to:',
|
|
247
|
+
invalidLanguage: 'Invalid language. Please use "zh" or "en".',
|
|
248
|
+
configUsage: 'Usage: slothtool config language <zh|en>',
|
|
249
|
+
|
|
250
|
+
// Interactive mode
|
|
251
|
+
interactive: {
|
|
252
|
+
mainMenu: 'Please select an action:',
|
|
253
|
+
installPlugin: 'Install plugin',
|
|
254
|
+
installOfficial: 'Install official plugin',
|
|
255
|
+
installCustom: 'Install custom plugin',
|
|
256
|
+
uninstallPlugin: 'Uninstall plugin',
|
|
257
|
+
updatePlugin: 'Update plugin',
|
|
258
|
+
updateAllPlugins: 'Update all plugins',
|
|
259
|
+
listPlugins: 'List installed plugins',
|
|
260
|
+
runPlugin: 'Run plugin',
|
|
261
|
+
configLanguage: 'Configure language',
|
|
262
|
+
uninstallAll: 'Complete uninstall (remove all data)',
|
|
263
|
+
exit: 'Exit',
|
|
264
|
+
|
|
265
|
+
selectPlugin: 'Select plugin:',
|
|
266
|
+
selectOfficialPlugin: 'Select official plugin to install:',
|
|
267
|
+
selectPluginToUpdate: 'Select plugin to update:',
|
|
268
|
+
enterPackageName: 'Enter plugin package name (e.g., @scope/plugin-name):',
|
|
269
|
+
enterPluginAlias: 'Enter plugin alias:',
|
|
270
|
+
selectLanguage: 'Select language:',
|
|
271
|
+
|
|
272
|
+
noPluginsToUninstall: 'No plugins installed to uninstall.',
|
|
273
|
+
noPluginsToUpdate: 'No plugins installed to update.',
|
|
274
|
+
noPluginsToRun: 'No plugins installed to run.',
|
|
275
|
+
|
|
276
|
+
pluginInfo: 'Plugin Information',
|
|
277
|
+
features: 'Features:',
|
|
278
|
+
author: 'Author:',
|
|
279
|
+
version: 'Version:',
|
|
280
|
+
|
|
281
|
+
confirmInstall: 'Confirm install {name}?',
|
|
282
|
+
confirmUninstall: 'Confirm uninstall {alias}?',
|
|
283
|
+
confirmUpdate: 'Confirm update {alias}?',
|
|
284
|
+
confirmUpdateAll: 'Confirm update all {count} plugins?',
|
|
285
|
+
|
|
286
|
+
runWithArgs: 'Do you want to run this plugin?',
|
|
287
|
+
enterArgs: 'Enter arguments (leave empty for no arguments):',
|
|
288
|
+
|
|
289
|
+
operationCancelled: 'Operation cancelled.',
|
|
290
|
+
pressEnterToContinue: '\nPress Enter to continue...'
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 获取当前语言的消息
|
|
297
|
+
* @param {string} key - 消息键(支持点号分隔的嵌套键)
|
|
298
|
+
* @param {Object} params - 替换参数
|
|
299
|
+
* @returns {string} 本地化的消息
|
|
300
|
+
*/
|
|
301
|
+
function t(key, params = {}) {
|
|
302
|
+
const lang = settings.getLanguage();
|
|
303
|
+
const langMessages = messages[lang] || messages.zh;
|
|
304
|
+
|
|
305
|
+
// 支持嵌套键,如 'commands.install'
|
|
306
|
+
const keys = key.split('.');
|
|
307
|
+
let message = langMessages;
|
|
308
|
+
|
|
309
|
+
for (const k of keys) {
|
|
310
|
+
message = message[k];
|
|
311
|
+
if (message === undefined) {
|
|
312
|
+
return key; // 如果找不到,返回键本身
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// 替换参数
|
|
317
|
+
if (typeof message === 'string') {
|
|
318
|
+
return message.replace(/\{(\w+)\}/g, (match, param) => {
|
|
319
|
+
return params[param] !== undefined ? params[param] : match;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return message;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
module.exports = {
|
|
327
|
+
t,
|
|
328
|
+
messages
|
|
329
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"officialPlugins": [
|
|
3
|
+
{
|
|
4
|
+
"name": "@holic512/plugin-loc",
|
|
5
|
+
"alias": "loc",
|
|
6
|
+
"description": "统计目录中的代码行数",
|
|
7
|
+
"descriptionEn": "Count lines of code in a directory",
|
|
8
|
+
"version": "latest",
|
|
9
|
+
"author": "holic512",
|
|
10
|
+
"features": [
|
|
11
|
+
"代码行数统计",
|
|
12
|
+
"文件类型过滤",
|
|
13
|
+
"交互式模式",
|
|
14
|
+
"详细模式"
|
|
15
|
+
],
|
|
16
|
+
"featuresEn": [
|
|
17
|
+
"Line counting",
|
|
18
|
+
"File type filtering",
|
|
19
|
+
"Interactive mode",
|
|
20
|
+
"Verbose mode"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|