pal-explorer-cli 0.4.0

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.
Files changed (156) hide show
  1. package/LICENSE.md +18 -0
  2. package/README.md +314 -0
  3. package/bin/pal.js +230 -0
  4. package/extensions/@palexplorer/analytics/README.md +45 -0
  5. package/extensions/@palexplorer/analytics/docs/MONETIZATION.md +14 -0
  6. package/extensions/@palexplorer/analytics/docs/PLAN.md +23 -0
  7. package/extensions/@palexplorer/analytics/docs/PRIVACY.md +38 -0
  8. package/extensions/@palexplorer/analytics/extension.json +27 -0
  9. package/extensions/@palexplorer/analytics/index.js +186 -0
  10. package/extensions/@palexplorer/analytics/test/analytics.test.js +82 -0
  11. package/extensions/@palexplorer/audit/extension.json +17 -0
  12. package/extensions/@palexplorer/audit/index.js +2 -0
  13. package/extensions/@palexplorer/auth-email/extension.json +17 -0
  14. package/extensions/@palexplorer/auth-email/index.js +102 -0
  15. package/extensions/@palexplorer/auth-oauth/extension.json +16 -0
  16. package/extensions/@palexplorer/auth-oauth/index.js +199 -0
  17. package/extensions/@palexplorer/chat/extension.json +17 -0
  18. package/extensions/@palexplorer/chat/index.js +2 -0
  19. package/extensions/@palexplorer/discovery/extension.json +16 -0
  20. package/extensions/@palexplorer/discovery/index.js +111 -0
  21. package/extensions/@palexplorer/email-notifications/extension.json +23 -0
  22. package/extensions/@palexplorer/email-notifications/index.js +242 -0
  23. package/extensions/@palexplorer/explorer-integration/extension.json +13 -0
  24. package/extensions/@palexplorer/explorer-integration/index.js +122 -0
  25. package/extensions/@palexplorer/groups/extension.json +17 -0
  26. package/extensions/@palexplorer/groups/index.js +2 -0
  27. package/extensions/@palexplorer/networks/extension.json +17 -0
  28. package/extensions/@palexplorer/networks/index.js +2 -0
  29. package/extensions/@palexplorer/share-links/extension.json +17 -0
  30. package/extensions/@palexplorer/share-links/index.js +2 -0
  31. package/extensions/@palexplorer/sync/extension.json +17 -0
  32. package/extensions/@palexplorer/sync/index.js +2 -0
  33. package/extensions/@palexplorer/user-mgmt/extension.json +17 -0
  34. package/extensions/@palexplorer/user-mgmt/index.js +2 -0
  35. package/extensions/@palexplorer/vfs/extension.json +17 -0
  36. package/extensions/@palexplorer/vfs/index.js +167 -0
  37. package/lib/capabilities.js +263 -0
  38. package/lib/commands/analytics.js +175 -0
  39. package/lib/commands/api-keys.js +131 -0
  40. package/lib/commands/audit.js +235 -0
  41. package/lib/commands/auth.js +137 -0
  42. package/lib/commands/backup.js +76 -0
  43. package/lib/commands/billing.js +148 -0
  44. package/lib/commands/chat.js +217 -0
  45. package/lib/commands/cloud-backup.js +231 -0
  46. package/lib/commands/comment.js +99 -0
  47. package/lib/commands/completion.js +203 -0
  48. package/lib/commands/compliance.js +218 -0
  49. package/lib/commands/config.js +136 -0
  50. package/lib/commands/connect.js +44 -0
  51. package/lib/commands/dept.js +294 -0
  52. package/lib/commands/device.js +146 -0
  53. package/lib/commands/download.js +226 -0
  54. package/lib/commands/explorer.js +178 -0
  55. package/lib/commands/extension.js +970 -0
  56. package/lib/commands/favorite.js +90 -0
  57. package/lib/commands/federation.js +270 -0
  58. package/lib/commands/file.js +533 -0
  59. package/lib/commands/group.js +271 -0
  60. package/lib/commands/gui-share.js +29 -0
  61. package/lib/commands/init.js +61 -0
  62. package/lib/commands/invite.js +59 -0
  63. package/lib/commands/list.js +59 -0
  64. package/lib/commands/log.js +116 -0
  65. package/lib/commands/nearby.js +108 -0
  66. package/lib/commands/network.js +251 -0
  67. package/lib/commands/notify.js +198 -0
  68. package/lib/commands/org.js +273 -0
  69. package/lib/commands/pal.js +180 -0
  70. package/lib/commands/permissions.js +216 -0
  71. package/lib/commands/pin.js +97 -0
  72. package/lib/commands/protocol.js +357 -0
  73. package/lib/commands/rbac.js +147 -0
  74. package/lib/commands/recover.js +36 -0
  75. package/lib/commands/register.js +171 -0
  76. package/lib/commands/relay.js +131 -0
  77. package/lib/commands/remote.js +368 -0
  78. package/lib/commands/revoke.js +50 -0
  79. package/lib/commands/scanner.js +280 -0
  80. package/lib/commands/schedule.js +344 -0
  81. package/lib/commands/scim.js +203 -0
  82. package/lib/commands/search.js +181 -0
  83. package/lib/commands/serve.js +438 -0
  84. package/lib/commands/server.js +350 -0
  85. package/lib/commands/share-link.js +199 -0
  86. package/lib/commands/share.js +323 -0
  87. package/lib/commands/sso.js +200 -0
  88. package/lib/commands/status.js +136 -0
  89. package/lib/commands/stream.js +562 -0
  90. package/lib/commands/su.js +187 -0
  91. package/lib/commands/sync.js +827 -0
  92. package/lib/commands/transfers.js +152 -0
  93. package/lib/commands/uninstall.js +188 -0
  94. package/lib/commands/update.js +204 -0
  95. package/lib/commands/user.js +276 -0
  96. package/lib/commands/vfs.js +84 -0
  97. package/lib/commands/web.js +52 -0
  98. package/lib/commands/webhook.js +180 -0
  99. package/lib/commands/whoami.js +59 -0
  100. package/lib/commands/workspace.js +121 -0
  101. package/lib/core/accessLog.js +54 -0
  102. package/lib/core/analytics.js +99 -0
  103. package/lib/core/backup.js +84 -0
  104. package/lib/core/billing.js +336 -0
  105. package/lib/core/bitfieldStore.js +53 -0
  106. package/lib/core/connectionManager.js +182 -0
  107. package/lib/core/dhtDiscovery.js +148 -0
  108. package/lib/core/discoveryClient.js +408 -0
  109. package/lib/core/extensionAnalyzer.js +357 -0
  110. package/lib/core/extensionSandbox.js +250 -0
  111. package/lib/core/extensionWorkerHost.js +166 -0
  112. package/lib/core/extensions.js +1082 -0
  113. package/lib/core/fileDiff.js +69 -0
  114. package/lib/core/groups.js +119 -0
  115. package/lib/core/identity.js +340 -0
  116. package/lib/core/mdnsService.js +126 -0
  117. package/lib/core/networks.js +81 -0
  118. package/lib/core/permissions.js +109 -0
  119. package/lib/core/pro.js +27 -0
  120. package/lib/core/resolver.js +74 -0
  121. package/lib/core/serverList.js +224 -0
  122. package/lib/core/sharePolicy.js +69 -0
  123. package/lib/core/shares.js +325 -0
  124. package/lib/core/signalingServer.js +441 -0
  125. package/lib/core/streamTransport.js +106 -0
  126. package/lib/core/su.js +55 -0
  127. package/lib/core/syncEngine.js +264 -0
  128. package/lib/core/syncState.js +159 -0
  129. package/lib/core/transfers.js +259 -0
  130. package/lib/core/users.js +225 -0
  131. package/lib/core/vfs.js +216 -0
  132. package/lib/core/webServer.js +702 -0
  133. package/lib/core/webrtcStream.js +396 -0
  134. package/lib/crypto/chatEncryption.js +57 -0
  135. package/lib/crypto/shareEncryption.js +195 -0
  136. package/lib/crypto/sharePassword.js +35 -0
  137. package/lib/crypto/streamEncryption.js +189 -0
  138. package/lib/package.json +1 -0
  139. package/lib/protocol/envelope.js +271 -0
  140. package/lib/protocol/handler.js +191 -0
  141. package/lib/protocol/index.js +27 -0
  142. package/lib/protocol/messages.js +247 -0
  143. package/lib/protocol/negotiation.js +127 -0
  144. package/lib/protocol/policy.js +142 -0
  145. package/lib/protocol/router.js +86 -0
  146. package/lib/protocol/sync.js +122 -0
  147. package/lib/utils/cli.js +15 -0
  148. package/lib/utils/config.js +123 -0
  149. package/lib/utils/configIntegrity.js +87 -0
  150. package/lib/utils/downloadDir.js +9 -0
  151. package/lib/utils/explorer.js +83 -0
  152. package/lib/utils/format.js +12 -0
  153. package/lib/utils/help.js +357 -0
  154. package/lib/utils/logger.js +103 -0
  155. package/lib/utils/torrent.js +203 -0
  156. package/package.json +71 -0
