@opencrvs/toolkit 2.1.0-rc.1f688f9 → 2.1.0-rc.268cfbe

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.
Files changed (209) hide show
  1. package/README.md +2 -12
  2. package/build.sh +20 -5
  3. package/create-countryconfig/index.js +164 -4
  4. package/dist/application-config/index.js +36 -25
  5. package/dist/authentication/index.d.ts +66 -0
  6. package/dist/authentication/index.d.ts.map +1 -0
  7. package/dist/authentication/index.js +765 -0
  8. package/dist/cli.js +2829 -1294
  9. package/dist/commons/api/router.d.ts +252 -290
  10. package/dist/commons/application-config/index.d.ts +0 -2
  11. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  12. package/dist/commons/conditionals/validate.d.ts +19 -4
  13. package/dist/commons/events/ActionConfig.d.ts +5 -14
  14. package/dist/commons/events/ActionDocument.d.ts +30 -4
  15. package/dist/commons/events/AdvancedSearchConfig.d.ts +24 -12
  16. package/dist/commons/events/AuditLog.d.ts +1 -0
  17. package/dist/commons/events/Draft.d.ts +1 -21
  18. package/dist/commons/events/EventDocument.d.ts +4 -4
  19. package/dist/commons/events/FieldConfig.d.ts +26 -15
  20. package/dist/commons/events/FieldTypeMapping.d.ts +10 -10
  21. package/dist/commons/events/FieldValue.d.ts +1 -0
  22. package/dist/commons/events/FormConfig.d.ts +6 -0
  23. package/dist/commons/events/PageConfig.d.ts +4 -0
  24. package/dist/commons/events/locations.d.ts +4 -0
  25. package/dist/commons/events/scopes.d.ts +21 -1
  26. package/dist/commons/events/test.utils.d.ts +71 -22
  27. package/dist/commons/events/utils.d.ts +37 -2
  28. package/dist/commons/notification/dispatch.d.ts +1 -6
  29. package/dist/conditionals/index.js +21 -7
  30. package/dist/csv.d.ts +25 -0
  31. package/dist/csv.d.ts.map +1 -0
  32. package/dist/csv.js +120 -0
  33. package/dist/environment/index.d.ts.map +1 -1
  34. package/dist/environment/index.js +2 -1
  35. package/dist/environment/logger.d.ts +3 -0
  36. package/dist/environment/logger.d.ts.map +1 -1
  37. package/dist/environment/manage-users.js +1 -1
  38. package/dist/environment/setup-environment.d.ts +1 -1
  39. package/dist/environment/setup-environment.d.ts.map +1 -1
  40. package/dist/environment/setup-environment.js +593 -562
  41. package/dist/environment/swarm-to-k8s.js +3 -4
  42. package/dist/environment/templates.d.ts +0 -1
  43. package/dist/environment/templates.d.ts.map +1 -1
  44. package/dist/environment/templates.js +3 -8
  45. package/dist/environment/update-workflows.d.ts.map +1 -1
  46. package/dist/environment/update-workflows.js +4 -0
  47. package/dist/environment/utils.d.ts +0 -12
  48. package/dist/environment/utils.d.ts.map +1 -1
  49. package/dist/environment/utils.js +1 -28
  50. package/dist/events/index.js +2115 -1884
  51. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -1
  52. package/dist/migrations/v2.1/add-recovery-link-notifications.js +13 -32
  53. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  54. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  55. package/dist/migrations/v2.1/add-translations.js +149 -0
  56. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
  57. package/dist/migrations/v2.1/enable-telemetry.js +32 -15
  58. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  59. package/dist/migrations/v2.1/index.js +1160 -70
  60. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +14 -0
  61. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -0
  62. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +345 -0
  63. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +2 -0
  64. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +1 -0
  65. package/dist/migrations/v2.1/remove-metabase-package-installs.js +161 -0
  66. package/dist/migrations/{v2.0/migrate-scopes.d.ts → v2.1/remove-sentry.d.ts} +1 -1
  67. package/dist/migrations/v2.1/remove-sentry.d.ts.map +1 -0
  68. package/dist/migrations/v2.1/remove-sentry.js +354 -0
  69. package/dist/migrations/{v2.0/rename-api-paths.d.ts → v2.1/rename-trigger-paths.d.ts} +1 -1
  70. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +1 -0
  71. package/dist/migrations/{v2.0/rename-api-paths.js → v2.1/rename-trigger-paths.js} +69 -40
  72. package/dist/migrations/v2.1/template-files.d.ts +8 -0
  73. package/dist/migrations/v2.1/template-files.d.ts.map +1 -0
  74. package/dist/migrations/v2.1/template-files.js +49 -0
  75. package/dist/migrations/v2.1/upgrade-tilt.d.ts +8 -0
  76. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -0
  77. package/dist/migrations/v2.1/upgrade-tilt.js +139 -0
  78. package/dist/notification/index.js +249 -207
  79. package/dist/scopes/index.d.ts +288 -5
  80. package/dist/scopes/index.js +22 -7
  81. package/dist/telemetry/index.js +5 -1
  82. package/dist/templates/charts-values/dependencies/values.yaml +8 -0
  83. package/dist/templates/charts-values/opencrvs-services/values.yaml +6 -0
  84. package/dist/templates/charts-values/opentelemetry/values.yaml +7 -0
  85. package/dist/templates/countryconfig-template/.tiltignore +1 -0
  86. package/dist/templates/countryconfig-template/Dockerfile.assets +7 -0
  87. package/dist/templates/countryconfig-template/Tiltfile +112 -0
  88. package/dist/templates/countryconfig-template/assets/README.md +1 -0
  89. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +61 -0
  90. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +455 -0
  91. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +168 -0
  92. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +67 -0
  93. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +168 -0
  94. package/dist/templates/countryconfig-template/assets/metabase/README.md +34 -0
  95. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +36 -0
  96. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +46 -0
  97. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +27737 -0
  98. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +21 -0
  99. package/dist/templates/countryconfig-template/assets/metabase/package.json +13 -0
  100. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +108 -0
  101. package/dist/templates/countryconfig-template/assets/metabase/run.sh +120 -0
  102. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +40 -0
  103. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +135 -0
  104. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +108 -0
  105. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +50 -0
  106. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +35 -0
  107. package/dist/templates/countryconfig-template/tilt/common.tilt +145 -0
  108. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +15 -0
  109. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +56 -0
  110. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +21 -0
  111. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +38 -0
  112. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +17 -0
  113. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +16 -0
  114. package/dist/templates/countryconfig-template/tilt/lib.tilt +95 -0
  115. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +136 -0
  116. package/dist/translations/template.d.ts +11 -0
  117. package/dist/translations/template.d.ts.map +1 -0
  118. package/dist/translations/template.js +100 -0
  119. package/dist/verify/endpoints.d.ts +2 -0
  120. package/dist/verify/endpoints.d.ts.map +1 -0
  121. package/dist/verify/endpoints.js +510 -0
  122. package/opencrvs-toolkit-2.1.0-rc.268cfbe.tgz +0 -0
  123. package/package.json +9 -4
  124. package/tsconfig.build.json +11 -0
  125. package/tsconfig.build.tsbuildinfo +1 -0
  126. package/tsconfig.json +3 -0
  127. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts +0 -3
  128. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +0 -1
  129. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +0 -429
  130. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
  131. package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
  132. package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
  133. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -22
  134. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +0 -1
  135. package/dist/migrations/v2.0/checkout-upstream-files.js +0 -146
  136. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts +0 -2
  137. package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +0 -1
  138. package/dist/migrations/v2.0/convert-config-files-to-ts.js +0 -838
  139. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts +0 -3
  140. package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +0 -1
  141. package/dist/migrations/v2.0/convert-paragraph-to-heading.js +0 -158
  142. package/dist/migrations/v2.0/create-events-index.d.ts +0 -3
  143. package/dist/migrations/v2.0/create-events-index.d.ts.map +0 -1
  144. package/dist/migrations/v2.0/create-events-index.js +0 -325
  145. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -11
  146. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
  147. package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -123
  148. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +0 -3
  149. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +0 -1
  150. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +0 -110
  151. package/dist/migrations/v2.0/index.d.ts +0 -13
  152. package/dist/migrations/v2.0/index.d.ts.map +0 -1
  153. package/dist/migrations/v2.0/index.js +0 -103
  154. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts +0 -3
  155. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +0 -1
  156. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +0 -432
  157. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -13
  158. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
  159. package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -222
  160. package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
  161. package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
  162. package/dist/migrations/v2.0/migrate-application-config-url.js +0 -343
  163. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +0 -1
  164. package/dist/migrations/v2.0/migrate-scopes.js +0 -305
  165. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts +0 -3
  166. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +0 -1
  167. package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +0 -267
  168. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
  169. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
  170. package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -317
  171. package/dist/migrations/v2.0/remove-delete-actions.d.ts +0 -3
  172. package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +0 -1
  173. package/dist/migrations/v2.0/remove-delete-actions.js +0 -156
  174. package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
  175. package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
  176. package/dist/migrations/v2.0/remove-demo-scope.js +0 -74
  177. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts +0 -3
  178. package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +0 -1
  179. package/dist/migrations/v2.0/remove-deprecated-imports.js +0 -96
  180. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
  181. package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
  182. package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
  183. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +0 -3
  184. package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +0 -1
  185. package/dist/migrations/v2.0/remove-hearth-migrations.js +0 -87
  186. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
  187. package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
  188. package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
  189. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts +0 -3
  190. package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +0 -1
  191. package/dist/migrations/v2.0/remove-pending-certification-flag.js +0 -109
  192. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts +0 -3
  193. package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +0 -1
  194. package/dist/migrations/v2.0/remove-review-from-register-action.js +0 -163
  195. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
  196. package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
  197. package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
  198. package/dist/migrations/v2.0/rename-api-paths.d.ts.map +0 -1
  199. package/dist/migrations/v2.0/rename-location-parent-id.d.ts +0 -3
  200. package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +0 -1
  201. package/dist/migrations/v2.0/rename-location-parent-id.js +0 -180
  202. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts +0 -3
  203. package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +0 -1
  204. package/dist/migrations/v2.0/simplify-analytics-precalculations.js +0 -195
  205. package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
  206. package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
  207. package/dist/migrations/v2.0/update-package-json.js +0 -105
  208. package/opencrvs-toolkit-2.1.0-rc.1f688f9.tgz +0 -0
  209. package/tsconfig.tsbuildinfo +0 -1
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=convert-paragraph-to-heading.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert-paragraph-to-heading.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-paragraph-to-heading.ts"],"names":[],"mappings":"AAsJA,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,158 +0,0 @@
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: Convert `FieldType.PARAGRAPH` fields with a heading `fontVariant` to `FieldType.HEADING`,
28
- * and remove the `fontVariant` property from plain paragraphs.
29
- *
30
- * Usage:
31
- * ts-node -r tsconfig-paths/register src/migrations/v2.0/convert-paragraph-to-heading.ts
32
- *
33
- * What it does:
34
- * - Scans all TypeScript files under `src/`
35
- * - Finds every object literal whose `type` property is `FieldType.PARAGRAPH`
36
- * - Navigates `configuration.styles.fontVariant` on that object
37
- * - If `fontVariant` is one of 'h1' | 'h2' | 'h3' | 'h4':
38
- * changes `type` to `FieldType.HEADING`
39
- * - If `fontVariant` is absent, not a string literal, or any other value:
40
- * leaves `type` as `FieldType.PARAGRAPH` and removes the `fontVariant` property
41
- * - Saves the modified files in-place
42
- */
43
- const ts_morph_1 = require("ts-morph");
44
- const path_1 = __importDefault(require("path"));
45
- const FIELD_TYPE_ENUM_NAME = 'FieldType';
46
- const PARAGRAPH_MEMBER_NAME = 'PARAGRAPH';
47
- const HEADING_MEMBER_NAME = 'HEADING';
48
- const TYPE_PROPERTY_NAME = 'type';
49
- const CONFIGURATION_PROPERTY_NAME = 'configuration';
50
- const STYLES_PROPERTY_NAME = 'styles';
51
- const FONT_VARIANT_PROPERTY_NAME = 'fontVariant';
52
- const HEADING_FONT_VARIANTS = new Set(['h1', 'h2', 'h3', 'h4']);
53
- function isParagraphType(typeInitializer) {
54
- if (!ts_morph_1.Node.isPropertyAccessExpression(typeInitializer))
55
- return false;
56
- const obj = typeInitializer.getExpression();
57
- const member = typeInitializer.getName();
58
- return (ts_morph_1.Node.isIdentifier(obj) &&
59
- obj.getText() === FIELD_TYPE_ENUM_NAME &&
60
- member === PARAGRAPH_MEMBER_NAME);
61
- }
62
- function getFontVariantProperty(obj) {
63
- const configProperty = obj.getProperty(CONFIGURATION_PROPERTY_NAME);
64
- if (!configProperty || !ts_morph_1.Node.isPropertyAssignment(configProperty))
65
- return null;
66
- const configInitializer = configProperty.getInitializer();
67
- if (!configInitializer || !ts_morph_1.Node.isObjectLiteralExpression(configInitializer))
68
- return null;
69
- const stylesProperty = configInitializer.getProperty(STYLES_PROPERTY_NAME);
70
- if (!stylesProperty || !ts_morph_1.Node.isPropertyAssignment(stylesProperty))
71
- return null;
72
- const stylesInitializer = stylesProperty.getInitializer();
73
- if (!stylesInitializer || !ts_morph_1.Node.isObjectLiteralExpression(stylesInitializer))
74
- return null;
75
- const fontVariantProperty = stylesInitializer.getProperty(FONT_VARIANT_PROPERTY_NAME);
76
- if (!fontVariantProperty || !ts_morph_1.Node.isPropertyAssignment(fontVariantProperty))
77
- return null;
78
- return fontVariantProperty;
79
- }
80
- function transformParagraphField(obj) {
81
- const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
82
- if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty))
83
- return null;
84
- const typeInitializer = typeProperty.getInitializer();
85
- if (!typeInitializer || !isParagraphType(typeInitializer))
86
- return null;
87
- const fontVariantProperty = getFontVariantProperty(obj);
88
- if (fontVariantProperty) {
89
- const fontVariantInitializer = fontVariantProperty.getInitializer();
90
- if (fontVariantInitializer &&
91
- ts_morph_1.Node.isStringLiteral(fontVariantInitializer) &&
92
- HEADING_FONT_VARIANTS.has(fontVariantInitializer.getLiteralValue())) {
93
- // fontVariant is h1–h4: promote to HEADING
94
- typeInitializer.replaceWithText(`${FIELD_TYPE_ENUM_NAME}.${HEADING_MEMBER_NAME}`);
95
- return 'converted-to-heading';
96
- }
97
- // fontVariant is present but not a heading variant: remove it
98
- fontVariantProperty.remove();
99
- return 'removed-font-variant';
100
- }
101
- // No fontVariant at all: nothing to do
102
- return null;
103
- }
104
- function processFile(filePath, project) {
105
- const sourceFile = project.getSourceFile(filePath);
106
- if (!sourceFile)
107
- return 0;
108
- let changedCount = 0;
109
- const objectLiterals = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
110
- for (const obj of objectLiterals) {
111
- const result = transformParagraphField(obj);
112
- if (result === 'converted-to-heading') {
113
- changedCount++;
114
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`);
115
- }
116
- else if (result === 'removed-font-variant') {
117
- changedCount++;
118
- console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`);
119
- }
120
- }
121
- return changedCount;
122
- }
123
- function main() {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- const srcDir = path_1.default.join(process.cwd(), 'src');
126
- console.log(`Scanning for FieldType.PARAGRAPH fields in: ${srcDir}\n`);
127
- const project = new ts_morph_1.Project({
128
- tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
129
- skipAddingFilesFromTsConfig: false
130
- });
131
- const sourceFiles = project.getSourceFiles().filter((sf) => {
132
- const fp = sf.getFilePath();
133
- return fp.includes('/src/') && !fp.includes('/node_modules/');
134
- });
135
- console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
136
- let totalChanged = 0;
137
- const modifiedFiles = [];
138
- for (const sourceFile of sourceFiles) {
139
- const filePath = sourceFile.getFilePath();
140
- const changed = processFile(filePath, project);
141
- if (changed > 0) {
142
- totalChanged += changed;
143
- modifiedFiles.push(filePath);
144
- }
145
- }
146
- if (modifiedFiles.length === 0) {
147
- console.log('No FieldType.PARAGRAPH fields with fontVariant found. Nothing to do.');
148
- return;
149
- }
150
- console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
151
- for (const filePath of modifiedFiles) {
152
- const sourceFile = project.getSourceFileOrThrow(filePath);
153
- yield sourceFile.save();
154
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
155
- }
156
- console.log(`\nDone. Processed ${totalChanged} FieldType.PARAGRAPH field(s).`);
157
- });
158
- }
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=create-events-index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-events-index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/create-events-index.ts"],"names":[],"mappings":"AAmTA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmEnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,325 +0,0 @@
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: Create `src/events/index.ts` that collects every `defineConfig`
28
- * event export, and rewire the event-config handler to import from it.
29
- *
30
- * Usage:
31
- * ts-node -r tsconfig-paths/register src/migrations/v2.0/create-events-index.ts
32
- *
33
- * Context:
34
- * No codemod currently *moves* event-config source files into `src/events/`.
35
- * Event configs therefore still live wherever the country defined them
36
- * (typically `src/form/...`). This codemod works regardless of their
37
- * location by discovering every `export const X = defineConfig(...)`
38
- * declaration in `src/`.
39
- *
40
- * What it does:
41
- * 1. Scans `src/` for every top-level `export const X = defineConfig(...)`
42
- * declaration and records `{ name, filePath }` pairs.
43
- * 2. Creates `src/events/index.ts` (if it does not already exist) that
44
- * imports each event config from its actual file location using a
45
- * relative path from `src/events/`, and exports:
46
- * export const eventConfigs = [<name1>, <name2>, ...]
47
- * 3. Locates the event-config Hapi handler file (a file whose top level
48
- * declares a function named `getCustomEventsHandler` or
49
- * `getEventsHandler`) and:
50
- * - Removes direct named imports of the event configs it no longer
51
- * needs, cleaning up the import declaration if it becomes empty.
52
- * - Removes any previously-inlined `export const eventConfigs = [...]`
53
- * at the top level (in case an earlier codemod version hoisted one).
54
- * - Adds `import { eventConfigs } from '@countryconfig/events'`
55
- * (merging into an existing import of the same module if present).
56
- * - Rewrites `h.response([<identifiers>]).code(...)` inside the
57
- * handler to `h.response(eventConfigs).code(...)`.
58
- * 4. Saves the modified files.
59
- *
60
- * The codemod is safe to re-run: if `src/events/index.ts` already exists it
61
- * is left untouched, and handler modifications are idempotent.
62
- */
63
- const ts_morph_1 = require("ts-morph");
64
- const fs_1 = __importDefault(require("fs"));
65
- const path_1 = __importDefault(require("path"));
66
- const DEFINE_CONFIG_NAME = 'defineConfig';
67
- const HANDLER_FUNCTION_NAMES = new Set([
68
- 'getCustomEventsHandler',
69
- 'getEventsHandler'
70
- ]);
71
- const EVENT_CONFIGS_IDENTIFIER = 'eventConfigs';
72
- const EVENTS_INDEX_IMPORT_PATH = '@countryconfig/events';
73
- const RESPONSE_METHOD_NAME = 'response';
74
- const LICENSE_HEADER = `/*
75
- * This Source Code Form is subject to the terms of the Mozilla Public
76
- * License, v. 2.0. If a copy of the MPL was not distributed with this
77
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
78
- *
79
- * OpenCRVS is also distributed under the terms of the Civil Registration
80
- * & Healthcare Disclaimer located at http://opencrvs.org/license.
81
- *
82
- * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
83
- */
84
- `;
85
- // ─── Discovery ───────────────────────────────────────────────────────────────
86
- /**
87
- * Returns every top-level `export const X = defineConfig(...)` declaration in
88
- * files under `srcDir`. A declaration may wrap the call in a type assertion
89
- * (`... as EventConfig`) — this is unwrapped before matching.
90
- *
91
- * An existing `src/events/index.ts` is excluded so re-runs don't pick up its
92
- * re-exports as source definitions.
93
- */
94
- function findEventConfigExports(project, srcDir) {
95
- const found = [];
96
- const eventsIndexAbs = path_1.default.join(srcDir, 'events', 'index.ts');
97
- for (const sourceFile of project.getSourceFiles()) {
98
- const filePath = sourceFile.getFilePath();
99
- if (!filePath.startsWith(srcDir) || filePath.includes('/node_modules/')) {
100
- continue;
101
- }
102
- if (filePath === eventsIndexAbs)
103
- continue;
104
- for (const statement of sourceFile.getVariableStatements()) {
105
- if (!statement.hasExportKeyword())
106
- continue;
107
- for (const decl of statement.getDeclarations()) {
108
- const initializer = decl.getInitializer();
109
- if (!initializer)
110
- continue;
111
- const unwrapped = ts_morph_1.Node.isAsExpression(initializer)
112
- ? initializer.getExpression()
113
- : initializer;
114
- if (!ts_morph_1.Node.isCallExpression(unwrapped))
115
- continue;
116
- const callee = unwrapped.getExpression();
117
- if (!ts_morph_1.Node.isIdentifier(callee))
118
- continue;
119
- if (callee.getText() !== DEFINE_CONFIG_NAME)
120
- continue;
121
- found.push({ name: decl.getName(), filePath });
122
- }
123
- }
124
- }
125
- return found;
126
- }
127
- // ─── Path helpers ────────────────────────────────────────────────────────────
128
- /**
129
- * Builds the POSIX module-specifier string used by `src/events/index.ts` to
130
- * import from `eventConfigFilePath`.
131
- *
132
- * - Strips the trailing `.ts` extension.
133
- * - Collapses `/index` so `src/form/v2/birth/index.ts` → `../form/v2/birth`.
134
- * - Ensures the result starts with `./` or `../` (relative paths are required
135
- * for sibling files that would otherwise be parsed as bare module names).
136
- */
137
- function buildIndexImportSpecifier(eventConfigFilePath, srcDir) {
138
- const eventsIndexDir = path_1.default.join(srcDir, 'events');
139
- let rel = path_1.default
140
- .relative(eventsIndexDir, eventConfigFilePath)
141
- .split(path_1.default.sep)
142
- .join('/');
143
- if (rel.endsWith('.ts'))
144
- rel = rel.slice(0, -'.ts'.length);
145
- if (rel.endsWith('/index'))
146
- rel = rel.slice(0, -'/index'.length);
147
- if (!rel.startsWith('.'))
148
- rel = './' + rel;
149
- return rel;
150
- }
151
- // ─── events/index.ts generation ──────────────────────────────────────────────
152
- function buildEventsIndexSource(exports, srcDir) {
153
- const imports = exports
154
- .map((e) => `import { ${e.name} } from '${buildIndexImportSpecifier(e.filePath, srcDir)}'`)
155
- .join('\n');
156
- const array = `export const ${EVENT_CONFIGS_IDENTIFIER} = [${exports
157
- .map((e) => e.name)
158
- .join(', ')}]`;
159
- return `${LICENSE_HEADER}${imports}\n\n${array}\n`;
160
- }
161
- // ─── Handler discovery & rewrite ─────────────────────────────────────────────
162
- /**
163
- * Returns the first source file under `srcDir` whose top-level declarations
164
- * include a function (either `function foo()` or `const foo = () => {}`) whose
165
- * name is in `HANDLER_FUNCTION_NAMES`.
166
- */
167
- function findHandlerSourceFile(project, srcDir) {
168
- for (const sf of project.getSourceFiles()) {
169
- const fp = sf.getFilePath();
170
- if (!fp.startsWith(srcDir) || fp.includes('/node_modules/'))
171
- continue;
172
- for (const fn of sf.getFunctions()) {
173
- const name = fn.getName();
174
- if (name && HANDLER_FUNCTION_NAMES.has(name))
175
- return sf;
176
- }
177
- for (const statement of sf.getVariableStatements()) {
178
- for (const decl of statement.getDeclarations()) {
179
- if (HANDLER_FUNCTION_NAMES.has(decl.getName()))
180
- return sf;
181
- }
182
- }
183
- }
184
- return undefined;
185
- }
186
- /**
187
- * Mutates the handler source file:
188
- * 1. Removes named imports matching `exportNames` from existing imports
189
- * and drops any import declaration that's left empty.
190
- * 2. Removes a stale top-level `export const eventConfigs = ...` if present.
191
- * 3. Ensures `import { eventConfigs } from '@countryconfig/events'` exists
192
- * (merging into an existing import of the same module when possible).
193
- * 4. Replaces every `h.response([<identifiers>])` argument with
194
- * `eventConfigs`.
195
- *
196
- * Returns a log of the changes that were actually applied.
197
- */
198
- function modifyHandler(sourceFile, exportNames) {
199
- const changes = [];
200
- // 1. Drop direct imports of event configs. Iterate over a snapshot because
201
- // `importDecl.remove()` may mutate the declaration list.
202
- for (const importDecl of [...sourceFile.getImportDeclarations()]) {
203
- const namedImports = importDecl.getNamedImports();
204
- if (namedImports.length === 0)
205
- continue;
206
- const matched = namedImports.filter((ni) => exportNames.has(ni.getName()));
207
- if (matched.length === 0)
208
- continue;
209
- const removedNames = matched.map((ni) => ni.getName());
210
- for (const ni of matched)
211
- ni.remove();
212
- changes.push(`removed direct imports: ${removedNames.join(', ')}`);
213
- const stillUsed = importDecl.getNamedImports().length > 0 ||
214
- importDecl.getDefaultImport() ||
215
- importDecl.getNamespaceImport();
216
- if (!stillUsed)
217
- importDecl.remove();
218
- }
219
- // 2. Remove an inline top-level `export const eventConfigs = ...` if present.
220
- // This cleans up after any earlier in-place hoisting done by a previous
221
- // version of this migration.
222
- for (const statement of [...sourceFile.getVariableStatements()]) {
223
- if (!statement.hasExportKeyword())
224
- continue;
225
- const hasEventConfigs = statement
226
- .getDeclarations()
227
- .some((d) => d.getName() === EVENT_CONFIGS_IDENTIFIER);
228
- if (hasEventConfigs) {
229
- statement.remove();
230
- changes.push(`removed inline 'export const ${EVENT_CONFIGS_IDENTIFIER}'`);
231
- }
232
- }
233
- // 3. Ensure `import { eventConfigs } from '@countryconfig/events'`.
234
- const existing = sourceFile.getImportDeclaration((imp) => imp.getModuleSpecifierValue() === EVENTS_INDEX_IMPORT_PATH);
235
- if (existing) {
236
- const already = existing
237
- .getNamedImports()
238
- .some((ni) => ni.getName() === EVENT_CONFIGS_IDENTIFIER);
239
- if (!already) {
240
- existing.addNamedImport(EVENT_CONFIGS_IDENTIFIER);
241
- changes.push(`added '${EVENT_CONFIGS_IDENTIFIER}' to existing import from '${EVENTS_INDEX_IMPORT_PATH}'`);
242
- }
243
- }
244
- else {
245
- sourceFile.addImportDeclaration({
246
- moduleSpecifier: EVENTS_INDEX_IMPORT_PATH,
247
- namedImports: [EVENT_CONFIGS_IDENTIFIER]
248
- });
249
- changes.push(`added import { ${EVENT_CONFIGS_IDENTIFIER} } from '${EVENTS_INDEX_IMPORT_PATH}'`);
250
- }
251
- // 4. Replace inline `h.response([<identifiers>])` with `h.response(eventConfigs)`.
252
- for (const call of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression)) {
253
- const callee = call.getExpression();
254
- if (!ts_morph_1.Node.isPropertyAccessExpression(callee))
255
- continue;
256
- if (callee.getName() !== RESPONSE_METHOD_NAME)
257
- continue;
258
- const args = call.getArguments();
259
- if (args.length !== 1)
260
- continue;
261
- const [arg] = args;
262
- if (!ts_morph_1.Node.isArrayLiteralExpression(arg))
263
- continue;
264
- if (arg.getElements().length === 0)
265
- continue;
266
- if (!arg.getElements().every((el) => ts_morph_1.Node.isIdentifier(el)))
267
- continue;
268
- arg.replaceWithText(EVENT_CONFIGS_IDENTIFIER);
269
- changes.push(`rewrote h.response([...]) → h.response(${EVENT_CONFIGS_IDENTIFIER})`);
270
- }
271
- return changes;
272
- }
273
- // ─── Entry point ─────────────────────────────────────────────────────────────
274
- function main() {
275
- return __awaiter(this, void 0, void 0, function* () {
276
- const cwd = process.cwd();
277
- const srcDir = path_1.default.join(cwd, 'src');
278
- console.log(`Scanning for defineConfig event exports in: ${srcDir}\n`);
279
- const project = new ts_morph_1.Project({
280
- tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
281
- skipAddingFilesFromTsConfig: false
282
- });
283
- const eventConfigExports = findEventConfigExports(project, srcDir);
284
- if (eventConfigExports.length === 0) {
285
- console.log('No top-level `export const X = defineConfig(...)` declarations found. Nothing to do.');
286
- return;
287
- }
288
- console.log(`Found ${eventConfigExports.length} event config export(s):`);
289
- for (const e of eventConfigExports) {
290
- console.log(` ${e.name} ← ${path_1.default.relative(cwd, e.filePath)}`);
291
- }
292
- // ── Create (or skip) src/events/index.ts ───────────────────────────────────
293
- const eventsIndexAbs = path_1.default.join(srcDir, 'events', 'index.ts');
294
- const eventsIndexRel = path_1.default.relative(cwd, eventsIndexAbs);
295
- if (fs_1.default.existsSync(eventsIndexAbs)) {
296
- console.log(`\n[${eventsIndexRel}] already exists — leaving untouched.`);
297
- }
298
- else {
299
- fs_1.default.mkdirSync(path_1.default.dirname(eventsIndexAbs), { recursive: true });
300
- const source = buildEventsIndexSource(eventConfigExports, srcDir);
301
- const eventsIndexFile = project.createSourceFile(eventsIndexAbs, source, {
302
- overwrite: false
303
- });
304
- yield eventsIndexFile.save();
305
- console.log(`\n[${eventsIndexRel}] created with ${EVENT_CONFIGS_IDENTIFIER} of ${eventConfigExports.length} event(s).`);
306
- }
307
- // ── Rewire handler file ────────────────────────────────────────────────────
308
- const handler = findHandlerSourceFile(project, srcDir);
309
- if (!handler) {
310
- console.log(`\nNo event-config handler file found (looked for exported function(s): ${Array.from(HANDLER_FUNCTION_NAMES).join(', ')}). Skipping handler rewrite.`);
311
- return;
312
- }
313
- const handlerRelPath = path_1.default.relative(cwd, handler.getFilePath());
314
- const exportNameSet = new Set(eventConfigExports.map((e) => e.name));
315
- const changes = modifyHandler(handler, exportNameSet);
316
- if (changes.length === 0) {
317
- console.log(`\n[${handlerRelPath}] already wired to ${EVENTS_INDEX_IMPORT_PATH} — no changes.`);
318
- return;
319
- }
320
- for (const c of changes)
321
- console.log(` [${handlerRelPath}] ${c}`);
322
- yield handler.save();
323
- console.log(`\nSaved ${handlerRelPath}.`);
324
- });
325
- }
@@ -1,11 +0,0 @@
1
- interface DeleteInfrastructureOptions {
2
- /**
3
- * Top-level entries directly under `infrastructure/` to preserve. Names
4
- * match against the basename of each entry (file or directory). When
5
- * empty (the default), the whole `infrastructure/` directory is deleted.
6
- */
7
- keep?: string[];
8
- }
9
- declare function main({ keep }?: DeleteInfrastructureOptions): Promise<void>;
10
- export { main };
11
- //# sourceMappingURL=delete-infrastructure-directory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delete-infrastructure-directory.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/delete-infrastructure-directory.ts"],"names":[],"mappings":"AAoDA,UAAU,2BAA2B;IACnC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,iBAAe,IAAI,CAAC,EAClB,IAAS,EACV,GAAE,2BAAgC,GAAG,OAAO,CAAC,IAAI,CAAC,CA4FlD;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,123 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.main = main;
23
- /**
24
- * Codemod: Remove the local `infrastructure/` directory.
25
- *
26
- * Used by the v1.9 → v2.0 upgrade when the country config does NOT deploy
27
- * via Docker Swarm. In that case the `infrastructure/` directory shipped
28
- * with opencrvs-countryconfig is no longer needed and can be removed.
29
- *
30
- * Some non-Swarm deployments still need a small subset of
31
- * `infrastructure/` (e.g. `postgres/` and `metabase/`). Pass `keep` to
32
- * preserve those top-level subdirectories — everything else under
33
- * `infrastructure/` is deleted, and the kept subdirectories can then be
34
- * refreshed from upstream by `merge-infrastructure-directory.ts` with the
35
- * matching `subdirs` option.
36
- *
37
- * Usage:
38
- * ts-node -r tsconfig-paths/register src/migrations/v2.0/delete-infrastructure-directory.ts
39
- *
40
- * What it does:
41
- * 1. Stages deletion of all tracked files under `infrastructure/` via
42
- * `git rm -rf --ignore-unmatch -- <path>`. This both removes the
43
- * files from the working tree and records the deletion in the
44
- * index, so it shows up in the upgrade commit alongside the other
45
- * codemod changes. When `keep` is provided, deletion is scoped to
46
- * the top-level entries that are NOT in `keep`.
47
- * 2. Cleans up any untracked files / empty directory that `git rm` left
48
- * behind, so the deleted paths are fully gone from the working tree.
49
- *
50
- * Caveats:
51
- * - Destructive: any local edits to deleted paths are lost. Run on a
52
- * clean working tree (or after committing your local changes).
53
- * - If `infrastructure/` doesn't exist, this codemod is a no-op.
54
- * - Requires git to be installed and the country config working directory
55
- * to be a git repo.
56
- */
57
- const fs_1 = require("fs");
58
- const path_1 = require("path");
59
- const checkout_upstream_files_1 = require("./checkout-upstream-files");
60
- const INFRASTRUCTURE_DIR = 'infrastructure';
61
- function main() {
62
- return __awaiter(this, arguments, void 0, function* ({ keep = [] } = {}) {
63
- const fullPath = (0, path_1.join)(process.cwd(), INFRASTRUCTURE_DIR);
64
- if (!(0, fs_1.existsSync)(fullPath)) {
65
- console.log(`'${INFRASTRUCTURE_DIR}/' not found in ${process.cwd()} — nothing to delete.`);
66
- return;
67
- }
68
- (0, checkout_upstream_files_1.assertIsGitRepo)();
69
- // ─── Whole-directory delete (legacy behavior) ────────────────────────
70
- if (keep.length === 0) {
71
- console.log(`Deleting '${INFRASTRUCTURE_DIR}/'...\n`);
72
- // `git rm -rf --ignore-unmatch` removes tracked files (working tree +
73
- // index) and is a no-op for paths with no tracked entries, so it's
74
- // safe to run even when `infrastructure/` exists only as untracked
75
- // files.
76
- (0, checkout_upstream_files_1.runGit)(['rm', '-rf', '--ignore-unmatch', '--', `${INFRASTRUCTURE_DIR}/`], {
77
- silent: true
78
- });
79
- console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR}/'.`);
80
- // `git rm` leaves untracked files (and any now-empty directory) on
81
- // disk; remove whatever's left so the path is fully gone.
82
- if ((0, fs_1.existsSync)(fullPath)) {
83
- (0, fs_1.rmSync)(fullPath, { recursive: true, force: true });
84
- console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR}/'.`);
85
- }
86
- console.log(`\n Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR}/'`);
87
- return;
88
- }
89
- // ─── Selective delete: keep listed top-level entries ─────────────────
90
- const keepSet = new Set(keep);
91
- console.log(`Deleting contents of '${INFRASTRUCTURE_DIR}/' except: ${[...keepSet]
92
- .map((name) => `'${name}'`)
93
- .join(', ')}\n`);
94
- const topLevelEntries = (0, fs_1.readdirSync)(fullPath, { withFileTypes: true });
95
- let deleted = 0;
96
- for (const entry of topLevelEntries) {
97
- if (keepSet.has(entry.name)) {
98
- console.log(` Keeping '${INFRASTRUCTURE_DIR}/${entry.name}'.`);
99
- continue;
100
- }
101
- // Append a trailing slash for directories so git treats it as a tree
102
- // pathspec (matches the recursive behavior of `git rm -rf`).
103
- const relPath = `${INFRASTRUCTURE_DIR}/${entry.name}${entry.isDirectory() ? '/' : ''}`;
104
- (0, checkout_upstream_files_1.runGit)(['rm', '-rf', '--ignore-unmatch', '--', relPath], { silent: true });
105
- const fullEntryPath = (0, path_1.join)(fullPath, entry.name);
106
- if ((0, fs_1.existsSync)(fullEntryPath)) {
107
- (0, fs_1.rmSync)(fullEntryPath, { recursive: true, force: true });
108
- }
109
- console.log(` Deleted '${relPath}'.`);
110
- deleted++;
111
- }
112
- // Note any requested keeps that weren't actually present, so the dev
113
- // notices typos / missing directories.
114
- const presentNames = new Set(topLevelEntries.map((e) => e.name));
115
- const missingKeeps = [...keepSet].filter((name) => !presentNames.has(name));
116
- if (missingKeeps.length > 0) {
117
- console.warn(` [warn] Requested to keep ${missingKeeps
118
- .map((n) => `'${n}'`)
119
- .join(', ')} but they don't exist under '${INFRASTRUCTURE_DIR}/'.`);
120
- }
121
- console.log(`\n Done. Deleted ${deleted} top-level entr${deleted === 1 ? 'y' : 'ies'}. Review the staged deletions with: git diff --cached -- '${INFRASTRUCTURE_DIR}/'`);
122
- });
123
- }
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=fix-accept-requested-registration-function-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fix-accept-requested-registration-function-type.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/fix-accept-requested-registration-function-type.ts"],"names":[],"mappings":"AAuFA,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}