@wwkit/opm 1.0.16 → 1.0.18
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/cli/groups/package.js +2 -1
- package/src/config.json5 +2 -2
- package/src/managers/base.js +10 -0
- package/src/managers/composer.js +25 -0
- package/src/managers/npm.js +19 -0
- package/src/managers/pip.js +19 -0
- package/src/tools/webwork/index.js +11 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wwkit/opm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
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.23"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"jest": "^29.7.0"
|
|
@@ -102,13 +102,14 @@ export class PackageGroup {
|
|
|
102
102
|
* 打印当前 registry 和 proxy(诊断信息,输出到 stderr)
|
|
103
103
|
* 在涉及网络请求的命令执行前调用,便于连接失败时定位。
|
|
104
104
|
* 输出到 stderr 不污染 JSON stdout。
|
|
105
|
+
* registry 通过 getEffectiveRegistry() 解析,含管理器自身配置回退(opm 配置 → 管理器全局配置 → 官方源)
|
|
105
106
|
* @param {PackageManager} manager
|
|
106
107
|
* @param {string} [proxy]
|
|
107
108
|
* @private
|
|
108
109
|
*/
|
|
109
110
|
async _printEndpoint(manager, proxy) {
|
|
110
111
|
try {
|
|
111
|
-
const { registry } = await manager.
|
|
112
|
+
const { registry } = await manager.getEffectiveRegistry()
|
|
112
113
|
if (registry) {
|
|
113
114
|
console.error(`[opm] registry: ${registry}`)
|
|
114
115
|
}
|
package/src/config.json5
CHANGED
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
registry: {
|
|
31
31
|
official: "https://pypi.org/simple",
|
|
32
32
|
tsinghua: "https://pypi.tuna.tsinghua.edu.cn/simple",
|
|
33
|
-
huawei: "https://
|
|
34
|
-
active: "
|
|
33
|
+
huawei: "https://mirrors.huaweicloud.com/repository/pypi/simple/",
|
|
34
|
+
active: "huawei",
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
|
package/src/managers/base.js
CHANGED
|
@@ -52,6 +52,16 @@ export class PackageManager {
|
|
|
52
52
|
throw new Error(`${this.name}: getRegistry not implemented`)
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* 查询生效的 registry 地址(打印诊断用)
|
|
57
|
+
* 默认委托 getRegistry();子类可覆写以增加管理器自身配置回退。
|
|
58
|
+
* 仅用于 _printEndpoint 打印,不影响实际 install/upgrade 的 registry 传参。
|
|
59
|
+
* @returns {Promise<{ registry: string }>}
|
|
60
|
+
*/
|
|
61
|
+
async getEffectiveRegistry() {
|
|
62
|
+
return this.getRegistry()
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
/**
|
|
56
66
|
* 设置镜像地址
|
|
57
67
|
* @param {string} url - 镜像 URL 或预设名
|
package/src/managers/composer.js
CHANGED
|
@@ -162,6 +162,31 @@ export class ComposerManager extends PackageManager {
|
|
|
162
162
|
return { registry: getActiveRegistry('composer') }
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/**
|
|
166
|
+
* 查询生效的 registry(打印诊断用)
|
|
167
|
+
* 回退链:opm 配置 → composer config --global repo.packagist → 官方源
|
|
168
|
+
* 仅用于 _printEndpoint 打印,不影响实际 install/upgrade 的仓库配置
|
|
169
|
+
* @returns {Promise<{ registry: string }>}
|
|
170
|
+
*/
|
|
171
|
+
async getEffectiveRegistry() {
|
|
172
|
+
let registry = getActiveRegistry('composer')
|
|
173
|
+
if (!registry) {
|
|
174
|
+
try {
|
|
175
|
+
const out = this._exec(['config', '--global', 'repo.packagist'], { allowNonZero: true }).trim()
|
|
176
|
+
try {
|
|
177
|
+
const data = JSON.parse(out)
|
|
178
|
+
registry = data.url || ''
|
|
179
|
+
} catch {
|
|
180
|
+
if (out) registry = out
|
|
181
|
+
}
|
|
182
|
+
} catch {}
|
|
183
|
+
}
|
|
184
|
+
if (!registry) {
|
|
185
|
+
registry = 'https://repo.packagist.org'
|
|
186
|
+
}
|
|
187
|
+
return { registry }
|
|
188
|
+
}
|
|
189
|
+
|
|
165
190
|
async setRegistry(url) {
|
|
166
191
|
const resolved = setActiveRegistry('composer', url)
|
|
167
192
|
return { registry: resolved }
|
package/src/managers/npm.js
CHANGED
|
@@ -96,6 +96,25 @@ export class NpmManager extends PackageManager {
|
|
|
96
96
|
return { registry: getActiveRegistry('npm') }
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* 查询生效的 registry(打印诊断用)
|
|
101
|
+
* 回退链:opm 配置 → npm config get registry → 官方源
|
|
102
|
+
* 仅用于 _printEndpoint 打印,不影响实际 install/upgrade 的 --registry 传参
|
|
103
|
+
* @returns {Promise<{ registry: string }>}
|
|
104
|
+
*/
|
|
105
|
+
async getEffectiveRegistry() {
|
|
106
|
+
let registry = getActiveRegistry('npm')
|
|
107
|
+
if (!registry) {
|
|
108
|
+
try {
|
|
109
|
+
registry = this._exec(['config', 'get', 'registry'], { allowNonZero: true }).trim()
|
|
110
|
+
} catch {}
|
|
111
|
+
}
|
|
112
|
+
if (!registry) {
|
|
113
|
+
registry = 'https://registry.npmjs.org/'
|
|
114
|
+
}
|
|
115
|
+
return { registry }
|
|
116
|
+
}
|
|
117
|
+
|
|
99
118
|
async getVersion() {
|
|
100
119
|
try {
|
|
101
120
|
const version = this._exec(['--version'], { allowNonZero: true }).trim()
|
package/src/managers/pip.js
CHANGED
|
@@ -277,6 +277,25 @@ export class PipManager extends PackageManager {
|
|
|
277
277
|
return { registry }
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
/**
|
|
281
|
+
* 查询生效的 registry(打印诊断用)
|
|
282
|
+
* 回退链:opm 配置 → pip config get global.index-url → 官方源
|
|
283
|
+
* 仅用于 _printEndpoint 打印,不影响实际 install/upgrade 的 --index-url 传参
|
|
284
|
+
* @returns {Promise<{ registry: string }>}
|
|
285
|
+
*/
|
|
286
|
+
async getEffectiveRegistry() {
|
|
287
|
+
let registry = getActiveRegistry('pip')
|
|
288
|
+
if (!registry) {
|
|
289
|
+
try {
|
|
290
|
+
registry = this._exec(['config', 'get', 'global.index-url'], { allowNonZero: true }).trim()
|
|
291
|
+
} catch {}
|
|
292
|
+
}
|
|
293
|
+
if (!registry) {
|
|
294
|
+
registry = 'https://pypi.org/simple'
|
|
295
|
+
}
|
|
296
|
+
return { registry }
|
|
297
|
+
}
|
|
298
|
+
|
|
280
299
|
async getVersion() {
|
|
281
300
|
try {
|
|
282
301
|
const out = this._exec(['--version'], { allowNonZero: true }).trim()
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* install 流程(5 步):
|
|
8
8
|
* 镜像检查(必查 npm/pip + 按需 nvm/node/uv) → ensure node/python → 写 NPM/PIP_REGISTRY/REGISTRY_PROXY → 装 blues-lib → ww init
|
|
9
|
-
* upgrade 流程(
|
|
10
|
-
* 镜像检查(必查 npm/pip) → 写 NPM/PIP_REGISTRY/REGISTRY_PROXY →
|
|
9
|
+
* upgrade 流程(3 步):
|
|
10
|
+
* 镜像检查(必查 npm/pip) → 写 NPM/PIP_REGISTRY/REGISTRY_PROXY → ww upgrade
|
|
11
11
|
*
|
|
12
12
|
* 命令: version / versions / installed / install / uninstall / upgrade / help
|
|
13
13
|
*/
|
|
@@ -37,7 +37,7 @@ const ACTIONS = {
|
|
|
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' },
|
|
40
|
-
upgrade: { desc: '
|
|
40
|
+
upgrade: { desc: 'Mirror check + write registry env + ww upgrade' },
|
|
41
41
|
help: { desc: 'Show this help' },
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -204,26 +204,22 @@ export class WebworkGroup {
|
|
|
204
204
|
async _upgrade(parsed) {
|
|
205
205
|
const proxy = this._resolveProxy(parsed)
|
|
206
206
|
|
|
207
|
-
console.log('\n========== 步骤 1/
|
|
207
|
+
console.log('\n========== 步骤 1/3: 镜像可达检查 ==========')
|
|
208
208
|
await this._checkMirrors(proxy, null)
|
|
209
209
|
|
|
210
|
-
console.log('\n========== 步骤 2/
|
|
210
|
+
console.log('\n========== 步骤 2/3: 写入 NPM_REGISTRY / PIP_REGISTRY / REGISTRY_PROXY ==========')
|
|
211
211
|
this._writeRegistryEnv(proxy)
|
|
212
212
|
|
|
213
|
-
console.log('\n========== 步骤 3/
|
|
214
|
-
|
|
215
|
-
console.log(` ✓ blues-lib 升级完成`)
|
|
213
|
+
console.log('\n========== 步骤 3/3: ww upgrade ==========')
|
|
214
|
+
this._runWwInit('upgrade')
|
|
216
215
|
|
|
217
|
-
|
|
218
|
-
this._runWwInit('init -u')
|
|
219
|
-
|
|
220
|
-
output({ action: 'upgrade', bluesLib: blue, init: 'ww init -u' })
|
|
216
|
+
output({ action: 'upgrade', upgrade: 'ww upgrade' })
|
|
221
217
|
}
|
|
222
218
|
|
|
223
219
|
/**
|
|
224
|
-
* 执行 ww init/init -u
|
|
220
|
+
* 执行 ww init / init -u / upgrade
|
|
225
221
|
* 镜像与代理配置通过 NPM_REGISTRY/PIP_REGISTRY/REGISTRY_PROXY 环境变量传递(见 _writeRegistryEnv)
|
|
226
|
-
* @param {string} action - 'init'
|
|
222
|
+
* @param {string} action - 'init' / 'init -u' / 'upgrade'
|
|
227
223
|
* @private
|
|
228
224
|
*/
|
|
229
225
|
_runWwInit(action) {
|
|
@@ -539,7 +535,7 @@ Examples:
|
|
|
539
535
|
opm webwork installed Show install status of all components
|
|
540
536
|
opm webwork install Mirror check + ensure runtime + registry env + blues-lib + ww init
|
|
541
537
|
opm webwork uninstall Uninstall all components in reverse order
|
|
542
|
-
opm webwork upgrade
|
|
538
|
+
opm webwork upgrade Mirror check + write registry env + ww upgrade
|
|
543
539
|
`)
|
|
544
540
|
}
|
|
545
541
|
}
|