mirror of
https://github.com/jdx/mise-action.git
synced 2026-05-14 13:50:33 +00:00
fix: guard against reserved output name collisions
Address review feedback: - Skip setting individual outputs for reserved names (cache-hit, versions) - Emit warning when a tool name conflicts with reserved outputs - Document dynamic outputs pattern in action.yml comments
This commit is contained in:
parent
3ae98ac76a
commit
1aec2f5751
4 changed files with 24 additions and 3 deletions
|
|
@ -90,6 +90,9 @@ outputs:
|
|||
description: A boolean value to indicate if a cache was hit.
|
||||
versions:
|
||||
description: JSON object containing all active tool versions with metadata (version, requested_version, install_path, source).
|
||||
# Dynamic outputs: each active tool (e.g. `node`, `bun`, `python`) is also
|
||||
# set as an individual output whose value is the resolved version string.
|
||||
# Access via ${{ steps.<step-id>.outputs.<tool-name> }}
|
||||
runs:
|
||||
using: node24
|
||||
main: dist/index.js
|
||||
|
|
|
|||
10
dist/index.js
generated
vendored
10
dist/index.js
generated
vendored
|
|
@ -84932,11 +84932,19 @@ async function outputToolVersions() {
|
|||
});
|
||||
const tools = JSON.parse(output.stdout);
|
||||
const activeVersions = {};
|
||||
// Reserved output names that should not be overwritten by tool names
|
||||
const reservedOutputs = ['cache-hit', 'versions'];
|
||||
for (const [toolName, versions] of Object.entries(tools)) {
|
||||
const activeVersion = versions.find(v => v.active);
|
||||
if (activeVersion) {
|
||||
// Set individual output: steps.mise.outputs.bun = "1.0.0"
|
||||
setOutput(toolName, activeVersion.version);
|
||||
// Skip reserved output names to avoid conflicts
|
||||
if (reservedOutputs.includes(toolName)) {
|
||||
warning(`Tool "${toolName}" conflicts with reserved output name; skipping individual output for this tool.`);
|
||||
}
|
||||
else {
|
||||
setOutput(toolName, activeVersion.version);
|
||||
}
|
||||
info(`${toolName}: ${activeVersion.version}`);
|
||||
// Collect for JSON output with full metadata
|
||||
activeVersions[toolName] = {
|
||||
|
|
|
|||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
12
src/index.ts
12
src/index.ts
|
|
@ -169,11 +169,21 @@ async function outputToolVersions(): Promise<void> {
|
|||
const tools: Record<string, ToolInfo[]> = JSON.parse(output.stdout)
|
||||
const activeVersions: Record<string, ToolVersionOutput> = {}
|
||||
|
||||
// Reserved output names that should not be overwritten by tool names
|
||||
const reservedOutputs = ['cache-hit', 'versions']
|
||||
|
||||
for (const [toolName, versions] of Object.entries(tools)) {
|
||||
const activeVersion = versions.find(v => v.active)
|
||||
if (activeVersion) {
|
||||
// Set individual output: steps.mise.outputs.bun = "1.0.0"
|
||||
core.setOutput(toolName, activeVersion.version)
|
||||
// Skip reserved output names to avoid conflicts
|
||||
if (reservedOutputs.includes(toolName)) {
|
||||
core.warning(
|
||||
`Tool "${toolName}" conflicts with reserved output name; skipping individual output for this tool.`
|
||||
)
|
||||
} else {
|
||||
core.setOutput(toolName, activeVersion.version)
|
||||
}
|
||||
core.info(`${toolName}: ${activeVersion.version}`)
|
||||
|
||||
// Collect for JSON output with full metadata
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue