Skip to content

Commit

Permalink
Merge pull request #514 from pact-foundation/fix/add_standalone_depre…
Browse files Browse the repository at this point in the history
…cation_warning

fix: add deprecation warnings for pact cli tools in pact-js-core
  • Loading branch information
YOU54F authored Jun 17, 2024
2 parents b0aea6f + b16530a commit ea41a94
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 0 deletions.
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
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

0 comments on commit ea41a94

Please sign in to comment.