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";
|
import { IVersionManager } from "./versionManager";
|
||||||
|
|
||||||
export interface IDotnetTool {
|
export interface IDotnetTool {
|
||||||
|
disableTelemetry(): void;
|
||||||
toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean): Promise<string>;
|
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");
|
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> {
|
public execute(cmd: string, args: string[]): Promise<IExecResult> {
|
||||||
console.log(`Command: ${cmd} ${args.join(' ')}`);
|
console.log(`Command: ${cmd} ${args.join(' ')}`);
|
||||||
return this.buildAgent.exec(cmd, args);
|
return this.buildAgent.exec(cmd, args);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent);
|
|||||||
export async function setup() {
|
export async function setup() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
gitReleaseManagerTool.disableTelemetry();
|
||||||
|
|
||||||
const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
|
const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
|
||||||
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
|
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
|
||||||
@@ -28,7 +28,7 @@ export async function setup() {
|
|||||||
export async function create() {
|
export async function create() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
gitReleaseManagerTool.disableTelemetry();
|
||||||
|
|
||||||
const settings = Settings.getCreateSettings(buildAgent);
|
const settings = Settings.getCreateSettings(buildAgent);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { IBuildAgent, TYPES, SetupOptions } from "../../core/common";
|
import { IBuildAgent, TYPES, SetupOptions } from "../../core/common";
|
||||||
import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/gitversion-tool";
|
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 container from "../../core/ioc";
|
||||||
|
import { Settings } from "../../tools/gitversion/settings";
|
||||||
|
|
||||||
container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool);
|
container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool);
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent);
|
|||||||
export async function setup() {
|
export async function setup() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
gitVersionTool.disableTelemetry();
|
||||||
|
|
||||||
const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
|
const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
|
||||||
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
|
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
|
||||||
@@ -27,9 +28,12 @@ export async function setup() {
|
|||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
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;
|
const gitversion = JSON.parse(result.stdout) as GitVersionOutput;
|
||||||
gitVersionTool.writeGitVersionToAgent(gitversion);
|
gitVersionTool.writeGitVersionToAgent(gitversion);
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ import path = require("path");
|
|||||||
|
|
||||||
import { TYPES, IBuildAgent, IExecResult } from "../../core/common";
|
import { TYPES, IBuildAgent, IExecResult } from "../../core/common";
|
||||||
import { injectable, inject } from "inversify";
|
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 { GitReleaseManagerCreateSettings, GitReleaseManagerSettings, CreateFields, CommonFields } from "./models";
|
||||||
import { IVersionManager } from "../../core/versionManager";
|
import { IVersionManager } from "../../core/versionManager";
|
||||||
|
|
||||||
export interface IGitReleaseManagerTool {
|
export interface IGitReleaseManagerTool extends IDotnetTool {
|
||||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||||
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>;
|
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { IBuildAgent } from "../../core/common";
|
|||||||
import { GitReleaseManagerSettings, CommonFields, CreateFields } from "./models";
|
import { GitReleaseManagerSettings, CommonFields, CreateFields } from "./models";
|
||||||
|
|
||||||
export class Settings {
|
export class Settings {
|
||||||
|
|
||||||
public static getCreateSettings(buildAgent: IBuildAgent) {
|
public static getCreateSettings(buildAgent: IBuildAgent) {
|
||||||
const milestone = buildAgent.getInput(CreateFields.milestone);
|
const milestone = buildAgent.getInput(CreateFields.milestone);
|
||||||
const releaseName = buildAgent.getInput(CreateFields.releaseName);
|
const releaseName = buildAgent.getInput(CreateFields.releaseName);
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import path = require("path");
|
import path = require("path");
|
||||||
import { injectable, inject } from "inversify";
|
import { injectable, inject } from "inversify";
|
||||||
import { IExecResult, IBuildAgent, TYPES } from "../../core/common";
|
import { IExecResult, IBuildAgent, TYPES } from "../../core/common";
|
||||||
import { DotnetTool } from "../../core/dotnet-tool";
|
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";
|
||||||
import { GitVersionInput, GitVersionOutput, GitVersionRunOptions } from "./models";
|
import { GitVersionSettings, GitVersionOutput, ExecuteFields } from "./models";
|
||||||
import { IVersionManager } from "../../core/versionManager";
|
import { IVersionManager } from "../../core/versionManager";
|
||||||
|
|
||||||
export interface IGitVersionTool {
|
export interface IGitVersionTool extends IDotnetTool {
|
||||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||||
run(options: GitVersionInput): Promise<IExecResult>;
|
run(options: GitVersionSettings): Promise<IExecResult>;
|
||||||
writeGitVersionToAgent(gitversion: GitVersionOutput): void;
|
writeGitVersionToAgent(gitversion: GitVersionOutput): void;
|
||||||
getGitVersionInput(): GitVersionInput;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
@@ -26,7 +25,7 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
|||||||
await this.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease);
|
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 workDir = this.getRepoDir(options.targetPath);
|
||||||
|
|
||||||
const args = this.getArguments(workDir, options);
|
const args = this.getArguments(workDir, options);
|
||||||
@@ -49,7 +48,7 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
|||||||
return workDir.replace(/\\/g, "/");
|
return workDir.replace(/\\/g, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
private getArguments(workDir: string, options: GitVersionInput): string[] {
|
private getArguments(workDir: string, options: GitVersionSettings): string[] {
|
||||||
const args = [
|
const args = [
|
||||||
workDir,
|
workDir,
|
||||||
"/output",
|
"/output",
|
||||||
@@ -84,31 +83,6 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
|||||||
return args;
|
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 {
|
public writeGitVersionToAgent(gitversion: GitVersionOutput): void {
|
||||||
|
|
||||||
this.buildAgent.setOutput("major", gitversion.Major.toString());
|
this.buildAgent.setOutput("major", gitversion.Major.toString());
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
export const GitVersionRunOptions = {
|
export enum ExecuteFields {
|
||||||
targetPath: "targetPath",
|
targetPath = "targetPath",
|
||||||
useConfigFile: "useConfigFile",
|
useConfigFile = "useConfigFile",
|
||||||
configFilePath: "configFilePath",
|
configFilePath = "configFilePath",
|
||||||
updateAssemblyInfo: "configFilePath",
|
updateAssemblyInfo = "updateAssemblyInfo",
|
||||||
updateAssemblyInfoFilename: "configFilePath",
|
updateAssemblyInfoFilename = "updateAssemblyInfoFilename",
|
||||||
additionalArguments: "additionalArguments",
|
additionalArguments = "additionalArguments",
|
||||||
|
srcDir = "srcDir",
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface GitVersionInput {
|
export interface GitVersionSettings {
|
||||||
targetPath: string;
|
[ExecuteFields.targetPath]: string;
|
||||||
useConfigFile: boolean;
|
[ExecuteFields.useConfigFile]: boolean;
|
||||||
configFilePath: string;
|
[ExecuteFields.configFilePath]: string;
|
||||||
updateAssemblyInfo: boolean;
|
[ExecuteFields.updateAssemblyInfo]: boolean;
|
||||||
updateAssemblyInfoFilename: string;
|
[ExecuteFields.updateAssemblyInfoFilename]: string;
|
||||||
additionalArguments: string;
|
[ExecuteFields.additionalArguments]: string;
|
||||||
srcDir: string;
|
[ExecuteFields.srcDir]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GitVersionOutput {
|
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