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

fix: add deprecation warnings for pact cli tools in pact-js-core #514

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/pact-broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions bin/pact-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {};

Expand Down
2 changes: 2 additions & 0 deletions bin/pact-mock-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {};

Expand Down
2 changes: 2 additions & 0 deletions bin/pact-provider-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {};

Expand Down
2 changes: 2 additions & 0 deletions bin/pact-stub-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {};

Expand Down
2 changes: 2 additions & 0 deletions bin/pact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {};

Expand Down
2 changes: 2 additions & 0 deletions bin/pactflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {};

Expand Down
14 changes: 13 additions & 1 deletion script/lib/download-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
12 changes: 12 additions & 0 deletions src/pact-standalone.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
3 changes: 3 additions & 0 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Loading