codemod upgrade-legacy cause path errors
- Dominant language
- TypeScript
- Stars
- 14.1k
- Forks
- 803
- PR merge metrics
- No merged PRs in 30d
Description
### What is the problem?
When I try to upgrade [legacy-framework](https://github.com/blitz-js/legacy-framework) (v0.45.5) using codemod, I get some wrong path errors
### Paste all your error logs here:
```
$ npx @blitzjs/codemod upgrade-legacy
✔ Successfully ran move the config from /Users/kyken/Documents/develop/tmp/legacy-framework/examples/auth/blitz.config.ts to next.config.js
✔ Successfully ran update .eslintrc.js configuration
✔ Successfully ran update dependencies in package.json
✔ Successfully ran update project's imports
✔ Successfully ran update NextJS' default imports
✔ Successfully ran change queryClient to getQueryClient()
✔ Successfully ran change BlitzApiRequest to NextApiRequest
✔ Successfully ran change BlitzApiResponse to NextApiResponse
✔ Successfully ran change BlitzApiHandler to NextApiHandler
✖ create blitz-server.ts and blitz-client.ts setup files
Error: ENOENT: no such file or directory, open '/Users/kyken/.npm/_npx/80c77bdc0015bdea/node_modules/@blitzjs/generator/dist/templates/app/app/blitz-server.ts'
This is an unexpected error. Please ask for help in the discord #general-help channel. https://discord.blitzjs.com
```
### Paste all relevant code snippets here:
```
steps.push({
name: "create blitz-server.ts and blitz-client.ts setup files",
action: async () => {
let appDirExist = fs.existsSync(appDir)
if (appDirExist) {
const templatePath = path.join(
require.resolve("@blitzjs/generator"),
"..",
"..",
isInternalBlitzMonorepoDevelopment ? "templates" : "dist/templates",
)
const blitzServer = fs
.readFileSync(path.join(templatePath, "app", "app", "blitz-server.ts"))
.toString()
const blitzClient = fs
.readFileSync(path.join(templatePath, "app", "app", "blitz-client.ts"))
.toString()
const replaceTemplateValues = (input: string) => {
let result = input
const token = `__safeNameSlug__`
if (result.includes(token)) {
result = result.replace(new RegExp(token, "g"), "blitz")
}
return result
}
fs.writeFileSync(
`${appDir}/blitz-server.${isTypescript ? "ts" : "js"}`,
replaceTemplateValues(blitzServer),
)
fs.writeFileSync(
`${appDir}/blitz-client.${isTypescript ? "ts" : "js"}`,
replaceTemplateValues(blitzClient),
)
} else {
throw new ExpectedError("App directory doesn't exit")
}
},
})
```
### What are detailed steps to reproduce this?
1. clone [legacy-framework](https://github.com/blitz-js/legacy-framework))
2. `$ cd legacy-framework/examples/auth` (maybe anything with `examples`).
3. `npx @blitzjs/codemod upgrade-legacy`
### Run `blitz -v` and paste the output here:
```
blitz -v
Blitz version: 2.0.0-beta.23 (local)
macOS Ventura | darwin-x64 | Node: v16.15.0
Package manager: npm
System:
OS: macOS 13.2.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 292.80 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - ~/.volta/tools/image/node/16.15.0/bin/node
Yarn: Not Found
npm: 8.5.5 - ~/.volta/tools/image/node/16.15.0/bin/npm
npmPackages:
@blitzjs/auth: Not Found
@blitzjs/next: Not Found
@blitzjs/rpc: Not Found
@prisma/client: Not Found
blitz: Not Found
next: Not Found
prisma: Not Found
react: Not Found
react-dom: Not Found
typescript: Not Found
```
### Please include below any other applicable logs and screenshots that show your problem:
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.