pal-explorer-cli 0.4.12 → 0.4.13
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 +149 -149
- package/bin/pal.js +63 -2
- package/extensions/@palexplorer/analytics/extension.json +20 -1
- package/extensions/@palexplorer/analytics/index.js +19 -9
- package/extensions/@palexplorer/audit/extension.json +14 -0
- package/extensions/@palexplorer/auth-email/extension.json +15 -0
- package/extensions/@palexplorer/auth-oauth/extension.json +15 -0
- package/extensions/@palexplorer/chat/extension.json +14 -0
- package/extensions/@palexplorer/discovery/extension.json +17 -0
- package/extensions/@palexplorer/discovery/index.js +1 -1
- package/extensions/@palexplorer/email-notifications/extension.json +23 -0
- package/extensions/@palexplorer/groups/extension.json +15 -0
- package/extensions/@palexplorer/share-links/extension.json +15 -0
- package/extensions/@palexplorer/sync/extension.json +16 -0
- package/extensions/@palexplorer/user-mgmt/extension.json +15 -0
- package/lib/capabilities.js +24 -24
- package/lib/commands/analytics.js +175 -175
- package/lib/commands/api-keys.js +131 -131
- package/lib/commands/audit.js +235 -235
- package/lib/commands/auth.js +137 -137
- package/lib/commands/backup.js +76 -76
- package/lib/commands/billing.js +148 -148
- package/lib/commands/chat.js +217 -217
- package/lib/commands/cloud-backup.js +231 -231
- package/lib/commands/comment.js +99 -99
- package/lib/commands/completion.js +203 -203
- package/lib/commands/compliance.js +218 -218
- package/lib/commands/config.js +136 -136
- package/lib/commands/connect.js +44 -44
- package/lib/commands/dept.js +294 -294
- package/lib/commands/device.js +146 -146
- package/lib/commands/download.js +240 -226
- package/lib/commands/explorer.js +178 -178
- package/lib/commands/extension.js +1060 -970
- package/lib/commands/favorite.js +90 -90
- package/lib/commands/federation.js +270 -270
- package/lib/commands/file.js +533 -533
- package/lib/commands/group.js +271 -271
- package/lib/commands/gui-share.js +29 -29
- package/lib/commands/init.js +61 -61
- package/lib/commands/invite.js +59 -59
- package/lib/commands/list.js +58 -58
- package/lib/commands/log.js +116 -116
- package/lib/commands/nearby.js +108 -108
- package/lib/commands/network.js +251 -251
- package/lib/commands/notify.js +198 -198
- package/lib/commands/org.js +273 -273
- package/lib/commands/pal.js +403 -180
- package/lib/commands/permissions.js +216 -216
- package/lib/commands/pin.js +97 -97
- package/lib/commands/protocol.js +357 -357
- package/lib/commands/rbac.js +147 -147
- package/lib/commands/recover.js +36 -36
- package/lib/commands/register.js +171 -171
- package/lib/commands/relay.js +131 -131
- package/lib/commands/remote.js +368 -368
- package/lib/commands/revoke.js +50 -50
- package/lib/commands/scanner.js +280 -280
- package/lib/commands/schedule.js +344 -344
- package/lib/commands/scim.js +203 -203
- package/lib/commands/search.js +181 -181
- package/lib/commands/serve.js +438 -438
- package/lib/commands/server.js +350 -350
- package/lib/commands/share-link.js +199 -199
- package/lib/commands/share.js +336 -323
- package/lib/commands/sso.js +200 -200
- package/lib/commands/status.js +145 -145
- package/lib/commands/stream.js +562 -562
- package/lib/commands/su.js +187 -187
- package/lib/commands/sync.js +979 -979
- package/lib/commands/transfers.js +152 -152
- package/lib/commands/uninstall.js +188 -188
- package/lib/commands/update.js +204 -204
- package/lib/commands/user.js +276 -276
- package/lib/commands/vfs.js +84 -84
- package/lib/commands/web-login.js +79 -79
- package/lib/commands/web.js +52 -52
- package/lib/commands/webhook.js +180 -180
- package/lib/commands/whoami.js +59 -59
- package/lib/commands/workspace.js +121 -121
- package/lib/core/billing.js +16 -5
- package/lib/core/dhtDiscovery.js +9 -2
- package/lib/core/discoveryClient.js +13 -7
- package/lib/core/extensions.js +142 -1
- package/lib/core/identity.js +33 -2
- package/lib/core/imageProcessor.js +109 -0
- package/lib/core/imageTorrent.js +167 -0
- package/lib/core/permissions.js +1 -1
- package/lib/core/pro.js +11 -4
- package/lib/core/serverList.js +4 -1
- package/lib/core/shares.js +12 -1
- package/lib/core/signalingServer.js +14 -2
- package/lib/core/su.js +1 -1
- package/lib/core/users.js +1 -1
- package/lib/protocol/messages.js +12 -3
- package/lib/utils/explorer.js +1 -1
- package/lib/utils/help.js +357 -357
- package/lib/utils/torrent.js +1 -0
- package/package.json +4 -3
package/lib/commands/status.js
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import config from '../utils/config.js';
|
|
5
|
-
import { getIdentity } from '../core/identity.js';
|
|
6
|
-
import { listShares } from '../core/shares.js';
|
|
7
|
-
import { getTransfers } from '../core/transfers.js';
|
|
8
|
-
import { getServers, checkServer } from '../core/discoveryClient.js';
|
|
9
|
-
import { getConnectionState } from '../core/connectionManager.js';
|
|
10
|
-
|
|
11
|
-
export default function statusCommand(program) {
|
|
12
|
-
program
|
|
13
|
-
.command('status')
|
|
14
|
-
.description('show system health dashboard')
|
|
15
|
-
.addHelpText('after', `
|
|
16
|
-
Examples:
|
|
17
|
-
$
|
|
18
|
-
`)
|
|
19
|
-
.action(async () => {
|
|
20
|
-
try {
|
|
21
|
-
const opts = program.opts();
|
|
22
|
-
const identity = await getIdentity();
|
|
23
|
-
|
|
24
|
-
if (opts.json) {
|
|
25
|
-
const shares = listShares();
|
|
26
|
-
const active = getTransfers() || [];
|
|
27
|
-
const pidPath = path.join(path.dirname(config.path), 'serve.pid');
|
|
28
|
-
const conn = getConnectionState();
|
|
29
|
-
const enabledExts = config.get('enabledExtensions') || [];
|
|
30
|
-
const hasDiscovery = enabledExts.includes('@palexplorer/discovery');
|
|
31
|
-
const data = {
|
|
32
|
-
identity: identity ? { name: identity.name, handle: identity.handle, publicKey: identity.publicKey?.slice(0, 16) } : null,
|
|
33
|
-
network: { status: conn.status, connectedCount: conn.connectedCount || 0 },
|
|
34
|
-
daemon: fs.existsSync(pidPath) ? 'running' : 'stopped',
|
|
35
|
-
shares: { count: shares.length },
|
|
36
|
-
transfers: { active: active.length },
|
|
37
|
-
};
|
|
38
|
-
if (hasDiscovery) {
|
|
39
|
-
const servers = getServers();
|
|
40
|
-
data.discoveryServers = await Promise.all(servers.map(s => checkServer(s)));
|
|
41
|
-
}
|
|
42
|
-
console.log(JSON.stringify(data, null, 2));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Identity
|
|
47
|
-
console.log('');
|
|
48
|
-
console.log(chalk.cyan.bold('Identity'));
|
|
49
|
-
if (identity) {
|
|
50
|
-
console.log(` Name: ${chalk.green(identity.name || 'Unknown')}`);
|
|
51
|
-
console.log(` Handle: ${chalk.green(identity.handle || 'Not linked')}`);
|
|
52
|
-
console.log(` Public Key: ${chalk.yellow(identity.publicKey?.slice(0, 16) + '...')}`);
|
|
53
|
-
} else {
|
|
54
|
-
console.log(chalk.gray(' Not initialized. Run `
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Network Connection
|
|
58
|
-
console.log('');
|
|
59
|
-
console.log(chalk.cyan.bold('Network'));
|
|
60
|
-
const conn = getConnectionState();
|
|
61
|
-
const connColor = conn.status === 'connected' ? chalk.green
|
|
62
|
-
: conn.status === 'connecting' ? chalk.yellow
|
|
63
|
-
: chalk.red;
|
|
64
|
-
console.log(` Status: ${connColor(conn.status)}`);
|
|
65
|
-
if (conn.protocol) {
|
|
66
|
-
console.log(` Protocol: ${chalk.white(conn.protocol)} v${conn.protocolVersion}`);
|
|
67
|
-
}
|
|
68
|
-
if (conn.connectedCount > 0) {
|
|
69
|
-
console.log(` Servers: ${chalk.white(conn.connectedCount)} reachable`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Daemon
|
|
73
|
-
console.log('');
|
|
74
|
-
console.log(chalk.cyan.bold('Daemon'));
|
|
75
|
-
const pidPath = path.join(path.dirname(config.path), 'serve.pid');
|
|
76
|
-
if (fs.existsSync(pidPath)) {
|
|
77
|
-
const pid = fs.readFileSync(pidPath, 'utf8').trim();
|
|
78
|
-
try {
|
|
79
|
-
process.kill(parseInt(pid, 10), 0);
|
|
80
|
-
console.log(` Status: ${chalk.green('Running')} (PID ${pid})`);
|
|
81
|
-
} catch {
|
|
82
|
-
console.log(` Status: ${chalk.yellow('Stale PID file')} (process ${pid} not found)`);
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
console.log(` Status: ${chalk.gray('Not running')}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Shares
|
|
89
|
-
console.log('');
|
|
90
|
-
console.log(chalk.cyan.bold('Shares'));
|
|
91
|
-
const shares = listShares();
|
|
92
|
-
if (shares.length === 0) {
|
|
93
|
-
console.log(chalk.gray(' No active shares.'));
|
|
94
|
-
} else {
|
|
95
|
-
let totalSize = 0;
|
|
96
|
-
for (const s of shares) {
|
|
97
|
-
try {
|
|
98
|
-
const stat = fs.statSync(s.path);
|
|
99
|
-
totalSize += stat.isDirectory() ? 0 : stat.size;
|
|
100
|
-
} catch { /* skip */ }
|
|
101
|
-
}
|
|
102
|
-
console.log(` Active: ${chalk.white(shares.length)}`);
|
|
103
|
-
if (totalSize > 0) {
|
|
104
|
-
console.log(` Size: ${chalk.white((totalSize / 1024 / 1024).toFixed(1) + ' MB')}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Transfers
|
|
109
|
-
console.log('');
|
|
110
|
-
console.log(chalk.cyan.bold('Transfers'));
|
|
111
|
-
const active = getTransfers() || [];
|
|
112
|
-
if (active.length === 0) {
|
|
113
|
-
console.log(chalk.gray(' No active transfers.'));
|
|
114
|
-
} else {
|
|
115
|
-
console.log(` Active: ${chalk.white(active.length)}`);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Discovery servers (only if discovery extension is enabled)
|
|
119
|
-
const enabled = config.get('enabledExtensions') || [];
|
|
120
|
-
const discoveryEnabled = enabled.includes('@palexplorer/discovery');
|
|
121
|
-
if (discoveryEnabled) {
|
|
122
|
-
console.log('');
|
|
123
|
-
console.log(chalk.cyan.bold('Discovery Servers'));
|
|
124
|
-
const servers = getServers();
|
|
125
|
-
if (servers.length === 0) {
|
|
126
|
-
console.log(chalk.gray(' No servers configured.'));
|
|
127
|
-
} else {
|
|
128
|
-
const checks = await Promise.all(servers.map(s => checkServer(s)));
|
|
129
|
-
for (const c of checks) {
|
|
130
|
-
if (c.reachable) {
|
|
131
|
-
console.log(` ${chalk.green('●')} ${c.url}`);
|
|
132
|
-
} else {
|
|
133
|
-
console.log(` ${chalk.red('●')} ${c.url} ${chalk.red('unreachable')}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
console.log('');
|
|
140
|
-
} catch (err) {
|
|
141
|
-
console.error(chalk.red('Status check failed:'), err.message);
|
|
142
|
-
process.exitCode = 1;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import config from '../utils/config.js';
|
|
5
|
+
import { getIdentity } from '../core/identity.js';
|
|
6
|
+
import { listShares } from '../core/shares.js';
|
|
7
|
+
import { getTransfers } from '../core/transfers.js';
|
|
8
|
+
import { getServers, checkServer } from '../core/discoveryClient.js';
|
|
9
|
+
import { getConnectionState } from '../core/connectionManager.js';
|
|
10
|
+
|
|
11
|
+
export default function statusCommand(program) {
|
|
12
|
+
program
|
|
13
|
+
.command('status')
|
|
14
|
+
.description('show system health dashboard')
|
|
15
|
+
.addHelpText('after', `
|
|
16
|
+
Examples:
|
|
17
|
+
$ pal status Show system health dashboard
|
|
18
|
+
`)
|
|
19
|
+
.action(async () => {
|
|
20
|
+
try {
|
|
21
|
+
const opts = program.opts();
|
|
22
|
+
const identity = await getIdentity();
|
|
23
|
+
|
|
24
|
+
if (opts.json) {
|
|
25
|
+
const shares = listShares();
|
|
26
|
+
const active = getTransfers() || [];
|
|
27
|
+
const pidPath = path.join(path.dirname(config.path), 'serve.pid');
|
|
28
|
+
const conn = getConnectionState();
|
|
29
|
+
const enabledExts = config.get('enabledExtensions') || [];
|
|
30
|
+
const hasDiscovery = enabledExts.includes('@palexplorer/discovery');
|
|
31
|
+
const data = {
|
|
32
|
+
identity: identity ? { name: identity.name, handle: identity.handle, publicKey: identity.publicKey?.slice(0, 16) } : null,
|
|
33
|
+
network: { status: conn.status, connectedCount: conn.connectedCount || 0 },
|
|
34
|
+
daemon: fs.existsSync(pidPath) ? 'running' : 'stopped',
|
|
35
|
+
shares: { count: shares.length },
|
|
36
|
+
transfers: { active: active.length },
|
|
37
|
+
};
|
|
38
|
+
if (hasDiscovery) {
|
|
39
|
+
const servers = getServers();
|
|
40
|
+
data.discoveryServers = await Promise.all(servers.map(s => checkServer(s)));
|
|
41
|
+
}
|
|
42
|
+
console.log(JSON.stringify(data, null, 2));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Identity
|
|
47
|
+
console.log('');
|
|
48
|
+
console.log(chalk.cyan.bold('Identity'));
|
|
49
|
+
if (identity) {
|
|
50
|
+
console.log(` Name: ${chalk.green(identity.name || 'Unknown')}`);
|
|
51
|
+
console.log(` Handle: ${chalk.green(identity.handle || 'Not linked')}`);
|
|
52
|
+
console.log(` Public Key: ${chalk.yellow(identity.publicKey?.slice(0, 16) + '...')}`);
|
|
53
|
+
} else {
|
|
54
|
+
console.log(chalk.gray(' Not initialized. Run `pal init <name>` to get started.'));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Network Connection
|
|
58
|
+
console.log('');
|
|
59
|
+
console.log(chalk.cyan.bold('Network'));
|
|
60
|
+
const conn = getConnectionState();
|
|
61
|
+
const connColor = conn.status === 'connected' ? chalk.green
|
|
62
|
+
: conn.status === 'connecting' ? chalk.yellow
|
|
63
|
+
: chalk.red;
|
|
64
|
+
console.log(` Status: ${connColor(conn.status)}`);
|
|
65
|
+
if (conn.protocol) {
|
|
66
|
+
console.log(` Protocol: ${chalk.white(conn.protocol)} v${conn.protocolVersion}`);
|
|
67
|
+
}
|
|
68
|
+
if (conn.connectedCount > 0) {
|
|
69
|
+
console.log(` Servers: ${chalk.white(conn.connectedCount)} reachable`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Daemon
|
|
73
|
+
console.log('');
|
|
74
|
+
console.log(chalk.cyan.bold('Daemon'));
|
|
75
|
+
const pidPath = path.join(path.dirname(config.path), 'serve.pid');
|
|
76
|
+
if (fs.existsSync(pidPath)) {
|
|
77
|
+
const pid = fs.readFileSync(pidPath, 'utf8').trim();
|
|
78
|
+
try {
|
|
79
|
+
process.kill(parseInt(pid, 10), 0);
|
|
80
|
+
console.log(` Status: ${chalk.green('Running')} (PID ${pid})`);
|
|
81
|
+
} catch {
|
|
82
|
+
console.log(` Status: ${chalk.yellow('Stale PID file')} (process ${pid} not found)`);
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
console.log(` Status: ${chalk.gray('Not running')}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Shares
|
|
89
|
+
console.log('');
|
|
90
|
+
console.log(chalk.cyan.bold('Shares'));
|
|
91
|
+
const shares = listShares();
|
|
92
|
+
if (shares.length === 0) {
|
|
93
|
+
console.log(chalk.gray(' No active shares.'));
|
|
94
|
+
} else {
|
|
95
|
+
let totalSize = 0;
|
|
96
|
+
for (const s of shares) {
|
|
97
|
+
try {
|
|
98
|
+
const stat = fs.statSync(s.path);
|
|
99
|
+
totalSize += stat.isDirectory() ? 0 : stat.size;
|
|
100
|
+
} catch { /* skip */ }
|
|
101
|
+
}
|
|
102
|
+
console.log(` Active: ${chalk.white(shares.length)}`);
|
|
103
|
+
if (totalSize > 0) {
|
|
104
|
+
console.log(` Size: ${chalk.white((totalSize / 1024 / 1024).toFixed(1) + ' MB')}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Transfers
|
|
109
|
+
console.log('');
|
|
110
|
+
console.log(chalk.cyan.bold('Transfers'));
|
|
111
|
+
const active = getTransfers() || [];
|
|
112
|
+
if (active.length === 0) {
|
|
113
|
+
console.log(chalk.gray(' No active transfers.'));
|
|
114
|
+
} else {
|
|
115
|
+
console.log(` Active: ${chalk.white(active.length)}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Discovery servers (only if discovery extension is enabled)
|
|
119
|
+
const enabled = config.get('enabledExtensions') || [];
|
|
120
|
+
const discoveryEnabled = enabled.includes('@palexplorer/discovery');
|
|
121
|
+
if (discoveryEnabled) {
|
|
122
|
+
console.log('');
|
|
123
|
+
console.log(chalk.cyan.bold('Discovery Servers'));
|
|
124
|
+
const servers = getServers();
|
|
125
|
+
if (servers.length === 0) {
|
|
126
|
+
console.log(chalk.gray(' No servers configured.'));
|
|
127
|
+
} else {
|
|
128
|
+
const checks = await Promise.all(servers.map(s => checkServer(s)));
|
|
129
|
+
for (const c of checks) {
|
|
130
|
+
if (c.reachable) {
|
|
131
|
+
console.log(` ${chalk.green('●')} ${c.url}`);
|
|
132
|
+
} else {
|
|
133
|
+
console.log(` ${chalk.red('●')} ${c.url} ${chalk.red('unreachable')}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
console.log('');
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.error(chalk.red('Status check failed:'), err.message);
|
|
142
|
+
process.exitCode = 1;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|