@govuk-pay/cli 0.0.19 → 0.0.21
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 +5 -1
- package/readme.md +15 -0
- package/src/core/commandRouter.js +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@govuk-pay/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "GOV.UK Pay Command Line Interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"pay": "bin/cli.js",
|
|
@@ -10,12 +10,16 @@
|
|
|
10
10
|
"keywords": [],
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "MIT",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">= 18.x"
|
|
15
|
+
},
|
|
13
16
|
"dependencies": {
|
|
14
17
|
"@aws-sdk/client-ec2": "^3.641.0",
|
|
15
18
|
"@aws-sdk/client-ecs": "^3.637.0",
|
|
16
19
|
"@aws-sdk/client-rds": "^3.637.0",
|
|
17
20
|
"@aws-sdk/client-ssm": "^3.651.1",
|
|
18
21
|
"openurl": "^1.1.1",
|
|
22
|
+
"semver": "^7.6.3",
|
|
19
23
|
"ts-standard": "^12.0.2"
|
|
20
24
|
},
|
|
21
25
|
"files": [
|
package/readme.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# pay-cli
|
|
2
2
|
GOV.UK Pay Command Line Interface
|
|
3
3
|
|
|
4
|
+
## Installation and migration guide
|
|
5
|
+
|
|
6
|
+
If you have used the Ruby CLI in the past, there are some additional steps required:
|
|
7
|
+
|
|
8
|
+
- Remove references to `pay` from your `.bashrc` (or other autostart shell script, `.bash_profile`, `.zshrc`, `.zprofile`, etc).
|
|
9
|
+
- Check `which pay`, if it points to `~/.rbenv/shims/pay` or similar, remove that script. Ideally, it should return `pay not found`.
|
|
10
|
+
- Restart your shell to clear functions and environment variables leftover.
|
|
11
|
+
|
|
12
|
+
To install the Node.js CLI:
|
|
13
|
+
|
|
14
|
+
- Run `npm install -g @govuk-pay/cli`. If npm was installed through Homebrew, you shouldn't need to use sudo to install packages.
|
|
15
|
+
- Run `pay` to see if you are running the new version (new features such as `pay tunnel` should be available), if not check `which pay` in case you are using an older version.
|
|
16
|
+
|
|
17
|
+
There is nothing more to do, you're done! To update, run `npm install -g @govuk-pay/cli` again, there are version check notifications if you are behind a version.
|
|
18
|
+
|
|
4
19
|
## Usage
|
|
5
20
|
|
|
6
21
|
This is published to NPM, you can install it globally using `npm install -g @govuk-pay/cli`,
|
|
@@ -9,6 +9,8 @@ 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"));
|
|
13
|
+
const semver_1 = __importDefault(require("semver"));
|
|
12
14
|
const handlers = new Map();
|
|
13
15
|
handlers.set('browse', {
|
|
14
16
|
handler: browse_js_1.default
|
|
@@ -51,6 +53,7 @@ handlers.set('demo', {
|
|
|
51
53
|
});
|
|
52
54
|
async function runCommand() {
|
|
53
55
|
const command = process.argv[2];
|
|
56
|
+
await checkVersion();
|
|
54
57
|
await showUsageIfNoCommand(command);
|
|
55
58
|
const commandDetails = await getCommandDetails(command);
|
|
56
59
|
if (commandDetails === undefined) {
|
|
@@ -83,3 +86,18 @@ async function runHandler(commandName, commandHandler) {
|
|
|
83
86
|
process.exit(12);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
89
|
+
async function checkVersion() {
|
|
90
|
+
try {
|
|
91
|
+
const { version: currentVersion, engines: { node: requiredNodeVersion } } = package_json_1.default;
|
|
92
|
+
if (!semver_1.default.satisfies(process.version, requiredNodeVersion)) {
|
|
93
|
+
console.log(`Required Node.js version is ${requiredNodeVersion}, you are running ${process.version}. Please upgrade before continuing.`);
|
|
94
|
+
}
|
|
95
|
+
const { version: remoteVersion } = await fetch('https://registry.npmjs.org/@govuk-pay/cli/latest')
|
|
96
|
+
.then(async (r) => await r.json());
|
|
97
|
+
if (currentVersion !== remoteVersion) {
|
|
98
|
+
console.log(`You are running pay-cli version ${currentVersion}, the latest version is ${remoteVersion}.`);
|
|
99
|
+
console.log('Run `npm install -g @govuk-pay/cli` to upgrade.');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch { }
|
|
103
|
+
}
|