Use nullish coalescing operator

pull/629/head
Andrew Kahr 2024-02-18 02:33:51 -08:00
parent ae7ec67e88
commit 3fcdb9f099
4 changed files with 81 additions and 81 deletions

80
dist/index.js generated vendored
View File

@ -316,7 +316,7 @@ class BuildParameters {
customParameters: input_1.default.customParameters, customParameters: input_1.default.customParameters,
sshAgent: input_1.default.sshAgent, sshAgent: input_1.default.sshAgent,
sshPublicKeysDirectoryPath: input_1.default.sshPublicKeysDirectoryPath, sshPublicKeysDirectoryPath: input_1.default.sshPublicKeysDirectoryPath,
gitPrivateToken: input_1.default.gitPrivateToken || (await github_cli_1.GithubCliReader.GetGitHubAuthToken()), gitPrivateToken: input_1.default.gitPrivateToken ?? (await github_cli_1.GithubCliReader.GetGitHubAuthToken()),
runAsHostUser: input_1.default.runAsHostUser, runAsHostUser: input_1.default.runAsHostUser,
chownFilesTo: input_1.default.chownFilesTo, chownFilesTo: input_1.default.chownFilesTo,
dockerCpuLimit: input_1.default.dockerCpuLimit, dockerCpuLimit: input_1.default.dockerCpuLimit,
@ -338,7 +338,7 @@ class BuildParameters {
branch: input_1.default.branch.replace('/head', '') || (await git_repo_1.GitRepoReader.GetBranch()), branch: input_1.default.branch.replace('/head', '') || (await git_repo_1.GitRepoReader.GetBranch()),
cloudRunnerBranch: cloud_runner_options_1.default.cloudRunnerBranch.split('/').reverse()[0], cloudRunnerBranch: cloud_runner_options_1.default.cloudRunnerBranch.split('/').reverse()[0],
cloudRunnerDebug: cloud_runner_options_1.default.cloudRunnerDebug, cloudRunnerDebug: cloud_runner_options_1.default.cloudRunnerDebug,
githubRepo: input_1.default.githubRepo || (await git_repo_1.GitRepoReader.GetRemote()) || 'game-ci/unity-builder', githubRepo: (input_1.default.githubRepo ?? (await git_repo_1.GitRepoReader.GetRemote())) || 'game-ci/unity-builder',
isCliMode: cli_1.Cli.isCliMode, isCliMode: cli_1.Cli.isCliMode,
awsStackName: cloud_runner_options_1.default.awsStackName, awsStackName: cloud_runner_options_1.default.awsStackName,
gitSha: input_1.default.gitSha, gitSha: input_1.default.gitSha,
@ -6908,10 +6908,10 @@ class Input {
} }
} }
static get region() { static get region() {
return Input.getInput('region') || 'eu-west-2'; return Input.getInput('region') ?? 'eu-west-2';
} }
static get githubRepo() { static get githubRepo() {
return Input.getInput('GITHUB_REPOSITORY') || Input.getInput('GITHUB_REPO') || undefined; return Input.getInput('GITHUB_REPOSITORY') ?? Input.getInput('GITHUB_REPO') ?? undefined;
} }
static get branch() { static get branch() {
if (Input.getInput(`GITHUB_REF`)) { if (Input.getInput(`GITHUB_REF`)) {
@ -6934,16 +6934,16 @@ class Input {
return ''; return '';
} }
static get runNumber() { static get runNumber() {
return Input.getInput('GITHUB_RUN_NUMBER') || '0'; return Input.getInput('GITHUB_RUN_NUMBER') ?? '0';
} }
static get targetPlatform() { static get targetPlatform() {
return Input.getInput('targetPlatform') || platform_1.default.default; return Input.getInput('targetPlatform') ?? platform_1.default.default;
} }
static get unityVersion() { static get unityVersion() {
return Input.getInput('unityVersion') || 'auto'; return Input.getInput('unityVersion') ?? 'auto';
} }
static get customImage() { static get customImage() {
return Input.getInput('customImage') || ''; return Input.getInput('customImage') ?? '';
} }
static get projectPath() { static get projectPath() {
const input = Input.getInput('projectPath'); const input = Input.getInput('projectPath');
@ -6961,85 +6961,85 @@ class Input {
return rawProjectPath.replace(/\/$/, ''); return rawProjectPath.replace(/\/$/, '');
} }
static get runnerTempPath() { static get runnerTempPath() {
return Input.getInput('RUNNER_TEMP') || ''; return Input.getInput('RUNNER_TEMP') ?? '';
} }
static get buildName() { static get buildName() {
return Input.getInput('buildName') || Input.targetPlatform; return Input.getInput('buildName') ?? Input.targetPlatform;
} }
static get buildsPath() { static get buildsPath() {
return Input.getInput('buildsPath') || 'build'; return Input.getInput('buildsPath') ?? 'build';
} }
static get unityLicensingServer() { static get unityLicensingServer() {
return Input.getInput('unityLicensingServer') || ''; return Input.getInput('unityLicensingServer') ?? '';
} }
static get buildMethod() { static get buildMethod() {
return Input.getInput('buildMethod') || ''; // Processed in docker file return Input.getInput('buildMethod') ?? ''; // Processed in docker file
} }
static get manualExit() { static get manualExit() {
const input = Input.getInput('manualExit') || false; const input = Input.getInput('manualExit') ?? false;
return input === 'true'; return input === 'true';
} }
static get customParameters() { static get customParameters() {
return Input.getInput('customParameters') || ''; return Input.getInput('customParameters') ?? '';
} }
static get versioningStrategy() { static get versioningStrategy() {
return Input.getInput('versioning') || 'Semantic'; return Input.getInput('versioning') ?? 'Semantic';
} }
static get specifiedVersion() { static get specifiedVersion() {
return Input.getInput('version') || ''; return Input.getInput('version') ?? '';
} }
static get androidVersionCode() { static get androidVersionCode() {
return Input.getInput('androidVersionCode') || ''; return Input.getInput('androidVersionCode') ?? '';
} }
static get androidExportType() { static get androidExportType() {
return Input.getInput('androidExportType') || 'androidPackage'; return Input.getInput('androidExportType') ?? 'androidPackage';
} }
static get androidKeystoreName() { static get androidKeystoreName() {
return Input.getInput('androidKeystoreName') || ''; return Input.getInput('androidKeystoreName') ?? '';
} }
static get androidKeystoreBase64() { static get androidKeystoreBase64() {
return Input.getInput('androidKeystoreBase64') || ''; return Input.getInput('androidKeystoreBase64') ?? '';
} }
static get androidKeystorePass() { static get androidKeystorePass() {
return Input.getInput('androidKeystorePass') || ''; return Input.getInput('androidKeystorePass') ?? '';
} }
static get androidKeyaliasName() { static get androidKeyaliasName() {
return Input.getInput('androidKeyaliasName') || ''; return Input.getInput('androidKeyaliasName') ?? '';
} }
static get androidKeyaliasPass() { static get androidKeyaliasPass() {
return Input.getInput('androidKeyaliasPass') || ''; return Input.getInput('androidKeyaliasPass') ?? '';
} }
static get androidTargetSdkVersion() { static get androidTargetSdkVersion() {
return Input.getInput('androidTargetSdkVersion') || ''; return Input.getInput('androidTargetSdkVersion') ?? '';
} }
static get androidSymbolType() { static get androidSymbolType() {
return Input.getInput('androidSymbolType') || 'none'; return Input.getInput('androidSymbolType') ?? 'none';
} }
static get sshAgent() { static get sshAgent() {
return Input.getInput('sshAgent') || ''; return Input.getInput('sshAgent') ?? '';
} }
static get sshPublicKeysDirectoryPath() { static get sshPublicKeysDirectoryPath() {
return Input.getInput('sshPublicKeysDirectoryPath') || ''; return Input.getInput('sshPublicKeysDirectoryPath') ?? '';
} }
static get gitPrivateToken() { static get gitPrivateToken() {
return Input.getInput('gitPrivateToken'); return Input.getInput('gitPrivateToken');
} }
static get runAsHostUser() { static get runAsHostUser() {
return Input.getInput('runAsHostUser')?.toLowerCase() || 'false'; return Input.getInput('runAsHostUser')?.toLowerCase() ?? 'false';
} }
static get chownFilesTo() { static get chownFilesTo() {
return Input.getInput('chownFilesTo') || ''; return Input.getInput('chownFilesTo') ?? '';
} }
static get allowDirtyBuild() { static get allowDirtyBuild() {
const input = Input.getInput('allowDirtyBuild') || false; const input = Input.getInput('allowDirtyBuild') ?? false;
return input === 'true'; return input === 'true';
} }
static get cacheUnityInstallationOnMac() { static get cacheUnityInstallationOnMac() {
const input = Input.getInput('cacheUnityInstallationOnMac') || false; const input = Input.getInput('cacheUnityInstallationOnMac') ?? false;
return input === 'true'; return input === 'true';
} }
static get unityHubVersionOnMac() { static get unityHubVersionOnMac() {
const input = Input.getInput('unityHubVersionOnMac') || ''; const input = Input.getInput('unityHubVersionOnMac') ?? '';
return input !== '' ? input : ''; return input !== '' ? input : '';
} }
static get unitySerial() { static get unitySerial() {
@ -7049,10 +7049,10 @@ class Input {
return Input.getInput('UNITY_LICENSE'); return Input.getInput('UNITY_LICENSE');
} }
static get dockerWorkspacePath() { static get dockerWorkspacePath() {
return Input.getInput('dockerWorkspacePath') || '/github/workspace'; return Input.getInput('dockerWorkspacePath') ?? '/github/workspace';
} }
static get dockerCpuLimit() { static get dockerCpuLimit() {
return Input.getInput('dockerCpuLimit') || node_os_1.default.cpus().length.toString(); return Input.getInput('dockerCpuLimit') ?? node_os_1.default.cpus().length.toString();
} }
static get dockerMemoryLimit() { static get dockerMemoryLimit() {
const bytesInMegabyte = 1024 * 1024; const bytesInMegabyte = 1024 * 1024;
@ -7068,19 +7068,19 @@ class Input {
memoryMultiplier = 0.75; memoryMultiplier = 0.75;
break; break;
} }
return (Input.getInput('dockerMemoryLimit') || `${Math.floor((node_os_1.default.totalmem() / bytesInMegabyte) * memoryMultiplier)}m`); return (Input.getInput('dockerMemoryLimit') ?? `${Math.floor((node_os_1.default.totalmem() / bytesInMegabyte) * memoryMultiplier)}m`);
} }
static get dockerIsolationMode() { static get dockerIsolationMode() {
return Input.getInput('dockerIsolationMode') || 'default'; return Input.getInput('dockerIsolationMode') ?? 'default';
} }
static get containerRegistryRepository() { static get containerRegistryRepository() {
return Input.getInput('containerRegistryRepository') || 'unityci/editor'; return Input.getInput('containerRegistryRepository') ?? 'unityci/editor';
} }
static get containerRegistryImageVersion() { static get containerRegistryImageVersion() {
return Input.getInput('containerRegistryImageVersion') || '3'; return Input.getInput('containerRegistryImageVersion') ?? '3';
} }
static get skipActivation() { static get skipActivation() {
return Input.getInput('skipActivation')?.toLowerCase() || 'false'; return Input.getInput('skipActivation')?.toLowerCase() ?? 'false';
} }
static ToEnvVarFormat(input) { static ToEnvVarFormat(input) {
if (input.toUpperCase() === input) { if (input.toUpperCase() === input) {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -170,7 +170,7 @@ class BuildParameters {
customParameters: Input.customParameters, customParameters: Input.customParameters,
sshAgent: Input.sshAgent, sshAgent: Input.sshAgent,
sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath, sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath,
gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()), gitPrivateToken: Input.gitPrivateToken ?? (await GithubCliReader.GetGitHubAuthToken()),
runAsHostUser: Input.runAsHostUser, runAsHostUser: Input.runAsHostUser,
chownFilesTo: Input.chownFilesTo, chownFilesTo: Input.chownFilesTo,
dockerCpuLimit: Input.dockerCpuLimit, dockerCpuLimit: Input.dockerCpuLimit,
@ -192,7 +192,7 @@ class BuildParameters {
branch: Input.branch.replace('/head', '') || (await GitRepoReader.GetBranch()), branch: Input.branch.replace('/head', '') || (await GitRepoReader.GetBranch()),
cloudRunnerBranch: CloudRunnerOptions.cloudRunnerBranch.split('/').reverse()[0], cloudRunnerBranch: CloudRunnerOptions.cloudRunnerBranch.split('/').reverse()[0],
cloudRunnerDebug: CloudRunnerOptions.cloudRunnerDebug, cloudRunnerDebug: CloudRunnerOptions.cloudRunnerDebug,
githubRepo: Input.githubRepo || (await GitRepoReader.GetRemote()) || 'game-ci/unity-builder', githubRepo: (Input.githubRepo ?? (await GitRepoReader.GetRemote())) || 'game-ci/unity-builder',
isCliMode: Cli.isCliMode, isCliMode: Cli.isCliMode,
awsStackName: CloudRunnerOptions.awsStackName, awsStackName: CloudRunnerOptions.awsStackName,
gitSha: Input.gitSha, gitSha: Input.gitSha,

View File

@ -46,11 +46,11 @@ class Input {
} }
static get region(): string { static get region(): string {
return Input.getInput('region') || 'eu-west-2'; return Input.getInput('region') ?? 'eu-west-2';
} }
static get githubRepo(): string | undefined { static get githubRepo(): string | undefined {
return Input.getInput('GITHUB_REPOSITORY') || Input.getInput('GITHUB_REPO') || undefined; return Input.getInput('GITHUB_REPOSITORY') ?? Input.getInput('GITHUB_REPO') ?? undefined;
} }
static get branch(): string { static get branch(): string {
@ -74,19 +74,19 @@ class Input {
} }
static get runNumber(): string { static get runNumber(): string {
return Input.getInput('GITHUB_RUN_NUMBER') || '0'; return Input.getInput('GITHUB_RUN_NUMBER') ?? '0';
} }
static get targetPlatform(): string { static get targetPlatform(): string {
return Input.getInput('targetPlatform') || Platform.default; return Input.getInput('targetPlatform') ?? Platform.default;
} }
static get unityVersion(): string { static get unityVersion(): string {
return Input.getInput('unityVersion') || 'auto'; return Input.getInput('unityVersion') ?? 'auto';
} }
static get customImage(): string { static get customImage(): string {
return Input.getInput('customImage') || ''; return Input.getInput('customImage') ?? '';
} }
static get projectPath(): string { static get projectPath(): string {
@ -108,85 +108,85 @@ class Input {
} }
static get runnerTempPath(): string { static get runnerTempPath(): string {
return Input.getInput('RUNNER_TEMP') || ''; return Input.getInput('RUNNER_TEMP') ?? '';
} }
static get buildName(): string { static get buildName(): string {
return Input.getInput('buildName') || Input.targetPlatform; return Input.getInput('buildName') ?? Input.targetPlatform;
} }
static get buildsPath(): string { static get buildsPath(): string {
return Input.getInput('buildsPath') || 'build'; return Input.getInput('buildsPath') ?? 'build';
} }
static get unityLicensingServer(): string { static get unityLicensingServer(): string {
return Input.getInput('unityLicensingServer') || ''; return Input.getInput('unityLicensingServer') ?? '';
} }
static get buildMethod(): string { static get buildMethod(): string {
return Input.getInput('buildMethod') || ''; // Processed in docker file return Input.getInput('buildMethod') ?? ''; // Processed in docker file
} }
static get manualExit(): boolean { static get manualExit(): boolean {
const input = Input.getInput('manualExit') || false; const input = Input.getInput('manualExit') ?? false;
return input === 'true'; return input === 'true';
} }
static get customParameters(): string { static get customParameters(): string {
return Input.getInput('customParameters') || ''; return Input.getInput('customParameters') ?? '';
} }
static get versioningStrategy(): string { static get versioningStrategy(): string {
return Input.getInput('versioning') || 'Semantic'; return Input.getInput('versioning') ?? 'Semantic';
} }
static get specifiedVersion(): string { static get specifiedVersion(): string {
return Input.getInput('version') || ''; return Input.getInput('version') ?? '';
} }
static get androidVersionCode(): string { static get androidVersionCode(): string {
return Input.getInput('androidVersionCode') || ''; return Input.getInput('androidVersionCode') ?? '';
} }
static get androidExportType(): string { static get androidExportType(): string {
return Input.getInput('androidExportType') || 'androidPackage'; return Input.getInput('androidExportType') ?? 'androidPackage';
} }
static get androidKeystoreName(): string { static get androidKeystoreName(): string {
return Input.getInput('androidKeystoreName') || ''; return Input.getInput('androidKeystoreName') ?? '';
} }
static get androidKeystoreBase64(): string { static get androidKeystoreBase64(): string {
return Input.getInput('androidKeystoreBase64') || ''; return Input.getInput('androidKeystoreBase64') ?? '';
} }
static get androidKeystorePass(): string { static get androidKeystorePass(): string {
return Input.getInput('androidKeystorePass') || ''; return Input.getInput('androidKeystorePass') ?? '';
} }
static get androidKeyaliasName(): string { static get androidKeyaliasName(): string {
return Input.getInput('androidKeyaliasName') || ''; return Input.getInput('androidKeyaliasName') ?? '';
} }
static get androidKeyaliasPass(): string { static get androidKeyaliasPass(): string {
return Input.getInput('androidKeyaliasPass') || ''; return Input.getInput('androidKeyaliasPass') ?? '';
} }
static get androidTargetSdkVersion(): string { static get androidTargetSdkVersion(): string {
return Input.getInput('androidTargetSdkVersion') || ''; return Input.getInput('androidTargetSdkVersion') ?? '';
} }
static get androidSymbolType(): string { static get androidSymbolType(): string {
return Input.getInput('androidSymbolType') || 'none'; return Input.getInput('androidSymbolType') ?? 'none';
} }
static get sshAgent(): string { static get sshAgent(): string {
return Input.getInput('sshAgent') || ''; return Input.getInput('sshAgent') ?? '';
} }
static get sshPublicKeysDirectoryPath(): string { static get sshPublicKeysDirectoryPath(): string {
return Input.getInput('sshPublicKeysDirectoryPath') || ''; return Input.getInput('sshPublicKeysDirectoryPath') ?? '';
} }
static get gitPrivateToken(): string | undefined { static get gitPrivateToken(): string | undefined {
@ -194,27 +194,27 @@ class Input {
} }
static get runAsHostUser(): string { static get runAsHostUser(): string {
return Input.getInput('runAsHostUser')?.toLowerCase() || 'false'; return Input.getInput('runAsHostUser')?.toLowerCase() ?? 'false';
} }
static get chownFilesTo() { static get chownFilesTo() {
return Input.getInput('chownFilesTo') || ''; return Input.getInput('chownFilesTo') ?? '';
} }
static get allowDirtyBuild(): boolean { static get allowDirtyBuild(): boolean {
const input = Input.getInput('allowDirtyBuild') || false; const input = Input.getInput('allowDirtyBuild') ?? false;
return input === 'true'; return input === 'true';
} }
static get cacheUnityInstallationOnMac(): boolean { static get cacheUnityInstallationOnMac(): boolean {
const input = Input.getInput('cacheUnityInstallationOnMac') || false; const input = Input.getInput('cacheUnityInstallationOnMac') ?? false;
return input === 'true'; return input === 'true';
} }
static get unityHubVersionOnMac(): string { static get unityHubVersionOnMac(): string {
const input = Input.getInput('unityHubVersionOnMac') || ''; const input = Input.getInput('unityHubVersionOnMac') ?? '';
return input !== '' ? input : ''; return input !== '' ? input : '';
} }
@ -228,11 +228,11 @@ class Input {
} }
static get dockerWorkspacePath(): string { static get dockerWorkspacePath(): string {
return Input.getInput('dockerWorkspacePath') || '/github/workspace'; return Input.getInput('dockerWorkspacePath') ?? '/github/workspace';
} }
static get dockerCpuLimit(): string { static get dockerCpuLimit(): string {
return Input.getInput('dockerCpuLimit') || os.cpus().length.toString(); return Input.getInput('dockerCpuLimit') ?? os.cpus().length.toString();
} }
static get dockerMemoryLimit(): string { static get dockerMemoryLimit(): string {
@ -252,24 +252,24 @@ class Input {
} }
return ( return (
Input.getInput('dockerMemoryLimit') || `${Math.floor((os.totalmem() / bytesInMegabyte) * memoryMultiplier)}m` Input.getInput('dockerMemoryLimit') ?? `${Math.floor((os.totalmem() / bytesInMegabyte) * memoryMultiplier)}m`
); );
} }
static get dockerIsolationMode(): string { static get dockerIsolationMode(): string {
return Input.getInput('dockerIsolationMode') || 'default'; return Input.getInput('dockerIsolationMode') ?? 'default';
} }
static get containerRegistryRepository(): string { static get containerRegistryRepository(): string {
return Input.getInput('containerRegistryRepository') || 'unityci/editor'; return Input.getInput('containerRegistryRepository') ?? 'unityci/editor';
} }
static get containerRegistryImageVersion(): string { static get containerRegistryImageVersion(): string {
return Input.getInput('containerRegistryImageVersion') || '3'; return Input.getInput('containerRegistryImageVersion') ?? '3';
} }
static get skipActivation(): string { static get skipActivation(): string {
return Input.getInput('skipActivation')?.toLowerCase() || 'false'; return Input.getInput('skipActivation')?.toLowerCase() ?? 'false';
} }
public static ToEnvVarFormat(input: string) { public static ToEnvVarFormat(input: string) {