@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
@@ -121,10 +121,9 @@ const github_1 = require("./github");
121
121
  (0, templates_1.copyChartsValues)(environment, {
122
122
  env: environment,
123
123
  environment_type: environment_type,
124
- // FIXME: In general that should be environment_type,
125
- // Hardcode like this blocks us from being generic:
126
- // https://github.com/opencrvs/opencrvs-core/issues/11171
127
- two_fa_enabled: environment !== 'production' ? false : true,
124
+ two_fa_enabled: process.env.TWO_FA_ENABLED
125
+ ? process.env.TWO_FA_ENABLED === 'true'
126
+ : environment_type === 'production',
128
127
  backup_enabled: environment === 'production' ? 'true' : 'false',
129
128
  restore_enabled: environment === 'staging' ? 'true' : 'false',
130
129
  restore_environment_name: environment === 'staging' ? 'production' : '',
@@ -1,4 +1,3 @@
1
- export declare function getUsers(data: any): any;
2
1
  export declare function extractAndModifyUsers(data: any): any;
3
2
  export declare function dockerManagerFirst(data: any): string;
4
3
  export declare function extractBackupNode(data: any): string;
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AAuBA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAKvC;AAID,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAYpD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsBzE"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/environment/templates.ts"],"names":[],"mappings":"AA0BA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAepD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAWpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAStD;AAGD;;;;GAIG;AACH;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QA0CzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAsBzE"}
@@ -24,7 +24,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.getUsers = getUsers;
28
27
  exports.extractAndModifyUsers = extractAndModifyUsers;
29
28
  exports.dockerManagerFirst = dockerManagerFirst;
30
29
  exports.extractBackupNode = extractBackupNode;
@@ -40,13 +39,6 @@ const handlebars_1 = __importDefault(require("handlebars"));
40
39
  handlebars_1.default.registerHelper('data_label_idx', function (value) {
41
40
  return parseInt(value) + 2;
42
41
  });
43
- function getUsers(data) {
44
- var _a, _b;
45
- if (!((_b = (_a = data === null || data === void 0 ? void 0 : data.all) === null || _a === void 0 ? void 0 : _a.vars) === null || _b === void 0 ? void 0 : _b.users)) {
46
- return { users: [] };
47
- }
48
- return data.all.vars.users;
49
- }
50
42
  // START: TEMPORAL SECTION FOR TRANSITION FROM DOCKER SWARM TO K8s
51
43
  // Extract users from the old inventory
52
44
  // Docker swarm format to new
@@ -56,6 +48,9 @@ function extractAndModifyUsers(data) {
56
48
  return { users: [] };
57
49
  }
58
50
  const users = data.all.vars.users.map((user) => {
51
+ if (user.role) {
52
+ return user;
53
+ }
59
54
  const { sudoer } = user, rest = __rest(user, ["sudoer"]);
60
55
  return Object.assign(Object.assign({}, rest), { role: sudoer ? 'admin' : 'operator' });
61
56
  });
