Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
93c02fe
Use Array.fromAsync
404Wolf Jul 5, 2025
ed4a1bb
Add windows test
404Wolf Jul 5, 2025
914d1d7
Use joins
404Wolf Jul 5, 2025
93c10fa
Fix regex for item names
404Wolf Jul 5, 2025
a726f9d
Use npm:slash
404Wolf Jul 5, 2025
0340bc4
Slash in more places
404Wolf Jul 5, 2025
daa5bcd
Use custom function
404Wolf Jul 5, 2025
16a705f
Update tests to use new sdk methods
404Wolf Jul 5, 2025
41de7af
More sdk utility functions
404Wolf Jul 5, 2025
41b55b2
More sdk utility usage
404Wolf Jul 5, 2025
e275c72
Add assertPathEquals
404Wolf Jul 5, 2025
1a7c11c
Use posix for pull
404Wolf Jul 5, 2025
668d93c
Normalize for the exists method
404Wolf Jul 5, 2025
f4017bf
More assertPathEquals
404Wolf Jul 5, 2025
4be9e62
More fixes
404Wolf Jul 5, 2025
7d3971c
Fix remix test
404Wolf Jul 5, 2025
bd572c4
Format code
404Wolf Jul 5, 2025
fca50f8
Don't import sdk
404Wolf Jul 5, 2025
7f89037
Clean up sdk
404Wolf Jul 5, 2025
bf444de
Use sdk utils
404Wolf Jul 5, 2025
7565fd6
Remove 'sdk' usages
404Wolf Jul 6, 2025
8c63de1
Fix param usage
404Wolf Jul 6, 2025
8e40f1f
Tick version
404Wolf Jul 6, 2025
2bb29ce
Merge branch 'main' into fix-windows-paths
404Wolf Sep 10, 2025
5063a19
Bump version
404Wolf Sep 10, 2025
2ea575b
Remove sanitizers
404Wolf Sep 10, 2025
7c5843b
Dont sanitize more tests
404Wolf Sep 10, 2025
65b8f77
Format
404Wolf Sep 10, 2025
89b783f
Update tests
404Wolf Sep 10, 2025
74d5961
Update tests
404Wolf Sep 10, 2025
951bb72
Fix test
404Wolf Sep 17, 2025
a2d07f4
Use assertpathequals
404Wolf Sep 23, 2025
73a81e4
Format code
404Wolf Sep 23, 2025
ccfc5bc
Normalize paths
404Wolf Sep 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ jobs:
env:
VAL_TOWN_API_KEY: ${{ secrets.VAL_TOWN_API_KEY }}

test-windows:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Run deno tests
uses: nick-fields/retry@v3
with:
command: deno task test:lib
max_attempts: 2
timeout_seconds: 2000
env:
VAL_TOWN_API_KEY: ${{ secrets.VAL_TOWN_API_KEY }}

test-mac:
runs-on: ubuntu-latest

