From 853490fb75aada441295151ec4168130c6e030e5 Mon Sep 17 00:00:00 2001 From: Matt Fellows Date: Thu, 16 Apr 2020 17:21:38 +1000 Subject: [PATCH] chore: remove consumer/provider as options in PactWeb as they are deprecated --- src/pact-web.ts | 51 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/pact-web.ts b/src/pact-web.ts index 73a3e2ad2..3eabaccd3 100644 --- a/src/pact-web.ts +++ b/src/pact-web.ts @@ -6,11 +6,49 @@ import { polyfill } from "es6-promise" import { isEmpty } from "lodash" import { Interaction, InteractionObject } from "./dsl/interaction" -import { MockService } from "./dsl/mockService" -import { PactOptions, PactOptionsComplete } from "./dsl/options" +import { MockService, PactfileWriteMode } from "./dsl/mockService" +import { PactOptions, LogLevel, MandatoryPactOptions } from "./dsl/options" import VerificationError from "./errors/verificationError" polyfill() +export interface PactWebOptions { + // The port to run the mock service on, defaults to 1234 + port?: number + + // The host to run the mock service, defaults to 127.0.0.1 + host?: string + + // SSL flag to identify the protocol to be used (default false, HTTP) + ssl?: boolean + + // Path to SSL certificate to serve on the mock service + sslcert?: string + + // Path to SSL key to serve on the mock service + sslkey?: string + + // Directory to output pact files + dir?: string + + // Directory to log to + log?: string + + // Log level + logLevel?: LogLevel + + // Pact specification version (defaults to 2) + spec?: number + + // Allow CORS OPTION requests to be accepted, defaults to false + cors?: boolean + + // Control how the Pact files are written + // (defaults to 'overwrite') + pactfileWriteMode?: PactfileWriteMode +} + +export type PactWebOptionsComplete = PactOptions & MandatoryPactOptions + /** * Creates a new {@link PactWeb}. * @memberof Pact @@ -22,7 +60,7 @@ polyfill() export class PactWeb { public mockService: MockService public server: any - public opts: PactOptionsComplete + public opts: PactWebOptionsComplete constructor(config?: PactOptions) { const defaults = { @@ -36,12 +74,7 @@ export class PactWeb { ssl: false, } as PactOptions - this.opts = { ...defaults, ...config } as PactOptionsComplete - - if (!isEmpty(this.opts.consumer) || !isEmpty(this.opts.provider)) { - console.warn(`Passing in consumer/provider to PactWeb is deprecated, - and will be removed in the next major version`) - } + this.opts = { ...defaults, ...config } as PactWebOptionsComplete console.info( `Setting up Pact using mock service on port: "${this.opts.port}"`