@govuk-pay/cli 0.0.61 → 0.0.63

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.61",
3
+ "version": "0.0.63",
4
4
  "description": "GOV.UK Pay Command Line Interface",
5
5
  "bin": {
6
6
  "pay": "bin/cli.js",
package/readme.md CHANGED
@@ -58,7 +58,7 @@ Config files needed by the pay cli will go in `$HOME/.pay-cli"
58
58
 
59
59
  #### Pay Local Config Files
60
60
 
61
- You can override environment variables set in the the .env files in [the pay local services local config directory](https://github.com/alphagov/pay-cli/tree/main/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services` for
61
+ You can override environment variables set in the .env files in [the pay local services local config directory](https://github.com/alphagov/pay-cli/tree/main/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services) for
62
62
  specific containers by placing files in `$HOME/.pay-cli/local/environment-overrides/<app_name>.env`.
63
63
 
64
64
  For example to override an environment variable for connector which was set in [connector.env](https://github.com/alphagov/pay-cli/blob/main/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/connector.env)
@@ -67,6 +67,23 @@ you could create the file `$HOME/.pay-cli/local/environment-overrides/connector.
67
67
  Note: This will only override variables set in the .env files, it will not override any variables which get declared in an `environment` configuration option in the generated docker-compose files. These are generated from the
68
68
  [docker-compose.erb](https://github.com/alphagov/pay-cli/blob/main/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/docker-compose.erb#L5) template.
69
69
 
70
+ You can configure custom clusters by creating a file at `$HOME/.pay-cli/local/custom-clusters.yaml` following the schema:
71
+ ```yaml
72
+ clusters:
73
+ - name: my-cool-cluster
74
+ apps:
75
+ - connector
76
+ - selfservice
77
+ - frontend
78
+ - adminusers
79
+ - toolbox
80
+ - name: another-cool-cluster
81
+ apps:
82
+ - connector
83
+ - selfservice
84
+ - frontend
85
+ ```
86
+
70
87
  ## Vulnerability Disclosure
71
88
 
72
89
  GOV.UK Pay aims to stay secure for everyone. If you are a security researcher and have discovered a security vulnerability in this code, we appreciate your help in disclosing it to us in a responsible manner. Please refer to our [vulnerability disclosure policy](https://www.gov.uk/help/report-vulnerability) and our [security.txt](https://vdp.cabinetoffice.gov.uk/.well-known/security.txt) file for details.
@@ -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.loadCustomClusterConfig = exports.loadServicesConfig = exports.loadClusterConfig = exports.PayLocalCluster = exports.CUSTOM_CLUSTER_NAMES = exports.CUSTOM_CLUSTERS = exports.CUSTOM_CLUSTERS_PATH = exports.CLUSTERS = void 0;
6
+ exports.loadCustomClusterConfig = exports.loadServicesConfig = exports.loadClusterConfig = exports.PayLocalCluster = exports.CUSTOM_CLUSTERS = exports.CUSTOM_CLUSTERS_PATH = 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"));
@@ -12,7 +12,6 @@ const configs_1 = require("../../../util/configs");
12
12
  exports.CLUSTERS = ['all', 'admin', 'card', 'paymentlinks', 'webhooks', 'endtoend', 'java', 'toolbox'];
13
13
  exports.CUSTOM_CLUSTERS_PATH = node_path_1.default.join((0, configs_1.ensureConfigDirectory)('local'), 'custom-clusters.yaml');
14
14
  exports.CUSTOM_CLUSTERS = loadCustomClusterConfig(exports.CUSTOM_CLUSTERS_PATH);
15
- exports.CUSTOM_CLUSTER_NAMES = exports.CUSTOM_CLUSTERS.clusters.map(cluster => cluster.name);
16
15
  // This is the complete cluster configuration that will be used as the context for template rendering
17
16
  class PayLocalCluster {
18
17
  name;
@@ -139,11 +138,14 @@ exports.loadServicesConfig = loadServicesConfig;
139
138
  function loadCustomClusterConfig(customClusterPath) {
140
139
  try {
141
140
  const customClusterFileContents = node_fs_1.default.readFileSync(customClusterPath, 'utf8');
142
- return yaml_1.default.parse(customClusterFileContents);
141
+ const customClusters = yaml_1.default.parse(customClusterFileContents);
142
+ customClusters.names = customClusters.clusters.map(cluster => cluster.name);
143
+ return customClusters;
143
144
  }
144
145
  catch (e) {
145
146
  return {
146
- clusters: []
147
+ clusters: [],
148
+ names: []
147
149
  };
148
150
  }
149
151
  }
@@ -154,7 +156,7 @@ function includeAppInCluster(cluster, options, serviceConfig) {
154
156
  return true;
155
157
  }
156
158
  }
157
- else if (exports.CUSTOM_CLUSTER_NAMES.includes(cluster)) {
159
+ else if (exports.CUSTOM_CLUSTERS.names.includes(cluster)) {
158
160
  const customCluster = exports.CUSTOM_CLUSTERS.clusters.filter(c => c.name === cluster)[0];
159
161
  if (customCluster.apps.includes(serviceConfig.name)) {
160
162
  return true;
@@ -22,7 +22,7 @@ const builder = (yargs) => {
22
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
23
  .option('cluster', {
24
24
  type: 'string',
25
- choices: [].concat(pay_local_cluster_js_1.CLUSTERS, pay_local_cluster_js_1.CUSTOM_CLUSTER_NAMES),
25
+ choices: [].concat(pay_local_cluster_js_1.CLUSTERS, pay_local_cluster_js_1.CUSTOM_CLUSTERS.names),
26
26
  default: 'all',
27
27
  description: 'Cluster of services to launch'
28
28
  })
@@ -71,7 +71,8 @@ exports.builder = builder;
71
71
  exports.handler = upCommandHandler;
72
72
  async function upCommandHandler(argv) {
73
73
  await (0, standardContent_1.showHeader)();
74
- const upOptions = {
74
+ const customClusterOptions = pay_local_cluster_js_1.CUSTOM_CLUSTERS.names.includes(argv.cluster) ? pay_local_cluster_js_1.CUSTOM_CLUSTERS.clusters.filter(c => c.name === argv.cluster)[0].options : {};
75
+ const upOptions = Object.assign({
75
76
  cluster: argv.cluster,
76
77
  proxy: argv.proxy,
77
78
  withEgressProxy: argv.withEgressProxy,
@@ -81,7 +82,7 @@ async function upCommandHandler(argv) {
81
82
  pull: argv.pull,
82
83
  mountLocalNodeApps: argv.mountLocalNodeApps,
83
84
  mountPayJSCommons: argv.mountPayJsCommons
84
- };
85
+ }, customClusterOptions);
85
86
  await UpHandler(upOptions, false);
86
87
  }
87
88
  exports.upCommandHandler = upCommandHandler;