Skip to content

Commit fc083de

Browse files
committed
Merge branch 'Chigala-bugfix/cli-init'
2 parents 302bd02 + c7c5fd7 commit fc083de

File tree

4 files changed

+309
-32
lines changed

4 files changed

+309
-32
lines changed

.changeset/ten-oranges-pretend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/cli": patch
3+
---
4+
5+
fixed the cli init log message to show the correct path to the app route created

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pnpm run dev
136136
3. Create a new temporary Next.js app in examples directory
137137

138138
```sh
139-
pnpm create next-app@latest
139+
pnpm create next-app@latest test-cli --ts --no-eslint --tailwind --app --src-dir --import-alias "@/*"
140140
```
141141

142142
Follow the prompts to create a TypeScript project using the App Directory.
@@ -145,14 +145,15 @@ Follow the prompts to create a TypeScript project using the App Directory.
145145

146146
```json
147147
{
148+
// other package.json properties
148149
"devDependencies": { "@trigger.dev/cli": "workspace:*" }
149150
}
150151
```
151152
152153
5. Open a new terminal window, navigate into the example, and initialize the CLI:
153154
154155
```sh
155-
cd examples/your-newly-created-nextjs-project
156+
cd examples/test-cli
156157
pnpm i
157158
pnpm exec trigger-cli init
158159
```

packages/cli/src/commands/init.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,7 @@ async function detectUseOfSrcDir(path: string): Promise<boolean> {
280280

281281
// Detect the use of pages or app dir in the Next.js project
282282
// Import the next.config.js file and check for experimental: { appDir: true }
283-
async function detectPagesOrAppDir(
284-
path: string,
285-
usesSrcDir = false,
286-
): Promise<"pages" | "app"> {
283+
async function detectPagesOrAppDir(path: string, usesSrcDir = false): Promise<"pages" | "app"> {
287284
const nextConfigPath = pathModule.join(path, "next.config.js");
288285
const importedConfig = await import(pathToFileURL(nextConfigPath).toString()).catch(() => ({}));
289286

@@ -527,7 +524,11 @@ export * from "./examples"
527524

528525
await fs.writeFile(pathModule.join(directories, routeFileName), routeContent);
529526

530-
logger.success(`✅ Created app route at ${usesSrcDir ? "src/" : ""}app/api/trigger.ts`);
527+
logger.success(
528+
`✅ Created app route at ${usesSrcDir ? "src/" : ""}app/api/${removeFileExtension(
529+
triggerFileName
530+
)}/${routeFileName}`
531+
);
531532

532533
const triggerFileExists = await pathExists(pathModule.join(path, triggerFileName));
533534

@@ -550,9 +551,7 @@ export * from "./examples"
550551
examplesIndexContent
551552
);
552553

553-
logger.success(
554-
`✅ Created example job at ${usesSrcDir ? "src/" : ""}jobs/examples/examplesFileName`
555-
);
554+
logger.success(`✅ Created example job at ${usesSrcDir ? "src/" : ""}jobs/examples.ts`);
556555
}
557556
}
558557

@@ -735,3 +734,7 @@ async function setupEnvironmentVariable(
735734
logger.success(`✅ Added ${variableName}=${renderer(value)} to ${fileName}`);
736735
}
737736
}
737+
738+
function removeFileExtension(filename: string) {
739+
return filename.replace(/\.[^.]+$/, "");
740+
}

0 commit comments

Comments
 (0)