@pocketenv/cli 0.2.1 → 0.2.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/index.js CHANGED
@@ -22,7 +22,7 @@ import relativeTime from 'dayjs/plugin/relativeTime.js';
22
22
  import { password, editor, input } from '@inquirer/prompts';
23
23
  import sodium from 'libsodium-wrappers';
24
24
 
25
- var version = "0.2.1";
25
+ var version = "0.2.2";
26
26
 
27
27
  async function getAccessToken() {
28
28
  const tokenPath = path.join(os.homedir(), ".pocketenv", "token.json");
@@ -67,18 +67,22 @@ const client = axios.create({
67
67
 
68
68
  async function start(name) {
69
69
  const token = await getAccessToken();
70
- await client.post("/xrpc/io.pocketenv.sandbox.startSandbox", void 0, {
71
- params: {
72
- id: name
73
- },
74
- headers: {
75
- Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
76
- }
77
- });
78
- consola.success(`Sandbox ${chalk.greenBright(name)} started`);
79
- consola.log(
80
- `Run ${chalk.greenBright(`pocketenv console ${name}`)} to access the sandbox`
81
- );
70
+ try {
71
+ await client.post("/xrpc/io.pocketenv.sandbox.startSandbox", void 0, {
72
+ params: {
73
+ id: name
74
+ },
75
+ headers: {
76
+ Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
77
+ }
78
+ });
79
+ consola.success(`Sandbox ${chalk.greenBright(name)} started`);
80
+ consola.log(
81
+ `Run ${chalk.greenBright(`pocketenv console ${name}`)} to access the sandbox`
82
+ );
83
+ } catch {
84
+ consola.error("Failed to start sandbox");
85
+ }
82
86
  }
83
87
 
84
88
  async function login(handle) {
@@ -528,15 +532,19 @@ async function listSandboxes() {
528
532
 
529
533
  async function stop(name) {
530
534
  const token = await getAccessToken();
531
- await client.post("/xrpc/io.pocketenv.sandbox.stopSandbox", void 0, {
532
- params: {
533
- id: name
534
- },
535
- headers: {
536
- Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
537
- }
538
- });
539
- consola.success(`Sandbox ${chalk.greenBright(name)} stopped`);
535
+ try {
536
+ await client.post("/xrpc/io.pocketenv.sandbox.stopSandbox", void 0, {
537
+ params: {
538
+ id: name
539
+ },
540
+ headers: {
541
+ Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
542
+ }
543
+ });
544
+ consola.success(`Sandbox ${chalk.greenBright(name)} stopped`);
545
+ } catch {
546
+ consola.error("Failed to stop sandbox");
547
+ }
540
548
  }
541
549
 
542
550
  async function createSandbox(name, {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "bin": {
5
5
  "pocketenv": "dist/index.js"
6
6
  },
7
- "version": "0.2.1",
7
+ "version": "0.2.2",
8
8
  "type": "module",
9
9
  "keywords": [
10
10
  "sandbox",
package/src/cmd/env.ts CHANGED
@@ -115,12 +115,16 @@ export async function putEnv(sandbox: string, key: string, value: string) {
115
115
  export async function deleteEnv(id: string) {
116
116
  const token = await getAccessToken();
117
117
 
118
- await client.post("/xrpc/io.pocketenv.variable.deleteVariable", undefined, {
119
- params: { id },
120
- headers: {
121
- Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
122
- },
123
- });
118
+ try {
119
+ await client.post("/xrpc/io.pocketenv.variable.deleteVariable", undefined, {
120
+ params: { id },
121
+ headers: {
122
+ Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
123
+ },
124
+ });
124
125
 
125
- consola.success("Variable deleted successfully");
126
+ consola.success("Variable deleted successfully");
127
+ } catch {
128
+ consola.error("Failed to delete variable");
129
+ }
126
130
  }
package/src/cmd/secret.ts CHANGED
@@ -114,14 +114,18 @@ export async function putSecret(sandbox: string, key: string) {
114
114
  export async function deleteSecret(id: string) {
115
115
  const token = await getAccessToken();
116
116
 
117
- await client.post("/xrpc/io.pocketenv.secret.deleteSecret", undefined, {
118
- params: {
119
- id,
120
- },
121
- headers: {
122
- Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
123
- },
124
- });
117
+ try {
118
+ await client.post("/xrpc/io.pocketenv.secret.deleteSecret", undefined, {
119
+ params: {
120
+ id,
121
+ },
122
+ headers: {
123
+ Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
124
+ },
125
+ });
125
126
 
126
- consola.success("Secret deleted successfully");
127
+ consola.success("Secret deleted successfully");
128
+ } catch {
129
+ consola.error("Failed to delete secret");
130
+ }
127
131
  }
@@ -152,25 +152,29 @@ export async function putKeys(
152
152
  return `${header}${maskedBody}${footer}`.replace(/\n/g, "\\n");
153
153
  })();
154
154
 
155
- await client.post(
156
- "/xrpc/io.pocketenv.sandbox.putSshKeys",
157
- {
158
- id: data.sandbox.id,
159
- privateKey: encryptedPrivateKey,
160
- publicKey,
161
- redacted,
162
- },
163
- {
164
- headers: {
165
- Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
155
+ try {
156
+ await client.post(
157
+ "/xrpc/io.pocketenv.sandbox.putSshKeys",
158
+ {
159
+ id: data.sandbox.id,
160
+ privateKey: encryptedPrivateKey,
161
+ publicKey,
162
+ redacted,
166
163
  },
167
- },
168
- );
164
+ {
165
+ headers: {
166
+ Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
167
+ },
168
+ },
169
+ );
169
170
 
170
- consola.log("\nPrivate Key:");
171
- consola.log(redacted.replace(/\\n/g, "\n"));
172
- consola.log("\nPublic Key:");
173
- consola.log(publicKey, "\n");
171
+ consola.log("\nPrivate Key:");
172
+ consola.log(redacted.replace(/\\n/g, "\n"));
173
+ consola.log("\nPublic Key:");
174
+ consola.log(publicKey, "\n");
174
175
 
175
- consola.success("SSH keys saved successfully!");
176
+ consola.success("SSH keys saved successfully!");
177
+ } catch {
178
+ consola.error("Failed to save SSH keys");
179
+ }
176
180
  }
package/src/cmd/start.ts CHANGED
@@ -7,19 +7,23 @@ import { env } from "../lib/env";
7
7
  async function start(name: string) {
8
8
  const token = await getAccessToken();
9
9
 
10
- await client.post("/xrpc/io.pocketenv.sandbox.startSandbox", undefined, {
11
- params: {
12
- id: name,
13
- },
14
- headers: {
15
- Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
16
- },
17
- });
10
+ try {
11
+ await client.post("/xrpc/io.pocketenv.sandbox.startSandbox", undefined, {
12
+ params: {
13
+ id: name,
14
+ },
15
+ headers: {
16
+ Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
17
+ },
18
+ });
18
19
 
19
- consola.success(`Sandbox ${chalk.greenBright(name)} started`);
20
- consola.log(
21
- `Run ${chalk.greenBright(`pocketenv console ${name}`)} to access the sandbox`,
22
- );
20
+ consola.success(`Sandbox ${chalk.greenBright(name)} started`);
21
+ consola.log(
22
+ `Run ${chalk.greenBright(`pocketenv console ${name}`)} to access the sandbox`,
23
+ );
24
+ } catch {
25
+ consola.error("Failed to start sandbox");
26
+ }
23
27
  }
24
28
 
25
29
  export default start;
package/src/cmd/stop.ts CHANGED
@@ -7,16 +7,20 @@ import { env } from "../lib/env";
7
7
  async function stop(name: string) {
8
8
  const token = await getAccessToken();
9
9
 
10
- await client.post("/xrpc/io.pocketenv.sandbox.stopSandbox", undefined, {
11
- params: {
12
- id: name,
13
- },
14
- headers: {
15
- Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
16
- },
17
- });
10
+ try {
11
+ await client.post("/xrpc/io.pocketenv.sandbox.stopSandbox", undefined, {
12
+ params: {
13
+ id: name,
14
+ },
15
+ headers: {
16
+ Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
17
+ },
18
+ });
18
19
 
19
- consola.success(`Sandbox ${chalk.greenBright(name)} stopped`);
20
+ consola.success(`Sandbox ${chalk.greenBright(name)} stopped`);
21
+ } catch {
22
+ consola.error("Failed to stop sandbox");
23
+ }
20
24
  }
21
25
 
22
26
  export default stop;