@gricha/perry 0.1.0 → 0.1.2
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/dist/client/ws-shell.js +5 -1
- package/dist/index.js +15 -0
- package/package.json +1 -1
package/dist/client/ws-shell.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'ws';
|
|
2
2
|
import { spawn } from 'child_process';
|
|
3
|
+
import { DEFAULT_AGENT_PORT } from '../shared/constants';
|
|
3
4
|
export function isLocalWorker(worker) {
|
|
4
5
|
const host = worker
|
|
5
6
|
.replace(/^https?:\/\//, '')
|
|
@@ -125,6 +126,9 @@ export function getTerminalWSUrl(worker, workspaceName) {
|
|
|
125
126
|
base = `http://${base}`;
|
|
126
127
|
}
|
|
127
128
|
const wsProtocol = base.startsWith('https://') ? 'wss://' : 'ws://';
|
|
128
|
-
|
|
129
|
+
let host = base.replace(/^https?:\/\//, '');
|
|
130
|
+
if (!host.includes(':')) {
|
|
131
|
+
host = `${host}:${DEFAULT_AGENT_PORT}`;
|
|
132
|
+
}
|
|
129
133
|
return `${wsProtocol}${host}/rpc/terminal/${encodeURIComponent(workspaceName)}`;
|
|
130
134
|
}
|
package/dist/index.js
CHANGED
|
@@ -452,6 +452,21 @@ function handleError(err) {
|
|
|
452
452
|
else if (err instanceof Error) {
|
|
453
453
|
console.error(`Error: ${err.message}`);
|
|
454
454
|
}
|
|
455
|
+
else if (err && typeof err === 'object') {
|
|
456
|
+
const errObj = err;
|
|
457
|
+
if ('message' in errObj && typeof errObj.message === 'string') {
|
|
458
|
+
console.error(`Error: ${errObj.message}`);
|
|
459
|
+
}
|
|
460
|
+
else if ('code' in errObj) {
|
|
461
|
+
console.error(`Error: ${String(errObj.code)}`);
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
console.error(`Error: ${JSON.stringify(err)}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
else if (err !== undefined && err !== null) {
|
|
468
|
+
console.error(`Error: ${String(err)}`);
|
|
469
|
+
}
|
|
455
470
|
else {
|
|
456
471
|
console.error('An unknown error occurred');
|
|
457
472
|
}
|