CompileToYAML compiles workflow data and returns the YAML as a string without writing to disk. This is useful for Wasm builds and programmatic usage.
(workflowData *WorkflowData, markdownPath string)
| 17 | // CompileToYAML compiles workflow data and returns the YAML as a string |
| 18 | // without writing to disk. This is useful for Wasm builds and programmatic usage. |
| 19 | func (c *Compiler) CompileToYAML(workflowData *WorkflowData, markdownPath string) (string, error) { |
| 20 | compilerStringAPILog.Printf("CompileToYAML: markdownPath=%s", markdownPath) |
| 21 | c.markdownPath = markdownPath |
| 22 | c.skipHeader = true |
| 23 | // Clear contentOverride after compilation (set by ParseWorkflowString) |
| 24 | defer func() { c.contentOverride = "" }() |
| 25 | |
| 26 | startTime := time.Now() |
| 27 | defer func() { |
| 28 | workflowLog.Printf("CompileToYAML completed in %v", time.Since(startTime)) |
| 29 | }() |
| 30 | |
| 31 | c.stepOrderTracker = NewStepOrderTracker() |
| 32 | c.scheduleFriendlyFormats = nil |
| 33 | |
| 34 | if c.artifactManager == nil { |
| 35 | c.artifactManager = NewArtifactManager() |
| 36 | } else { |
| 37 | c.artifactManager.Reset() |
| 38 | } |
| 39 | |
| 40 | lockFile := stringutil.MarkdownToLockFile(markdownPath) |
| 41 | |
| 42 | if err := c.validateWorkflowData(workflowData, markdownPath); err != nil { |
| 43 | return "", err |
| 44 | } |
| 45 | |
| 46 | yamlContent, _, _, err := c.generateAndValidateYAML(workflowData, markdownPath, lockFile) |
| 47 | if err != nil { |
| 48 | return "", err |
| 49 | } |
| 50 | |
| 51 | return yamlContent, nil |
| 52 | } |
| 53 | |
| 54 | // ParseWorkflowString parses workflow markdown content from a string rather than a file. |
| 55 | // This is the primary entry point for Wasm/browser usage where filesystem access is unavailable. |