Skip to content

Commit

Permalink
feat: use tsx (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey authored Oct 2, 2024
1 parent 966d0fa commit 17dc382
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
20 changes: 9 additions & 11 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ function login({
email?: string;
} = {}) {
cy.then(() => ({ email })).as("user");
cy.exec(
`npx ts-node -r tsconfig-paths/register ./cypress/support/create-user.ts "${email}"`,
).then(({ stdout }) => {
const cookieValue = stdout
.replace(/.*<cookie>(?<cookieValue>.*)<\/cookie>.*/s, "$<cookieValue>")
.trim();
cy.setCookie("__session", cookieValue);
});
cy.exec(`npx tsx ./cypress/support/create-user.ts "${email}"`).then(
({ stdout }) => {
const cookieValue = stdout
.replace(/.*<cookie>(?<cookieValue>.*)<\/cookie>.*/s, "$<cookieValue>")
.trim();
cy.setCookie("__session", cookieValue);
},
);
return cy.get("@user");
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion cypress/support/create-user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Use this to create a new user and login with that user
// Simply call this with:
// npx ts-node -r tsconfig-paths/register ./cypress/support/create-user.ts [email protected]
// npx tsx ./cypress/support/create-user.ts [email protected]
// and it will log out the cookie value you can use to interact with the server
// as that new user.

Expand Down
2 changes: 1 addition & 1 deletion cypress/support/delete-user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Use this to delete a user by their email
// Simply call this with:
// npx ts-node -r tsconfig-paths/register ./cypress/support/delete-user.ts [email protected]
// npx tsx ./cypress/support/delete-user.ts [email protected]
// and that user will get deleted

import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@
"prisma": "^5.19.1",
"start-server-and-test": "^2.0.7",
"tailwindcss": "^3.4.10",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.6.2",
"vite": "^5.4.3",
"vite-tsconfig-paths": "^4.3.2",
Expand All @@ -105,6 +103,6 @@
"node": ">=18.0.0"
},
"prisma": {
"seed": "ts-node -r tsconfig-paths/register prisma/seed.ts"
"seed": "tsx prisma/seed.ts"
}
}
8 changes: 4 additions & 4 deletions remix.init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const semver = require("semver");
const cleanupCypressFiles = ({ fileEntries, packageManager }) =>
fileEntries.flatMap(([filePath, content]) => {
const newContent = content.replace(
new RegExp("npx ts-node", "g"),
packageManager.name === "bun" ? "bun" : `${packageManager.exec} ts-node`,
new RegExp("npx tsx", "g"),
packageManager.name === "bun" ? "bun" : `${packageManager.exec} tsx`,
);

return [fs.writeFile(filePath, newContent)];
Expand Down Expand Up @@ -87,13 +87,13 @@ const updatePackageJson = ({ APP_NAME, packageJson, packageManager }) => {
name: APP_NAME,
devDependencies:
packageManager.name === "bun"
? removeUnusedDependencies(devDependencies, ["ts-node"])
? removeUnusedDependencies(devDependencies, ["tsx"])
: devDependencies,
prisma: {
...prisma,
seed:
packageManager.name === "bun"
? prismaSeed.replace("ts-node", "bun")
? prismaSeed.replace("tsx", "bun")
: prismaSeed,
},
scripts,
Expand Down

0 comments on commit 17dc382

Please sign in to comment.