move to common main
This commit is contained in:
@@ -1,55 +1,11 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { IBuildAgent, IGitVersion, IGitVersionOptions, IGitVersionTool } from "../interfaces";
|
||||
import { RunOptions, TYPES } from "../types";
|
||||
import { IBuildAgent, IGitVersionTool } from "../interfaces";
|
||||
import { run } from "../main";
|
||||
import { TYPES } from "../types";
|
||||
import { ioc } from "./ioc";
|
||||
|
||||
const gitVersionTool = ioc.get<IGitVersionTool>(TYPES.IGitVersionTool);
|
||||
const buildAgent = ioc.get<IBuildAgent>(TYPES.IBuildAgent);
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
const inputOptions: IGitVersionOptions = getGitVersionOptions();
|
||||
|
||||
const result = await gitVersionTool.run(inputOptions);
|
||||
|
||||
const gitversion = JSON.parse(result.stdout) as IGitVersion;
|
||||
console.log(gitversion.FullSemVer);
|
||||
|
||||
if (result.code === 0) {
|
||||
buildAgent.setSucceeded("GitVersion executed successfully", true);
|
||||
} else {
|
||||
buildAgent.setFailed(result.error.message, true);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error, true);
|
||||
}
|
||||
}
|
||||
|
||||
function getGitVersionOptions(): IGitVersionOptions {
|
||||
|
||||
const targetPath = buildAgent.getInput(RunOptions.targetPath);
|
||||
|
||||
const useConfigFile = buildAgent.getBooleanInput(RunOptions.useConfigFile);
|
||||
const configFilePath = buildAgent.getInput(RunOptions.configFilePath);
|
||||
|
||||
const updateAssemblyInfo = buildAgent.getBooleanInput(RunOptions.updateAssemblyInfo);
|
||||
const updateAssemblyInfoFilename = buildAgent.getInput(RunOptions.updateAssemblyInfoFilename);
|
||||
|
||||
const additionalArguments = buildAgent.getInput(RunOptions.additionalArguments);
|
||||
|
||||
const srcDir = buildAgent.getSourceDir().replace(/\\/g, "/");
|
||||
|
||||
return {
|
||||
targetPath,
|
||||
useConfigFile,
|
||||
configFilePath,
|
||||
updateAssemblyInfo,
|
||||
updateAssemblyInfoFilename,
|
||||
additionalArguments,
|
||||
srcDir,
|
||||
};
|
||||
}
|
||||
|
||||
run();
|
||||
run(buildAgent, gitVersionTool);
|
||||
|
||||
@@ -1,26 +1,11 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { IBuildAgent, IGitVersionTool } from "../interfaces";
|
||||
import { SetupOptions, TYPES } from "../types";
|
||||
import { setup } from "../main";
|
||||
import { TYPES } from "../types";
|
||||
import { ioc } from "./ioc";
|
||||
|
||||
const gitVersionTool = ioc.get<IGitVersionTool>(TYPES.IGitVersionTool);
|
||||
const buildAgent = ioc.get<IBuildAgent>(TYPES.IBuildAgent);
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
|
||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
||||
|
||||
const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
|
||||
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
|
||||
|
||||
await gitVersionTool.install(versionSpec, includePrerelease);
|
||||
|
||||
buildAgent.setSucceeded("GitVersion installed successfully", true);
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
setup(buildAgent, gitVersionTool);
|
||||
|
||||
Reference in New Issue
Block a user