bugfix: jsx extensions breaks cli init (#374)
* bugfix: jsx extensions breaks cli init * Update init.ts (adding ts extension to check) * Create rude-spoons-compete.md --------- Co-authored-by: Eric Allam <eallam@icloud.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/cli": patch
|
||||
---
|
||||
|
||||
Bugfix: @trigger.dev/cli init now correctly identifies the App Dir when using JS
|
||||
@@ -117,7 +117,7 @@ export const initCommand = async (options: InitCommandOptions) => {
|
||||
logger.info("📁 Detected use of src directory");
|
||||
}
|
||||
|
||||
const nextJsDir = await detectPagesOrAppDir(resolvedPath, usesSrcDir, isTypescriptProject);
|
||||
const nextJsDir = await detectPagesOrAppDir(resolvedPath, usesSrcDir);
|
||||
|
||||
const routeDir = pathModule.join(resolvedPath, usesSrcDir ? "src" : "");
|
||||
|
||||
@@ -283,7 +283,6 @@ async function detectUseOfSrcDir(path: string): Promise<boolean> {
|
||||
async function detectPagesOrAppDir(
|
||||
path: string,
|
||||
usesSrcDir = false,
|
||||
isTypescriptProject = false
|
||||
): Promise<"pages" | "app"> {
|
||||
const nextConfigPath = pathModule.join(path, "next.config.js");
|
||||
const importedConfig = await import(pathToFileURL(nextConfigPath).toString()).catch(() => ({}));
|
||||
@@ -296,14 +295,16 @@ async function detectPagesOrAppDir(
|
||||
// If so then we return app
|
||||
// If not return pages
|
||||
|
||||
const extension = isTypescriptProject ? "tsx" : "js";
|
||||
const extensionsToCheck = ["jsx", "tsx", "js", "ts"];
|
||||
const basePath = pathModule.join(path, usesSrcDir ? "src" : "", "app", `page.`);
|
||||
|
||||
const appPagePath = pathModule.join(path, usesSrcDir ? "src" : "", "app", `page.${extension}`);
|
||||
for (const extension of extensionsToCheck) {
|
||||
const appPagePath = basePath + extension;
|
||||
const appPageExists = await pathExists(appPagePath);
|
||||
|
||||
const appPageExists = await pathExists(appPagePath);
|
||||
|
||||
if (appPageExists) {
|
||||
return "app";
|
||||
if (appPageExists) {
|
||||
return "app";
|
||||
}
|
||||
}
|
||||
|
||||
return "pages";
|
||||
|
||||
Reference in New Issue
Block a user