Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/nitro/src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ ${webhookRouteContent}`;
}

export function getWorkflowDirs(nitro: Nitro) {
const srcDir = nitro.options.srcDir || nitro.options.rootDir;

return unique(
[
...(nitro.options.workflow?.dirs ?? []),
join(nitro.options.rootDir, 'workflows'),
...nitro.options.scanDirs.map((dir) => join(dir, 'workflows')),
join(srcDir, nitro.options.routesDir || 'routes'),
join(srcDir, nitro.options.apiDir || 'api'),
].map((dir) => resolve(nitro.options.rootDir, dir))
).sort();
}
Expand Down
30 changes: 7 additions & 23 deletions packages/sveltekit/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ async function convertSvelteKitRequest(request) {
export class SvelteKitBuilder extends BaseBuilder {
constructor(config?: Partial<SvelteKitConfig>) {
const workingDir = config?.workingDir || process.cwd();
const dirs = getWorkflowDirs({ dirs: config?.dirs });

// Merge user-provided dirs with framework defaults
// User dirs are included if provided, then framework defaults are added
const defaultDirs = ['workflows', 'src/workflows', 'routes', 'src/routes'];
const userDirs = config?.dirs ?? [];
const allDirs = Array.from(new Set([...userDirs, ...defaultDirs]));

super({
...config,
dirs,
dirs: allDirs,
buildTarget: 'sveltekit' as const,
stepsBundlePath: '', // unused in base
workflowsBundlePath: '', // unused in base
Expand Down Expand Up @@ -232,24 +237,3 @@ export const OPTIONS = createSvelteKitHandler('OPTIONS');`
}
}
}

/**
* Gets the list of directories to scan for workflow files.
*/
export function getWorkflowDirs(options?: { dirs?: string[] }): string[] {
return unique([
// User-provided directories take precedence
...(options?.dirs ?? []),
// Scan routes directories (like Next.js does with app/pages directories)
// This allows workflows to be placed anywhere in the routes tree
'routes',
'src/routes',
// Also scan dedicated workflow directories for organization
'workflows',
'src/workflows',
]).sort();
}

function unique<T>(array: T[]): T[] {
return Array.from(new Set(array));
}
Loading