Skip to content

Commit

Permalink
fix<codemod-upgrade-legacy>: fixed add cookieprefix to blitz server step
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonMueller-OneAndOnly committed Jan 13, 2024
1 parent c778f2e commit 2187fa9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/codemod/src/upgrade-legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,10 @@ const upgradeLegacy = async () => {
j.Identifier,
(node) => node.name === "cookiePrefix",
)

if (cookieIdentifier.length) {
const cookiePrefix = cookieIdentifier.get().parentPath.value.value.value

if (cookiePrefix) {
const blitzClientProgram = getCollectionFromSource(
path.join(appDir, `blitz-client.${isTypescript ? "ts" : "js"}`),
Expand All @@ -584,8 +586,11 @@ const upgradeLegacy = async () => {
j.Identifier,
(node) => node.name === "cookiePrefix",
)
cookieIdentifierBlitzClient.get().parentPath.value.value.value = cookiePrefix

if (cookieIdentifierBlitzClient.length) {
cookieIdentifierBlitzClient.get().parentPath.value.value.value = cookiePrefix
}
console.log("i am here")
fs.writeFileSync(
`${appDir}/blitz-client.${isTypescript ? "ts" : "js"}`,
blitzClientProgram.toSource(),
Expand Down Expand Up @@ -684,7 +689,9 @@ const upgradeLegacy = async () => {
isInternalBlitzMonorepoDevelopment ? "templates" : "dist/templates",
)
const rpcRoute = fs
.readFileSync(path.join(templatePath, "app", "pages", "api", "rpc", "blitzrpcroute.ts"))
.readFileSync(
path.join(templatePath, "app", "src", "pages", "api", "rpc", "blitzrpcroute.ts"),
)
.toString()

if (!fs.existsSync(pagesDir)) {
Expand Down

0 comments on commit 2187fa9

Please sign in to comment.