@@ -3779,14 +3779,17 @@ class LicensingClient {
37793779 /**
37803780 * Activates a Unity license.
37813781 * @param options The activation options including license type, services config, serial, username, and password.
3782+ * @param skipEntitlementCheck Whether to skip the entitlement check.
37823783 * @returns A promise that resolves when the license is activated.
37833784 * @throws Error if activation fails or required parameters are missing.
37843785 */
3785- async Activate(options) {
3786- let activeLicenses = await this.GetActiveEntitlements();
3787- if (activeLicenses.includes(options.licenseType)) {
3788- this.logger.info(`License of type '${options.licenseType}' is already active, skipping activation`);
3789- return;
3786+ async Activate(options, skipEntitlementCheck = false) {
3787+ if (!skipEntitlementCheck) {
3788+ let activeLicenses = await this.GetActiveEntitlements();
3789+ if (activeLicenses.includes(options.licenseType)) {
3790+ this.logger.info(`License of type '${options.licenseType}' is already active, skipping activation`);
3791+ return;
3792+ }
37903793 }
37913794 switch (options.licenseType) {
37923795 case LicenseType.floating: {
@@ -3988,6 +3991,14 @@ class Logger {
39883991 this.logLevel = process.env.ACTIONS_STEP_DEBUG === 'true' ? LogLevel.DEBUG : LogLevel.CI;
39893992 }
39903993 }
3994+ printLine(message, lineColor, optionalParams = []) {
3995+ if (lineColor && lineColor.length > 0) {
3996+ process.stdout.write(`${lineColor}${message}\x1b[0m\n`, ...optionalParams);
3997+ }
3998+ else {
3999+ process.stdout.write(`${message}\n`, ...optionalParams);
4000+ }
4001+ }
39914002 /**
39924003 * Logs a message to the console.
39934004 * @param level The log level for this message.
@@ -4018,15 +4029,14 @@ class Logger {
40184029 break;
40194030 }
40204031 default: {
4021- const clear = '\x1b[0m';
40224032 const stringColor = {
40234033 [LogLevel.DEBUG]: '\x1b[35m', // Purple
4024- [LogLevel.INFO]: clear , // No color / White
4025- [LogLevel.CI]: clear , // No color / White
4034+ [LogLevel.INFO]: undefined , // No color / White
4035+ [LogLevel.CI]: undefined , // No color / White
40264036 [LogLevel.WARN]: '\x1b[33m', // Yellow
40274037 [LogLevel.ERROR]: '\x1b[31m', // Red
4028- }[level] || clear ; // Default to no color / White
4029- process.stdout.write(`${stringColor}${ message}${clear}\n`, ... optionalParams);
4038+ }[level] || undefined ; // Default to no color / White
4039+ this.printLine( message, stringColor, optionalParams);
40304040 break;
40314041 }
40324042 }
@@ -4042,11 +4052,9 @@ class Logger {
40424052 // then print the rest of the lines inside the group in cyan color
40434053 const firstLine = message.toString().split('\n')[0];
40444054 const restLines = message.toString().split('\n').slice(1);
4045- const cyan = '\x1b[36m';
4046- const clear = '\x1b[0m';
40474055 process.stdout.write(`::group::${firstLine}\n`, ...optionalParams);
40484056 restLines.forEach(line => {
4049- process.stdout.write(`${cyan}${ line}${clear}\n` , ...optionalParams);
4057+ this.printLine( line, '\x1b[36m' , ...optionalParams);
40504058 });
40514059 break;
40524060 }
@@ -4267,12 +4275,12 @@ class UnityEditor {
42674275 this.logger.warn(`No Unity templates found for ${this.version.toString()}`);
42684276 return undefined;
42694277 }
4270- // Build a regex to match the template name and optional version suffix
4271- // e.g., com.unity.template.3d(-cross-platform)?.*
4272- // Supports files (.tgz / . tar.gz) and legacy folder templates without a suffix.
4278+ // Build a regex to match the template name, an optional numeric version suffix, and required file extension
4279+ // Example input: com.unity.template.3d(-cross-platform)?.*
4280+ // Example match: com.unity.template.3d-cross-platform-1.2.3. tar.gz or com.unity.template.3d-1.2.3.tgz
42734281 let regex;
42744282 try {
4275- regex = new RegExp(`^${template}(?:[-.].* )?(?:\.tgz|\.tar\.gz)? $`);
4283+ regex = new RegExp(`^${template}(?:-\\d+\\.\\d+\\.\\d+ )?(?:\\ .tgz|\\ .tar\\ .gz)$`);
42764284 }
42774285 catch (e) {
42784286 throw new Error(`Invalid template regex: ${template}`);
@@ -4297,7 +4305,7 @@ class UnityEditor {
42974305 * @returns An array of available template file names.
42984306 */
42994307 GetAvailableTemplates() {
4300- if (this.version.isLessThan('2018 .0.0')) {
4308+ if (this.version.isLessThan('2019 .0.0')) {
43014309 this.logger.warn(`Unity version ${this.version.toString()} does not support project templates.`);
43024310 return [];
43034311 }
@@ -4354,19 +4362,38 @@ class UnityEditor {
43544362 if (!command.args || command.args.length === 0) {
43554363 throw Error('No command arguments provided for Unity execution');
43564364 }
4357- if (!command.args.includes(`-automated`)) {
4358- command.args.push(`-automated`);
4359- }
4360- if (!command.args.includes(`-batchmode`)) {
4361- command.args.push(`-batchmode`);
4362- }
43634365 if (this.autoAddNoGraphics &&
43644366 !command.args.includes(`-nographics`) &&
43654367 !command.args.includes(`-force-graphics`)) {
4366- command.args.push(`-nographics`);
4368+ command.args.unshift(`-nographics`);
4369+ }
4370+ if (!command.args.includes(`-batchmode`)) {
4371+ command.args.unshift(`-batchmode`);
4372+ }
4373+ if (!command.args.includes(`-automated`)) {
4374+ command.args.unshift(`-automated`);
43674375 }
43684376 if (!command.args.includes('-logFile')) {
4369- command.args.push('-logFile', this.GenerateLogFilePath(command.projectPath));
4377+ command.args.unshift('-logFile', this.GenerateLogFilePath(command.projectPath));
4378+ }
4379+ else {
4380+ const existingLogPath = (0, utilities_1.GetArgumentValueAsString)('-logFile', command.args);
4381+ command.args.splice(command.args.indexOf(existingLogPath) - 1, 2);
4382+ command.args.unshift('-logFile', existingLogPath);
4383+ }
4384+ if (command.projectPath) {
4385+ if (!command.args.includes('-projectPath')) {
4386+ command.args.unshift('-projectPath', command.projectPath);
4387+ }
4388+ else {
4389+ const existingPath = (0, utilities_1.GetArgumentValueAsString)('-projectPath', command.args);
4390+ if (existingPath !== command.projectPath) {
4391+ throw Error(`Conflicting project paths provided. Argument: "${existingPath}", Command: "${command.projectPath}"`);
4392+ }
4393+ // Ensure -projectPath is the first argument
4394+ command.args.splice(command.args.indexOf(existingPath) - 1, 2);
4395+ command.args.unshift('-projectPath', command.projectPath);
4396+ }
43704397 }
43714398 const logPath = (0, utilities_1.GetArgumentValueAsString)('-logFile', command.args);
43724399 logTail = (0, utilities_1.TailLogFile)(logPath);
0 commit comments