@opencrvs/toolkit 2.1.0 → 2.1.1-rc.52250d8
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/create-countryconfig/package.json +1 -1
- package/dist/cli.js +230 -116
- package/dist/environment/derived-variables.d.ts +18 -0
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +22 -1
- package/dist/environment/questions.d.ts +1 -1
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +8 -5
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +29 -10
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +95 -32
- package/dist/migrations/v2.1/remove-typings-from-dockerfile.d.ts +3 -0
- package/dist/migrations/v2.1/remove-typings-from-dockerfile.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-typings-from-dockerfile.js +121 -0
- package/dist/templates/countryconfig-template/Tiltfile +2 -2
- package/opencrvs-toolkit-2.1.1-rc.52250d8.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.1.0.tgz +0 -0
|
@@ -112,11 +112,29 @@ export declare const derivedVariables: readonly [{
|
|
|
112
112
|
readonly valueType: 'VARIABLE';
|
|
113
113
|
readonly type: 'disabled';
|
|
114
114
|
readonly scope: 'ENVIRONMENT';
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: 'RESTORE_ENVIRONMENT_MODE';
|
|
117
|
+
readonly valueLabel: 'RESTORE_ENVIRONMENT_MODE';
|
|
118
|
+
readonly valueType: 'VARIABLE';
|
|
119
|
+
readonly type: 'disabled';
|
|
120
|
+
readonly scope: 'ENVIRONMENT';
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: 'RESTORE_HOST';
|
|
123
|
+
readonly valueLabel: 'RESTORE_HOST';
|
|
124
|
+
readonly valueType: 'VARIABLE';
|
|
125
|
+
readonly type: 'disabled';
|
|
126
|
+
readonly scope: 'ENVIRONMENT';
|
|
115
127
|
}, {
|
|
116
128
|
readonly name: 'NOTIFICATION_TRANSPORT';
|
|
117
129
|
readonly valueLabel: 'NOTIFICATION_TRANSPORT';
|
|
118
130
|
readonly valueType: 'VARIABLE';
|
|
119
131
|
readonly type: 'disabled';
|
|
120
132
|
readonly scope: 'ENVIRONMENT';
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: 'TWO_FA_ENABLED';
|
|
135
|
+
readonly valueLabel: 'TWO_FA_ENABLED';
|
|
136
|
+
readonly valueType: 'VARIABLE';
|
|
137
|
+
readonly type: 'disabled';
|
|
138
|
+
readonly scope: 'ENVIRONMENT';
|
|
121
139
|
}];
|
|
122
140
|
//# sourceMappingURL=derived-variables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived-variables.d.ts","sourceRoot":"","sources":["../../src/environment/derived-variables.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB;aAEzB,IAAI,EAAE,gBAAgB;aACtB,UAAU,EAAE,gBAAgB;aAC5B,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,qBAAqB;aAC3B,UAAU,EAAE,qBAAqB;aACjC,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,cAAc;aACpB,UAAU,EAAE,cAAc;aAC1B,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,kCAAkC;aACxC,UAAU,EAAE,kCAAkC;aAC9C,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,gBAAgB;aACtB,UAAU,EAAE,gBAAgB;aAC5B,SAAS,EAAE,UAAU;aACrB,IAA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UAAU,EAAE,wBAAwB;aACpC,SAAS,EAAE,QAAQ;aACnB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,YAAY;;aAGnB,IAAI,EAAE,8BAA8B;aACpC,UAAU,EAAE,8BAA8B;aAC1C,SAAS,EAAE,QAAQ;aACnB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,yBAAyB;aAC/B,UAAU,EAAE,yBAAyB;aACrC,SAAS,EAAE,QAAQ;aACnB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,wBAAwB;aAC9B,UAAU,EAAE,wBAAwB;aACpC,SAAS,EAAE,QAAQ;aACnB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,0BAA0B;aAChC,UAAU,EAAE,0BAA0B;aACtC,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,wBAAwB;aAC9B,UAAU,EAAE,wBAAwB;aACpC,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;EAEd,CAAA"}
|
|
1
|
+
{"version":3,"file":"derived-variables.d.ts","sourceRoot":"","sources":["../../src/environment/derived-variables.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB;aAEzB,IAAI,EAAE,gBAAgB;aACtB,UAAU,EAAE,gBAAgB;aAC5B,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,qBAAqB;aAC3B,UAAU,EAAE,qBAAqB;aACjC,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;;aAGpB,IAAI,EAAE,cAAc;aACpB,UAAU,EAAE,cAAc;aAC1B,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KA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B,IAAI,EAAE,gBAAgB;aACtB,UAAU,EAAE,gBAAgB;aAC5B,SAAS,EAAE,UAAU;aACrB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,aAAa;EAEd,CAAA"}
|
|
@@ -145,11 +145,32 @@ exports.derivedVariables = [
|
|
|
145
145
|
type: 'disabled',
|
|
146
146
|
scope: 'ENVIRONMENT'
|
|
147
147
|
},
|
|
148
|
+
{
|
|
149
|
+
name: 'RESTORE_ENVIRONMENT_MODE',
|
|
150
|
+
valueLabel: 'RESTORE_ENVIRONMENT_MODE',
|
|
151
|
+
valueType: 'VARIABLE',
|
|
152
|
+
type: 'disabled',
|
|
153
|
+
scope: 'ENVIRONMENT'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'RESTORE_HOST',
|
|
157
|
+
valueLabel: 'RESTORE_HOST',
|
|
158
|
+
valueType: 'VARIABLE',
|
|
159
|
+
type: 'disabled',
|
|
160
|
+
scope: 'ENVIRONMENT'
|
|
161
|
+
},
|
|
148
162
|
{
|
|
149
163
|
name: 'NOTIFICATION_TRANSPORT',
|
|
150
164
|
valueLabel: 'NOTIFICATION_TRANSPORT',
|
|
151
165
|
valueType: 'VARIABLE',
|
|
152
166
|
type: 'disabled',
|
|
153
167
|
scope: 'ENVIRONMENT'
|
|
154
|
-
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'TWO_FA_ENABLED',
|
|
171
|
+
valueLabel: 'TWO_FA_ENABLED',
|
|
172
|
+
valueType: 'VARIABLE',
|
|
173
|
+
type: 'disabled',
|
|
174
|
+
scope: 'ENVIRONMENT'
|
|
175
|
+
},
|
|
155
176
|
];
|
|
@@ -138,7 +138,7 @@ export declare const diskQuestions: {
|
|
|
138
138
|
type: 'text';
|
|
139
139
|
message: string;
|
|
140
140
|
valueType: 'VARIABLE';
|
|
141
|
-
validate:
|
|
141
|
+
validate: (value: string) => "Enter a size in gigabytes, e.g. 200g" | true;
|
|
142
142
|
valueLabel: string;
|
|
143
143
|
initial: string;
|
|
144
144
|
scope: 'ENVIRONMENT';
|
|
@@ -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;;;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;;
|
|
1
|
+
{"version":3,"file":"questions.d.ts","sourceRo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AAc;;;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"}
|
|
@@ -201,7 +201,7 @@ exports.infrastructureQuestions = [
|
|
|
201
201
|
valueLabel: 'KUBE_API_ALLOWED_CIDRS',
|
|
202
202
|
initial: process.env.KUBE_API_ALLOWED_CIDRS || '',
|
|
203
203
|
scope: 'ENVIRONMENT'
|
|
204
|
-
}
|
|
204
|
+
}
|
|
205
205
|
];
|
|
206
206
|
exports.staticSSLCertQuestions = [
|
|
207
207
|
{
|
|
@@ -270,11 +270,14 @@ exports.diskQuestions = [
|
|
|
270
270
|
{
|
|
271
271
|
name: 'diskSpace',
|
|
272
272
|
type: 'text',
|
|
273
|
-
message:
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
message: [
|
|
274
|
+
'How much disk space should be reserved for OpenCRVS data on each node? (e.g. 200g)',
|
|
275
|
+
'A fixed-size encrypted volume of this size is created on every node and cannot be resized later.',
|
|
276
|
+
kleur_1.default.red('DO NOT USE ALL DISK SPACE FOR OPENCRVS!'),
|
|
277
|
+
'Each node needs this much free space on its root partition, plus 50g or 10% of this size, whichever is larger.'
|
|
278
|
+
].join('\n'),
|
|
276
279
|
valueType: 'VARIABLE',
|
|
277
|
-
validate:
|
|
280
|
+
validate: (value) => /^\d+g$/i.test(value.trim()) || 'Enter a size in gigabytes, e.g. 200g',
|
|
278
281
|
valueLabel: 'DISK_SPACE',
|
|
279
282
|
initial: process.env.DISK_SPACE || '200g',
|
|
280
283
|
scope: 'ENVIRONMENT'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"AAwSA,wBAAsB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"setup-environment.d.ts","sourceRoot":"","sources":["../../src/environment/setup-environment.ts"],"names":[],"mappings":"AAwSA,wBAAsB,mBAAmB,kBA+nCxC"}
|
|
@@ -239,16 +239,6 @@ function runSetupEnvironment() {
|
|
|
239
239
|
]
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
-
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
|
|
243
|
-
const two_fa_enabled = yield confirm({
|
|
244
|
-
message: 'Enable two-factor authentication (2FA)? This should be enabled for any environment that hosts PII data.',
|
|
245
|
-
default: process.env.TWO_FA_ENABLED
|
|
246
|
-
? process.env.TWO_FA_ENABLED === 'true'
|
|
247
|
-
: environment_type === 'production'
|
|
248
|
-
});
|
|
249
|
-
if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
|
|
250
|
-
(0, logger_1.warn)('2FA is disabled on a production-like environment. Logins will accept the fixed test code 000000, exposing real citizen data. Only do this if you know what you are doing.');
|
|
251
|
-
}
|
|
252
242
|
const environment_exists = existingEnvironments
|
|
253
243
|
.map((e) => e.trim())
|
|
254
244
|
.includes(environment);
|
|
@@ -277,6 +267,18 @@ function runSetupEnvironment() {
|
|
|
277
267
|
.bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
|
|
278
268
|
yield promptAndStoreAnswer(questions_1.githubOtherQuestions, existingValues);
|
|
279
269
|
}
|
|
270
|
+
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Two-factor authentication (2FA)'));
|
|
271
|
+
const existingTwoFaEnabled = (0, utils_1.findExistingValue)('TWO_FA_ENABLED', 'VARIABLE', 'ENVIRONMENT', existingValues);
|
|
272
|
+
const twoFaDefault = process.env.TWO_FA_ENABLED || (existingTwoFaEnabled === null || existingTwoFaEnabled === void 0 ? void 0 : existingTwoFaEnabled.value);
|
|
273
|
+
const two_fa_enabled = yield confirm({
|
|
274
|
+
message: 'Enable two-factor authentication (2FA)? This should be enabled for any environment that hosts PII data.',
|
|
275
|
+
default: twoFaDefault
|
|
276
|
+
? twoFaDefault === 'true'
|
|
277
|
+
: environment_type === 'production'
|
|
278
|
+
});
|
|
279
|
+
if (!two_fa_enabled && ['production', 'staging'].includes(environment_type)) {
|
|
280
|
+
(0, logger_1.warn)('2FA is disabled on a production-like environment. Logins will accept the fixed test code 000000, exposing real citizen data. Only do this if you know what you are doing.');
|
|
281
|
+
}
|
|
280
282
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Docker Hub'));
|
|
281
283
|
yield promptAndStoreAnswer(questions_1.dockerhubQuestions, existingValues);
|
|
282
284
|
(0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
|
|
@@ -396,6 +398,7 @@ function runSetupEnvironment() {
|
|
|
396
398
|
});
|
|
397
399
|
restoreType = yield select({
|
|
398
400
|
message: `Select ${kleur_1.default.yellow().bold(restoreEnvironmentName)} environment backup mode`,
|
|
401
|
+
default: restoreType,
|
|
399
402
|
choices: [
|
|
400
403
|
{
|
|
401
404
|
name: 'Full dump (daily full database backup)',
|
|
@@ -467,6 +470,14 @@ function runSetupEnvironment() {
|
|
|
467
470
|
value: findExistingOrDefine('NOTIFICATION_TRANSPORT', 'VARIABLE', 'ENVIRONMENT', 'email'),
|
|
468
471
|
scope: 'ENVIRONMENT'
|
|
469
472
|
});
|
|
473
|
+
derivedUpdates.push({
|
|
474
|
+
name: 'TWO_FA_ENABLED',
|
|
475
|
+
type: 'VARIABLE',
|
|
476
|
+
didExist: existingTwoFaEnabled,
|
|
477
|
+
// Always stored, so the next run defaults to the current answer
|
|
478
|
+
value: two_fa_enabled ? 'true' : 'false',
|
|
479
|
+
scope: 'ENVIRONMENT'
|
|
480
|
+
});
|
|
470
481
|
derivedUpdates.push(...ssl_answers);
|
|
471
482
|
if (configureBackup) {
|
|
472
483
|
derivedUpdates.push({
|
|
@@ -582,6 +593,14 @@ function runSetupEnvironment() {
|
|
|
582
593
|
value: answerOrExisting(restoreHost, (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
|
|
583
594
|
didExist: (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues),
|
|
584
595
|
scope: 'ENVIRONMENT'
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
type: 'VARIABLE',
|
|
599
|
+
name: 'RESTORE_ENVIRONMENT_MODE',
|
|
600
|
+
// Only persist the mode when restore is configured
|
|
601
|
+
value: restoreEnvironmentName ? restoreType : '',
|
|
602
|
+
didExist: (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues),
|
|
603
|
+
scope: 'ENVIRONMENT'
|
|
585
604
|
}
|
|
586
605
|
];
|
|
587
606
|
if (enableEncryption) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/index.ts"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,OAAO,iBAcpD"}
|
|
@@ -257,20 +257,20 @@ function idOf(line) {
|
|
|
257
257
|
const comma = line.indexOf(",");
|
|
258
258
|
return comma === -1 ? line : line.slice(0, comma);
|
|
259
259
|
}
|
|
260
|
-
function readCsvFile(
|
|
261
|
-
if (!(0, import_fs.existsSync)(
|
|
260
|
+
function readCsvFile(path11) {
|
|
261
|
+
if (!(0, import_fs.existsSync)(path11)) {
|
|
262
262
|
return void 0;
|
|
263
263
|
}
|
|
264
|
-
const contents = (0, import_fs.readFileSync)(
|
|
264
|
+
const contents = (0, import_fs.readFileSync)(path11, "utf8");
|
|
265
265
|
const newline = contents.includes("\r\n") ? "\r\n" : "\n";
|
|
266
266
|
const trailingNewline = /\r?\n$/.test(contents);
|
|
267
267
|
const lines = contents.replace(/\r?\n$/, "").split(/\r?\n/);
|
|
268
268
|
const body = lines.slice(1).filter((line) => line !== "");
|
|
269
269
|
return { header: lines[0], body, newline, trailingNewline };
|
|
270
270
|
}
|
|
271
|
-
function writeCsvFile(
|
|
271
|
+
function writeCsvFile(path11, file) {
|
|
272
272
|
(0, import_fs.writeFileSync)(
|
|
273
|
-
|
|
273
|
+
path11,
|
|
274
274
|
[file.header, ...file.body].join(file.newline) + (file.trailingNewline ? file.newline : "")
|
|
275
275
|
);
|
|
276
276
|
}
|
|
@@ -1911,9 +1911,71 @@ async function main7() {
|
|
|
1911
1911
|
}
|
|
1912
1912
|
}
|
|
1913
1913
|
|
|
1914
|
+
// src/migrations/v2.1/remove-typings-from-dockerfile.ts
|
|
1915
|
+
var import_fs8 = require("fs");
|
|
1916
|
+
var import_path9 = __toESM(require("path"));
|
|
1917
|
+
var DOCKERFILE = "Dockerfile";
|
|
1918
|
+
var TYPINGS_PATH = /^(?:\.\/)?typings(?:\/.*)?$/;
|
|
1919
|
+
var continues = (line) => !/^\s*#/.test(line) && /\\[ \t]*\r?\n?$/.test(line);
|
|
1920
|
+
function contextSources(line, continued) {
|
|
1921
|
+
const [instruction, ...args] = line.split(/[\s"',[\]]+/).filter(Boolean);
|
|
1922
|
+
if (!/^(?:COPY|ADD)$/i.test(instruction) || args.some((arg) => arg.startsWith("--from"))) {
|
|
1923
|
+
return [];
|
|
1924
|
+
}
|
|
1925
|
+
const paths = args.filter((arg) => arg !== "\\" && !arg.startsWith("--"));
|
|
1926
|
+
return continued ? paths : paths.slice(0, -1);
|
|
1927
|
+
}
|
|
1928
|
+
function removeTypingsCopy(dockerfile) {
|
|
1929
|
+
const kept = [];
|
|
1930
|
+
const removed = [];
|
|
1931
|
+
const unresolved = [];
|
|
1932
|
+
let previousCarriesOn = false;
|
|
1933
|
+
const lines = dockerfile.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
1934
|
+
for (const line of lines) {
|
|
1935
|
+
const startsInstruction = !previousCarriesOn;
|
|
1936
|
+
const carriesOn = continues(line);
|
|
1937
|
+
previousCarriesOn = carriesOn;
|
|
1938
|
+
const sources = startsInstruction ? contextSources(line, carriesOn) : [];
|
|
1939
|
+
if (!sources.some((source) => TYPINGS_PATH.test(source))) {
|
|
1940
|
+
kept.push(line);
|
|
1941
|
+
} else if (sources.length === 1 && !carriesOn) {
|
|
1942
|
+
removed.push(line.trim());
|
|
1943
|
+
} else {
|
|
1944
|
+
kept.push(line);
|
|
1945
|
+
unresolved.push(line.trim());
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
return { contents: kept.join(""), removed, unresolved };
|
|
1949
|
+
}
|
|
1950
|
+
function removeTypingsFromDockerfile(cwd) {
|
|
1951
|
+
const dockerfilePath = import_path9.default.join(cwd, DOCKERFILE);
|
|
1952
|
+
if (!(0, import_fs8.existsSync)(dockerfilePath)) return;
|
|
1953
|
+
const { contents, removed, unresolved } = removeTypingsCopy(
|
|
1954
|
+
(0, import_fs8.readFileSync)(dockerfilePath, "utf8")
|
|
1955
|
+
);
|
|
1956
|
+
if (removed.length === 0 && unresolved.length === 0) return;
|
|
1957
|
+
console.log("\nUpdating the Dockerfile...\n");
|
|
1958
|
+
if (removed.length > 0) {
|
|
1959
|
+
(0, import_fs8.writeFileSync)(dockerfilePath, contents);
|
|
1960
|
+
}
|
|
1961
|
+
for (const instruction of removed) {
|
|
1962
|
+
console.log(
|
|
1963
|
+
` \u2713 ${DOCKERFILE}: removed '${instruction}', the Tiltfile no longer sends typings/ to the image build`
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
for (const instruction of unresolved) {
|
|
1967
|
+
console.warn(
|
|
1968
|
+
` \u26A0\uFE0F ${DOCKERFILE} still copies from typings/ ('${instruction}'), which the Tiltfile no longer sends to the image build; remove it by hand`
|
|
1969
|
+
);
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
async function main8() {
|
|
1973
|
+
removeTypingsFromDockerfile(process.cwd());
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1914
1976
|
// src/migrations/v2.1/rename-trigger-paths.ts
|
|
1915
1977
|
var import_ts_morph5 = require("ts-morph");
|
|
1916
|
-
var
|
|
1978
|
+
var import_path10 = __toESM(require("path"));
|
|
1917
1979
|
var PATH_PREFIX_RENAMES = {
|
|
1918
1980
|
"/triggers/user/": "/trigger/user/",
|
|
1919
1981
|
"/triggers/system/": "/trigger/system/"
|
|
@@ -1971,7 +2033,7 @@ function processFile2(filePath, project) {
|
|
|
1971
2033
|
const sourceFile = project.getSourceFile(filePath);
|
|
1972
2034
|
if (!sourceFile) return 0;
|
|
1973
2035
|
let renamedCount = 0;
|
|
1974
|
-
const relPath =
|
|
2036
|
+
const relPath = import_path10.default.relative(process.cwd(), filePath);
|
|
1975
2037
|
const candidates = sourceFile.getDescendantsOfKind(
|
|
1976
2038
|
import_ts_morph5.SyntaxKind.ObjectLiteralExpression
|
|
1977
2039
|
);
|
|
@@ -1988,7 +2050,7 @@ function processFile2(filePath, project) {
|
|
|
1988
2050
|
function warnAboutStalePaths(sourceFiles) {
|
|
1989
2051
|
const stale = [];
|
|
1990
2052
|
for (const sourceFile of sourceFiles) {
|
|
1991
|
-
const relPath =
|
|
2053
|
+
const relPath = import_path10.default.relative(process.cwd(), sourceFile.getFilePath());
|
|
1992
2054
|
const lines = sourceFile.getFullText().split("\n");
|
|
1993
2055
|
lines.forEach((line, index) => {
|
|
1994
2056
|
if (line.includes(STALE_PREFIX)) {
|
|
@@ -2003,8 +2065,8 @@ WARNING: ${stale.length} remaining '${STALE_PREFIX}' reference(s) need to be ren
|
|
|
2003
2065
|
);
|
|
2004
2066
|
console.log(stale.join("\n"));
|
|
2005
2067
|
}
|
|
2006
|
-
async function
|
|
2007
|
-
const srcDir =
|
|
2068
|
+
async function main9() {
|
|
2069
|
+
const srcDir = import_path10.default.join(process.cwd(), "src");
|
|
2008
2070
|
console.log(`Scanning for Hapi route configs in: ${srcDir}
|
|
2009
2071
|
`);
|
|
2010
2072
|
console.log("Active path renames:");
|
|
@@ -2013,7 +2075,7 @@ async function main8() {
|
|
|
2013
2075
|
}
|
|
2014
2076
|
console.log();
|
|
2015
2077
|
const project = new import_ts_morph5.Project({
|
|
2016
|
-
tsConfigFilePath:
|
|
2078
|
+
tsConfigFilePath: import_path10.default.resolve(srcDir, "../tsconfig.json"),
|
|
2017
2079
|
skipAddingFilesFromTsConfig: false
|
|
2018
2080
|
});
|
|
2019
2081
|
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
@@ -2040,7 +2102,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
2040
2102
|
for (const filePath of modifiedFiles) {
|
|
2041
2103
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
2042
2104
|
await sourceFile.save();
|
|
2043
|
-
console.log(` Saved: ${
|
|
2105
|
+
console.log(` Saved: ${import_path10.default.relative(process.cwd(), filePath)}`);
|
|
2044
2106
|
}
|
|
2045
2107
|
console.log(`
|
|
2046
2108
|
Done. Renamed ${totalRenamed} route path(s).`);
|
|
@@ -2049,21 +2111,21 @@ Done. Renamed ${totalRenamed} route path(s).`);
|
|
|
2049
2111
|
}
|
|
2050
2112
|
|
|
2051
2113
|
// src/migrations/v2.1/upgrade-tilt.ts
|
|
2052
|
-
var
|
|
2053
|
-
var
|
|
2114
|
+
var import_fs9 = require("fs");
|
|
2115
|
+
var import_path11 = __toESM(require("path"));
|
|
2054
2116
|
var COUNTRY_OWNED_DIR = "tilt/helm/";
|
|
2055
2117
|
var CHARTS_CHECKOUT_DIR = ".opencrvs-core-charts";
|
|
2056
2118
|
var IMAGE_NAME_PATTERN = /^countryconfig_image_name\s*=\s*(["'])(.*?)\1/m;
|
|
2057
2119
|
function writeIfChanged(cwd, relativePath, contents, mode) {
|
|
2058
|
-
const target =
|
|
2059
|
-
const existed = (0,
|
|
2060
|
-
if (existed && (0,
|
|
2120
|
+
const target = import_path11.default.join(cwd, relativePath);
|
|
2121
|
+
const existed = (0, import_fs9.existsSync)(target);
|
|
2122
|
+
if (existed && (0, import_fs9.readFileSync)(target, "utf8") === contents) {
|
|
2061
2123
|
return "unchanged";
|
|
2062
2124
|
}
|
|
2063
|
-
(0,
|
|
2064
|
-
(0,
|
|
2125
|
+
(0, import_fs9.mkdirSync)(import_path11.default.dirname(target), { recursive: true });
|
|
2126
|
+
(0, import_fs9.writeFileSync)(target, contents);
|
|
2065
2127
|
if (mode !== void 0) {
|
|
2066
|
-
(0,
|
|
2128
|
+
(0, import_fs9.chmodSync)(target, mode & 511);
|
|
2067
2129
|
}
|
|
2068
2130
|
return existed ? "updated" : "created";
|
|
2069
2131
|
}
|
|
@@ -2093,29 +2155,29 @@ function withIgnoreEntry(contents, line) {
|
|
|
2093
2155
|
`;
|
|
2094
2156
|
}
|
|
2095
2157
|
function ensureIgnored(cwd, file, line) {
|
|
2096
|
-
const target =
|
|
2097
|
-
const contents = (0,
|
|
2158
|
+
const target = import_path11.default.join(cwd, file);
|
|
2159
|
+
const contents = (0, import_fs9.existsSync)(target) ? (0, import_fs9.readFileSync)(target, "utf8") : "";
|
|
2098
2160
|
report(file, writeIfChanged(cwd, file, withIgnoreEntry(contents, line)));
|
|
2099
2161
|
}
|
|
2100
2162
|
function upgradeTilt(cwd, templateDir) {
|
|
2101
|
-
const tiltfilePath =
|
|
2102
|
-
const existingTiltfile = (0,
|
|
2163
|
+
const tiltfilePath = import_path11.default.join(cwd, "Tiltfile");
|
|
2164
|
+
const existingTiltfile = (0, import_fs9.existsSync)(tiltfilePath) ? (0, import_fs9.readFileSync)(tiltfilePath, "utf8") : void 0;
|
|
2103
2165
|
report(
|
|
2104
2166
|
"Tiltfile",
|
|
2105
2167
|
writeIfChanged(
|
|
2106
2168
|
cwd,
|
|
2107
2169
|
"Tiltfile",
|
|
2108
2170
|
renderTiltfile(
|
|
2109
|
-
(0,
|
|
2171
|
+
(0, import_fs9.readFileSync)(import_path11.default.join(templateDir, "Tiltfile"), "utf8"),
|
|
2110
2172
|
existingTiltfile
|
|
2111
2173
|
)
|
|
2112
2174
|
)
|
|
2113
2175
|
);
|
|
2114
2176
|
const templateFiles = listFiles(templateDir, "tilt");
|
|
2115
2177
|
for (const file of templateFiles) {
|
|
2116
|
-
const source =
|
|
2178
|
+
const source = import_path11.default.join(templateDir, file);
|
|
2117
2179
|
const countryOwned = file.startsWith(COUNTRY_OWNED_DIR);
|
|
2118
|
-
if (countryOwned && (0,
|
|
2180
|
+
if (countryOwned && (0, import_fs9.existsSync)(import_path11.default.join(cwd, file))) {
|
|
2119
2181
|
continue;
|
|
2120
2182
|
}
|
|
2121
2183
|
report(
|
|
@@ -2123,8 +2185,8 @@ function upgradeTilt(cwd, templateDir) {
|
|
|
2123
2185
|
writeIfChanged(
|
|
2124
2186
|
cwd,
|
|
2125
2187
|
file,
|
|
2126
|
-
(0,
|
|
2127
|
-
(0,
|
|
2188
|
+
(0, import_fs9.readFileSync)(source, "utf8"),
|
|
2189
|
+
(0, import_fs9.statSync)(source).mode
|
|
2128
2190
|
)
|
|
2129
2191
|
);
|
|
2130
2192
|
}
|
|
@@ -2144,7 +2206,7 @@ function upgradeTilt(cwd, templateDir) {
|
|
|
2144
2206
|
);
|
|
2145
2207
|
}
|
|
2146
2208
|
}
|
|
2147
|
-
async function
|
|
2209
|
+
async function main10() {
|
|
2148
2210
|
console.log("Upgrading the local Tilt setup...\n");
|
|
2149
2211
|
upgradeTilt(process.cwd(), findTemplateDir());
|
|
2150
2212
|
console.log(
|
|
@@ -2155,13 +2217,14 @@ async function main9() {
|
|
|
2155
2217
|
// src/migrations/v2.1/index.ts
|
|
2156
2218
|
async function runUpgrade(dockerSwarm) {
|
|
2157
2219
|
await main();
|
|
2158
|
-
await
|
|
2220
|
+
await main9();
|
|
2159
2221
|
await main2();
|
|
2160
2222
|
await main3();
|
|
2161
2223
|
await main7();
|
|
2162
2224
|
await main6();
|
|
2163
2225
|
await main5(dockerSwarm);
|
|
2164
|
-
await
|
|
2226
|
+
await main10();
|
|
2227
|
+
await main8();
|
|
2165
2228
|
await main4();
|
|
2166
2229
|
}
|
|
2167
2230
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-typings-from-dockerfile.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/remove-typings-from-dockerfile.ts"],"names":[],"mappings":"AAgIA,iBAAe,IAAI,kBAElB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.main = main;
|
|
26
|
+
/**
|
|
27
|
+
* Codemod: stop the country config's Dockerfile copying `typings/` into the
|
|
28
|
+
* image.
|
|
29
|
+
*
|
|
30
|
+
* A v2.0 Tiltfile sends `typings/` to the image build, and the Dockerfile ends
|
|
31
|
+
* with `COPY typings ./typings`. The Tiltfile that `upgrade-tilt` installs does
|
|
32
|
+
* not send it, and starts a yarn country config with `start:prod`, which runs
|
|
33
|
+
* `ts-node --transpile-only` and so never reads a declaration file. The
|
|
34
|
+
* Dockerfile left behind then fails under Tilt, on its last step:
|
|
35
|
+
*
|
|
36
|
+
* ERROR IN: [runner 6/6] COPY typings ./typings
|
|
37
|
+
*
|
|
38
|
+
* This step removes that instruction. `typings/` itself stays in the country
|
|
39
|
+
* config, where `tsconfig.json` still includes it when type-checking.
|
|
40
|
+
*
|
|
41
|
+
* Only a `COPY` that reads nothing but `typings` is removed. One that mixes it
|
|
42
|
+
* with other sources, or that is spread over several lines, is reported for the
|
|
43
|
+
* country to edit by hand. Anything already absent is left alone.
|
|
44
|
+
*/
|
|
45
|
+
const fs_1 = require("fs");
|
|
46
|
+
const path_1 = __importDefault(require("path"));
|
|
47
|
+
const DOCKERFILE = 'Dockerfile';
|
|
48
|
+
/** `typings`, `./typings`, `typings/`, or anything under it. */
|
|
49
|
+
const TYPINGS_PATH = /^(?:\.\/)?typings(?:\/.*)?$/;
|
|
50
|
+
/** A line ending in a backslash carries on into the next one. */
|
|
51
|
+
const continues = (line) => !/^\s*#/.test(line) && /\\[ \t]*\r?\n?$/.test(line);
|
|
52
|
+
/**
|
|
53
|
+
* What a line copies out of the build context, destination left out. Empty for
|
|
54
|
+
* anything but `COPY` and `ADD`, and for `--from`, which reads from another
|
|
55
|
+
* stage rather than from the build context.
|
|
56
|
+
*/
|
|
57
|
+
function contextSources(line, continued) {
|
|
58
|
+
const [instruction, ...args] = line.split(/[\s"',[\]]+/).filter(Boolean);
|
|
59
|
+
if (!/^(?:COPY|ADD)$/i.test(instruction) ||
|
|
60
|
+
args.some((arg) => arg.startsWith('--from'))) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const paths = args.filter((arg) => arg !== '\\' && !arg.startsWith('--'));
|
|
64
|
+
// The destination is the last path, which a line that carries on has not
|
|
65
|
+
// reached yet: everything on it is a source.
|
|
66
|
+
return continued ? paths : paths.slice(0, -1);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The Dockerfile without its instructions that copy only from `typings/`, and
|
|
70
|
+
* the ones that copy from it but could not be taken out safely.
|
|
71
|
+
*/
|
|
72
|
+
function removeTypingsCopy(dockerfile) {
|
|
73
|
+
var _a;
|
|
74
|
+
const kept = [];
|
|
75
|
+
const removed = [];
|
|
76
|
+
const unresolved = [];
|
|
77
|
+
let previousCarriesOn = false;
|
|
78
|
+
// Each line keeps its own terminator, so the ones left are written back as
|
|
79
|
+
// they were, whether LF or CRLF.
|
|
80
|
+
const lines = (_a = dockerfile.match(/[^\n]*\n|[^\n]+$/g)) !== null && _a !== void 0 ? _a : [];
|
|
81
|
+
for (const line of lines) {
|
|
82
|
+
const startsInstruction = !previousCarriesOn;
|
|
83
|
+
const carriesOn = continues(line);
|
|
84
|
+
previousCarriesOn = carriesOn;
|
|
85
|
+
const sources = startsInstruction ? contextSources(line, carriesOn) : [];
|
|
86
|
+
if (!sources.some((source) => TYPINGS_PATH.test(source))) {
|
|
87
|
+
kept.push(line);
|
|
88
|
+
}
|
|
89
|
+
else if (sources.length === 1 && !carriesOn) {
|
|
90
|
+
removed.push(line.trim());
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
kept.push(line);
|
|
94
|
+
unresolved.push(line.trim());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { contents: kept.join(''), removed, unresolved };
|
|
98
|
+
}
|
|
99
|
+
function removeTypingsFromDockerfile(cwd) {
|
|
100
|
+
const dockerfilePath = path_1.default.join(cwd, DOCKERFILE);
|
|
101
|
+
if (!(0, fs_1.existsSync)(dockerfilePath))
|
|
102
|
+
return;
|
|
103
|
+
const { contents, removed, unresolved } = removeTypingsCopy((0, fs_1.readFileSync)(dockerfilePath, 'utf8'));
|
|
104
|
+
if (removed.length === 0 && unresolved.length === 0)
|
|
105
|
+
return;
|
|
106
|
+
console.log('\nUpdating the Dockerfile...\n');
|
|
107
|
+
if (removed.length > 0) {
|
|
108
|
+
(0, fs_1.writeFileSync)(dockerfilePath, contents);
|
|
109
|
+
}
|
|
110
|
+
for (const instruction of removed) {
|
|
111
|
+
console.log(` ✓ ${DOCKERFILE}: removed '${instruction}', the Tiltfile no longer sends typings/ to the image build`);
|
|
112
|
+
}
|
|
113
|
+
for (const instruction of unresolved) {
|
|
114
|
+
console.warn(` ⚠️ ${DOCKERFILE} still copies from typings/ ('${instruction}'), which the Tiltfile no longer sends to the image build; remove it by hand`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function main() {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
removeTypingsFromDockerfile(process.cwd());
|
|
120
|
+
});
|
|
121
|
+
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
# https://github.com/opencrvs/infrastructure/blob/develop/Tiltfile
|
|
5
5
|
|
|
6
6
|
# OpenCRVS core images tag:
|
|
7
|
-
core_images_tag = os.getenv("OPENCRVS_CORE_IMAGE_TAG", "v2.1.
|
|
7
|
+
core_images_tag = os.getenv("OPENCRVS_CORE_IMAGE_TAG", "v2.1.1")
|
|
8
8
|
|
|
9
|
-
core_ref = os.getenv("OPENCRVS_CORE_REF", "release/2.1.
|
|
9
|
+
core_ref = os.getenv("OPENCRVS_CORE_REF", "release/2.1.1")
|
|
10
10
|
|
|
11
11
|
# Build countryconfig image in local registry (use any name and tag you want)
|
|
12
12
|
countryconfig_image_name="opencrvs/ocrvs-countryconfig"
|
|
Binary file
|