Skip to content

Commit 01296f2

Browse files
remove temp pidFile
updated hub install command visibility
1 parent 824b773 commit 01296f2

3 files changed

Lines changed: 15 additions & 37 deletions

File tree

src/unity-editor.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class UnityEditor {
2222
public readonly editorRootPath: string;
2323

2424
private readonly logger: Logger = Logger.instance;
25-
private readonly pidFile: string;
2625
private readonly autoAddNoGraphics: boolean;
2726

2827
private procInfo: ProcInfo | undefined;
@@ -39,7 +38,6 @@ export class UnityEditor {
3938

4039
fs.accessSync(editorPath, fs.constants.X_OK);
4140
this.editorRootPath = UnityEditor.GetEditorRootPath(editorPath);
42-
this.pidFile = path.join(process.env.RUNNER_TEMP || process.env.USERPROFILE || '.', '.unity', 'unity-editor-process-id.txt');
4341

4442
const match = editorPath.match(/(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/);
4543

@@ -231,26 +229,6 @@ export class UnityEditor {
231229

232230
onPid({ pid: processId, ppid: process.pid, name: this.editorPath });
233231
this.logger.debug(`Unity process started with pid: ${processId}`);
234-
// make sure the directory for the PID file exists
235-
const pidDir = path.dirname(this.pidFile);
236-
237-
if (!fs.existsSync(pidDir)) {
238-
fs.mkdirSync(pidDir, { recursive: true });
239-
} else {
240-
try {
241-
var existingProcInfo = await ReadPidFile(this.pidFile);
242-
if (existingProcInfo) {
243-
const killedPid = await TryKillProcess(existingProcInfo);
244-
if (killedPid) {
245-
this.logger.warn(`Killed existing Unity process with pid: ${killedPid}`);
246-
}
247-
}
248-
} catch {
249-
// PID file does not exist, continue
250-
}
251-
}
252-
// Write the PID to the PID file
253-
fs.writeFileSync(this.pidFile, String(processId));
254232
const logPollingInterval = 100; // milliseconds
255233
// Wait for log file to appear
256234
while (!fs.existsSync(logPath)) {

src/unity-hub.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ sudo apt-get install -y --no-install-recommends --only-upgrade unityhub`]);
201201
}
202202

203203
private async installHub(): Promise<void> {
204+
this.logger.ci(`Installing Unity Hub...`);
204205
switch (process.platform) {
205206
case 'win32': {
206207
const url = 'https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.exe';
@@ -210,7 +211,7 @@ sudo apt-get install -y --no-install-recommends --only-upgrade unityhub`]);
210211
this.logger.info(`Running Unity Hub installer...`);
211212

212213
try {
213-
await Exec(downloadPath, ['/S'], { silent: true });
214+
await Exec(downloadPath, ['/S'], { silent: true, showCommand: true });
214215
} finally {
215216
if (fs.statSync(downloadPath).isFile()) {
216217
await fs.promises.unlink(downloadPath);
@@ -223,7 +224,6 @@ sudo apt-get install -y --no-install-recommends --only-upgrade unityhub`]);
223224
const baseUrl = 'https://public-cdn.cloud.unity3d.com/hub/prod';
224225
const url = `${baseUrl}/UnityHubSetup-${process.arch}.dmg`;
225226
const downloadPath = path.join(GetTempDir(), `UnityHubSetup-${process.arch}.dmg`);
226-
this.logger.info(`Downloading Unity Hub from ${url} to ${downloadPath}`);
227227

228228
await DownloadFile(url, downloadPath);
229229
await fs.promises.chmod(downloadPath, 0o777);
@@ -232,7 +232,7 @@ sudo apt-get install -y --no-install-recommends --only-upgrade unityhub`]);
232232
this.logger.debug(`Mounting DMG...`);
233233

234234
try {
235-
const output = await Exec('hdiutil', ['attach', downloadPath, '-nobrowse'], { silent: true });
235+
const output = await Exec('hdiutil', ['attach', downloadPath, '-nobrowse'], { silent: true, showCommand: true });
236236
// can be "/Volumes/Unity Hub 3.13.1-arm64" or "/Volumes/Unity Hub 3.13.1"
237237
const mountPointMatch = output.match(/\/Volumes\/Unity Hub.*$/m);
238238

@@ -248,16 +248,16 @@ sudo apt-get install -y --no-install-recommends --only-upgrade unityhub`]);
248248

249249
await fs.promises.access(appPath, fs.constants.R_OK | fs.constants.X_OK);
250250
if (fs.existsSync('/Applications/Unity Hub.app')) {
251-
await Exec('sudo', ['rm', '-rf', '/Applications/Unity Hub.app'], { silent: true });
251+
await Exec('sudo', ['rm', '-rf', '/Applications/Unity Hub.app'], { silent: true, showCommand: true });
252252
}
253-
await Exec('sudo', ['cp', '-R', appPath, '/Applications/Unity Hub.app'], { silent: true });
254-
await Exec('sudo', ['chmod', '777', '/Applications/Unity Hub.app/Contents/MacOS/Unity Hub'], { silent: true });
255-
await Exec('sudo', ['mkdir', '-p', '/Library/Application Support/Unity'], { silent: true });
256-
await Exec('sudo', ['chmod', '777', '/Library/Application Support/Unity'], { silent: true });
253+
await Exec('sudo', ['cp', '-R', appPath, '/Applications/Unity Hub.app'], { silent: true, showCommand: true });
254+
await Exec('sudo', ['chmod', '777', '/Applications/Unity Hub.app/Contents/MacOS/Unity Hub'], { silent: true, showCommand: true });
255+
await Exec('sudo', ['mkdir', '-p', '/Library/Application Support/Unity'], { silent: true, showCommand: true });
256+
await Exec('sudo', ['chmod', '777', '/Library/Application Support/Unity'], { silent: true, showCommand: true });
257257
} finally {
258258
try {
259259
if (mountPoint && mountPoint.length > 0) {
260-
await Exec('hdiutil', ['detach', mountPoint, '-quiet'], { silent: true });
260+
await Exec('hdiutil', ['detach', mountPoint, '-quiet'], { silent: true, showCommand: true });
261261
}
262262
} finally {
263263
if (fs.statSync(downloadPath).isFile()) {
@@ -295,7 +295,7 @@ chmod -R 777 "$hubPath"`]);
295295
}
296296

297297
await fs.promises.access(this.executable, fs.constants.X_OK);
298-
this.logger.info(`Unity Hub installed successfully.`);
298+
this.logger.debug(`Unity Hub install complete`);
299299
}
300300

