@wwkit/opm 1.0.18 → 1.0.20
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 +26 -23
- package/bin/index.js +8 -0
- package/package.json +2 -2
- package/src/binaries/base.js +5 -10
- package/src/cli/groups/env.js +15 -14
- package/src/cli/groups/nvm.js +1 -1
- package/src/cli/groups/overlay.js +7 -7
- package/src/cli/groups/package.js +62 -20
- package/src/cli/groups/phpenv.js +2 -2
- package/src/cli/groups/ping.js +83 -85
- package/src/cli/groups/proc.js +14 -14
- package/src/cli/groups/version-manager.js +6 -10
- package/src/cli/helpers/args.js +4 -46
- package/src/cli/index.js +24 -2
- package/src/harnesses/base.js +2 -1
- package/src/harnesses/opencode/clear.js +29 -26
- package/src/harnesses/opencode/index.js +1 -2
- package/src/managers/apt.js +16 -0
- package/src/managers/brew.js +20 -1
- package/src/managers/bun.js +23 -0
- package/src/managers/composer.js +11 -0
- package/src/managers/dnf.js +16 -0
- package/src/managers/node.js +1 -1
- package/src/managers/npm.js +12 -0
- package/src/managers/php.js +2 -2
- package/src/managers/pip.js +16 -0
- package/src/managers/runtime.js +1 -1
- package/src/managers/winget.js +12 -0
- package/src/tools/clipboard.js +68 -0
- package/src/tools/ftp/index.js +11 -11
- package/src/tools/git/index.js +30 -13
- package/src/tools/share/index.js +327 -139
- package/src/tools/share/server.js +21 -5
- package/src/tools/webwork/index.js +6 -2
|
@@ -219,6 +219,7 @@ async function handleUpload(req, res, dataDir, baseUrl) {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
const id = parsed.id || genId()
|
|
222
|
+
const existed = fs.existsSync(path.join(dataDir, `${id}.json`))
|
|
222
223
|
const item = {
|
|
223
224
|
id,
|
|
224
225
|
title: parsed.title || defaultTitle(content),
|
|
@@ -226,11 +227,12 @@ async function handleUpload(req, res, dataDir, baseUrl) {
|
|
|
226
227
|
password: parsed.password || DEFAULT_PASSWORD,
|
|
227
228
|
type: parsed.type || 'text',
|
|
228
229
|
filename: parsed.filename || '',
|
|
230
|
+
sourcePath: parsed.sourcePath || '',
|
|
229
231
|
created: new Date().toISOString(),
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
writeShare(dataDir, item)
|
|
233
|
-
sendJson(res, 200, { id, url: `${baseUrl}/share/${id}`, htmlUrl: `${baseUrl}/share/html/${id}
|
|
235
|
+
sendJson(res, 200, { id, url: `${baseUrl}/share/${id}`, htmlUrl: `${baseUrl}/share/html/${id}`, overwritten: existed })
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
function handleList(req, res, dataDir, url) {
|
|
@@ -269,7 +271,7 @@ function handleLatest(req, res, dataDir, pw) {
|
|
|
269
271
|
}
|
|
270
272
|
sendByAccept(
|
|
271
273
|
req, res, 200,
|
|
272
|
-
{ id: item.id, title: item.title, content: item.content, type: item.type || 'text', filename: item.filename || '', created: item.created },
|
|
274
|
+
{ id: item.id, title: item.title, content: item.content, type: item.type || 'text', filename: item.filename || '', sourcePath: item.sourcePath || '', created: item.created },
|
|
273
275
|
renderHtml(item),
|
|
274
276
|
)
|
|
275
277
|
}
|
|
@@ -286,7 +288,7 @@ function handleGet(req, res, dataDir, id, pw) {
|
|
|
286
288
|
}
|
|
287
289
|
sendByAccept(
|
|
288
290
|
req, res, 200,
|
|
289
|
-
{ id: item.id, title: item.title, content: item.content, type: item.type || 'text', filename: item.filename || '', created: item.created },
|
|
291
|
+
{ id: item.id, title: item.title, content: item.content, type: item.type || 'text', filename: item.filename || '', sourcePath: item.sourcePath || '', created: item.created },
|
|
290
292
|
renderHtml(item),
|
|
291
293
|
)
|
|
292
294
|
}
|
|
@@ -300,8 +302,18 @@ function handleDelete(req, res, dataDir, id) {
|
|
|
300
302
|
sendJson(res, 200, { deleted: true, id })
|
|
301
303
|
}
|
|
302
304
|
|
|
305
|
+
/**
|
|
306
|
+
* 某毫秒时间戳所在「天」的本地零点(与 opencode clear 语义一致)
|
|
307
|
+
* @param {number} ts - epoch ms
|
|
308
|
+
* @returns {number}
|
|
309
|
+
*/
|
|
310
|
+
function startOfDayLocal(ts) {
|
|
311
|
+
const d = new Date(ts)
|
|
312
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime()
|
|
313
|
+
}
|
|
314
|
+
|
|
303
315
|
function handleClear(req, res, dataDir, url) {
|
|
304
|
-
const days =
|
|
316
|
+
const days = parseFloat(url.searchParams.get('days') || '0') || 0
|
|
305
317
|
const keep = parseInt(url.searchParams.get('keep') || '0', 10) || 0
|
|
306
318
|
|
|
307
319
|
let files = fs.readdirSync(dataDir)
|
|
@@ -315,7 +327,11 @@ function handleClear(req, res, dataDir, url) {
|
|
|
315
327
|
const now = Date.now()
|
|
316
328
|
|
|
317
329
|
if (days > 0) {
|
|
318
|
-
|
|
330
|
+
// 语义与 opencode clear 统一:保留最近 n 天(含今天)。
|
|
331
|
+
// 整数天对齐本地零点(删除 今天零点-(n-1)天 之前);小数天 = 小时级滚动窗口(0.5 = 12h)
|
|
332
|
+
const cutoff = Number.isInteger(days)
|
|
333
|
+
? startOfDayLocal(now) - (days - 1) * 86400000
|
|
334
|
+
: now - days * 86400000
|
|
319
335
|
for (const f of files) {
|
|
320
336
|
const createdMs = new Date(f.created).getTime()
|
|
321
337
|
if (createdMs < cutoff) {
|
|
@@ -33,7 +33,7 @@ const COMPONENTS = [
|
|
|
33
33
|
|
|
34
34
|
const ACTIONS = {
|
|
35
35
|
version: { desc: 'Show installed version of each component' },
|
|
36
|
-
versions: { desc: 'Show latest available versions (default 10, -n <
|
|
36
|
+
versions: { desc: 'Show latest available versions (default 10, -n <count>)' },
|
|
37
37
|
installed: { desc: 'Show install status (true/false) of each component' },
|
|
38
38
|
install: { desc: 'Mirror check + ensure runtime + write registry env + blues-lib + ww init' },
|
|
39
39
|
uninstall: { desc: 'Uninstall all components in reverse order' },
|
|
@@ -96,7 +96,7 @@ export class WebworkGroup {
|
|
|
96
96
|
|
|
97
97
|
async _versions(parsed) {
|
|
98
98
|
const proxy = this._resolveProxy(parsed)
|
|
99
|
-
const num = parseInt(parsed.flags.n || parsed.flags.num || '10', 10)
|
|
99
|
+
const num = parseInt(parsed.flags.n || parsed.flags.count || parsed.flags.num || '10', 10)
|
|
100
100
|
|
|
101
101
|
const result = {}
|
|
102
102
|
|
|
@@ -274,6 +274,10 @@ export class WebworkGroup {
|
|
|
274
274
|
await this._runBatch('uninstall', reversed, proxy, (key, p) => this._uninstallComponent(key, p))
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
// TODO(P2-6): webwork 自身需要提供真正的 uninstall 命令。
|
|
278
|
+
// 当前 _uninstall 仅卸载 blues-lib(python/node 作为系统依赖跳过);
|
|
279
|
+
// 自身的完整卸载方案(registry env 清理、ww 相关配置移除等)待实现。
|
|
280
|
+
|
|
277
281
|
/**
|
|
278
282
|
* 检查镜像可达性(HEAD 请求,不可达则抛错)
|
|
279
283
|
* 必查:npm / pip(blues-lib 依赖,环境必然可用)
|