@fanwang/pack-util 1.0.9 → 1.1.0
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 +11 -38
- package/bin/index.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
# pack-util
|
|
2
|
-
打包工具,可以在公网上将项目 ./node_modules 中安装的包遍历后打包,并放在 ./node_modules_pack 文件夹中,然后批量上传到 nexus 搭建的 npm 私服上。
|
|
3
|
-
|
|
4
|
-
Pack all installed package in ./node_modules, and publish to Nexus hosted Registry.
|
|
2
|
+
`npm package` 打包工具,可以在公网上将项目 ./node_modules 中安装的包遍历后打包,并放在 ./node_modules_pack 文件夹中,然后批量上传到 nexus 搭建的 npm 私服上。(Pack all installed package in ./node_modules, and publish to Nexus hosted Registry.)
|
|
5
3
|
|
|
6
4
|
## !!注意:在私网上安装 npm 包需要忽略对 peer 依赖!!
|
|
7
|
-
|
|
8
5
|
```
|
|
9
6
|
npm install --save --legacy-peer-deps
|
|
10
7
|
```
|
|
11
|
-
|
|
12
8
|
## 安装 (Install)
|
|
13
|
-
|
|
14
9
|
```sh
|
|
15
10
|
npm install -g @fanwang/pack-util
|
|
16
11
|
```
|
|
17
|
-
|
|
18
12
|
## 使用说明 (Usage: pack-util [ pack | upload ])
|
|
19
13
|
|
|
20
14
|
如果使用控制台命令的时候提示电脑禁止运行脚本,用管理员身份运行 cmd 或者 vscode 等然后在命令行输入:
|
|
@@ -23,31 +17,22 @@ npm install -g @fanwang/pack-util
|
|
|
23
17
|
Set-ExecutionPolicy RemoteSigned
|
|
24
18
|
```
|
|
25
19
|
|
|
26
|
-
### 将所有 ./node_modules 中安装的包打包至 ./node_modules_pack
|
|
27
|
-
|
|
20
|
+
### 将所有 ./node_modules 中安装的包打包至 ./node_modules_pack(Pack all installed package in ./node_modules)
|
|
21
|
+
**推荐现将 npm 仓库设为阿里仓库,这样打包更快:`npm config set registry https://registry.npmmirror.com`**
|
|
28
22
|
|
|
29
23
|
```sh
|
|
30
24
|
cd your_project
|
|
31
25
|
pack-util pack
|
|
32
26
|
```
|
|
33
27
|
|
|
34
|
-
### 批量上传到 nexus 搭建的 npm
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
1. 将 ./node_modules_pack 文件夹和你的项目一起拷贝至内网,然后执行上传。
|
|
38
|
-
|
|
39
|
-
Copy ./node_modules_pack along with your project.
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
### 批量上传到 nexus 搭建的 npm 私服上(Upload all packed packages in ./node_modules_pack)
|
|
29
|
+
1. 将 ./node_modules_pack 文件夹和你的项目一起拷贝至内网,然后执行上传。(Copy ./node_modules_pack along with your project.)
|
|
42
30
|
```sh
|
|
43
31
|
cd your_project
|
|
44
32
|
pack-util upload
|
|
45
33
|
```
|
|
46
34
|
|
|
47
|
-
2.
|
|
48
|
-
|
|
49
|
-
Input some params
|
|
50
|
-
|
|
35
|
+
2. 输入参数(Input some params)
|
|
51
36
|
```
|
|
52
37
|
? Please input your Nexus url host (eg: http://xx.xx.xx.xx:xxxx): http://xx.xx.xx.xx:8081/
|
|
53
38
|
? Please input your Nexus npm repository (eg: localNpm): localNpm
|
|
@@ -55,38 +40,26 @@ Input some params
|
|
|
55
40
|
? password: [hidden]
|
|
56
41
|
```
|
|
57
42
|
|
|
58
|
-
3.
|
|
59
|
-
|
|
60
|
-
If there is upload error, delete other packages within the ./node_modules_pack, and upload again.
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
3. 如果出现上传失败,删除其他成功上传的包,然后重新执行上传。(If there is upload error, delete other packages within the ./node_modules_pack, and upload again.)
|
|
63
44
|
|
|
64
45
|
### ~~批量发布至 Nexus 搭建的 npm 私服上,Publish all packed packages in ./node_modules_pack~~
|
|
65
46
|
!!以下方式已弃用:
|
|
66
47
|
原因是 npm publish 会将解析打包的 package.json 中 publishConfig, 有的公共包如果设置了 { "registry": "https://registry.npmjs.org/" } , 会导致publish失败。[目前没法 Hack npm 的这种行为](https://stackoverflow.com/questions/66914753/override-registry-mentioned-in-publishconfig-of-package-json-through-command-lin)。
|
|
67
48
|
|
|
68
|
-
将 ./node_modules_pack 文件夹和你的项目一起拷贝至内网,然后执行发布。
|
|
69
|
-
|
|
70
|
-
copy node_modules_pack along with your project.
|
|
71
|
-
|
|
72
|
-
1. change registry
|
|
49
|
+
将 ./node_modules_pack 文件夹和你的项目一起拷贝至内网,然后执行发布。(copy node_modules_pack along with your project.)
|
|
73
50
|
|
|
51
|
+
1. change registry
|
|
74
52
|
```sh
|
|
75
53
|
npm config set registry http://xx.xx.xx.xx:xxxx/repository/xxxx/
|
|
76
54
|
```
|
|
77
|
-
2. adduser
|
|
78
|
-
|
|
55
|
+
2. adduser
|
|
79
56
|
```sh
|
|
80
57
|
npm adduser -registry http://xx.xx.xx.xx:xxxx/repository/xxxx/
|
|
81
58
|
```
|
|
82
|
-
|
|
83
|
-
3. batch publish
|
|
84
|
-
|
|
59
|
+
3. batch publish
|
|
85
60
|
```sh
|
|
86
61
|
cd your_project
|
|
87
62
|
pack-util publish
|
|
88
63
|
```
|
|
89
|
-
|
|
90
|
-
|
|
91
64
|
## TODO
|
|
92
65
|
- [x] 实现打包和上传显示进度
|
package/bin/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const program = new Command()
|
|
|
11
11
|
program
|
|
12
12
|
.name('pack-util')
|
|
13
13
|
.description('Pack all installed package in ./node_modules, and publish to Nexus self-hosted Registry.')
|
|
14
|
-
.version('1.0
|
|
14
|
+
.version('1.1.0')
|
|
15
15
|
|
|
16
16
|
const getPackageNames = async () => {
|
|
17
17
|
const { stdout } = await execa('npm', ['list', '--all'])
|
|
@@ -34,10 +34,10 @@ var index = 0
|
|
|
34
34
|
const packPackage = async (packageName) => {
|
|
35
35
|
const { stdout } = await execa('npm', ['pack', packageName, '--pack-destination=./node_modules_pack'])
|
|
36
36
|
index++
|
|
37
|
-
console.log(`${index}: ${stdout}`)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
// console.log(`${index}: ${stdout}`)
|
|
38
|
+
process.stdout.clearLine()
|
|
39
|
+
process.stdout.cursorTo(0)
|
|
40
|
+
process.stdout.write(`${index}: ${stdout}`) // 在同一行打印处理进度
|
|
41
41
|
return stdout
|
|
42
42
|
}
|
|
43
43
|
|