create action for GRM (2)

This commit is contained in:
Artur Stolear
2020-02-08 10:40:14 +02:00
parent b677d43869
commit 632a7fdad0
17 changed files with 832 additions and 30 deletions

View File

@@ -1,14 +1,19 @@
import { TYPES, IBuildAgent } from "../../core/common";
import path = require("path");
import { TYPES, IBuildAgent, IExecResult } from "../../core/common";
import { injectable, inject } from "inversify";
import { IDotnetTool } from "../../core/dotnet-tool";
import { GitReleaseManagerCreateSettings, GitReleaseManagerSettings, CreateFields, CommonFields } from "./models";
export interface IGitReleaseManagerTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>;
}
@injectable()
export class GitReleaseManagerTool implements IGitReleaseManagerTool {
private buildAgent: IBuildAgent;
private dotnetTool: IDotnetTool;
constructor(
@@ -21,4 +26,44 @@ export class GitReleaseManagerTool implements IGitReleaseManagerTool {
public async install(versionSpec: string, includePrerelease: boolean): Promise<void> {
await this.dotnetTool.toolInstall("GitReleaseManager.Tool", versionSpec, false, includePrerelease);
}
public create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult> {
const args = this.getCreateArguments(settings);
console.log(args);
return Promise.resolve(null);
// return this.buildAgent.exec("dotnet-gitreleasemanager", args);
}
getCommonArguments(settings: GitReleaseManagerSettings): string[] {
const args: string[] = [];
args.push("--owner", settings.owner);
args.push("--repository", settings.repository);
args.push("--token", settings.token);
return args;
}
getCreateArguments(settings: GitReleaseManagerCreateSettings): string[] {
const args: string[] = [...this.getCommonArguments(settings)];
args.push("--milestone", settings.milestone);
args.push("--name", settings.releaseName);
args.push("--targetcommitish", settings.commit);
args.push("--targetDirectory", settings.targetDirectory);
if (this.buildAgent.fileExists(settings.inputFileName)) {
args.push("--inputFilePath", settings.inputFileName);
} else {
throw new Error("GitReleaseManager inputFilePath not found at " + settings.inputFileName);
}
if (settings.isPreRelease) {
args.push("--pre");
}
return args;
}
}