creepercli 1.0.0 → 1.1.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 +190 -0
- package/README.md +85 -117
- package/bin/creepercli.js +12 -25
- package/package.json +48 -48
- package/src/client.js +137 -127
- package/src/commands/auth.js +94 -108
- package/src/commands/exec.js +23 -37
- package/src/commands/fs.js +138 -152
- package/src/commands/index.js +129 -139
- package/src/commands/monitor.js +60 -69
- package/src/commands/search.js +56 -70
- package/src/config.js +47 -61
- package/src/editor.js +84 -98
- package/src/formatters.js +120 -134
- package/src/index.js +175 -186
- package/src/prompts.js +120 -134
- package/src/protocol.js +68 -82
- package/src/repl.js +94 -104
- package/src/session.js +40 -58
- package/src/top.js +39 -53
- package/src/transfer.js +292 -217
- package/src/update.js +73 -87
package/src/update.js
CHANGED
|
@@ -1,87 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!current || !latest) return false;
|
|
75
|
-
const c = current.split('-')[0].split('.').map((x) => parseInt(x, 10) || 0);
|
|
76
|
-
const l = latest.split('-')[0].split('.').map((x) => parseInt(x, 10) || 0);
|
|
77
|
-
const max = Math.max(c.length, l.length);
|
|
78
|
-
for (let i = 0; i < max; i++) {
|
|
79
|
-
const cv = c[i] || 0;
|
|
80
|
-
const lv = l[i] || 0;
|
|
81
|
-
if (lv > cv) return true;
|
|
82
|
-
if (lv < cv) return false;
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
module.exports = { checkUpdate };
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const https = require('https');
|
|
8
|
+
const { DIR } = require('./session');
|
|
9
|
+
const pkg = require('../package.json');
|
|
10
|
+
|
|
11
|
+
const UPDATE_FILE = path.join(DIR, 'update.json');
|
|
12
|
+
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
13
|
+
|
|
14
|
+
function checkUpdate() {
|
|
15
|
+
try {
|
|
16
|
+
const now = Date.now();
|
|
17
|
+
let cache = {};
|
|
18
|
+
try {
|
|
19
|
+
cache = JSON.parse(fs.readFileSync(UPDATE_FILE, 'utf8'));
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (cache.lastCheck && now - cache.lastCheck < CHECK_INTERVAL_MS) {
|
|
24
|
+
if (cache.latest && isNewerVersion(pkg.version, cache.latest)) {
|
|
25
|
+
console.log(`[Notice] A new version of creepercli (v${cache.latest}) is available! Run "npm install -g creepercli" to update.\n`);
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const req = https.get('https://registry.npmjs.org/creepercli/latest', {
|
|
31
|
+
timeout: 2500,
|
|
32
|
+
headers: { 'User-Agent': `creepercli/${pkg.version}` }
|
|
33
|
+
}, (res) => {
|
|
34
|
+
if (res.statusCode !== 200) return;
|
|
35
|
+
let body = '';
|
|
36
|
+
res.on('data', (chunk) => body += chunk);
|
|
37
|
+
res.on('end', () => {
|
|
38
|
+
try {
|
|
39
|
+
const data = JSON.parse(body);
|
|
40
|
+
if (data && data.version) {
|
|
41
|
+
const latest = data.version;
|
|
42
|
+
fs.mkdirSync(DIR, { recursive: true, mode: 0o700 });
|
|
43
|
+
fs.writeFileSync(UPDATE_FILE, JSON.stringify({ lastCheck: now, latest }), { mode: 0o600 });
|
|
44
|
+
if (isNewerVersion(pkg.version, latest)) {
|
|
45
|
+
console.log(`[Notice] A new version of creepercli (v${latest}) is available! Run "npm install -g creepercli" to update.\n`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
req.on('error', () => {});
|
|
54
|
+
req.on('socket', (socket) => socket.unref());
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isNewerVersion(current, latest) {
|
|
60
|
+
if (!current || !latest) return false;
|
|
61
|
+
const c = current.split('-')[0].split('.').map((x) => parseInt(x, 10) || 0);
|
|
62
|
+
const l = latest.split('-')[0].split('.').map((x) => parseInt(x, 10) || 0);
|
|
63
|
+
const max = Math.max(c.length, l.length);
|
|
64
|
+
for (let i = 0; i < max; i++) {
|
|
65
|
+
const cv = c[i] || 0;
|
|
66
|
+
const lv = l[i] || 0;
|
|
67
|
+
if (lv > cv) return true;
|
|
68
|
+
if (lv < cv) return false;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = { checkUpdate };
|