@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 +30 -22
- package/package.json +1 -1
- package/src/cmd/env.ts +11 -7
- package/src/cmd/secret.ts +13 -9
- package/src/cmd/sshkeys.ts +22 -18
- package/src/cmd/start.ts +16 -12
- package/src/cmd/stop.ts +13 -9
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.
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
127
|
+
consola.success("Secret deleted successfully");
|
|
128
|
+
} catch {
|
|
129
|
+
consola.error("Failed to delete secret");
|
|
130
|
+
}
|
|
127
131
|
}
|
package/src/cmd/sshkeys.ts
CHANGED
|
@@ -152,25 +152,29 @@ export async function putKeys(
|
|
|
152
152
|
return `${header}${maskedBody}${footer}`.replace(/\n/g, "\\n");
|
|
153
153
|
})();
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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;
|