Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 2a1e69e

Browse files
feat: use tsx (#298)
1 parent 0b6b213 commit 2a1e69e

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

cypress/support/commands.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ function login({
4949
email?: string;
5050
} = {}) {
5151
cy.then(() => ({ email })).as("user");
52-
cy.exec(
53-
`npx ts-node -r tsconfig-paths/register ./cypress/support/create-user.ts "${email}"`,
54-
).then(({ stdout }) => {
55-
const cookieValue = stdout
56-
.replace(/.*<cookie>(?<cookieValue>.*)<\/cookie>.*/s, "$<cookieValue>")
57-
.trim();
58-
cy.setCookie("__session", cookieValue);
59-
});
52+
cy.exec(`npx tsx ./cypress/support/create-user.ts "${email}"`).then(
53+
({ stdout }) => {
54+
const cookieValue = stdout
55+
.replace(/.*<cookie>(?<cookieValue>.*)<\/cookie>.*/s, "$<cookieValue>")
56+
.trim();
57+
cy.setCookie("__session", cookieValue);
58+
},
59+
);
6060
return cy.get("@user");
6161
}
6262

@@ -75,9 +75,7 @@ function cleanupUser({ email }: { email?: string } = {}) {
7575
}
7676

7777
function deleteUserByEmail(email: string) {
78-
cy.exec(
79-
`npx ts-node -r tsconfig-paths/register ./cypress/support/delete-user.ts "${email}"`,
80-
);
78+
cy.exec(`npx tsx ./cypress/support/delete-user.ts "${email}"`);
8179
cy.clearCookie("__session");
8280
}
8381

cypress/support/create-user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Use this to create a new user and login with that user
22
// Simply call this with:
3-
// npx ts-node -r tsconfig-paths/register ./cypress/support/create-user.ts [email protected],
3+
// npx tsx ./cypress/support/create-user.ts [email protected],
44
// and it will log out the cookie value you can use to interact with the server
55
// as that new user.
66

cypress/support/delete-user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Use this to delete a user by their email
22
// Simply call this with:
3-
// npx ts-node -r tsconfig-paths/register ./cypress/support/delete-user.ts [email protected],
3+
// npx tsx ./cypress/support/delete-user.ts [email protected],
44
// and that user will get deleted
55

66
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@
7777
"prisma": "^5.19.1",
7878
"start-server-and-test": "^2.0.7",
7979
"tailwindcss": "^3.4.10",
80-
"ts-node": "^10.9.2",
81-
"tsconfig-paths": "^4.2.0",
80+
"tsx": "^4.19.0",
8281
"typescript": "^5.6.2",
8382
"vite": "^5.4.3",
8483
"vite-tsconfig-paths": "^4.3.2",
@@ -88,6 +87,6 @@
8887
"node": ">=18.0.0"
8988
},
9089
"prisma": {
91-
"seed": "ts-node -r tsconfig-paths/register prisma/seed.ts"
90+
"seed": "tsx prisma/seed.ts"
9291
}
9392
}

remix.init/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const semver = require("semver");
1010
const cleanupCypressFiles = ({ fileEntries, packageManager }) =>
1111
fileEntries.flatMap(([filePath, content]) => {
1212
const newContent = content.replace(
13-
new RegExp("npx ts-node", "g"),
14-
packageManager.name === "bun" ? "bun" : `${packageManager.exec} ts-node`,
13+
new RegExp("npx tsx", "g"),
14+
packageManager.name === "bun" ? "bun" : `${packageManager.exec} tsx`,
1515
);
1616

1717
return [fs.writeFile(filePath, newContent)];
@@ -87,13 +87,13 @@ const updatePackageJson = ({ APP_NAME, packageJson, packageManager }) => {
8787
name: APP_NAME,
8888
devDependencies:
8989
packageManager.name === "bun"
90-
? removeUnusedDependencies(devDependencies, ["ts-node"])
90+
? removeUnusedDependencies(devDependencies, ["tsx"])
9191
: devDependencies,
9292
prisma: {
9393
...prisma,
9494
seed:
9595
packageManager.name === "bun"
96-
? prismaSeed.replace("ts-node", "bun")
96+
? prismaSeed.replace("tsx", "bun")
9797
: prismaSeed,
9898
},
9999
scripts,

0 commit comments

Comments
 (0)