made gitversion & gitreleasemanager extend dotnet-tool
This commit is contained in:
28
dist/azure/gitreleasemanager/create/bundle.js
vendored
28
dist/azure/gitreleasemanager/create/bundle.js
vendored
File diff suppressed because one or more lines are too long
28
dist/azure/gitreleasemanager/setup/bundle.js
vendored
28
dist/azure/gitreleasemanager/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
25
dist/azure/gitversion/execute/bundle.js
vendored
25
dist/azure/gitversion/execute/bundle.js
vendored
File diff suppressed because one or more lines are too long
25
dist/azure/gitversion/setup/bundle.js
vendored
25
dist/azure/gitversion/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
28
dist/github/gitreleasemanager/create/bundle.js
vendored
28
dist/github/gitreleasemanager/create/bundle.js
vendored
File diff suppressed because one or more lines are too long
28
dist/github/gitreleasemanager/setup/bundle.js
vendored
28
dist/github/gitreleasemanager/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
25
dist/github/gitversion/execute/bundle.js
vendored
25
dist/github/gitversion/execute/bundle.js
vendored
File diff suppressed because one or more lines are too long
25
dist/github/gitversion/setup/bundle.js
vendored
25
dist/github/gitversion/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
28
dist/mock/gitreleasemanager/create/bundle.js
vendored
28
dist/mock/gitreleasemanager/create/bundle.js
vendored
File diff suppressed because one or more lines are too long
28
dist/mock/gitreleasemanager/setup/bundle.js
vendored
28
dist/mock/gitreleasemanager/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
25
dist/mock/gitversion/execute/bundle.js
vendored
25
dist/mock/gitversion/execute/bundle.js
vendored
File diff suppressed because one or more lines are too long
25
dist/mock/gitversion/setup/bundle.js
vendored
25
dist/mock/gitversion/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
@@ -8,15 +8,14 @@ import { TYPES, IExecResult, IBuildAgent } from "./common";
|
||||
import { IVersionManager } from "./versionManager";
|
||||
|
||||
export interface IDotnetTool {
|
||||
run(args: string[]): Promise<IExecResult>;
|
||||
toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean): Promise<string>;
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class DotnetTool implements IDotnetTool {
|
||||
|
||||
private buildAgent: IBuildAgent;
|
||||
private versionManager: IVersionManager;
|
||||
protected buildAgent: IBuildAgent;
|
||||
protected versionManager: IVersionManager;
|
||||
private httpClient: http.HttpClient;
|
||||
|
||||
constructor(
|
||||
@@ -28,8 +27,9 @@ export class DotnetTool implements IDotnetTool {
|
||||
this.httpClient = new http.HttpClient("dotnet");
|
||||
}
|
||||
|
||||
public run(args: string[]): Promise<IExecResult> {
|
||||
return this.buildAgent.exec("dotnet", args);
|
||||
public execute(cmd: string, args: string[]): Promise<IExecResult> {
|
||||
console.log(`Command: ${cmd} ${args.join(' ')}`);
|
||||
return this.buildAgent.exec(cmd, args);
|
||||
}
|
||||
|
||||
public async toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean)
|
||||
@@ -131,7 +131,7 @@ export class DotnetTool implements IDotnetTool {
|
||||
args = args.concat(["--version", version]);
|
||||
}
|
||||
|
||||
const result = await this.run(args);
|
||||
const result = await this.execute("dotnet", args);
|
||||
const status = result.code === 0 ? "success" : "failure";
|
||||
const message = result.code === 0 ? result.stdout : result.stderr;
|
||||
|
||||
|
||||
@@ -2,12 +2,10 @@ import { Container } from "inversify";
|
||||
import { IVersionManager, VersionManager } from "./versionManager";
|
||||
import { TYPES, IBuildAgent } from "./common";
|
||||
import { BuildAgent } from "../agent/mock/build-agent";
|
||||
import { IDotnetTool, DotnetTool } from "./dotnet-tool";
|
||||
|
||||
const container = new Container();
|
||||
|
||||
container.bind<IVersionManager>(TYPES.IVersionManager).to(VersionManager);
|
||||
container.bind<IBuildAgent>(TYPES.IBuildAgent).to(BuildAgent);
|
||||
container.bind<IDotnetTool>(TYPES.IDotnetTool).to(DotnetTool);
|
||||
|
||||
export default container;
|
||||
|
||||
@@ -2,8 +2,9 @@ import path = require("path");
|
||||
|
||||
import { TYPES, IBuildAgent, IExecResult } from "../../core/common";
|
||||
import { injectable, inject } from "inversify";
|
||||
import { IDotnetTool } from "../../core/dotnet-tool";
|
||||
import { DotnetTool } from "../../core/dotnet-tool";
|
||||
import { GitReleaseManagerCreateSettings, GitReleaseManagerSettings, CreateFields, CommonFields } from "./models";
|
||||
import { IVersionManager } from "../../core/versionManager";
|
||||
|
||||
export interface IGitReleaseManagerTool {
|
||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||
@@ -11,30 +12,23 @@ export interface IGitReleaseManagerTool {
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class GitReleaseManagerTool implements IGitReleaseManagerTool {
|
||||
|
||||
private buildAgent: IBuildAgent;
|
||||
private dotnetTool: IDotnetTool;
|
||||
export class GitReleaseManagerTool extends DotnetTool implements IGitReleaseManagerTool {
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
|
||||
@inject(TYPES.IDotnetTool) dotnetTool: IDotnetTool,
|
||||
@inject(TYPES.IVersionManager) versionManager: IVersionManager
|
||||
) {
|
||||
this.dotnetTool = dotnetTool;
|
||||
super(buildAgent, versionManager);
|
||||
}
|
||||
|
||||
public async install(versionSpec: string, includePrerelease: boolean): Promise<void> {
|
||||
await this.dotnetTool.toolInstall("GitReleaseManager.Tool", versionSpec, false, includePrerelease);
|
||||
await this.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);
|
||||
return this.execute("dotnet-gitreleasemanager", args);
|
||||
}
|
||||
|
||||
getCommonArguments(settings: GitReleaseManagerSettings): string[] {
|
||||
@@ -48,7 +42,7 @@ export class GitReleaseManagerTool implements IGitReleaseManagerTool {
|
||||
}
|
||||
|
||||
getCreateArguments(settings: GitReleaseManagerCreateSettings): string[] {
|
||||
const args: string[] = [...this.getCommonArguments(settings)];
|
||||
const args: string[] = ['create', ...this.getCommonArguments(settings)];
|
||||
|
||||
if (settings.milestone) {
|
||||
args.push("--milestone", settings.milestone);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import path = require("path");
|
||||
import { injectable, inject } from "inversify";
|
||||
import { IExecResult, IBuildAgent, TYPES } from "../../core/common";
|
||||
import { IDotnetTool } from "../../core/dotnet-tool";
|
||||
import { DotnetTool } from "../../core/dotnet-tool";
|
||||
import { GitVersionInput, GitVersionOutput, GitVersionRunOptions } from "./models";
|
||||
import { IVersionManager } from "../../core/versionManager";
|
||||
|
||||
export interface IGitVersionTool {
|
||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||
@@ -12,21 +13,17 @@ export interface IGitVersionTool {
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class GitVersionTool implements IGitVersionTool {
|
||||
|
||||
private buildAgent: IBuildAgent;
|
||||
private dotnetTool: IDotnetTool;
|
||||
export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
|
||||
@inject(TYPES.IDotnetTool) dotnetTool: IDotnetTool,
|
||||
@inject(TYPES.IVersionManager) versionManager: IVersionManager
|
||||
) {
|
||||
this.buildAgent = buildAgent;
|
||||
this.dotnetTool = dotnetTool;
|
||||
super(buildAgent, versionManager);
|
||||
}
|
||||
|
||||
public async install(versionSpec: string, includePrerelease: boolean): Promise<void> {
|
||||
await this.dotnetTool.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease);
|
||||
await this.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease);
|
||||
}
|
||||
|
||||
public run(options: GitVersionInput): Promise<IExecResult> {
|
||||
@@ -34,7 +31,7 @@ export class GitVersionTool implements IGitVersionTool {
|
||||
|
||||
const args = this.getArguments(workDir, options);
|
||||
|
||||
return this.buildAgent.exec("dotnet-gitversion", args);
|
||||
return this.execute("dotnet-gitversion", args);
|
||||
}
|
||||
|
||||
private getRepoDir(targetPath: string): string {
|
||||
@@ -65,7 +62,7 @@ export class GitVersionTool implements IGitVersionTool {
|
||||
updateAssemblyInfo,
|
||||
updateAssemblyInfoFilename,
|
||||
additionalArguments,
|
||||
} = options;
|
||||
} = options;
|
||||
|
||||
if (useConfigFile) {
|
||||
if (this.buildAgent.isValidInputFile("configFilePath", configFilePath)) {
|
||||
@@ -114,35 +111,35 @@ export class GitVersionTool implements IGitVersionTool {
|
||||
|
||||
public writeGitVersionToAgent(gitversion: GitVersionOutput): void {
|
||||
|
||||
this.buildAgent.setOutput("major", gitversion.Major.toString());
|
||||
this.buildAgent.setOutput("minor", gitversion.Minor.toString());
|
||||
this.buildAgent.setOutput("patch", gitversion.Patch.toString());
|
||||
this.buildAgent.setOutput("preReleaseTag", gitversion.PreReleaseTag);
|
||||
this.buildAgent.setOutput("preReleaseTagWithDash", gitversion.PreReleaseTagWithDash);
|
||||
this.buildAgent.setOutput("preReleaseLabel", gitversion.PreReleaseLabel);
|
||||
this.buildAgent.setOutput("preReleaseNumber", gitversion.PreReleaseNumber.toString());
|
||||
this.buildAgent.setOutput("weightedPreReleaseNumber", gitversion.WeightedPreReleaseNumber.toString());
|
||||
this.buildAgent.setOutput("buildMetaData", gitversion.BuildMetaData.toString());
|
||||
this.buildAgent.setOutput("buildMetaDataPadded", gitversion.BuildMetaDataPadded);
|
||||
this.buildAgent.setOutput("fullBuildMetaData", gitversion.FullBuildMetaData);
|
||||
this.buildAgent.setOutput("majorMinorPatch", gitversion.MajorMinorPatch);
|
||||
this.buildAgent.setOutput("semVer", gitversion.SemVer);
|
||||
this.buildAgent.setOutput("legacySemVer", gitversion.LegacySemVer);
|
||||
this.buildAgent.setOutput("legacySemVerPadded", gitversion.LegacySemVerPadded);
|
||||
this.buildAgent.setOutput("assemblySemVer", gitversion.AssemblySemVer);
|
||||
this.buildAgent.setOutput("assemblySemFileVer", gitversion.AssemblySemFileVer);
|
||||
this.buildAgent.setOutput("fullSemVer", gitversion.FullSemVer);
|
||||
this.buildAgent.setOutput("informationalVersion", gitversion.InformationalVersion);
|
||||
this.buildAgent.setOutput("branchName", gitversion.BranchName);
|
||||
this.buildAgent.setOutput("sha", gitversion.Sha);
|
||||
this.buildAgent.setOutput("shortSha", gitversion.ShortSha);
|
||||
this.buildAgent.setOutput("nuGetVersionV2", gitversion.NuGetVersionV2);
|
||||
this.buildAgent.setOutput("nuGetVersion", gitversion.NuGetVersion);
|
||||
this.buildAgent.setOutput("nuGetPreReleaseTagV2", gitversion.NuGetPreReleaseTagV2);
|
||||
this.buildAgent.setOutput("nuGetPreReleaseTag", gitversion.NuGetPreReleaseTag);
|
||||
this.buildAgent.setOutput("versionSourceSha", gitversion.VersionSourceSha);
|
||||
this.buildAgent.setOutput("commitsSinceVersionSource", gitversion.CommitsSinceVersionSource.toString());
|
||||
this.buildAgent.setOutput("major", gitversion.Major.toString());
|
||||
this.buildAgent.setOutput("minor", gitversion.Minor.toString());
|
||||
this.buildAgent.setOutput("patch", gitversion.Patch.toString());
|
||||
this.buildAgent.setOutput("preReleaseTag", gitversion.PreReleaseTag);
|
||||
this.buildAgent.setOutput("preReleaseTagWithDash", gitversion.PreReleaseTagWithDash);
|
||||
this.buildAgent.setOutput("preReleaseLabel", gitversion.PreReleaseLabel);
|
||||
this.buildAgent.setOutput("preReleaseNumber", gitversion.PreReleaseNumber.toString());
|
||||
this.buildAgent.setOutput("weightedPreReleaseNumber", gitversion.WeightedPreReleaseNumber.toString());
|
||||
this.buildAgent.setOutput("buildMetaData", gitversion.BuildMetaData.toString());
|
||||
this.buildAgent.setOutput("buildMetaDataPadded", gitversion.BuildMetaDataPadded);
|
||||
this.buildAgent.setOutput("fullBuildMetaData", gitversion.FullBuildMetaData);
|
||||
this.buildAgent.setOutput("majorMinorPatch", gitversion.MajorMinorPatch);
|
||||
this.buildAgent.setOutput("semVer", gitversion.SemVer);
|
||||
this.buildAgent.setOutput("legacySemVer", gitversion.LegacySemVer);
|
||||
this.buildAgent.setOutput("legacySemVerPadded", gitversion.LegacySemVerPadded);
|
||||
this.buildAgent.setOutput("assemblySemVer", gitversion.AssemblySemVer);
|
||||
this.buildAgent.setOutput("assemblySemFileVer", gitversion.AssemblySemFileVer);
|
||||
this.buildAgent.setOutput("fullSemVer", gitversion.FullSemVer);
|
||||
this.buildAgent.setOutput("informationalVersion", gitversion.InformationalVersion);
|
||||
this.buildAgent.setOutput("branchName", gitversion.BranchName);
|
||||
this.buildAgent.setOutput("sha", gitversion.Sha);
|
||||
this.buildAgent.setOutput("shortSha", gitversion.ShortSha);
|
||||
this.buildAgent.setOutput("nuGetVersionV2", gitversion.NuGetVersionV2);
|
||||
this.buildAgent.setOutput("nuGetVersion", gitversion.NuGetVersion);
|
||||
this.buildAgent.setOutput("nuGetPreReleaseTagV2", gitversion.NuGetPreReleaseTagV2);
|
||||
this.buildAgent.setOutput("nuGetPreReleaseTag", gitversion.NuGetPreReleaseTag);
|
||||
this.buildAgent.setOutput("versionSourceSha", gitversion.VersionSourceSha);
|
||||
this.buildAgent.setOutput("commitsSinceVersionSource", gitversion.CommitsSinceVersionSource.toString());
|
||||
this.buildAgent.setOutput("commitsSinceVersionSourcePadded", gitversion.CommitsSinceVersionSourcePadded);
|
||||
this.buildAgent.setOutput("commitDate", gitversion.CommitDate);
|
||||
this.buildAgent.setOutput("commitDate", gitversion.CommitDate);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user