File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,20 +5,27 @@ published_version=$(npm view @nhsdigital/notify-digital-letters-consumer-contrac
55
66set -euo pipefail
77
8+ cd " $( git rev-parse --show-toplevel) "
9+
810# Fail if there are uncommitted changes as this indicates unexpected changes to the contracts
911git diff --quiet tests/pact-tests
1012
11- local_version=$( cat pact-contracts/package.json | jq -r ' .version' )
12-
13- if [[ ! $BRANCH_NAME == " main" ]]; then
13+ branch_name=${BRANCH_NAME:- $(git rev-parse --abbrev-ref HEAD 2>/ dev/ null || echo " " )}
14+ if [[ " $branch_name " != " main" ]]; then
1415 echo " Not publishing package because this is not the main branch"
1516 exit 0
1617fi
1718
19+ local_version=$( cat pact-contracts/package.json | jq -r ' .version' )
1820if [[ $local_version == $published_version ]]; then
1921 echo " Local version is the same as the latest published version - skipping publish"
2022 exit 0
2123fi
2224
25+ if ! ls pact-contracts/pacts/** /* .json > /dev/null 2>&1 ; then
26+ echo " Cannot publish package: no pact .json files found under pact-contracts/pacts"
27+ exit 1
28+ fi
29+
2330echo " Local version is different to the latest published version - publishing new version"
2431npm publish ./pact-contracts
Original file line number Diff line number Diff line change 22
33set -euo pipefail
44
5+ schema_package=" @nhsdigital/nhs-notify-event-schemas-status-published"
6+
57cd " $( git rev-parse --show-toplevel) "
68
7- if [[ $( npm outdated @nhsdigital/nhs-notify-event-schemas-status-published) ]]; then
8- echo " The provider schema package (@nhsdigital/nhs-notify-event-schemas-status-published) is outdated."
9- echo " Please run \` npm update @nhsdigital/nhs-notify-event-schemas-status-published\` to update to the latest version and re-run."
9+ if npm outdated " $schema_package " > /dev/null 2>&1 ; then
10+ outdated_status=0
11+ else
12+ outdated_status=$?
13+ fi
14+
15+ if [[ $outdated_status -eq 1 ]]; then
16+ echo " The provider schema package ($schema_package ) is outdated."
17+ echo " Please run npm update $schema_package to update to the latest version and re-run."
1018 echo
1119 exit 1
1220fi
1321
22+ if [[ $outdated_status -gt 1 ]]; then
23+ echo " Failed to check provider schema package version (npm outdated exited with status $outdated_status )."
24+ exit $outdated_status
25+ fi
26+
1427npm run test:contract
You can’t perform that action at this time.
0 commit comments