-
-
Notifications
You must be signed in to change notification settings - Fork 312
Expand file tree
/
Copy pathplatform-setup.ts
More file actions
48 lines (38 loc) · 1.61 KB
/
Copy pathplatform-setup.ts
File metadata and controls
48 lines (38 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import fs from 'node:fs';
import * as core from '@actions/core';
import { BuildParameters } from '.';
import { SetupMac, SetupWindows, SetupAndroid } from './platform-setup/';
import ValidateWindows from './platform-validation/validate-windows';
class PlatformSetup {
static async setup(buildParameters: BuildParameters, actionFolder: string) {
PlatformSetup.SetupShared(buildParameters, actionFolder);
switch (process.platform) {
case 'win32':
ValidateWindows.validate(buildParameters);
SetupWindows.setup(buildParameters);
break;
case 'darwin':
await SetupMac.setup(buildParameters, actionFolder);
break;
// Add other baseOS's here
}
}
private static SetupShared(buildParameters: BuildParameters, actionFolder: string) {
const servicesConfigPath = `${actionFolder}/unity-config/services-config.json`;
const servicesConfigPathTemplate = `${servicesConfigPath}.template`;
if (!fs.existsSync(servicesConfigPathTemplate)) {
core.error(`Missing services config ${servicesConfigPathTemplate}`);
return;
}
let servicesConfig = fs.readFileSync(servicesConfigPathTemplate).toString();
servicesConfig = servicesConfig.replace('%URL%', buildParameters.unityLicensingServer);
if (buildParameters.unityLicensingToolset) {
const parsed = JSON.parse(servicesConfig);
parsed.toolset = buildParameters.unityLicensingToolset;
servicesConfig = JSON.stringify(parsed, undefined, 2);
}
fs.writeFileSync(servicesConfigPath, servicesConfig);
SetupAndroid.setup(buildParameters);
}
}
export default PlatformSetup;