Skip to content

Commit

Permalink
moved the common settings to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Feb 8, 2020
1 parent dab6b01 commit 274c9b2
Show file tree
Hide file tree
Showing 26 changed files with 930 additions and 575 deletions.
120 changes: 74 additions & 46 deletions dist/azure/gitreleasemanager/create/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/azure/gitreleasemanager/setup/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/azure/gitversion/execute/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/azure/gitversion/setup/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/github/gitreleasemanager/create/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/github/gitreleasemanager/setup/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/github/gitversion/execute/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/github/gitversion/setup/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/mock/gitreleasemanager/create/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/mock/gitreleasemanager/setup/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/mock/gitversion/execute/bundle.js

Large diffs are not rendered by default.

120 changes: 74 additions & 46 deletions dist/mock/gitversion/setup/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/agent/azure/build-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { injectable } from "inversify";
import * as taskLib from "azure-pipelines-task-lib/task";
import * as toolLib from "azure-pipelines-tool-lib/tool";

import { IBuildAgent, IExecResult } from "../../core/common";
import { IBuildAgent, IExecResult } from "../../core/models";

@injectable()
class BuildAgent implements IBuildAgent {
Expand Down
2 changes: 1 addition & 1 deletion src/agent/github/build-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as toolCache from "@actions/tool-cache";

import { injectable } from "inversify";

import { IBuildAgent, IExecResult } from "../../core/common";
import { IBuildAgent, IExecResult } from "../../core/models";

@injectable()
class BuildAgent implements IBuildAgent {
Expand Down
2 changes: 1 addition & 1 deletion src/agent/mock/build-agent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { injectable } from "inversify";

import { IBuildAgent, IExecResult } from "../../core/common";
import { IBuildAgent, IExecResult } from "../../core/models";

@injectable()
class BuildAgent implements IBuildAgent {
Expand Down
2 changes: 1 addition & 1 deletion src/core/dotnet-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from "path";
import * as http from "typed-rest-client/HttpClient";

import { inject, injectable } from "inversify";
import { TYPES, IExecResult, IBuildAgent } from "./common";
import { TYPES, IExecResult, IBuildAgent } from "./models";
import { IVersionManager } from "./versionManager";

export interface IDotnetTool {
Expand Down
2 changes: 1 addition & 1 deletion src/core/ioc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Container } from "inversify";
import { IVersionManager, VersionManager } from "./versionManager";
import { TYPES, IBuildAgent } from "./common";
import { TYPES, IBuildAgent } from "./models";
import { BuildAgent } from "../agent/mock/build-agent";

const container = new Container();
Expand Down
11 changes: 8 additions & 3 deletions src/core/common.ts → src/core/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ export const TYPES = {
IVersionManager: Symbol.for("VersionManager"),
};

export const SetupOptions = {
includePrerelease: "includePrerelease",
versionSpec: "versionSpec",
export enum SetupFields {
includePrerelease = "includePrerelease",
versionSpec = "versionSpec",
};

export interface ISetupSettings {
[SetupFields.versionSpec]: string;
[SetupFields.includePrerelease]: boolean;
}

export interface IExecResult {
stdout: string;
stderr: string;
Expand Down
14 changes: 14 additions & 0 deletions src/core/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { IBuildAgent, SetupFields, ISetupSettings } from "./models";

export class Settings {

public static getSetupSettings(buildAgent: IBuildAgent): ISetupSettings {
const versionSpec = buildAgent.getInput(SetupFields.versionSpec);
const includePrerelease = buildAgent.getBooleanInput(SetupFields.includePrerelease);

return {
versionSpec,
includePrerelease
}
}
}
2 changes: 1 addition & 1 deletion src/core/versionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cmp from "semver-compare";
import * as semver from "semver";
import { injectable, inject } from "inversify";

import { IBuildAgent, TYPES } from "./common";
import { IBuildAgent, TYPES } from "./models";

export interface IVersionManager {
isExplicitVersion(versionSpec: string): boolean;
Expand Down
10 changes: 5 additions & 5 deletions src/tasks/gitreleasemanager/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { IBuildAgent, TYPES, SetupOptions } from "../../core/common";
import { IBuildAgent, TYPES, SetupFields } from "../../core/models";
import { IGitReleaseManagerTool, GitReleaseManagerTool } from "../../tools/gitreleasemanager/gitreleasemanager-tool";
import { Settings as CommonSettings } from "../../core/settings";
import { Settings } from "../../tools/gitreleasemanager/settings";

import container from "../../core/ioc";
import { Settings } from "../../tools/gitreleasemanager/settings";

container.bind<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool).to(GitReleaseManagerTool);

Expand All @@ -14,10 +15,9 @@ export async function setup() {

gitReleaseManagerTool.disableTelemetry();

const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
const settings = CommonSettings.getSetupSettings(buildAgent);

await gitReleaseManagerTool.install(versionSpec, includePrerelease);
await gitReleaseManagerTool.install(settings.versionSpec, settings.includePrerelease);

buildAgent.setSucceeded("GitVersionManager installed successfully", true);
} catch (error) {
Expand Down
10 changes: 5 additions & 5 deletions src/tasks/gitversion/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { IBuildAgent, TYPES, SetupOptions } from "../../core/common";
import { IBuildAgent, TYPES, SetupFields } from "../../core/models";
import { Settings as CommonSettings } from "../../core/settings";
import { Settings } from "../../tools/gitversion/settings";
import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/gitversion-tool";
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);

Expand All @@ -15,10 +16,9 @@ export async function setup() {

gitVersionTool.disableTelemetry();

const versionSpec = buildAgent.getInput(SetupOptions.versionSpec);
const includePrerelease = buildAgent.getBooleanInput(SetupOptions.includePrerelease);
const settings = CommonSettings.getSetupSettings(buildAgent);

await gitVersionTool.install(versionSpec, includePrerelease);
await gitVersionTool.install(settings.versionSpec, settings.includePrerelease);

buildAgent.setSucceeded("GitVersion installed successfully", true);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/gitreleasemanager/gitreleasemanager-tool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path = require("path");

import { TYPES, IBuildAgent, IExecResult } from "../../core/common";
import { TYPES, IBuildAgent, IExecResult } from "../../core/models";
import { injectable, inject } from "inversify";
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";
import { GitReleaseManagerCreateSettings, GitReleaseManagerSettings, CreateFields, CommonFields } from "./models";
Expand Down
2 changes: 1 addition & 1 deletion src/tools/gitreleasemanager/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IBuildAgent } from "../../core/common";
import { IBuildAgent } from "../../core/models";
import { GitReleaseManagerSettings, CommonFields, CreateFields } from "./models";

export class Settings {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/gitversion/gitversion-tool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path = require("path");
import { injectable, inject } from "inversify";
import { IExecResult, IBuildAgent, TYPES } from "../../core/common";
import { IExecResult, IBuildAgent, TYPES } from "../../core/models";
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";
import { GitVersionSettings, GitVersionOutput, ExecuteFields } from "./models";
import { IVersionManager } from "../../core/versionManager";
Expand Down
2 changes: 1 addition & 1 deletion src/tools/gitversion/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IBuildAgent } from "../../core/common";
import { IBuildAgent } from "../../core/models";

import { GitVersionSettings, ExecuteFields } from "./models";

Expand Down

0 comments on commit 274c9b2

Please sign in to comment.