@govuk-pay/cli 0.0.32 → 0.0.34
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 +3 -2
- package/resources/pay-local/templates/docker-compose.hbs +7 -4
- package/src/commands/browse.js +19 -70
- package/src/commands/browse.spec.js +15 -48
- package/src/commands/demo.js +8 -2
- package/src/commands/legacy.js +12 -16
- package/src/commands/local/config/pay_local_cluster.js +10 -7
- package/src/commands/local/subcommands/account.js +24 -23
- package/src/commands/local/subcommands/browse.js +28 -20
- package/src/commands/local/subcommands/db.js +28 -20
- package/src/commands/local/subcommands/down.js +26 -15
- package/src/commands/local/subcommands/nuke.js +11 -5
- package/src/commands/local/subcommands/otp.js +16 -14
- package/src/commands/local/subcommands/payment.js +25 -12
- package/src/commands/local/subcommands/paymentlink.js +20 -14
- package/src/commands/local/subcommands/restart.js +22 -19
- package/src/commands/local/subcommands/token.js +19 -21
- package/src/commands/local/subcommands/up.js +77 -19
- package/src/commands/local/subcommands/url.js +25 -20
- package/src/commands/local/subcommands/user.js +20 -9
- package/src/commands/local.js +9 -134
- package/src/commands/tunnel.js +17 -28
- package/src/core/commandRouter.js +11 -69
- package/src/core/standardContent.js +1 -5
- package/resources/usageDetails.txt +0 -9
- package/src/commands/help.js +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@govuk-pay/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"description": "GOV.UK Pay Command Line Interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"pay": "bin/cli.js",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"openurl": "^1.1.1",
|
|
23
23
|
"semver": "^7.6.3",
|
|
24
24
|
"totp-generator": "^1.0.0",
|
|
25
|
-
"yaml": "^2.5.1"
|
|
25
|
+
"yaml": "^2.5.1",
|
|
26
|
+
"yargs": "^17.7.2"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
29
|
"resources",
|
|
@@ -39,7 +39,7 @@ services:
|
|
|
39
39
|
condition: service_healthy
|
|
40
40
|
{{/if}}
|
|
41
41
|
healthcheck:
|
|
42
|
-
test: ["CMD", "wget", "-O", "/dev/null", "http://{{name}}:{{port}}/healthcheck"]
|
|
42
|
+
test: ["CMD", "wget", "-Y", "off", "-O", "/dev/null", "http://{{name}}:{{port}}/healthcheck"]
|
|
43
43
|
interval: 10s
|
|
44
44
|
timeout: 5s
|
|
45
45
|
retries: 12
|
|
@@ -82,7 +82,7 @@ services:
|
|
|
82
82
|
- HTTP_PROXY_PORT=8080
|
|
83
83
|
- HTTPS_PROXY_PORT=8080
|
|
84
84
|
- HTTP_PROXY_SCHEME=http
|
|
85
|
-
- NO_PROXY={{noProxyEnvVar}}
|
|
85
|
+
- NO_PROXY={{../noProxyEnvVar}}
|
|
86
86
|
{{/if}}
|
|
87
87
|
|
|
88
88
|
{{#if hasSQSQueues}}
|
|
@@ -134,7 +134,7 @@ services:
|
|
|
134
134
|
condition: service_healthy
|
|
135
135
|
{{/if}}
|
|
136
136
|
healthcheck:
|
|
137
|
-
test: ["CMD", "wget", "-O", "/dev/null", "http://{{name}}:{{port}}/healthcheck"]
|
|
137
|
+
test: ["CMD", "wget", "-Y", "off", "-O", "/dev/null", "http://{{name}}:{{port}}/healthcheck"]
|
|
138
138
|
interval: 10s
|
|
139
139
|
timeout: 5s
|
|
140
140
|
retries: 12
|
|
@@ -146,6 +146,9 @@ services:
|
|
|
146
146
|
{{#ifBoth ../mountLocalNodeApps localBuild}}
|
|
147
147
|
volumes:
|
|
148
148
|
- "$WORKSPACE/pay-{{../name}}:/app"
|
|
149
|
+
{{#if ../../mountPayJSCommons}}
|
|
150
|
+
- "$WORKSPACE/pay-js-commons:/pay-js-commons"
|
|
151
|
+
{{/if}}
|
|
149
152
|
{{/ifBoth}}
|
|
150
153
|
environment:
|
|
151
154
|
- BIND_HOST=0.0.0.0
|
|
@@ -222,7 +225,7 @@ services:
|
|
|
222
225
|
image: governmentdigitalservice/pay-egress:latest-master
|
|
223
226
|
container_name: egress
|
|
224
227
|
volumes:
|
|
225
|
-
- "{{defaultServiceConfigsPath}}/egress/squid.conf:/etc/squid/squid.conf"
|
|
228
|
+
- "{{defaultServiceConfigsPath}}/services/egress/squid.conf:/etc/squid/squid.conf"
|
|
226
229
|
networks:
|
|
227
230
|
pay_local_mimic_aws_vpc:
|
|
228
231
|
ipv4_address: 172.18.0.253
|
package/src/commands/browse.js
CHANGED
|
@@ -1,33 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const path = __importStar(require("path"));
|
|
3
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
28
4
|
const standardContent_js_1 = require("../core/standardContent.js");
|
|
29
5
|
const moduleFunctionWrapper_js_1 = require("../util/moduleFunctionWrapper.js");
|
|
30
|
-
const constants_1 = require("../core/constants");
|
|
31
6
|
const requestableItems = new Map();
|
|
32
7
|
requestableItems.set('concourse', {
|
|
33
8
|
name: 'concourse page',
|
|
@@ -45,51 +20,25 @@ requestableItems.set('status', {
|
|
|
45
20
|
name: 'status page',
|
|
46
21
|
url: 'https://payments.statuspage.io/'
|
|
47
22
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
exports.
|
|
57
|
-
function
|
|
58
|
-
console.
|
|
59
|
-
console.log(`The available options are: "${Array.from(requestableItems.keys()).join('", "')}".`);
|
|
60
|
-
}
|
|
61
|
-
async function browseHandler(options) {
|
|
23
|
+
exports.command = 'browse <location>';
|
|
24
|
+
exports.desc = 'Open a web browser to useful locations';
|
|
25
|
+
const builder = (yargs) => {
|
|
26
|
+
return yargs.positional('location', {
|
|
27
|
+
choices: [...requestableItems.keys()]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.builder = builder;
|
|
31
|
+
exports.handler = browseHandler;
|
|
32
|
+
async function browseHandler(argv) {
|
|
33
|
+
console.log(argv);
|
|
62
34
|
await (0, standardContent_js_1.showHeader)();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (argumentName === undefined || argumentName.trim() === '') {
|
|
70
|
-
logBrowseCommands();
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const requestedItem = requestableItems.get(argumentName);
|
|
74
|
-
if (requestedItem != null) {
|
|
75
|
-
console.log('Usage:');
|
|
76
|
-
console.log(` npx --package=${path.resolve(constants_1.rootDir)} browse ${argumentName}`);
|
|
77
|
-
console.log(`browses the ${requestedItem.name}`);
|
|
78
|
-
return;
|
|
35
|
+
const location = argv.location;
|
|
36
|
+
const requestedItem = requestableItems.get(location);
|
|
37
|
+
console.log(`Opening the ${requestedItem.name}`);
|
|
38
|
+
moduleFunctionWrapper_js_1.moduleFunctionWrapper.open(requestedItem.url, (err) => {
|
|
39
|
+
if (err != null) {
|
|
40
|
+
console.log(`Failed to open browser, please visit ${requestedItem.url}`);
|
|
79
41
|
}
|
|
80
|
-
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const requestedItem = requestableItems.get(options.arguments[0]);
|
|
84
|
-
if (requestedItem != null) {
|
|
85
|
-
console.log(`Opening the ${requestedItem.name}`);
|
|
86
|
-
moduleFunctionWrapper_js_1.moduleFunctionWrapper.open(requestedItem.url, (err) => {
|
|
87
|
-
if (err != null) {
|
|
88
|
-
console.log(`Failed to open browser, please visit ${requestedItem.url}`);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
logNoCommand(options.arguments[0]);
|
|
42
|
+
});
|
|
94
43
|
}
|
|
95
44
|
exports.default = browseHandler;
|
|
@@ -5,77 +5,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
// import * as open from 'open'
|
|
7
7
|
const globals_1 = require("@jest/globals");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const commandsText = `Commands:
|
|
11
|
-
pay browse concourse # browses the concourse page
|
|
12
|
-
pay browse help [COMMAND] # Describe subcommands or one specific subcommand
|
|
13
|
-
pay browse manual # browses the pay team manual
|
|
14
|
-
pay browse repo # browses the pay-infra github repo
|
|
15
|
-
pay browse status # browses the pay status page`;
|
|
8
|
+
const moduleFunctionWrapper_1 = require("../util/moduleFunctionWrapper");
|
|
9
|
+
const browse_1 = __importDefault(require("./browse"));
|
|
16
10
|
(0, globals_1.describe)('browse command', () => {
|
|
17
11
|
(0, globals_1.beforeEach)(() => {
|
|
18
12
|
globals_1.jest.spyOn(console, 'log').mockImplementation(() => { });
|
|
19
13
|
globals_1.jest.spyOn(console, 'error').mockImplementation(() => { });
|
|
20
|
-
globals_1.jest.spyOn(
|
|
14
|
+
globals_1.jest.spyOn(moduleFunctionWrapper_1.moduleFunctionWrapper, 'open').mockImplementation(() => { });
|
|
21
15
|
});
|
|
22
16
|
(0, globals_1.afterEach)(() => {
|
|
23
17
|
globals_1.jest.restoreAllMocks();
|
|
24
18
|
globals_1.jest.resetModules();
|
|
25
19
|
});
|
|
26
|
-
(0, globals_1.it)('should show usage when no additional params are provided', async () => {
|
|
27
|
-
await (0, browse_js_1.default)({ commandName: 'browse', arguments: [] });
|
|
28
|
-
(0, globals_1.expect)(console.log).toHaveBeenCalledWith(commandsText);
|
|
29
|
-
});
|
|
30
20
|
(0, globals_1.it)('should open the browser when manual is provided as the first param', async () => {
|
|
31
|
-
|
|
32
|
-
(0,
|
|
21
|
+
const argv = { _: ['browse'], $0: 'pay', location: 'manual' };
|
|
22
|
+
await (0, browse_1.default)(argv);
|
|
23
|
+
(0, globals_1.expect)(moduleFunctionWrapper_1.moduleFunctionWrapper.open).toHaveBeenCalledWith('https://manual.payments.service.gov.uk/', globals_1.expect.any(Function));
|
|
33
24
|
(0, globals_1.expect)(console.log).toHaveBeenCalledWith('Opening the team manual');
|
|
34
25
|
(0, globals_1.expect)(console.error).not.toHaveBeenCalled();
|
|
35
26
|
});
|
|
36
27
|
(0, globals_1.it)('should open the browser when concourse is provided as the first param', async () => {
|
|
37
|
-
|
|
38
|
-
(0,
|
|
28
|
+
const argv = { _: ['browse'], $0: 'pay', location: 'concourse' };
|
|
29
|
+
await (0, browse_1.default)(argv);
|
|
30
|
+
(0, globals_1.expect)(moduleFunctionWrapper_1.moduleFunctionWrapper.open).toHaveBeenCalledWith('https://pay-cd.deploy.payments.service.gov.uk/', globals_1.expect.any(Function));
|
|
39
31
|
(0, globals_1.expect)(console.log).toHaveBeenCalledWith('Opening the concourse page');
|
|
40
32
|
(0, globals_1.expect)(console.error).not.toHaveBeenCalled();
|
|
41
33
|
});
|
|
42
34
|
(0, globals_1.it)('should open the browser when repo is provided as the first param', async () => {
|
|
43
|
-
|
|
44
|
-
(0,
|
|
35
|
+
const argv = { _: ['browse'], $0: 'pay', location: 'repo' };
|
|
36
|
+
await (0, browse_1.default)(argv);
|
|
37
|
+
(0, globals_1.expect)(moduleFunctionWrapper_1.moduleFunctionWrapper.open).toHaveBeenCalledWith('https://github.com/alphagov/pay-infra', globals_1.expect.any(Function));
|
|
45
38
|
(0, globals_1.expect)(console.log).toHaveBeenCalledWith('Opening the pay-infra github repository');
|
|
46
39
|
(0, globals_1.expect)(console.error).not.toHaveBeenCalled();
|
|
47
40
|
});
|
|
48
41
|
(0, globals_1.it)('should open the browser when status is provided as the first param', async () => {
|
|
49
|
-
|
|
50
|
-
(0,
|
|
42
|
+
const argv = { _: ['browse'], $0: 'pay', location: 'status' };
|
|
43
|
+
await (0, browse_1.default)(argv);
|
|
44
|
+
(0, globals_1.expect)(moduleFunctionWrapper_1.moduleFunctionWrapper.open).toHaveBeenCalledWith('https://payments.statuspage.io/', globals_1.expect.any(Function));
|
|
51
45
|
(0, globals_1.expect)(console.log).toHaveBeenCalledWith('Opening the status page');
|
|
52
46
|
(0, globals_1.expect)(console.error).not.toHaveBeenCalled();
|
|
53
47
|
});
|
|
54
|
-
(0, globals_1.it)('should show the help page when requested', async () => {
|
|
55
|
-
await (0, browse_js_1.default)({ commandName: 'browse', arguments: ['help'] });
|
|
56
|
-
(0, globals_1.expect)(moduleFunctionWrapper_js_1.moduleFunctionWrapper.open).not.toHaveBeenCalled();
|
|
57
|
-
(0, globals_1.expect)(console.log).toHaveBeenCalledWith(`Commands:
|
|
58
|
-
pay browse concourse # browses the concourse page
|
|
59
|
-
pay browse help [COMMAND] # Describe subcommands or one specific subcommand
|
|
60
|
-
pay browse manual # browses the pay team manual
|
|
61
|
-
pay browse repo # browses the pay-infra github repo
|
|
62
|
-
pay browse status # browses the pay status page`);
|
|
63
|
-
});
|
|
64
|
-
(0, globals_1.it)('should details about a command', async () => {
|
|
65
|
-
await (0, browse_js_1.default)({ commandName: 'browse', arguments: ['help', 'manual'] });
|
|
66
|
-
(0, globals_1.expect)(moduleFunctionWrapper_js_1.moduleFunctionWrapper.open).not.toHaveBeenCalled();
|
|
67
|
-
(0, globals_1.expect)(console.log).toHaveBeenCalledWith('Usage:');
|
|
68
|
-
(0, globals_1.expect)(console.log).toHaveBeenCalledWith('browses the team manual');
|
|
69
|
-
});
|
|
70
|
-
(0, globals_1.it)('should handle an unknown command', async () => {
|
|
71
|
-
await (0, browse_js_1.default)({ commandName: 'browse', arguments: ['abcdef'] });
|
|
72
|
-
(0, globals_1.expect)(moduleFunctionWrapper_js_1.moduleFunctionWrapper.open).not.toHaveBeenCalled();
|
|
73
|
-
(0, globals_1.expect)(console.error).toHaveBeenCalledWith('Could not find command "abcdef".');
|
|
74
|
-
(0, globals_1.expect)(console.log).toHaveBeenCalledWith('The available options are: "concourse", "manual", "repo", "status".');
|
|
75
|
-
});
|
|
76
|
-
(0, globals_1.it)('should handle an unknown command within help', async () => {
|
|
77
|
-
await (0, browse_js_1.default)({ commandName: 'browse', arguments: ['help', 'abcdef'] });
|
|
78
|
-
(0, globals_1.expect)(moduleFunctionWrapper_js_1.moduleFunctionWrapper.open).not.toHaveBeenCalled();
|
|
79
|
-
(0, globals_1.expect)(console.error).toHaveBeenCalledWith('Could not find command "abcdef".');
|
|
80
|
-
});
|
|
81
48
|
});
|
package/src/commands/demo.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
|
+
const standardContent_1 = require("../core/standardContent");
|
|
5
|
+
exports.command = 'demo';
|
|
6
|
+
exports.desc = false; // Hide command from generated help
|
|
7
|
+
exports.builder = {};
|
|
8
|
+
exports.handler = demoHandler;
|
|
9
|
+
async function demoHandler(argv) {
|
|
10
|
+
await (0, standardContent_1.showHeader)();
|
|
4
11
|
console.log('This is where you would put your implementation.');
|
|
5
12
|
await new Promise((resolve) => {
|
|
6
13
|
setTimeout(resolve, 10);
|
|
@@ -8,4 +15,3 @@ async function demoHandler(options) {
|
|
|
8
15
|
console.log('It can be asynchronous.');
|
|
9
16
|
console.error('You can also write to stderr.');
|
|
10
17
|
}
|
|
11
|
-
exports.default = demoHandler;
|
package/src/commands/legacy.js
CHANGED
|
@@ -23,25 +23,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.proxyArrayOfArgumentsToLegacyCli = exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
27
27
|
const payCliExec_1 = __importStar(require("../util/payCliExec"));
|
|
28
28
|
const path = __importStar(require("node:path"));
|
|
29
29
|
const constants_1 = require("../core/constants");
|
|
30
|
-
const standardContent_1 = require("../core/standardContent");
|
|
31
30
|
const pathToLegacyRubyCli = path.join(constants_1.rootDir, 'resources', 'legacy-ruby-cli');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
exports.command = 'legacy';
|
|
32
|
+
exports.desc = 'Pass through to legacy ruby cli';
|
|
33
|
+
const commandDesc = '$0 legacy -- {ruby version command and options}';
|
|
34
|
+
const longDesc = 'Use the legacy ruby version of the pay cli, passing through commands, options etc. The legacy command itself should be followed by `--` then the command from the ruby version followed by it\'s parameters and options. e.g. use `pay legacy -- help` to run help on the legacy version.';
|
|
35
|
+
const builder = (yargs) => {
|
|
36
|
+
return yargs.usage(`${commandDesc}\n\n${longDesc}`);
|
|
37
|
+
};
|
|
38
|
+
exports.builder = builder;
|
|
39
|
+
exports.handler = legacyHandler;
|
|
40
|
+
async function legacyHandler(argv) {
|
|
41
|
+
const argsToPassOn = argv._.slice(1);
|
|
40
42
|
await proxyArrayOfArgumentsToLegacyCli(argsToPassOn);
|
|
41
43
|
}
|
|
42
|
-
exports.default = legacyHandler;
|
|
43
44
|
async function proxyArrayOfArgumentsToLegacyCli(argsToPassOn) {
|
|
44
|
-
await (0, standardContent_1.showHeader)();
|
|
45
45
|
const rbenvCommand = process.env.PAY_CLI_RBENV_COMMAND ?? 'rbenv';
|
|
46
46
|
const shellCommand = process.env.PAY_CLI_SHELL_COMMAND ?? 'zsh';
|
|
47
47
|
const whichRbenvResult = await (0, payCliExec_1.execAndReturnIO)(`which ${rbenvCommand}`);
|
|
@@ -67,7 +67,3 @@ async function proxyArrayOfArgumentsToLegacyCli(argsToPassOn) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
exports.proxyArrayOfArgumentsToLegacyCli = proxyArrayOfArgumentsToLegacyCli;
|
|
70
|
-
async function proxyHandlerOptionsToLegacyCli(options) {
|
|
71
|
-
await proxyArrayOfArgumentsToLegacyCli([options.commandName].concat(options.arguments));
|
|
72
|
-
}
|
|
73
|
-
exports.proxyHandlerOptionsToLegacyCli = proxyHandlerOptionsToLegacyCli;
|
|
@@ -3,18 +3,18 @@ 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.loadServicesConfig = exports.loadClusterConfig = exports.PayLocalCluster = void 0;
|
|
6
|
+
exports.loadServicesConfig = exports.loadClusterConfig = exports.PayLocalCluster = exports.CLUSTERS = void 0;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const yaml_1 = __importDefault(require("yaml"));
|
|
10
10
|
const md5_js_1 = require("../../../util/md5.js");
|
|
11
|
+
exports.CLUSTERS = ['all', 'admin', 'card', 'paymentlinks', 'webhooks', 'endtoend', 'java', 'toolbox'];
|
|
11
12
|
// This is the complete cluster configuration that will be used as the context for template rendering
|
|
12
13
|
class PayLocalCluster {
|
|
13
14
|
name;
|
|
14
15
|
payServices;
|
|
15
16
|
dbServices;
|
|
16
17
|
reverseProxyServices;
|
|
17
|
-
egressProxy;
|
|
18
18
|
javaApps;
|
|
19
19
|
nodeApps;
|
|
20
20
|
localJavaApps;
|
|
@@ -29,6 +29,7 @@ class PayLocalCluster {
|
|
|
29
29
|
requiresEgressProxy;
|
|
30
30
|
serviceURLEnvVars;
|
|
31
31
|
mountLocalNodeApps;
|
|
32
|
+
mountPayJSCommons;
|
|
32
33
|
noProxyEnvVar;
|
|
33
34
|
defaultServiceConfigsPath;
|
|
34
35
|
environmentOverridesPath;
|
|
@@ -38,7 +39,6 @@ class PayLocalCluster {
|
|
|
38
39
|
this.payServices = clusterConfig.payServices;
|
|
39
40
|
this.dbServices = clusterConfig.dbServices;
|
|
40
41
|
this.reverseProxyServices = clusterConfig.reverseProxyServices;
|
|
41
|
-
this.egressProxy = clusterConfig.egressProxy;
|
|
42
42
|
this.javaApps = this.payServices.filter((service) => service.serviceType === PayServiceType.Java);
|
|
43
43
|
this.nodeApps = this.payServices.filter((service) => service.serviceType === PayServiceType.Node);
|
|
44
44
|
this.remoteJavaApps = this.javaApps.filter((service) => service.localBuild);
|
|
@@ -49,8 +49,9 @@ class PayLocalCluster {
|
|
|
49
49
|
this.anyNodeApps = this.nodeApps.length >= 0;
|
|
50
50
|
this.requiresLocalStack = this.payServices.some((service) => service.requiresLocalStack);
|
|
51
51
|
this.requiresRedis = this.payServices.some((service) => service.usesRedis);
|
|
52
|
-
this.requiresEgressProxy =
|
|
52
|
+
this.requiresEgressProxy = clusterConfig.egressProxy;
|
|
53
53
|
this.mountLocalNodeApps = clusterConfig.mountLocalNodeApps;
|
|
54
|
+
this.mountPayJSCommons = clusterConfig.mountPayJSCommons;
|
|
54
55
|
this.serviceURLEnvVars = [
|
|
55
56
|
this.javaApps.map((javaService) => envVarForJavaService(javaService)),
|
|
56
57
|
this.nodeApps.map((nodeService) => envVarForNodeService(nodeService))
|
|
@@ -64,7 +65,7 @@ class PayLocalCluster {
|
|
|
64
65
|
this.payServices.map((service) => service.name),
|
|
65
66
|
this.dbServices.map((service) => service.name),
|
|
66
67
|
this.reverseProxyServices.map((service) => service.name),
|
|
67
|
-
this.
|
|
68
|
+
this.requiresEgressProxy ? [] : ['egress']
|
|
68
69
|
].flat().join(',');
|
|
69
70
|
this.environmentOverridesPath = clusterConfig.environmentOverridesPath;
|
|
70
71
|
this.defaultServiceConfigsPath = clusterConfig.defaultServiceConfigsPath;
|
|
@@ -114,9 +115,11 @@ function loadClusterConfig(options, workspace, defaultServiceConfigsPath, enviro
|
|
|
114
115
|
name: options.cluster,
|
|
115
116
|
payServices,
|
|
116
117
|
dbServices,
|
|
118
|
+
egressProxy: options.withEgressProxy,
|
|
117
119
|
reverseProxyServices,
|
|
118
120
|
workspace,
|
|
119
|
-
mountLocalNodeApps: options.
|
|
121
|
+
mountLocalNodeApps: options.mountLocalNodeApps,
|
|
122
|
+
mountPayJSCommons: options.mountPayJSCommons,
|
|
120
123
|
defaultServiceConfigsPath,
|
|
121
124
|
environmentOverridesPath
|
|
122
125
|
};
|
|
@@ -170,7 +173,7 @@ function payServiceFromPayServiceConfig(config, upOptions, environmentOverridesP
|
|
|
170
173
|
hasSNSTopics: snsTopics.length > 0,
|
|
171
174
|
hasProxy: config.proxy === undefined ? false : config.proxy,
|
|
172
175
|
hasDB: config.db,
|
|
173
|
-
useEgressProxy: config.can_use_egress_proxy === undefined ? false : config.can_use_egress_proxy && upOptions.
|
|
176
|
+
useEgressProxy: config.can_use_egress_proxy === undefined ? false : config.can_use_egress_proxy && upOptions.withEgressProxy,
|
|
174
177
|
dependsOn: config.db ? [`${config.name}_db`] : [],
|
|
175
178
|
expose: [],
|
|
176
179
|
payServiceConfig: config,
|
|
@@ -3,9 +3,23 @@ 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.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
6
7
|
const app_client_js_1 = __importDefault(require("../app_client/app_client.js"));
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const standardContent_1 = require("../../../core/standardContent");
|
|
9
|
+
exports.command = 'account';
|
|
10
|
+
exports.desc = 'Create a local gateway account';
|
|
11
|
+
const builder = (yargs) => {
|
|
12
|
+
return yargs.usage(`$0 local account [--service-id <SERVICE_ID>]\n\n${exports.desc}`)
|
|
13
|
+
.option('service-id', {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'ID of an existing service'
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.builder = builder;
|
|
19
|
+
exports.handler = accountHandler;
|
|
20
|
+
async function accountHandler(argv) {
|
|
21
|
+
await (0, standardContent_1.showHeader)();
|
|
22
|
+
const serviceId = argv.serviceId;
|
|
9
23
|
if (await app_client_js_1.default.isUnhealthy('adminusers')) {
|
|
10
24
|
console.error('The adminusers service is unhealthy, so an account cannot be created');
|
|
11
25
|
return;
|
|
@@ -14,38 +28,25 @@ async function AccountHandler(options) {
|
|
|
14
28
|
console.error('The connector service is unhealthy, so an account cannot be created');
|
|
15
29
|
return;
|
|
16
30
|
}
|
|
17
|
-
let
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
if (
|
|
31
|
+
let serviceExternalId;
|
|
32
|
+
if (serviceId === undefined) {
|
|
33
|
+
serviceExternalId = await app_client_js_1.default.createService();
|
|
34
|
+
if (serviceExternalId === undefined) {
|
|
21
35
|
console.error('Service creation failed');
|
|
22
36
|
return;
|
|
23
37
|
}
|
|
24
38
|
}
|
|
25
39
|
else {
|
|
26
|
-
|
|
40
|
+
serviceExternalId = serviceId;
|
|
27
41
|
}
|
|
28
|
-
if (
|
|
42
|
+
if (serviceExternalId === undefined) {
|
|
29
43
|
throw new Error('Service external ID is undefined, this should be impossible');
|
|
30
44
|
}
|
|
31
|
-
const account = await app_client_js_1.default.createAccountInServiceWithEmailCollectionMode(
|
|
45
|
+
const account = await app_client_js_1.default.createAccountInServiceWithEmailCollectionMode(serviceExternalId, 'MANDATORY');
|
|
32
46
|
if (account === undefined) {
|
|
33
47
|
console.error('Failed to create a fully set up account');
|
|
34
48
|
return;
|
|
35
49
|
}
|
|
36
50
|
console.log(account);
|
|
37
51
|
}
|
|
38
|
-
exports.default =
|
|
39
|
-
function parseArguments(options) {
|
|
40
|
-
if (options.length === 0) {
|
|
41
|
-
return {};
|
|
42
|
-
}
|
|
43
|
-
if (options.length > 1) {
|
|
44
|
-
help();
|
|
45
|
-
throw new Error('Too many arguments');
|
|
46
|
-
}
|
|
47
|
-
return { serviceID: options[0] };
|
|
48
|
-
}
|
|
49
|
-
function help() {
|
|
50
|
-
console.log('Usage: pay local account [service_id]>');
|
|
51
|
-
}
|
|
52
|
+
exports.default = accountHandler;
|
|
@@ -3,18 +3,39 @@ 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.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
6
7
|
const node_child_process_1 = require("node:child_process");
|
|
7
8
|
const app_client_js_1 = __importDefault(require("../app_client/app_client.js"));
|
|
8
9
|
const pay_local_cluster_js_1 = require("../config/pay_local_cluster.js");
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const standardContent_1 = require("../../../core/standardContent");
|
|
11
|
+
exports.command = 'browse <service>';
|
|
12
|
+
exports.desc = 'Browse to local service';
|
|
13
|
+
const builder = (yargs) => {
|
|
14
|
+
return yargs
|
|
15
|
+
.usage(`$0 local browse <service> [--proxy]\n\n${exports.desc}`)
|
|
16
|
+
.positional('service', {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'service'
|
|
19
|
+
})
|
|
20
|
+
.option('proxy', {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
default: false,
|
|
23
|
+
description: 'Opens the service via the local proxy for the service'
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.builder = builder;
|
|
27
|
+
exports.handler = browseHandler;
|
|
28
|
+
async function browseHandler(argv) {
|
|
29
|
+
await (0, standardContent_1.showHeader)();
|
|
30
|
+
const service = argv.service;
|
|
31
|
+
const proxy = argv.proxy;
|
|
11
32
|
const servicesConfig = (0, pay_local_cluster_js_1.loadServicesConfig)();
|
|
12
|
-
if (!(
|
|
13
|
-
console.error(`The service specified (${
|
|
33
|
+
if (!(service in servicesConfig)) {
|
|
34
|
+
console.error(`The service specified (${service}) was not defined in the service_config.yaml file`);
|
|
14
35
|
return;
|
|
15
36
|
}
|
|
16
|
-
const serviceConfig = servicesConfig[
|
|
17
|
-
const url = app_client_js_1.default.externalUrlFor(
|
|
37
|
+
const serviceConfig = servicesConfig[service];
|
|
38
|
+
const url = app_client_js_1.default.externalUrlFor(service, '/', proxy);
|
|
18
39
|
(0, node_child_process_1.spawn)('open', [url]);
|
|
19
40
|
if (await app_client_js_1.default.isHealthy(serviceConfig.name)) {
|
|
20
41
|
console.log(`📋 “${url}” opened`);
|
|
@@ -23,17 +44,4 @@ async function BrowseHandler(options) {
|
|
|
23
44
|
console.error(`❌ “${url}” opened, however the app did not respond successfully to ${url}/healthcheck`);
|
|
24
45
|
}
|
|
25
46
|
}
|
|
26
|
-
exports.default =
|
|
27
|
-
function help() {
|
|
28
|
-
console.log('Usage: pay local browse <service>');
|
|
29
|
-
}
|
|
30
|
-
function parseArguments(options) {
|
|
31
|
-
if (options.length !== 1) {
|
|
32
|
-
help();
|
|
33
|
-
throw new Error('No service specified');
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
service: options[0],
|
|
37
|
-
proxy: true
|
|
38
|
-
};
|
|
39
|
-
}
|
|
47
|
+
exports.default = browseHandler;
|
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
3
4
|
const node_child_process_1 = require("node:child_process");
|
|
4
5
|
const pay_local_cluster_js_1 = require("../config/pay_local_cluster.js");
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const standardContent_1 = require("../../../core/standardContent");
|
|
7
|
+
exports.command = 'db <app_name>';
|
|
8
|
+
exports.desc = 'Connect to <app_name> database';
|
|
9
|
+
const builder = (yargs) => {
|
|
10
|
+
return yargs
|
|
11
|
+
.usage(`$0 local db <app_name> [--docker]\n\n${exports.desc}`)
|
|
12
|
+
.positional('app_name', {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'service'
|
|
15
|
+
})
|
|
16
|
+
.option('docker', {
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
default: false,
|
|
19
|
+
description: 'Launch psql inside the apps database container (no psql history)'
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.builder = builder;
|
|
23
|
+
exports.handler = dbHandler;
|
|
24
|
+
async function dbHandler(argv) {
|
|
25
|
+
await (0, standardContent_1.showHeader)();
|
|
26
|
+
const service = argv.app_name;
|
|
27
|
+
const docker = argv.docker;
|
|
7
28
|
const servicesConfig = (0, pay_local_cluster_js_1.loadServicesConfig)();
|
|
8
|
-
if (!(
|
|
9
|
-
console.error(`The service specified (${
|
|
29
|
+
if (!(service in servicesConfig)) {
|
|
30
|
+
console.error(`The service specified (${service}) was not defined in the service_config.yaml file`);
|
|
10
31
|
return;
|
|
11
32
|
}
|
|
12
|
-
const serviceConfig = servicesConfig[
|
|
33
|
+
const serviceConfig = servicesConfig[service];
|
|
13
34
|
if (!serviceConfig.db) {
|
|
14
35
|
console.error(`The service specified (${serviceConfig.name}) does not have a database`);
|
|
15
36
|
return;
|
|
16
37
|
}
|
|
17
|
-
if (
|
|
38
|
+
if (docker) {
|
|
18
39
|
launchPsqlInDocker(serviceConfig);
|
|
19
40
|
}
|
|
20
41
|
else if (!psqlAvailable()) {
|
|
@@ -25,7 +46,7 @@ async function DBHandler(options) {
|
|
|
25
46
|
launchPsql(serviceConfig);
|
|
26
47
|
}
|
|
27
48
|
}
|
|
28
|
-
exports.default =
|
|
49
|
+
exports.default = dbHandler;
|
|
29
50
|
function psqlAvailable() {
|
|
30
51
|
const psqlCheck = (0, node_child_process_1.spawnSync)('command', ['-v', 'psql'], { shell: true });
|
|
31
52
|
if (psqlCheck.status === 0) {
|
|
@@ -67,16 +88,3 @@ function launchPsql(serviceConfig) {
|
|
|
67
88
|
}
|
|
68
89
|
});
|
|
69
90
|
}
|
|
70
|
-
function help() {
|
|
71
|
-
console.log('Usage: pay local db <service> [--docker]');
|
|
72
|
-
}
|
|
73
|
-
function parseArguments(options) {
|
|
74
|
-
if (options.length !== 1) {
|
|
75
|
-
help();
|
|
76
|
-
throw new Error('No service specified');
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
service: options[0],
|
|
80
|
-
docker: false
|
|
81
|
-
};
|
|
82
|
-
}
|