@wwkit/opm 1.0.11 → 1.0.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 +2 -2
- package/src/tools/webwork/index.js +34 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wwkit/opm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"author": "bluesliu <langcai163@163.com>",
|
|
5
5
|
"description": "Unified CLI — package management (npm/pip/dnf/apt) + config view + opencode maintenance",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"basic-ftp": "^6.2.1",
|
|
36
36
|
"extract-zip": "^2.0.1",
|
|
37
37
|
"systeminformation": "^5.23.0",
|
|
38
|
-
"@wwkit/shared": "1.0.
|
|
38
|
+
"@wwkit/shared": "1.0.17"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -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
|
|
36
|
+
versions: { desc: 'Show latest available versions (default 10, -n <num>)' },
|
|
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,11 +96,13 @@ 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)
|
|
100
|
+
|
|
99
101
|
const result = {}
|
|
100
102
|
|
|
101
|
-
result['python'] = await this.
|
|
102
|
-
result['node'] = await this.
|
|
103
|
-
result['blues-lib'] = await this.
|
|
103
|
+
result['python'] = await this._pythonVersions(proxy, num)
|
|
104
|
+
result['node'] = await this._nodeVersions(proxy, num)
|
|
105
|
+
result['blues-lib'] = await this._pipVersions('blues-lib', proxy, num)
|
|
104
106
|
|
|
105
107
|
output(result)
|
|
106
108
|
}
|
|
@@ -368,14 +370,14 @@ export class WebworkGroup {
|
|
|
368
370
|
return '-'
|
|
369
371
|
}
|
|
370
372
|
|
|
371
|
-
async
|
|
373
|
+
async _pythonVersions(proxy, num) {
|
|
372
374
|
const mgr = new PythonManager()
|
|
373
375
|
try {
|
|
374
376
|
const out = mgr._exec(mgr.cfg.listRemoteCmd, { allowNonZero: true, proxy })
|
|
375
377
|
const versions = mgr._parseRemote(out)
|
|
376
|
-
return versions
|
|
378
|
+
return this._topVersions(versions, num)
|
|
377
379
|
} catch {
|
|
378
|
-
return
|
|
380
|
+
return []
|
|
379
381
|
}
|
|
380
382
|
}
|
|
381
383
|
|
|
@@ -412,15 +414,15 @@ export class WebworkGroup {
|
|
|
412
414
|
return '-'
|
|
413
415
|
}
|
|
414
416
|
|
|
415
|
-
async
|
|
417
|
+
async _nodeVersions(proxy, num) {
|
|
416
418
|
const mgr = new NodeManager()
|
|
417
|
-
if (!isNvmInstalled()) return
|
|
419
|
+
if (!isNvmInstalled()) return []
|
|
418
420
|
try {
|
|
419
421
|
const out = mgr._exec(mgr.cfg.listRemoteCmd, { allowNonZero: true, proxy })
|
|
420
|
-
const versions = mgr._parseRemote(out)
|
|
421
|
-
return
|
|
422
|
+
const versions = mgr._parseRemote(out).map((v) => v.replace(/^v/, ''))
|
|
423
|
+
return this._topVersions(versions, num)
|
|
422
424
|
} catch {
|
|
423
|
-
return
|
|
425
|
+
return []
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
428
|
|
|
@@ -458,10 +460,26 @@ export class WebworkGroup {
|
|
|
458
460
|
return result.version || '-'
|
|
459
461
|
}
|
|
460
462
|
|
|
461
|
-
async
|
|
463
|
+
async _pipVersions(name, proxy, num) {
|
|
462
464
|
const pip = new PipManager()
|
|
463
|
-
|
|
464
|
-
|
|
465
|
+
try {
|
|
466
|
+
const { versions } = await pip.packageVersions(name, { proxy })
|
|
467
|
+
return this._topVersions(versions, num)
|
|
468
|
+
} catch {
|
|
469
|
+
return []
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* 取版本列表前 num 条,降序排列(高版本在上)
|
|
475
|
+
* @param {string[]} versions
|
|
476
|
+
* @param {number} num
|
|
477
|
+
* @returns {string[]}
|
|
478
|
+
*/
|
|
479
|
+
_topVersions(versions, num) {
|
|
480
|
+
return [...versions]
|
|
481
|
+
.sort((a, b) => this._compareVersion(b, a))
|
|
482
|
+
.slice(0, num)
|
|
465
483
|
}
|
|
466
484
|
|
|
467
485
|
async _installPipPackage(name, proxy) {
|
|
@@ -502,7 +520,7 @@ Options:
|
|
|
502
520
|
|
|
503
521
|
Examples:
|
|
504
522
|
opm webwork version Show installed versions of all components
|
|
505
|
-
opm webwork versions Show latest available versions (
|
|
523
|
+
opm webwork versions Show latest available versions (default 10, -n <num>)
|
|
506
524
|
opm webwork installed Show install status of all components
|
|
507
525
|
opm webwork install Mirror check + ensure runtime + registry env + blues-lib + ww init
|
|
508
526
|
opm webwork uninstall Uninstall all components in reverse order
|