@govuk-pay/cli 0.0.60 → 0.0.61
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
|
@@ -3,12 +3,16 @@ 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 = exports.CLUSTERS = void 0;
|
|
6
|
+
exports.loadCustomClusterConfig = exports.loadServicesConfig = exports.loadClusterConfig = exports.PayLocalCluster = exports.CUSTOM_CLUSTER_NAMES = 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"));
|
|
10
10
|
const md5_js_1 = require("../../../util/md5.js");
|
|
11
|
+
const configs_1 = require("../../../util/configs");
|
|
11
12
|
exports.CLUSTERS = ['all', 'admin', 'card', 'paymentlinks', 'webhooks', 'endtoend', 'java', 'toolbox'];
|
|
13
|
+
exports.CUSTOM_CLUSTERS_PATH = node_path_1.default.join((0, configs_1.ensureConfigDirectory)('local'), 'custom-clusters.yaml');
|
|
14
|
+
exports.CUSTOM_CLUSTERS = loadCustomClusterConfig(exports.CUSTOM_CLUSTERS_PATH);
|
|
15
|
+
exports.CUSTOM_CLUSTER_NAMES = exports.CUSTOM_CLUSTERS.clusters.map(cluster => cluster.name);
|
|
12
16
|
// This is the complete cluster configuration that will be used as the context for template rendering
|
|
13
17
|
class PayLocalCluster {
|
|
14
18
|
name;
|
|
@@ -132,12 +136,30 @@ function loadServicesConfig() {
|
|
|
132
136
|
return yaml_1.default.parse(serviceConfigFileContents);
|
|
133
137
|
}
|
|
134
138
|
exports.loadServicesConfig = loadServicesConfig;
|
|
139
|
+
function loadCustomClusterConfig(customClusterPath) {
|
|
140
|
+
try {
|
|
141
|
+
const customClusterFileContents = node_fs_1.default.readFileSync(customClusterPath, 'utf8');
|
|
142
|
+
return yaml_1.default.parse(customClusterFileContents);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
return {
|
|
146
|
+
clusters: []
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.loadCustomClusterConfig = loadCustomClusterConfig;
|
|
135
151
|
function includeAppInCluster(cluster, options, serviceConfig) {
|
|
136
152
|
if (cluster === 'all' || cluster === 'nuke' || serviceConfig.clusters.includes(cluster)) {
|
|
137
153
|
if (options.apps.length === 0 || options.apps.includes(serviceConfig.name)) {
|
|
138
154
|
return true;
|
|
139
155
|
}
|
|
140
156
|
}
|
|
157
|
+
else if (exports.CUSTOM_CLUSTER_NAMES.includes(cluster)) {
|
|
158
|
+
const customCluster = exports.CUSTOM_CLUSTERS.clusters.filter(c => c.name === cluster)[0];
|
|
159
|
+
if (customCluster.apps.includes(serviceConfig.name)) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
141
163
|
return false;
|
|
142
164
|
}
|
|
143
165
|
function payServiceFromPayServiceConfig(config, upOptions, environmentOverridesPath) {
|
|
@@ -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: pay_local_cluster_js_1.CLUSTERS,
|
|
25
|
+
choices: [].concat(pay_local_cluster_js_1.CLUSTERS, pay_local_cluster_js_1.CUSTOM_CLUSTER_NAMES),
|
|
26
26
|
default: 'all',
|
|
27
27
|
description: 'Cluster of services to launch'
|
|
28
28
|
})
|