@opencrvs/toolkit 2.1.0-rc.99061f0 → 2.1.0-rc.9a83eed
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/README.md +2 -12
- package/build.sh +9 -1
- package/create-countryconfig/index.js +412 -59
- package/create-countryconfig/node_modules/.bin/degit +21 -0
- package/create-countryconfig/package.json +4 -1
- package/dist/application-config/index.js +347 -281
- package/dist/authentication/index.d.ts +67 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +751 -0
- package/dist/cli.js +2077 -299
- package/dist/commons/api/router.d.ts +689 -110
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +16 -5
- package/dist/commons/events/ActionConfig.d.ts +4 -0
- package/dist/commons/events/ActionDocument.d.ts +5 -11
- package/dist/commons/events/ActionInput.d.ts +4 -4
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +36 -12
- package/dist/commons/events/AuditLog.d.ts +147 -0
- package/dist/commons/events/EventConfig.d.ts +3 -0
- package/dist/commons/events/EventDocument.d.ts +470 -2
- package/dist/commons/events/EventIndex.d.ts +3 -26
- package/dist/commons/events/EventMetadata.d.ts +1 -11
- package/dist/commons/events/EventStatus.d.ts +19 -0
- package/dist/commons/events/FieldConfig.d.ts +99 -63
- package/dist/commons/events/FieldTypeMapping.d.ts +27 -27
- package/dist/commons/events/FieldValue.d.ts +2 -2
- package/dist/commons/events/Flag.d.ts +42 -0
- package/dist/commons/events/FormConfig.d.ts +6 -0
- package/dist/commons/events/PageConfig.d.ts +4 -0
- package/dist/commons/events/PlainDate.d.ts +8 -0
- package/dist/commons/events/SummaryConfig.d.ts +249 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
- package/dist/commons/events/event.d.ts +12 -0
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locationPayloads.d.ts +95 -0
- package/dist/commons/events/locations.d.ts +169 -26
- package/dist/commons/events/mocks.test.utils.d.ts +30 -0
- package/dist/commons/events/test.utils.d.ts +25 -4
- package/dist/commons/events/utils.d.ts +17 -2
- package/dist/commons/notification/UserNotifications.d.ts +28 -13
- package/dist/commons/notification/dispatch.d.ts +10 -0
- package/dist/commons/notification/index.d.ts +1 -0
- package/dist/conditionals/index.js +335 -64
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +120 -0
- package/dist/environment/logger.d.ts +15 -3
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/manage-users.js +1 -1
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +20 -14
- package/dist/environment/setup-environment.js +45 -27
- package/dist/environment/templates.d.ts +0 -1
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +3 -8
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +4 -0
- package/dist/environment/utils.d.ts +0 -12
- package/dist/environment/utils.d.ts.map +1 -1
- package/dist/environment/utils.js +1 -28
- package/dist/events/index.js +7660 -7156
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +1 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -1
- package/dist/migrations/v2.1/add-explicit-correction-flags.js +34 -6
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +506 -0
- package/dist/migrations/v2.1/add-translations.d.ts +9 -0
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-translations.js +208 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
- package/dist/migrations/v2.1/enable-telemetry.js +433 -0
- package/dist/migrations/v2.1/index.d.ts +14 -1
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +1077 -7
- package/dist/notification/index.js +1835 -1425
- package/dist/scopes/index.d.ts +435 -36
- package/dist/scopes/index.js +336 -64
- package/dist/telemetry/index.d.ts +45 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +39 -0
- package/dist/templates/charts-values/dependencies/values.yaml +2 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
- package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
- package/dist/templates/charts-values/traefik/values.yaml +23 -9
- package/dist/templates/inventory/inventory.template.yml +1 -3
- package/dist/translations/check.d.ts +21 -0
- package/dist/translations/check.d.ts.map +1 -0
- package/dist/translations/check.js +132 -0
- package/dist/verify/endpoints.d.ts +19 -0
- package/dist/verify/endpoints.d.ts.map +1 -0
- package/dist/verify/endpoints.js +353 -0
- package/dist/verify/scopes.d.ts +13 -0
- package/dist/verify/scopes.d.ts.map +1 -0
- package/dist/verify/scopes.js +131 -0
- package/dist/verify/upgrade.d.ts +14 -0
- package/dist/verify/upgrade.d.ts.map +1 -0
- package/dist/verify/upgrade.js +111 -0
- package/opencrvs-toolkit-2.1.0-rc.9a83eed.tgz +0 -0
- package/package.json +12 -6
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/dist/templates/inventory/production.example.yml +0 -77
- package/dist/templates/inventory/qa.example.yml +0 -48
- package/opencrvs-toolkit-2.1.0-rc.99061f0.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
package/dist/csv.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.parseCsvLine = parseCsvLine;
|
|
14
|
+
exports.toCsvLine = toCsvLine;
|
|
15
|
+
exports.idOf = idOf;
|
|
16
|
+
exports.readCsvFile = readCsvFile;
|
|
17
|
+
exports.writeCsvFile = writeCsvFile;
|
|
18
|
+
exports.addRows = addRows;
|
|
19
|
+
/**
|
|
20
|
+
* Just enough CSV for the translation files codemods edit. They are read and
|
|
21
|
+
* written a line at a time rather than through a parser, so that adding two
|
|
22
|
+
* rows to a file of sixteen hundred produces a diff of two lines instead of a
|
|
23
|
+
* re-quoted rewrite of the whole thing.
|
|
24
|
+
*
|
|
25
|
+
* Rows spanning multiple lines are not supported, and none of the translation
|
|
26
|
+
* files contain any.
|
|
27
|
+
*/
|
|
28
|
+
const fs_1 = require("fs");
|
|
29
|
+
function parseCsvLine(line) {
|
|
30
|
+
const values = [];
|
|
31
|
+
let value = '';
|
|
32
|
+
let quoted = false;
|
|
33
|
+
for (let index = 0; index < line.length; index++) {
|
|
34
|
+
const character = line[index];
|
|
35
|
+
if (quoted) {
|
|
36
|
+
if (character !== '"') {
|
|
37
|
+
value += character;
|
|
38
|
+
}
|
|
39
|
+
else if (line[index + 1] === '"') {
|
|
40
|
+
value += '"';
|
|
41
|
+
index++;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
quoted = false;
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (character === '"') {
|
|
49
|
+
quoted = true;
|
|
50
|
+
}
|
|
51
|
+
else if (character === ',') {
|
|
52
|
+
values.push(value);
|
|
53
|
+
value = '';
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
value += character;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
values.push(value);
|
|
60
|
+
return values;
|
|
61
|
+
}
|
|
62
|
+
function toCsvLine(values) {
|
|
63
|
+
return values
|
|
64
|
+
.map((value) => /["\n,]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value)
|
|
65
|
+
.join(',');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The id of a row, which is its first column. Translation ids never contain a
|
|
69
|
+
* comma or a quote, so this does not need the parser.
|
|
70
|
+
*/
|
|
71
|
+
function idOf(line) {
|
|
72
|
+
const comma = line.indexOf(',');
|
|
73
|
+
// No comma: `slice(0, -1)` would eat the last character.
|
|
74
|
+
return comma === -1 ? line : line.slice(0, comma);
|
|
75
|
+
}
|
|
76
|
+
function readCsvFile(path) {
|
|
77
|
+
if (!(0, fs_1.existsSync)(path)) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const contents = (0, fs_1.readFileSync)(path, 'utf8');
|
|
81
|
+
const newline = contents.includes('\r\n') ? '\r\n' : '\n';
|
|
82
|
+
const trailingNewline = /\r?\n$/.test(contents);
|
|
83
|
+
const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
|
|
84
|
+
// Trailing blank line leaves an empty entry. It sorts before every id, so
|
|
85
|
+
// the file reads as unsorted.
|
|
86
|
+
const body = lines.slice(1).filter((line) => line !== '');
|
|
87
|
+
return { header: lines[0], body, newline, trailingNewline };
|
|
88
|
+
}
|
|
89
|
+
function writeCsvFile(path, file) {
|
|
90
|
+
(0, fs_1.writeFileSync)(path, [file.header, ...file.body].join(file.newline) +
|
|
91
|
+
(file.trailingNewline ? file.newline : ''));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Adds the rows the file does not already have an id for, in place. Rows go in
|
|
95
|
+
* sorted position when the file is sorted by id, and at the end when it is not,
|
|
96
|
+
* so a country config that keeps its own order keeps it.
|
|
97
|
+
*
|
|
98
|
+
* Returns the ids that were added.
|
|
99
|
+
*/
|
|
100
|
+
function addRows(file, rows) {
|
|
101
|
+
const isSorted = file.body.every((line, index) => index === 0 || idOf(file.body[index - 1]) <= idOf(line));
|
|
102
|
+
const added = [];
|
|
103
|
+
for (const row of rows) {
|
|
104
|
+
const id = idOf(row);
|
|
105
|
+
if (file.body.some((line) => idOf(line) === id)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const insertAt = isSorted
|
|
109
|
+
? file.body.findIndex((line) => idOf(line) > id)
|
|
110
|
+
: -1;
|
|
111
|
+
if (insertAt === -1) {
|
|
112
|
+
file.body.push(row);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
file.body.splice(insertAt, 0, row);
|
|
116
|
+
}
|
|
117
|
+
added.push(id);
|
|
118
|
+
}
|
|
119
|
+
return added;
|
|
120
|
+
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
export declare const log:
|
|
2
|
-
|
|
1
|
+
export declare const log: {
|
|
2
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
3
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
4
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
5
|
+
};
|
|
6
|
+
export declare const warn: {
|
|
7
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
8
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
9
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
10
|
+
};
|
|
3
11
|
export declare const success: (...args: any[]) => void;
|
|
4
|
-
export declare const info:
|
|
12
|
+
export declare const info: {
|
|
13
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
14
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
15
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
16
|
+
};
|
|
5
17
|
export declare const error: (...args: any[]) => void;
|
|
6
18
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG;;;;CAAc,CAAA;AAC9B,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,OAAO,YAAa,GAAG,EAAE,SACI,CAAA;AAC1C,eAAO,MAAM,IAAI;;;;CAAe,CAAA;AAChC,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,SAA2C,CAAA"}
|
|
@@ -95,7 +95,7 @@ function updateInventoryFile(filePath, users) {
|
|
|
95
95
|
function parseInventoryFile(filePath) {
|
|
96
96
|
try {
|
|
97
97
|
const data = (0, utils_1.readYamlFile)(filePath);
|
|
98
|
-
return (0, templates_1.
|
|
98
|
+
return (0, templates_1.extractAndModifyUsers)(data);
|
|
99
99
|
}
|
|
100
100
|
catch (_a) {
|
|
101
101
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,QAAQ,UAAW,MAAM,GAAG,MAAM,kCAC4B,CAAA;AAepE,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBnD;AAED,eAAO,MAAM,kBAAkB;;UAGrB,MAAM;;eAED,QAAQ;;;;WAIZ,YAAY;GAiCtB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;;;WAIL,YAAY;GAUtB,CAAA;AACD,eAAO,MAAM,oBAAoB;;UAGvB,MAAM;;;eAGD,UAAU;;WAEd,YAAY;;;;;UAIb,QAAQ;;;;;;eAaH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AACD,eAAO,MAAM,mBAAmB;;UAGtB,MAAM;;;;eAID,QAAQ;WACZ,YAAY;;GAGtB,CAAA;AAED,eAAO,MAAM,gBAAgB;;UAGnB,MAAM;;eAGD,UAAU;;;WAGd,YAAY;GAEtB,CAAA;AAED,eAAO,MAAM,uBAAuB;;UAG1B,MAAM;;eAED,UAAU;;;;WAId,aAAa;;;;UAId,MAAM;;eAED,UAAU;;;
|
|
1
|
+
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/environment/questions.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,QAAQ,UAAW,MAAM,GAAG,MAAM,kCAC4B,CAAA;AAepE,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAgBnD;AAED,eAAO,MAAM,kBAAkB;;UAGrB,MAAM;;eAED,QAAQ;;;;WAIZ,YAAY;GAiCtB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;;;WAIL,YAAY;GAUtB,CAAA;AACD,eAAO,MAAM,oBAAoB;;UAGvB,MAAM;;;eAGD,UAAU;;WAEd,YAAY;;;;;UAIb,QAAQ;;;;;;eAaH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AACD,eAAO,MAAM,mBAAmB;;UAGtB,MAAM;;;;eAID,QAAQ;WACZ,YAAY;;GAGtB,CAAA;AAED,eAAO,MAAM,gBAAgB;;UAGnB,MAAM;;eAGD,UAAU;;;WAGd,YAAY;GAEtB,CAAA;AAED,eAAO,MAAM,uBAAuB;;UAG1B,MAAM;;eAED,UAAU;;;;WAId,aAAa;;;;UAId,MAAM;;eAED,UAAU;;;WAGd,aAAa;;;UAsBd,MAAM;;eAED,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;;UAGzB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,eAAe;;;;UAGlB,MAAM;;eAED,UAAU;;;WAGd,aAAa;;;;UAId,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAId,QAAQ;;;;;;eAYH,UAAU;;;;WAId,aAAa;IAEvB,CAAA;AAED,eAAO,MAAM,aAAa;;UAGhB,MAAM;;eAID,UAAU;;;;WAId,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,8BAA8B;;UAGjC,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAYvB,CAAA;AAED,eAAO,MAAM,cAAc;;;UAGjB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;;;UAkCd,QAAQ;;;;;;eAYH,QAAQ;;;;WAIZ,aAAa;IAuBvB,CAAA;AAED,eAAO,MAAM,eAAe;;UAGlB,MAAM;;eAED,QAAQ;;;;WAIZ,aAAa;GAEvB,CAAA;AAED,eAAO,MAAM,sBAAsB;eAEpB,QAAQ;;UAEb,MAAM;;;WAIL,aAAa;;GAYvB,CAAA"}
|
|
@@ -166,11 +166,28 @@ exports.infrastructureQuestions = [
|
|
|
166
166
|
scope: 'ENVIRONMENT'
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
|
-
name: '
|
|
169
|
+
name: 'kubeMasterNode',
|
|
170
170
|
type: 'text',
|
|
171
|
-
message: `Kubernetes
|
|
171
|
+
message: `Kubernetes master node hostnames or IP (default: auto-detect)`,
|
|
172
|
+
valueType: 'VARIABLE',
|
|
173
|
+
valueLabel: 'KUBE_MASTER_NODE',
|
|
174
|
+
initial: process.env.KUBE_MASTER_NODE,
|
|
175
|
+
scope: 'ENVIRONMENT'
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'kubeWorkerNodes',
|
|
179
|
+
type: 'text',
|
|
180
|
+
message: `Kubernetes worker node hostnames or IPs (comma-separated, default: no worker nodes)`,
|
|
181
|
+
valueType: 'VARIABLE',
|
|
182
|
+
valueLabel: 'KUBE_WORKER_NODES',
|
|
183
|
+
initial: process.env.KUBE_WORKER_NODES || '',
|
|
184
|
+
scope: 'ENVIRONMENT'
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'kubeApiHost',
|
|
188
|
+
type: 'text',
|
|
189
|
+
message: `Kubernetes API endpoint IP (default: KUBE_MASTER_NODE)`,
|
|
172
190
|
valueType: 'VARIABLE',
|
|
173
|
-
// validate: notEmpty,
|
|
174
191
|
valueLabel: 'KUBE_API_HOST',
|
|
175
192
|
initial: process.env.KUBE_API_HOST,
|
|
176
193
|
scope: 'ENVIRONMENT'
|
|
@@ -185,16 +202,6 @@ exports.infrastructureQuestions = [
|
|
|
185
202
|
initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
|
|
186
203
|
scope: 'ENVIRONMENT'
|
|
187
204
|
},
|
|
188
|
-
{
|
|
189
|
-
name: 'kubeWorkerNodes',
|
|
190
|
-
type: 'text',
|
|
191
|
-
message: `Kubernetes worker node hostnames or IPs (comma-separated, default: no worker nodes)`,
|
|
192
|
-
valueType: 'VARIABLE',
|
|
193
|
-
// validate: notEmpty,
|
|
194
|
-
valueLabel: 'KUBE_WORKER_NODES',
|
|
195
|
-
initial: process.env.KUBE_WORKER_NODES || '',
|
|
196
|
-
scope: 'ENVIRONMENT'
|
|
197
|
-
}
|
|
198
205
|
];
|
|
199
206
|
exports.staticSSLCertQuestions = [
|
|
200
207
|
{
|
|
@@ -224,7 +231,6 @@ exports.backupQuestions = [
|
|
|
224
231
|
type: 'text',
|
|
225
232
|
message: `Please enter backup server host/IP address, (default: no backup):`,
|
|
226
233
|
valueType: 'VARIABLE',
|
|
227
|
-
// validate: notEmpty,
|
|
228
234
|
valueLabel: 'BACKUP_HOST',
|
|
229
235
|
initial: process.env.BACKUP_HOST || '',
|
|
230
236
|
scope: 'ENVIRONMENT'
|
|
@@ -34,7 +34,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const core_1 = require("@octokit/core");
|
|
37
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
38
37
|
const kleur_1 = __importDefault(require("kleur"));
|
|
39
38
|
const prompts_1 = __importDefault(require("prompts"));
|
|
40
39
|
function confirm(options) {
|
|
@@ -49,6 +48,12 @@ function select(options) {
|
|
|
49
48
|
return inquirer.select(options);
|
|
50
49
|
});
|
|
51
50
|
}
|
|
51
|
+
function input(options) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const inquirer = yield import('@inquirer/prompts');
|
|
54
|
+
return inquirer.input(options);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
52
57
|
const github_1 = require("./github");
|
|
53
58
|
const derived_variables_1 = require("./derived-variables");
|
|
54
59
|
const utils_1 = require("./utils");
|
|
@@ -105,7 +110,7 @@ function getAnswers(existingValues) {
|
|
|
105
110
|
});
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
|
-
function promptAndStoreAnswer(
|
|
113
|
+
function promptAndStoreAnswer(questions, existingValues) {
|
|
109
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
115
|
(0, logger_1.log)('');
|
|
111
116
|
const processedQuestions = questions.flatMap((question) => {
|
|
@@ -158,7 +163,6 @@ function promptAndStoreAnswer(environment, questions, existingValues) {
|
|
|
158
163
|
}
|
|
159
164
|
});
|
|
160
165
|
ALL_ANSWERS.push(result);
|
|
161
|
-
(0, utils_1.storeSecrets)(environment, getAnswers(existingValues));
|
|
162
166
|
const existingValuesForQuestions = questions
|
|
163
167
|
// Only variables can have previous values we can use
|
|
164
168
|
.filter((question) => question.valueType === 'VARIABLE')
|
|
@@ -171,14 +175,14 @@ function promptAndStoreAnswer(environment, questions, existingValues) {
|
|
|
171
175
|
}
|
|
172
176
|
ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOtherQuestions, ...questions_1.dockerhubQuestions, ...questions_1.diskQuestions, ...questions_1.infrastructureQuestions, ...questions_1.backupQuestions, ...questions_1.countryQuestions, ...questions_1.databaseAndMonitoringQuestions, ...questions_1.emailQuestions, ...questions_1.sentryQuestions, ...derived_variables_1.derivedVariables, ...questions_1.metabaseAdminQuestions);
|
|
173
177
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
174
|
-
var _a, _b, _c;
|
|
178
|
+
var _a, _b, _c, _d;
|
|
175
179
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Github'), '\n');
|
|
176
180
|
const { githubOrganisation, githubRepository } = yield (0, prompts_1.default)(questions_1.githubQuestions.map(questionToPrompt), {
|
|
177
181
|
onCancel: () => {
|
|
178
182
|
process.exit(1);
|
|
179
183
|
}
|
|
180
184
|
});
|
|
181
|
-
const { githubToken } = yield promptAndStoreAnswer(
|
|
185
|
+
const { githubToken } = yield promptAndStoreAnswer(questions_1.githubTokenQuestion, []);
|
|
182
186
|
const octokit = new core_1.Octokit({
|
|
183
187
|
auth: githubToken
|
|
184
188
|
});
|
|
@@ -238,10 +242,6 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
238
242
|
if (!environment) {
|
|
239
243
|
process.exit(1);
|
|
240
244
|
}
|
|
241
|
-
// Read users .env file based on the environment name they gave above, e.g. .env.production
|
|
242
|
-
dotenv_1.default.config({
|
|
243
|
-
path: `${process.cwd()}/.env.${environment}`
|
|
244
|
-
});
|
|
245
245
|
yield (0, github_1.createEnvironment)(octokit, environment, githubOrganisation, githubRepository);
|
|
246
246
|
const repositoryId = yield (0, github_1.getRepositoryId)(octokit, githubOrganisation, githubRepository);
|
|
247
247
|
const existingRepositorySecrets = yield (0, github_1.listRepositorySecrets)(octokit, githubOrganisation, githubRepository);
|
|
@@ -262,12 +262,12 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
262
262
|
(0, logger_1.log)('\n', kleur_1.default
|
|
263
263
|
.yellow()
|
|
264
264
|
.bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
|
|
265
|
-
yield promptAndStoreAnswer(
|
|
265
|
+
yield promptAndStoreAnswer(questions_1.githubOtherQuestions, existingValues);
|
|
266
266
|
}
|
|
267
267
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Docker Hub'));
|
|
268
|
-
yield promptAndStoreAnswer(
|
|
268
|
+
yield promptAndStoreAnswer(questions_1.dockerhubQuestions, existingValues);
|
|
269
269
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
|
|
270
|
-
const infrastructure = yield promptAndStoreAnswer(
|
|
270
|
+
const infrastructure = yield promptAndStoreAnswer(questions_1.infrastructureQuestions, existingValues);
|
|
271
271
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes
|
|
272
272
|
? infrastructure.kubeWorkerNodes.split(',').map((ip) => ip.trim())
|
|
273
273
|
: [];
|
|
@@ -309,7 +309,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
309
309
|
}
|
|
310
310
|
if (enableEncryption && !encryption_key_defined && !environment_exists) {
|
|
311
311
|
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow(' Disk encryption is enabled'));
|
|
312
|
-
yield promptAndStoreAnswer(
|
|
312
|
+
yield promptAndStoreAnswer(questions_1.diskQuestions, existingValues);
|
|
313
313
|
}
|
|
314
314
|
else {
|
|
315
315
|
if (!enableEncryption && !encryption_key_defined && environment_exists) {
|
|
@@ -331,7 +331,8 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
331
331
|
let backupHost = ((_a = (0, utils_1.findExistingValue)('BACKUP_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _a === void 0 ? void 0 : _a.value) || '';
|
|
332
332
|
let backupType = '';
|
|
333
333
|
let restoreEnvironmentName = (_b = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _b === void 0 ? void 0 : _b.value;
|
|
334
|
-
let
|
|
334
|
+
let restoreHost = ((_c = (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _c === void 0 ? void 0 : _c.value) || '';
|
|
335
|
+
let restoreType = ((_d = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _d === void 0 ? void 0 : _d.value) ||
|
|
335
336
|
process.env.RESTORE_ENVIRONMENT_MODE ||
|
|
336
337
|
'dump';
|
|
337
338
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Backup'));
|
|
@@ -346,7 +347,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
346
347
|
let backupHostPrivateKey = '';
|
|
347
348
|
let backupHostPublicKey = '';
|
|
348
349
|
if (configureBackup) {
|
|
349
|
-
const backupAnswers = yield promptAndStoreAnswer(
|
|
350
|
+
const backupAnswers = yield promptAndStoreAnswer(questions_1.backupQuestions, existingValues);
|
|
350
351
|
const backupHostPrivateKeyExists = (0, utils_1.findExistingValue)('BACKUP_HOST_PRIVATE_KEY', 'SECRET', 'ENVIRONMENT', existingValues);
|
|
351
352
|
backupType = backupAnswers.backupType;
|
|
352
353
|
backupHost = backupAnswers.backupHost || backupHost;
|
|
@@ -393,16 +394,20 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
393
394
|
}
|
|
394
395
|
]
|
|
395
396
|
});
|
|
397
|
+
restoreHost = yield input({
|
|
398
|
+
message: 'What is the host/IP address of the restore backup server?',
|
|
399
|
+
default: restoreHost
|
|
400
|
+
});
|
|
396
401
|
}
|
|
397
402
|
else {
|
|
398
403
|
(0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Restore is disabled'));
|
|
399
404
|
}
|
|
400
405
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Monitoring'));
|
|
401
|
-
yield promptAndStoreAnswer(
|
|
406
|
+
yield promptAndStoreAnswer(questions_1.databaseAndMonitoringQuestions, existingValues);
|
|
402
407
|
const sentryDSNExists = (0, utils_1.findExistingValue)('SENTRY_DSN', 'SECRET', 'ENVIRONMENT', existingValues);
|
|
403
408
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Sentry'));
|
|
404
409
|
if (sentryDSNExists) {
|
|
405
|
-
yield promptAndStoreAnswer(
|
|
410
|
+
yield promptAndStoreAnswer(questions_1.sentryQuestions, existingValues);
|
|
406
411
|
}
|
|
407
412
|
else {
|
|
408
413
|
const { useSentry } = yield (0, prompts_1.default)([
|
|
@@ -414,13 +419,13 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
414
419
|
}
|
|
415
420
|
]);
|
|
416
421
|
if (useSentry) {
|
|
417
|
-
yield promptAndStoreAnswer(
|
|
422
|
+
yield promptAndStoreAnswer(questions_1.sentryQuestions, existingValues);
|
|
418
423
|
}
|
|
419
424
|
}
|
|
420
425
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('METABASE ADMIN'));
|
|
421
|
-
yield promptAndStoreAnswer(
|
|
426
|
+
yield promptAndStoreAnswer(questions_1.metabaseAdminQuestions, existingValues);
|
|
422
427
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('SMTP'));
|
|
423
|
-
yield promptAndStoreAnswer(
|
|
428
|
+
yield promptAndStoreAnswer(questions_1.emailQuestions, existingValues);
|
|
424
429
|
const allAnswers = ALL_ANSWERS.reduce((acc, answer) => {
|
|
425
430
|
return Object.assign(Object.assign({}, acc), answer);
|
|
426
431
|
});
|
|
@@ -557,6 +562,13 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
557
562
|
value: answerOrExisting(restoreEnvironmentName, (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
|
|
558
563
|
didExist: (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues),
|
|
559
564
|
scope: 'ENVIRONMENT'
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
type: 'VARIABLE',
|
|
568
|
+
name: 'RESTORE_HOST',
|
|
569
|
+
value: answerOrExisting(restoreHost, (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
|
|
570
|
+
didExist: (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues),
|
|
571
|
+
scope: 'ENVIRONMENT'
|
|
560
572
|
}
|
|
561
573
|
];
|
|
562
574
|
if (enableEncryption) {
|
|
@@ -591,7 +603,6 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
591
603
|
// Only update values that changed
|
|
592
604
|
(variable.type !== 'VARIABLE' ||
|
|
593
605
|
variable.value !== ((_a = variable.didExist) === null || _a === void 0 ? void 0 : _a.value)); });
|
|
594
|
-
(0, utils_1.storeSecrets)(environment, updates);
|
|
595
606
|
/*
|
|
596
607
|
* List out all updates to the variables and confirm with the user
|
|
597
608
|
*/
|
|
@@ -670,6 +681,10 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
670
681
|
.concat(updatedVariables).length === 0) {
|
|
671
682
|
process.exit(0);
|
|
672
683
|
}
|
|
684
|
+
(0, logger_1.log)(kleur_1.default
|
|
685
|
+
.bold()
|
|
686
|
+
.red("⚠️ COPY THESE NOW INTO A PASSWORD MANAGER — YOU WON'T SEE THEM AGAIN"));
|
|
687
|
+
(0, logger_1.log)('');
|
|
673
688
|
const saveChanges = yield confirm({
|
|
674
689
|
message: 'Do you want to continue?',
|
|
675
690
|
default: true
|
|
@@ -717,7 +732,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
717
732
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Running configuration files updates'));
|
|
718
733
|
(0, templates_1.generateInventory)(environment, {
|
|
719
734
|
kube_worker_nodes: kubeWorkerNodes,
|
|
720
|
-
kube_api_host: infrastructure.
|
|
735
|
+
kube_api_host: infrastructure.kubeApiHost || '',
|
|
721
736
|
backup_host: backupHost || '',
|
|
722
737
|
users: users
|
|
723
738
|
});
|
|
@@ -728,12 +743,14 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
|
|
|
728
743
|
// Hardcode like this blocks us from being generic:
|
|
729
744
|
// https://github.com/opencrvs/opencrvs-core/issues/11171
|
|
730
745
|
two_fa_enabled: environment !== 'production' ? false : true,
|
|
731
|
-
|
|
746
|
+
traefik_mode: traefikConfOption,
|
|
732
747
|
restore_enabled: restoreEnvironmentName ? true : false,
|
|
733
748
|
restore_environment_name: restoreEnvironmentName || '',
|
|
734
749
|
restore_type: restoreType,
|
|
735
|
-
|
|
736
|
-
|
|
750
|
+
restore_host: restoreHost || '',
|
|
751
|
+
backup_enabled: configureBackup ? true : false,
|
|
752
|
+
backup_type: backupType,
|
|
753
|
+
backup_host: backupHost || ''
|
|
737
754
|
});
|
|
738
755
|
let addon_message = kubeWorkerNodes.length > 0 || configureBackup
|
|
739
756
|
? '--------------------------------------------------------------------------------------------\n' +
|
|
@@ -770,6 +787,7 @@ ${addon_message}
|
|
|
770
787
|
${kleur_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')}
|
|
771
788
|
${kleur_1.default.yellow('Please KINDLY read hints above')}
|
|
772
789
|
`);
|
|
773
|
-
(0, logger_1.log)('\nAll variables
|
|
774
|
-
|
|
790
|
+
(0, logger_1.log)('\nAll secrets and variables were printed above.', kleur_1.default
|
|
791
|
+
.bold()
|
|
792
|
+
.yellow('Store them in a password manager — they are not saved to disk.'));
|
|
775
793
|
}))();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AA0BA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAepD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsBzE"}
|
|
@@ -24,7 +24,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.getUsers = getUsers;
|
|
28
27
|
exports.extractAndModifyUsers = extractAndModifyUsers;
|
|
29
28
|
exports.dockerManagerFirst = dockerManagerFirst;
|
|
30
29
|
exports.extractBackupNode = extractBackupNode;
|
|
@@ -40,13 +39,6 @@ const handlebars_1 = __importDefault(require("handlebars"));
|
|
|
40
39
|
handlebars_1.default.registerHelper('data_label_idx', function (value) {
|
|
41
40
|
return parseInt(value) + 2;
|
|
42
41
|
});
|
|
43
|
-
function getUsers(data) {
|
|
44
|
-
var _a, _b;
|
|
45
|
-
if (!((_b = (_a = data === null || data === void 0 ? void 0 : data.all) === null || _a === void 0 ? void 0 : _a.vars) === null || _b === void 0 ? void 0 : _b.users)) {
|
|
46
|
-
return { users: [] };
|
|
47
|
-
}
|
|
48
|
-
return data.all.vars.users;
|
|
49
|
-
}
|
|
50
42
|
// START: TEMPORAL SECTION FOR TRANSITION FROM DOCKER SWARM TO K8s
|
|
51
43
|
// Extract users from the old inventory
|
|
52
44
|
// Docker swarm format to new
|
|
@@ -56,6 +48,9 @@ function extractAndModifyUsers(data) {
|
|
|
56
48
|
return { users: [] };
|
|
57
49
|
}
|
|
58
50
|
const users = data.all.vars.users.map((user) => {
|
|
51
|
+
if (user.role) {
|
|
52
|
+
return user;
|
|
53
|
+
}
|
|
59
54
|
const { sudoer } = user, rest = __rest(user, ["sudoer"]);
|
|
60
55
|
return Object.assign(Object.assign({}, rest), { role: sudoer ? 'admin' : 'operator' });
|
|
61
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-workflows.d.ts","sourceRoot":"","sources":["../../src/environment/update-workflows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update-workflows.d.ts","sourceRoot":"","sources":["../../src/environment/update-workflows.ts"],"names":[],"mappings":"AAmIA,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAgDhE"}
|
|
@@ -121,6 +121,10 @@ function updateWorkflows(envList, config) {
|
|
|
121
121
|
var _a, _b, _c, _d;
|
|
122
122
|
const { workflows } = config;
|
|
123
123
|
for (const workflowPath of workflows) {
|
|
124
|
+
if (!(0, fs_1.existsSync)(workflowPath)) {
|
|
125
|
+
(0, logger_1.log)(` ↷ Skipped ${workflowPath} (not found in this repository)`);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
124
128
|
try {
|
|
125
129
|
const fileContents = (0, fs_1.readFileSync)(workflowPath, 'utf8');
|
|
126
130
|
// Verify the file is valid YAML and has the expected structure
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { Secret, Variable } from './github';
|
|
2
|
-
import { Answers } from './custom-types';
|
|
3
2
|
export declare function generateLongPassword(): string;
|
|
4
3
|
export declare function findExistingValue<T extends string>(name: string, type: T, scope: 'ENVIRONMENT' | 'REPOSITORY', existingValues: Array<Secret | Variable>): (T extends 'SECRET' ? Secret : T extends 'VARIABLE' ? Variable : never) | undefined;
|
|
5
|
-
/**
|
|
6
|
-
* Merges and stores secrets in `.env.{environment}` file.
|
|
7
|
-
* Updates existing variables, preserves unchanged ones, adds new ones.
|
|
8
|
-
*
|
|
9
|
-
* @param environment - Environment name (e.g., 'production')
|
|
10
|
-
* @param answers - Variables to update: `[{ name: 'KEY', value: 'val' }]`
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* storeSecrets('prod', [{ name: 'API_KEY', value: 'abc123' }]);
|
|
14
|
-
*/
|
|
15
|
-
export declare function storeSecrets(environment: string, answers: Answers): void;
|
|
16
4
|
export declare function readYamlFile(filePath: any): any;
|
|
17
5
|
export declare function writeYamlFile(filePath: string, data: any): void;
|
|
18
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/environment/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/environment/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE3C,wBAAgB,oBAAoB,WAMnC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,aAAa,GAAG,YAAY,EACnC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAMpC,CAAC,CAAC,SAAS,QAAQ,GAAG,MAAM,GAAG,CAAC,SAAS,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC,GACvE,SAAS,CACd;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CAG/C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,QAcxD"}
|
|
@@ -48,12 +48,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.generateLongPassword = generateLongPassword;
|
|
50
50
|
exports.findExistingValue = findExistingValue;
|
|
51
|
-
exports.storeSecrets = storeSecrets;
|
|
52
51
|
exports.readYamlFile = readYamlFile;
|
|
53
52
|
exports.writeYamlFile = writeYamlFile;
|
|
54
|
-
const fs_1 =
|
|
53
|
+
const fs_1 = __importDefault(require("fs"));
|
|
55
54
|
const yaml = __importStar(require("js-yaml"));
|
|
56
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
57
55
|
function generateLongPassword() {
|
|
58
56
|
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
59
57
|
let result = '';
|
|
@@ -64,31 +62,6 @@ function generateLongPassword() {
|
|
|
64
62
|
function findExistingValue(name, type, scope, existingValues) {
|
|
65
63
|
return existingValues.find((value) => value.name === name && value.type === type && value.scope === scope);
|
|
66
64
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Merges and stores secrets in `.env.{environment}` file.
|
|
69
|
-
* Updates existing variables, preserves unchanged ones, adds new ones.
|
|
70
|
-
*
|
|
71
|
-
* @param environment - Environment name (e.g., 'production')
|
|
72
|
-
* @param answers - Variables to update: `[{ name: 'KEY', value: 'val' }]`
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* storeSecrets('prod', [{ name: 'API_KEY', value: 'abc123' }]);
|
|
76
|
-
*/
|
|
77
|
-
function storeSecrets(environment, answers) {
|
|
78
|
-
let envConfig = {};
|
|
79
|
-
try {
|
|
80
|
-
envConfig = dotenv_1.default.parse((0, fs_1.readFileSync)(`${process.cwd()}/.env.${environment}`));
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
envConfig = {};
|
|
84
|
-
}
|
|
85
|
-
const linesFromAnswers = answers.map((update) => `${update.name}="${update.value}"`);
|
|
86
|
-
const linesFromEnvConfig = Object.entries(envConfig)
|
|
87
|
-
.filter(([name]) => !answers.find((update) => update.name === name))
|
|
88
|
-
.map(([name, value]) => `${name}="${value}"`);
|
|
89
|
-
const allLines = [...linesFromEnvConfig, ...linesFromAnswers].sort();
|
|
90
|
-
(0, fs_1.writeFileSync)(`.env.${environment}`, allLines.join('\n'));
|
|
91
|
-
}
|
|
92
65
|
function readYamlFile(filePath) {
|
|
93
66
|
const fileContent = fs_1.default.readFileSync(filePath, 'utf8');
|
|
94
67
|
return yaml.load(fileContent);
|