Skip to content

Commit

Permalink
fix: add deprecation warnings for pact cli tools in pact-js-core
Browse files Browse the repository at this point in the history
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/[email protected] -c pact-broker`
  • Loading branch information
YOU54F committed Jun 12, 2024
1 parent ead4097 commit 6292535
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 6292535

Please sign in to comment.