Open History to see the last commit
1import { assert, it } from "@effect/vitest";
2
3import { formatCliCommand } from "./invocation.ts";
4
5it("formats package runner commands from their cache entry paths", () => {
6 for (const [entryPath, expected] of [
7 ["/home/theo/.npm/_npx/abc123/node_modules/t3/dist/bin.mjs", "npx t3 serve"],
8 [
9 "C:\\Users\\theo\\AppData\\Local\\npm-cache\\_npx\\abc\\node_modules\\t3\\dist\\bin.mjs",
10 "npx t3 serve",
11 ],
12 ["/home/theo/.cache/pnpm/dlx/abc/node_modules/t3/dist/bin.mjs", "pnpm dlx t3 serve"],
13 [
14 "/home/theo/.local/share/pnpm/.pnpm/dlx/abc/node_modules/t3/dist/bin.mjs",
15 "pnpm dlx t3 serve",
16 ],
17 [
18 "C:\\Users\\theo\\AppData\\Local\\pnpm-cache\\dlx\\abc\\node_modules\\t3\\dist\\bin.mjs",
19 "pnpm dlx t3 serve",
20 ],
21 ["/home/theo/.bun/install/cache/t3@0.0.31/dist/bin.mjs", "bunx t3 serve"],
22 ["/tmp/bunx-1000-t3@latest/node_modules/t3/dist/bin.mjs", "bunx t3 serve"],
23 [
24 "C:\\Users\\theo\\AppData\\Local\\Temp\\bunx-0-t3@latest\\node_modules\\t3\\dist\\bin.mjs",
25 "bunx t3 serve",
26 ],
27 ] as const) {
28 assert.equal(formatCliCommand({ subcommand: "serve", entryPath, version: "0.0.31" }), expected);
29 }
30});
31
32it("treats stable installs as direct invocations", () => {
33 for (const entryPath of [
34 "/usr/local/lib/node_modules/t3/dist/bin.mjs",
35 "/home/theo/Code/work/t3code/apps/server/dist/bin.mjs",
36 "/home/theo/.t3/runtime/0.0.31/node_modules/t3/dist/bin.mjs",
37 "",
38 ]) {
39 assert.equal(
40 formatCliCommand({ subcommand: "serve", entryPath, version: "0.0.31" }),
41 "t3 serve",
42 );
43 }
44});
45
46it("re-suggests the prerelease channel only for prerelease builds", () => {
47 for (const [version, expected] of [
48 ["0.0.31-nightly.20260729", "npx t3@nightly serve"],
49 ["0.0.31-preview.20260729.1", "npx t3@preview serve"],
50 ["0.0.31-foo-preview.20260729.1", "npx t3 serve"],
51 ["0.0.31", "npx t3 serve"],
52 ] as const) {
53 assert.equal(
54 formatCliCommand({
55 subcommand: "serve",
56 entryPath: "/home/theo/.npm/_npx/abc123/node_modules/t3/dist/bin.mjs",
57 version,
58 }),
59 expected,
60 );
61 }
62});
63
64it("formats serve suggestions to match the launching command", () => {
65 assert.equal(
66 formatCliCommand({
67 subcommand: "serve",
68 entryPath: "/home/theo/.npm/_npx/abc/node_modules/t3/dist/bin.mjs",
69 version: "0.0.31-nightly.20260729",
70 }),
71 "npx t3@nightly serve",
72 );
73 assert.equal(
74 formatCliCommand({
75 subcommand: "serve",
76 entryPath: "/tmp/bunx-1000-t3@latest/node_modules/t3/dist/bin.mjs",
77 version: "0.0.31",
78 }),
79 "bunx t3 serve",
80 );
81 assert.equal(
82 formatCliCommand({
83 subcommand: "serve",
84 entryPath: "/usr/local/lib/node_modules/t3/dist/bin.mjs",
85 version: "0.0.31-nightly.20260729",
86 }),
87 "t3 serve",
88 );
89});