Skip to content

Commit 1cfbfd2

Browse files
authored
Migrate from "Projects" to "Vals" (#119)
* Migrate to new sdk * Change use of 'project' to 'val' * Change capitalization * Update readme * Remove more 'project' references * Fix remix tests * Fix interactive clone test * Remix without editor files * Fix spelling case issue * Fix remix tests * Fix push test * Fix casing for remixing * Have tests inherit permissions * Fix remix tests again * Fix tests that required editor prompt * Fix vt watch test * Don't do concurrent cmd test * Make watch simulation faster * Improve watch test * Add more grace * Add a deadline to tests * Continue using project on state for now, but inject vals * Change how zod recasting works * Slow down watch test * Cap val listing count * Reduce concurrency amount * Fix list test * Clean up modified files deadline method * Add another deadline * Provide multiple yeses * Improve tests * Make autoconfirmation more robust * Increase deadline * Slow down watch * Add retry to test * Fix uncaught writer close error * Do concurrent test * Change delays * Make sequential again * Fix modified test * Load from .env before config json * Allow listing all * Fix checkout message spacing * Fix checkout test * Improve resource sanitization * Format code * Clean up code * Restore disabling resource sanitization * Increase timeout * Make bearer checking more accurate * Clean up tests * Fix checkout test confirmation * Remove weird catch * Change casing of 'val' * No more parallel cli tests * Restore parallel tests * Fix test workflow * A --paralleldd schema migration test * Tick version * Don't do concurrent cmd test
1 parent 06ea697 commit 1cfbfd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2026
-1959
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Run deno tests
2323
uses: nick-fields/retry@v3
2424
with:
25-
command: deno task test:lib --parallel
25+
command: deno task test:lib
2626
max_attempts: 2
2727
timeout_seconds: 2000
2828
env:
@@ -44,7 +44,7 @@ jobs:
4444
max_attempts: 2
4545
timeout_seconds: 2000
4646
env:
47-
VAL_TOWN_API_KEY: ${{ secrets.VAL_TOWN_API_KEY }}
47+
VAL_TOWN_API_KEY: ${{ secrets.VAL_TOWN_API_KEY_2 }}
4848

4949
test-publish:
5050
runs-on: ubuntu-latest

README.md

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# Val Town CLI
22

3-
`vt` is the official CLI to work with projects on the
4-
[Val Town](https://val.town) platform.
5-
6-
![Vt in action!](https://wolf-imagedumper.web.val.run/blob/blob_file_1744915159083_recording.gif)
3+
VT is a cli to work with Vals in the [Val Town](https://val.town) platform.
74

85
```
96
Usage: vt
10-
Version: x.x.xx
7+
Version:x0.x.xx
118
129
Options:
1310
@@ -16,19 +13,19 @@ Options:
1613
1714
Commands:
1815
19-
clone [projectUri] [targetDir] [branchName] - Clone a val town project
20-
push - Push local changes to a val town project
21-
pull - Pull the latest changes for a val town project
22-
status - Show the working tree status
23-
branch - List or delete branches
24-
checkout [existingBranchName] - Check out a different branch
25-
watch - Watch for changes and automatically sync with Val Town
26-
browse - Open a project in a web browser
27-
create <projectName> [targetDir] - Create a new Val Town project
28-
remix <fromProjectUri> [newProjectName] [targetDir] - Remix a Val Town project
29-
config - Manage vt configuration
30-
delete - Delete a Val Town project
31-
list - List all your Val Town projects
16+
clone [valUri] [targetDir] [branchName] - Clone a Val
17+
push - Push local changes to a Val
18+
pull - Pull the latest changes for the current Val
19+
status - Show the working tree status
20+
branch - List or delete branches
21+
checkout [existingBranchName] - Check out a different branch
22+
watch - Watch for changes and automatically sync with Val Town
23+
browse - Open a Val's main page in a web browser
24+
create <valName> [targetDir] - Create a new Val
25+
remix <fromValUri> [newValName] [targetDir] - Remix a Val
26+
config - Manage vt configuration
27+
delete - Delete the current Val
28+
list - List all your Vals
3229
```
3330

3431
## Installation
@@ -50,10 +47,10 @@ To authenticate with `val.town`, just run `vt`, and you should get the dialog
5047
```
5148
Welcome to the Val Town CLI!
5249
53-
VT is a companion CLI to interface with Val Town projects.
50+
VT is a companion CLI to interface with Val Town vals.
5451
5552
With this CLI, you can:
56-
- Create and manage Val Town projects
53+
- Create and manage Val Town vals
5754
- Push and pull changes between your local system and Val Town
5855
- Watch a directory to keep it automatically synced with Val Town
5956
- And more!
@@ -63,12 +60,12 @@ Welcome to the Val Town CLI!
6360
? Would you like to open val.town/settings/api in a browser to get an API key? (y/n) ›
6461
```
6562

66-
Respond yes, and ensure you select to create an API key with user read & project
63+
Respond yes, and ensure you select to create an API key with user read & val
6764
read+write permissions.
6865

6966
Alternatively, you can set the `VAL_TOWN_API_KEY` environment variable to
7067
authenticate. Either as an environment variable, or place it in a .env in your
71-
project.
68+
val.
7269

7370
Now you can run `vt` again to confirm everything is working:
7471

@@ -83,24 +80,24 @@ vt x.x.xx
8380
Let's walk through a complete workflow to get you familiar with the Val Town
8481
CLI.
8582

86-
First, let's remix a nice starting project.
83+
First, let's remix a nice starting val.
8784

8885
```bash
8986
$ vt remix std/reactHonoStarter myNewWebsite
9087

91-
√ Remixed "@std/reactHonoStarter" to public project "@you/myNewWebsite"
88+
√ Remixed "@std/reactHonoStarter" to public Val "@you/myNewWebsite"
9289

9390
$ cd myNewWebsite
9491
```
9592

96-
![Your new project!](https://wolf-imagedumper.web.val.run/blob/blob_file_1744521935175_7f04c371-d619-4062-8bc6-941d56a23eed.png)
93+
![Your new val!](https://wolf-imagedumper.web.val.run/blob/blob_file_1744521935175_7f04c371-d619-4062-8bc6-941d56a23eed.png)
9794

98-
Alternatively, you can use `vt create` to create a new empty project. If you
99-
don't specify a path, the name of the project will automatically be used.
95+
Alternatively, you can use `vt create` to create a new empty val. If you don't
96+
specify a path, the name of the Val will automatically be used.
10097

101-
When you `remix`, `create`, or `clone` a project, `vt` creates a `.vt` that
102-
tracks your project metadata. You can think of this like `.git`, it is not meant
103-
to be manually edited and is used for internal bookkeeping.
98+
When you `remix`, `create`, or `clone` a val, `vt` creates a `.vt` that tracks
99+
your Val metadata. You can think of this like `.git`, it is not meant to be
100+
manually edited and is used for internal bookkeeping.
104101

105102
`vt` also creates an ignore file, `.vtignore`, which works like `.gitignore`,
106103
and a `deno.json`. By having a `deno.json`, your editor will be able to make use
@@ -112,17 +109,17 @@ If you use some other editor, you'll want to head over to
112109
[Deno's editor set up](https://docs.deno.com/runtime/getting_started/setup_your_environment/)
113110
guide and find how to configure yours.
114111

115-
If you use packages in your project, your editor may warn you that you do not
116-
have those packages installed (or "cached"). Occasionally you'll want to run
117-
`deno cache .` to make sure that all the libraries you use in your Val Town
118-
project are installed locally.
112+
If you use packages in your val, your editor may warn you that you do not have
113+
those packages installed (or "cached"). Occasionally you'll want to run
114+
`deno cache .` to make sure that all the libraries you use in your Val Town val
115+
are installed locally.
119116

120117
![Making changes](https://wolf-imagedumper.web.val.run/blob/blob_file_1744522002151_95d9436e-9e8b-4361-880f-bf6d7e970741.png)
121118

122-
Let's start editing our project! Fire up your favorite editor, and then make a
119+
Let's start editing our val! Fire up your favorite editor, and then make a
123120
change to `README.md`.
124121

125-
Now, let's upload this file to your project with `vt push`
122+
Now, let's upload this file to your Val with `vt push`
126123

127124
```bash
128125
Pushed:
@@ -152,7 +149,7 @@ until you run `vt push`. If you don't want this behavior, then you can delete
152149
them and add `deno.json` and `.vtignore` to the `.vtignore`(the `.vtignore` will
153150
respect itself being ignored!).
154151

155-
![Browse the project on the website](https://wolf-imagedumper.web.val.run/blob/blob_file_1744522722640_recording.gif)
152+
![Browse the Val on the website](https://wolf-imagedumper.web.val.run/blob/blob_file_1744522722640_recording.gif)
156153

157154
Now run `vt browse` to see your file in the Val Town website UI. We advise you
158155
use `vt` in conjunction with the Val Town website. The CLI can do a lot, but not
@@ -182,7 +179,7 @@ Changes pushed:
182179
√ Successfully pushed local changes
183180
```
184181

185-
Now, if we return to our browser we can see that an http val has been created.
182+
Now, if we return to our browser we can see that an http Val has been created.
186183
It's erroring, let's fix that. Write a simple handler to the file:
187184

188185
```ts
@@ -210,16 +207,15 @@ Oftentimes you'll end up in a workflow that looks like
210207
4. Repeat
211208

212209
`vt`'s solution to tightening this loop is `vt watch`. With `vt watch`, `vt`
213-
will automatically run `vt push` when any project files are modified
214-
**locally**.
210+
will automatically run `vt push` when any Val files are modified **locally**.
215211

216212
To get automatic website reloading, check out
217213
[this live reload middleware](https://www.val.town/x/stevekrouse/live-reload)
218214
that works by polling Val Town for updates.
219215

220216
### Branching Out
221217

222-
One common Val Town project workflow is branching out. `vt`'s `checkout` and
218+
One common Val Town Val workflow is branching out. `vt`'s `checkout` and
223219
`branch` command work the same as `git`'s.
224220

225221
- `vt checkout <branchName>` checks out the branch as it is on Val Town. You
@@ -234,8 +230,8 @@ One common Val Town project workflow is branching out. `vt`'s `checkout` and
234230

235231
### Management
236232

237-
- `vt list` lists all your Val Town projects
238-
- `vt delete` deletes the current project of the folder you are in (with
233+
- `vt list` lists all your Val Town vals
234+
- `vt delete` deletes the current Val of the folder you are in (with
239235
confirmation).
240236

241237
## Configuration
@@ -244,18 +240,18 @@ One common Val Town project workflow is branching out. `vt`'s `checkout` and
244240
`<System Configuration Directory>/vt/config.yaml`. Right now, this file only
245241
stores your `config.yaml`, and some experimental options.
246242

247-
This config can also be overridden locally for specific projects by, when you
248-
are in a `.vt` directory, using `vt config set [-g for global]` (otherwise the
249-
global config is modified). This can be useful if someone shares an API key with
250-
you so you can collaborate on a project. You can view all configuration options
251-
with `vt config`, and all the ones you've set with `vt config get`.
243+
This config can also be overridden locally for specific vals by, when you are in
244+
a `.vt` directory, using `vt config set [-g for global]` (otherwise the global
245+
config is modified). This can be useful if someone shares an API key with you so
246+
you can collaborate on a val. You can view all configuration options with
247+
`vt config`, and all the ones you've set with `vt config get`.
252248

253249
Right now, we offer the following configuration options:
254250

255251
- `dangerousOperations.confirmation`: Whether to do confirmations on actions
256252
that might cause you to lose local state, like `vt pull`.
257-
- `editorTemplate`: The project URI for the editor files that you are prompted
258-
about when you run a `vt clone`, `vt remix`, or `vt create`.
253+
- `editorTemplate`: The Val URI for the editor files that you are prompted about
254+
when you run a `vt clone`, `vt remix`, or `vt create`.
259255

260256
## LLMs
261257

deno.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"$schema": "https://raw.githubusercontent.com/denoland/deno/348900b8b79f4a434cab4c74b3bc8d4d2fa8ee74/cli/schemas/config-file.v1.json",
33
"name": "@valtown/vt",
44
"description": "The Val Town CLI",
5-
"version": "0.1.24",
5+
"version": "0.1.25",
66
"exports": "./vt.ts",
77
"license": "MIT",
88
"tasks": {
99
"run": "./vt.ts",
10-
"test": "deno task test:lib --parallel && deno task test:cmd",
11-
"test:cmd": "env DENO_NO_PROMPT=1 deno test -A ./src/cmd",
12-
"test:lib": "env DENO_NO_PROMPT=1 deno test -A ./src/vt/lib",
10+
"test": "deno task test:lib && deno task test:cmd",
11+
"test:cmd": "env DENO_NO_PROMPT=1 deno test -A --trace-leaks --fail-fast ./src/cmd",
12+
"test:lib": "env DENO_NO_PROMPT=1 deno test -A --trace-leaks --parallel ./src/vt/lib",
1313
"check": "env DENO_NO_PROMPT=1 deno check .",
1414
"fmt:check": "env DENO_NO_PROMPT=1 deno fmt --check"
1515
},
@@ -31,7 +31,7 @@
3131
"@std/encoding": "jsr:@std/encoding@^1.0.7",
3232
"@std/fs": "jsr:@std/fs@^1.0.13",
3333
"@std/path": "jsr:@std/path@^1.0.8",
34-
"@valtown/sdk": "jsr:@valtown/sdk@^0.38.0",
34+
"@valtown/sdk": "jsr:@valtown/sdk@^1.0.0",
3535
"xdg-portable": "jsr:@404wolf/xdg-portable@^0.1.0",
3636
"highlight.js": "npm:highlight.js@^11.11.1",
3737
"strip-ansi": "npm:strip-ansi@^7.1.0",

deno.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/flows/onboard.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ function welcomeToVt(): void {
2222

2323
console.log(wrap(
2424
colors.bold("VT") +
25-
" is a companion CLI to interface with Val Town projects.",
25+
" is a companion CLI to interface with Val Town vals.",
2626
{ width: DEFAULT_WRAP_WIDTH },
2727
));
2828
console.log();
2929

3030
console.log(wrap("With this CLI, you can:", { width: DEFAULT_WRAP_WIDTH }));
3131

3232
[
33-
"Create and manage Val Town projects",
33+
"Create and manage Val Town vals",
3434
"Push and pull changes between your local system and Val Town",
3535
"Watch a directory to keep it automatically synced with Val Town",
3636
"And more!",
@@ -68,15 +68,15 @@ export async function onboardFlow(
6868
});
6969

7070
if (goToWebsite) {
71-
console.log("Ensure you select user read & project read+write permissions");
71+
console.log("Ensure you select user read & Val read+write permissions");
7272
await delay(500);
7373
await open(GET_API_KEY_URL);
7474
console.log(`Browser opened to ${GET_API_KEY_URL}`);
7575
} else {
7676
console.log();
7777
console.log(
7878
"You can get an API key at " + GET_API_KEY_URL +
79-
" with project read/write permissions",
79+
" with Val read/write permissions",
8080
);
8181
}
8282

src/cmd/lib/branch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ async function listBranches(vt: VTClient) {
1111
return await doWithSpinner("Loading branches...", async (spinner) => {
1212
const meta = await vt.getMeta().loadVtState();
1313

14-
const branches: ValTown.Projects.BranchListResponse[] = [];
14+
const branches: ValTown.Vals.BranchListResponse[] = [];
1515
// deno-fmt-ignore
16-
for await (const file of (await sdk.projects.branches.list(meta.project.id, {}))) branches.push(file);
16+
for await (const file of (await sdk.vals.branches.list(meta.val.id, {}))) branches.push(file);
1717

1818
const formatter = new Intl.DateTimeFormat("en-US", {
1919
year: "numeric",
@@ -67,7 +67,7 @@ async function deleteBranch(vt: VTClient, toDeleteName: string) {
6767

6868
await doWithSpinner("Deleting branch...", async (spinner) => {
6969
const toDeleteBranch = await branchNameToBranch(
70-
meta.project.id,
70+
meta.val.id,
7171
toDeleteName,
7272
);
7373
if (toDeleteBranch.id === meta.branch.id) {
@@ -76,7 +76,7 @@ async function deleteBranch(vt: VTClient, toDeleteName: string) {
7676
);
7777
}
7878

79-
await sdk.projects.branches.delete(meta.project.id, toDeleteBranch.id);
79+
await sdk.vals.branches.delete(meta.val.id, toDeleteBranch.id);
8080
spinner.succeed(`Branch '${toDeleteName}' has been deleted.`);
8181
});
8282
}

src/cmd/lib/browse.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ import { delay } from "@std/async";
88

99
export const browseCmd = new Command()
1010
.name("browse")
11-
.description("Open a project in a web browser")
11+
.description("Open a Val's main page in a web browser")
1212
.option("--no-browser", "Print destination url instead of opening browser")
1313
.action(async ({ browser }: { browser?: boolean }) => {
1414
const vt = VTClient.from(await findVtRoot(Deno.cwd()));
1515

16-
const state = await vt.getMeta().loadVtState();
17-
const branch = await sdk.projects.branches.retrieve(
18-
state.project.id,
19-
state.branch.id,
16+
const vtState = await vt.getMeta().loadVtState();
17+
const branch = await sdk.vals.branches.retrieve(
18+
vtState.val.id,
19+
vtState.branch.id,
2020
);
2121

2222
if (browser) {
23-
await doWithSpinner("Opening project url...", async (spinner) => {
23+
await doWithSpinner("Opening Val url...", async (spinner) => {
2424
await open(branch.links.html);
2525
await delay(150);
26-
spinner.succeed(`Project url opened in browser:\n${branch.links.html}`);
26+
spinner.succeed(`Val url opened in browser:\n${branch.links.html}`);
2727
});
2828
} else console.log(`${branch.links.html}`);
2929
});

0 commit comments

Comments
 (0)