Socket
Socket
Sign inDemoInstall

@pact-foundation/pact-node

Package Overview
Dependencies
13
Maintainers
4
Versions
187
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.0 to 6.1.0

bin/pact-cli.spec.d.ts

9

bin/pact-cli.spec.ts

@@ -6,7 +6,7 @@ import chai = require("chai");

import path = require("path");
import _ = require("underscore");
import {ChildProcess} from "child_process";
import {ServerOptions} from "../src/server";
import decamelize = require("decamelize");
import providerMock from "../test/integration/provider-mock";
const decamelize = require("decamelize");
const _ = require("underscore");

@@ -68,3 +68,3 @@ const request = q.denodeify(require("request"));

context("with mock broker", () => {
let server;
let server: any;
const PORT = 9123;

@@ -88,3 +88,3 @@ const providerBaseUrl = `http://localhost:${PORT}`;

.pairs()
.map((arr) => [`--${decamelize(arr[0], "-")}`, `${arr[1]}`])
.map((arr: any[]) => [`--${decamelize(arr[0], "-")}`, `${arr[1]}`])
.flatten()

@@ -119,2 +119,3 @@ .value();

}
return null;
});

@@ -121,0 +122,0 @@ }

#!/usr/bin/env node
import pact from "../src/pact";
import cli = require("caporal");
const cli = require("caporal");

@@ -26,3 +26,3 @@ const pkg = require("../package.json");

.option("--provider [providerName]", "Specify provider name for written Pact files.")
.action((args, options) => pact.createServer(options).start());
.action((args: any, options: any) => pact.createServer(options).start());

@@ -42,4 +42,4 @@ cli

.option("-pub, --publish-verification-result", "Publish verification result to Broker.")
.action((args, options) => pact.verifyPacts(options));
.action((args: any, options: any) => pact.verifyPacts(options));
cli.parse(process.argv);
{
"name": "@pact-foundation/pact-node",
"version": "6.0.0",
"version": "6.1.0",
"description": "A wrapper for the Ruby version of Pact to work within Node",

@@ -71,2 +71,3 @@ "main": "src/index.js",

"@types/request": "2.0.3",
"@types/underscore": "^1.8.5",
"basic-auth": "1.1.0",

@@ -88,2 +89,3 @@ "body-parser": "1.17.2",

"sinon": "3.2.1",
"standard-version": "^4.2.0",
"ts-node": "3.3.0",

@@ -97,7 +99,9 @@ "tslint": "5.7.0",

"pretest": "npm run build",
"test": "mocha -r ts-node/register -R mocha-unfunk-reporter --timeout 10000 \"{src,test,bin}/**/*.spec.ts\"",
"test": "mocha -r ts-node/register -R mocha-unfunk-reporter --timeout 15000 \"{src,test,bin}/**/*.spec.ts\"",
"dev": "npm run lint --force && npm test && node .",
"build": "npm run clean && tsc",
"start": "npm run watch"
"start": "npm run watch",
"prerelease": "npm i && npm t && rm package-lock.json",
"release": "standard-version"
}
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var checkTypes = require("check-types");
var q = require("q");
var logger_1 = require("./logger");
var _ = require("underscore");
var logger_1 = require("./logger");
var checkTypes = require("check-types");
var request = q.denodeify(require("request"));

