added setup for gitreleasemanager

This commit is contained in:
Artur Stolear
2020-01-23 18:07:00 +02:00
parent ef8d92d27a
commit 300345b152
22 changed files with 38122 additions and 14 deletions

View File

@@ -4,11 +4,20 @@ import * as os from "os";
import * as path from "path";
import * as semver from "semver";
import * as http from "typed-rest-client/HttpClient";
import cmp from "semver-compare";
import { inject, injectable } from "inversify";
import { IBuildAgent, IDotnetTool, IExecResult, IGitVersionOptions, IGitVersionTool, IVersionManager } from "./interfaces";
import { IBuildAgent,
IDotnetTool,
IExecResult,
IGitReleaseManagerTool,
IGitVersionOptions,
IGitVersionTool,
IVersionManager,
} from "./interfaces";
import { TYPES } from "./types";
@injectable()
@@ -221,6 +230,25 @@ class GitVersionTool implements IGitVersionTool {
}
}
@injectable()
class GitReleaseManagerTool implements IGitReleaseManagerTool {
private buildAgent: IBuildAgent;
private dotnetTool: IDotnetTool;
constructor(
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
@inject(TYPES.IDotnetTool) dotnetTool: IDotnetTool,
) {
this.buildAgent = buildAgent;
this.dotnetTool = dotnetTool;
}
public async install(versionSpec: string, includePrerelease: boolean): Promise<void> {
await this.dotnetTool.toolInstall("GitReleaseManager.Tool", versionSpec, false, includePrerelease);
}
}
@injectable()
class VersionManager implements IVersionManager {
@@ -271,6 +299,7 @@ class VersionManager implements IVersionManager {
export {
DotnetTool,
GitReleaseManagerTool,
GitVersionTool,
VersionManager,
};

View File

@@ -0,0 +1,22 @@
import { IBuildAgent, IGitReleaseManagerTool } from "./interfaces";
import { ioc } from "./ioc";
import { SetupOptions, TYPES } from "./types";
const gitReleaseManagerTool = ioc.get<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool);
const buildAgent = ioc.get<IBuildAgent>(TYPES.IBuildAgent);
export async function setup() {
try {
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
await gitReleaseManagerTool.install(versionSpec, includePrerelease);
buildAgent.setSucceeded("GitVersionManager installed successfully", true);
} catch (error) {
buildAgent.setFailed(error.message, true);
}
}

View File

@@ -41,6 +41,10 @@ export interface IGitVersionTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
run(options: IGitVersionOptions): Promise<IExecResult>;
}
export interface IGitReleaseManagerTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
}
export interface IExecResult {
stdout: string;
stderr: string;

View File

@@ -1,8 +1,8 @@
import { Container } from "inversify";
import { BuildAgent } from "../agent/mock/build-agent";
import { DotnetTool, GitVersionTool, VersionManager } from "./common";
import { IBuildAgent, IDotnetTool, IGitVersionTool, IVersionManager } from "./interfaces";
import { DotnetTool, GitReleaseManagerTool, GitVersionTool, VersionManager } from "./common";
import { IBuildAgent, IDotnetTool, IGitReleaseManagerTool, IGitVersionTool, IVersionManager } from "./interfaces";
import { TYPES } from "./types";
const ioc = new Container();
@@ -11,5 +11,6 @@ ioc.bind<IVersionManager>(TYPES.IVersionManager).to(VersionManager);
ioc.bind<IBuildAgent>(TYPES.IBuildAgent).to(BuildAgent);
ioc.bind<IDotnetTool>(TYPES.IDotnetTool).to(DotnetTool);
ioc.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool);
ioc.bind<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool).to(GitReleaseManagerTool);
export { ioc };

View File

@@ -2,6 +2,7 @@ const TYPES = {
IBuildAgent: Symbol.for("BuildAgent"),
IDotnetTool: Symbol.for("DotnetTool"),
IGitVersionTool: Symbol.for("GitVersionTool"),
IGitReleaseManagerTool: Symbol.for("GitReleaseManagerTool"),
IVersionManager: Symbol.for("VersionManager"),
};

View File

@@ -0,0 +1,4 @@
import "reflect-metadata";
import { setup } from "./core/gitreleasemanager";
setup();