301301
private async getInstalledHubVersion(): Promise<SemVer> {
@@ -861,7 +861,7 @@ done
861861
this.logger.info(`Running Unity ${unityVersion.toString()} installer...`);
862862

863863
try {
864-
await Exec(installerPath, ['/S', `/D=${installPath}`, '-Wait', '-NoNewWindow'], { silent: true });
864+
await Exec(installerPath, ['/S', `/D=${installPath}`, '-Wait', '-NoNewWindow'], { silent: true, showCommand: true });
865865
} catch (error) {
866866
this.logger.error(`Failed to install Unity ${unityVersion.toString()}: ${error}`);
867867
} finally {
@@ -885,7 +885,7 @@ done
885885
let mountPoint = '';
886886

887887
try {
888-
const output = await Exec('hdiutil', ['attach', installerPath, '-nobrowse'], { silent: true });
888+
const output = await Exec('hdiutil', ['attach', installerPath, '-nobrowse'], { silent: true, showCommand: true });
889889
const mountPointMatch = output.match(/\/Volumes\/Unity Installer.*$/m);
890890

891891
if (!mountPointMatch || mountPointMatch.length === 0) {
@@ -899,7 +899,7 @@ done
899899
await fs.promises.access(pkgPath, fs.constants.R_OK);
900900

901901
this.logger.debug(`Found .pkg installer: ${pkgPath}`);
902-
await Exec('sudo', ['installer', '-pkg', pkgPath, '-target', '/', '-verboseR'], { silent: true });
902+
await Exec('sudo', ['installer', '-pkg', pkgPath, '-target', '/', '-verboseR'], { silent: true, showCommand: true });
903903
const unityAppPath = path.join('/Applications', 'Unity');
904904
const targetPath = path.join(installDir, `Unity ${unityVersion.version}`);
905905

@@ -928,7 +928,7 @@ done
928928
} finally {
929929
try {
930930
if (mountPoint && mountPoint.length > 0) {
931-
await Exec('hdiutil', ['detach', mountPoint, '-quiet'], { silent: true });
931+
await Exec('hdiutil', ['detach', mountPoint, '-quiet'], { silent: true, showCommand: true });
932932
}
933933
} finally {
934934
await fs.promises.unlink(installerPath);

src/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export async function Exec(command: string, args: string[], options: ExecOptions
129129
* @throws An error if the download fails or the file is not accessible after download.
130130
*/
131131
export async function DownloadFile(url: string, downloadPath: string): Promise<void> {
132-
logger.debug(`Downloading from ${url} to ${downloadPath}...`);
132+
logger.ci(`Downloading from ${url} to ${downloadPath}...`);
133133
await fs.promises.mkdir(path.dirname(downloadPath), { recursive: true });
134134
await new Promise<void>((resolve, reject) => {
135135
const file = fs.createWriteStream(downloadPath, { mode: 0o755 });

0 commit comments

Comments
 (0)