From 57cd9399a17f87e786f215a3900201977c21b7ce Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Sat, 27 Sep 2025 21:36:22 -0400 Subject: [PATCH 1/2] unity-cli@v1.0.4 - added hub-install --auto-update arg --- .github/workflows/unity-build.yml | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/cli.ts | 6 +++++- src/unity-hub.ts | 5 +++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unity-build.yml b/.github/workflows/unity-build.yml index 72cecee..b329463 100644 --- a/.github/workflows/unity-build.yml +++ b/.github/workflows/unity-build.yml @@ -34,7 +34,7 @@ jobs: npm run build npm run link unity-cli --version - unity-cli hub-install + unity-cli hub-install --auto-update unity-cli activate-license --license personal --email "${{ secrets.UNITY_USERNAME }}" --password "${{ secrets.UNITY_PASSWORD }}" setup_output=$(unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-targets }}" --json) unity_editor_path=$(echo "$setup_output" | tail -n 1 | jq -r '.UNITY_EDITOR') diff --git a/package-lock.json b/package-lock.json index d030438..b3700a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.0.3", + "version": "1.0.4", "license": "MIT", "dependencies": { "@electron/asar": "^4.0.1", diff --git a/package.json b/package.json index d0dc293..17a1be0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.0.3", + "version": "1.0.4", "description": "A command line utility for the Unity Game Engine.", "author": "RageAgainstThePixel", "license": "MIT", diff --git a/src/cli.ts b/src/cli.ts index 9389488..5f9c029 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -112,14 +112,18 @@ program.command('hub-version') program.command('hub-install') .description('Install the Unity Hub.') .option('--verbose', 'Enable verbose logging.') + .option('--auto-update', 'Automatically updates the Unity Hub if it is already installed.') .option('--json', 'Prints the last line of output as JSON string.') .action(async (options) => { if (options.verbose) { Logger.instance.logLevel = LogLevel.DEBUG; } + Logger.instance.debug(JSON.stringify(options)); + + let autoUpdate: boolean = options.autoUpdate === undefined ? false : true; const unityHub = new UnityHub(); - const hubPath = await unityHub.Install(); + const hubPath = await unityHub.Install(autoUpdate); if (options.json) { process.stdout.write(`\n${JSON.stringify({ UNITY_HUB_PATH: hubPath })}\n`); diff --git a/src/unity-hub.ts b/src/unity-hub.ts index e679cef..908ed6c 100644 --- a/src/unity-hub.ts +++ b/src/unity-hub.ts @@ -163,9 +163,10 @@ export class UnityHub { /** * Installs or updates the Unity Hub. * If the Unity Hub is already installed, it will be updated to the latest version. + * @param autoUpdate If true, automatically updates the Unity Hub if it is already installed. Default is true. * @returns The path to the Unity Hub executable. */ - public async Install(): Promise { + public async Install(autoUpdate: boolean = true): Promise { let isInstalled = false; try { await fs.promises.access(this.executable, fs.constants.X_OK); @@ -174,7 +175,7 @@ export class UnityHub { await this.installHub(); } - if (isInstalled) { + if (isInstalled && autoUpdate) { const installedVersion: SemVer = await this.getInstalledHubVersion(); this.logger.ci(`Installed Unity Hub version: ${installedVersion.version}`); let latestVersion: SemVer | undefined = undefined; From 4b62f2802cd64c550494736e0d59f64628f62392 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Sat, 27 Sep 2025 21:38:20 -0400 Subject: [PATCH 2/2] refactor --- src/cli.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 5f9c029..b7e9b36 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -121,9 +121,8 @@ program.command('hub-install') Logger.instance.debug(JSON.stringify(options)); - let autoUpdate: boolean = options.autoUpdate === undefined ? false : true; const unityHub = new UnityHub(); - const hubPath = await unityHub.Install(autoUpdate); + const hubPath = await unityHub.Install(options.autoUpdate === true); if (options.json) { process.stdout.write(`\n${JSON.stringify({ UNITY_HUB_PATH: hubPath })}\n`);