Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,8 @@ trivy-results.sarif
licenses.csv
*.bck.yml
actions/setup/js/test-*/

# Test inline feature files
test-inline-*.txt
test-inline-*.md
test-inline-*.lock.yml
22 changes: 16 additions & 6 deletions actions/setup/js/interpolate_prompt.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

const fs = require("fs");
const { isTruthy } = require("./is_truthy.cjs");
const { processRuntimeImports } = require("./runtime_import.cjs");
const { processRuntimeImports, convertInlinesToMacros } = require("./runtime_import.cjs");
const { getErrorMessage } = require("./error_helpers.cjs");

/**
Expand Down Expand Up @@ -79,17 +79,27 @@ async function main() {
// Read the prompt file
let content = fs.readFileSync(promptPath, "utf8");

// Step 1: Process runtime imports
// Step 1: Convert @./path and @url inline syntax to {{#runtime-import}} macros
const hasInlines = /@[^\s]+/.test(content);
if (hasInlines) {
core.info("Converting inline references (@./path, @../path, and @url) to runtime-import macros");
content = convertInlinesToMacros(content);
core.info("Inline references converted successfully");
} else {
core.info("No inline references found, skipping conversion");
}

// Step 2: Process runtime imports (including converted @./path and @url macros)
const hasRuntimeImports = /{{#runtime-import\??[ \t]+[^\}]+}}/.test(content);
if (hasRuntimeImports) {
core.info("Processing runtime import macros");
content = processRuntimeImports(content, workspaceDir);
core.info("Processing runtime import macros (files and URLs)");
content = await processRuntimeImports(content, workspaceDir);
core.info("Runtime imports processed successfully");
} else {
core.info("No runtime import macros found, skipping runtime import processing");
}

// Step 2: Interpolate variables
// Step 3: Interpolate variables
/** @type {Record<string, string>} */
const variables = {};
for (const [key, value] of Object.entries(process.env)) {
Expand All @@ -107,7 +117,7 @@ async function main() {
core.info("No expression variables found, skipping interpolation");
}

// Step 3: Render template conditionals
// Step 4: Render template conditionals
const hasConditionals = /{{#if\s+[^}]+}}/.test(content);
if (hasConditionals) {
core.info("Processing conditional template blocks");
Expand Down
Loading
Loading