From 5c502eb892835e09bb17213b0f0c92d94a47a547 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Tue, 7 Oct 2025 18:16:57 -0400 Subject: [PATCH] unity-cli@v1.2.3 - fixed open-project -u not overriding project version --- package-lock.json | 4 ++-- package.json | 2 +- src/cli.ts | 27 ++++++++++++++++----------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8e92fa0e..4388d216 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.2.1", + "version": "1.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.2.1", + "version": "1.2.3", "license": "MIT", "dependencies": { "@electron/asar": "^4.0.1", diff --git a/package.json b/package.json index 94b1311a..594cd561 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.2.2", + "version": "1.2.3", "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 39da881c..f4a3b4e8 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -197,10 +197,10 @@ program.command('hub') program.command('setup-unity') .description('Sets up the environment for the specified project and finds or installs the Unity Editor version for it.') - .option('-p, --unity-project ', 'The path to a Unity project or "none" to skip project detection.') + .option('-p, --unity-project ', 'The path to a Unity project or "none" to skip project detection.') .option('-u, --unity-version ', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If specified, it will override the version read from the project.') .option('-c, --changeset ', 'The Unity changeset to get (e.g. 1234567890ab).') - .option('-a, --arch ', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.') + .option('-a, --arch ', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.') .option('-b, --build-targets ', 'The Unity build target to get (e.g. iOS, Android).') .option('-m, --modules ', 'The Unity module to get (e.g. ios, android).') .option('-i, --install-path ', 'The path to install the Unity Editor to. By default, it will be installed to the default Unity Hub location.') @@ -224,7 +224,7 @@ program.command('setup-unity') process.exit(1); } - const unityVersion = unityProject?.version ?? new UnityVersion(options.unityVersion, options.changeset); + const unityVersion = unityProject?.version ?? new UnityVersion(options.unityVersion, options.changeset, options.arch); const modules: string[] = options.modules ? options.modules.split(/[ ,]+/).filter(Boolean) : []; const buildTargets: string[] = options.buildTargets ? options.buildTargets.split(/[ ,]+/).filter(Boolean) : []; const moduleBuildTargetMap = UnityHub.GetPlatformTargetModuleMap(); @@ -287,10 +287,10 @@ program.command('setup-unity') program.command('uninstall-unity') .description('Uninstall the specified Unity Editor version.') - .option('-e, --unity-editor ', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version or the UNITY_EDITOR_PATH environment variable must be set.') + .option('-e, --unity-editor ', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version or the UNITY_EDITOR_PATH environment variable must be set.') .option('-u, --unity-version ', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If unspecified, then --unity-editor must be specified.') .option('-c, --changeset ', 'The Unity changeset to get (e.g. 1234567890ab).') - .option('-a, --arch ', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.') + .option('-a, --arch ', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.') .option('--verbose', 'Enable verbose logging.') .action(async (options) => { if (options.verbose) { @@ -342,7 +342,7 @@ program.commandsGroup('Unity Editor:'); program.command('open-project') .description('Open a Unity project in the Unity Editor.') - .option('-p, --unity-project ', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable or the current working directory will be used.') + .option('-p, --unity-project ', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable or the current working directory will be used.') .option('-u, --unity-version ', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If specified, it will override the version read from the project.') .option('--verbose', 'Enable verbose logging.') .action(async (options) => { @@ -359,7 +359,12 @@ program.command('open-project') process.exit(1); } - const unityVersion = unityProject?.version ?? new UnityVersion(options.unityVersion, options.changeset); + let unityVersion: UnityVersion | undefined = unityProject?.version; + + if (options.unityVersion) { + unityVersion = new UnityVersion(options.unityVersion); + } + const unityHub = new UnityHub(); const unityEditor = await unityHub.GetEditor(unityVersion); @@ -376,8 +381,8 @@ program.command('open-project') program.command('run') .description('Run command line args directly to the Unity Editor.') - .option('--unity-editor ', 'The path to the Unity Editor executable. If unspecified, --unity-project or the UNITY_EDITOR_PATH environment variable must be set.') - .option('--unity-project ', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable or the current working directory will be used.') + .option('--unity-editor ', 'The path to the Unity Editor executable. If unspecified, --unity-project or the UNITY_EDITOR_PATH environment variable must be set.') + .option('--unity-project ', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable or the current working directory will be used.') .option('--log-name ', 'The name of the log file.') .option('--verbose', 'Enable verbose logging.') .allowUnknownOption(true) @@ -428,7 +433,7 @@ program.command('run') program.command('list-project-templates') .description('List all available project templates for the given Unity editor.') .option('-u, --unity-version ', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If unspecified, then --unity-editor must be specified.') - .option('-e, --unity-editor ', 'The path to the Unity Editor executable. If unspecified, the UNITY_EDITOR_PATH environment variable must be set.') + .option('-e, --unity-editor ', 'The path to the Unity Editor executable. If unspecified, the UNITY_EDITOR_PATH environment variable must be set.') .option('--verbose', 'Enable verbose logging.') .option('--json', 'Prints the last line of output as JSON string.') .action(async (options) => { @@ -481,7 +486,7 @@ program.command('create-project') .option('-p, --path ', 'The path to create the new Unity project. If unspecified, the current working directory will be used.') .option('-t, --template ', 'The name of the template package to use for creating the unity project. Supports regex patterns.', 'com.unity.template.3d(-cross-platform)?') .option('-u, --unity-version ', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If unspecified, then --unity-editor must be specified.') - .option('-e, --unity-editor ', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version, or the UNITY_EDITOR_PATH environment variable must be set.') + .option('-e, --unity-editor ', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version, or the UNITY_EDITOR_PATH environment variable must be set.') .option('--verbose', 'Enable verbose logging.') .option('--json', 'Prints the last line of output as JSON string.') .action(async (options) => {