moved the gitversion settings to a file
This commit is contained in:
File diff suppressed because one or more lines are too long
9
dist/azure/gitreleasemanager/setup/bundle.js
vendored
9
dist/azure/gitreleasemanager/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
87
dist/azure/gitversion/execute/bundle.js
vendored
87
dist/azure/gitversion/execute/bundle.js
vendored
File diff suppressed because one or more lines are too long
87
dist/azure/gitversion/setup/bundle.js
vendored
87
dist/azure/gitversion/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
87
dist/github/gitversion/execute/bundle.js
vendored
87
dist/github/gitversion/execute/bundle.js
vendored
File diff suppressed because one or more lines are too long
87
dist/github/gitversion/setup/bundle.js
vendored
87
dist/github/gitversion/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
9
dist/mock/gitreleasemanager/create/bundle.js
vendored
9
dist/mock/gitreleasemanager/create/bundle.js
vendored
File diff suppressed because one or more lines are too long
9
dist/mock/gitreleasemanager/setup/bundle.js
vendored
9
dist/mock/gitreleasemanager/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
87
dist/mock/gitversion/execute/bundle.js
vendored
87
dist/mock/gitversion/execute/bundle.js
vendored
File diff suppressed because one or more lines are too long
87
dist/mock/gitversion/setup/bundle.js
vendored
87
dist/mock/gitversion/setup/bundle.js
vendored
File diff suppressed because one or more lines are too long
@@ -8,6 +8,7 @@ import { TYPES, IExecResult, IBuildAgent } from "./common";
|
||||
import { IVersionManager } from "./versionManager";
|
||||
|
||||
export interface IDotnetTool {
|
||||
disableTelemetry(): void;
|
||||
toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean): Promise<string>;
|
||||
}
|
||||
|
||||
@@ -27,6 +28,10 @@ export class DotnetTool implements IDotnetTool {
|
||||
this.httpClient = new http.HttpClient("dotnet");
|
||||
}
|
||||
|
||||
public disableTelemetry(): void {
|
||||
this.buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
||||
}
|
||||
|
||||
public execute(cmd: string, args: string[]): Promise<IExecResult> {
|
||||
console.log(`Command: ${cmd} ${args.join(' ')}`);
|
||||
return this.buildAgent.exec(cmd, args);
|
||||
|
||||
@@ -12,7 +12,7 @@ const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent);
|
||||
export async function setup() {
|
||||
try {
|
||||
|
||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
|
||||
const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
|
||||
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
|
||||
@@ -28,7 +28,7 @@ export async function setup() {
|
||||
export async function create() {
|
||||
try {
|
||||
|
||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
|
||||
const settings = Settings.getCreateSettings(buildAgent);
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { IBuildAgent, TYPES, SetupOptions } from "../../core/common";
|
||||
import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/gitversion-tool";
|
||||
import { GitVersionInput, GitVersionOutput } from "../../tools/gitversion/models";
|
||||
import { GitVersionSettings, GitVersionOutput } from "../../tools/gitversion/models";
|
||||
|
||||
import container from "../../core/ioc";
|
||||
import { Settings } from "../../tools/gitversion/settings";
|
||||
|
||||
container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool);
|
||||
|
||||
@@ -12,7 +13,7 @@ const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent);
|
||||
export async function setup() {
|
||||
try {
|
||||
|
||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
||||
gitVersionTool.disableTelemetry();
|
||||
|
||||
const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
|
||||
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
|
||||
@@ -27,9 +28,12 @@ export async function setup() {
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
const inputOptions: GitVersionInput = gitVersionTool.getGitVersionInput();
|
||||
|
||||
const result = await gitVersionTool.run(inputOptions);
|
||||
gitVersionTool.disableTelemetry();
|
||||
|
||||
const settings: GitVersionSettings = Settings.getGitVersionSettings(buildAgent);
|
||||
|
||||
const result = await gitVersionTool.run(settings);
|
||||
|
||||
const gitversion = JSON.parse(result.stdout) as GitVersionOutput;
|
||||
gitVersionTool.writeGitVersionToAgent(gitversion);
|
||||
|
||||
@@ -2,11 +2,11 @@ import path = require("path");
|
||||
|
||||
import { TYPES, IBuildAgent, IExecResult } from "../../core/common";
|
||||
import { injectable, inject } from "inversify";
|
||||
import { DotnetTool } from "../../core/dotnet-tool";
|
||||
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";
|
||||
import { GitReleaseManagerCreateSettings, GitReleaseManagerSettings, CreateFields, CommonFields } from "./models";
|
||||
import { IVersionManager } from "../../core/versionManager";
|
||||
|
||||
export interface IGitReleaseManagerTool {
|
||||
export interface IGitReleaseManagerTool extends IDotnetTool {
|
||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { IBuildAgent } from "../../core/common";
|
||||
import { GitReleaseManagerSettings, CommonFields, CreateFields } from "./models";
|
||||
|
||||
export class Settings {
|
||||
|
||||
public static getCreateSettings(buildAgent: IBuildAgent) {
|
||||
const milestone = buildAgent.getInput(CreateFields.milestone);
|
||||
const releaseName = buildAgent.getInput(CreateFields.releaseName);
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import path = require("path");
|
||||
import { injectable, inject } from "inversify";
|
||||
import { IExecResult, IBuildAgent, TYPES } from "../../core/common";
|
||||
import { DotnetTool } from "../../core/dotnet-tool";
|
||||
import { GitVersionInput, GitVersionOutput, GitVersionRunOptions } from "./models";
|
||||
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";
|
||||
import { GitVersionSettings, GitVersionOutput, ExecuteFields } from "./models";
|
||||
import { IVersionManager } from "../../core/versionManager";
|
||||
|
||||
export interface IGitVersionTool {
|
||||
export interface IGitVersionTool extends IDotnetTool {
|
||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||
run(options: GitVersionInput): Promise<IExecResult>;
|
||||
run(options: GitVersionSettings): Promise<IExecResult>;
|
||||
writeGitVersionToAgent(gitversion: GitVersionOutput): void;
|
||||
getGitVersionInput(): GitVersionInput;
|
||||
}
|
||||
|
||||
@injectable()
|
||||
@@ -26,7 +25,7 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
||||
await this.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease);
|
||||
}
|
||||
|
||||
public run(options: GitVersionInput): Promise<IExecResult> {
|
||||
public run(options: GitVersionSettings): Promise<IExecResult> {
|
||||
const workDir = this.getRepoDir(options.targetPath);
|
||||
|
||||
const args = this.getArguments(workDir, options);
|
||||
@@ -49,7 +48,7 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
||||
return workDir.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
private getArguments(workDir: string, options: GitVersionInput): string[] {
|
||||
private getArguments(workDir: string, options: GitVersionSettings): string[] {
|
||||
const args = [
|
||||
workDir,
|
||||
"/output",
|
||||
@@ -84,31 +83,6 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
||||
return args;
|
||||
}
|
||||
|
||||
public getGitVersionInput(): GitVersionInput {
|
||||
|
||||
const targetPath = this.buildAgent.getInput(GitVersionRunOptions.targetPath);
|
||||
|
||||
const useConfigFile = this.buildAgent.getBooleanInput(GitVersionRunOptions.useConfigFile);
|
||||
const configFilePath = this.buildAgent.getInput(GitVersionRunOptions.configFilePath);
|
||||
|
||||
const updateAssemblyInfo = this.buildAgent.getBooleanInput(GitVersionRunOptions.updateAssemblyInfo);
|
||||
const updateAssemblyInfoFilename = this.buildAgent.getInput(GitVersionRunOptions.updateAssemblyInfoFilename);
|
||||
|
||||
const additionalArguments = this.buildAgent.getInput(GitVersionRunOptions.additionalArguments);
|
||||
|
||||
const srcDir = this.buildAgent.getSourceDir().replace(/\\/g, "/");
|
||||
|
||||
return {
|
||||
targetPath,
|
||||
useConfigFile,
|
||||
configFilePath,
|
||||
updateAssemblyInfo,
|
||||
updateAssemblyInfoFilename,
|
||||
additionalArguments,
|
||||
srcDir,
|
||||
};
|
||||
}
|
||||
|
||||
public writeGitVersionToAgent(gitversion: GitVersionOutput): void {
|
||||
|
||||
this.buildAgent.setOutput("major", gitversion.Major.toString());
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
export const GitVersionRunOptions = {
|
||||
targetPath: "targetPath",
|
||||
useConfigFile: "useConfigFile",
|
||||
configFilePath: "configFilePath",
|
||||
updateAssemblyInfo: "configFilePath",
|
||||
updateAssemblyInfoFilename: "configFilePath",
|
||||
additionalArguments: "additionalArguments",
|
||||
export enum ExecuteFields {
|
||||
targetPath = "targetPath",
|
||||
useConfigFile = "useConfigFile",
|
||||
configFilePath = "configFilePath",
|
||||
updateAssemblyInfo = "updateAssemblyInfo",
|
||||
updateAssemblyInfoFilename = "updateAssemblyInfoFilename",
|
||||
additionalArguments = "additionalArguments",
|
||||
srcDir = "srcDir",
|
||||
};
|
||||
|
||||
export interface GitVersionInput {
|
||||
targetPath: string;
|
||||
useConfigFile: boolean;
|
||||
configFilePath: string;
|
||||
updateAssemblyInfo: boolean;
|
||||
updateAssemblyInfoFilename: string;
|
||||
additionalArguments: string;
|
||||
srcDir: string;
|
||||
export interface GitVersionSettings {
|
||||
[ExecuteFields.targetPath]: string;
|
||||
[ExecuteFields.useConfigFile]: boolean;
|
||||
[ExecuteFields.configFilePath]: string;
|
||||
[ExecuteFields.updateAssemblyInfo]: boolean;
|
||||
[ExecuteFields.updateAssemblyInfoFilename]: string;
|
||||
[ExecuteFields.additionalArguments]: string;
|
||||
[ExecuteFields.srcDir]: string;
|
||||
}
|
||||
|
||||
export interface GitVersionOutput {
|
||||
|
||||
30
src/tools/gitversion/settings.ts
Normal file
30
src/tools/gitversion/settings.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { IBuildAgent } from "../../core/common";
|
||||
|
||||
import { GitVersionSettings, ExecuteFields } from "./models";
|
||||
|
||||
export class Settings {
|
||||
|
||||
public static getGitVersionSettings(buildAgent: IBuildAgent): GitVersionSettings {
|
||||
const targetPath = buildAgent.getInput(ExecuteFields.targetPath);
|
||||
|
||||
const useConfigFile = buildAgent.getBooleanInput(ExecuteFields.useConfigFile);
|
||||
const configFilePath = buildAgent.getInput(ExecuteFields.configFilePath);
|
||||
|
||||
const updateAssemblyInfo = buildAgent.getBooleanInput(ExecuteFields.updateAssemblyInfo);
|
||||
const updateAssemblyInfoFilename = buildAgent.getInput(ExecuteFields.updateAssemblyInfoFilename);
|
||||
|
||||
const additionalArguments = buildAgent.getInput(ExecuteFields.additionalArguments);
|
||||
|
||||
const srcDir = buildAgent.getSourceDir().replace(/\\/g, "/");
|
||||
|
||||
return {
|
||||
targetPath,
|
||||
useConfigFile,
|
||||
configFilePath,
|
||||
updateAssemblyInfo,
|
||||
updateAssemblyInfoFilename,
|
||||
additionalArguments,
|
||||
srcDir,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user