@@ -0,0 +1,178 @@
1
+ import chalk from 'chalk';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+
8
+ export default function explorerCommand(program) {
9
+ const explorer = program
10
+ .command('explorer')
11
+ .description('manage file manager integration (Explorer, Finder, Nautilus)')
12
+ .addHelpText('after', `
13
+ Examples:
14
+ $ pe explorer install Add "Share with Palexplorer" to context menu
15
+ $ pe explorer uninstall Remove context menu entry
16
+ `);
17
+
18
+ explorer
19
+ .command('install')
20
+ .description('install "Share with Pal" context menu for your platform')
21
+ .action(async () => {
22
+ const platform = process.platform;
23
+ try {
24
+ if (platform === 'win32') {
25
+ const { installExplorerContextMenu } = await import('../utils/explorer.js');
26
+ await installExplorerContextMenu();
27
+ console.log(chalk.green('Windows Explorer context menu installed.'));
28
+ } else if (platform === 'darwin') {
29
+ await installFinderAction();
30
+ } else if (platform === 'linux') {
31
+ await installNautilusScript();
32
+ } else {
33
+ console.log(chalk.yellow(`No file manager integration available for ${platform}.`));
34
+ }
35
+ } catch (err) {
36
+ console.error(chalk.red('Failed to install context menu:'), err.message);
37
+ }
38
+ });
39
+
40
+ explorer
41
+ .command('uninstall')
42
+ .description('remove "Share with Pal" context menu')
43
+ .action(async () => {
44
+ const platform = process.platform;
45
+ try {
46
+ if (platform === 'win32') {
47
+ const { uninstallExplorerContextMenu } = await import('../utils/explorer.js');
48
+ await uninstallExplorerContextMenu();
49
+ console.log(chalk.green('Windows Explorer context menu removed.'));
50
+ } else if (platform === 'darwin') {
51
+ await uninstallFinderAction();
52
+ } else if (platform === 'linux') {
53
+ await uninstallNautilusScript();
54
+ } else {
55
+ console.log(chalk.yellow(`No file manager integration available for ${platform}.`));
56
+ }
57
+ } catch (err) {
58
+ console.error(chalk.red('Failed to remove context menu:'), err.message);
59
+ }
60
+ });
61
+ }
62
+
63
+ async function installFinderAction() {
64
+ const workflowDir = path.join(
65
+ process.env.HOME,
66
+ 'Library/Services/Share with Pal.workflow/Contents'
67
+ );
68
+ const plistPath = path.join(workflowDir, 'Info.plist');
69
+
70
+ fs.mkdirSync(workflowDir, { recursive: true });
71
+
72
+ const plist = `<?xml version="1.0" encoding="UTF-8"?>
73
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
74
+ <plist version="1.0">
75
+ <dict>
76
+ <key>NSServices</key>
77
+ <array>
78
+ <dict>
79
+ <key>NSMenuItem</key>
80
+ <dict>
81
+ <key>default</key>
82
+ <string>Share with Pal</string>
83
+ </dict>
84
+ <key>NSMessage</key>
85
+ <string>runWorkflowAsService</string>
86
+ <key>NSSendFileTypes</key>
87
+ <array>
88
+ <string>public.item</string>
89
+ </array>
90
+ </dict>
91
+ </array>
92
+ </dict>
93
+ </plist>
94
+ `;
95
+
96
+ const script = `#!/bin/bash
97
+ # Share with Pal - Finder Quick Action
98
+ for f in "$@"; do
99
+ pe share "$f"
100
+ done
101
+ `;
102
+
103
+ const documentWf = path.join(workflowDir, 'document.wflow');
104
+ fs.writeFileSync(plistPath, plist);
105
+ fs.writeFileSync(path.join(workflowDir, 'share-with-pal.sh'), script, { mode: 0o755 });
106
+
107
+ console.log(chalk.green('Finder Quick Action created at:'));
108
+ console.log(chalk.gray(` ${workflowDir}`));
109
+ console.log(chalk.yellow('Note: You may need to enable it in System Preferences > Extensions > Finder.'));
110
+ }
111
+
112
+ async function uninstallFinderAction() {
113
+ const workflowDir = path.join(
114
+ process.env.HOME,
115
+ 'Library/Services/Share with Pal.workflow'
116
+ );
117
+ if (fs.existsSync(workflowDir)) {
118
+ fs.rmSync(workflowDir, { recursive: true });
119
+ console.log(chalk.green('Finder Quick Action removed.'));
120
+ } else {
121
+ console.log(chalk.yellow('Finder Quick Action not found.'));
122
+ }
123
+ }
124
+
125
+ async function installNautilusScript() {
126
+ const scriptDir = path.join(process.env.HOME, '.local/share/nautilus/scripts');
127
+ const scriptPath = path.join(scriptDir, 'Share with Pal');
128
+
129
+ fs.mkdirSync(scriptDir, { recursive: true });
130
+
131
+ const script = `#!/bin/bash
132
+ # Share with Pal - Nautilus Script
133
+ IFS=$'\\n'
134
+ for f in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
135
+ pe share "$f"
136
+ done
137
+ `;
138
+
139
+ fs.writeFileSync(scriptPath, script, { mode: 0o755 });
140
+
141
+ // Also create a .desktop action
142
+ const desktopActionsDir = path.join(process.env.HOME, '.local/share/file-manager/actions');
143
+ fs.mkdirSync(desktopActionsDir, { recursive: true });
144
+
145
+ const desktopAction = `[Desktop Action]
146
+ Name=Share with Pal
147
+ Icon=palexplorer
148
+ Exec=pe share %f
149
+ MimeType=inode/directory;application/octet-stream;
150
+ `;
151
+
152
+ fs.writeFileSync(path.join(desktopActionsDir, 'palexplorer-share.desktop'), desktopAction);
153
+
154
+ console.log(chalk.green('Nautilus script installed at:'));
155
+ console.log(chalk.gray(` ${scriptPath}`));
156
+ console.log(chalk.yellow('Right-click a file in Nautilus > Scripts > Share with Pal'));
157
+ }
158
+
159
+ async function uninstallNautilusScript() {
160
+ const scriptPath = path.join(process.env.HOME, '.local/share/nautilus/scripts/Share with Pal');
161
+ const actionPath = path.join(process.env.HOME, '.local/share/file-manager/actions/palexplorer-share.desktop');
162
+
163
+ let removed = false;
164
+ if (fs.existsSync(scriptPath)) {
165
+ fs.unlinkSync(scriptPath);
166
+ removed = true;
167
+ }
168
+ if (fs.existsSync(actionPath)) {
169
+ fs.unlinkSync(actionPath);
170
+ removed = true;
171
+ }
172
+
173
+ if (removed) {
174
+ console.log(chalk.green('Nautilus integration removed.'));
175
+ } else {
176
+ console.log(chalk.yellow('No Nautilus integration found.'));
177
+ }
178
+ }