@pocketenv/cli 0.3.1 → 0.3.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 +11 -1
- package/package.json +1 -1
- package/src/cmd/create.ts +2 -0
- package/src/cmd/start.ts +2 -0
- package/src/lib/expandRepo.ts +9 -0
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.3.
|
|
25
|
+
var version = "0.3.2";
|
|
26
26
|
|
|
27
27
|
async function getAccessToken() {
|
|
28
28
|
const tokenPath = path.join(os.homedir(), ".pocketenv", "token.json");
|
|
@@ -410,8 +410,17 @@ async function ssh(sandboxName) {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
function expandRepo(repo) {
|
|
414
|
+
const githubMatch = repo.match(/^github:([^/]+\/[^/]+)$/);
|
|
415
|
+
if (githubMatch) return `https://github.com/${githubMatch[1]}`;
|
|
416
|
+
const tangledMatch = repo.match(/^tangled:([^/]+\/[^/]+)$/);
|
|
417
|
+
if (tangledMatch) return `https://tangled.org/${tangledMatch[1]}`;
|
|
418
|
+
return repo;
|
|
419
|
+
}
|
|
420
|
+
|
|
413
421
|
async function start(name, { ssh: ssh$1, repo }) {
|
|
414
422
|
const token = await getAccessToken();
|
|
423
|
+
if (repo) repo = expandRepo(repo);
|
|
415
424
|
try {
|
|
416
425
|
await client.post(
|
|
417
426
|
"/xrpc/io.pocketenv.sandbox.startSandbox",
|
|
@@ -582,6 +591,7 @@ async function createSandbox(name, {
|
|
|
582
591
|
repo
|
|
583
592
|
}) {
|
|
584
593
|
const token = await getAccessToken();
|
|
594
|
+
if (repo) repo = expandRepo(repo);
|
|
585
595
|
if (["deno", "vercel", "daytona"].includes(provider || "")) {
|
|
586
596
|
consola.error(
|
|
587
597
|
`This Sandbox Runtime is temporarily disabled. ${c.primary(provider ?? "")}`
|
package/package.json
CHANGED
package/src/cmd/create.ts
CHANGED
|
@@ -4,6 +4,7 @@ import getAccessToken from "../lib/getAccessToken";
|
|
|
4
4
|
import type { Sandbox } from "../types/sandbox";
|
|
5
5
|
import connectToSandbox from "./ssh";
|
|
6
6
|
import { c } from "../theme";
|
|
7
|
+
import { expandRepo } from "../lib/expandRepo";
|
|
7
8
|
|
|
8
9
|
async function createSandbox(
|
|
9
10
|
name: string,
|
|
@@ -20,6 +21,7 @@ async function createSandbox(
|
|
|
20
21
|
},
|
|
21
22
|
) {
|
|
22
23
|
const token = await getAccessToken();
|
|
24
|
+
if (repo) repo = expandRepo(repo);
|
|
23
25
|
|
|
24
26
|
if (["deno", "vercel", "daytona"].includes(provider || "")) {
|
|
25
27
|
consola.error(
|
package/src/cmd/start.ts
CHANGED
|
@@ -4,12 +4,14 @@ import getAccessToken from "../lib/getAccessToken";
|
|
|
4
4
|
import { client } from "../client";
|
|
5
5
|
import { env } from "../lib/env";
|
|
6
6
|
import connectToSandbox from "./ssh";
|
|
7
|
+
import { expandRepo } from "../lib/expandRepo";
|
|
7
8
|
|
|
8
9
|
async function start(
|
|
9
10
|
name: string,
|
|
10
11
|
{ ssh, repo }: { ssh?: boolean; repo?: string },
|
|
11
12
|
) {
|
|
12
13
|
const token = await getAccessToken();
|
|
14
|
+
if (repo) repo = expandRepo(repo);
|
|
13
15
|
|
|
14
16
|
try {
|
|
15
17
|
await client.post(
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function expandRepo(repo: string): string {
|
|
2
|
+
const githubMatch = repo.match(/^github:([^/]+\/[^/]+)$/);
|
|
3
|
+
if (githubMatch) return `https://github.com/${githubMatch[1]}`;
|
|
4
|
+
|
|
5
|
+
const tangledMatch = repo.match(/^tangled:([^/]+\/[^/]+)$/);
|
|
6
|
+
if (tangledMatch) return `https://tangled.org/${tangledMatch[1]}`;
|
|
7
|
+
|
|
8
|
+
return repo;
|
|
9
|
+
}
|