@xx-in/tools 0.0.1 → 0.0.2
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 +28 -0
- package/dist/cli.js +23 -9
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -14,6 +14,34 @@ npm install -g @xx-in/tools
|
|
|
14
14
|
xx upgrade
|
|
15
15
|
# 或
|
|
16
16
|
npm install -g @xx-in/tools@latest
|
|
17
|
+
|
|
18
|
+
# 如果当前环境配置了其他 npm 源,可强制走官方源
|
|
19
|
+
xx upgrade -r
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 临时指定 npm 官方源
|
|
23
|
+
|
|
24
|
+
如果你本机默认配置了其他 npm 源,安装、升级或发布时可以临时指定官方源,而不影响全局配置:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
# 安装
|
|
28
|
+
npm --registry=https://registry.npmjs.org/ install -g @xx-in/tools
|
|
29
|
+
|
|
30
|
+
# 升级
|
|
31
|
+
npm --registry=https://registry.npmjs.org/ install -g @xx-in/tools@latest
|
|
32
|
+
|
|
33
|
+
# 发布
|
|
34
|
+
npm --registry=https://registry.npmjs.org/ publish --access public
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
也可以直接使用项目内置脚本:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
# 常规发布
|
|
41
|
+
npm run publish:npm
|
|
42
|
+
|
|
43
|
+
# 强制走 npm 官方源发布
|
|
44
|
+
npm run publish:npm:registry
|
|
17
45
|
```
|
|
18
46
|
|
|
19
47
|
## 功能列表
|
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import process4 from "process";
|
|
|
7
7
|
// package.json
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "@xx-in/tools",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.2",
|
|
11
11
|
description: "A command-line tool to run in any system",
|
|
12
12
|
license: "MIT",
|
|
13
13
|
type: "module",
|
|
@@ -20,7 +20,9 @@ var package_default = {
|
|
|
20
20
|
scripts: {
|
|
21
21
|
build: "tsup",
|
|
22
22
|
dev: "tsup --watch",
|
|
23
|
-
prepublishOnly: "npm run build"
|
|
23
|
+
prepublishOnly: "npm run build",
|
|
24
|
+
"publish:npm": "npm publish --access public",
|
|
25
|
+
"publish:npm:registry": "npm --registry=https://registry.npmjs.org/ publish --access public"
|
|
24
26
|
},
|
|
25
27
|
engines: {
|
|
26
28
|
node: ">=18"
|
|
@@ -165,6 +167,10 @@ _xx() {
|
|
|
165
167
|
'-d[\u6307\u5B9A\u89E3\u538B\u5230\u7684\u76EE\u6807\u76EE\u5F55\u8DEF\u5F84]:directory:_files -/' \\
|
|
166
168
|
'*:Zip File:_files -g "*.zip"'
|
|
167
169
|
;;
|
|
170
|
+
upgrade)
|
|
171
|
+
_arguments \\
|
|
172
|
+
'-r[\u5F3A\u5236\u4F7F\u7528 npm \u5B98\u65B9\u6E90 https://registry.npmjs.org/]'
|
|
173
|
+
;;
|
|
168
174
|
zip)
|
|
169
175
|
_arguments \\
|
|
170
176
|
'*:Target Path:_files'
|
|
@@ -247,6 +253,11 @@ _xx_completion() {
|
|
|
247
253
|
COMPREPLY=( $(compgen -W "\${sub_opts}" -- \${cur}) )
|
|
248
254
|
return 0
|
|
249
255
|
;;
|
|
256
|
+
upgrade)
|
|
257
|
+
local sub_opts="-r --registry"
|
|
258
|
+
COMPREPLY=( $(compgen -W "\${sub_opts}" -- \${cur}) )
|
|
259
|
+
return 0
|
|
260
|
+
;;
|
|
250
261
|
help)
|
|
251
262
|
local sub_opts="completion copy create format ip list move open park proxy remove search translate uninstall unzip upgrade zip"
|
|
252
263
|
COMPREPLY=( $(compgen -W "\${sub_opts}" -- \${cur}) )
|
|
@@ -301,6 +312,7 @@ $xx_completer = {
|
|
|
301
312
|
"park" = @("-d", "-o", "-g")
|
|
302
313
|
"proxy" = @("on", "off")
|
|
303
314
|
"unzip" = @("-d")
|
|
315
|
+
"upgrade" = @("-r", "--registry")
|
|
304
316
|
"translate" = @("-t")
|
|
305
317
|
"help" = @("completion", "copy", "create", "format", "ip", "list", "move", "open", "park", "proxy", "remove", "search", "translate", "uninstall", "unzip", "upgrade", "zip")
|
|
306
318
|
}
|
|
@@ -2482,15 +2494,17 @@ function registerUnzipCommand(program2) {
|
|
|
2482
2494
|
// commands/upgrade.ts
|
|
2483
2495
|
import pc17 from "picocolors";
|
|
2484
2496
|
function registerUpgradeCommand(program2) {
|
|
2485
|
-
program2.command("upgrade").description("\u68C0\u67E5\u5E76\u81EA\u52A8\u66F4\u65B0 xx \u547D\u4EE4\u884C\u5DE5\u5177\u81F3\u6700\u65B0\u7248\u672C").action(async () => {
|
|
2497
|
+
program2.command("upgrade").description("\u68C0\u67E5\u5E76\u81EA\u52A8\u66F4\u65B0 xx \u547D\u4EE4\u884C\u5DE5\u5177\u81F3\u6700\u65B0\u7248\u672C").option("-r, --registry", "\u5F3A\u5236\u4F7F\u7528 npm \u5B98\u65B9\u6E90 https://registry.npmjs.org/").action(async (options) => {
|
|
2498
|
+
const args = ["install", "-g"];
|
|
2499
|
+
if (options.registry) {
|
|
2500
|
+
args.push("--registry=https://registry.npmjs.org/");
|
|
2501
|
+
}
|
|
2502
|
+
args.push("@xx-in/tools@latest");
|
|
2486
2503
|
console.log(pc17.cyan("\u{1F916} \u6B63\u5728\u4E3A\u60A8\u68C0\u67E5\u5E76\u66F4\u65B0 xx \u547D\u4EE4\u884C\u5DE5\u5177..."));
|
|
2487
|
-
console.log(pc17.dim(
|
|
2504
|
+
console.log(pc17.dim(`\u6267\u884C\u547D\u4EE4: npm ${args.join(" ")}
|
|
2505
|
+
`));
|
|
2488
2506
|
try {
|
|
2489
|
-
const status = await spawnCommand("npm",
|
|
2490
|
-
"install",
|
|
2491
|
-
"-g",
|
|
2492
|
-
"@xx-in/tools@latest"
|
|
2493
|
-
]);
|
|
2507
|
+
const status = await spawnCommand("npm", args);
|
|
2494
2508
|
if (status.success) {
|
|
2495
2509
|
console.log(
|
|
2496
2510
|
pc17.cyan("\n\u{1F916} \u6B63\u5728\u4E3A\u60A8\u5F3A\u5236\u8986\u76D6\u5E76\u5237\u65B0\u7EC8\u7AEF\u81EA\u52A8\u8865\u5168\u811A\u672C...")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xx-in/tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "A command-line tool to run in any system",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsup",
|
|
15
15
|
"dev": "tsup --watch",
|
|
16
|
-
"prepublishOnly": "npm run build"
|
|
16
|
+
"prepublishOnly": "npm run build",
|
|
17
|
+
"publish:npm": "npm publish --access public",
|
|
18
|
+
"publish:npm:registry": "npm --registry=https://registry.npmjs.org/ publish --access public"
|
|
17
19
|
},
|
|
18
20
|
"engines": {
|
|
19
21
|
"node": ">=18"
|