Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
11 changes: 10 additions & 1 deletion dist/platforms/mac/steps/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then
mkdir -p "$UNITY_LICENSE_PATH/config/"
cp "$ACTION_FOLDER/unity-config/services-config.json" "$UNITY_LICENSE_PATH/config/services-config.json"

/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \
UNITY_EDITOR_DIR="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app"
UNITY_LICENSING_CLIENT_SUBDIR="Frameworks"

# Unity 6000.3+ moved UnityLicensingClient from Contents/Frameworks to Contents/Helpers.
# See: https://docs.unity.com/en-us/licensing-server/client-config
if [[ "$UNITY_VERSION" =~ ^6000\.([3-9]|[1-9][0-9]) ]]; then
UNITY_LICENSING_CLIENT_SUBDIR="Helpers"
fi

"$UNITY_EDITOR_DIR/Contents/$UNITY_LICENSING_CLIENT_SUBDIR/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client" \
--acquire-floating > license.txt

# Store the exit code from the verify command
Expand Down
11 changes: 10 additions & 1 deletion dist/platforms/mac/steps/return_license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ if [[ -n "$UNITY_LICENSING_SERVER" ]]; then
# Return any floating license used.
#
echo "Returning floating license: \"$FLOATING_LICENSE\""
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \
UNITY_EDITOR_DIR="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app"
UNITY_LICENSING_CLIENT_SUBDIR="Frameworks"

# Unity 6000.3+ moved UnityLicensingClient from Contents/Frameworks to Contents/Helpers.
# See: https://docs.unity.com/en-us/licensing-server/client-config
if [[ "$UNITY_VERSION" =~ ^6000\.([3-9]|[1-9][0-9]) ]]; then
UNITY_LICENSING_CLIENT_SUBDIR="Helpers"
fi

"$UNITY_EDITOR_DIR/Contents/$UNITY_LICENSING_CLIENT_SUBDIR/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client" \
--return-floating "$FLOATING_LICENSE"
elif [[ -n "$UNITY_SERIAL" ]]; then
#
Expand Down
29 changes: 29 additions & 0 deletions src/integrity.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
import { describe, it, expect, vi, beforeEach, afterEach, beforeAll, afterAll, test } from 'vitest';
import { stat } from 'node:fs/promises';
import { readFile } from 'node:fs/promises';

describe('Integrity tests', () => {
describe('package-lock.json', () => {
it('does not exist', async () => {
await expect(stat(`${process.cwd()}/package-lock.json`)).rejects.toThrowError();
});
});

describe('mac licensing scripts', () => {
it('activate script switches Unity Licensing Client path for Unity 6000.3+', async () => {
const activateScriptPath = `${process.cwd()}/dist/platforms/mac/steps/activate.sh`;
const activateScript = await readFile(activateScriptPath, 'utf8');

expect(activateScript).toContain('UNITY_LICENSING_CLIENT_SUBDIR="Frameworks"');
expect(activateScript).toContain('UNITY_LICENSING_CLIENT_SUBDIR="Helpers"');
expect(activateScript).toContain('^6000\\.([3-9]|[1-9][0-9])');
expect(activateScript).toContain('https://docs.unity.com/en-us/licensing-server/client-config');
expect(activateScript).toContain(
'"$UNITY_EDITOR_DIR/Contents/$UNITY_LICENSING_CLIENT_SUBDIR/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client"',
);
});

it('return license script uses the same Unity version-gated path logic', async () => {
const returnLicenseScriptPath = `${process.cwd()}/dist/platforms/mac/steps/return_license.sh`;
const returnLicenseScript = await readFile(returnLicenseScriptPath, 'utf8');

expect(returnLicenseScript).toContain('UNITY_LICENSING_CLIENT_SUBDIR="Frameworks"');
expect(returnLicenseScript).toContain('UNITY_LICENSING_CLIENT_SUBDIR="Helpers"');
expect(returnLicenseScript).toContain('^6000\\.([3-9]|[1-9][0-9])');
expect(returnLicenseScript).toContain('https://docs.unity.com/en-us/licensing-server/client-config');
expect(returnLicenseScript).toContain(
'"$UNITY_EDITOR_DIR/Contents/$UNITY_LICENSING_CLIENT_SUBDIR/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client"',
);
});
});
});
Loading