Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pact = require('@pact-foundation/pact-node');
const path = require('path');
require('dotenv').config();
if (process.env.PACT_BROKER) {
const opts = {
pactFilesOrDirs: [path.resolve(__dirname, `../../../pacts/${namespace}.json`)],
pactBroker: process.env.PACT_BROKER,
pactBrokerUsername: process.env.PACT_BROKER_USERNAME,
pactBrokerPassword: process.env.PACT_BROKER_PASSWORD,
tags: ['prod', 'test'],
consumerVersion: `${process.env.CI_COMMIT_REF_NAME || 'local'}.${Math.floor(new Date() / 1000)}`,
};
pact.publishPacts(opts)
.then(() => {
})
.catch(() => {
});
} else {
console.log('Skipping pact publish, no PACT_BROKER env variable found!');
}
let publisher = require('@pact-foundation/pact-node');
let path = require('path');
let opts = {
pactFilesOrDirs: [path.resolve(process.cwd(), 'pacts')],
pactBroker: 'https://adesso.pact.dius.com.au/',
pactBrokerUsername: process.env.PACT_USERNAME,
pactBrokerPassword: process.env.PACT_PASSWORD,
consumerVersion: '2.0.0'
};
publisher.publishPacts(opts).then(() => console.log("Pacts successfully published"));
let project = require('./package.json');
let pactBrokerUrl = process.env.npm_package_config_brokerUrl;
let pactBrokerUsername = process.env.npm_package_config_brokerUsername;
let pactBrokerPassword = process.env.npm_package_config_brokerPassword;
let options = {
pactFilesOrDirs: [projectFolder + '/pacts'],
pactBroker: pactBrokerUrl,
consumerVersion: project.version,
tags: ['latest'],
pactBrokerUsername: pactBrokerUsername,
pactBrokerPassword: pactBrokerPassword
};
pact.publishPacts(options).then(function () {
console.log("Pacts successfully published!");
});
const pact = require('@pact-foundation/pact-node')
const path = require('path')
const opts = {
pactFilesOrDirs: [path.resolve(__dirname, 'pacts/myjsmessageconsumer-myjsmessageprovider.json')],
pactBroker: 'https://test.pact.dius.com.au',
pactBrokerUsername: 'dXfltyFMgNOFZAxr8io9wJ37iUpY42M',
pactBrokerPassword: 'O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1',
tags: ['prod', 'test'],
consumerVersion: '1.0.' + ((process.env.TRAVIS_BUILD_NUMBER) ? process.env.TRAVIS_BUILD_NUMBER : Math.floor(new Date() / 1000))
}
pact.publishPacts(opts)
.then(() => {
console.log('Pact contract publishing complete!')
console.log('')
console.log('Head over to https://test.pact.dius.com.au/ and login with')
console.log('=> Username: dXfltyFMgNOFZAxr8io9wJ37iUpY42M')
console.log('=> Password: O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1')
console.log('to see your published contracts.')
})
.catch(e => {
console.log('Pact contract publishing failed: ', e)
})
#!/usr/bin/env node
let pact = require('@pact-foundation/pact-node')
let opts = {
pactFilesOrDirs: [`${__dirname}/../pacts/`],
pactBroker: process.env.PACT_BROKER_URL,
consumerVersion: process.env.PACT_CONSUMER_VERSION,
pactBrokerUsername: process.env.PACT_BROKER_USERNAME,
pactBrokerPassword: process.env.PACT_BROKER_PASSWORD,
tags: process.env.PACT_CONSUMER_TAG
}
pact.publishPacts(opts).then(function () {
console.log('>> Pact files have been published')
})
#!/usr/bin/env node
const pact = require('@pact-foundation/pact-node')
const opts = {
pactFilesOrDirs: [`${__dirname}/../pacts/`],
pactBroker: process.env.PACT_BROKER_URL,
consumerVersion: process.env.PACT_CONSUMER_VERSION,
pactBrokerUsername: process.env.PACT_BROKER_USERNAME,
pactBrokerPassword: process.env.PACT_BROKER_PASSWORD,
tags: process.env.PACT_CONSUMER_TAG
}
pact.publishPacts(opts).then(function () {
console.log('>> Pact files have been published')
})
function publishPacts (opts, args, config) {
return pact.publishPacts(opts).then((pactObject) => {
log('=================================================================================');
log(`Pact ${args.PACT_FILE} Published on ${config.brokerUrl}`);
log('=================================================================================');
log(JSON.stringify(pactObject, null, 2));
log('=================================================================================');
}, (err) => log(`Publish failed because of \n${err}`));
}
let publisher = require("@pact-foundation/pact-node")
let path = require("path")
let opts = {
providerBaseUrl: "http://localhost:8080",
pactFilesOrDirs: [path.resolve(process.cwd(), "pacts")],
pactBroker: "https://localhost:3000",
pactBrokerUsername: process.env.PACT_USERNAME,
pactBrokerPassword: process.env.PACT_PASSWORD,
consumerVersion: "2.0.0",
}
publisher.publishPacts(opts)