Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
27 changes: 16 additions & 11 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <unityProjectPath>', 'The path to a Unity project or "none" to skip project detection.')
.option('-p, --unity-project <unityProject>', 'The path to a Unity project or "none" to skip project detection.')
.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.')
.option('-c, --changeset <changeset>', 'The Unity changeset to get (e.g. 1234567890ab).')
.option('-a, --arch <architecture>', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.')
.option('-a, --arch <arch>', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.')
.option('-b, --build-targets <buildTargets>', 'The Unity build target to get (e.g. iOS, Android).')
.option('-m, --modules <modules>', 'The Unity module to get (e.g. ios, android).')
.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.')
Expand All @@ -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();
Expand Down Expand Up @@ -287,10 +287,10 @@ program.command('setup-unity')

program.command('uninstall-unity')
.description('Uninstall the specified Unity Editor version.')
.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.')
.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.')
.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.')
.option('-c, --changeset <changeset>', 'The Unity changeset to get (e.g. 1234567890ab).')
.option('-a, --arch <architecture>', 'The Unity architecture to get (e.g. x86_64, arm64). Defaults to the architecture of the current process.')
.option('-a, --arch <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) {
Expand Down Expand Up @@ -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 <unityProjectPath>', '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 <unityProject>', '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 <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.')
.option('--verbose', 'Enable verbose logging.')
.action(async (options) => {
Expand All @@ -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);

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

program.command('run')
.description('Run command line args directly to the Unity Editor.')
.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.')
.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.')
.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.')
.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.')
.option('--log-name <logName>', 'The name of the log file.')
.option('--verbose', 'Enable verbose logging.')
.allowUnknownOption(true)
Expand Down Expand Up @@ -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 <unityVersion>', '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 <unityEditorPath>', 'The path to the Unity Editor executable. If unspecified, the UNITY_EDITOR_PATH environment variable must be set.')
.option('-e, --unity-editor <unityEditor>', '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) => {
Expand Down Expand Up @@ -481,7 +486,7 @@ program.command('create-project')
.option('-p, --path <projectPath>', 'The path to create the new Unity project. If unspecified, the current working directory will be used.')
.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)?')
.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.')
.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.')
.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.')
.option('--verbose', 'Enable verbose logging.')
.option('--json', 'Prints the last line of output as JSON string.')
.action(async (options) => {
Expand Down