pxnpm 2.0.3 → 2.0.4
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/LICENSE.txt +0 -0
- package/README.md +37 -32
- package/bin/pxnpm +1 -1
- package/lib/config.js +47 -59
- package/lib/parse_argv.js +1 -1
- package/package.json +26 -49
package/LICENSE.txt
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -1,62 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
=======
|
|
1
|
+
# 普迅电力-FE-私库
|
|
3
2
|
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
| | Minimum | Recommended |
|
|
7
|
-
|--------|---------|-------------|
|
|
8
|
-
| NodeJS | 4.0.0 | stable |
|
|
9
|
-
|
|
10
|
-
## Install
|
|
3
|
+
## 使用
|
|
11
4
|
|
|
12
5
|
```bash
|
|
13
|
-
$ npm install pxnpm
|
|
6
|
+
$ npm install -g pxnpm // 外网
|
|
7
|
+
|
|
8
|
+
$ npm install -g pxnpm --registry=http://10.120.20.50:5507 // 内网
|
|
14
9
|
```
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
### 安装依赖
|
|
17
12
|
|
|
18
13
|
```bash
|
|
19
|
-
$
|
|
14
|
+
$ pxnpm install [name]
|
|
20
15
|
```
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
### 注册用户
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
```bash
|
|
20
|
+
$ pxnpm adduser
|
|
21
|
+
```
|
|
25
22
|
|
|
26
|
-
###
|
|
23
|
+
### 登录 / 登出
|
|
27
24
|
|
|
28
25
|
```bash
|
|
29
|
-
$ pxnpm
|
|
26
|
+
$ pxnpm login
|
|
27
|
+
$ pxnpm logout
|
|
28
|
+
|
|
30
29
|
```
|
|
31
30
|
|
|
32
|
-
###
|
|
31
|
+
### 创建新项目
|
|
32
|
+
|
|
33
|
+
package.json中name格式需要符合 `@团队名称/项目名` 原则,例如: `@yfzx/xxx, @zrui/query-table`
|
|
33
34
|
|
|
34
35
|
```bash
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
pxnpm init
|
|
37
|
+
|
|
37
38
|
```
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
### 更新版本号
|
|
41
|
+
|
|
42
|
+
发布前运行,例如`pxnpm version patch`
|
|
40
43
|
|
|
41
44
|
```bash
|
|
42
|
-
|
|
45
|
+
pxnpm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
|
|
43
46
|
|
|
44
|
-
# then alias it
|
|
45
|
-
$ alias mynpm='pxnpm --registry=http://registry.npm.example.com \
|
|
46
|
-
--registryweb=http://npm.example.com \
|
|
47
|
-
--userconfig=$HOME/.mynpmrc'
|
|
48
47
|
```
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
- major: 主版本号
|
|
50
|
+
- premajor: 预备主版本
|
|
51
|
+
- minor: 次版本号
|
|
52
|
+
- preminor: 预备次版本
|
|
53
|
+
- patch: 修订号
|
|
54
|
+
- prepatch: 预备修订版
|
|
55
|
+
- prerelease: 预发布版本
|
|
56
|
+
|
|
57
|
+
### 发布
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
If you don't like symlink mode for `node_modules`, you can change the installer to original npm.
|
|
54
|
-
But you will lose the fastest install speed.
|
|
59
|
+
项目根目录运行
|
|
55
60
|
|
|
56
61
|
```bash
|
|
57
|
-
$ pxnpm
|
|
62
|
+
$ pxnpm publish
|
|
58
63
|
```
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
### 其他命令
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
支持所有其他npm命令
|
package/bin/pxnpm
CHANGED
package/lib/config.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
const debug = require(
|
|
4
|
-
const path = require(
|
|
5
|
-
const fs = require(
|
|
6
|
-
const cp = require(
|
|
7
|
-
const ini = require(
|
|
8
|
-
const ping = require('connection-tester');
|
|
3
|
+
const debug = require("debug")("cnpm:config");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const cp = require("child_process");
|
|
7
|
+
const ini = require("ini");
|
|
9
8
|
|
|
10
9
|
let root;
|
|
11
|
-
if (process.platform ===
|
|
10
|
+
if (process.platform === "win32") {
|
|
12
11
|
root = process.env.USERPROFILE || process.env.APPDATA || process.env.TMP || process.env.TEMP;
|
|
13
12
|
} else {
|
|
14
|
-
root = process.env.HOME || process.env.TMPDIR ||
|
|
13
|
+
root = process.env.HOME || process.env.TMPDIR || "/tmp";
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
let prefix = null;
|
|
18
17
|
try {
|
|
19
|
-
prefix = cp.execSync(
|
|
18
|
+
prefix = cp.execSync("npm config get prefix").toString().trim();
|
|
20
19
|
} catch (err) {
|
|
21
20
|
// ignore it
|
|
22
|
-
debug(
|
|
21
|
+
debug("npm config cli error: %s", err);
|
|
23
22
|
}
|
|
24
23
|
|
|
24
|
+
// =====
|
|
25
|
+
const ping = require("connection-tester");
|
|
25
26
|
const rawArgs = process.argv && process.argv.slice(2);
|
|
26
27
|
const rawAction = rawArgs && rawArgs[0];
|
|
27
28
|
const isPublish = rawAction === "login" || rawAction === "publish";
|
|
@@ -29,49 +30,44 @@ const isPublish = rawAction === "login" || rawAction === "publish";
|
|
|
29
30
|
process.env.outerAddr = JSON.stringify({
|
|
30
31
|
inner: {
|
|
31
32
|
proxy: {
|
|
32
|
-
protocol:
|
|
33
|
-
host:
|
|
34
|
-
port: 8080
|
|
33
|
+
protocol: "http:",
|
|
34
|
+
host: "fe-repo.inner.px.nfjbill.ren",
|
|
35
|
+
port: 8080
|
|
35
36
|
},
|
|
36
37
|
registry: {
|
|
37
|
-
protocol:
|
|
38
|
-
host:
|
|
39
|
-
port: isPublish ? 5508 : 5507
|
|
40
|
-
}
|
|
38
|
+
protocol: "http:",
|
|
39
|
+
host: "fe-repo.inner.px.nfjbill.ren",
|
|
40
|
+
port: isPublish ? 5508 : 5507
|
|
41
|
+
}
|
|
41
42
|
},
|
|
42
43
|
outer: {
|
|
43
44
|
proxy: {
|
|
44
|
-
protocol:
|
|
45
|
-
host:
|
|
46
|
-
port: 80
|
|
45
|
+
protocol: "http:",
|
|
46
|
+
host: "npm.taobao.org",
|
|
47
|
+
port: 80
|
|
47
48
|
},
|
|
48
|
-
// registry: {
|
|
49
|
-
// protocol: 'https:',
|
|
50
|
-
// host: 'pips.xt.nfjbill.ren',
|
|
51
|
-
// port: isPublish ? 8905 : 38083,
|
|
52
|
-
// },
|
|
53
49
|
registry: {
|
|
54
|
-
protocol:
|
|
55
|
-
host:
|
|
56
|
-
port: isPublish ? 8905 : 38082
|
|
57
|
-
}
|
|
50
|
+
protocol: "http:",
|
|
51
|
+
host: "pip.xt.huizhixi.cn",
|
|
52
|
+
port: isPublish ? 8905 : 38082
|
|
53
|
+
}
|
|
58
54
|
},
|
|
59
55
|
io: {
|
|
60
56
|
proxy: {
|
|
61
|
-
protocol:
|
|
62
|
-
host:
|
|
63
|
-
port: 8080
|
|
57
|
+
protocol: "http:",
|
|
58
|
+
host: "r.pxnpm.nfjbill.ren",
|
|
59
|
+
port: 8080
|
|
64
60
|
},
|
|
65
61
|
registry: {
|
|
66
|
-
protocol:
|
|
67
|
-
host:
|
|
68
|
-
port: isPublish ? 5508 : 5507
|
|
69
|
-
}
|
|
62
|
+
protocol: "http:",
|
|
63
|
+
host: "registry.pxnpm.nfjbill.ren",
|
|
64
|
+
port: isPublish ? 5508 : 5507
|
|
65
|
+
}
|
|
70
66
|
},
|
|
71
67
|
// yk3 内部端口
|
|
72
68
|
lp: {
|
|
73
|
-
addr:
|
|
74
|
-
}
|
|
69
|
+
addr: "http://127.0.0.1:38020"
|
|
70
|
+
}
|
|
75
71
|
});
|
|
76
72
|
|
|
77
73
|
const outerAddr = JSON.parse(process.env.outerAddr);
|
|
@@ -79,11 +75,11 @@ const outerAddr = JSON.parse(process.env.outerAddr);
|
|
|
79
75
|
const getAddr = function(type) {
|
|
80
76
|
return {
|
|
81
77
|
proxy: `${outerAddr[type].proxy.protocol}//${outerAddr[type].proxy.host}:${outerAddr[type].proxy.port}`,
|
|
82
|
-
registry: `${outerAddr[type].registry.protocol}//${outerAddr[type].registry.host}:${outerAddr[type].registry.port}
|
|
78
|
+
registry: `${outerAddr[type].registry.protocol}//${outerAddr[type].registry.host}:${outerAddr[type].registry.port}`
|
|
83
79
|
};
|
|
84
80
|
};
|
|
85
81
|
|
|
86
|
-
let addr = getAddr(
|
|
82
|
+
let addr = getAddr("io");
|
|
87
83
|
let pxnpmServer = `http://${outerAddr.io.registry.host}`;
|
|
88
84
|
const timeout = 3000;
|
|
89
85
|
const { success: is } = ping.test(outerAddr.inner.proxy.host, outerAddr.inner.proxy.port, timeout); // registry
|
|
@@ -92,28 +88,29 @@ const { success: os } = ping.test(outerAddr.outer.proxy.host, outerAddr.outer.pr
|
|
|
92
88
|
if (!is && !os) {
|
|
93
89
|
// consola.fatal('没有发现安装源,请调通网络,或重新尝试安装');
|
|
94
90
|
// process.exit(0);
|
|
95
|
-
addr = getAddr(
|
|
91
|
+
addr = getAddr("outer");
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
if (!is && os) {
|
|
99
95
|
// consola.warn('您正在使用协同模式安装,如果安装失败,请多尝试几次,或联系管理员');
|
|
100
|
-
addr = getAddr(
|
|
96
|
+
addr = getAddr("outer");
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
if (is && !os) {
|
|
104
|
-
addr = getAddr(
|
|
100
|
+
addr = getAddr("inner");
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
let proxy = addr.proxy;
|
|
108
104
|
let registry = addr.registry;
|
|
109
105
|
|
|
110
|
-
|
|
106
|
+
// ====
|
|
107
|
+
const userconfig = path.join(root, ".pxnpmrc");
|
|
111
108
|
if (fs.existsSync(userconfig)) {
|
|
112
109
|
let cnpmrc;
|
|
113
110
|
try {
|
|
114
|
-
cnpmrc = ini.parse(fs.readFileSync(userconfig,
|
|
111
|
+
cnpmrc = ini.parse(fs.readFileSync(userconfig, "utf-8"));
|
|
115
112
|
} catch (err) {
|
|
116
|
-
console.warn(
|
|
113
|
+
console.warn("[cnpm:config] [WARN] read %s ini format error", userconfig);
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
if (cnpmrc && cnpmrc.proxy) {
|
|
@@ -125,21 +122,12 @@ process.env.__pxnpm_config_proxy = proxy;
|
|
|
125
122
|
process.env.__pxnpm_config_pxnpmServer = pxnpmServer;
|
|
126
123
|
|
|
127
124
|
module.exports = {
|
|
128
|
-
// cnpmHost: 'https://npm.taobao.org',
|
|
129
|
-
// cnpmRegistry: 'http://cln.grsg.aly.px.nfjbill.xyz:38020/',
|
|
130
|
-
// disturl: 'https://npm.taobao.org/mirrors/node', // download dist tarball for node-gyp
|
|
131
|
-
// iojsDisturl: 'https://npm.taobao.org/mirrors/iojs',
|
|
132
|
-
// cache: path.join(root, '.cnpm'), // cache folder name
|
|
133
|
-
// userconfig,
|
|
134
|
-
// proxy,
|
|
135
|
-
// prefix,
|
|
136
|
-
|
|
137
125
|
cnpmHost: pxnpmServer,
|
|
138
126
|
cnpmRegistry: registry,
|
|
139
127
|
disturl: `${proxy}/mirrors/node`, // download dist tarball for node-gyp
|
|
140
|
-
iojsDisturl: `${proxy}/mirrors/
|
|
141
|
-
cache: path.join(root,
|
|
128
|
+
iojsDisturl: `${proxy}/mirrors/node`,
|
|
129
|
+
cache: path.join(root, ".pxnpm"), // cache folder name
|
|
142
130
|
userconfig,
|
|
143
131
|
proxy: '',
|
|
144
|
-
prefix
|
|
132
|
+
prefix
|
|
145
133
|
};
|
package/lib/parse_argv.js
CHANGED
|
@@ -19,7 +19,7 @@ module.exports = cmd => {
|
|
|
19
19
|
.option('-c, --cache [cache]', 'cache folder, default is ' + config.cache)
|
|
20
20
|
.option('-u, --userconfig [userconfig]', 'userconfig file, default is ' + config.userconfig)
|
|
21
21
|
.option('-y, --yes', 'yes all confirm')
|
|
22
|
-
.option('--ignore-custom-config', 'ignore custom .
|
|
22
|
+
.option('--ignore-custom-config', 'ignore custom .cnpmrc')
|
|
23
23
|
.option('--proxy [proxy]', 'set a http proxy, no default');
|
|
24
24
|
}
|
|
25
25
|
|
package/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"name": "pxnpm",
|
|
3
|
+
"version": "2.0.4",
|
|
4
|
+
"description": "pxnpm use cnpm engine",
|
|
5
|
+
"main": "bin/pxnpm",
|
|
6
|
+
"files": [
|
|
7
|
+
"bin",
|
|
8
|
+
"lib"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "npm run lint -- --fix && npm run test-local",
|
|
12
|
+
"test-local": "egg-bin test",
|
|
13
|
+
"lint": "eslint bin lib test/*.js",
|
|
14
|
+
"ci": "npm run lint && npm run test",
|
|
15
|
+
"autod": "autod"
|
|
6
16
|
},
|
|
17
|
+
"preferGlobal": true,
|
|
7
18
|
"bin": {
|
|
8
19
|
"pxnpm": "bin/pxnpm"
|
|
9
20
|
},
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/cnpm/cnpm/issues"
|
|
12
|
-
},
|
|
13
|
-
"bundleDependencies": false,
|
|
14
|
-
"ci": {
|
|
15
|
-
"version": "6, 8, 10, 12",
|
|
16
|
-
"command": {
|
|
17
|
-
"travis": "ci",
|
|
18
|
-
"appveyor": "ci"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"auto-correct": "^1.0.0",
|
|
23
23
|
"bagpipe": "^0.3.5",
|
|
24
24
|
"colors": "^1.1.2",
|
|
25
25
|
"commander": "~2.10.0",
|
|
26
|
+
"config-chain": "^1.1.13",
|
|
26
27
|
"connection-tester": "^0.2.1",
|
|
27
28
|
"cross-spawn": "~0.2.8",
|
|
28
29
|
"debug": "^2.2.0",
|
|
@@ -30,12 +31,10 @@
|
|
|
30
31
|
"ini": "^1.3.4",
|
|
31
32
|
"npm": "^6.13.4",
|
|
32
33
|
"npm-request": "^1.0.0",
|
|
33
|
-
"open": "^
|
|
34
|
-
"pxnpminstall": "
|
|
34
|
+
"open": "^8.2.1",
|
|
35
|
+
"pxnpminstall": "2.0.0",
|
|
35
36
|
"urllib": "^2.17.0"
|
|
36
37
|
},
|
|
37
|
-
"deprecated": false,
|
|
38
|
-
"description": "cnpm: npm client for cnpmjs.org",
|
|
39
38
|
"devDependencies": {
|
|
40
39
|
"autod": "^2.7.1",
|
|
41
40
|
"coffee": "^3.3.0",
|
|
@@ -47,36 +46,14 @@
|
|
|
47
46
|
"rimraf": "^2.5.4"
|
|
48
47
|
},
|
|
49
48
|
"engines": {
|
|
50
|
-
"node": ">=
|
|
49
|
+
"node": ">= 10.0.0"
|
|
51
50
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"cnpm",
|
|
59
|
-
"npm",
|
|
60
|
-
"npminstall"
|
|
61
|
-
],
|
|
62
|
-
"license": "MIT",
|
|
63
|
-
"main": "bin/cnpm",
|
|
64
|
-
"name": "pxnpm",
|
|
65
|
-
"preferGlobal": true,
|
|
66
|
-
"publishConfig": {
|
|
67
|
-
"tag": "latest"
|
|
68
|
-
},
|
|
69
|
-
"repository": {
|
|
70
|
-
"type": "git",
|
|
71
|
-
"url": "git://github.com/cnpm/cnpm.git"
|
|
72
|
-
},
|
|
73
|
-
"scripts": {
|
|
74
|
-
"autod": "autod",
|
|
75
|
-
"ci": "npm run lint && npm run test",
|
|
76
|
-
"lint": "eslint bin lib test/*.js",
|
|
77
|
-
"test": "npm run lint -- --fix && npm run test-local",
|
|
78
|
-
"test-local": "egg-bin test",
|
|
79
|
-
"pub:beta": "npm version prerelease --preid=beta && npm publish --tag beta"
|
|
51
|
+
"ci": {
|
|
52
|
+
"type": "github",
|
|
53
|
+
"version": "10, 12, 14, 16",
|
|
54
|
+
"os": {
|
|
55
|
+
"github": "linux, windows, macos"
|
|
56
|
+
}
|
|
80
57
|
},
|
|
81
|
-
"
|
|
58
|
+
"license": "MIT"
|
|
82
59
|
}
|