Skip to content

Commit

Permalink
fix<codemod-upgrade-legacy>: provide correct path to template files (#…
Browse files Browse the repository at this point in the history
…4274)

* fix<codemod-upgrade-legacy>: provide correct path to template files

* fix<codemod-upgrade-legacy>: corrected path

* fix<codemod-legacy-upgrade>: add cookiePrefix step: always errored that collection was empty => invoke it only conditionally

* Create famous-worms-grab.md

---------

Co-authored-by: Siddharth Suresh <siddh.suresh@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Jan 16, 2024
1 parent 47722e0 commit 956a739
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-worms-grab.md
@@ -0,0 +1,5 @@
---
"@blitzjs/codemod": patch
---

codemod: provide correct path to new template paths
12 changes: 8 additions & 4 deletions packages/codemod/src/upgrade-legacy.ts
Expand Up @@ -536,10 +536,10 @@ const upgradeLegacy = async () => {
isInternalBlitzMonorepoDevelopment ? "templates" : "dist/templates",
)
const blitzServer = fs
.readFileSync(path.join(templatePath, "app", "app", "blitz-server.ts"))
.readFileSync(path.join(templatePath, "app", "src", "app", "blitz-server.ts"))
.toString()
const blitzClient = fs
.readFileSync(path.join(templatePath, "app", "app", "blitz-client.ts"))
.readFileSync(path.join(templatePath, "app", "src", "app", "blitz-client.ts"))
.toString()

const replaceTemplateValues = (input: string) => {
Expand Down Expand Up @@ -584,7 +584,9 @@ 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
}

fs.writeFileSync(
`${appDir}/blitz-client.${isTypescript ? "ts" : "js"}`,
Expand Down Expand Up @@ -684,7 +686,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 956a739

Please sign in to comment.