diff --git a/CHANGELOG.md b/CHANGELOG.md index eb5dd23..c57c2fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.6] - 2026-06-12 + +### Fixed + +- `action-runner.bat` now runs `cd /d "%~dp0"` before invoking Node, so CLI aliases work from any terminal working directory (matching Run Now spawn behavior). + ## [1.0.5] - 2026-06-12 ### Fixed diff --git a/command-lib/tests/actionRunnerBat.integration.test.js b/command-lib/tests/actionRunnerBat.integration.test.js new file mode 100644 index 0000000..4a8417e --- /dev/null +++ b/command-lib/tests/actionRunnerBat.integration.test.js @@ -0,0 +1,57 @@ +const { describe, it } = require("node:test"); +const assert = require("node:assert/strict"); +const { spawnSync } = require("node:child_process"); +const fs = require("node:fs"); +const os = require("node:os"); +const path = require("node:path"); + +const repoRoot = path.resolve(__dirname, "..", ".."); +const isWindows = process.platform === "win32"; +const actionRunnerBatPath = path.join( + repoRoot, + "commands", + "action-runner", + "action-runner.bat", +); +const missingActionName = "shellforge-nonexistent-action-for-test"; + +function runActionRunnerBatFromDirectory(workingDirectory, environmentVariables = {}) { + return spawnSync("cmd.exe", ["/c", actionRunnerBatPath, `--action=${missingActionName}`], { + cwd: workingDirectory, + encoding: "utf8", + windowsHide: true, + env: { + ...process.env, + ...environmentVariables, + }, + }); +} + +function createTempDirectory() { + return fs.mkdtempSync(path.join(os.tmpdir(), "shellforge-action-runner-bat-")); +} + +const describeWindows = isWindows ? describe : describe.skip; + +describeWindows("action-runner.bat integration", () => { + it("runs from an arbitrary working directory and reaches the Action Runner runtime", () => { + const unrelatedWorkingDirectory = createTempDirectory(); + + const executionResult = runActionRunnerBatFromDirectory(unrelatedWorkingDirectory, { + SHELLFORGE_USER_DATA: repoRoot, + }); + + const combinedOutput = `${executionResult.stdout}\n${executionResult.stderr}`; + + assert.notEqual( + executionResult.status, + 0, + "Expected a non-zero exit code for a missing action name.", + ); + assert.match( + combinedOutput, + /\[Action Runner\]|Missing Configuration/, + "Expected Action Runner output when the bat starts Node from an unrelated cwd.", + ); + }); +}); diff --git a/commands/action-runner/action-runner.bat b/commands/action-runner/action-runner.bat index 6470ce2..881eeb5 100644 --- a/commands/action-runner/action-runner.bat +++ b/commands/action-runner/action-runner.bat @@ -1,4 +1,5 @@ @echo off +cd /d "%~dp0" setlocal enabledelayedexpansion set JS_FILE="%~dp0\action-runner.js" diff --git a/package.json b/package.json index 5916fd9..303bbf3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shellforge", - "version": "1.0.5", + "version": "1.0.6", "description": "ShellForge - custom Windows PowerShell automation and commands", "license": "ISC", "author": "João Luiz de Castro", diff --git a/ui/package-lock.json b/ui/package-lock.json index ed2f82c..c11d554 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "shellforge-ui", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shellforge-ui", - "version": "1.0.5", + "version": "1.0.6", "dependencies": { "dagre": "^0.8.5", "js-pretty-icons": "^0.3.0", diff --git a/ui/package.json b/ui/package.json index 058b397..80e13b8 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "shellforge-ui", - "version": "1.0.5", + "version": "1.0.6", "description": "ShellForge desktop manager for Windows PowerShell automation", "author": "João Luiz de Castro", "private": true,