added setup for gitreleasemanager
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
22
src/core/gitreleasemanager.ts
Normal file
22
src/core/gitreleasemanager.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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"),
|
||||
};
|
||||
|
||||
|
||||
4
src/setup-gitreleasemanager.ts
Normal file
4
src/setup-gitreleasemanager.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { setup } from "./core/gitreleasemanager";
|
||||
|
||||
setup();
|
||||
Reference in New Issue
Block a user