Skip to content

Commit 7565fd6

Browse files
committed
Remove 'sdk' usages
1 parent bf444de commit 7565fd6

File tree

19 files changed

+183
-165
lines changed

19 files changed

+183
-165
lines changed

src/cmd/lib/clone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const cloneCmd = new Command()
5454

5555
// If no Val URI is provided, show interactive Val selection
5656
if (!valUri) {
57-
const vals = await doWithSpinner(
57+
const [vals, _] = await doWithSpinner(
5858
"Loading vals...",
5959
async (spinner) => {
6060
const allVals = await listMyVals(100);

src/cmd/lib/list.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Command } from "@cliffy/command";
22
import { colors } from "@cliffy/ansi/colors";
33
import { Table } from "@cliffy/table";
4-
import sdk from "~/sdk.ts";
54
import { doWithSpinner } from "~/cmd/utils.ts";
6-
import { arrayFromAsyncN } from "~/utils.ts";
5+
import { listMyVals } from "~/sdk.ts";
76

87
const VAL_LIST_BATCH_SIZE = 20;
98

@@ -20,10 +19,7 @@ export const listCmd = new Command()
2019
"Loading Val list...",
2120
async (spinner) => {
2221
const batchSize = allVals ? Infinity : VAL_LIST_BATCH_SIZE;
23-
const result = await arrayFromAsyncN(
24-
sdk.me.vals.list({ offset }),
25-
batchSize,
26-
);
22+
const result = await listMyVals(batchSize, offset);
2723
spinner.stop();
2824
return result;
2925
},

src/cmd/lib/watch.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { Command } from "@cliffy/command";
22
import VTClient from "~/vt/vt/VTClient.ts";
33
import { colors } from "@cliffy/ansi/colors";
4-
import sdk, { getCurrentUser, getLatestVersion, listValItems } from "~/sdk.ts";
4+
import {
5+
getBranch,
6+
getCurrentUser,
7+
getLatestVersion,
8+
getVal,
9+
listValItems,
10+
} from "~/sdk.ts";
511
import { FIRST_VERSION_NUMBER } from "~/consts.ts";
612
import { doWithSpinner } from "~/cmd/utils.ts";
713
import { findVtRoot } from "~/vt/vt/utils.ts";
@@ -28,12 +34,12 @@ export const watchCmd = new Command()
2834

2935
// Get initial branch information for display
3036
const vtState = await vt.getMeta().loadVtState();
31-
const currentBranch = await sdk.vals.branches.retrieve(
37+
const currentBranch = await getBranch(
3238
vtState.val.id,
3339
vtState.branch.id,
3440
);
3541

36-
const valToWatch = await sdk.vals.retrieve(vtState.val.id);
42+
const valToWatch = await getVal(vtState.val.id);
3743
if (valToWatch.author.id !== user.id) {
3844
console.log(valToWatch.author.id, user.id);
3945
throw new Error(

src/cmd/tests/branch_test.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { doWithNewVal } from "~/vt/lib/tests/utils.ts";
22
import { join } from "@std/path";
3-
import sdk from "~/sdk.ts";
43
import { runVtCommand } from "~/cmd/tests/utils.ts";
54
import { assert, assertEquals, assertStringIncludes } from "@std/assert";
65
import type ValTown from "@valtown/sdk";
76
import { doWithTempDir } from "~/vt/lib/utils/misc.ts";
7+
import { createNewBranch, createValItem, deleteBranch } from "~/sdk.ts";
88

99
Deno.test({
1010
name: "branch list command shows all branches",
@@ -15,12 +15,12 @@ Deno.test({
1515
const fullPath = join(tmpDir, val.name);
1616

1717
await t.step("create additional branches", async () => {
18-
await sdk.vals.branches.create(
18+
await createNewBranch(
1919
val.id,
2020
{ name: "feature", branchId: mainBranch.id },
2121
);
2222

23-
await sdk.vals.branches.create(
23+
await createNewBranch(
2424
val.id,
2525
{ name: "development", branchId: mainBranch.id },
2626
);
@@ -60,18 +60,18 @@ Deno.test({
6060
let featureBranch: ValTown.Vals.BranchListResponse;
6161

6262
await t.step("create feature branch", async () => {
63-
featureBranch = await sdk.vals.branches.create(
63+
featureBranch = await createNewBranch(
6464
val.id,
65-
{ name: "feature-to-delete", branchId: mainBranch.id },
65+
{ name: "feature", branchId: mainBranch.id },
6666
);
6767

68-
await sdk.vals.files.create(
68+
await createValItem(
6969
val.id,
7070
{
71-
path: "feaature.ts",
72-
content: "console.log('Feature branch file');",
73-
branch_id: featureBranch.id,
74-
type: "script",
71+
path: "feature.txt",
72+
branchId: featureBranch.id,
73+
content: "feature branch file",
74+
type: "file",
7575
},
7676
);
7777
});
@@ -85,25 +85,25 @@ Deno.test({
8585
"verify feature branch exists in branch list",
8686
async () => {
8787
const [listOutput] = await runVtCommand(["branch"], fullPath);
88-
assertStringIncludes(listOutput, "feature-to-delete");
88+
assertStringIncludes(listOutput, "feature");
8989
},
9090
);
9191

9292
await t.step("delete the feature branch", async () => {
9393
const [deleteOutput] = await runVtCommand(
94-
["branch", "-D", "feature-to-delete"],
94+
["branch", "-D", "feature"],
9595
fullPath,
9696
);
9797
assertStringIncludes(
9898
deleteOutput,
99-
"Branch 'feature-to-delete' has been deleted",
99+
"Branch 'feature' has been deleted",
100100
);
101101
});
102102

103103
await t.step("verify branch is no longer listed", async () => {
104104
const [listOutput] = await runVtCommand(["branch"], fullPath);
105105
assert(
106-
!listOutput.includes("feature-to-delete"),
106+
!listOutput.includes("feature"),
107107
"deleted branch should not appear in branch list",
108108
);
109109
});
@@ -180,29 +180,29 @@ Deno.test({
180180
let tempBranch: ValTown.Vals.BranchListResponse;
181181

182182
await t.step("create temporary branch", async () => {
183-
tempBranch = await sdk.vals.branches.create(
183+
tempBranch = await createNewBranch(
184184
val.id,
185-
{ name: "temp-branch", branchId: mainBranch.id },
185+
{ name: "temp", branchId: mainBranch.id },
186186
);
187187

188-
await sdk.vals.files.create(
188+
await createValItem(
189189
val.id,
190190
{
191-
path: "temp.ts",
192-
content: "// Temporary file",
193-
branch_id: tempBranch.id,
194-
type: "script",
191+
path: "temp.txt",
192+
branchId: tempBranch.id,
193+
content: "temp branch file",
194+
type: "file",
195195
},
196196
);
197197
});
198198

199199
await t.step("clone and checkout to temporary branch", async () => {
200200
await runVtCommand(["clone", val.name, "--no-editor-files"], tmpDir);
201-
await runVtCommand(["checkout", "temp-branch"], fullPath);
201+
await runVtCommand(["checkout", "temp"], fullPath);
202202
});
203203

204204
await t.step("delete the branch remotely", async () => {
205-
await sdk.vals.branches.delete(val.id, tempBranch.id);
205+
await deleteBranch(val.id, tempBranch.id);
206206
});
207207

208208
await t.step("run branch command and verify warning", async () => {

0 commit comments

Comments
 (0)