prepare the execute part
This commit is contained in:
@@ -7,7 +7,7 @@ import * as http from "typed-rest-client/HttpClient";
|
||||
|
||||
import { inject, injectable } from "inversify";
|
||||
|
||||
import { Argument, IBuildAgent, IDotnetTool, IExecResult, IGitVersionTool, IVersionManager } from "./interfaces";
|
||||
import { Argument, IBuildAgent, IDotnetTool, IExecResult, IGitVersionOptions, IGitVersionTool, IVersionManager } from "./interfaces";
|
||||
import { TYPES } from "./types";
|
||||
|
||||
@injectable()
|
||||
@@ -157,7 +157,8 @@ class GitVersionTool implements IGitVersionTool {
|
||||
const toolPath = await this.dotnetTool.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease);
|
||||
}
|
||||
|
||||
public run(...params: Argument[]): Promise<IExecResult> {
|
||||
public run(options: IGitVersionOptions): Promise<IExecResult> {
|
||||
console.log(options);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { IBuildAgent, IGitVersionTool } from "../interfaces";
|
||||
import { TYPES } from "../types";
|
||||
import { IBuildAgent, IGitVersionOptions, IGitVersionTool } from "../interfaces";
|
||||
import { RunOptions, TYPES } from "../types";
|
||||
import { ioc } from "./ioc";
|
||||
|
||||
const gitVersionTool = ioc.get<IGitVersionTool>(TYPES.IGitVersionTool);
|
||||
@@ -10,11 +10,11 @@ const buildAgent = ioc.get<IBuildAgent>(TYPES.IBuildAgent);
|
||||
export async function run() {
|
||||
try {
|
||||
|
||||
const version = "5.1.2";
|
||||
const includePrerelease = false;
|
||||
|
||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
||||
await gitVersionTool.install(version, includePrerelease);
|
||||
|
||||
const inputOptions: IGitVersionOptions = getGitVersionOptions();
|
||||
|
||||
await gitVersionTool.run(inputOptions);
|
||||
|
||||
buildAgent.setSucceeded("GitVersion installed successfully", true);
|
||||
} catch (error) {
|
||||
@@ -22,4 +22,26 @@ export async function run() {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return {
|
||||
targetPath,
|
||||
useConfigFile,
|
||||
configFilePath,
|
||||
updateAssemblyInfo,
|
||||
updateAssemblyInfoFilename,
|
||||
additionalArguments,
|
||||
};
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
@@ -32,7 +32,7 @@ export class Argument {
|
||||
}
|
||||
export interface IGitVersionTool {
|
||||
install: (versionSpec: string, includePrerelease: boolean) => Promise<void>;
|
||||
run: (...params: Argument[]) => Promise<IExecResult>;
|
||||
run: (options: IGitVersionOptions) => Promise<IExecResult>;
|
||||
}
|
||||
export interface IExecResult {
|
||||
stdout: string;
|
||||
@@ -40,3 +40,12 @@ export interface IExecResult {
|
||||
code: number;
|
||||
error: Error;
|
||||
}
|
||||
|
||||
export interface IGitVersionOptions {
|
||||
targetPath: string;
|
||||
useConfigFile: boolean;
|
||||
configFilePath: string;
|
||||
updateAssemblyInfo: boolean;
|
||||
updateAssemblyInfoFilename: string;
|
||||
additionalArguments: string;
|
||||
}
|
||||
|
||||
14
src/types.ts
14
src/types.ts
@@ -10,4 +10,16 @@ const SetupOptions = {
|
||||
versionSpec: "versionSpec",
|
||||
};
|
||||
|
||||
export { SetupOptions, TYPES };
|
||||
const RunOptions = {
|
||||
targetPath: "targetPath",
|
||||
|
||||
useConfigFile: "useConfigFile",
|
||||
configFilePath: "configFilePath",
|
||||
|
||||
updateAssemblyInfo: "configFilePath",
|
||||
updateAssemblyInfoFilename: "configFilePath",
|
||||
|
||||
additionalArguments: "additionalArguments",
|
||||
};
|
||||
|
||||
export { SetupOptions, RunOptions, TYPES };
|
||||
|
||||
Reference in New Issue
Block a user