@opencrvs/toolkit 2.1.0-rc.ffe0b7f → 2.2.0-rc.ab91cce
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 +23 -5
- package/create-countryconfig/index.js +441 -59
- package/create-countryconfig/node_modules/.bin/degit +21 -0
- package/create-countryconfig/package.json +5 -2
- package/dist/application-config/index.js +362 -284
- package/dist/authentication/index.d.ts +66 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +765 -0
- package/dist/cli.js +2041 -1311
- package/dist/commons/api/router.d.ts +940 -363
- package/dist/commons/application-config/index.d.ts +0 -2
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/conditionals/validate.d.ts +34 -8
- package/dist/commons/events/ActionConfig.d.ts +77 -7
- package/dist/commons/events/ActionDocument.d.ts +35 -15
- 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 +48 -12
- package/dist/commons/events/AuditLog.d.ts +148 -0
- package/dist/commons/events/Draft.d.ts +1 -21
- package/dist/commons/events/EventConfig.d.ts +29 -6
- package/dist/commons/events/EventDocument.d.ts +472 -4
- 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 +109 -63
- package/dist/commons/events/FieldTypeMapping.d.ts +17 -17
- package/dist/commons/events/FieldValue.d.ts +3 -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/eventConfigValidation.d.ts +17 -1
- 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/scopes.d.ts +21 -1
- package/dist/commons/events/test.utils.d.ts +83 -25
- package/dist/commons/events/utils.d.ts +52 -17
- 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 +349 -65
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +120 -0
- 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/index.d.ts.map +1 -1
- package/dist/environment/index.js +2 -1
- 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.d.ts +1 -1
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +610 -560
- package/dist/environment/swarm-to-k8s.js +3 -4
- 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 +6115 -5378
- package/dist/migrations/add-translations.d.ts +15 -0
- package/dist/migrations/add-translations.d.ts.map +1 -0
- package/dist/migrations/add-translations.js +151 -0
- 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 +511 -0
- package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/enable-telemetry.d.ts} +1 -1
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
- package/dist/migrations/v2.1/enable-telemetry.js +455 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +47 -215
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +17 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
- package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +348 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
- package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
- package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
- package/dist/migrations/v2.1/remove-sentry.js +354 -0
- package/dist/migrations/{v2.0/create-events-index.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
- package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
- package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
- package/dist/migrations/v2.1/template-files.d.ts +8 -0
- package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
- package/dist/migrations/v2.1/template-files.js +49 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts +11 -0
- package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
- package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
- package/dist/migrations/v2.2/index.d.ts +6 -0
- package/dist/migrations/v2.2/index.d.ts.map +1 -0
- package/dist/migrations/v2.2/index.js +456 -0
- package/dist/migrations/v2.2/read-declaration-through-helper.d.ts +39 -0
- package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +1 -0
- package/dist/migrations/v2.2/read-declaration-through-helper.js +257 -0
- package/dist/notification/index.js +2012 -1455
- package/dist/scopes/index.d.ts +614 -36
- package/dist/scopes/index.js +351 -65
- package/dist/telemetry/index.d.ts +45 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +43 -0
- package/dist/templates/charts-values/dependencies/values.yaml +8 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +10 -3
- package/dist/templates/charts-values/opentelemetry/values.yaml +102 -0
- package/dist/templates/charts-values/traefik/values.yaml +25 -12
- package/dist/templates/countryconfig-template/.tiltignore +1 -0
- package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
- package/dist/templates/countryconfig-template/Tiltfile +112 -0
- package/dist/templates/countryconfig-template/assets/README.md +1 -0
- package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
- package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
- package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
- package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
- package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
- package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
- package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
- package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
- package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
- package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
- package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
- package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
- package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
- package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
- package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
- package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
- package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
- package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
- package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
- package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
- package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
- package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
- package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
- package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
- package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
- package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
- package/dist/templates/inventory/inventory.template.yml +1 -3
- package/dist/translations/template.d.ts +11 -0
- package/dist/translations/template.d.ts.map +1 -0
- package/dist/translations/template.js +100 -0
- package/dist/verify/endpoints.d.ts +2 -0
- package/dist/verify/endpoints.d.ts.map +1 -0
- package/dist/verify/endpoints.js +510 -0
- package/opencrvs-toolkit-2.2.0-rc.ab91cce.tgz +0 -0
- package/package.json +13 -7
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
- package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
- package/dist/migrations/v2.0/create-events-index.js +0 -325
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
- package/dist/migrations/v2.0/index.d.ts +0 -13
- package/dist/migrations/v2.0/index.d.ts.map +0 -1
- package/dist/migrations/v2.0/index.js +0 -103
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-scopes.js +0 -305
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
- package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
- package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
- package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
- package/dist/migrations/v2.0/update-package-json.js +0 -105
- 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.ffe0b7f.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CsvFile } from '../csv';
|
|
2
|
+
/**
|
|
3
|
+
* The rows of the template that the local file has no id for, expressed in the
|
|
4
|
+
* local file's columns.
|
|
5
|
+
*/
|
|
6
|
+
export declare function rowsToAdd(local: CsvFile, template: CsvFile): string[];
|
|
7
|
+
/**
|
|
8
|
+
* @param targetVersion the major.minor the country config is upgraded to, e.g. `2.2`.
|
|
9
|
+
*/
|
|
10
|
+
declare function main(targetVersion: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* @knipignore
|
|
13
|
+
*/
|
|
14
|
+
export { main };
|
|
15
|
+
//# sourceMappingURL=add-translations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-translations.d.ts","sourceRoot":"","sources":["../../src/migrations/add-translations.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,OAAO,EAMR,MAAM,QAAQ,CAAA;AAYf;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,CAgBrE;AAqED;;GAEG;AACH,iBAAe,IAAI,CAAC,aAAa,EAAE,MAAM,iBA2BxC;AAED;;GAEG;AACH,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,151 @@
|
|
|
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.rowsToAdd = rowsToAdd;
|
|
26
|
+
exports.main = main;
|
|
27
|
+
/**
|
|
28
|
+
* Codemod: copy the translation keys core gained this version into this country
|
|
29
|
+
* config.
|
|
30
|
+
*
|
|
31
|
+
* Unlike every other codemod, this one carries no list of what it changes, and
|
|
32
|
+
* should not need editing again: every version's upgrade runs it, passing the
|
|
33
|
+
* version it upgrades to. Its input is `client.csv` and `login.csv` from
|
|
34
|
+
* the country config template of that version, fetched from
|
|
35
|
+
* GitHub; whatever rows those files have gained, this adds. A pull request that
|
|
36
|
+
* introduces a translation key therefore only has to add it to the template —
|
|
37
|
+
* `packages/countryconfig-template/src/translations/` — which the
|
|
38
|
+
* check-missing-translation workflow makes it do anyway.
|
|
39
|
+
*
|
|
40
|
+
* `countryconfig.csv` is deliberately left alone. It holds the copy the country
|
|
41
|
+
* config declares itself, which is nobody's business but the country's.
|
|
42
|
+
*
|
|
43
|
+
* Rows are rebuilt against the local file's own columns rather than copied
|
|
44
|
+
* across, so a country config with languages the template does not have keeps
|
|
45
|
+
* its shape: the template's value is used for a language they share, and an
|
|
46
|
+
* empty cell for one it has nothing for.
|
|
47
|
+
*/
|
|
48
|
+
const path_1 = __importDefault(require("path"));
|
|
49
|
+
const csv_1 = require("../csv");
|
|
50
|
+
const template_1 = require("../translations/template");
|
|
51
|
+
const APPLICATIONS = ['client', 'login'];
|
|
52
|
+
const skipped = [];
|
|
53
|
+
function warnSkipped(message) {
|
|
54
|
+
skipped.push(message);
|
|
55
|
+
console.warn(` ⚠️ ${message}`);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The rows of the template that the local file has no id for, expressed in the
|
|
59
|
+
* local file's columns.
|
|
60
|
+
*/
|
|
61
|
+
function rowsToAdd(local, template) {
|
|
62
|
+
const localColumns = (0, csv_1.parseCsvLine)(local.header);
|
|
63
|
+
const templateColumns = (0, csv_1.parseCsvLine)(template.header);
|
|
64
|
+
return template.body
|
|
65
|
+
.filter((line) => line !== '')
|
|
66
|
+
.map((line) => {
|
|
67
|
+
const values = (0, csv_1.parseCsvLine)(line);
|
|
68
|
+
return (0, csv_1.toCsvLine)(localColumns.map((column) => {
|
|
69
|
+
var _a;
|
|
70
|
+
const index = templateColumns.indexOf(column);
|
|
71
|
+
return index === -1 ? '' : ((_a = values[index]) !== null && _a !== void 0 ? _a : '');
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function updateApplication(cwd, targetVersion, refs, application) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const relativePath = `src/translations/${application}.csv`;
|
|
78
|
+
const local = (0, csv_1.readCsvFile)(path_1.default.join(cwd, relativePath));
|
|
79
|
+
if (!local) {
|
|
80
|
+
warnSkipped(`${relativePath} not found; translations not added`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const fetched = yield (0, template_1.fetchTemplate)(refs, application);
|
|
84
|
+
if (!fetched) {
|
|
85
|
+
warnSkipped(`No ${application}.csv found in the ${targetVersion} country config template on GitHub; ${application}.csv not updated`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const template = readTemplate(fetched.contents);
|
|
89
|
+
const added = (0, csv_1.addRows)(local, rowsToAdd(local, template));
|
|
90
|
+
if (added.length === 0) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
(0, csv_1.writeCsvFile)(path_1.default.join(cwd, relativePath), local);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
warnSkipped(`Could not write ${relativePath} (${error.message}); translations not added`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const id of added) {
|
|
101
|
+
console.log(` ✓ ${relativePath}: ${id}`);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function readTemplate(contents) {
|
|
106
|
+
const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
|
|
107
|
+
return {
|
|
108
|
+
header: lines[0],
|
|
109
|
+
body: lines.slice(1),
|
|
110
|
+
newline: '\n',
|
|
111
|
+
trailingNewline: true
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** Refs to read the template from. Undefined when GitHub cannot be asked. */
|
|
115
|
+
function listRefs(targetVersion) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
try {
|
|
118
|
+
return yield (0, template_1.candidateRefs)(targetVersion);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
warnSkipped(`Could not list the ${targetVersion} refs on GitHub (${error.message}); translations not added`);
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @param targetVersion the major.minor the country config is upgraded to, e.g. `2.2`.
|
|
128
|
+
*/
|
|
129
|
+
function main(targetVersion) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const cwd = process.cwd();
|
|
132
|
+
console.log('Adding the translation keys core gained this version...\n');
|
|
133
|
+
const refs = yield listRefs(targetVersion);
|
|
134
|
+
if (refs) {
|
|
135
|
+
for (const application of APPLICATIONS) {
|
|
136
|
+
try {
|
|
137
|
+
yield updateApplication(cwd, targetVersion, refs, application);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
warnSkipped(`Could not read ${application}.csv from the country config template on GitHub (${error.message}); ${application}.csv not updated`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (skipped.length > 0) {
|
|
145
|
+
console.warn(`\n⚠️ ${skipped.length} step(s) were skipped. Add the missing translations by hand before upgrading:`);
|
|
146
|
+
for (const message of skipped) {
|
|
147
|
+
console.warn(` - ${message}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-recovery-link-notifications.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/add-recovery-link-notifications.ts"],"names":[],"mappings":"AAopBA,iBAAe,IAAI,kBA0ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|