Skip to content

Commit

Permalink
fix: The verifier option providerStatesSetupUrl is no longer deprec…
Browse files Browse the repository at this point in the history
…ated. Other deprecated options have been removed.

BREAKING CHANGE:

All options deprecated in previous versions have been removed. Migration instructions:

* In `VerifierOptions`: replace use of `tags`, `consumerVersionTag` and `providerVersionTag` with the appropriate `consumerVersionTags` or `providerVersionTags` option.

* The following classes have had their `.create(options)` removed. Please use the appropriate constructor instead (for example, `new Verifier(options)`)
    * `Verifier`
    * `Publisher`
    * `Server`
    * `Stub`
  • Loading branch information
TimothyJones committed May 21, 2021
1 parent 1bdb45d commit 95b88e0
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 139 deletions.
6 changes: 0 additions & 6 deletions src/publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ import fs = require('fs');
import logger, { verboseIsImplied } from './logger';
import spawn from './spawn';
import { DEFAULT_ARG } from './spawn';
import { deprecate } from 'util';
import pactStandalone from './pact-standalone';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const checkTypes = require('check-types');

export class Publisher {
public static create = deprecate(
(options: PublisherOptions) => new Publisher(options),
'Create function will be removed in future release, please use the default export function or use `new Publisher()`'
);

public readonly options: PublisherOptions;
private readonly __argMapping = {
pactFilesOrDirs: DEFAULT_ARG,
Expand Down
6 changes: 0 additions & 6 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AbstractService, LogLevel } from './service';
import { deprecate } from 'util';
import pact from './pact-standalone';
import path = require('path');
import fs = require('fs');
Expand All @@ -9,11 +8,6 @@ import mkdirp = require('mkdirp');
const checkTypes = require('check-types');

export class Server extends AbstractService {
public static create = deprecate(
(options?: ServerOptions) => new Server(options),
'Create function will be removed in future release, please use the default export function or use `new Server()`'
);

public readonly options: ServerOptions;

constructor(options: ServerOptions = {}) {
Expand Down
6 changes: 0 additions & 6 deletions src/stub.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { DEFAULT_ARG } from './spawn';
import { AbstractService, LogLevel } from './service';
import { deprecate } from 'util';

import pact from './pact-standalone';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const checkTypes = require('check-types');

export class Stub extends AbstractService {
public static create = deprecate(
(options?: StubOptions) => new Stub(options),
'Create function will be removed in future release, please use the default export function or use `new Stub()`'
);

public readonly options: StubOptions;

constructor(options?: StubOptions) {
Expand Down
55 changes: 0 additions & 55 deletions src/verifier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,6 @@ describe('Verifier Spec', () => {
expect(v.options.consumerVersionTags).to.deep.eq(['tag-1']);
});
});
context('when consumerVersionTag is provided as a string', () => {
it('should convert the argument to an array', () => {
const v = verifierFactory({
providerBaseUrl: 'http://localhost',
pactUrls: [path.dirname(currentDir)],
consumerVersionTag: 'tag-1',
});

expect(v.options.consumerVersionTag).to.deep.eq(['tag-1']);
});
});

context('when consumerVersionTags is provided as an array', () => {
it('should not fail', () => {
Expand All @@ -306,22 +295,6 @@ describe('Verifier Spec', () => {
});
});

context(
'when consumerVersionTags and consumerVersionTag are provided',
() => {
it('should fail', () => {
expect(() => {
verifierFactory({
providerBaseUrl: 'http://localhost',
pactUrls: [path.dirname(currentDir)],
consumerVersionTags: ['tag-1'],
consumerVersionTag: ['tag-1'],
});
}).to.throw(Error);
});
}
);

context('when providerVersionTags is not provided', () => {
it('should not fail', () => {
expect(() =>
Expand All @@ -345,18 +318,6 @@ describe('Verifier Spec', () => {
});
});

context('when providerVersionTag is provided as a string', () => {
it('should convert the argument to an array', () => {
const v = verifierFactory({
providerBaseUrl: 'http://localhost',
pactUrls: [path.dirname(currentDir)],
providerVersionTag: 'tag-1',
});

expect(v.options.providerVersionTag).to.deep.eq(['tag-1']);
});
});

context('when providerVersionTags is provided as an array', () => {
it('should not fail', () => {
expect(() =>
Expand All @@ -369,22 +330,6 @@ describe('Verifier Spec', () => {
});
});

context(
'when providerVersionTags and providerVersionTag are provided',
() => {
it('should fail', () => {
expect(() => {
verifierFactory({
providerBaseUrl: 'http://localhost',
pactUrls: [path.dirname(currentDir)],
providerVersionTags: ['tag-1'],
providerVersionTag: ['tag-1'],
});
}).to.throw(Error);
});
}
);

context('when using a bearer token', () => {
context('and specifies a username or password', () => {
it('should fail with an error', () => {
Expand Down
68 changes: 2 additions & 66 deletions src/verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ const checkTypes = require('check-types');
const unixify = require('unixify');

import fs = require('fs');
import { deprecate } from 'util';
import { LogLevel } from './service';

export class Verifier {
public static create = deprecate(
(options: VerifierOptions) => new Verifier(options),
'Create function will be removed in future release, please use the default export function or use `new Verifier()`'
);

public readonly options: VerifierOptions;
private readonly __argMapping = {
pactUrls: DEFAULT_ARG,
Expand Down Expand Up @@ -56,30 +50,10 @@ export class Verifier {
options.provider = options.provider || '';
options.providerStatesSetupUrl = options.providerStatesSetupUrl || '';
options.timeout = options.timeout || 30000;
options.consumerVersionTag = options.consumerVersionTag || [];
options.providerVersionTag = options.providerVersionTag || [];
options.consumerVersionTags = options.consumerVersionTags || [];
options.providerVersionTags = options.providerVersionTags || [];
options.consumerVersionSelectors = options.consumerVersionSelectors || [];

if (
!_.isEmpty(options.consumerVersionTag) &&
!_.isEmpty(options.consumerVersionTags)
) {
throw new Error(
"Must not use both 'consumerVersionTags' and 'consumerVersionTag'. Please use 'consumerVersionTags' instead"
);
}

if (
!_.isEmpty(options.providerVersionTag) &&
!_.isEmpty(options.providerVersionTags)
) {
throw new Error(
"Must not use both 'providerVersionTags' and 'providerVersionTag'. Please use 'providerVersionTags' instead"
);
}

if (
options.consumerVersionTags &&
checkTypes.string(options.consumerVersionTags)
Expand All @@ -96,31 +70,6 @@ export class Verifier {
}
checkTypes.assert.array.of.string(options.providerVersionTags);

if (
options.consumerVersionTag &&
checkTypes.string(options.consumerVersionTag)
) {
options.consumerVersionTag = [options.consumerVersionTag as string];
}
checkTypes.assert.array.of.string(options.consumerVersionTag);

if (
options.providerVersionTag &&
checkTypes.string(options.providerVersionTag)
) {
options.providerVersionTag = [options.providerVersionTag as string];
}
checkTypes.assert.array.of.string(options.providerVersionTag);

if (
!_.isEmpty(options.consumerVersionTag) ||
!_.isEmpty(options.providerVersionTag)
) {
logger.warn(
"'consumerVersionTag' and 'providerVersionTag' have been deprecated, please use 'consumerVersionTags' or 'providerVersionTags' instead"
);
}

if (options.includeWipPactsSince !== undefined) {
checkTypes.assert.nonEmptyString(options.includeWipPactsSince);
}
Expand Down Expand Up @@ -234,12 +183,6 @@ export class Verifier {
checkTypes.assert.boolean(options.enablePending);
}

if (options.tags) {
logger.warn(
"'tags' has been deprecated as at v8.0.0, please use 'consumerVersionTags' instead"
);
}

checkTypes.assert.positive(options.timeout as number);

if (options.monkeypatch) {
Expand Down Expand Up @@ -317,15 +260,8 @@ interface CurrentVerifierOptions {
format?: 'json' | 'xml' | 'progress' | 'RspecJunitFormatter';
out?: string;
logDir?: string;
logLevel?: LogLevel;
}

interface DeprecatedVerifierOptions {
consumerVersionTag?: string | string[];
providerStatesSetupUrl?: string;
providerVersionTag?: string | string[];
tags?: string[];
logLevel?: LogLevel;
}

export type VerifierOptions = CurrentVerifierOptions &
DeprecatedVerifierOptions;
export type VerifierOptions = CurrentVerifierOptions;

0 comments on commit 95b88e0

Please sign in to comment.