pxnpm 2.0.7 → 3.0.0-1
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 → LICENSE} +6 -6
- package/bin/cnpm-check +29 -46
- package/bin/cnpm-doc +16 -14
- package/bin/cnpm-sync +53 -60
- package/bin/cnpm-update +26 -0
- package/bin/pxnpm +7 -7
- package/lib/config.js +22 -25
- package/lib/help.js +7 -7
- package/lib/origin_npm.js +3 -3
- package/package.json +46 -32
- package/bin/cnpm +0 -27
package/{LICENSE.txt → LICENSE}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (
|
|
3
|
+
Copyright (c) 2013-present pxnpm and other contributors.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/cnpm-check
CHANGED
|
@@ -2,54 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var names = Object.keys(pkg.dependencies);
|
|
18
|
-
var next = function () {
|
|
19
|
-
var name = names.shift();
|
|
20
|
-
if (!name) {
|
|
21
|
-
return process.exit(0);
|
|
22
|
-
}
|
|
23
|
-
var url = config.cnpmRegistry + '/' + name + '/latest';
|
|
24
|
-
urllib.request(url, {headers: {'user-agent': 'cnpm-check'}},
|
|
25
|
-
function (err, result) {
|
|
26
|
-
var errmsg = '';
|
|
27
|
-
if (err) {
|
|
28
|
-
errmsg = err.message;
|
|
29
|
-
} else {
|
|
30
|
-
try {
|
|
31
|
-
result = JSON.parse(result);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
errmsg = 'parse origin package info error. ' + err.message;
|
|
34
|
-
result = {};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (errmsg) {
|
|
38
|
-
console.log('[' + name.red + '] check version error: ' + err.message.red);
|
|
39
|
-
return next();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var localVersion = String(pkg.dependencies[name] || '*');
|
|
43
|
-
var localVersionCheck = localVersion.replace(/^[^\.\d]+/g, '');
|
|
44
|
-
var remoteVersion = result && result.version || 'unknow';
|
|
45
|
-
if (remoteVersion !== localVersionCheck) {
|
|
46
|
-
console.log('[' + name.yellow + '] new version: ' + remoteVersion.green + ', local version: ' + localVersion.yellow);
|
|
47
|
-
}
|
|
48
|
-
next();
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const urllib = require('urllib');
|
|
7
|
+
const config = require('../lib/config');
|
|
8
|
+
|
|
9
|
+
const pkg = require(path.join(process.cwd(), 'package.json'));
|
|
10
|
+
|
|
11
|
+
async function checkOnePackage(name) {
|
|
12
|
+
const url = config.cnpmRegistry + '/' + name + '/latest';
|
|
13
|
+
try {
|
|
14
|
+
const response = await urllib.request(url, {
|
|
15
|
+
headers: { 'user-agent': 'pxnpm-check' },
|
|
16
|
+
dataType: 'json',
|
|
49
17
|
});
|
|
50
|
-
|
|
18
|
+
const result = response.data;
|
|
19
|
+
const localVersion = String(pkg.dependencies[name] || '*');
|
|
20
|
+
const localVersionCheck = localVersion.replace(/^[^\.\d]+/g, '');
|
|
21
|
+
const remoteVersion = result && result.version || 'unknow';
|
|
22
|
+
if (remoteVersion !== localVersionCheck) {
|
|
23
|
+
console.log('[' + name + '] new version: ' + remoteVersion + ', local version: ' + localVersion);
|
|
24
|
+
}
|
|
25
|
+
} catch (err) {
|
|
26
|
+
console.error(err);
|
|
27
|
+
console.log('[' + name + '] check version error: ' + err.message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
51
30
|
|
|
52
|
-
|
|
31
|
+
async function checkUpdate() {
|
|
32
|
+
const names = Object.keys(pkg.dependencies);
|
|
33
|
+
for (const name of names) {
|
|
34
|
+
await checkOnePackage(name);
|
|
35
|
+
}
|
|
53
36
|
}
|
|
54
37
|
|
|
55
38
|
checkUpdate();
|
package/bin/cnpm-doc
CHANGED
|
@@ -2,43 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const request = require('npm-request');
|
|
6
|
+
const giturl = require('giturl');
|
|
7
|
+
const utils = require('../lib/utils');
|
|
8
|
+
const argv = require('../lib/parse_argv')('doc');
|
|
9
|
+
const pkgName = argv.args[1];
|
|
10
|
+
const docurl = argv.registryweb + '/package/' + pkgName;
|
|
11
11
|
|
|
12
12
|
if (!pkgName) {
|
|
13
|
-
|
|
13
|
+
argv.help();
|
|
14
|
+
process.exit(0);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
if (!argv.git) {
|
|
17
|
-
|
|
18
|
+
utils.openurl(docurl);
|
|
19
|
+
process.exit(0);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
console.log('getting "%s" package info...', pkgName);
|
|
21
23
|
request({
|
|
22
24
|
method: 'GET',
|
|
23
|
-
path: pkgName + '/latest'
|
|
25
|
+
path: pkgName + '/latest',
|
|
24
26
|
}, {
|
|
25
|
-
registry: argv.registry
|
|
26
|
-
}, function
|
|
27
|
+
registry: argv.registry,
|
|
28
|
+
}, function(err, info) {
|
|
27
29
|
if (err) {
|
|
28
30
|
console.error(err);
|
|
29
31
|
process.exit(-1);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
if (!info.name) {
|
|
33
|
-
console.log('"%s" package not exists',
|
|
35
|
+
console.log('"%s" package not exists', pkgName);
|
|
34
36
|
process.exit(0);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
const repository = info.repository;
|
|
38
40
|
if (!repository || !repository.url) {
|
|
39
41
|
return utils.openurl(docurl);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
const url = giturl.parse(repository.url) || docurl;
|
|
43
45
|
utils.openurl(url);
|
|
44
46
|
});
|
package/bin/cnpm-sync
CHANGED
|
@@ -2,38 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var argv = require('../lib/parse_argv')('sync');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const Bagpipe = require('bagpipe');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const querystring = require('querystring');
|
|
9
|
+
const request = require('npm-request');
|
|
10
|
+
const argv = require('../lib/parse_argv')('sync');
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const args = argv.args;
|
|
13
|
+
const registrys = [ argv.registry ];
|
|
14
|
+
const registrywebs = {};
|
|
16
15
|
registrywebs[argv.registry] = argv.registryweb;
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const nodeps = !argv.deps;
|
|
18
|
+
const publish = !!argv.syncPublish;
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const names = args.slice(1);
|
|
21
|
+
let packageName;
|
|
22
|
+
let dependencies = [];
|
|
23
|
+
let isPrivate = false;
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
const packagePath = path.join(process.cwd(), 'package.json');
|
|
27
26
|
if (!names.length && fs.existsSync(packagePath)) {
|
|
28
27
|
try {
|
|
29
28
|
console.log('Parse `package.json` file now...');
|
|
30
|
-
|
|
29
|
+
const pkg = require(packagePath);
|
|
31
30
|
packageName = pkg.name;
|
|
32
|
-
|
|
33
|
-
for (
|
|
31
|
+
const dependenciesMap = {};
|
|
32
|
+
for (const key in (pkg.dependencies || {})) {
|
|
34
33
|
dependenciesMap[key] = pkg.dependencies[key];
|
|
35
34
|
}
|
|
36
|
-
for (
|
|
35
|
+
for (const key in (pkg.devDependencies || {})) {
|
|
37
36
|
dependenciesMap[key] = pkg.devDependencies[key];
|
|
38
37
|
}
|
|
39
38
|
dependencies = Object.keys(dependenciesMap);
|
|
@@ -49,34 +48,28 @@ if (names && names.length) {
|
|
|
49
48
|
} else if (packageName) {
|
|
50
49
|
syncByPackage(packageName);
|
|
51
50
|
} else {
|
|
52
|
-
console.log(
|
|
53
|
-
Options
|
|
54
|
-
--publish sync as publish
|
|
55
|
-
--no-deps do not sync dependencies and devDependencies
|
|
51
|
+
console.log(`Usage: $ cnpm sync [moduleName1 moduleName2 ...]
|
|
52
|
+
Options:
|
|
53
|
+
--publish sync as publish
|
|
54
|
+
--no-deps do not sync dependencies and devDependencies`);
|
|
56
55
|
process.exit(1);
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
// var syncInfo = {};
|
|
60
|
-
// var NPM_OPTIONS = {
|
|
61
|
-
// registry: registry,
|
|
62
|
-
// configFile: argv.userconfig
|
|
63
|
-
// };
|
|
64
|
-
|
|
65
58
|
function showlog(registry, syncInfo, done) {
|
|
66
59
|
request({
|
|
67
60
|
method: 'GET',
|
|
68
|
-
path: syncInfo.logurl + '?offset=' + syncInfo.lastLines
|
|
61
|
+
path: syncInfo.logurl + '?offset=' + syncInfo.lastLines,
|
|
69
62
|
}, {
|
|
70
|
-
registry
|
|
71
|
-
configFile: argv.userconfig
|
|
72
|
-
}, function
|
|
63
|
+
registry,
|
|
64
|
+
configFile: argv.userconfig,
|
|
65
|
+
}, function(err, info) {
|
|
73
66
|
if (err) {
|
|
74
67
|
return done(err);
|
|
75
68
|
}
|
|
76
69
|
if (!info || !info.log) {
|
|
77
70
|
return setTimeout(showlog.bind(null, registry, syncInfo, done), 2000);
|
|
78
71
|
}
|
|
79
|
-
|
|
72
|
+
const log = info.log.trim();
|
|
80
73
|
console.log(log);
|
|
81
74
|
syncInfo.lastLines += log.split('\n').length;
|
|
82
75
|
if (log.indexOf('[done] Sync ' + syncInfo.name) >= 0) {
|
|
@@ -88,20 +81,20 @@ function showlog(registry, syncInfo, done) {
|
|
|
88
81
|
}
|
|
89
82
|
|
|
90
83
|
function sync(registry, name, callback) {
|
|
91
|
-
|
|
84
|
+
let url = name + '/sync?';
|
|
92
85
|
url += querystring.stringify({
|
|
93
|
-
publish
|
|
94
|
-
nodeps
|
|
86
|
+
publish,
|
|
87
|
+
nodeps,
|
|
95
88
|
});
|
|
96
89
|
console.log('sync %s, PUT %s/%s', name, registry, url);
|
|
97
90
|
request({
|
|
98
91
|
method: 'PUT',
|
|
99
92
|
path: url,
|
|
100
|
-
data: {}
|
|
93
|
+
data: {},
|
|
101
94
|
}, {
|
|
102
|
-
registry
|
|
103
|
-
configFile: argv.userconfig
|
|
104
|
-
}, function
|
|
95
|
+
registry,
|
|
96
|
+
configFile: argv.userconfig,
|
|
97
|
+
}, function(err, result, data, res) {
|
|
105
98
|
if (err) {
|
|
106
99
|
return callback(err);
|
|
107
100
|
}
|
|
@@ -112,38 +105,38 @@ function sync(registry, name, callback) {
|
|
|
112
105
|
return callback(null, {
|
|
113
106
|
ok: false,
|
|
114
107
|
statusCode: res.statusCode,
|
|
115
|
-
result
|
|
116
|
-
data
|
|
108
|
+
result,
|
|
109
|
+
data,
|
|
117
110
|
});
|
|
118
111
|
}
|
|
119
|
-
|
|
120
|
-
name
|
|
112
|
+
const syncInfo = {
|
|
113
|
+
name,
|
|
121
114
|
lastLines: 0,
|
|
122
|
-
logurl: name + '/sync/log/' + result.logId
|
|
115
|
+
logurl: name + '/sync/log/' + result.logId,
|
|
123
116
|
};
|
|
124
|
-
console.log('logurl: %s/sync/%s#logid=%
|
|
125
|
-
showlog(registry, syncInfo, function
|
|
117
|
+
console.log('logurl: %s/sync/%s#logid=%s', registrywebs[registry], name, result.logId);
|
|
118
|
+
showlog(registry, syncInfo, function(err) {
|
|
126
119
|
if (err) {
|
|
127
120
|
return callback(err);
|
|
128
121
|
}
|
|
129
|
-
callback(null, {ok: true});
|
|
122
|
+
callback(null, { ok: true });
|
|
130
123
|
});
|
|
131
124
|
});
|
|
132
125
|
}
|
|
133
126
|
|
|
134
127
|
function syncByNames(names) {
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
const queue = new Bagpipe(1);
|
|
129
|
+
let remain = names.length * registrys.length;
|
|
137
130
|
if (!names) {
|
|
138
131
|
console.log('Can not find any packages to sync.');
|
|
139
132
|
process.exit(0);
|
|
140
133
|
}
|
|
141
134
|
console.log('Start sync %j.', names);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
registrys.forEach(function
|
|
145
|
-
names.forEach(function
|
|
146
|
-
queue.push(sync, registry, name, function
|
|
135
|
+
const fail = {};
|
|
136
|
+
const success = {};
|
|
137
|
+
registrys.forEach(function(registry) {
|
|
138
|
+
names.forEach(function(name) {
|
|
139
|
+
queue.push(sync, registry, name, function(err, data) {
|
|
147
140
|
remain--;
|
|
148
141
|
if (err) {
|
|
149
142
|
console.error(err.message);
|
|
@@ -154,7 +147,7 @@ function syncByNames(names) {
|
|
|
154
147
|
success[name] = true;
|
|
155
148
|
}
|
|
156
149
|
if (!remain) {
|
|
157
|
-
for (
|
|
150
|
+
for (const n in success) {
|
|
158
151
|
if (fail[n]) {
|
|
159
152
|
delete success[n];
|
|
160
153
|
}
|
|
@@ -178,5 +171,5 @@ function syncByPackage(packageName) {
|
|
|
178
171
|
return syncByNames(dependencies);
|
|
179
172
|
}
|
|
180
173
|
|
|
181
|
-
syncByNames([packageName]);
|
|
174
|
+
syncByNames([ packageName ]);
|
|
182
175
|
}
|
package/bin/cnpm-update
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const debug = require('debug')('pxnpm:update');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { fork } = require('child_process');
|
|
8
|
+
const { rmSync } = require('fs');
|
|
9
|
+
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const cnpmCli = path.join(__dirname, 'pxnpm');
|
|
12
|
+
const options = {
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const nodeModulesDir = path.join(cwd, 'node_modules');
|
|
17
|
+
console.log('[pxnpm:update] Removing %s', nodeModulesDir);
|
|
18
|
+
rmSync(nodeModulesDir, { force: true, recursive: true });
|
|
19
|
+
|
|
20
|
+
console.log('[pxnpm:update] Running "pxnpm install" on %s', cwd);
|
|
21
|
+
fork(cnpmCli, [ 'install' ], options)
|
|
22
|
+
.on('exit', code => {
|
|
23
|
+
debug('exit %s', code);
|
|
24
|
+
process.exit(code);
|
|
25
|
+
});
|
|
26
|
+
|
package/bin/pxnpm
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
|
-
const pkg = require('../package.json');
|
|
5
4
|
|
|
6
|
-
const debug = require('debug')('
|
|
5
|
+
const debug = require('debug')('pxnpm');
|
|
7
6
|
const argv = require('../lib/parse_argv')();
|
|
8
7
|
|
|
9
8
|
const action = argv.args[0];
|
|
@@ -15,13 +14,14 @@ const extendsMethd = {
|
|
|
15
14
|
sync: 1,
|
|
16
15
|
user: 1,
|
|
17
16
|
search: 1,
|
|
17
|
+
update: 1,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
debug('
|
|
20
|
+
debug('pxnpm %s', action);
|
|
21
21
|
|
|
22
22
|
if (extendsMethd[action]) {
|
|
23
|
-
|
|
23
|
+
require('./pxnpm-' + action);
|
|
24
|
+
} else {
|
|
25
|
+
debug('origin npm with origin registry: $ npm %s', action);
|
|
26
|
+
require('../lib/origin_npm');
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
debug('origin npm with origin registry: $ npm %s', action);
|
|
27
|
-
require('../lib/origin_npm');
|
package/lib/config.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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(
|
|
3
|
+
const debug = require('debug')('pxnpm:config');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const cp = require('child_process');
|
|
7
|
+
const ini = require('ini');
|
|
8
8
|
|
|
9
9
|
try {
|
|
10
10
|
fs.writeFileSync("/tmp/.pxnpm_install_status", "0", {
|
|
@@ -14,21 +14,21 @@ try {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
let root;
|
|
17
|
-
if (process.platform ===
|
|
17
|
+
if (process.platform === 'win32') {
|
|
18
18
|
root = process.env.USERPROFILE || process.env.APPDATA || process.env.TMP || process.env.TEMP;
|
|
19
19
|
} else {
|
|
20
|
-
root = process.env.HOME || process.env.TMPDIR ||
|
|
20
|
+
root = process.env.HOME || process.env.TMPDIR || '/tmp';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// let proxyC = '';
|
|
24
23
|
let prefix = null;
|
|
25
24
|
try {
|
|
26
|
-
prefix = cp.execSync(
|
|
25
|
+
prefix = cp.execSync('npm config get prefix', {timeout: 2000}).toString().trim();
|
|
27
26
|
} catch (err) {
|
|
28
27
|
// ignore it
|
|
29
|
-
// debug(
|
|
28
|
+
// debug('npm config cli error: %s', err);
|
|
30
29
|
}
|
|
31
30
|
|
|
31
|
+
|
|
32
32
|
// =====
|
|
33
33
|
const ping = require("connection-tester");
|
|
34
34
|
const rawArgs = process.argv && process.argv.slice(2);
|
|
@@ -93,6 +93,8 @@ const timeout = 3000;
|
|
|
93
93
|
const { success: is } = ping.test(outerAddr.inner.proxy.host, outerAddr.inner.proxy.port, timeout); // registry
|
|
94
94
|
const { success: os } = ping.test(outerAddr.outer.proxy.host, outerAddr.outer.proxy.port, timeout); // proxy
|
|
95
95
|
|
|
96
|
+
let proxy = '';
|
|
97
|
+
|
|
96
98
|
if (!is && !os) {
|
|
97
99
|
// consola.fatal('没有发现安装源,请调通网络,或重新尝试安装');
|
|
98
100
|
// process.exit(0);
|
|
@@ -106,20 +108,18 @@ if (!is && os) {
|
|
|
106
108
|
|
|
107
109
|
if (is && !os) {
|
|
108
110
|
addr = getAddr("inner");
|
|
109
|
-
|
|
111
|
+
proxy = addr.proxy;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
let proxy = addr.proxy;
|
|
113
114
|
let registry = addr.registry;
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
const userconfig = path.join(root, ".pxnpmrc");
|
|
116
|
+
const userconfig = path.join(root, '.pxnpmrc');
|
|
117
117
|
if (fs.existsSync(userconfig)) {
|
|
118
118
|
let cnpmrc;
|
|
119
119
|
try {
|
|
120
|
-
cnpmrc = ini.parse(fs.readFileSync(userconfig,
|
|
120
|
+
cnpmrc = ini.parse(fs.readFileSync(userconfig, 'utf-8'));
|
|
121
121
|
} catch (err) {
|
|
122
|
-
console.warn(
|
|
122
|
+
console.warn('[pxnpm:config] [WARN] read %s ini format error', userconfig);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
if (cnpmrc && cnpmrc.proxy) {
|
|
@@ -127,16 +127,13 @@ if (fs.existsSync(userconfig)) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
process.env.__pxnpm_config_proxy = proxy;
|
|
131
|
-
process.env.__pxnpm_config_pxnpmServer = pxnpmServer;
|
|
132
|
-
|
|
133
130
|
module.exports = {
|
|
134
131
|
cnpmHost: pxnpmServer,
|
|
135
132
|
cnpmRegistry: registry,
|
|
136
|
-
disturl:
|
|
137
|
-
iojsDisturl:
|
|
138
|
-
cache: path.join(root,
|
|
133
|
+
disturl: 'https://npmmirror.com/mirrors/node', // download dist tarball for node-gyp
|
|
134
|
+
iojsDisturl: 'https://npmmirror.com/mirrors/iojs',
|
|
135
|
+
cache: path.join(root, '.pxnpm'), // cache folder name
|
|
139
136
|
userconfig,
|
|
140
|
-
proxy
|
|
141
|
-
prefix
|
|
137
|
+
proxy,
|
|
138
|
+
prefix,
|
|
142
139
|
};
|
package/lib/help.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
const config = require('./config');
|
|
4
4
|
|
|
5
5
|
module.exports = function outputHelp(argv) {
|
|
6
|
-
const helpInfo = 'Usage:
|
|
7
|
-
'Help: http://cnpmjs.org/help/
|
|
6
|
+
const helpInfo = 'Usage: pxnpm [option] <command>\n' +
|
|
7
|
+
'Help: http://cnpmjs.org/help/pxnpm\n\n' +
|
|
8
8
|
' Extend command\n' +
|
|
9
|
-
' web open
|
|
10
|
-
' check [ingoreupdate] check project dependencies, add ignoreupdate will not check modules\' latest version(ex.:
|
|
11
|
-
' doc [moduleName] open document page (ex.:
|
|
12
|
-
' sync [moduleName] sync module from source npm (ex.:
|
|
13
|
-
' user [username] open user profile page (ex.:
|
|
9
|
+
' web open pxnpm web (ex.: pxnpm web)\n' +
|
|
10
|
+
' check [ingoreupdate] check project dependencies, add ignoreupdate will not check modules\' latest version(ex.: pxnpm check, pxnpm check -i)\n' +
|
|
11
|
+
' doc [moduleName] open document page (ex.: pxnpm doc egg)\n' +
|
|
12
|
+
' sync [moduleName] sync module from source npm (ex.: pxnpm sync egg)\n' +
|
|
13
|
+
' user [username] open user profile page (ex.: pxnpm user fengmk2)\n' +
|
|
14
14
|
'\n' +
|
|
15
15
|
' npm command use --registry=' + (argv.registry || config.cnpmRegistry) + '\n' +
|
|
16
16
|
' where <command> is one of:\n' +
|
package/lib/origin_npm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const debug = require('debug')('
|
|
3
|
+
const debug = require('debug')('pxnpm:origin');
|
|
4
4
|
const match = require('auto-correct');
|
|
5
5
|
const spawn = require('cross-spawn');
|
|
6
6
|
const cp = require('child_process');
|
|
@@ -25,7 +25,7 @@ for (let i = 0; i < rawArgs.length; i++) {
|
|
|
25
25
|
continue;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// support `$
|
|
28
|
+
// support `$ pxnpm i --by=npm`
|
|
29
29
|
if (arg.indexOf('--by=') === 0) {
|
|
30
30
|
installer = arg.split('=', 2)[1];
|
|
31
31
|
continue;
|
|
@@ -65,7 +65,7 @@ const stdio = [
|
|
|
65
65
|
if (isInstall) {
|
|
66
66
|
npmBin = path.join(__dirname, '..', 'node_modules', '.bin', installer);
|
|
67
67
|
if (installer === 'pxnpminstall') {
|
|
68
|
-
// use fork to spawn can fix install
|
|
68
|
+
// use fork to spawn can fix install pxnpm itself fail on Windows
|
|
69
69
|
execMethod = cp.fork;
|
|
70
70
|
stdio.push('ipc');
|
|
71
71
|
npmBin = require.resolve('pxnpminstall/bin/install.js');
|
package/package.json
CHANGED
|
@@ -1,61 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pxnpm",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.0.0-1",
|
|
4
|
+
"description": "cnpm: npm client for cnpmjs.org",
|
|
5
|
+
"preferGlobal": true,
|
|
6
|
+
"bin": {
|
|
7
|
+
"pxnpm": "bin/pxnpm"
|
|
8
|
+
},
|
|
5
9
|
"main": "bin/pxnpm",
|
|
6
10
|
"files": [
|
|
7
11
|
"bin",
|
|
8
12
|
"lib"
|
|
9
13
|
],
|
|
10
14
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"test": "npm run lint -- --fix && npm run test-local",
|
|
15
|
+
"contributor": "git-contributor",
|
|
16
|
+
"test": "npm run lint && npm run test-local",
|
|
14
17
|
"test-local": "egg-bin test",
|
|
15
|
-
"lint": "eslint bin lib test/*.js",
|
|
16
|
-
"ci": "npm run lint &&
|
|
17
|
-
"autod": "autod"
|
|
18
|
-
},
|
|
19
|
-
"preferGlobal": true,
|
|
20
|
-
"bin": {
|
|
21
|
-
"pxnpm": "bin/pxnpm"
|
|
18
|
+
"lint": "eslint bin/* lib test/*.test.js",
|
|
19
|
+
"ci": "npm run lint && egg-bin test"
|
|
22
20
|
},
|
|
23
21
|
"dependencies": {
|
|
24
22
|
"auto-correct": "^1.0.0",
|
|
25
23
|
"bagpipe": "^0.3.5",
|
|
26
|
-
"colors": "^1.1.2",
|
|
27
24
|
"commander": "~2.10.0",
|
|
28
|
-
"config-chain": "^1.1.13",
|
|
29
25
|
"connection-tester": "^0.2.1",
|
|
30
26
|
"cross-spawn": "~0.2.8",
|
|
31
|
-
"debug": "^
|
|
27
|
+
"debug": "^4.3.4",
|
|
32
28
|
"giturl": "^1.0.0",
|
|
33
29
|
"ini": "^1.3.4",
|
|
34
|
-
"npm": "^
|
|
30
|
+
"npm": "^8.12.1",
|
|
35
31
|
"npm-request": "^1.0.0",
|
|
32
|
+
"pxnpminstall": "3.0.0-0",
|
|
36
33
|
"open": "^8.2.1",
|
|
37
|
-
"
|
|
38
|
-
"urllib": "^2.17.0"
|
|
34
|
+
"urllib": "^3.1.0"
|
|
39
35
|
},
|
|
40
36
|
"devDependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"egg-
|
|
44
|
-
"
|
|
45
|
-
"eslint": "
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
"coffee": "5",
|
|
38
|
+
"egg-bin": "5",
|
|
39
|
+
"egg-ci": "2",
|
|
40
|
+
"eslint": "8",
|
|
41
|
+
"eslint-config-egg": "12",
|
|
42
|
+
"git-contributor": "1"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/cnpm/cnpm",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git://github.com/cnpm/cnpm.git"
|
|
48
|
+
},
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/cnpm/cnpm/issues"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"cnpm",
|
|
54
|
+
"npm",
|
|
55
|
+
"npminstall"
|
|
56
|
+
],
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"tag": "latest"
|
|
49
59
|
},
|
|
50
60
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
61
|
+
"node": ">= 14.0.0"
|
|
52
62
|
},
|
|
53
63
|
"ci": {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
"
|
|
64
|
+
"version": "14, 16, 18",
|
|
65
|
+
"license": {
|
|
66
|
+
"year": "2013",
|
|
67
|
+
"fullname": "cnpm and other contributors."
|
|
58
68
|
}
|
|
59
69
|
},
|
|
60
|
-
"
|
|
70
|
+
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)",
|
|
71
|
+
"license": "MIT",
|
|
72
|
+
"__npminstall_done": true,
|
|
73
|
+
"_from": "cnpm@8.3.0",
|
|
74
|
+
"_resolved": "http://fe-repo.inner.px.nfjbill.ren:5507/cnpm/-/cnpm-8.3.0.tgz"
|
|
61
75
|
}
|
package/bin/cnpm
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const debug = require('debug')('cnpm');
|
|
6
|
-
const pkg = require('../package.json');
|
|
7
|
-
const argv = require('../lib/parse_argv')();
|
|
8
|
-
|
|
9
|
-
const action = argv.args[0];
|
|
10
|
-
|
|
11
|
-
const extendsMethd = {
|
|
12
|
-
web: 1,
|
|
13
|
-
check: 1,
|
|
14
|
-
doc: 1,
|
|
15
|
-
sync: 1,
|
|
16
|
-
user: 1,
|
|
17
|
-
search: 1,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
debug('cnpm %s', action);
|
|
21
|
-
|
|
22
|
-
if (extendsMethd[action]) {
|
|
23
|
-
return require('./cnpm-' + action);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
debug('origin npm with origin registry: $ npm %s', action);
|
|
27
|
-
require('../lib/origin_npm');
|