Split responsibilities between Input and BuildParameters models
This commit is contained in:
@@ -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') || '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user