@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.
@@ -3,34 +3,50 @@ 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.composeFileToDown = exports.ENVIRONMENT_OVERRIDES_PATH = exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = void 0;
6
+ exports.composeFileToDown = exports.handler = exports.builder = exports.desc = exports.command = exports.ENVIRONMENT_OVERRIDES_PATH = exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const node_fs_1 = __importDefault(require("node:fs"));
9
9
  const configs_js_1 = require("../../../util/configs.js");
10
10
  const last_up_record_js_1 = require("../config/last_up_record.js");
11
11
  const docker_compose_controller_js_1 = __importDefault(require("../docker_compose_controller.js"));
12
+ const pay_local_cluster_js_1 = require("../config/pay_local_cluster.js");
13
+ const standardContent_1 = require("../../../core/standardContent");
12
14
  exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = node_path_1.default.join('local', 'docker-compose', 'rendered-templates');
13
15
  exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = node_path_1.default.join('local', 'docker-compose', 'default-configs-DO-NOT-EDIT');
14
16
  exports.ENVIRONMENT_OVERRIDES_PATH = node_path_1.default.join('local', 'environment-overrides');
15
- async function DownHandler(options) {
17
+ exports.command = 'down';
18
+ exports.desc = 'Bring down a cluster';
19
+ const builder = (yargs) => {
20
+ return yargs
21
+ .usage(`$0 local down [--cluster <cluster>]\n\n${exports.desc}`)
22
+ .option('cluster', {
23
+ type: 'string',
24
+ description: 'Cluster to bring down',
25
+ choices: pay_local_cluster_js_1.CLUSTERS
26
+ });
27
+ };
28
+ exports.builder = builder;
29
+ exports.handler = downHandler;
30
+ async function downHandler(argv) {
31
+ await (0, standardContent_1.showHeader)();
32
+ const { cluster } = argv;
16
33
  const renderedTempaltesPath = (0, configs_js_1.ensureConfigDirectory)(exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH);
17
- const args = parseArguments(options);
18
- const composeFilePath = composeFileToDown(args, renderedTempaltesPath);
34
+ const composeFilePath = composeFileToDown(cluster, renderedTempaltesPath);
19
35
  const composeFileName = node_path_1.default.basename(composeFilePath);
20
36
  const clusterToDown = composeFileName.substring(0, composeFileName.lastIndexOf('.yaml'));
21
37
  console.log(`Bringing down cluster ${clusterToDown}`);
22
38
  docker_compose_controller_js_1.default.down(composeFilePath);
23
39
  }
24
- exports.default = DownHandler;
25
- function composeFileToDown(downOptions, renderedTemplatesPath) {
26
- if (downOptions.cluster !== undefined) {
27
- const clusterFilePath = node_path_1.default.resolve(renderedTemplatesPath, `${downOptions.cluster}.yaml`);
40
+ exports.default = downHandler;
41
+ function composeFileToDown(cluster, renderedTemplatesPath) {
42
+ if (cluster !== undefined) {
43
+ const clusterFilePath = node_path_1.default.resolve(renderedTemplatesPath, `${cluster}.yaml`);
28
44
  if (node_fs_1.default.existsSync(clusterFilePath)) {
29
45
  return clusterFilePath;
30
46
  }
31
- throw new Error(`Cannot bring down cluster '${downOptions.cluster}' since it does not have a rendered docker-compose template in ${renderedTemplatesPath}.\n` +
47
+ throw new Error(`Cannot bring down cluster '${cluster}' since it does not have a rendered docker-compose template in ${renderedTemplatesPath}.\n` +
32
48
  '\n' +
33
- `Perhaps you don't have a cluster running, or the cluster that is running isn't ${downOptions.cluster}\n`);
49
+ `Perhaps you don't have a cluster running, or the cluster that is running isn't ${cluster}\n`);
34
50
  }
35
51
  const mostRecentUpFile = (0, last_up_record_js_1.getLastUp)(renderedTemplatesPath);
36
52
  if (mostRecentUpFile !== undefined) {
@@ -49,8 +65,3 @@ function composeFileToDown(downOptions, renderedTemplatesPath) {
49
65
  'Perhaps you do not have a running cluster, or you need to `pay local down --cluster <cluster>` specifying the last cluster you launched\n');
50
66
  }
51
67
  exports.composeFileToDown = composeFileToDown;
52
- function parseArguments(_options) {
53
- return {
54
- cluster: 'card'
55
- };
56
- }
@@ -3,26 +3,32 @@ 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.ENVIRONMENT_OVERRIDES_PATH = exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = void 0;
6
+ exports.handler = exports.desc = exports.command = exports.ENVIRONMENT_OVERRIDES_PATH = exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = void 0;
7
7
  const up_js_1 = __importDefault(require("./up.js"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const docker_compose_controller_js_1 = __importDefault(require("../docker_compose_controller.js"));
10
+ const standardContent_1 = require("../../../core/standardContent");
10
11
  exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = node_path_1.default.join('local', 'docker-compose', 'rendered-templates');
11
12
  exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = node_path_1.default.join('local', 'docker-compose', 'default-configs-DO-NOT-EDIT');
12
13
  exports.ENVIRONMENT_OVERRIDES_PATH = node_path_1.default.join('local', 'environment-overrides');
13
- async function NukeHandler() {
14
+ exports.command = 'nuke';
15
+ exports.desc = 'Kill and completely destroy all containers previously started by pay local';
16
+ exports.handler = nukeHandler;
17
+ async function nukeHandler(argv) {
18
+ await (0, standardContent_1.showHeader)();
14
19
  const upOptions = {
15
20
  cluster: 'nuke',
16
21
  proxy: true,
17
- with_egress_proxy: true,
22
+ withEgressProxy: true,
18
23
  apps: [],
19
24
  local: [],
20
25
  rebuild: false,
21
26
  pull: false,
22
- mount_local_node_apps: false
27
+ mountLocalNodeApps: false,
28
+ mountPayJSCommons: false
23
29
  };
24
30
  const renderedTemplatePath = await (0, up_js_1.default)(upOptions, true);
25
31
  console.log('Nuking cluster');
26
32
  docker_compose_controller_js_1.default.nuke(renderedTemplatePath);
27
33
  }
28
- exports.default = NukeHandler;
34
+ exports.default = nukeHandler;
@@ -1,27 +1,29 @@
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 totp_generator_1 = require("totp-generator");
5
- async function OTPHandler(options) {
6
- const args = parseArguments(options);
7
- const { otp } = totp_generator_1.TOTP.generate(args.secret);
6
+ const standardContent_1 = require("../../../core/standardContent");
7
+ exports.command = 'opt <key>';
8
+ exports.desc = 'Create otp code';
9
+ const builder = (yargs) => {
10
+ return yargs.positional('key', {
11
+ type: 'string',
12
+ description: 'otp key'
13
+ });
14
+ };
15
+ exports.builder = builder;
16
+ exports.handler = otpHandler;
17
+ async function otpHandler(argv) {
18
+ await (0, standardContent_1.showHeader)();
19
+ const { otp } = totp_generator_1.TOTP.generate(argv.key);
8
20
  console.log(otp);
9
21
  copyToClipboard(otp);
10
22
  console.log(`📋 “${otp}” copied to clipboard`);
11
23
  }
12
- exports.default = OTPHandler;
13
- function parseArguments(options) {
14
- if (options.length !== 1) {
15
- help();
16
- throw new Error('No key specified');
17
- }
18
- return { secret: options[0].trimEnd() };
19
- }
24
+ exports.default = otpHandler;
20
25
  function copyToClipboard(otp) {
21
26
  const proc = (0, node_child_process_1.spawn)('pbcopy');
22
27
  proc.stdin.write(otp);
23
28
  proc.stdin.end();
24
29
  }
25
- function help() {
26
- console.log('Usage: pay local otp <otp_secret_key>');
27
- }
@@ -3,10 +3,30 @@ 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
- async function PaymentHandler(options) {
9
- const args = parseArguments(options);
9
+ const standardContent_1 = require("../../../core/standardContent");
10
+ exports.command = 'payment';
11
+ exports.desc = 'Create a payment';
12
+ const builder = (yargs) => {
13
+ return yargs
14
+ .usage(`$0 local payment [--api-key <api-key>] [--email-collection-mode <email-collection-mode>]\n\n${exports.desc}`)
15
+ .option('api-key', {
16
+ type: 'string',
17
+ description: 'API Key'
18
+ }).option('email-collection-mode', {
19
+ type: 'string',
20
+ default: 'MANDATORY',
21
+ choices: ['MANDATORY', 'OPTIONAL', 'OFF'],
22
+ description: 'Email collection mode to use'
23
+ });
24
+ };
25
+ exports.builder = builder;
26
+ exports.handler = paymentHandler;
27
+ async function paymentHandler(argv) {
28
+ await (0, standardContent_1.showHeader)();
29
+ let apiKey = argv.apiKey;
10
30
  if (await app_client_js_1.default.isUnhealthy('connector')) {
11
31
  console.error('The connector service is unhealthy, so a payment cannot be created');
12
32
  return;
@@ -15,8 +35,7 @@ async function PaymentHandler(options) {
15
35
  console.error('The publicapi service is unhealthy, so a payment cannot be created');
16
36
  return;
17
37
  }
18
- let apiKey;
19
- if (args.api_key === undefined) {
38
+ if (apiKey === undefined) {
20
39
  console.warn('👔 Creating gateway account and service');
21
40
  console.warn();
22
41
  if (await app_client_js_1.default.isUnhealthy('adminusers')) {
@@ -28,7 +47,7 @@ async function PaymentHandler(options) {
28
47
  console.error('Unable to create a service');
29
48
  return;
30
49
  }
31
- const account = await app_client_js_1.default.createAccountInServiceWithEmailCollectionMode(serviceExternalID, args.email_collection_mode === undefined ? 'MANDATORY' : args.email_collection_mode);
50
+ const account = await app_client_js_1.default.createAccountInServiceWithEmailCollectionMode(serviceExternalID, argv.emailCollectionMode);
32
51
  if (account === undefined) {
33
52
  console.error('Failed to create a fully set up account');
34
53
  return;
@@ -43,9 +62,6 @@ async function PaymentHandler(options) {
43
62
  console.warn(`💁 Service ID: ${serviceExternalID}`);
44
63
  console.warn();
45
64
  }
46
- else {
47
- apiKey = args.api_key;
48
- }
49
65
  const createPaymentResult = await app_client_js_1.default.createPayment(apiKey);
50
66
  if (createPaymentResult === undefined) {
51
67
  console.error('Failed to create a payment');
@@ -62,7 +78,4 @@ async function PaymentHandler(options) {
62
78
  console.log(`Opening next_url (${nextUrl} in your browser`);
63
79
  (0, node_child_process_1.spawn)('open', [nextUrl]);
64
80
  }
65
- exports.default = PaymentHandler;
66
- function parseArguments(_options) {
67
- return {};
68
- }
81
+ exports.default = paymentHandler;
@@ -3,10 +3,26 @@ 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 = __importDefault(require("node:child_process"));
7
8
  const app_client_js_1 = __importDefault(require("../app_client/app_client.js"));
8
- async function PaymentLinkHandler(options) {
9
- const args = parseArguments(options);
9
+ const standardContent_1 = require("../../../core/standardContent");
10
+ exports.command = 'paymentlink';
11
+ exports.desc = 'Create a payment link';
12
+ const builder = (yargs) => {
13
+ return yargs
14
+ .usage(`$0 local paymentlink --api-key <api-key>\n\n${exports.desc}`)
15
+ .option('api-key', {
16
+ demandOption: true,
17
+ type: 'string',
18
+ description: 'API Key'
19
+ });
20
+ };
21
+ exports.builder = builder;
22
+ exports.handler = paymentLinkHandler;
23
+ async function paymentLinkHandler(argv) {
24
+ await (0, standardContent_1.showHeader)();
25
+ const apiKey = argv.apiKey;
10
26
  if (await app_client_js_1.default.isUnhealthy('products')) {
11
27
  console.error('The products service is unhealthy, so a payment link cannot be created');
12
28
  return;
@@ -15,7 +31,7 @@ async function PaymentLinkHandler(options) {
15
31
  console.error('The products-ui service is unhealthy, so a payment link cannot be created');
16
32
  return;
17
33
  }
18
- const paymentLinks = await app_client_js_1.default.createPaymentLink(args.apiKey);
34
+ const paymentLinks = await app_client_js_1.default.createPaymentLink(apiKey);
19
35
  if (paymentLinks === undefined) {
20
36
  console.error('Payment link creation failed');
21
37
  return;
@@ -28,14 +44,4 @@ async function PaymentLinkHandler(options) {
28
44
  }
29
45
  node_child_process_1.default.spawn('open', [payLink.href]);
30
46
  }
31
- exports.default = PaymentLinkHandler;
32
- function parseArguments(options) {
33
- if (options.length !== 1) {
34
- help();
35
- throw new Error('No key specified');
36
- }
37
- return { apiKey: options[0].trimEnd() };
38
- }
39
- function help() {
40
- console.log('Usage: pay local paymentlink <api_key>');
41
- }
47
+ exports.default = paymentLinkHandler;
@@ -3,33 +3,36 @@ 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.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = void 0;
6
+ exports.handler = exports.builder = exports.desc = exports.command = exports.DOCKER_COMPOSE_RENDERED_TEMPLATES_PATH = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const configs_js_1 = require("../../../util/configs.js");
9
9
  const last_up_record_js_1 = require("../config/last_up_record.js");
10
10
  const docker_compose_controller_js_1 = __importDefault(require("../docker_compose_controller.js"));
11
- exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = node_path_1.default.join('local', 'docker-compose', 'rendered-templates');
12
- async function DownHandler(options) {
13
- const renderedTempaltesPath = (0, configs_js_1.ensureConfigDirectory)(exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH);
14
- const args = parseArguments(options);
11
+ const standardContent_1 = require("../../../core/standardContent");
12
+ exports.DOCKER_COMPOSE_RENDERED_TEMPLATES_PATH = node_path_1.default.join('local', 'docker-compose', 'rendered-templates');
13
+ exports.command = 'restart <app>';
14
+ exports.desc = 'Restart a container and waits for it to be healthy';
15
+ const builder = (yargs) => {
16
+ return yargs
17
+ .usage(`$0 local restart <app>\n\n${exports.desc}`)
18
+ .positional('app', {
19
+ type: 'string',
20
+ description: 'App to restart'
21
+ });
22
+ };
23
+ exports.builder = builder;
24
+ exports.handler = restartHandler;
25
+ async function restartHandler(argv) {
26
+ await (0, standardContent_1.showHeader)();
27
+ const service = argv.app;
28
+ const renderedTempaltesPath = (0, configs_js_1.ensureConfigDirectory)(exports.DOCKER_COMPOSE_RENDERED_TEMPLATES_PATH);
15
29
  const composeFilePath = (0, last_up_record_js_1.getLastUp)(renderedTempaltesPath);
16
30
  if (composeFilePath === undefined) {
17
31
  throw new Error('Cannot find the docker-compose file for the running cluster');
18
32
  }
19
33
  const composeFileName = node_path_1.default.basename(composeFilePath);
20
34
  const clusterName = composeFileName.substring(0, composeFileName.lastIndexOf('.yaml'));
21
- console.log(`\nRestarting '${args.service} in cluster ${clusterName}`);
22
- docker_compose_controller_js_1.default.restart(composeFilePath, args.service);
23
- }
24
- exports.default = DownHandler;
25
- function parseArguments(options) {
26
- if (options.length !== 1) {
27
- throw new Error('Incorrect number of arguments, expected 1 to restart command\n' +
28
- '\n' +
29
- ' Usage: pay local restart <service>\n' +
30
- '\n');
31
- }
32
- return {
33
- service: options[0]
34
- };
35
+ console.log(`\nRestarting '${service} in cluster ${clusterName}`);
36
+ docker_compose_controller_js_1.default.restart(composeFilePath, service);
35
37
  }
38
+ exports.default = restartHandler;
@@ -3,16 +3,30 @@ 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
- async function TokenHandler(options) {
9
- const args = parseArguments(options);
9
+ const standardContent_1 = require("../../../core/standardContent");
10
+ exports.command = 'token';
11
+ exports.desc = 'Create a token';
12
+ const builder = (yargs) => {
13
+ return yargs
14
+ .usage(`$0 local token [--gateway-account-id <gateway-account-id>]\n\n${exports.desc}`)
15
+ .option('gateway-account-id', {
16
+ type: 'string',
17
+ description: 'ID of the gateway account'
18
+ });
19
+ };
20
+ exports.builder = builder;
21
+ exports.handler = tokenHandler;
22
+ async function tokenHandler(argv) {
23
+ await (0, standardContent_1.showHeader)();
24
+ let gatewayAccountID = argv.gatewayAccountID;
10
25
  if (await app_client_js_1.default.isUnhealthy('publicauth')) {
11
26
  console.error('The publicauth service is unhealthy, so an API token cannot be created');
12
27
  return;
13
28
  }
14
- let gatewayAccountID;
15
- if (args.gatewayAccountID === undefined) {
29
+ if (gatewayAccountID === undefined) {
16
30
  console.log('No gateway_account_id provided, creating service and gateway account');
17
31
  if (await app_client_js_1.default.isUnhealthy('adminusers')) {
18
32
  console.error('The adminusers service is unhealthy, so an API token cannot be created');
@@ -34,9 +48,6 @@ async function TokenHandler(options) {
34
48
  }
35
49
  gatewayAccountID = account.gateway_account_id;
36
50
  }
37
- else {
38
- gatewayAccountID = args.gatewayAccountID;
39
- }
40
51
  const token = await app_client_js_1.default.createToken(gatewayAccountID);
41
52
  if (token === undefined) {
42
53
  console.error('Failed to create an API token');
@@ -45,22 +56,9 @@ async function TokenHandler(options) {
45
56
  copyToClipboard(token);
46
57
  console.log(`📋 API token “${token}” copied to clipboard`);
47
58
  }
48
- exports.default = TokenHandler;
49
- function parseArguments(options) {
50
- if (options.length === 0) {
51
- return {};
52
- }
53
- if (options.length > 1) {
54
- help();
55
- throw new Error('Too many arguments');
56
- }
57
- return { gatewayAccountID: options[0] };
58
- }
59
+ exports.default = tokenHandler;
59
60
  function copyToClipboard(token) {
60
61
  const proc = (0, node_child_process_1.spawn)('pbcopy');
61
62
  proc.stdin.write(token);
62
63
  proc.stdin.end();
63
64
  }
64
- function help() {
65
- console.log('Usage: pay local token [gateway_account_id]>');
66
- }
@@ -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.ENVIRONMENT_OVERRIDES_PATH = exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = void 0;
6
+ exports.upCommandHandler = exports.handler = exports.builder = exports.desc = exports.command = exports.ENVIRONMENT_OVERRIDES_PATH = exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = exports.DOCKER_COMPOSE_RENDERED_TEMPLATES_PATH = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const docker_compose_controller_js_1 = __importDefault(require("../docker_compose_controller.js"));
9
9
  const configs_js_1 = require("../../../util/configs.js");
@@ -11,28 +11,98 @@ const pay_local_cluster_js_1 = require("../config/pay_local_cluster.js");
11
11
  const renderer_js_1 = require("../config/renderer.js");
12
12
  const last_up_record_js_1 = require("../config/last_up_record.js");
13
13
  const default_config_setup_js_1 = require("../config/default_config_setup.js");
14
- exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH = path_1.default.join('local', 'docker-compose', 'rendered-templates');
14
+ const standardContent_1 = require("../../../core/standardContent");
15
+ exports.DOCKER_COMPOSE_RENDERED_TEMPLATES_PATH = path_1.default.join('local', 'docker-compose', 'rendered-templates');
15
16
  exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH = path_1.default.join('local', 'docker-compose', 'default-configs-DO-NOT-EDIT');
16
17
  exports.ENVIRONMENT_OVERRIDES_PATH = path_1.default.join('local', 'environment-overrides');
18
+ exports.command = ['up', 'launch'];
19
+ exports.desc = 'Launch a predefined cluster, or a user specified list of apps.';
20
+ const builder = (yargs) => {
21
+ return yargs
22
+ .usage(`$0 local up | launch [--cluster <cluster>] [--local <app>] [--proxy] [--apps] [--rebuild] [--with-egress-proxy]\n\n${exports.desc}\n\nSpecify a list of apps that should use your locally checked out code using --local`)
23
+ .option('cluster', {
24
+ type: 'string',
25
+ choices: pay_local_cluster_js_1.CLUSTERS,
26
+ default: 'all',
27
+ description: 'cluster'
28
+ })
29
+ .option('apps', {
30
+ type: 'array',
31
+ default: [],
32
+ description: ''
33
+ })
34
+ .option('local', {
35
+ type: 'array',
36
+ default: [],
37
+ description: ''
38
+ })
39
+ .option('proxy', {
40
+ type: 'boolean',
41
+ default: false,
42
+ description: ''
43
+ })
44
+ .option('with-egress-proxy', {
45
+ type: 'boolean',
46
+ default: false,
47
+ description: ''
48
+ })
49
+ .option('rebuild', {
50
+ type: 'boolean',
51
+ default: true,
52
+ description: ''
53
+ })
54
+ .option('pull', {
55
+ type: 'boolean',
56
+ default: true,
57
+ description: ''
58
+ })
59
+ .option('mount-local-node-apps', {
60
+ type: 'boolean',
61
+ default: false,
62
+ description: ''
63
+ })
64
+ .option('mount-pay-js-commons', {
65
+ type: 'boolean',
66
+ default: false,
67
+ description: 'If mount local node apps is also specified this will mount pay-js-commons into /pay-js-commons in the node containers'
68
+ });
69
+ };
70
+ exports.builder = builder;
71
+ exports.handler = upCommandHandler;
72
+ async function upCommandHandler(argv) {
73
+ await (0, standardContent_1.showHeader)();
74
+ const upOptions = {
75
+ cluster: argv.cluster,
76
+ proxy: argv.proxy,
77
+ withEgressProxy: argv.withEgressProxy,
78
+ apps: argv.apps,
79
+ local: argv.local,
80
+ rebuild: argv.rebuild,
81
+ pull: argv.pull,
82
+ mountLocalNodeApps: argv.mountLocalNodeApps,
83
+ mountPayJSCommons: argv.mountPayJsCommons
84
+ };
85
+ await UpHandler(upOptions, false);
86
+ }
87
+ exports.upCommandHandler = upCommandHandler;
17
88
  async function UpHandler(options, onlyWriteConfig = false) {
18
89
  const workspace = (0, configs_js_1.workspaceEnvVar)();
19
- const renderedTemplatesPath = (0, configs_js_1.ensureConfigDirectory)(exports.DOCKER_COMPOSE_RENDERED_TEMPALTES_PATH);
90
+ const renderedTemplatesPath = (0, configs_js_1.ensureConfigDirectory)(exports.DOCKER_COMPOSE_RENDERED_TEMPLATES_PATH);
20
91
  const composeServicesConfigPath = (0, configs_js_1.ensureConfigDirectory)(exports.DOCKER_COMPOSE_SERVICES_CONFIG_PATH);
21
92
  const environmentOverridesPath = (0, configs_js_1.ensureConfigDirectory)(exports.ENVIRONMENT_OVERRIDES_PATH);
22
93
  (0, default_config_setup_js_1.copyDefaultConfigs)(composeServicesConfigPath);
23
- const args = options instanceof Array ? parseArguments(options) : options;
24
- const clusterConfig = (0, pay_local_cluster_js_1.loadClusterConfig)(args, workspace, composeServicesConfigPath, environmentOverridesPath);
94
+ const clusterConfig = (0, pay_local_cluster_js_1.loadClusterConfig)(options, workspace, composeServicesConfigPath, environmentOverridesPath);
25
95
  const renderedTemplatePath = (0, renderer_js_1.renderDockerCompose)(clusterConfig, renderedTemplatesPath);
26
96
  console.log(`docker-compose yaml written to ${renderedTemplatePath}`);
27
97
  (0, last_up_record_js_1.recordUp)(renderedTemplatesPath, clusterConfig);
28
98
  if (onlyWriteConfig) {
29
99
  return renderedTemplatePath;
30
100
  }
31
- if (args.pull) {
101
+ if (options.pull) {
32
102
  console.log(`\nPulling containers for cluster ${clusterConfig.name}`);
33
103
  docker_compose_controller_js_1.default.pull(renderedTemplatePath);
34
104
  }
35
- if (args.local.length > 0 && args.rebuild) {
105
+ if (options.local.length > 0 && options.rebuild) {
36
106
  console.log(`\nBuilding all local apps for cluster ${clusterConfig.name}`);
37
107
  docker_compose_controller_js_1.default.build(renderedTemplatePath);
38
108
  }
@@ -41,15 +111,3 @@ async function UpHandler(options, onlyWriteConfig = false) {
41
111
  return renderedTemplatePath;
42
112
  }
43
113
  exports.default = UpHandler;
44
- function parseArguments(_options) {
45
- return {
46
- cluster: 'all',
47
- apps: [],
48
- local: [], // ['cardid', 'frontend'],
49
- proxy: true,
50
- with_egress_proxy: false,
51
- rebuild: true,
52
- pull: true,
53
- mount_local_node_apps: false
54
- };
55
- }
@@ -3,18 +3,36 @@ 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
- async function URLHandler(options) {
10
- const args = parseArguments(options);
10
+ const standardContent_1 = require("../../../core/standardContent");
11
+ exports.command = 'url <service>';
12
+ exports.desc = 'Copy base URL of local service to clipboard';
13
+ const builder = (yargs) => {
14
+ return yargs.positional('service', {
15
+ type: 'string',
16
+ description: 'service'
17
+ }).option('proxy', {
18
+ type: 'boolean',
19
+ default: false,
20
+ description: 'Something about proxy'
21
+ });
22
+ };
23
+ exports.builder = builder;
24
+ exports.handler = urlHandler;
25
+ async function urlHandler(argv) {
26
+ await (0, standardContent_1.showHeader)();
27
+ const service = argv.service;
28
+ const proxy = argv.service;
11
29
  const servicesConfig = (0, pay_local_cluster_js_1.loadServicesConfig)();
12
- if (!(args.service in servicesConfig)) {
13
- console.error(`The service specified (${args.service}) was not defined in the service_config.yaml file`);
30
+ if (!(service in servicesConfig)) {
31
+ console.error(`The service specified (${service}) was not defined in the service_config.yaml file`);
14
32
  return;
15
33
  }
16
- const serviceConfig = servicesConfig[args.service];
17
- const url = app_client_js_1.default.externalUrlFor(args.service, '/', args.proxy);
34
+ const serviceConfig = servicesConfig[service];
35
+ const url = app_client_js_1.default.externalUrlFor(service, '/', proxy);
18
36
  copyToClipboard(url);
19
37
  if (await app_client_js_1.default.isHealthy(serviceConfig.name)) {
20
38
  console.log(`📋 “${url}” copied to clipboard`);
@@ -23,22 +41,9 @@ async function URLHandler(options) {
23
41
  console.error(`❌ “${url}” copied to clipboard, however the app did not respond successfully to ${url}/healthcheck`);
24
42
  }
25
43
  }
26
- exports.default = URLHandler;
44
+ exports.default = urlHandler;
27
45
  function copyToClipboard(url) {
28
46
  const proc = (0, node_child_process_1.spawn)('pbcopy');
29
47
  proc.stdin.write(url);
30
48
  proc.stdin.end();
31
49
  }
32
- function help() {
33
- console.log('Usage: pay local url <service>');
34
- }
35
- function parseArguments(options) {
36
- if (options.length !== 1) {
37
- help();
38
- throw new Error('No service specified');
39
- }
40
- return {
41
- service: options[0],
42
- proxy: false
43
- };
44
- }
@@ -3,11 +3,27 @@ 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
  const totp_generator_1 = require("totp-generator");
8
9
  const node_child_process_1 = require("node:child_process");
9
- async function UserHandler(options) {
10
- const args = parseArguments(options);
10
+ const standardContent_1 = require("../../../core/standardContent");
11
+ exports.command = 'user';
12
+ exports.desc = 'Create a local user';
13
+ const builder = (yargs) => {
14
+ return yargs
15
+ .usage(`$0 local user [--create-payments]\n\n${exports.desc}`)
16
+ .option('create-payments', {
17
+ type: 'boolean',
18
+ default: false,
19
+ description: 'Create payments'
20
+ });
21
+ };
22
+ exports.builder = builder;
23
+ exports.handler = userHandler;
24
+ async function userHandler(argv) {
25
+ await (0, standardContent_1.showHeader)();
26
+ const createPayments = argv.createPayments;
11
27
  if (await app_client_js_1.default.isUnhealthy('adminusers')) {
12
28
  console.error('The adminusers service is unhealthy, so a user cannot be created');
13
29
  return;
@@ -32,7 +48,7 @@ async function UserHandler(options) {
32
48
  console.error('Failed to create an API token');
33
49
  return;
34
50
  }
35
- if (args.createPayments !== undefined && args.createPayments) {
51
+ if (createPayments !== undefined && createPayments) {
36
52
  console.warn('💸 Creating 10 payments in card sandbox gateway account (each . is a success, each ! is a failure)');
37
53
  let createPaymentResult;
38
54
  for (let i = 0; i < 10; i++) {
@@ -78,14 +94,9 @@ async function UserHandler(options) {
78
94
  console.log();
79
95
  (0, node_child_process_1.spawn)('open', [selfserviceUrl]);
80
96
  }
81
- exports.default = UserHandler;
97
+ exports.default = userHandler;
82
98
  function copyToClipboard(email) {
83
99
  const proc = (0, node_child_process_1.spawn)('pbcopy');
84
100
  proc.stdin.write(email);
85
101
  proc.stdin.end();
86
102
  }
87
- function parseArguments(_options) {
88
- return {
89
- createPayments: false
90
- };
91
- }