Skip to content

Commit

Permalink
feat: use tsx (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey authored Oct 2, 2024
1 parent 0b6b213 commit 2a1e69e
Show file tree
Hide file tree
Showing 5 changed files with 17 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
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@
"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",
"tsx": "^4.19.0",
"typescript": "^5.6.2",
"vite": "^5.4.3",
"vite-tsconfig-paths": "^4.3.2",
Expand All @@ -88,6 +87,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 2a1e69e

Please sign in to comment.