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..b7e9b36 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -112,14 +112,17 @@ 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)); + const unityHub = new UnityHub(); - const hubPath = await unityHub.Install(); + const hubPath = await unityHub.Install(options.autoUpdate === true); 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;