Skip to content

Commit 4c41b74

Browse files
unity-cli@v1.6.0 (#47)
- fix floating license activations - added `activate-license --json` optional arg for json output of floating license token - added `return-license -t <token> | --token <token>` arg. Required for returning floating license - added `license-context` to get the license context details - added `licensing-logs` to get the path to the license client log - fix macOS editor `run` with Rosetta editor env ags (uses base args as all the other platforms) - updated GitHub annotation handling for richer, clickable annotations in the Checks UI - added unit tests - added docs - refactor editor logging features - ***experimental!*** introduced `--log-level` to `run <args>` to only log the utp messages and print tables for builds timing and error logs and unit tests - bump deps
1 parent 1dac07c commit 4c41b74

14 files changed

+1752
-251
lines changed

README.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ A powerful command line utility for the Unity Game Engine. Automate Unity projec
2828
- [Run Unity Editor Commands](#run-unity-editor-commands)
2929
- [Unity Package Manager](#unity-package-manager)
3030
- [Sign a Unity Package](#sign-a-unity-package)
31+
- [Logging](#logging)
32+
- [Local cli](#local-cli)
33+
- [Github Actions](#github-actions)
3134

3235
## Features
3336

@@ -88,6 +91,7 @@ unity-cli license-version
8891
- `-p`, `--password`: Password for the Unity account. Required when activating a personal or professional license.
8992
- `-s`, `--serial`: License serial number. Required when activating a professional license.
9093
- `-c`, `--config`: Path to the configuration file, or base64 encoded JSON string. Required when activating a floating license.
94+
- `--json`: Prints the last line of output as JSON string.
9195
- `--verbose`: Enable verbose output.
9296

9397
```bash
@@ -99,12 +103,29 @@ unity-cli activate-license --license personal --email <your-email> --password <y
99103
`return-license [options]`: Return a Unity license.
100104

101105
- `-l`, `--license`: License type (personal, professional, floating)
106+
- `-t`, `--token`: Floating license token. Required when returning a floating license.
102107
- `--verbose`: Enable verbose output.
103108

104109
```bash
105110
unity-cli return-license --license personal
106111
```
107112

113+
#### License Context
114+
115+
`license-context`: Prints the current license context information.
116+
117+
```bash
118+
unity-cli license-context
119+
```
120+
121+
#### Licensing Logs
122+
123+
`licensing-logs`: Prints the Unity licensing logs.
124+
125+
```bash
126+
unity-cli licensing-logs
127+
```
128+
108129
#### Unity Hub
109130

110131
##### Hub Version
@@ -259,9 +280,15 @@ unity-cli open-project
259280
- `--unity-editor <unityEditor>` The path to the Unity Editor executable. If unspecified, `--unity-project` or the `UNITY_EDITOR_PATH` environment variable must be set.
260281
- `--unity-project <unityProject>` The path to a Unity project. If unspecified, the `UNITY_PROJECT_PATH` environment variable will be used, otherwise no project will be specified.
261282
- `--log-name <logName>` The name of the log file.
262-
- `--verbose` Enable verbose logging.
283+
- `--log-level <logLevel>` Override the logger verbosity (`debug`, `info`, `minimal`, `warning`, `error`). Defaults to `info`.
284+
- `--verbose` Enable verbose logging. (Deprecated, use `--log-level <value>` instead)
263285
- `<args...>` Arguments to pass directly to the Unity Editor executable.
264286

287+
> [!NOTE]
288+
> When setting the `--log-level` option to `minimal`, only the unity telemetry logs will be shown in the console output. All other logs will be written to the log file. This option is only supported when running the command locally in the terminal. ***This options is still experimental and may change in future releases.***
289+
>
290+
> When running in CI environments the logger will automatically print the full logs to the console no matter the log level.
291+
265292
```bash
266293
unity-cli run --unity-project <path-to-project> -quit -batchmode -executeMethod StartCommandLineBuild
267294
```
@@ -288,3 +315,37 @@ unity-cli run --unity-project <path-to-project> -quit -batchmode -executeMethod
288315
```bash
289316
unity-cli sign-package --package <path-to-package-folder> --email <your-email> --password <your-password> --organization <your-organization-id>
290317
```
318+
319+
## Logging
320+
321+
### Local cli
322+
323+
`unity-cli` keeps regular terminal runs simple:
324+
325+
- Writes everything to `stdout` with ANSI colors (yellow warnings, red errors) so you can scan logs quickly.
326+
- `startGroup`/`endGroup` just print headers and content, and don't include any foldouts or collapsing behavior and is meant for CI environments only.
327+
328+
### Github Actions
329+
330+
When `GITHUB_ACTIONS=true`, the logger emits GitHub workflow commands automatically:
331+
332+
- Defaults to `info` level; add `--verbose` (or temporarily set `ACTIONS_STEP_DEBUG=true`) to surface `debug` lines.
333+
- `Logger.annotate(...)` escapes `%`, `\r`, and `\n`, then includes `file`, `line`, `endLine`, `col`, `endColumn`, and `title` metadata so annotations are clickable in the Checks UI.
334+
- `startGroup`/`endGroup` become `::group::` / `::endgroup::` blocks.
335+
- Helper methods (`CI_mask`, `CI_setEnvironmentVariable`, `CI_setOutput`, `CI_appendWorkflowSummary`) write to the corresponding GitHub-provided files, so secrets stay masked and workflow outputs update automatically.
336+
337+
The same command line you run locally therefore produces colorized console output on your machine and rich annotations once it runs inside Actions.
338+
339+
### Additional CI Environments
340+
341+
At the moment, only GitHub Actions is supported for enhanced logging. If you would like to see support for additional CI environments, please open a pull request or feature request on the GitHub repository.
342+
343+
#### Roadmap
344+
345+
- [ ] Support Azure DevOps logging commands
346+
- [ ] Support GitLab CI logging commands
347+
- [ ] Support Bitbucket Pipelines logging commands
348+
- [ ] Support Jenkins logging commands
349+
- [ ] Support CircleCI logging commands
350+
- [ ] Support Travis CI logging commands
351+
- [ ] Support TeamCity logging commands

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rage-against-the-pixel/unity-cli",
3-
"version": "1.5.5",
3+
"version": "1.6.0",
44
"description": "A command line utility for the Unity Game Engine.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",
@@ -49,7 +49,7 @@
4949
},
5050
"dependencies": {
5151
"@electron/asar": "^4.0.1",
52-
"@rage-against-the-pixel/unity-releases-api": "^1.0.3",
52+
"@rage-against-the-pixel/unity-releases-api": "^1.0.4",
5353
"commander": "^14.0.2",
5454
"glob": "^11.1.0",
5555
"semver": "^7.7.3",

src/cli.ts

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ program.command('activate-license')
4444
.option('-s, --serial <serial>', 'License serial number. Required when activating a professional license.')
4545
.option('-c, --config <config>', 'Path to the configuration file, or base64 encoded JSON string. Required when activating a floating license.')
4646
.option('--verbose', 'Enable verbose logging.')
47+
.option('--json', 'Prints the last line of output as JSON string.')
4748
.action(async (options) => {
4849
if (options.verbose) {
4950
Logger.instance.logLevel = LogLevel.DEBUG;
@@ -80,19 +81,25 @@ program.command('activate-license')
8081
}
8182
}
8283

83-
await client.Activate({
84+
const token = await client.Activate({
8485
licenseType,
8586
servicesConfig: options.config,
8687
serial: options.serial,
8788
username: options.email,
8889
password: options.password
8990
});
91+
92+
if (licenseType === LicenseType.floating && token && options.json) {
93+
process.stdout.write(`\n${JSON.stringify({ token: token })}\n`);
94+
}
95+
9096
process.exit(0);
9197
});
9298

9399
program.command('return-license')
94100
.description('Return a Unity license.')
95101
.option('-l, --license <license>', 'License type (personal, professional, floating)')
102+
.option('-t, --token <token>', 'Token received when acquiring a floating license lease. Required when returning a floating license.')
96103
.option('--verbose', 'Enable verbose logging.')
97104
.action(async (options) => {
98105
if (options.verbose) {
@@ -116,7 +123,36 @@ program.command('return-license')
116123
process.exit(1);
117124
}
118125

119-
await client.Deactivate(licenseType);
126+
let token: string | undefined = options.token;
127+
128+
if (licenseType === LicenseType.floating) {
129+
if (!token || token.length === 0) {
130+
token = await PromptForSecretInput('Token: ');
131+
}
132+
133+
if (!token || token.length === 0) {
134+
Logger.instance.error('Token is required when returning a floating license. Use -t or --token to specify it.');
135+
process.exit(1);
136+
}
137+
}
138+
139+
await client.Deactivate(licenseType, token);
140+
process.exit(0);
141+
});
142+
143+
program.command('license-context')
144+
.description('Display the context information of the Unity Licensing Client.')
145+
.action(async () => {
146+
const client = new LicensingClient();
147+
await client.Context();
148+
process.exit(0);
149+
});
150+
151+
program.command('licensing-logs')
152+
.description('Print the path to the Unity Licensing Client log files.')
153+
.action(async () => {
154+
const client = new LicensingClient();
155+
process.stdout.write(`${client.logPath()}\n`);
120156
process.exit(0);
121157
});
122158

@@ -359,14 +395,57 @@ program.command('run')
359395
.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.')
360396
.option('--unity-project <unityProject>', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable will be used, otherwise no project will be specified.')
361397
.option('--log-name <logName>', 'The name of the log file.')
362-
.option('--verbose', 'Enable verbose logging.')
398+
.option('--log-level <logLevel>', 'Set the logging level (debug, info, minimal, warning, error).')
399+
.option('--verbose', 'Enable verbose logging. Deprecated, use --log-level instead.')
363400
.allowUnknownOption(true)
364401
.argument('<args...>', 'Arguments to pass to the Unity Editor executable.')
365402
.action(async (args: string[], options) => {
366403
if (options.verbose) {
404+
Logger.instance.warn('The --verbose option is deprecated. Please use "--log-level <value>" instead.');
367405
Logger.instance.logLevel = LogLevel.DEBUG;
368406
}
369407

408+
let requestedLogLevel: LogLevel | undefined;
409+
410+
if (options.logLevel) {
411+
const levelStr: string = options.logLevel?.toString()?.trim().toLowerCase();
412+
413+
switch (levelStr) {
414+
case 'debug':
415+
requestedLogLevel = LogLevel.DEBUG;
416+
break;
417+
case 'ci':
418+
requestedLogLevel = LogLevel.CI;
419+
break;
420+
case 'minimal':
421+
requestedLogLevel = LogLevel.UTP;
422+
break;
423+
case 'info':
424+
requestedLogLevel = LogLevel.INFO;
425+
break;
426+
case 'warning':
427+
requestedLogLevel = LogLevel.WARN;
428+
break;
429+
case 'error':
430+
requestedLogLevel = LogLevel.ERROR;
431+
break;
432+
default:
433+
Logger.instance.warn(`Unknown log level: ${levelStr}. Using default log level.`);
434+
break;
435+
}
436+
}
437+
438+
if (requestedLogLevel === LogLevel.UTP) {
439+
if (process.env.GITHUB_ACTIONS === 'true') {
440+
Logger.instance.warn('The "minimal" log level is not supported in CI environments. Falling back to CI log output.');
441+
Logger.instance.logLevel = LogLevel.CI;
442+
} else {
443+
Logger.instance.logLevel = LogLevel.UTP;
444+
}
445+
} else if (requestedLogLevel) {
446+
Logger.instance.logLevel = requestedLogLevel;
447+
}
448+
370449
Logger.instance.debug(JSON.stringify({ options, args }));
371450

372451
let unityEditor: UnityEditor | undefined;

0 commit comments

Comments
 (0)