diff --git a/README.md b/README.md index cfbe42b42..89b035dfe 100644 --- a/README.md +++ b/README.md @@ -459,7 +459,7 @@ Alternating between configurations can be done by providing the `--server-id` op ### Enabling Package Alias -When enabled, the action runs `jf package-alias install` after setting up JFrog CLI and appends the alias bin directory to `GITHUB_PATH`. Subsequent steps will transparently intercept package manager commands such as `mvn`, `npm`, `go`, etc., so they use JFrog CLI without changing your workflow scripts. +When enabled, the action runs `jf package-alias install` after setting up JFrog CLI, appends the alias bin directory to `GITHUB_PATH`, and exports `JFROG_CLI_GHOST_FROG` so Ghost Frog interception is active. Subsequent steps will transparently intercept package manager commands such as `mvn`, `npm`, `go`, etc., so they use JFrog CLI without changing your workflow scripts. You can optionally provide `package-alias-tools` as a comma-separated list to pass specific package managers to `jf package-alias install --packages`. diff --git a/action.yml b/action.yml index d1a779ea2..612cbf606 100644 --- a/action.yml +++ b/action.yml @@ -37,7 +37,7 @@ inputs: description: 'Alias for ghe-base-url' required: false enable-package-alias: - description: "If true, after setting up JFrog CLI the action runs 'jf package-alias install' and appends the alias directory to GITHUB_PATH so that mvn, npm, go, etc. are transparently intercepted in subsequent steps." + description: "If true, after setting up JFrog CLI the action runs 'jf package-alias install', appends the alias directory to GITHUB_PATH, and sets JFROG_CLI_GHOST_FROG so that mvn, npm, go, etc. are transparently intercepted in subsequent steps." default: "false" required: false package-alias-tools: diff --git a/lib/utils.js b/lib/utils.js index 3e3f302ca..5c3bd6c40 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -470,7 +470,7 @@ class Utils { } /** * If enable-package-alias is true and GITHUB_PATH is set, runs `jf package-alias install` - * and appends the alias bin directory to GITHUB_PATH so subsequent steps intercept mvn, npm, go, etc. + * and adds the alias bin directory to PATH via core.addPath so subsequent steps intercept mvn, npm, go, etc. * On failure (e.g. older CLI without package-alias), logs a warning and does not fail the job. */ static setupPackageAliasIfRequested() { @@ -513,8 +513,10 @@ class Utils { return; } const aliasBinDir = Utils.getPackageAliasBinDir(); - (0, fs_1.appendFileSync)(githubPath, aliasBinDir + '\n'); - core.info('Package aliases installed and "' + aliasBinDir + '" appended to GITHUB_PATH.'); + core.addPath(aliasBinDir); + // Ghost Frog interception is opt-in; without this env var the PATH shims do not activate. + Utils.exportVariableIfNotSet('JFROG_CLI_GHOST_FROG', 'true'); + core.info('Package aliases installed and "' + aliasBinDir + '" added to PATH.'); }); } } diff --git a/src/utils.ts b/src/utils.ts index 8ff668407..345c7c8db 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -578,6 +578,8 @@ export class Utils { } const aliasBinDir = Utils.getPackageAliasBinDir(); core.addPath(aliasBinDir); + // Ghost Frog interception is opt-in; without this env var the PATH shims do not activate. + Utils.exportVariableIfNotSet('JFROG_CLI_GHOST_FROG', 'true'); core.info('Package aliases installed and "' + aliasBinDir + '" added to PATH.'); } } diff --git a/test/main.spec.ts b/test/main.spec.ts index 19258b5a4..e1aac8bac 100644 --- a/test/main.spec.ts +++ b/test/main.spec.ts @@ -487,6 +487,7 @@ describe('setupPackageAliasIfRequested', () => { await Utils.setupPackageAliasIfRequested(); expect(myExec.exec).toHaveBeenCalledWith('jf', ['package-alias', 'install'], { ignoreReturnCode: true }); + expect(myCore.exportVariable).toHaveBeenCalledWith('JFROG_CLI_GHOST_FROG', 'true'); }); it('should pass normalized tools as --packages when package-alias-tools is provided', async () => {