Auto-fix config.dirs of /trigger and /src/trigger (#1665)

This commit is contained in:
Eric Allam
2025-02-05 13:00:18 +00:00
committed by GitHub
parent e35b6f539a
commit 99d38151f6
3 changed files with 29 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---
Auto-fix /trigger or /src/trigger config.dirs to relative paths to prevent misconfiguration from preventing dev CLI from working
+8
View File
@@ -46,6 +46,14 @@
"cwd": "${workspaceFolder}/references/init-shell",
"sourceMaps": true
},
{
"type": "node-terminal",
"request": "launch",
"name": "Debug V3 init dev CLI",
"command": "pnpm exec trigger dev",
"cwd": "${workspaceFolder}/references/init-shell",
"sourceMaps": true
},
{
"type": "node-terminal",
"request": "launch",
+16 -3
View File
@@ -155,11 +155,11 @@ async function resolveConfig(
let dirs = config.dirs ? config.dirs : await autoDetectDirs(workingDir);
dirs = dirs.map((dir) => (isAbsolute(dir) ? relative(workingDir, dir) : dir));
dirs = dirs.map((dir) => resolveTriggerDir(dir, workingDir));
const mergedConfig = defu(
{
workingDir: packageJsonPath ? dirname(packageJsonPath) : cwd,
workingDir,
configFile: result.configFile,
packageJsonPath,
tsconfigPath,
@@ -187,11 +187,24 @@ async function resolveConfig(
return {
...mergedConfig,
dirs: Array.from(new Set(mergedConfig.dirs)),
dirs: Array.from(new Set(dirs)),
instrumentedPackageNames: getInstrumentedPackageNames(mergedConfig),
};
}
function resolveTriggerDir(dir: string, workingDir: string): string {
if (isAbsolute(dir)) {
// If dir is `/trigger` or `/src/trigger`, we should add a `.` to make it relative to the working directory
if (dir === "/trigger" || dir === "/src/trigger") {
return `.${dir}`;
} else {
return relative(workingDir, dir);
}
}
return dir;
}
async function safeResolveTsConfig(cwd: string) {
try {
return await resolveTSConfig(cwd);