Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pact.publishPacts(opts) missing #426

Closed
3 of 5 tasks
ireinhart opened this issue Dec 27, 2022 · 4 comments
Closed
3 of 5 tasks

pact.publishPacts(opts) missing #426

ireinhart opened this issue Dec 27, 2022 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@ireinhart
Copy link

Since 13.3.3 the function publishPacts() is not found.

Software versions

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

If I run the code from https://github.com/pact-foundation/pact-js-core#pact-broker-publishing it should publish pacts.

My version

let publisher = require("@pact-foundation/pact-core");
let path = require("path");
if(process.env.bamboo_planRepository_branch == 'master') {
    let opts = {
        pactFilesOrDirs: [path.resolve(process.cwd(), "../../artifacts/contracts/js")],
        pactBroker: "https://pact-broker.mydomain.net",
        consumerVersion: "1.0-" + process.env.bamboo_repository_revision_number.substring(0, 8),
        tags: ['master']
    };
    publisher.publishPacts(opts);
} else {
    console.log('Pact publishing only at master branch on bamboo');
}

Actual behaviour

build	27-Dec-2022 05:13:37	> [email protected] publish:pact
build	27-Dec-2022 05:13:37	> node ./assets/js/pact/publish.js
build	27-Dec-2022 05:13:37	
error	27-Dec-2022 05:13:37	/opt/bamboo/xml-data/build-dir/APPLICATIONS-UM-JOB1/components/app/assets/js/pact/publish.js:10
error	27-Dec-2022 05:13:37	    publisher.publishPacts(opts);
error	27-Dec-2022 05:13:37	              ^
error	27-Dec-2022 05:13:37	
error	27-Dec-2022 05:13:37	TypeError: publisher.publishPacts is not a function
error	27-Dec-2022 05:13:37	    at Object.<anonymous> (/opt/bamboo/xml-data/build-dir/APPLICATIONS-UM-JOB1/components/app/assets/js/pact/publish.js:10:15)
error	27-Dec-2022 05:13:37	    at Module._compile (node:internal/modules/cjs/loader:1159:14)
error	27-Dec-2022 05:13:37	    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
error	27-Dec-2022 05:13:37	    at Module.load (node:internal/modules/cjs/loader:1037:32)
error	27-Dec-2022 05:13:37	    at Module._load (node:internal/modules/cjs/loader:878:12)
error	27-Dec-2022 05:13:37	    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
error	27-Dec-2022 05:13:37	    at node:internal/main/run_main_module:23:47
@ireinhart ireinhart added the bug Indicates an unexpected problem or unintended behavior label Dec 27, 2022
@TimothyJones
Copy link
Contributor

Ah, apologies. This one is my fault.

There's a break between 13.13.2 and 13.13.3 because I removed a hack in the exports that this particular usage relies on. I'll make a PR to put it back.

For now, you could work around it with:

let publisher = require("@pact-foundation/pact-core").default;

(this will work in all versions)

I believe the recommended path for publishing is to use the CLI binstubs anyway - is there a reason you need programmatic access?

You can find examples of the CLI usage here, and if you need the documentation for the CLI, you can print the usage information with npx pact-broker once you've installed pact.

(For maintainers: I can't find the publishing pacts instructions from the pact-js documentation any more. I know it used to be there - am I just looking in the wrong place?)

TimothyJones added a commit to TimothyJones/pact-js-core that referenced this issue Dec 28, 2022
TimothyJones added a commit to TimothyJones/pact-js-core that referenced this issue Dec 28, 2022
TimothyJones added a commit to TimothyJones/pact-js-core that referenced this issue Dec 28, 2022
@TimothyJones
Copy link
Contributor

TimothyJones commented Dec 28, 2022

Fix is up in #427. (despite what the build status checkmarks above suggest, the build is passing - click through to the PR for details).

@ireinhart
Copy link
Author

Thx Timothy for your very fast fix!!!

For me the workaround with .default is totally fine.

I am not the producer of this nice custom script. That is an old relict from another team. At some places I replaced such things by using the official pact-broker/cli image for pact publishing.

To update the example code at https://github.com/pact-foundation/pact-js-core#pact-broker-publishing could help someone else.

Best, Ingo

@TimothyJones
Copy link
Contributor

I am not the producer of this nice custom script. That is an old relict from another team

Ah yes. In their defence, using this function in a custom script used to be the recommended way, but that changed in some release in the last couple of years.

To update the example code at https://github.com/pact-foundation/pact-js-core#pact-broker-publishing could help someone else.

This readme is intended for users of the pact-core package - which isn't intended to be end users. However, it does look like:

  1. the the end-user documentation for publishing pacts has been lost in some re-shuffle of documentation at some point, so this seems like currently the best source - so it's not surprising that you found it
  2. It could be clearer that this is maintainer documentation and not user documentation

I'll leave those for the current maintainers to pick up.

Thanks again for the report!

(cc @mefellows and @YOU54F) - Also, my apologies to all for introducing a regression in a linting PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants