Split responsibilities between Input and BuildParameters models

This commit is contained in:
Webber
2020-05-21 17:44:56 +02:00
committed by Webber Takken
parent 02ff5bbef2
commit 7e17091251
10 changed files with 329 additions and 131 deletions

View File

@@ -1,41 +1,54 @@
import Platform from './platform';
import Versioning from './versioning';
const core = require('@actions/core');
/**
* Input variables specified in workflows using "with" prop.
*
* Note that input is always passed as a string, even booleans.
*/
class Input {
static async getFromUser() {
// Input variables specified in workflows using "with" prop.
const version = core.getInput('unityVersion');
const targetPlatform = core.getInput('targetPlatform') || Platform.default;
static get unityVersion() {
return core.getInput('unityVersion');
}
static get targetPlatform() {
return core.getInput('targetPlatform') || Platform.default;
}
static get projectPath() {
const rawProjectPath = core.getInput('projectPath') || '.';
const buildName = core.getInput('buildName') || targetPlatform;
const buildsPath = core.getInput('buildsPath') || 'build';
const buildMethod = core.getInput('buildMethod'); // processed in docker file
const versioningStrategy = core.getInput('versioning') || 'Semantic';
const specifiedVersion = core.getInput('version') || '';
const rawAllowDirtyBuild = core.getInput('allowDirtyBuild') || 'false';
const customParameters = core.getInput('customParameters') || '';
return rawProjectPath.replace(/\/$/, '');
}
// Sanitise input
const projectPath = rawProjectPath.replace(/\/$/, '');
const allowDirtyBuild = rawAllowDirtyBuild === 'true' ? 'true' : 'false';
static get buildName() {
return core.getInput('buildName') || this.targetPlatform;
}
// Parse input
const buildVersion = await Versioning.determineVersion(versioningStrategy, specifiedVersion);
static get buildsPath() {
return core.getInput('buildsPath') || 'build';
}
// Return validated input
return {
version,
targetPlatform,
projectPath,
buildName,
buildsPath,
buildMethod,
buildVersion,
allowDirtyBuild,
customParameters,
};
static get buildMethod() {
return core.getInput('buildMethod'); // processed in docker file
}
static get versioningStrategy() {
return core.getInput('versioning') || 'Semantic';
}
static get specifiedVersion() {
return core.getInput('version') || '';
}
static get allowDirtyBuild() {
const input = core.getInput('allowDirtyBuild') || 'false';
return input === 'true' ? 'true' : 'false';
}
static get customParameters() {
return core.getInput('customParameters') || '';
}
}