@govuk-pay/cli 0.0.87 → 0.0.88
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
package/src/commands/update.js
CHANGED
|
@@ -13,7 +13,8 @@ async function updateHandler(_argv) {
|
|
|
13
13
|
console.error('Pay cli is already the latest version available in npm');
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
(
|
|
16
|
+
const remoteVersion = await (0, commandRouter_js_1.getRemoteVersion)();
|
|
17
|
+
console.log(`Running 'npm install -g @govuk-pay/cli@${remoteVersion}'`);
|
|
18
|
+
(0, node_child_process_1.spawnSync)('npm', ['install', '-g', `@govuk-pay/cli@${remoteVersion}`], { shell: true, stdio: 'inherit' });
|
|
18
19
|
}
|
|
19
20
|
exports.default = updateHandler;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isLatestVersion = void 0;
|
|
6
|
+
exports.isLatestVersion = exports.getRemoteVersion = void 0;
|
|
7
7
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
8
8
|
const semver_1 = __importDefault(require("semver"));
|
|
9
9
|
const yargs_1 = __importDefault(require("yargs/yargs"));
|
|
@@ -34,10 +34,15 @@ async function checkVersion() {
|
|
|
34
34
|
}
|
|
35
35
|
catch { }
|
|
36
36
|
}
|
|
37
|
+
async function getRemoteVersion() {
|
|
38
|
+
const { version } = await fetch('https://registry.npmjs.org/@govuk-pay/cli/latest')
|
|
39
|
+
.then(async (r) => await r.json());
|
|
40
|
+
return version;
|
|
41
|
+
}
|
|
42
|
+
exports.getRemoteVersion = getRemoteVersion;
|
|
37
43
|
async function isLatestVersion() {
|
|
38
44
|
const { version: currentVersion } = package_json_1.default;
|
|
39
|
-
const
|
|
40
|
-
.then(async (r) => await r.json());
|
|
45
|
+
const remoteVersion = await getRemoteVersion();
|
|
41
46
|
if (currentVersion !== remoteVersion) {
|
|
42
47
|
console.log(`You are running pay-cli version ${currentVersion}, the latest version is ${remoteVersion}.`);
|
|
43
48
|
return false;
|