mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 16:00:38 +00:00
fix path assigner for nested calls (#6732)
This commit is contained in:
+5
-1
@@ -16,4 +16,8 @@ set -e
|
||||
echo "Running dnt..."
|
||||
deno run -A dnt.ts
|
||||
|
||||
echo "Build complete!"
|
||||
# Remove .ts extensions after building to go back to the original state
|
||||
./windmill-utils-internal/remove-ts-ext.sh
|
||||
|
||||
echo "Build complete!"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { newPathAssigner } from "../path-utils/path-assigner";
|
||||
import { newPathAssigner, PathAssigner } from "../path-utils/path-assigner";
|
||||
import { FlowModule } from "../gen/types.gen";
|
||||
|
||||
/**
|
||||
@@ -17,20 +17,25 @@ interface InlineScript {
|
||||
*
|
||||
* @param modules - Array of flow modules to process
|
||||
* @param mapping - Optional mapping of module IDs to custom file paths
|
||||
* @param separator - Path separator to use
|
||||
* @param defaultTs - Default TypeScript runtime to use ("bun" or "deno")
|
||||
* @param pathAssigner - Optional path assigner to reuse (for nested calls)
|
||||
* @returns Array of inline scripts with their paths and content
|
||||
*/
|
||||
export function extractInlineScripts(
|
||||
modules: FlowModule[],
|
||||
mapping: Record<string, string> = {},
|
||||
separator: string = "/",
|
||||
defaultTs?: "bun" | "deno"
|
||||
defaultTs?: "bun" | "deno",
|
||||
pathAssigner?: PathAssigner
|
||||
): InlineScript[] {
|
||||
const pathAssigner = newPathAssigner(defaultTs ?? "bun");
|
||||
// Create pathAssigner only if not provided (top-level call), but reuse it for nested calls
|
||||
const assigner = pathAssigner ?? newPathAssigner(defaultTs ?? "bun");
|
||||
|
||||
return modules.flatMap((m) => {
|
||||
if (m.value.type == "rawscript") {
|
||||
let basePath, ext;
|
||||
[basePath, ext] = pathAssigner.assignPath(m.summary, m.value.language);
|
||||
[basePath, ext] = assigner.assignPath(m.summary, m.value.language);
|
||||
const path = mapping[m.id] ?? basePath + ext;
|
||||
const content = m.value.content;
|
||||
const r = [{ path: path, content: content }];
|
||||
@@ -47,25 +52,39 @@ export function extractInlineScripts(
|
||||
m.value.modules,
|
||||
mapping,
|
||||
separator,
|
||||
defaultTs
|
||||
defaultTs,
|
||||
assigner
|
||||
);
|
||||
} else if (m.value.type == "branchall") {
|
||||
return m.value.branches.flatMap((b) =>
|
||||
extractInlineScripts(b.modules, mapping, separator, defaultTs)
|
||||
extractInlineScripts(b.modules, mapping, separator, defaultTs, assigner)
|
||||
);
|
||||
} else if (m.value.type == "whileloopflow") {
|
||||
return extractInlineScripts(
|
||||
m.value.modules,
|
||||
mapping,
|
||||
separator,
|
||||
defaultTs
|
||||
defaultTs,
|
||||
assigner
|
||||
);
|
||||
} else if (m.value.type == "branchone") {
|
||||
return [
|
||||
...m.value.branches.flatMap((b) =>
|
||||
extractInlineScripts(b.modules, mapping, separator, defaultTs)
|
||||
extractInlineScripts(
|
||||
b.modules,
|
||||
mapping,
|
||||
separator,
|
||||
defaultTs,
|
||||
assigner
|
||||
)
|
||||
),
|
||||
...extractInlineScripts(
|
||||
m.value.default,
|
||||
mapping,
|
||||
separator,
|
||||
defaultTs,
|
||||
assigner
|
||||
),
|
||||
...extractInlineScripts(m.value.default, mapping, separator, defaultTs),
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user