@govuk-pay/cli 0.0.19 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@govuk-pay/cli",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "GOV.UK Pay Command Line Interface",
5
5
  "bin": {
6
6
  "pay": "bin/cli.js",
@@ -9,6 +9,7 @@ const demo_js_1 = __importDefault(require("../commands/demo.js"));
9
9
  const legacy_1 = __importDefault(require("../commands/legacy"));
10
10
  const help_1 = __importDefault(require("../commands/help"));
11
11
  const tunnel_js_1 = __importDefault(require("../commands/tunnel.js"));
12
+ const package_json_1 = __importDefault(require("../../package.json"));
12
13
  const handlers = new Map();
13
14
  handlers.set('browse', {
14
15
  handler: browse_js_1.default
@@ -51,6 +52,7 @@ handlers.set('demo', {
51
52
  });
52
53
  async function runCommand() {
53
54
  const command = process.argv[2];
55
+ await checkVersion();
54
56
  await showUsageIfNoCommand(command);
55
57
  const commandDetails = await getCommandDetails(command);
56
58
  if (commandDetails === undefined) {
@@ -83,3 +85,15 @@ async function runHandler(commandName, commandHandler) {
83
85
  process.exit(12);
84
86
  }
85
87
  }
88
+ async function checkVersion() {
89
+ try {
90
+ const { version: currentVersion } = package_json_1.default;
91
+ const { version: remoteVersion } = await fetch('https://registry.npmjs.org/@govuk-pay/cli/latest')
92
+ .then(async (r) => await r.json());
93
+ if (currentVersion !== remoteVersion) {
94
+ console.log(`You are running pay-cli version ${currentVersion}, the latest version is ${remoteVersion}.`);
95
+ console.log('Run `npm install -g @govuk-pay/cli` to upgrade.');
96
+ }
97
+ }
98
+ catch { }
99
+ }