From 62925355646d7cb6abd4331cbfaf9c29a91926a9 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 12 Jun 2024 13:12:07 +0100 Subject: [PATCH 1/2] fix: add deprecation warnings for pact cli tools in pact-js-core All CLI/API functionality provided by the Pact CLI tools (ruby based) will be moved in pact-js-core 15.x to pact-js-cli. * Repo * https://github.com/pact-foundation/pact-js-cli/ * NPM Package * https://www.npmjs.com/package/@pact-foundation/pact-cli * imports * `@pact-foundation/pact-core` imports will now become `@pact-foundation/pact-cli` for programatic usage of the CLI tools * npx usage * `npx --package=@pact-foundation/pact-cli@15.0.1 -c pact-broker` --- bin/pact-broker.ts | 2 ++ bin/pact-message.ts | 2 ++ bin/pact-mock-service.ts | 2 ++ bin/pact-provider-verifier.ts | 2 ++ bin/pact-stub-service.ts | 2 ++ bin/pact.ts | 2 ++ bin/pactflow.ts | 2 ++ src/pact-standalone.ts | 12 ++++++++++++ src/service.ts | 3 +++ 9 files changed, 29 insertions(+) diff --git a/bin/pact-broker.ts b/bin/pact-broker.ts index 6c614acd..f46d0a99 100644 --- a/bin/pact-broker.ts +++ b/bin/pact-broker.ts @@ -5,8 +5,10 @@ import { standalone, standaloneUseShell, setStandaloneArgs, + showStandaloneDeprecationWarning, } from '../src/pact-standalone'; +showStandaloneDeprecationWarning(); const args = process.argv.slice(2); const opts = standaloneUseShell ? { shell: true } : {}; const { error, status } = childProcess.spawnSync( diff --git a/bin/pact-message.ts b/bin/pact-message.ts index d1d2214c..7b080500 100644 --- a/bin/pact-message.ts +++ b/bin/pact-message.ts @@ -5,8 +5,10 @@ import { standalone, standaloneUseShell, setStandaloneArgs, + showStandaloneDeprecationWarning, } from '../src/pact-standalone'; +showStandaloneDeprecationWarning(); const args = process.argv.slice(2); const opts = standaloneUseShell ? { shell: true } : {}; diff --git a/bin/pact-mock-service.ts b/bin/pact-mock-service.ts index b3542900..6e80acbc 100644 --- a/bin/pact-mock-service.ts +++ b/bin/pact-mock-service.ts @@ -5,8 +5,10 @@ import { standalone, standaloneUseShell, setStandaloneArgs, + showStandaloneDeprecationWarning, } from '../src/pact-standalone'; +showStandaloneDeprecationWarning(); const args = process.argv.slice(2); const opts = standaloneUseShell ? { shell: true } : {}; diff --git a/bin/pact-provider-verifier.ts b/bin/pact-provider-verifier.ts index 706fc925..a1fa9411 100644 --- a/bin/pact-provider-verifier.ts +++ b/bin/pact-provider-verifier.ts @@ -5,8 +5,10 @@ import { standalone, standaloneUseShell, setStandaloneArgs, + showStandaloneDeprecationWarning, } from '../src/pact-standalone'; +showStandaloneDeprecationWarning(); const args = process.argv.slice(2); const opts = standaloneUseShell ? { shell: true } : {}; diff --git a/bin/pact-stub-service.ts b/bin/pact-stub-service.ts index 3e02e29c..bca5c7fa 100644 --- a/bin/pact-stub-service.ts +++ b/bin/pact-stub-service.ts @@ -5,8 +5,10 @@ import { standalone, standaloneUseShell, setStandaloneArgs, + showStandaloneDeprecationWarning, } from '../src/pact-standalone'; +showStandaloneDeprecationWarning(); const args = process.argv.slice(2); const opts = standaloneUseShell ? { shell: true } : {}; diff --git a/bin/pact.ts b/bin/pact.ts index d4afad30..ab6412c2 100644 --- a/bin/pact.ts +++ b/bin/pact.ts @@ -5,8 +5,10 @@ import { standalone, standaloneUseShell, setStandaloneArgs, + showStandaloneDeprecationWarning, } from '../src/pact-standalone'; +showStandaloneDeprecationWarning(); const args = process.argv.slice(2); const opts = standaloneUseShell ? { shell: true } : {}; diff --git a/bin/pactflow.ts b/bin/pactflow.ts index fddc26fd..bce1f397 100644 --- a/bin/pactflow.ts +++ b/bin/pactflow.ts @@ -5,8 +5,10 @@ import { standalone, standaloneUseShell, setStandaloneArgs, + showStandaloneDeprecationWarning, } from '../src/pact-standalone'; +showStandaloneDeprecationWarning(); const args = process.argv.slice(2); const opts = standaloneUseShell ? { shell: true } : {}; diff --git a/src/pact-standalone.ts b/src/pact-standalone.ts index 3dc11632..8ef06644 100644 --- a/src/pact-standalone.ts +++ b/src/pact-standalone.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import { getBinaryEntry } from '../standalone/install'; import pactEnvironment from './pact-environment'; +import logger from './logger'; export interface PactStandalone { cwd: string; @@ -110,6 +111,17 @@ export function setStandaloneArgs( return parsedArgs; } +export function showStandaloneDeprecationWarning(): void { + const silenceDeprecationWarnings = + process.env['PACT_SILENCE_DEPRECATION_WARNINGS'] === 'true'; + + if (!silenceDeprecationWarnings) { + logger.warn( + 'DEPRECATION NOTICE: \n pact standalone tools will be removed in pact-js-core 15.x. \n Please update imports to @pact-foundation/pact-cli \n https://github.com/pact-foundation/pact-js-core/issues/488' + ); + } +} + export const standaloneUseShell = isWindows; export default standalone(); diff --git a/src/service.ts b/src/service.ts index 1777d692..685e9d03 100644 --- a/src/service.ts +++ b/src/service.ts @@ -12,6 +12,7 @@ import spawn, { CliVerbOptions } from './spawn'; import { LogLevel } from './logger/types'; import logger, { setLogLevel } from './logger'; import { ServiceOptions } from './types'; +import { showStandaloneDeprecationWarning } from './pact-standalone'; // Get a reference to the global setTimeout object in case it is mocked by a testing library later const { setTimeout } = global; @@ -93,6 +94,8 @@ export abstract class AbstractService extends events.EventEmitter { 'Like a Boss, you used a port outside of the recommended range (1024 to 49151); I too like to live dangerously.' ); } + + showStandaloneDeprecationWarning(); } // ssl check From b16530a4eb3adcc34e121de155965a572d433f54 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Wed, 12 Jun 2024 13:17:43 +0100 Subject: [PATCH 2/2] ci(win): workaround for broken curl 8.8.0 --write-out opt in gha images --- script/lib/download-file.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/script/lib/download-file.sh b/script/lib/download-file.sh index 0640a0ea..87110c34 100644 --- a/script/lib/download-file.sh +++ b/script/lib/download-file.sh @@ -16,7 +16,19 @@ function download_to { OUTPUT_FILE="$2" debug_log "doing curl of: '$URL', saving in $OUTPUT_FILE" - HTTP_CODE="$(curl --silent --output "$OUTPUT_FILE" --write-out "%{http_code}" --location "$URL")" + if [[ "$(uname -m)" == "Darwin" ]] || [[ "$(uname -m)" == "Linux" ]]; then + HTTP_CODE="$(curl --silent --output "$OUTPUT_FILE" --write-out "%{http_code}" --location "$URL")" + else + # temp workaround for curl 8.8.x error on windows gha runners + # https://github.com/curl/curl/issues/13845 + curl --silent --output "$OUTPUT_FILE" --location "$URL" + if [ $? -ne 0 ]; then + error "Unable to download file at url ${URL}" + exit 1 + else + HTTP_CODE=200 + fi + fi debug_log "did curl, http code was '${HTTP_CODE}'" if [[ "${HTTP_CODE}" -lt 200 || "${HTTP_CODE}" -gt 299 ]] ; then error "Unable to download file at url ${URL}"