Skip to content

Commit 4e0e7af

Browse files
unity-cli@v1.6.9 (#57)
- skip entitlements check for floating licenses - add --showContext call when polling for license server configuration updates
1 parent 30388b0 commit 4e0e7af

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
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.6.8",
3+
"version": "1.6.9",
44
"description": "A command line utility for the Unity Game Engine.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ program.command('activate-license')
4242
.option('-e, --email <email>', 'Email associated with the Unity account. Required when activating a personal or professional license.')
4343
.option('-p, --password <password>', 'Password for the Unity account. Required when activating a personal or professional license.')
4444
.option('-s, --serial <serial>', 'License serial number. Required when activating a professional license.')
45-
.option('-c, --config <config>', 'Path to the configuration file, or base64 encoded JSON string. Required when activating a floating license.')
45+
.option('-c, --config <config>', 'Path to the configuration file, raw JSON, or base64 encoded JSON string. Required when activating a floating license.')
4646
.option('--verbose', 'Enable verbose logging.')
4747
.option('--json', 'Prints the last line of output as JSON string.')
4848
.action(async (options) => {

src/license-client.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ export class LicensingClient {
513513
}
514514
catch (error) {
515515
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
516-
this.logger.debug(`Failed to inspect licensing client log: ${error}`);
516+
this.logger.error(`Failed to inspect licensing client log: ${error}`);
517+
continue;
517518
}
518519
}
519520

@@ -531,11 +532,12 @@ export class LicensingClient {
531532
}
532533

533534
if (notConfiguredPattern.test(line)) {
534-
this.logger.warn('Floating license server is not configured. Waiting for configuration...');
535+
this.logger.debug('Floating license server is not configured. Waiting for configuration...');
535536
}
536537
}
537538
}
538539

540+
await this.exec(['--showContext'], true);
539541
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
540542
}
541543

@@ -561,6 +563,9 @@ export class LicensingClient {
561563
this.logger.debug(`Using services config at: ${servicesConfigPath}`);
562564
}
563565

566+
// For floating licenses, skip the entitlement check
567+
skipEntitlementCheck = options.licenseType === LicenseType.floating;
568+
564569
if (!skipEntitlementCheck) {
565570
const activeLicenses = await this.GetActiveEntitlements();
566571

@@ -572,7 +577,6 @@ export class LicensingClient {
572577

573578
switch (options.licenseType) {
574579
case LicenseType.floating: {
575-
await this.Context();
576580
await this.waitForLicenseServerConfiguration();
577581
const output = await this.exec([`--acquire-floating`], true);
578582
const tokenMatch = output.match(/with token:\s*"(?<token>[\w-]+)"/);

tests/license-client.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,24 @@ describe('LicensingClient services config handling', () => {
3939
});
4040

4141
describe('LicensingClient floating activation order', () => {
42-
it('prepares services config before checking entitlements', async () => {
42+
it('prepares services config without checking entitlements', async () => {
4343
const client = new LicensingClient();
4444
const setupSpy = jest.spyOn(client as any, 'setupServicesConfig').mockResolvedValue('/tmp/services-config.json');
4545
const entitlementsSpy = jest.spyOn(client, 'GetActiveEntitlements').mockResolvedValue([]);
4646
jest.spyOn(client, 'Context').mockResolvedValue();
47-
jest.spyOn(client as any, 'waitForLicenseServerConfiguration').mockResolvedValue(undefined);
48-
jest.spyOn(client as any, 'exec').mockResolvedValue('Successfully acquired with token: "token-123"');
47+
const waitSpy = jest.spyOn(client as any, 'waitForLicenseServerConfiguration').mockResolvedValue(undefined);
48+
const execSpy = jest.spyOn(client as any, 'exec').mockResolvedValue('Successfully acquired with token: "token-123"');
4949

5050
await client.Activate({
5151
licenseType: LicenseType.floating,
5252
servicesConfig: '{"floatingServer":"https://example.com"}'
5353
});
5454

5555
expect(setupSpy).toHaveBeenCalledTimes(1);
56-
expect(entitlementsSpy).toHaveBeenCalledTimes(1);
57-
expect(entitlementsSpy.mock.invocationCallOrder[0]).toBeGreaterThan(setupSpy.mock.invocationCallOrder[0]);
56+
expect(entitlementsSpy).not.toHaveBeenCalled();
57+
expect(waitSpy).toHaveBeenCalledTimes(1);
58+
expect(execSpy).toHaveBeenCalledTimes(1);
59+
expect(execSpy.mock.invocationCallOrder[0]).toBeGreaterThan(waitSpy.mock.invocationCallOrder[0]);
5860
});
5961
});
6062

@@ -69,6 +71,7 @@ describe('LicensingClient waitForLicenseServerConfiguration', () => {
6971
const client = new LicensingClient();
7072
const tempLog = createTempLog();
7173
jest.spyOn(LicensingClient, 'ClientLogPath').mockReturnValue(tempLog);
74+
jest.spyOn(client as any, 'exec').mockResolvedValue('');
7275

7376
setTimeout(() => {
7477
fs.appendFileSync(tempLog, '\nFloating license server URL is: https://example.com (via config file)\n');
@@ -82,6 +85,7 @@ describe('LicensingClient waitForLicenseServerConfiguration', () => {
8285
const client = new LicensingClient();
8386
const tempLog = createTempLog();
8487
jest.spyOn(LicensingClient, 'ClientLogPath').mockReturnValue(tempLog);
88+
jest.spyOn(client as any, 'exec').mockResolvedValue('');
8589

8690
await expect((client as any).waitForLicenseServerConfiguration(200, 10)).rejects.toThrow(/Timed out waiting for floating license server configuration/);
8791
fs.rmSync(tempLog, { force: true });

0 commit comments

Comments
 (0)