From f5c85c26e2e503a947cc600400c33105325046f2 Mon Sep 17 00:00:00 2001 From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Thu, 2 Mar 2017 16:20:06 +0300 Subject: [PATCH] Implemented settings type --- BuildServer/lib/tasks/dotnetcompile.ts | 6 ++- BuildServer/lib/tasks/dotnetrewrite.ts | 6 ++- BuildServer/lib/tasks/eslintbrowser.ts | 12 +++-- BuildServer/types/index.ts | 3 ++ BuildServer/types/settings-types.ts | 63 ++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 BuildServer/types/settings-types.ts diff --git a/BuildServer/lib/tasks/dotnetcompile.ts b/BuildServer/lib/tasks/dotnetcompile.ts index be0ad81..be824ac 100644 --- a/BuildServer/lib/tasks/dotnetcompile.ts +++ b/BuildServer/lib/tasks/dotnetcompile.ts @@ -3,10 +3,12 @@ import { join } from "path"; import * as _ from "underscore"; -import settings from "../../settings"; -import { Task } from "../../types"; +import rawSettings from "../../settings"; +import { Settings, Task } from "../../types"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; +const settings: Settings = rawSettings; + export default ((params, processor) => { if (settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) { processor.onError("Code analysis is not supported"); diff --git a/BuildServer/lib/tasks/dotnetrewrite.ts b/BuildServer/lib/tasks/dotnetrewrite.ts index 31cb5be..0b4462d 100644 --- a/BuildServer/lib/tasks/dotnetrewrite.ts +++ b/BuildServer/lib/tasks/dotnetrewrite.ts @@ -5,11 +5,13 @@ import { readFile, writeFile } from "fs"; import * as glob from "glob"; import { join } from "path"; -import settings from "../../settings"; -import { Task } from "../../types"; +import rawSettings from "../../settings"; +import { Settings, Task } from "../../types"; const flagDoneName = "dotnetrewriterDone"; +const settings: Settings = rawSettings; + const processAssemblyInfo = (params, processor, appendInformationalVersion) => (originalContent, cb) => { const processInternalsVisible = (content) => { if (params.skipCodeSigning || settings.skipCodeSigning) { diff --git a/BuildServer/lib/tasks/eslintbrowser.ts b/BuildServer/lib/tasks/eslintbrowser.ts index 2885842..a010cb6 100644 --- a/BuildServer/lib/tasks/eslintbrowser.ts +++ b/BuildServer/lib/tasks/eslintbrowser.ts @@ -3,14 +3,20 @@ import { CLIEngine } from "eslint"; import { join } from "path"; -import settings from "../../settings"; -import { Task } from "../../types"; +import rawSettings from "../../settings"; +import { Settings, Task } from "../../types"; -const cli = new CLIEngine({ configFile: settings.eslintBrowserConfig }); +const settings: Settings = rawSettings; const errorSeverity = 2; export default ((params, processor) => () => { + if (settings.isCodeAnalysisUnsupported) { + return; + } + + const cli = new CLIEngine({ configFile: settings.eslintBrowserConfig }); + const filePath = join(processor.context.exported, params.filename); const result = cli.executeOnFiles([filePath]); diff --git a/BuildServer/types/index.ts b/BuildServer/types/index.ts index 61c6d56..f1b61d1 100644 --- a/BuildServer/types/index.ts +++ b/BuildServer/types/index.ts @@ -1,4 +1,5 @@ import * as ReportTypes from "./report-types"; +import * as SettingsTypes from "./settings-types"; import * as TaskProcessorTypes from "./task-processor-types"; export type Message = ReportTypes.IMessage; @@ -7,6 +8,8 @@ export type MessagesRoot = ReportTypes.MessagesRoot; export type Report = ReportTypes.IReport; export type ReportResult = ReportTypes.IReportResult; +export type Settings = SettingsTypes.Settings; + export type Task = TaskProcessorTypes.Task; export type TaskInfo = TaskProcessorTypes.ITaskInfo; export type TaskProcessor = TaskProcessorTypes.ITaskProcessor; diff --git a/BuildServer/types/settings-types.ts b/BuildServer/types/settings-types.ts new file mode 100644 index 0000000..56fa897 --- /dev/null +++ b/BuildServer/types/settings-types.ts @@ -0,0 +1,63 @@ +import * as Github from "github"; + +interface IBuilderSettings { + builderExecutable: string; +} + +interface ICodeAnalysisSettingsUnsupported { + isCodeAnalysisUnsupported: true; +} + +interface ICodeAnalysisSettingsSupported { + eslintBrowserConfig: string; + ignoreCodeAnalysisByDefault: boolean; + isCodeAnalysisUnsupported: false; +} + +type CodeAnalysisSettings = ICodeAnalysisSettingsUnsupported | ICodeAnalysisSettingsSupported; + +interface ICodeSigningSettingsUnsupported { + skipCodeSigning: true; +} + +interface ICodeSigningSettingsSupported { + codeSigningKeyFile: string; + codeSigningPublicKey: string; + skipCodeSigning: false; +} + +type CodeSigningSettings = ICodeSigningSettingsUnsupported | ICodeSigningSettingsSupported; + +interface IStorageSettings { + gitpath: string; + releasepath: string; + tmpcodepath: string; +} + +interface INugetSettings { + nugetApiKey: string; + nugetHost: string; +} + +interface ISmtpSettings { + smtp: { + auth: { + pass: string; + user: string; + }, + host: string; + receiver: string; + sender: string; + }; +} + +interface ISiteSettings { + port: number | string; + siteRoot: string; +} + +interface IGithubSettings { + createGithub: (repoOwner: string) => Github; +} + +export type Settings = IBuilderSettings & CodeAnalysisSettings & CodeSigningSettings & IStorageSettings & INugetSettings & ISmtpSettings & ISiteSettings & IGithubSettings;