@opencrvs/toolkit 2.1.0-rc.982e0ae → 2.1.0-rc.9a83eed

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +2 -12
  2. package/create-countryconfig/index.js +133 -2
  3. package/dist/application-config/index.js +17 -18
  4. package/dist/authentication/index.js +7 -6
  5. package/dist/cli.js +458 -204
  6. package/dist/commons/api/router.d.ts +6 -42
  7. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  8. package/dist/commons/conditionals/validate.d.ts +1 -1
  9. package/dist/commons/events/ActionConfig.d.ts +4 -0
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -12
  11. package/dist/commons/events/FieldConfig.d.ts +16 -15
  12. package/dist/commons/events/FormConfig.d.ts +6 -0
  13. package/dist/commons/events/PageConfig.d.ts +4 -0
  14. package/dist/commons/events/locations.d.ts +4 -0
  15. package/dist/commons/events/test.utils.d.ts +18 -1
  16. package/dist/commons/events/utils.d.ts +15 -0
  17. package/dist/conditionals/index.js +7 -6
  18. package/dist/environment/manage-users.js +1 -1
  19. package/dist/environment/setup-environment.js +44 -26
  20. package/dist/environment/templates.d.ts +0 -1
  21. package/dist/environment/templates.d.ts.map +1 -1
  22. package/dist/environment/templates.js +3 -8
  23. package/dist/environment/update-workflows.d.ts.map +1 -1
  24. package/dist/environment/update-workflows.js +4 -0
  25. package/dist/environment/utils.d.ts +0 -12
  26. package/dist/environment/utils.d.ts.map +1 -1
  27. package/dist/environment/utils.js +1 -28
  28. package/dist/events/index.js +1901 -1792
  29. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  30. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +1 -1
  31. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -1
  32. package/dist/migrations/v2.1/add-explicit-correction-flags.js +34 -6
  33. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +1 -1
  34. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -1
  35. package/dist/migrations/v2.1/add-recovery-link-notifications.js +2 -7
  36. package/dist/migrations/v2.1/add-translations.d.ts +1 -1
  37. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -1
  38. package/dist/migrations/v2.1/add-translations.js +1 -6
  39. package/dist/migrations/v2.1/enable-telemetry.d.ts +1 -1
  40. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -1
  41. package/dist/migrations/v2.1/enable-telemetry.js +1 -6
  42. package/dist/migrations/v2.1/index.d.ts +14 -1
  43. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  44. package/dist/migrations/v2.1/index.js +96 -84
  45. package/dist/notification/index.js +155 -152
  46. package/dist/scopes/index.d.ts +109 -5
  47. package/dist/scopes/index.js +7 -6
  48. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  49. package/dist/translations/check.d.ts +2 -0
  50. package/dist/translations/check.d.ts.map +1 -1
  51. package/dist/translations/check.js +9 -4
  52. package/dist/verify/endpoints.d.ts +18 -1
  53. package/dist/verify/endpoints.d.ts.map +1 -1
  54. package/dist/verify/endpoints.js +12 -4
  55. package/dist/verify/scopes.d.ts +13 -0
  56. package/dist/verify/scopes.d.ts.map +1 -0
  57. package/dist/verify/scopes.js +131 -0
  58. package/dist/verify/upgrade.d.ts +14 -0
  59. package/dist/verify/upgrade.d.ts.map +1 -0
  60. package/dist/verify/upgrade.js +111 -0
  61. package/opencrvs-toolkit-2.1.0-rc.9a83eed.tgz +0 -0
  62. package/package.json +2 -2
  63. package/tsconfig.build.tsbuildinfo +1 -1
  64. package/opencrvs-toolkit-2.1.0-rc.982e0ae.tgz +0 -0
@@ -10,6 +10,7 @@ import { UUID } from '../uuid';
10
10
  import { ActionConfig, ActionConfigTypes } from './ActionConfig';
11
11
  import { FormConfig } from './FormConfig';
12
12
  import { PlainDate, SelectDateRangeValue } from './FieldValue';
13
+ import { EventIndex } from './EventIndex';
13
14
  export declare function ageToDate(age: number, asOfDate: PlainDate): string & import("zod").$brand<"PlainDate">;
14
15
  export declare function getDeclarationFields(configuration: EventConfig): FieldConfig[];