@@ -1 +1 @@
1
- {"version":3,"file":"update-workflows.d.ts","sourceRoot":"","sources":["../../src/environment/update-workflows.ts"],"names":[],"mappings":"AA+HA,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAgDhE"}
1
+ {"version":3,"file":"update-workflows.d.ts","sourceRoot":"","sources":["../../src/environment/update-workflows.ts"],"names":[],"mappings":"AAmIA,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAgDhE"}
@@ -121,6 +121,10 @@ function updateWorkflows(envList, config) {
121
121
  var _a, _b, _c, _d;
122
122
  const { workflows } = config;
123
123
  for (const workflowPath of workflows) {
124
+ if (!(0, fs_1.existsSync)(workflowPath)) {
125
+ (0, logger_1.log)(` ↷ Skipped ${workflowPath} (not found in this repository)`);
126
+ continue;
127
+ }
124
128
  try {
125
129
  const fileContents = (0, fs_1.readFileSync)(workflowPath, 'utf8');
126
130
  // Verify the file is valid YAML and has the expected structure
@@ -1,18 +1,6 @@
1
1
  import { Secret, Variable } from './github';
2
- import { Answers } from './custom-types';
3
2
  export declare function generateLongPassword(): string;
4
3
  export declare function findExistingValue<T extends string>(name: string, type: T, scope: 'ENVIRONMENT' | 'REPOSITORY', existingValues: Array<Secret | Variable>): (T extends 'SECRET' ? Secret : T extends 'VARIABLE' ? Variable : never) | undefined;
5
- /**
6
- * Merges and stores secrets in `.env.{environment}` file.
7
- * Updates existing variables, preserves unchanged ones, adds new ones.
8
- *
9
- * @param environment - Environment name (e.g., 'production')
10
- * @param answers - Variables to update: `[{ name: 'KEY', value: 'val' }]`
11
- *
12
- * @example
13
- * storeSecrets('prod', [{ name: 'API_KEY', value: 'abc123' }]);
14
- */
15
- export declare function storeSecrets(environment: string, answers: Answers): void;
16
4
  export declare function readYamlFile(filePath: any): any;
17
5
  export declare function writeYamlFile(filePath: string, data: any): void;
18
6
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/environment/utils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,wBAAgB,oBAAoB,WAMnC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,aAAa,GAAG,YAAY,EACnC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAMpC,CAAC,CAAC,SAAS,QAAQ,GAAG,MAAM,GAAG,CAAC,SAAS,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC,GACvE,SAAS,CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,QAoBjE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CAG/C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,QAcxD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/environment/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE3C,wBAAgB,oBAAoB,WAMnC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,aAAa,GAAG,YAAY,EACnC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAMpC,CAAC,CAAC,SAAS,QAAQ,GAAG,MAAM,GAAG,CAAC,SAAS,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC,GACvE,SAAS,CACd;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CAG/C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,QAcxD"}
@@ -48,12 +48,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
49
  exports.generateLongPassword = generateLongPassword;
50
50
  exports.findExistingValue = findExistingValue;
51
- exports.storeSecrets = storeSecrets;
52
51
  exports.readYamlFile = readYamlFile;
53
52
  exports.writeYamlFile = writeYamlFile;
54
- const fs_1 = __importStar(require("fs"));
53
+ const fs_1 = __importDefault(require("fs"));
55
54
  const yaml = __importStar(require("js-yaml"));
56
- const dotenv_1 = __importDefault(require("dotenv"));
57
55
  function generateLongPassword() {
58
56
  const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
59
57
  let result = '';
@@ -64,31 +62,6 @@ function generateLongPassword() {
64
62
  function findExistingValue(name, type, scope, existingValues) {
65
63
  return existingValues.find((value) => value.name === name && value.type === type && value.scope === scope);
66
64
  }
67
- /**
68
- * Merges and stores secrets in `.env.{environment}` file.
69
- * Updates existing variables, preserves unchanged ones, adds new ones.
70
- *
71
- * @param environment - Environment name (e.g., 'production')
72
- * @param answers - Variables to update: `[{ name: 'KEY', value: 'val' }]`
73
- *
74
- * @example
75
- * storeSecrets('prod', [{ name: 'API_KEY', value: 'abc123' }]);
76
- */
77
- function storeSecrets(environment, answers) {
78
- let envConfig = {};
79
- try {
80
- envConfig = dotenv_1.default.parse((0, fs_1.readFileSync)(`${process.cwd()}/.env.${environment}`));
81
- }
82
- catch (error) {
83
- envConfig = {};
84
- }
85
- const linesFromAnswers = answers.map((update) => `${update.name}="${update.value}"`);
86
- const linesFromEnvConfig = Object.entries(envConfig)
87
- .filter(([name]) => !answers.find((update) => update.name === name))
88
- .map(([name, value]) => `${name}="${value}"`);
89
- const allLines = [...linesFromEnvConfig, ...linesFromAnswers].sort();
90
- (0, fs_1.writeFileSync)(`.env.${environment}`, allLines.join('\n'));
91
- }
92
65
  function readYamlFile(filePath) {
93
66
  const fileContent = fs_1.default.readFileSync(filePath, 'utf8');
94
67
  return yaml.load(fileContent);