@@ -8,0 +8,0 @@ var Broker = (function () {

@@ -1,6 +0,6 @@

import checkTypes = require("check-types");
import q = require("q");
import _ = require("underscore");
import logger from "./logger";
import { IWhenable } from "q";
const _ = require("underscore");
const checkTypes = require("check-types");
const request = q.denodeify(require("request"));

@@ -52,3 +52,3 @@

return request(requestOptions)
.then((data) => data[0])
.then((data: any) => data[0])
.then((response) => {

@@ -61,3 +61,3 @@ if (response.statusCode < 200 && response.statusCode >= 300) {

})
.then((data) => data[0])
.then((data: any) => data[0])
.then((response) => response.statusCode < 200 && response.statusCode >= 300 ? q.reject(response) : JSON.parse(response.body));

@@ -70,6 +70,6 @@ }

logger.debug("Finding consumers");
const promises = _.isEmpty(this.options.tags) ? [this.findPacts()] : _.map(this.options.tags, (t) => this.findPacts(t));
const promises = _.isEmpty(this.options.tags) ? [this.findPacts()] : _.map(this.options.tags, (t: string) => this.findPacts(t));
return q.all(promises)
.then((values) => _.reduce(values, (array, v) => {
.then((values) => _.reduce(values, (array: string[], v: any) => {
if (v && v._links && v._links.pacts) {

@@ -80,3 +80,3 @@ array.push(..._.pluck(v._links.pacts, "href"));

}, []))
.catch(() => q.reject(`Unable to find pacts for given provider '${this.options.provider}' and tags '${this.options.tags}'`));
.catch(() => q.reject<IWhenable<any>>(`Unable to find pacts for given provider '${this.options.provider}' and tags '${this.options.tags}'`));
}

@@ -83,0 +83,0 @@ }

import bunyan = require("bunyan");
import PrettyStream = require("bunyan-prettystream");
const PrettyStream = require("bunyan-prettystream");

@@ -4,0 +4,0 @@ const pkg = require("../package.json");

@@ -14,5 +14,5 @@ /// <reference types="node" />

export interface SpawnArguments {
[id: string]: string | string[] | boolean | number;
[id: string]: string | string[] | boolean | number | undefined;
}
declare const _default: PactUtil;
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var cp = require("child_process");
var logger_1 = require("./logger");
var _ = require("underscore");
var checkTypes = require("check-types");
var pactStandalone = require("@pact-foundation/pact-standalone");
var cp = require("child_process");
var logger_1 = require("./logger");
var isWindows = process.platform === "win32";

@@ -20,3 +20,3 @@ exports.DEFAULT_ARG = "DEFAULT";

if (mapping_1 === exports.DEFAULT_ARG) {
mapping_1 = null;
mapping_1 = "";
f_1 = acc.unshift.bind(acc);

@@ -23,0 +23,0 @@ }

// tslint:disable:no-string-literal
import _ = require("underscore");
import checkTypes = require("check-types");
import pactStandalone = require("@pact-foundation/pact-standalone");
import cp = require("child_process");
import logger from "./logger";
import {ChildProcess, SpawnOptions} from "child_process";
import { Dictionary } from "underscore";
const _ = require("underscore");
const checkTypes = require("check-types");
const pactStandalone = require("@pact-foundation/pact-standalone");

@@ -16,3 +17,3 @@ const isWindows = process.platform === "win32";

return _.chain(args)
.reduce((acc, value, key) => {
.reduce((acc: any, value: any, key: any) => {
if (value && mappings[key]) {

@@ -22,6 +23,6 @@ let mapping = mappings[key];

if (mapping === DEFAULT_ARG) {
mapping = null;
mapping = "";
f = acc.unshift.bind(acc);
}
_.map(checkTypes.array(value) ? value : [value], (v) => f([mapping, `'${v}'`]));
_.map(checkTypes.array(value) ? value : [value], (v: any) => f([mapping, `'${v}'`]));
}

@@ -97,5 +98,5 @@ return acc;

export interface SpawnArguments {
[id: string]: string | string[] | boolean | number;
[id: string]: string | string[] | boolean | number | undefined;
}
export default new PactUtil();
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _ = require("underscore");
var q = require("q");

@@ -9,2 +8,3 @@ var server_1 = require("./server");

var logger_1 = require("./logger");
var _ = require("underscore");
var Pact = (function () {

@@ -11,0 +11,0 @@ function Pact() {

@@ -8,4 +8,4 @@ import chai = require("chai");

const expect = chai.expect;
chai.use(chaiAsPromised);
const currentDir = (process && process.mainModule) ? process.mainModule.filename : "";

@@ -16,3 +16,3 @@ describe("Pact Spec", () => {

describe("Set Log Level", () => {
let originalLogLevel;
let originalLogLevel: any;
// Reset lot level after the tests

@@ -56,3 +56,3 @@ before(() => originalLogLevel = pact.logLevel());

describe("Create serverFactory", () => {
let dirPath;
let dirPath: string;

@@ -248,3 +248,3 @@ beforeEach(() => dirPath = path.resolve(__dirname, `../.tmp/${Math.floor(Math.random() * 1000)}`));

providerBaseUrl: "http://localhost",
pactUrls: [path.dirname(process.mainModule.filename)]
pactUrls: [path.dirname(currentDir)]
};

@@ -260,3 +260,3 @@ return expect(pact.verifyPacts(opts)).to.eventually.be.fulfilled;

pactBroker: "http://localhost",
pactUrls: [path.dirname(process.mainModule.filename)],
pactUrls: [path.dirname(currentDir)],
consumerVersion: "1.0.0"

@@ -263,0 +263,0 @@ };

@@ -1,2 +0,1 @@

import _ = require("underscore");
import q = require("q");

@@ -7,2 +6,3 @@ import serverFactory, {Server, ServerOptions} from "./server";

import logger, {LogLevels} from "./logger";
import _ = require("underscore");

@@ -25,3 +25,3 @@ export class Pact {

public createServer(options: ServerOptions = {}): Server {
if (options && options.port && _.some(this.__servers, (s) => s.options.port === options.port)) {
if (options && options.port && _.some(this.__servers, (s: Server) => s.options.port === options.port)) {
let msg = `Port '${options.port}' is already in use by another process.`;

@@ -37,3 +37,3 @@ logger.error(msg);

// Listen to server delete events, to remove from server list
server.once("delete", (s) => {
server.once("delete", (s: Server) => {
logger.info(`Deleting Pact Server with options: \n${this.__stringifyOptions(s.options)}`);

@@ -59,3 +59,3 @@ this.__servers = _.without(this.__servers, s);

logger.info("Removing all Pact servers.");
return q.all<Server>(_.map(this.__servers, (server:Server) => server.delete()));
return q.all<Server>(_.map(this.__servers, (server:Server) => server.delete() as PromiseLike<Server>));
}

@@ -78,3 +78,3 @@

.pairs()
.map((v) => v.join(" = "))
.map((v: string[]) => v.join(" = "))
.value()

@@ -81,0 +81,0 @@ .join(",\n");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var checkTypes = require("check-types");
var q = require("q");
var logger_1 = require("./logger");
var pact_util_1 = require("./pact-util");
var pactStandalone = require("@pact-foundation/pact-standalone");
var pact_util_1 = require("./pact-util");
var checkTypes = require("check-types");
var Publisher = (function () {

@@ -9,0 +9,0 @@ function Publisher(options) {

@@ -13,2 +13,3 @@ // tslint:disable:no-string-literal

chai.use(chaiAsPromised);
const currentDir = (process && process.mainModule) ? process.mainModule.filename : "";

@@ -43,3 +44,3 @@ describe("Publish Spec", () => {

publisherFactory({
pactFilesOrDirs: [path.dirname(process.mainModule.filename)],
pactFilesOrDirs: [path.dirname(currentDir)],
consumerVersion: "1.0.0"

@@ -56,3 +57,3 @@ });

pactBroker: "http://localhost",
pactFilesOrDirs: [path.dirname(process.mainModule.filename)]
pactFilesOrDirs: [path.dirname(currentDir)]
});

@@ -79,3 +80,3 @@ }).to.throw(Error);

pactBroker: "http://localhost",
pactFilesOrDirs: [path.dirname(process.mainModule.filename)],
pactFilesOrDirs: [path.dirname(currentDir)],
consumerVersion: "1.0.0"

@@ -82,0 +83,0 @@ });

@@ -1,6 +0,6 @@

import checkTypes = require("check-types");
import q = require("q");
import logger from "./logger";
import pactStandalone = require("@pact-foundation/pact-standalone");
import pactUtil, {DEFAULT_ARG, SpawnArguments} from "./pact-util";
const pactStandalone = require("@pact-foundation/pact-standalone");
const checkTypes = require("check-types");

@@ -63,3 +63,3 @@ export class Publisher {

const instance = pactUtil.spawnBinary(`${pactStandalone.brokerPath} publish`, this.options, this.__argMapping);
const output = [];
const output: any[] = [];
instance.stdout.on("data", (l) => output.push(l));

@@ -80,3 +80,3 @@ instance.stderr.on("data", (l) => output.push(l));

return deferred.promise
.timeout(this.options.timeout, `Timeout waiting for verification process to complete (PID: ${instance.pid})`);
.timeout(this.options.timeout as number, `Timeout waiting for verification process to complete (PID: ${instance.pid})`);
}

@@ -83,0 +83,0 @@ }

@@ -13,3 +13,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var checkTypes = require("check-types");
var path = require("path");

@@ -20,6 +19,7 @@ var fs = require("fs");

var q = require("q");
var pact = require("@pact-foundation/pact-standalone");
var mkdirp = require("mkdirp");
var logger_1 = require("./logger");
var pact_util_1 = require("./pact-util");
var mkdirp = require("mkdirp");
var pact = require("@pact-foundation/pact-standalone");
var checkTypes = require("check-types");
var CHECKTIME = 500;

@@ -136,3 +136,3 @@ var RETRY_AMOUNT = 60;

logger_1.default.warn("You already have a process running with PID: " + this.__instance.pid);
return;
return q.resolve(this);
}

@@ -170,3 +170,2 @@ this.__instance = pact_util_1.default.spawnBinary(pact.mockServicePath + " service", this.options, this.__argMapping);

_this.__running = false;
_this.__instance = undefined;
_this.emit(Server.Events.STOP_EVENT, _this);

@@ -173,0 +172,0 @@ return _this;

@@ -15,3 +15,3 @@ // tslint:disable:no-string-literal

describe("Server Spec", () => {
let server;
let server: any;

@@ -61,3 +61,3 @@ afterEach(() => server ? server.delete() : null);

context("when valid options are set", () => {
let dirPath;
let dirPath: string;

@@ -64,0 +64,0 @@ beforeEach(() => dirPath = path.resolve(__dirname, `../.tmp/${Math.floor(Math.random() * 1000)}`));

// tslint:disable:no-string-literal
import checkTypes = require("check-types");
import path = require("path");

@@ -9,7 +8,8 @@ import fs = require("fs");

import q = require("q");
import pact = require("@pact-foundation/pact-standalone");
import mkdirp = require("mkdirp");
import logger from "./logger";
import pactUtil, {SpawnArguments} from "./pact-util";
import {ChildProcess} from "child_process";
const mkdirp = require("mkdirp");
const pact = require("@pact-foundation/pact-standalone");
const checkTypes = require("check-types");

@@ -153,3 +153,3 @@ const CHECKTIME = 500;

logger.warn(`You already have a process running with PID: ${this.__instance.pid}`);
return;
return q.resolve(this);
}

@@ -161,3 +161,3 @@ this.__instance = pactUtil.spawnBinary(`${pact.mockServicePath} service`, this.options, this.__argMapping);

// if port isn't specified, listen for it when pact runs
const catchPort = (data) => {
const catchPort = (data: any) => {
const match = data.match(/port=([0-9]+)/);

@@ -194,3 +194,2 @@ if (match && match[1]) {

this.__running = false;
this.__instance = undefined;
this.emit(Server.Events.STOP_EVENT, this);

@@ -273,3 +272,3 @@ return this;

http(config, (err, res) => (!err && res.statusCode === 200) ? deferred.resolve() : deferred.reject(`HTTP Error: '${JSON.stringify(err ? err : res)}'`));
http(config, (err: any, res: any) => (!err && res.statusCode === 200) ? deferred.resolve() : deferred.reject(`HTTP Error: '${JSON.stringify(err ? err : res)}'`));

@@ -276,0 +275,0 @@ return deferred.promise;

/// <reference types="q" />
import { SpawnArguments } from "./pact-util";
import q = require("q");
import { SpawnArguments } from "./pact-util";
export declare class Verifier {

@@ -5,0 +5,0 @@ static create(options: VerifierOptions): Verifier;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var checkTypes = require("check-types");
var path = require("path");
var q = require("q");
var _ = require("underscore");
var unixify = require("unixify");
var url = require("url");
var pactStandalone = require("@pact-foundation/pact-standalone");
var broker_1 = require("./broker");
var logger_1 = require("./logger");
var pact_util_1 = require("./pact-util");
var q = require("q");
var _ = require("underscore");
var pactStandalone = require("@pact-foundation/pact-standalone");
var checkTypes = require("check-types");
var unixify = require("unixify");
var fs = require("fs");

@@ -36,3 +36,3 @@ var Verifier = (function () {

.map(function (uri) {
if (!/https?:/.test(url.parse(uri).protocol)) {
if (!/https?:/.test(url.parse(uri).protocol || "")) {
try {

@@ -39,0 +39,0 @@ fs.statSync(path.normalize(uri)).isFile();

@@ -8,2 +8,3 @@ import path = require("path");

chai.use(chaiAsPromised);
const currentDir = (process && process.mainModule) ? process.mainModule.filename : "";

@@ -90,3 +91,3 @@ describe("Verifier Spec", () => {

providerBaseUrl: "http://localhost",
pactUrls: [path.dirname(process.mainModule.filename)]
pactUrls: [path.dirname(currentDir)]
})).to.not.throw(Error);

@@ -93,0 +94,0 @@ });

@@ -1,11 +0,11 @@

import checkTypes = require("check-types");
import path = require("path");
import q = require("q");
import _ = require("underscore");
import unixify = require("unixify");
import url = require("url");
import pactStandalone = require("@pact-foundation/pact-standalone");
import Broker from "./broker";
import logger from "./logger";
import pactUtil, {DEFAULT_ARG, SpawnArguments} from "./pact-util";
import q = require("q");
const _ = require("underscore");
const pactStandalone = require("@pact-foundation/pact-standalone");
const checkTypes = require("check-types");
const unixify = require("unixify");

@@ -24,5 +24,5 @@ import fs = require("fs");

options.pactUrls = _.chain(options.pactUrls)
.map((uri) => {
.map((uri: string) => {
// only check local files
if (!/https?:/.test(url.parse(uri).protocol)) { // If it"s not a URL, check if file is available
if (!/https?:/.test(url.parse(uri).protocol || "")) { // If it's not a URL, check if file is available
try {

@@ -115,3 +115,3 @@ fs.statSync(path.normalize(uri)).isFile();

return q(this.options.pactUrls)
.then((uris) => {
.then((uris) => {
if (!uris || uris.length === 0) {

@@ -128,7 +128,7 @@ return new Broker({

})
.then((data: string[]): q.Promise<string> => {
.then((data: string[]): PromiseLike<string> => {
const deferred = q.defer<string>();
this.options.pactUrls = data;
const instance = pactUtil.spawnBinary(pactStandalone.verifierPath, this.options, this.__argMapping);
const output = [];
const output: any[] = [];
instance.stdout.on("data", (l) => output.push(l));

@@ -142,4 +142,4 @@ instance.stderr.on("data", (l) => output.push(l));

return deferred.promise
.timeout(this.options.timeout, `Timeout waiting for verification process to complete (PID: ${instance.pid})`)
.tap(() => logger.info("Pact Verification succeeded."));
.timeout(this.options.timeout as number, `Timeout waiting for verification process to complete (PID: ${instance.pid})`)
.tap(() => logger.info("Pact Verification succeeded.")) as PromiseLike<string>;
});

@@ -146,0 +146,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var q = require("q");
var express = require("express");
var data_utils_1 = require("./data-utils");
var cors = require("cors");
var _ = require("underscore");
var q = require("q");
var express = require("express");
var bodyParser = require("body-parser");
var data_utils_1 = require("./data-utils");
exports.default = function (port) {

@@ -10,0 +10,0 @@ var BROKER_HOST = "http://localhost:" + port;

@@ -1,8 +0,8 @@

import cors = require("cors");
import _ = require("underscore");
import q = require("q");
import express = require("express");
import bodyParser = require("body-parser");
import * as http from "http";
import {auth, returnJson} from "./data-utils";
const cors = require("cors");
const _ = require("underscore");
const bodyParser = require("body-parser");

@@ -9,0 +9,0 @@ export default (port: number): q.Promise<http.Server> => {

@@ -16,3 +16,2 @@ "use strict";

next();
return;
}

@@ -19,0 +18,0 @@ res.set("WWW-Authenticate", "Basic realm=Authorization Required");

import express = require("express");
import basicAuth = require("basic-auth");
const basicAuth = require("basic-auth");

@@ -16,3 +16,2 @@ export function returnJsonFile(filename: string): (req: express.Request, res: express.Response) => express.Response {

next();
return;
}

@@ -19,0 +18,0 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var cors = require("cors");
var express = require("express");
var q = require("q");
var data_utils_1 = require("./data-utils");
var cors = require("cors");
var bodyParser = require("body-parser");
var data_utils_1 = require("./data-utils");
exports.default = function (port) {

@@ -9,0 +9,0 @@ var server = express();

@@ -1,7 +0,7 @@

import cors = require("cors");
import express = require("express");
import q = require("q");
import bodyParser = require("body-parser");
import * as http from "http";
import {returnJson, returnJsonFile, auth} from "./data-utils";
const cors = require("cors");
const bodyParser = require("body-parser");

@@ -8,0 +8,0 @@ export default (port: number): q.Promise<http.Server> => {

@@ -5,3 +5,2 @@ {

"target": "es5",
"noImplicitAny": false,
"removeComments": true,

@@ -16,3 +15,7 @@ "noLib": false,

"suppressImplicitAnyIndexErrors": true,
"declaration": true
"declaration": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true
},

@@ -25,3 +28,2 @@ "include": [

"node_modules",
"**/*.spec.ts",
"**/*.d.ts"

@@ -28,0 +30,0 @@ ],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc