Skip to content

Commit 6292535

Browse files
committed
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`
1 parent ead4097 commit 6292535

File tree

9 files changed

+29
-0
lines changed

9 files changed

+29
-0
lines changed

bin/pact-broker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import {
55
standalone,
66
standaloneUseShell,
77
setStandaloneArgs,
8+
showStandaloneDeprecationWarning,
89
} from '../src/pact-standalone';
910

11+
showStandaloneDeprecationWarning();
1012
const args = process.argv.slice(2);
1113
const opts = standaloneUseShell ? { shell: true } : {};
1214
const { error, status } = childProcess.spawnSync(

bin/pact-message.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import {
55
standalone,
66
standaloneUseShell,
77
setStandaloneArgs,
8+
showStandaloneDeprecationWarning,
89
} from '../src/pact-standalone';
910

11+
showStandaloneDeprecationWarning();
1012
const args = process.argv.slice(2);
1113
const opts = standaloneUseShell ? { shell: true } : {};
1214

bin/pact-mock-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import {
55
standalone,
66
standaloneUseShell,
77
setStandaloneArgs,
8+
showStandaloneDeprecationWarning,
89
} from '../src/pact-standalone';
910

11+
showStandaloneDeprecationWarning();
1012
const args = process.argv.slice(2);
1113
const opts = standaloneUseShell ? { shell: true } : {};
1214

bin/pact-provider-verifier.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import {
55
standalone,
66
standaloneUseShell,
77
setStandaloneArgs,
8+
showStandaloneDeprecationWarning,
89
} from '../src/pact-standalone';
910

11+
showStandaloneDeprecationWarning();
1012
const args = process.argv.slice(2);
1113
const opts = standaloneUseShell ? { shell: true } : {};
1214

bin/pact-stub-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import {
55
standalone,
66
standaloneUseShell,
77
setStandaloneArgs,
8+
showStandaloneDeprecationWarning,
89
} from '../src/pact-standalone';
910

11+
showStandaloneDeprecationWarning();
1012
const args = process.argv.slice(2);
1113
const opts = standaloneUseShell ? { shell: true } : {};
1214

bin/pact.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import {
55
standalone,
66
standaloneUseShell,
77
setStandaloneArgs,
8+
showStandaloneDeprecationWarning,
89
} from '../src/pact-standalone';
910

11+
showStandaloneDeprecationWarning();
1012
const args = process.argv.slice(2);
1113
const opts = standaloneUseShell ? { shell: true } : {};
1214

bin/pactflow.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import {
55
standalone,
66
standaloneUseShell,
77
setStandaloneArgs,
8+
showStandaloneDeprecationWarning,
89
} from '../src/pact-standalone';
910

11+
showStandaloneDeprecationWarning();
1012
const args = process.argv.slice(2);
1113
const opts = standaloneUseShell ? { shell: true } : {};
1214

src/pact-standalone.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path';
22
import { getBinaryEntry } from '../standalone/install';
33
import pactEnvironment from './pact-environment';
4+
import logger from './logger';
45

56
export interface PactStandalone {
67
cwd: string;
@@ -110,6 +111,17 @@ export function setStandaloneArgs(
110111
return parsedArgs;
111112
}
112113

114+
export function showStandaloneDeprecationWarning(): void {
115+
const silenceDeprecationWarnings =
116+
process.env['PACT_SILENCE_DEPRECATION_WARNINGS'] === 'true';
117+
118+
if (!silenceDeprecationWarnings) {
119+
logger.warn(
120+
'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'
121+
);
122+
}
123+
}
124+
113125
export const standaloneUseShell = isWindows;
114126

115127
export default standalone();

src/service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import spawn, { CliVerbOptions } from './spawn';
1212
import { LogLevel } from './logger/types';
1313
import logger, { setLogLevel } from './logger';
1414
import { ServiceOptions } from './types';
15+
import { showStandaloneDeprecationWarning } from './pact-standalone';
1516

1617
// Get a reference to the global setTimeout object in case it is mocked by a testing library later
1718
const { setTimeout } = global;
@@ -93,6 +94,8 @@ export abstract class AbstractService extends events.EventEmitter {
9394
'Like a Boss, you used a port outside of the recommended range (1024 to 49151); I too like to live dangerously.'
9495
);
9596
}
97+
98+
showStandaloneDeprecationWarning();
9699
}
97100

98101
// ssl check

0 commit comments

Comments
 (0)