pal-explorer-cli 0.4.11 → 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/network.js
CHANGED
|
@@ -1,251 +1,251 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import {
|
|
3
|
-
createNetwork,
|
|
4
|
-
listNetworks,
|
|
5
|
-
getNetwork,
|
|
6
|
-
deleteNetwork,
|
|
7
|
-
createInvite,
|
|
8
|
-
joinNetwork,
|
|
9
|
-
listMembers,
|
|
10
|
-
listGroups,
|
|
11
|
-
createGroup as createNetworkGroup,
|
|
12
|
-
} from '../core/networks.js';
|
|
13
|
-
import { connect, disconnect, getConnectionState } from '../core/connectionManager.js';
|
|
14
|
-
|
|
15
|
-
export default function networkCommand(program) {
|
|
16
|
-
const cmd = program
|
|
17
|
-
.command('network')
|
|
18
|
-
.description('manage networks')
|
|
19
|
-
.addHelpText('after', `
|
|
20
|
-
Examples:
|
|
21
|
-
$
|
|
22
|
-
$
|
|
23
|
-
$
|
|
24
|
-
$
|
|
25
|
-
$
|
|
26
|
-
$
|
|
27
|
-
$
|
|
28
|
-
$
|
|
29
|
-
$
|
|
30
|
-
$
|
|
31
|
-
$
|
|
32
|
-
`);
|
|
33
|
-
|
|
34
|
-
cmd
|
|
35
|
-
.command('create <name>')
|
|
36
|
-
.description('create a new network')
|
|
37
|
-
.option('--slug <slug>', 'URL-friendly slug')
|
|
38
|
-
.option('--description <desc>', 'Network description')
|
|
39
|
-
.action(async (name, opts) => {
|
|
40
|
-
try {
|
|
41
|
-
const network = await createNetwork(name, opts.slug, opts.description);
|
|
42
|
-
console.log(chalk.green(`Network '${name}' created.`));
|
|
43
|
-
console.log(chalk.gray(`ID: ${network.id}`));
|
|
44
|
-
if (network.slug) console.log(chalk.gray(`Slug: ${network.slug}`));
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.log(chalk.red(err.message));
|
|
47
|
-
process.exitCode = 1;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
cmd
|
|
52
|
-
.command('list')
|
|
53
|
-
.description('list your networks')
|
|
54
|
-
.action(async () => {
|
|
55
|
-
try {
|
|
56
|
-
const networks = await listNetworks();
|
|
57
|
-
if (!networks || networks.length === 0) {
|
|
58
|
-
console.log(chalk.gray('No networks. Create one with `
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
console.log('');
|
|
62
|
-
console.log(chalk.cyan('Networks:'));
|
|
63
|
-
for (const n of networks) {
|
|
64
|
-
const members = n.memberCount != null ? chalk.gray(` (${n.memberCount} members)`) : '';
|
|
65
|
-
const role = n.role ? chalk.yellow(` [${n.role}]`) : '';
|
|
66
|
-
console.log(` ${chalk.white(n.name)}${role}${members}`);
|
|
67
|
-
console.log(` ${chalk.gray(`ID: ${n.id}`)}`);
|
|
68
|
-
if (n.description) console.log(` ${chalk.gray(n.description)}`);
|
|
69
|
-
}
|
|
70
|
-
console.log('');
|
|
71
|
-
} catch (err) {
|
|
72
|
-
console.log(chalk.red(err.message));
|
|
73
|
-
process.exitCode = 1;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
cmd
|
|
78
|
-
.command('info <id>')
|
|
79
|
-
.description('show network details')
|
|
80
|
-
.action(async (id) => {
|
|
81
|
-
try {
|
|
82
|
-
const n = await getNetwork(id);
|
|
83
|
-
console.log('');
|
|
84
|
-
console.log(chalk.cyan(`Network: ${n.name}`));
|
|
85
|
-
console.log(` ID: ${chalk.white(n.id)}`);
|
|
86
|
-
if (n.slug) console.log(` Slug: ${chalk.white(n.slug)}`);
|
|
87
|
-
if (n.description) console.log(` Description: ${chalk.white(n.description)}`);
|
|
88
|
-
if (n.owner) console.log(` Owner: ${chalk.white(n.owner)}`);
|
|
89
|
-
if (n.memberCount != null) console.log(` Members: ${chalk.white(n.memberCount)}`);
|
|
90
|
-
if (n.createdAt) console.log(` Created: ${chalk.gray(n.createdAt)}`);
|
|
91
|
-
console.log('');
|
|
92
|
-
} catch (err) {
|
|
93
|
-
console.log(chalk.red(err.message));
|
|
94
|
-
process.exitCode = 1;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
cmd
|
|
99
|
-
.command('delete <id>')
|
|
100
|
-
.description('delete a network')
|
|
101
|
-
.action(async (id) => {
|
|
102
|
-
try {
|
|
103
|
-
await deleteNetwork(id);
|
|
104
|
-
console.log(chalk.green(`Network ${id} deleted.`));
|
|
105
|
-
} catch (err) {
|
|
106
|
-
console.log(chalk.red(err.message));
|
|
107
|
-
process.exitCode = 1;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
cmd
|
|
112
|
-
.command('invite <id>')
|
|
113
|
-
.description('create an invite link')
|
|
114
|
-
.option('--role <role>', 'Role for invited user: member or admin', 'member')
|
|
115
|
-
.action(async (id, opts) => {
|
|
116
|
-
try {
|
|
117
|
-
const invite = await createInvite(id, opts.role);
|
|
118
|
-
console.log(chalk.green('Invite created.'));
|
|
119
|
-
console.log(` Code: ${chalk.white(invite.code)}`);
|
|
120
|
-
if (invite.url) console.log(` Link: ${chalk.cyan(invite.url)}`);
|
|
121
|
-
if (invite.expiresAt) console.log(` Expires: ${chalk.gray(invite.expiresAt)}`);
|
|
122
|
-
} catch (err) {
|
|
123
|
-
console.log(chalk.red(err.message));
|
|
124
|
-
process.exitCode = 1;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
cmd
|
|
129
|
-
.command('join <code>')
|
|
130
|
-
.description('join a network via invite code')
|
|
131
|
-
.action(async (code) => {
|
|
132
|
-
try {
|
|
133
|
-
const result = await joinNetwork(code);
|
|
134
|
-
console.log(chalk.green(`Joined network '${result.name || result.networkId}'.`));
|
|
135
|
-
} catch (err) {
|
|
136
|
-
console.log(chalk.red(err.message));
|
|
137
|
-
process.exitCode = 1;
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
cmd
|
|
142
|
-
.command('members <id>')
|
|
143
|
-
.description('list network members')
|
|
144
|
-
.action(async (id) => {
|
|
145
|
-
try {
|
|
146
|
-
const members = await listMembers(id);
|
|
147
|
-
if (!members || members.length === 0) {
|
|
148
|
-
console.log(chalk.gray('No members in this network.'));
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
console.log('');
|
|
152
|
-
console.log(chalk.cyan('Members:'));
|
|
153
|
-
for (const m of members) {
|
|
154
|
-
const role = m.role ? chalk.yellow(` [${m.role}]`) : '';
|
|
155
|
-
const handle = m.handle ? chalk.gray(` @${m.handle}`) : '';
|
|
156
|
-
console.log(` ${chalk.white(m.name || m.userId)}${handle}${role}`);
|
|
157
|
-
}
|
|
158
|
-
console.log('');
|
|
159
|
-
} catch (err) {
|
|
160
|
-
console.log(chalk.red(err.message));
|
|
161
|
-
process.exitCode = 1;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
cmd
|
|
166
|
-
.command('groups <id>')
|
|
167
|
-
.description('list groups in a network')
|
|
168
|
-
.action(async (id) => {
|
|
169
|
-
try {
|
|
170
|
-
const groups = await listGroups(id);
|
|
171
|
-
if (!groups || groups.length === 0) {
|
|
172
|
-
console.log(chalk.gray('No groups in this network.'));
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
console.log('');
|
|
176
|
-
console.log(chalk.cyan('Groups:'));
|
|
177
|
-
for (const g of groups) {
|
|
178
|
-
console.log(` ${chalk.white(g.name)} ${chalk.gray(`ID: ${g.id}`)}`);
|
|
179
|
-
}
|
|
180
|
-
console.log('');
|
|
181
|
-
} catch (err) {
|
|
182
|
-
console.log(chalk.red(err.message));
|
|
183
|
-
process.exitCode = 1;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
cmd
|
|
188
|
-
.command('create-group <network-id> <name>')
|
|
189
|
-
.description('create a group in a network')
|
|
190
|
-
.action(async (networkId, name) => {
|
|
191
|
-
try {
|
|
192
|
-
const group = await createNetworkGroup(networkId, name);
|
|
193
|
-
console.log(chalk.green(`Group '${name}' created in network.`));
|
|
194
|
-
console.log(chalk.gray(`ID: ${group.id}`));
|
|
195
|
-
} catch (err) {
|
|
196
|
-
console.log(chalk.red(err.message));
|
|
197
|
-
process.exitCode = 1;
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
cmd
|
|
202
|
-
.command('connect')
|
|
203
|
-
.description('connect to the Palexplorer network')
|
|
204
|
-
.action(async () => {
|
|
205
|
-
const current = getConnectionState();
|
|
206
|
-
if (current.status === 'connected') {
|
|
207
|
-
console.log(chalk.yellow('Already connected.'));
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
console.log(chalk.blue('Connecting to Palexplorer network...'));
|
|
211
|
-
const result = await connect({
|
|
212
|
-
onProgress: (step, progress) => {
|
|
213
|
-
console.log(chalk.gray(` [${progress}%] ${step}`));
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
if (result.connectedCount > 0) {
|
|
217
|
-
console.log(chalk.green(`\nConnected to ${result.connectedCount} server(s).`));
|
|
218
|
-
} else {
|
|
219
|
-
console.log(chalk.yellow('\nWarning: No servers reachable.'));
|
|
220
|
-
process.exitCode = 1;
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
cmd
|
|
225
|
-
.command('disconnect')
|
|
226
|
-
.description('disconnect from the Palexplorer network')
|
|
227
|
-
.action(async () => {
|
|
228
|
-
const current = getConnectionState();
|
|
229
|
-
if (current.status === 'disconnected') {
|
|
230
|
-
console.log(chalk.yellow('Already disconnected.'));
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
console.log(chalk.blue('Disconnecting...'));
|
|
234
|
-
await disconnect();
|
|
235
|
-
console.log(chalk.green('Disconnected from network.'));
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
cmd.action(async () => {
|
|
239
|
-
try {
|
|
240
|
-
const networks = await listNetworks();
|
|
241
|
-
if (!networks || networks.length === 0) {
|
|
242
|
-
console.log(chalk.gray('No networks. Create one with `
|
|
243
|
-
} else {
|
|
244
|
-
console.log(chalk.cyan(`${networks.length} network(s). Use \`
|
|
245
|
-
}
|
|
246
|
-
} catch (err) {
|
|
247
|
-
console.log(chalk.red(err.message));
|
|
248
|
-
process.exitCode = 1;
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
}
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import {
|
|
3
|
+
createNetwork,
|
|
4
|
+
listNetworks,
|
|
5
|
+
getNetwork,
|
|
6
|
+
deleteNetwork,
|
|
7
|
+
createInvite,
|
|
8
|
+
joinNetwork,
|
|
9
|
+
listMembers,
|
|
10
|
+
listGroups,
|
|
11
|
+
createGroup as createNetworkGroup,
|
|
12
|
+
} from '../core/networks.js';
|
|
13
|
+
import { connect, disconnect, getConnectionState } from '../core/connectionManager.js';
|
|
14
|
+
|
|
15
|
+
export default function networkCommand(program) {
|
|
16
|
+
const cmd = program
|
|
17
|
+
.command('network')
|
|
18
|
+
.description('manage networks')
|
|
19
|
+
.addHelpText('after', `
|
|
20
|
+
Examples:
|
|
21
|
+
$ pal network create "My Network" Create a network
|
|
22
|
+
$ pal network list List your networks
|
|
23
|
+
$ pal network info <id> Show network details
|
|
24
|
+
$ pal network invite <id> Create an invite link
|
|
25
|
+
$ pal network join <code> Join via invite code
|
|
26
|
+
$ pal network members <id> List members
|
|
27
|
+
$ pal network groups <id> List groups
|
|
28
|
+
$ pal network create-group <id> <name> Create a group in network
|
|
29
|
+
$ pal network delete <id> Delete a network
|
|
30
|
+
$ pal network connect Connect to the network
|
|
31
|
+
$ pal network disconnect Disconnect from the network
|
|
32
|
+
`);
|
|
33
|
+
|
|
34
|
+
cmd
|
|
35
|
+
.command('create <name>')
|
|
36
|
+
.description('create a new network')
|
|
37
|
+
.option('--slug <slug>', 'URL-friendly slug')
|
|
38
|
+
.option('--description <desc>', 'Network description')
|
|
39
|
+
.action(async (name, opts) => {
|
|
40
|
+
try {
|
|
41
|
+
const network = await createNetwork(name, opts.slug, opts.description);
|
|
42
|
+
console.log(chalk.green(`Network '${name}' created.`));
|
|
43
|
+
console.log(chalk.gray(`ID: ${network.id}`));
|
|
44
|
+
if (network.slug) console.log(chalk.gray(`Slug: ${network.slug}`));
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.log(chalk.red(err.message));
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
cmd
|
|
52
|
+
.command('list')
|
|
53
|
+
.description('list your networks')
|
|
54
|
+
.action(async () => {
|
|
55
|
+
try {
|
|
56
|
+
const networks = await listNetworks();
|
|
57
|
+
if (!networks || networks.length === 0) {
|
|
58
|
+
console.log(chalk.gray('No networks. Create one with `pal network create <name>`.'));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
console.log('');
|
|
62
|
+
console.log(chalk.cyan('Networks:'));
|
|
63
|
+
for (const n of networks) {
|
|
64
|
+
const members = n.memberCount != null ? chalk.gray(` (${n.memberCount} members)`) : '';
|
|
65
|
+
const role = n.role ? chalk.yellow(` [${n.role}]`) : '';
|
|
66
|
+
console.log(` ${chalk.white(n.name)}${role}${members}`);
|
|
67
|
+
console.log(` ${chalk.gray(`ID: ${n.id}`)}`);
|
|
68
|
+
if (n.description) console.log(` ${chalk.gray(n.description)}`);
|
|
69
|
+
}
|
|
70
|
+
console.log('');
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.log(chalk.red(err.message));
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
cmd
|
|
78
|
+
.command('info <id>')
|
|
79
|
+
.description('show network details')
|
|
80
|
+
.action(async (id) => {
|
|
81
|
+
try {
|
|
82
|
+
const n = await getNetwork(id);
|
|
83
|
+
console.log('');
|
|
84
|
+
console.log(chalk.cyan(`Network: ${n.name}`));
|
|
85
|
+
console.log(` ID: ${chalk.white(n.id)}`);
|
|
86
|
+
if (n.slug) console.log(` Slug: ${chalk.white(n.slug)}`);
|
|
87
|
+
if (n.description) console.log(` Description: ${chalk.white(n.description)}`);
|
|
88
|
+
if (n.owner) console.log(` Owner: ${chalk.white(n.owner)}`);
|
|
89
|
+
if (n.memberCount != null) console.log(` Members: ${chalk.white(n.memberCount)}`);
|
|
90
|
+
if (n.createdAt) console.log(` Created: ${chalk.gray(n.createdAt)}`);
|
|
91
|
+
console.log('');
|
|
92
|
+
} catch (err) {
|
|
93
|
+
console.log(chalk.red(err.message));
|
|
94
|
+
process.exitCode = 1;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
cmd
|
|
99
|
+
.command('delete <id>')
|
|
100
|
+
.description('delete a network')
|
|
101
|
+
.action(async (id) => {
|
|
102
|
+
try {
|
|
103
|
+
await deleteNetwork(id);
|
|
104
|
+
console.log(chalk.green(`Network ${id} deleted.`));
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.log(chalk.red(err.message));
|
|
107
|
+
process.exitCode = 1;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
cmd
|
|
112
|
+
.command('invite <id>')
|
|
113
|
+
.description('create an invite link')
|
|
114
|
+
.option('--role <role>', 'Role for invited user: member or admin', 'member')
|
|
115
|
+
.action(async (id, opts) => {
|
|
116
|
+
try {
|
|
117
|
+
const invite = await createInvite(id, opts.role);
|
|
118
|
+
console.log(chalk.green('Invite created.'));
|
|
119
|
+
console.log(` Code: ${chalk.white(invite.code)}`);
|
|
120
|
+
if (invite.url) console.log(` Link: ${chalk.cyan(invite.url)}`);
|
|
121
|
+
if (invite.expiresAt) console.log(` Expires: ${chalk.gray(invite.expiresAt)}`);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
console.log(chalk.red(err.message));
|
|
124
|
+
process.exitCode = 1;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
cmd
|
|
129
|
+
.command('join <code>')
|
|
130
|
+
.description('join a network via invite code')
|
|
131
|
+
.action(async (code) => {
|
|
132
|
+
try {
|
|
133
|
+
const result = await joinNetwork(code);
|
|
134
|
+
console.log(chalk.green(`Joined network '${result.name || result.networkId}'.`));
|
|
135
|
+
} catch (err) {
|
|
136
|
+
console.log(chalk.red(err.message));
|
|
137
|
+
process.exitCode = 1;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
cmd
|
|
142
|
+
.command('members <id>')
|
|
143
|
+
.description('list network members')
|
|
144
|
+
.action(async (id) => {
|
|
145
|
+
try {
|
|
146
|
+
const members = await listMembers(id);
|
|
147
|
+
if (!members || members.length === 0) {
|
|
148
|
+
console.log(chalk.gray('No members in this network.'));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
console.log('');
|
|
152
|
+
console.log(chalk.cyan('Members:'));
|
|
153
|
+
for (const m of members) {
|
|
154
|
+
const role = m.role ? chalk.yellow(` [${m.role}]`) : '';
|
|
155
|
+
const handle = m.handle ? chalk.gray(` @${m.handle}`) : '';
|
|
156
|
+
console.log(` ${chalk.white(m.name || m.userId)}${handle}${role}`);
|
|
157
|
+
}
|
|
158
|
+
console.log('');
|
|
159
|
+
} catch (err) {
|
|
160
|
+
console.log(chalk.red(err.message));
|
|
161
|
+
process.exitCode = 1;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
cmd
|
|
166
|
+
.command('groups <id>')
|
|
167
|
+
.description('list groups in a network')
|
|
168
|
+
.action(async (id) => {
|
|
169
|
+
try {
|
|
170
|
+
const groups = await listGroups(id);
|
|
171
|
+
if (!groups || groups.length === 0) {
|
|
172
|
+
console.log(chalk.gray('No groups in this network.'));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
console.log('');
|
|
176
|
+
console.log(chalk.cyan('Groups:'));
|
|
177
|
+
for (const g of groups) {
|
|
178
|
+
console.log(` ${chalk.white(g.name)} ${chalk.gray(`ID: ${g.id}`)}`);
|
|
179
|
+
}
|
|
180
|
+
console.log('');
|
|
181
|
+
} catch (err) {
|
|
182
|
+
console.log(chalk.red(err.message));
|
|
183
|
+
process.exitCode = 1;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
cmd
|
|
188
|
+
.command('create-group <network-id> <name>')
|
|
189
|
+
.description('create a group in a network')
|
|
190
|
+
.action(async (networkId, name) => {
|
|
191
|
+
try {
|
|
192
|
+
const group = await createNetworkGroup(networkId, name);
|
|
193
|
+
console.log(chalk.green(`Group '${name}' created in network.`));
|
|
194
|
+
console.log(chalk.gray(`ID: ${group.id}`));
|
|
195
|
+
} catch (err) {
|
|
196
|
+
console.log(chalk.red(err.message));
|
|
197
|
+
process.exitCode = 1;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
cmd
|
|
202
|
+
.command('connect')
|
|
203
|
+
.description('connect to the Palexplorer network')
|
|
204
|
+
.action(async () => {
|
|
205
|
+
const current = getConnectionState();
|
|
206
|
+
if (current.status === 'connected') {
|
|
207
|
+
console.log(chalk.yellow('Already connected.'));
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
console.log(chalk.blue('Connecting to Palexplorer network...'));
|
|
211
|
+
const result = await connect({
|
|
212
|
+
onProgress: (step, progress) => {
|
|
213
|
+
console.log(chalk.gray(` [${progress}%] ${step}`));
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
if (result.connectedCount > 0) {
|
|
217
|
+
console.log(chalk.green(`\nConnected to ${result.connectedCount} server(s).`));
|
|
218
|
+
} else {
|
|
219
|
+
console.log(chalk.yellow('\nWarning: No servers reachable.'));
|
|
220
|
+
process.exitCode = 1;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
cmd
|
|
225
|
+
.command('disconnect')
|
|
226
|
+
.description('disconnect from the Palexplorer network')
|
|
227
|
+
.action(async () => {
|
|
228
|
+
const current = getConnectionState();
|
|
229
|
+
if (current.status === 'disconnected') {
|
|
230
|
+
console.log(chalk.yellow('Already disconnected.'));
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
console.log(chalk.blue('Disconnecting...'));
|
|
234
|
+
await disconnect();
|
|
235
|
+
console.log(chalk.green('Disconnected from network.'));
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
cmd.action(async () => {
|
|
239
|
+
try {
|
|
240
|
+
const networks = await listNetworks();
|
|
241
|
+
if (!networks || networks.length === 0) {
|
|
242
|
+
console.log(chalk.gray('No networks. Create one with `pal network create <name>`.'));
|
|
243
|
+
} else {
|
|
244
|
+
console.log(chalk.cyan(`${networks.length} network(s). Use \`pal network list\` for details.`));
|
|
245
|
+
}
|
|
246
|
+
} catch (err) {
|
|
247
|
+
console.log(chalk.red(err.message));
|
|
248
|
+
process.exitCode = 1;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|