Expand Down
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/denoland/deno/348900b8b79f4a434cab4c74b3bc8d4d2fa8ee74/cli/schemas/config-file.v1.json",
"name": "@valtown/vt",
"description": "The Val Town CLI",
"version": "0.1.36",
"version": "0.1.37",
"exports": "./vt.ts",
"license": "MIT",
"tasks": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"@std/encoding": "jsr:@std/encoding@^1.0.7",
"@std/fs": "jsr:@std/fs@^1.0.13",
"@std/path": "jsr:@std/path@^1.0.8",
"@valtown/sdk": "jsr:@valtown/sdk@^1.0.0",
"@valtown/sdk": "jsr:@valtown/sdk@^1.5.0",
"xdg-portable": "jsr:@404wolf/xdg-portable@^0.1.0",
"highlight.js": "npm:highlight.js@^11.11.1",
"strip-ansi": "npm:strip-ansi@^7.1.0",
Expand Down
16 changes: 9 additions & 7 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions src/cmd/lib/branch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Command } from "@cliffy/command";
import sdk, { branchNameToBranch } from "~/sdk.ts";
import {
branchNameToBranch,
deleteBranch as deleteValbranch,
listBranches as listValBranches,
} from "~/sdk.ts";
import { colors } from "@cliffy/ansi/colors";
import { Table } from "@cliffy/table";
import { doWithSpinner } from "~/cmd/utils.ts";
Expand All @@ -10,9 +14,7 @@ async function listBranches(vt: VTClient) {
return await doWithSpinner("Loading branches...", async (spinner) => {
const vtState = await vt.getMeta().loadVtState();

const branches = await Array.fromAsync(
sdk.vals.branches.list(vtState.val.id, {}),
);
const branches = await listValBranches(vtState.val.id);

const formatter = new Intl.DateTimeFormat("en-US", {
year: "numeric",
Expand Down Expand Up @@ -88,7 +90,7 @@ async function deleteBranch(vt: VTClient, toDeleteName: string) {
);
}

await sdk.vals.branches.delete(meta.val.id, toDeleteBranch.id);
await deleteValbranch(meta.val.id, toDeleteBranch.id);
spinner.succeed(`Branch '${toDeleteName}' has been deleted.`);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/lib/browse.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Command } from "@cliffy/command";
import open from "open";
import sdk from "~/sdk.ts";
import { doWithSpinner } from "~/cmd/utils.ts";
import VTClient from "~/vt/vt/VTClient.ts";
import { findVtRoot } from "~/vt/vt/utils.ts";
import { delay } from "@std/async";
import { getBranch } from "~/sdk.ts";

export const browseCmd = new Command()
.name("browse")
Expand All @@ -14,7 +14,7 @@ export const browseCmd = new Command()
const vt = VTClient.from(await findVtRoot(Deno.cwd()));

const vtState = await vt.getMeta().loadVtState();
const branch = await sdk.vals.branches.retrieve(
const branch = await getBranch(
vtState.val.id,
vtState.branch.id,
);
Expand Down
17 changes: 10 additions & 7 deletions src/cmd/lib/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { findVtRoot } from "~/vt/vt/utils.ts";
import { colors } from "@cliffy/ansi/colors";
import { Confirm } from "@cliffy/prompt";
import { tty } from "@cliffy/ansi/tty";
import sdk, {
import {
branchNameToBranch,
getBranch,
getCurrentUser,
getLatestVersion,
getVal,
} from "~/sdk.ts";
import { displayFileStateChanges } from "~/cmd/lib/utils/displayFileStatus.ts";
import {
Expand Down Expand Up @@ -78,9 +80,10 @@ export const checkoutCmd = new Command()
const user = await getCurrentUser();

// Get the current branch data
const currentBranchData = await sdk.vals.branches
.retrieve(vtState.val.id, vtState.branch.id)
.catch(() => null);
const currentBranchData = await getBranch(
vtState.val.id,
vtState.branch.id,
).catch(() => null);

// Handle the case where the current branch no longer exists as a
// special case
Expand Down Expand Up @@ -129,7 +132,7 @@ export const checkoutCmd = new Command()
// If they are creating a new branch, ensure that they are the owner of this Val
if (
isNewBranch &&
(await sdk.vals.retrieve(vtState.val.id)).author.id !== user.id
(await getVal(vtState.val.id)).author.id !== user.id
) {
throw new Error(
"You are not the owner of this Val, you cannot make a new branch.",
Expand Down Expand Up @@ -173,8 +176,8 @@ export const checkoutCmd = new Command()
const dangerousLocalChanges = dryCheckoutResult
.fileStateChanges
.filter(
(fileStatus) => (fileStatus.status == "deleted" ||
fileStatus.status == "modified"),
(fileStatus) => (fileStatus.status === "deleted" ||
fileStatus.status === "modified"),
)
.merge(
priorVtStatus
Expand Down
10 changes: 3 additions & 7 deletions src/cmd/lib/clone.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from "@cliffy/command";
import { Input } from "@cliffy/prompt/input";
import { colors } from "@cliffy/ansi/colors";
import sdk, { getCurrentUser } from "~/sdk.ts";
import { getCurrentUser, listMyVals } from "~/sdk.ts";
import VTClient from "~/vt/vt/VTClient.ts";
import { relative } from "@std/path";
import { doWithSpinner, getClonePath } from "~/cmd/utils.ts";
Expand All @@ -10,7 +10,6 @@ import { Confirm } from "@cliffy/prompt";
import { ensureAddEditorFiles } from "~/cmd/lib/utils/messages.ts";
import { parseValUrl } from "~/cmd/parsing.ts";
import { DEFAULT_BRANCH_NAME, DEFAULT_EDITOR_TEMPLATE } from "~/consts.ts";
import { arrayFromAsyncN } from "~/utils.ts";

export const cloneCmd = new Command()
.name("clone")
Expand Down Expand Up @@ -55,13 +54,10 @@ export const cloneCmd = new Command()

// If no Val URI is provided, show interactive Val selection
if (!valUri) {
const vals = await doWithSpinner(
const [vals, _] = await doWithSpinner(
"Loading vals...",
async (spinner) => {
const [allVals, _] = await arrayFromAsyncN(
sdk.me.vals.list({}),
500,
);
const allVals = await listMyVals(100);
spinner.stop();
return allVals;
},
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/lib/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Command } from "@cliffy/command";
import VTClient from "~/vt/vt/VTClient.ts";
import { doWithSpinner } from "~/cmd/utils.ts";
import { Confirm } from "@cliffy/prompt";
import sdk from "~/sdk.ts";
import { findVtRoot } from "~/vt/vt/utils.ts";
import { colors } from "@cliffy/ansi/colors";
import { getVal } from "~/sdk.ts";

export const deleteCmd = new Command()
.name("delete")
Expand All @@ -19,7 +19,7 @@ export const deleteCmd = new Command()
const vtState = await meta.loadVtState();

// Get Val name for display
const val = await sdk.vals.retrieve(vtState.val.id);
const val = await getVal(vtState.val.id);
const valName = val.name;

// Confirm deletion unless --force is used
Expand Down
8 changes: 2 additions & 6 deletions src/cmd/lib/list.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Command } from "@cliffy/command";
import { colors } from "@cliffy/ansi/colors";
import { Table } from "@cliffy/table";
import sdk from "~/sdk.ts";
import { doWithSpinner } from "~/cmd/utils.ts";
import { arrayFromAsyncN } from "~/utils.ts";
import { listMyVals } from "~/sdk.ts";

const VAL_LIST_BATCH_SIZE = 20;

Expand All @@ -20,10 +19,7 @@ export const listCmd = new Command()
"Loading Val list...",
async (spinner) => {
const batchSize = allVals ? Infinity : VAL_LIST_BATCH_SIZE;
const result = await arrayFromAsyncN(
sdk.me.vals.list({ offset }),
batchSize,
);
const result = await listMyVals(batchSize, offset);
spinner.stop();
return result;
},
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/lib/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from "@cliffy/command";
import { doWithSpinner } from "~/cmd/utils.ts";
import VTClient from "~/vt/vt/VTClient.ts";
import { findVtRoot } from "~/vt/vt/utils.ts";
import sdk, { getCurrentUser } from "~/sdk.ts";
import { getCurrentUser, getVal } from "~/sdk.ts";
import { displayFileStateChanges } from "~/cmd/lib/utils/displayFileStatus.ts";
import { noChangesDryRunMsg } from "~/cmd/lib/utils/messages.ts";

Expand All @@ -27,7 +27,7 @@ export const pushCmd = new Command()
const user = await getCurrentUser();

const vtState = await vt.getMeta().loadVtState();
const valToPush = await sdk.vals.retrieve(vtState.val.id);
const valToPush = await getVal(vtState.val.id);
if (valToPush.author.id !== user.id) {
throw new Error(
"You are not the owner of this Val, you cannot push." +
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/lib/status.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Command } from "@cliffy/command";
import { colors } from "@cliffy/ansi/colors";
import sdk from "~/sdk.ts";
import { FIRST_VERSION_NUMBER } from "~/consts.ts";
import { doWithSpinner } from "~/cmd/utils.ts";
import VTClient from "~/vt/vt/VTClient.ts";
import { findVtRoot } from "~/vt/vt/utils.ts";
import { displayFileStateChanges } from "~/cmd/lib/utils/displayFileStatus.ts";
import { displayVersionRange } from "~/cmd/lib/utils/displayVersionRange.ts";
import { getBranch } from "~/sdk.ts";

export const statusCmd = new Command()
.name("status")
Expand All @@ -17,7 +17,7 @@ export const statusCmd = new Command()

const vtState = await vt.getMeta().loadVtState();

const currentBranch = await sdk.vals.branches.retrieve(
const currentBranch = await getBranch(
vtState.val.id,
vtState.branch.id,
);
Expand Down
12 changes: 9 additions & 3 deletions src/cmd/lib/watch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Command } from "@cliffy/command";
import VTClient from "~/vt/vt/VTClient.ts";
import { colors } from "@cliffy/ansi/colors";
import sdk, { getCurrentUser, getLatestVersion, listValItems } from "~/sdk.ts";
import {
getBranch,
getCurrentUser,
getLatestVersion,
getVal,
listValItems,
} from "~/sdk.ts";
import { FIRST_VERSION_NUMBER } from "~/consts.ts";
import { doWithSpinner } from "~/cmd/utils.ts";
import { findVtRoot } from "~/vt/vt/utils.ts";
Expand All @@ -28,12 +34,12 @@ export const watchCmd = new Command()

// Get initial branch information for display
const vtState = await vt.getMeta().loadVtState();
const currentBranch = await sdk.vals.branches.retrieve(
const currentBranch = await getBranch(
vtState.val.id,
vtState.branch.id,
);

const valToWatch = await sdk.vals.retrieve(vtState.val.id);
const valToWatch = await getVal(vtState.val.id);
if (valToWatch.author.id !== user.id) {
console.log(valToWatch.author.id, user.id);
throw new Error(
Expand Down
Loading