Skip to content

Commit 0ce2f47

Browse files
unity-cli@v1.2.3 (#27)
- fixed open-project -u <version> not overriding project version
1 parent 3a81c8f commit 0ce2f47

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rage-against-the-pixel/unity-cli",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "A command line utility for the Unity Game Engine.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",

src/cli.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ program.command('hub')
197197

198198
program.command('setup-unity')
199199
.description('Sets up the environment for the specified project and finds or installs the Unity Editor version for it.')
200-
.option('-p, --unity-project <unityProjectPath>', 'The path to a Unity project or "none" to skip project detection.')
200+
.option('-p, --unity-project <unityProject>', 'The path to a Unity project or "none" to skip project detection.')
201201
.option('-u, --unity-version <unityVersion>', '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.')
202202
.option('-c, --changeset <changeset>', 'The Unity changeset to get (e.g. 1234567890ab).')
203-
.option('-a, --arch <architecture>', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.')
203+
.option('-a, --arch <arch>', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.')
204204
.option('-b, --build-targets <buildTargets>', 'The Unity build target to get (e.g. iOS, Android).')
205205
.option('-m, --modules <modules>', 'The Unity module to get (e.g. ios, android).')
206206
.option('-i, --install-path <installPath>', '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')
224224
process.exit(1);
225225
}
226226

227-
const unityVersion = unityProject?.version ?? new UnityVersion(options.unityVersion, options.changeset);
227+
const unityVersion = unityProject?.version ?? new UnityVersion(options.unityVersion, options.changeset, options.arch);
228228
const modules: string[] = options.modules ? options.modules.split(/[ ,]+/).filter(Boolean) : [];
229229
const buildTargets: string[] = options.buildTargets ? options.buildTargets.split(/[ ,]+/).filter(Boolean) : [];
230230
const moduleBuildTargetMap = UnityHub.GetPlatformTargetModuleMap();
@@ -287,10 +287,10 @@ program.command('setup-unity')
287287

288288
program.command('uninstall-unity')
289289
.description('Uninstall the specified Unity Editor version.')
290-
.option('-e, --unity-editor <unityEditorPath>', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version or the UNITY_EDITOR_PATH environment variable must be set.')
290+
.option('-e, --unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version or the UNITY_EDITOR_PATH environment variable must be set.')
291291
.option('-u, --unity-version <unityVersion>', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If unspecified, then --unity-editor must be specified.')
292292
.option('-c, --changeset <changeset>', 'The Unity changeset to get (e.g. 1234567890ab).')
293-
.option('-a, --arch <architecture>', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.')
293+
.option('-a, --arch <arch>', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.')
294294
.option('--verbose', 'Enable verbose logging.')
295295
.action(async (options) => {
296296
if (options.verbose) {
@@ -342,7 +342,7 @@ program.commandsGroup('Unity Editor:');
342342

343343
program.command('open-project')
344344
.description('Open a Unity project in the Unity Editor.')
345-
.option('-p, --unity-project <unityProjectPath>', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable or the current working directory will be used.')
345+
.option('-p, --unity-project <unityProject>', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable or the current working directory will be used.')
346346
.option('-u, --unity-version <unityVersion>', '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.')
347347
.option('--verbose', 'Enable verbose logging.')
348348
.action(async (options) => {
@@ -359,7 +359,12 @@ program.command('open-project')
359359
process.exit(1);
360360
}
361361

362-
const unityVersion = unityProject?.version ?? new UnityVersion(options.unityVersion, options.changeset);
362+
let unityVersion: UnityVersion | undefined = unityProject?.version;
363+
364+
if (options.unityVersion) {
365+
unityVersion = new UnityVersion(options.unityVersion);
366+
}
367+
363368
const unityHub = new UnityHub();
364369
const unityEditor = await unityHub.GetEditor(unityVersion);
365370

@@ -376,8 +381,8 @@ program.command('open-project')
376381

377382
program.command('run')
378383
.description('Run command line args directly to the Unity Editor.')
379-
.option('--unity-editor <unityEditorPath>', 'The path to the Unity Editor executable. If unspecified, --unity-project or the UNITY_EDITOR_PATH environment variable must be set.')
380-
.option('--unity-project <unityProjectPath>', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable or the current working directory will be used.')
384+
.option('--unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, --unity-project or the UNITY_EDITOR_PATH environment variable must be set.')
385+
.option('--unity-project <unityProject>', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable or the current working directory will be used.')
381386
.option('--log-name <logName>', 'The name of the log file.')
382387
.option('--verbose', 'Enable verbose logging.')
383388
.allowUnknownOption(true)
@@ -428,7 +433,7 @@ program.command('run')
428433
program.command('list-project-templates')
429434
.description('List all available project templates for the given Unity editor.')
430435
.option('-u, --unity-version <unityVersion>', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If unspecified, then --unity-editor must be specified.')
431-
.option('-e, --unity-editor <unityEditorPath>', 'The path to the Unity Editor executable. If unspecified, the UNITY_EDITOR_PATH environment variable must be set.')
436+
.option('-e, --unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, the UNITY_EDITOR_PATH environment variable must be set.')
432437
.option('--verbose', 'Enable verbose logging.')
433438
.option('--json', 'Prints the last line of output as JSON string.')
434439
.action(async (options) => {
@@ -481,7 +486,7 @@ program.command('create-project')
481486
.option('-p, --path <projectPath>', 'The path to create the new Unity project. If unspecified, the current working directory will be used.')
482487
.option('-t, --template <projectTemplate>', 'The name of the template package to use for creating the unity project. Supports regex patterns.', 'com.unity.template.3d(-cross-platform)?')
483488
.option('-u, --unity-version <unityVersion>', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If unspecified, then --unity-editor must be specified.')
484-
.option('-e, --unity-editor <unityEditorPath>', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version, or the UNITY_EDITOR_PATH environment variable must be set.')
489+
.option('-e, --unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version, or the UNITY_EDITOR_PATH environment variable must be set.')
485490
.option('--verbose', 'Enable verbose logging.')
486491
.option('--json', 'Prints the last line of output as JSON string.')
487492
.action(async (options) => {

0 commit comments

Comments
 (0)