15
16
  export declare function getDeclarationPages(configuration: EventConfig): {
@@ -20,6 +21,7 @@ export declare function getDeclarationPages(configuration: EventConfig): {
20
21
  description: string;
21
22
  };
22
23
  requireCompletionToContinue: boolean;
24
+ showClearButton?: boolean | undefined;
23
25
  fields: FieldConfig[];
24
26
  conditional?: any;
25
27
  type: "FORM";
@@ -38,6 +40,7 @@ export declare function getDeclaration(configuration: EventConfig): {
38
40
  description: string;
39
41
  };
40
42
  requireCompletionToContinue: boolean;
43
+ showClearButton?: boolean | undefined;
41
44
  fields: FieldConfig[];
42
45
  conditional?: any;
43
46
  type: "FORM";
@@ -66,6 +69,7 @@ export declare function getPrintCertificatePages(configuration: EventConfig): ({
66
69
  description: string;
67
70
  };
68
71
  requireCompletionToContinue: boolean;
72
+ showClearButton?: boolean | undefined;
69
73
  fields: FieldConfig[];
70
74
  conditional?: any;
71
75
  type: "FORM";
@@ -77,6 +81,7 @@ export declare function getPrintCertificatePages(configuration: EventConfig): ({
77
81
  description: string;
78
82
  };
79
83
  requireCompletionToContinue: boolean;
84
+ showClearButton?: boolean | undefined;
80
85
  fields: FieldConfig[];
81
86
  conditional?: any;
82
87
  type: "VERIFICATION";
@@ -597,4 +602,14 @@ export declare function getCompleteActionDeclaration<T extends EventState | Acti
597
602
  export declare function getAcceptedActions(event: EventDocument): ActionDocument[];
598
603
  export declare function aggregateActionDeclarations(event: EventDocument): EventState;
599
604
  export declare function aggregateActionAnnotations(event: EventDocument): EventState;
605
+ /**
606
+ * 2.1. onwards secured fields have accepted conditionals.
607
+ * Secured fields are not present in EventIndex payload.
608
+ * When we derive @see EventIndex from @see EventDocument, we will have all the fields present.
609
+ *
610
+ * To keep the views consistent, and not to change if event.get gets triggered, we need to clean out the secured fields.
611
+ *
612
+ * @returns EventIndex without values that evaluate to secured: true.
613
+ */
614
+ export declare function dropSecuredDeclarationFields(eventConfig: EventConfig, eventIndex: EventIndex, validatorContext: ValidatorContext): EventIndex;
600
615
  //# sourceMappingURL=utils.d.ts.map
@@ -436,10 +436,7 @@ var PlainScopeType = z11.enum([
436
436
  // Performance dashboard
437
437
  "performance.read",
438
438
  "performance.read-dashboards",
439
- "performance.vital-statistics-export",
440
- // Scopes used exclusively by countryconfig integration token
441
- "record.confirm-registration",
442
- "record.reject-registration"
439
+ "performance.vital-statistics-export"
443
440
  ]);
444
441
  var scopeByEvent = z11.preprocess(
445
442
  (val) => val === void 0 ? void 0 : [val].flat(),
@@ -457,7 +454,9 @@ var userRole = z11.preprocess(
457
454
  ).describe("User role, e.g. admin, field agent");
458
455
  var scopeOptionsPlaceEvent = z11.object({
459
456
  event: scopeByEvent,
460
- placeOfEvent: JurisdictionFilter.optional()
457
+ placeOfEvent: JurisdictionFilter.optional(),
458
+ createdBy: UserFilter.optional(),
459
+ createdIn: JurisdictionFilter.optional()
461
460
  }).describe("Options applicable to all record scopes.");
462
461
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
463
462
  notifiedIn: JurisdictionFilter.optional(),
@@ -500,7 +499,9 @@ var AllScopeOptions = z11.object({
500
499
  var ScopeOptionKey = AllScopeOptions.keyof();
501
500
  var ResolvedScopeOptionsPlaceEvent = z11.object({
502
501
  event: scopeByEvent,
503
- placeOfEvent: UUID.nullish()
502
+ placeOfEvent: UUID.nullish(),
503
+ createdBy: z11.string().optional(),
504
+ createdIn: UUID.nullish()
504
505
  }).describe(
505
506
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
506
507
  );
@@ -95,7 +95,7 @@ function updateInventoryFile(filePath, users) {
95
95
  function parseInventoryFile(filePath) {
96
96
  try {
97
97
  const data = (0, utils_1.readYamlFile)(filePath);
98
- return (0, templates_1.getUsers)(data);
98
+ return (0, templates_1.extractAndModifyUsers)(data);
99
99
  }
100
100
  catch (_a) {
101
101
  return [];
@@ -34,7 +34,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const core_1 = require("@octokit/core");
37
- const dotenv_1 = __importDefault(require("dotenv"));
38
37
  const kleur_1 = __importDefault(require("kleur"));
39
38
  const prompts_1 = __importDefault(require("prompts"));
40
39
  function confirm(options) {
@@ -49,6 +48,12 @@ function select(options) {
49
48
  return inquirer.select(options);
50
49
  });
51
50
  }
51
+ function input(options) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const inquirer = yield import('@inquirer/prompts');
54
+ return inquirer.input(options);
55
+ });
56
+ }
52
57
  const github_1 = require("./github");
53
58
  const derived_variables_1 = require("./derived-variables");
54
59
  const utils_1 = require("./utils");
@@ -105,7 +110,7 @@ function getAnswers(existingValues) {
105
110
  });
106
111
  });
107
112
  }
108
- function promptAndStoreAnswer(environment, questions, existingValues) {
113
+ function promptAndStoreAnswer(questions, existingValues) {
109
114
  return __awaiter(this, void 0, void 0, function* () {
110
115
  (0, logger_1.log)('');
111
116
  const processedQuestions = questions.flatMap((question) => {
@@ -158,7 +163,6 @@ function promptAndStoreAnswer(environment, questions, existingValues) {
158
163
  }
159
164
  });
160
165
  ALL_ANSWERS.push(result);
161
- (0, utils_1.storeSecrets)(environment, getAnswers(existingValues));
162
166
  const existingValuesForQuestions = questions
163
167
  // Only variables can have previous values we can use
164
168
  .filter((question) => question.valueType === 'VARIABLE')
@@ -171,14 +175,14 @@ function promptAndStoreAnswer(environment, questions, existingValues) {
171
175
  }
172
176
  ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOtherQuestions, ...questions_1.dockerhubQuestions, ...questions_1.diskQuestions, ...questions_1.infrastructureQuestions, ...questions_1.backupQuestions, ...questions_1.countryQuestions, ...questions_1.databaseAndMonitoringQuestions, ...questions_1.emailQuestions, ...questions_1.sentryQuestions, ...derived_variables_1.derivedVariables, ...questions_1.metabaseAdminQuestions);
173
177
  (() => __awaiter(void 0, void 0, void 0, function* () {
174
- var _a, _b, _c;
178
+ var _a, _b, _c, _d;
175
179
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Github'), '\n');
176
180
  const { githubOrganisation, githubRepository } = yield (0, prompts_1.default)(questions_1.githubQuestions.map(questionToPrompt), {
177
181
  onCancel: () => {
178
182
  process.exit(1);
179
183
  }
180
184
  });
181
- const { githubToken } = yield promptAndStoreAnswer('', questions_1.githubTokenQuestion, []);
185
+ const { githubToken } = yield promptAndStoreAnswer(questions_1.githubTokenQuestion, []);
182
186
  const octokit = new core_1.Octokit({
183
187
  auth: githubToken
184
188
  });
@@ -238,10 +242,6 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
238
242
  if (!environment) {
239
243
  process.exit(1);
240
244
  }
241
- // Read users .env file based on the environment name they gave above, e.g. .env.production
242
- dotenv_1.default.config({
243
- path: `${process.cwd()}/.env.${environment}`
244
- });
245
245
  yield (0, github_1.createEnvironment)(octokit, environment, githubOrganisation, githubRepository);
246
246
  const repositoryId = yield (0, github_1.getRepositoryId)(octokit, githubOrganisation, githubRepository);
247
247
  const existingRepositorySecrets = yield (0, github_1.listRepositorySecrets)(octokit, githubOrganisation, githubRepository);
@@ -262,12 +262,12 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
262
262
  (0, logger_1.log)('\n', kleur_1.default
263
263
  .yellow()
264
264
  .bold('WARNING! You are setting up a production environment.\n Make sure you have read the deployment guide carefully before proceeding.\n'));
265
- yield promptAndStoreAnswer(environment, questions_1.githubOtherQuestions, existingValues);
265
+ yield promptAndStoreAnswer(questions_1.githubOtherQuestions, existingValues);
266
266
  }
267
267
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Docker Hub'));
268
- yield promptAndStoreAnswer(environment, questions_1.dockerhubQuestions, existingValues);
268
+ yield promptAndStoreAnswer(questions_1.dockerhubQuestions, existingValues);
269
269
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Kubernetes & Runtime'));
270
- const infrastructure = yield promptAndStoreAnswer(environment, questions_1.infrastructureQuestions, existingValues);
270
+ const infrastructure = yield promptAndStoreAnswer(questions_1.infrastructureQuestions, existingValues);
271
271
  const kubeWorkerNodes = infrastructure.kubeWorkerNodes
272
272
  ? infrastructure.kubeWorkerNodes.split(',').map((ip) => ip.trim())
273
273
  : [];
@@ -309,7 +309,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
309
309
  }
310
310
  if (enableEncryption && !encryption_key_defined && !environment_exists) {
311
311
  (0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow(' Disk encryption is enabled'));
312
- yield promptAndStoreAnswer(environment, questions_1.diskQuestions, existingValues);
312
+ yield promptAndStoreAnswer(questions_1.diskQuestions, existingValues);
313
313
  }
314
314
  else {
315
315
  if (!enableEncryption && !encryption_key_defined && environment_exists) {
@@ -331,7 +331,8 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
331
331
  let backupHost = ((_a = (0, utils_1.findExistingValue)('BACKUP_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _a === void 0 ? void 0 : _a.value) || '';
332
332
  let backupType = '';
333
333
  let restoreEnvironmentName = (_b = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _b === void 0 ? void 0 : _b.value;
334
- let restoreType = ((_c = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _c === void 0 ? void 0 : _c.value) ||
334
+ let restoreHost = ((_c = (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _c === void 0 ? void 0 : _c.value) || '';
335
+ let restoreType = ((_d = (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_MODE', 'VARIABLE', 'ENVIRONMENT', existingValues)) === null || _d === void 0 ? void 0 : _d.value) ||
335
336
  process.env.RESTORE_ENVIRONMENT_MODE ||
336
337
  'dump';
337
338
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Backup'));
@@ -346,7 +347,7 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
346
347
  let backupHostPrivateKey = '';
347
348
  let backupHostPublicKey = '';
348
349
  if (configureBackup) {
349
- const backupAnswers = yield promptAndStoreAnswer(environment, questions_1.backupQuestions, existingValues);
350
+ const backupAnswers = yield promptAndStoreAnswer(questions_1.backupQuestions, existingValues);
350
351
  const backupHostPrivateKeyExists = (0, utils_1.findExistingValue)('BACKUP_HOST_PRIVATE_KEY', 'SECRET', 'ENVIRONMENT', existingValues);
351
352
  backupType = backupAnswers.backupType;
352
353
  backupHost = backupAnswers.backupHost || backupHost;
@@ -393,16 +394,20 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
393
394
  }
394
395
  ]
395
396
  });
397
+ restoreHost = yield input({
398
+ message: 'What is the host/IP address of the restore backup server?',
399
+ default: restoreHost
400
+ });
396
401
  }
397
402
  else {
398
403
  (0, logger_1.log)(kleur_1.default.bold().green('✔'), kleur_1.default.bold().yellow('Restore is disabled'));
399
404
  }
400
405
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Monitoring'));
401
- yield promptAndStoreAnswer(environment, questions_1.databaseAndMonitoringQuestions, existingValues);
406
+ yield promptAndStoreAnswer(questions_1.databaseAndMonitoringQuestions, existingValues);
402
407
  const sentryDSNExists = (0, utils_1.findExistingValue)('SENTRY_DSN', 'SECRET', 'ENVIRONMENT', existingValues);
403
408
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('Sentry'));
404
409
  if (sentryDSNExists) {
405
- yield promptAndStoreAnswer(environment, questions_1.sentryQuestions, existingValues);
410
+ yield promptAndStoreAnswer(questions_1.sentryQuestions, existingValues);
406
411
  }
407
412
  else {
408
413
  const { useSentry } = yield (0, prompts_1.default)([
@@ -414,13 +419,13 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
414
419
  }
415
420
  ]);
416
421
  if (useSentry) {
417
- yield promptAndStoreAnswer(environment, questions_1.sentryQuestions, existingValues);
422
+ yield promptAndStoreAnswer(questions_1.sentryQuestions, existingValues);
418
423
  }
419
424
  }
420
425
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('METABASE ADMIN'));
421
- yield promptAndStoreAnswer(environment, questions_1.metabaseAdminQuestions, existingValues);
426
+ yield promptAndStoreAnswer(questions_1.metabaseAdminQuestions, existingValues);
422
427
  (0, logger_1.log)('\n', kleur_1.default.bold().underline('SMTP'));
423
- yield promptAndStoreAnswer(environment, questions_1.emailQuestions, existingValues);
428
+ yield promptAndStoreAnswer(questions_1.emailQuestions, existingValues);
424
429
  const allAnswers = ALL_ANSWERS.reduce((acc, answer) => {
425
430
  return Object.assign(Object.assign({}, acc), answer);
426
431
  });
@@ -557,6 +562,13 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
557
562
  value: answerOrExisting(restoreEnvironmentName, (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
558
563
  didExist: (0, utils_1.findExistingValue)('RESTORE_ENVIRONMENT_NAME', 'VARIABLE', 'ENVIRONMENT', existingValues),
559
564
  scope: 'ENVIRONMENT'
565
+ },
566
+ {
567
+ type: 'VARIABLE',
568
+ name: 'RESTORE_HOST',
569
+ value: answerOrExisting(restoreHost, (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues), (val) => val || ''),
570
+ didExist: (0, utils_1.findExistingValue)('RESTORE_HOST', 'VARIABLE', 'ENVIRONMENT', existingValues),
571
+ scope: 'ENVIRONMENT'
560
572
  }
561
573
  ];
562
574
  if (enableEncryption) {
@@ -591,7 +603,6 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
591
603
  // Only update values that changed
592
604
  (variable.type !== 'VARIABLE' ||
593
605
  variable.value !== ((_a = variable.didExist) === null || _a === void 0 ? void 0 : _a.value)); });
594
- (0, utils_1.storeSecrets)(environment, updates);
595
606
  /*
596
607
  * List out all updates to the variables and confirm with the user
597
608
  */
@@ -670,6 +681,10 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
670
681
  .concat(updatedVariables).length === 0) {
671
682
  process.exit(0);
672
683
  }
684
+ (0, logger_1.log)(kleur_1.default
685
+ .bold()
686
+ .red("⚠️ COPY THESE NOW INTO A PASSWORD MANAGER — YOU WON'T SEE THEM AGAIN"));
687
+ (0, logger_1.log)('');
673
688
  const saveChanges = yield confirm({
674
689
  message: 'Do you want to continue?',
675
690
  default: true
@@ -728,12 +743,14 @@ ALL_QUESTIONS.push(...questions_1.githubTokenQuestion, ...questions_1.githubOthe
728
743
  // Hardcode like this blocks us from being generic:
729
744
  // https://github.com/opencrvs/opencrvs-core/issues/11171
730
745
  two_fa_enabled: environment !== 'production' ? false : true,
731
- backup_enabled: configureBackup ? true : false,
746
+ traefik_mode: traefikConfOption,
732
747
  restore_enabled: restoreEnvironmentName ? true : false,
733
748
  restore_environment_name: restoreEnvironmentName || '',
734
749
  restore_type: restoreType,
735
- traefik_mode: traefikConfOption,
736
- backup_type: backupType
750
+ restore_host: restoreHost || '',
751
+ backup_enabled: configureBackup ? true : false,
752
+ backup_type: backupType,
753
+ backup_host: backupHost || ''
737
754
  });
738
755
  let addon_message = kubeWorkerNodes.length > 0 || configureBackup
739
756
  ? '--------------------------------------------------------------------------------------------\n' +
@@ -770,6 +787,7 @@ ${addon_message}
770
787
  ${kleur_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')}
771
788
  ${kleur_1.default.yellow('Please KINDLY read hints above')}
772
789
  `);
773
- (0, logger_1.log)('\nAll variables stored in', kleur_1.default.cyan(`.env.${environment}`));
774
- (0, logger_1.log)(kleur_1.default.bold().yellow('DO NOT COMMIT THIS FILE TO GIT!'));
790
+ (0, logger_1.log)('\nAll secrets and variables were printed above.', kleur_1.default
791
+ .bold()
792
+ .yellow('Store them in a password manager — they are not saved to disk.'));
775
793
  }))();
@@ -1,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);