@wwkit/opm 1.0.20 → 1.0.22

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": "@wwkit/opm",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
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.25"
38
+ "@wwkit/shared": "1.0.27"
39
39
  },
40
40
  "devDependencies": {
41
41
  "jest": "^29.7.0"
@@ -55,7 +55,7 @@ export class WebworkGroup {
55
55
  return
56
56
  }
57
57
 
58
- const parsed = parseFlags(rest)
58
+ const parsed = parseFlags(rest, { booleans: ['f', 'force'] })
59
59
 
60
60
  switch (action) {
61
61
  case 'version':
@@ -162,6 +162,7 @@ export class WebworkGroup {
162
162
 
163
163
  async _install(parsed) {
164
164
  const proxy = this._resolveProxy(parsed)
165
+ const force = !!(parsed.flags.force || parsed.flags.f)
165
166
 
166
167
  console.log('\n========== 步骤 1/5: 镜像可达检查 ==========')
167
168
  const env = await this._checkEnv()
@@ -188,9 +189,11 @@ export class WebworkGroup {
188
189
  this._writeRegistryEnv(proxy)
189
190
 
190
191
  console.log('\n========== 步骤 4/5: 安装 blues-lib ==========')
191
- const blue = await this._installPipPackage('blues-lib', proxy)
192
+ const blue = await this._installPipPackage('blues-lib', proxy, force)
192
193
  if (blue.action === 'skipped') {
193
194
  console.log(` → blues-lib ${blue.version} 已安装,跳过`)
195
+ } else if (blue.action === 'upgraded') {
196
+ console.log(` ✓ blues-lib 已升级到最新(提供 ww 命令)`)
194
197
  } else {
195
198
  console.log(` ✓ blues-lib 安装完成(提供 ww 命令)`)
196
199
  }
@@ -458,9 +461,17 @@ export class WebworkGroup {
458
461
  }
459
462
  const mgr = new NodeManager()
460
463
  mgr._execInherit(mgr.cfg.installCmd(defaultVersion), { proxy })
461
- mgr._execInherit(mgr.cfg.useCmd(defaultVersion), { proxy })
462
- mgr._execInherit(mgr.cfg.defaultCmd(defaultVersion), { proxy })
463
- return { action: 'installed', version: defaultVersion }
464
+ // nvm-windows 不支持主版本别名(如 `nvm use 24`),需要完整版本号。
465
+ // install 后查询 nvm current 获取实际激活的完整版本(如 24.21.0)。
466
+ let useVersion = defaultVersion
467
+ try {
468
+ const currentOut = mgr._exec(mgr.cfg.currentCmd, { allowNonZero: true, proxy })
469
+ const parsed = mgr.cfg.parseCurrent(currentOut)
470
+ if (parsed) useVersion = parsed.replace(/^v/, '')
471
+ } catch {}
472
+ mgr._execInherit(mgr.cfg.useCmd(useVersion), { proxy })
473
+ mgr._execInherit(mgr.cfg.defaultCmd(useVersion), { proxy })
474
+ return { action: 'installed', version: useVersion }
464
475
  }
465
476
 
466
477
  async _pipInstalled(name) {
@@ -497,10 +508,13 @@ export class WebworkGroup {
497
508
  .slice(0, num)
498
509
  }
499
510
 
500
- async _installPipPackage(name, proxy) {
511
+ async _installPipPackage(name, proxy, force = false) {
501
512
  const pip = new PipManager()
502
513
  const existing = await pip.isInstalled(name, { global: true })
503
514
  if (existing.installed) {
515
+ if (force) {
516
+ return pip.upgrade(name, { global: true, proxy })
517
+ }
504
518
  return { action: 'skipped', reason: `${name} ${existing.version} already installed`, version: existing.version }
505
519
  }
506
520
  return pip.install(name, null, { global: true, proxy })
@@ -531,6 +545,7 @@ ${actionLines}
531
545
 
532
546
  Options:
533
547
  -p, --proxy <url> Proxy for install/upgrade/versions (overrides config proxy.active)
548
+ -f, --force Force upgrade blues-lib even if already installed (install only)
534
549
  -h, --help Show this help
535
550
 
536
551
  Examples:
@@ -538,6 +553,7 @@ Examples:
538
553
  opm webwork versions Show latest available versions (default 10, -n <num>)
539
554
  opm webwork installed Show install status of all components
540
555
  opm webwork install Mirror check + ensure runtime + registry env + blues-lib + ww init
556
+ opm webwork install -f Same as install, but force upgrade blues-lib to latest
541
557
  opm webwork uninstall Uninstall all components in reverse order
542
558
  opm webwork upgrade Mirror check + write registry env + ww upgrade
543
559
  `)