@opencrvs/toolkit 2.1.0-rc.c8d2a48 → 2.1.0-rc.ce802f4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/application-config/index.js +1 -0
- package/dist/cli.js +77 -191
- package/dist/commons/api/router.d.ts +73 -2
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
- package/dist/commons/events/AuditLog.d.ts +23 -0
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locationPayloads.d.ts +95 -0
- package/dist/commons/events/locations.d.ts +7 -0
- package/dist/conditionals/index.js +1 -0
- package/dist/environment/index.d.ts +0 -1
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +0 -10
- package/dist/environment/setup-environment.js +1 -2
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +1 -2
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +3 -4
- package/dist/environment/users.js +13 -11
- package/dist/events/index.js +81 -0
- package/dist/notification/index.js +92 -25
- package/dist/scopes/index.d.ts +3 -1
- package/dist/scopes/index.js +1 -0
- package/opencrvs-toolkit-2.1.0-rc.ce802f4.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/environment/paths.d.ts +0 -11
- package/dist/environment/paths.d.ts.map +0 -1
- package/dist/environment/paths.js +0 -89
- package/dist/environment/upgrade.d.ts +0 -2
- package/dist/environment/upgrade.d.ts.map +0 -1
- package/dist/environment/upgrade.js +0 -80
- package/opencrvs-toolkit-2.1.0-rc.c8d2a48.tgz +0 -0
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -30,49 +30,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
mod
|
|
31
31
|
));
|
|
32
32
|
|
|
33
|
-
// src/environment/paths.ts
|
|
34
|
-
function getEnvironmentDir(environment) {
|
|
35
|
-
return (0, import_path2.join)("environments", environment);
|
|
36
|
-
}
|
|
37
|
-
function getEnvironmentInventoryPath(environment) {
|
|
38
|
-
return (0, import_path2.join)(getEnvironmentDir(environment), INVENTORY_FILE_NAME);
|
|
39
|
-
}
|
|
40
|
-
function findOldInventoryFiles() {
|
|
41
|
-
return glob.sync((0, import_path2.join)(OLD_INVENTORY_DIR, "*.yml")).sort();
|
|
42
|
-
}
|
|
43
|
-
function getEnvironmentNameFromOldInventoryPath(filePath) {
|
|
44
|
-
return (0, import_path2.basename)(filePath, ".yml");
|
|
45
|
-
}
|
|
46
|
-
function hasOldInventoryLayout() {
|
|
47
|
-
return findOldInventoryFiles().length > 0;
|
|
48
|
-
}
|
|
49
|
-
function assertNoOldInventoryLayout() {
|
|
50
|
-
if (!hasOldInventoryLayout()) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
throw new Error(
|
|
54
|
-
[
|
|
55
|
-
`Old inventory layout detected at ${OLD_INVENTORY_DIR}.`,
|
|
56
|
-
"Please run `yarn environment:upgrade` before running `yarn environment:init`."
|
|
57
|
-
].join(" ")
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
var import_fs, import_path2, glob, OLD_INVENTORY_DIR, INVENTORY_FILE_NAME;
|
|
61
|
-
var init_paths = __esm({
|
|
62
|
-
"src/environment/paths.ts"() {
|
|
63
|
-
"use strict";
|
|
64
|
-
import_fs = require("fs");
|
|
65
|
-
import_path2 = require("path");
|
|
66
|
-
glob = __toESM(require("glob"));
|
|
67
|
-
OLD_INVENTORY_DIR = (0, import_path2.join)(
|
|
68
|
-
"infrastructure",
|
|
69
|
-
"server-setup",
|
|
70
|
-
"inventory"
|
|
71
|
-
);
|
|
72
|
-
INVENTORY_FILE_NAME = "inventory.yml";
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
33
|
// src/environment/logger.ts
|
|
77
34
|
var import_kleur, log, warn, success, info, error;
|
|
78
35
|
var init_logger = __esm({
|
|
@@ -514,9 +471,9 @@ function storeSecrets(environment, answers) {
|
|
|
514
471
|
let envConfig = {};
|
|
515
472
|
try {
|
|
516
473
|
envConfig = import_dotenv.default.parse(
|
|
517
|
-
(0,
|
|
474
|
+
(0, import_fs.readFileSync)(`${process.cwd()}/.env.${environment}`)
|
|
518
475
|
);
|
|
519
|
-
} catch (
|
|
476
|
+
} catch (error4) {
|
|
520
477
|
envConfig = {};
|
|
521
478
|
}
|
|
522
479
|
const linesFromAnswers = answers.map(
|
|
@@ -524,10 +481,10 @@ function storeSecrets(environment, answers) {
|
|
|
524
481
|
);
|
|
525
482
|
const linesFromEnvConfig = Object.entries(envConfig).filter(([name]) => !answers.find((update) => update.name === name)).map(([name, value]) => `${name}="${value}"`);
|
|
526
483
|
const allLines = [...linesFromEnvConfig, ...linesFromAnswers].sort();
|
|
527
|
-
(0,
|
|
484
|
+
(0, import_fs.writeFileSync)(`.env.${environment}`, allLines.join("\n"));
|
|
528
485
|
}
|
|
529
486
|
function readYamlFile(filePath) {
|
|
530
|
-
const fileContent =
|
|
487
|
+
const fileContent = import_fs.default.readFileSync(filePath, "utf8");
|
|
531
488
|
return yaml.load(fileContent);
|
|
532
489
|
}
|
|
533
490
|
function writeYamlFile(filePath, data) {
|
|
@@ -540,16 +497,16 @@ function writeYamlFile(filePath, data) {
|
|
|
540
497
|
noRefs: true,
|
|
541
498
|
sortKeys: false
|
|
542
499
|
});
|
|
543
|
-
|
|
544
|
-
} catch (
|
|
545
|
-
throw new Error(`Failed to write inventory file: ${
|
|
500
|
+
import_fs.default.writeFileSync(filePath, yamlContent, "utf8");
|
|
501
|
+
} catch (error4) {
|
|
502
|
+
throw new Error(`Failed to write inventory file: ${error4}`);
|
|
546
503
|
}
|
|
547
504
|
}
|
|
548
|
-
var
|
|
505
|
+
var import_fs, yaml, import_dotenv;
|
|
549
506
|
var init_utils = __esm({
|
|
550
507
|
"src/environment/utils.ts"() {
|
|
551
508
|
"use strict";
|
|
552
|
-
|
|
509
|
+
import_fs = __toESM(require("fs"));
|
|
553
510
|
yaml = __toESM(require("js-yaml"));
|
|
554
511
|
import_dotenv = __toESM(require("dotenv"));
|
|
555
512
|
}
|
|
@@ -602,29 +559,29 @@ function extractWorkerNodes(data) {
|
|
|
602
559
|
return worker_hosts;
|
|
603
560
|
}
|
|
604
561
|
function copyChartsValues(env, values) {
|
|
605
|
-
const srcDir =
|
|
606
|
-
const destDir =
|
|
607
|
-
|
|
562
|
+
const srcDir = import_path2.default.resolve(__dirname, "templates", "charts-values");
|
|
563
|
+
const destDir = import_path2.default.resolve(process.cwd(), "environments", env);
|
|
564
|
+
import_fs2.default.mkdirSync(destDir, { recursive: true });
|
|
608
565
|
values["lets_encrypt"] = values["traefik_mode"] === "lets_encrypt";
|
|
609
566
|
values["static_ssl"] = values["traefik_mode"] === "static_ssl";
|
|
610
567
|
values["opencrvs_environment"] = env;
|
|
611
568
|
function copyRecursive(src, dest) {
|
|
612
|
-
const stat =
|
|
569
|
+
const stat = import_fs2.default.statSync(src);
|
|
613
570
|
if (stat.isDirectory()) {
|
|
614
|
-
|
|
615
|
-
for (const item of
|
|
616
|
-
copyRecursive(
|
|
571
|
+
import_fs2.default.mkdirSync(dest, { recursive: true });
|
|
572
|
+
for (const item of import_fs2.default.readdirSync(src)) {
|
|
573
|
+
copyRecursive(import_path2.default.join(src, item), import_path2.default.join(dest, item));
|
|
617
574
|
}
|
|
618
575
|
} else {
|
|
619
|
-
const content =
|
|
576
|
+
const content = import_fs2.default.readFileSync(src, "utf8");
|
|
620
577
|
const template = import_handlebars.default.compile(content);
|
|
621
578
|
const updated = template(values);
|
|
622
579
|
const isOverridesFile = dest.endsWith("override.yaml");
|
|
623
|
-
if (isOverridesFile &&
|
|
580
|
+
if (isOverridesFile && import_fs2.default.existsSync(dest)) {
|
|
624
581
|
log(` \u21B7 Skipped existing overrides file: ${dest}`);
|
|
625
582
|
return;
|
|
626
583
|
}
|
|
627
|
-
|
|
584
|
+
import_fs2.default.writeFileSync(dest, updated, "utf8");
|
|
628
585
|
log(` \u2713 Created: ${dest}`);
|
|
629
586
|
}
|
|
630
587
|
}
|
|
@@ -635,31 +592,36 @@ function copyChartsValues(env, values) {
|
|
|
635
592
|
`);
|
|
636
593
|
}
|
|
637
594
|
function generateInventory(env, values) {
|
|
638
|
-
const templatePath =
|
|
595
|
+
const templatePath = import_path2.default.join(
|
|
639
596
|
__dirname,
|
|
640
597
|
"templates",
|
|
641
598
|
"inventory",
|
|
642
599
|
"inventory.template.yml"
|
|
643
600
|
);
|
|
644
|
-
const outputPath =
|
|
645
|
-
|
|
601
|
+
const outputPath = import_path2.default.join(
|
|
602
|
+
process.cwd(),
|
|
603
|
+
"infrastructure",
|
|
604
|
+
"server-setup",
|
|
605
|
+
"inventory",
|
|
606
|
+
`${env}.yml`
|
|
607
|
+
);
|
|
608
|
+
const templateFile = import_fs2.default.readFileSync(templatePath, "utf-8");
|
|
646
609
|
const template = import_handlebars.default.compile(templateFile);
|
|
647
610
|
values["single_node"] = values["kube_worker_nodes"].length > 0 || values["backup_host"] ? "false" : "true";
|
|
648
611
|
const updated = template(values);
|
|
649
|
-
|
|
650
|
-
|
|
612
|
+
import_fs2.default.mkdirSync(import_path2.default.dirname(outputPath), { recursive: true });
|
|
613
|
+
import_fs2.default.writeFileSync(outputPath, updated);
|
|
651
614
|
log(`
|
|
652
615
|
\u2705 Generated inventory file at ${outputPath}
|
|
653
616
|
`);
|
|
654
617
|
}
|
|
655
|
-
var
|
|
618
|
+
var import_fs2, import_path2, import_handlebars;
|
|
656
619
|
var init_templates = __esm({
|
|
657
620
|
"src/environment/templates.ts"() {
|
|
658
621
|
"use strict";
|
|
659
|
-
|
|
660
|
-
|
|
622
|
+
import_fs2 = __toESM(require("fs"));
|
|
623
|
+
import_path2 = __toESM(require("path"));
|
|
661
624
|
init_logger();
|
|
662
|
-
init_paths();
|
|
663
625
|
import_handlebars = __toESM(require("handlebars"));
|
|
664
626
|
import_handlebars.default.registerHelper("data_label_idx", function(value) {
|
|
665
627
|
return parseInt(value) + 2;
|
|
@@ -1275,7 +1237,7 @@ function getCurrentUserSSHKeys() {
|
|
|
1275
1237
|
keys.push(keyContent);
|
|
1276
1238
|
}
|
|
1277
1239
|
}
|
|
1278
|
-
} catch (
|
|
1240
|
+
} catch (error4) {
|
|
1279
1241
|
continue;
|
|
1280
1242
|
}
|
|
1281
1243
|
}
|
|
@@ -1811,7 +1773,6 @@ var init_setup_environment = __esm({
|
|
|
1811
1773
|
init_editor_questions();
|
|
1812
1774
|
init_questions_helper();
|
|
1813
1775
|
init_manage_users();
|
|
1814
|
-
init_paths();
|
|
1815
1776
|
ALL_QUESTIONS = [];
|
|
1816
1777
|
ALL_ANSWERS = [];
|
|
1817
1778
|
ALL_QUESTIONS.push(
|
|
@@ -1975,7 +1936,9 @@ var init_setup_environment = __esm({
|
|
|
1975
1936
|
);
|
|
1976
1937
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes ? infrastructure.kubeWorkerNodes.split(",").map((ip) => ip.trim()) : [];
|
|
1977
1938
|
log("\n", import_kleur4.default.bold().underline("SSH Users"), "\n");
|
|
1978
|
-
const users = await manageUsers(
|
|
1939
|
+
const users = await manageUsers(
|
|
1940
|
+
`infrastructure/server-setup/inventory/${environment}.yml`
|
|
1941
|
+
);
|
|
1979
1942
|
log("\n", import_kleur4.default.bold().underline("Traefik SSL Certificate"), "\n");
|
|
1980
1943
|
const sslCertExists = findExistingValue(
|
|
1981
1944
|
"SSL_CRT",
|
|
@@ -2789,11 +2752,11 @@ __export(update_workflows_exports, {
|
|
|
2789
2752
|
updateWorkflowEnvironments: () => updateWorkflowEnvironments
|
|
2790
2753
|
});
|
|
2791
2754
|
async function extractInfrastructureNames() {
|
|
2792
|
-
const files =
|
|
2793
|
-
const infraEnvironments = files.map((file) => (0,
|
|
2755
|
+
const files = glob.sync("infrastructure/server-setup/inventory/*.yml");
|
|
2756
|
+
const infraEnvironments = files.map((file) => (0, import_path3.basename)(file, ".yml"));
|
|
2794
2757
|
if (infraEnvironments.length === 0) {
|
|
2795
2758
|
console.log(
|
|
2796
|
-
|
|
2759
|
+
"\u26A0\uFE0F Warning: No environment directories found in infrastructure/server-setup/inventory/"
|
|
2797
2760
|
);
|
|
2798
2761
|
return [];
|
|
2799
2762
|
}
|
|
@@ -2803,8 +2766,8 @@ async function extractInfrastructureNames() {
|
|
|
2803
2766
|
async function extractEnvironmentNames() {
|
|
2804
2767
|
const entries = await (0, import_promises.readdir)("environments");
|
|
2805
2768
|
const environments = entries.filter((entry) => {
|
|
2806
|
-
const fullPath = (0,
|
|
2807
|
-
return (0,
|
|
2769
|
+
const fullPath = (0, import_path3.join)("environments", entry);
|
|
2770
|
+
return (0, import_fs3.statSync)(fullPath).isDirectory();
|
|
2808
2771
|
});
|
|
2809
2772
|
if (environments.length === 0) {
|
|
2810
2773
|
console.log(
|
|
@@ -2830,7 +2793,7 @@ async function updateWorkflows(envList, config) {
|
|
|
2830
2793
|
const { workflows } = config;
|
|
2831
2794
|
for (const workflowPath of workflows) {
|
|
2832
2795
|
try {
|
|
2833
|
-
const fileContents = (0,
|
|
2796
|
+
const fileContents = (0, import_fs3.readFileSync)(workflowPath, "utf8");
|
|
2834
2797
|
const workflowData = yaml2.load(fileContents);
|
|
2835
2798
|
if (!workflowData?.on?.workflow_dispatch?.inputs?.environment?.options) {
|
|
2836
2799
|
throw new Error(
|
|
@@ -2838,15 +2801,15 @@ async function updateWorkflows(envList, config) {
|
|
|
2838
2801
|
);
|
|
2839
2802
|
}
|
|
2840
2803
|
const updatedContent = updateOptionsInYaml(fileContents, envList);
|
|
2841
|
-
(0,
|
|
2804
|
+
(0, import_fs3.writeFileSync)(workflowPath, updatedContent, "utf8");
|
|
2842
2805
|
log(` \u2713 Successfully updated ${workflowPath}`);
|
|
2843
|
-
} catch (
|
|
2806
|
+
} catch (error4) {
|
|
2844
2807
|
console.error(
|
|
2845
2808
|
`
|
|
2846
2809
|
\u26A0\uFE0F Error updating ${workflowPath} with environments: [${envList.join(", ")}]`
|
|
2847
2810
|
);
|
|
2848
|
-
console.error(`\u2717 Failed to update ${workflowPath}:`,
|
|
2849
|
-
throw
|
|
2811
|
+
console.error(`\u2717 Failed to update ${workflowPath}:`, error4);
|
|
2812
|
+
throw error4;
|
|
2850
2813
|
}
|
|
2851
2814
|
}
|
|
2852
2815
|
}
|
|
@@ -2887,89 +2850,21 @@ async function updateWorkflowEnvironments() {
|
|
|
2887
2850
|
} else {
|
|
2888
2851
|
log("\u2139\uFE0F No workflows were updated.");
|
|
2889
2852
|
}
|
|
2890
|
-
} catch (
|
|
2891
|
-
console.error("\n\u274C Error updating workflows:",
|
|
2853
|
+
} catch (error4) {
|
|
2854
|
+
console.error("\n\u274C Error updating workflows:", error4);
|
|
2892
2855
|
process.exit(1);
|
|
2893
2856
|
}
|
|
2894
2857
|
}
|
|
2895
|
-
var import_promises,
|
|
2858
|
+
var import_promises, import_fs3, import_path3, glob, yaml2;
|
|
2896
2859
|
var init_update_workflows = __esm({
|
|
2897
2860
|
"src/environment/update-workflows.ts"() {
|
|
2898
2861
|
"use strict";
|
|
2899
2862
|
import_promises = require("fs/promises");
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2863
|
+
import_fs3 = require("fs");
|
|
2864
|
+
import_path3 = require("path");
|
|
2865
|
+
glob = __toESM(require("glob"));
|
|
2903
2866
|
yaml2 = __toESM(require("js-yaml"));
|
|
2904
2867
|
init_logger();
|
|
2905
|
-
init_paths();
|
|
2906
|
-
}
|
|
2907
|
-
});
|
|
2908
|
-
|
|
2909
|
-
// src/environment/upgrade.ts
|
|
2910
|
-
var upgrade_exports = {};
|
|
2911
|
-
__export(upgrade_exports, {
|
|
2912
|
-
upgradeEnvironmentLayout: () => upgradeEnvironmentLayout
|
|
2913
|
-
});
|
|
2914
|
-
function moveFileIfDestinationMissing(sourcePath, destinationPath) {
|
|
2915
|
-
if (!(0, import_fs5.existsSync)(sourcePath)) {
|
|
2916
|
-
return false;
|
|
2917
|
-
}
|
|
2918
|
-
if ((0, import_fs5.existsSync)(destinationPath)) {
|
|
2919
|
-
warn(
|
|
2920
|
-
`\u26A0\uFE0F Skipped ${sourcePath}; destination already exists at ${destinationPath}`
|
|
2921
|
-
);
|
|
2922
|
-
return false;
|
|
2923
|
-
}
|
|
2924
|
-
(0, import_fs5.mkdirSync)((0, import_path5.dirname)(destinationPath), { recursive: true });
|
|
2925
|
-
(0, import_fs5.renameSync)(sourcePath, destinationPath);
|
|
2926
|
-
log(` \u2713 Moved ${sourcePath} -> ${destinationPath}`);
|
|
2927
|
-
return true;
|
|
2928
|
-
}
|
|
2929
|
-
function migrateInventoryFiles() {
|
|
2930
|
-
const oldInventoryFiles = findOldInventoryFiles();
|
|
2931
|
-
if (oldInventoryFiles.length === 0) {
|
|
2932
|
-
log(`\u2139\uFE0F No old inventory files found at ${OLD_INVENTORY_DIR}`);
|
|
2933
|
-
return false;
|
|
2934
|
-
}
|
|
2935
|
-
log(import_kleur5.default.bold("\nMigrating Ansible inventory files"));
|
|
2936
|
-
let didMoveInventory = false;
|
|
2937
|
-
for (const oldInventoryFile of oldInventoryFiles) {
|
|
2938
|
-
const environment = getEnvironmentNameFromOldInventoryPath(oldInventoryFile);
|
|
2939
|
-
didMoveInventory = moveFileIfDestinationMissing(
|
|
2940
|
-
oldInventoryFile,
|
|
2941
|
-
getEnvironmentInventoryPath(environment)
|
|
2942
|
-
) || didMoveInventory;
|
|
2943
|
-
}
|
|
2944
|
-
try {
|
|
2945
|
-
if ((0, import_fs5.existsSync)(OLD_INVENTORY_DIR) && (0, import_fs5.readdirSync)(OLD_INVENTORY_DIR).length === 0) {
|
|
2946
|
-
(0, import_fs5.rmdirSync)(OLD_INVENTORY_DIR);
|
|
2947
|
-
log(` \u2713 Removed empty ${OLD_INVENTORY_DIR}`);
|
|
2948
|
-
}
|
|
2949
|
-
} catch {
|
|
2950
|
-
warn(`\u26A0\uFE0F Could not remove ${OLD_INVENTORY_DIR}; please review it manually`);
|
|
2951
|
-
}
|
|
2952
|
-
return didMoveInventory;
|
|
2953
|
-
}
|
|
2954
|
-
async function upgradeEnvironmentLayout() {
|
|
2955
|
-
const didMoveInventory = migrateInventoryFiles();
|
|
2956
|
-
await updateWorkflowEnvironments();
|
|
2957
|
-
if (didMoveInventory) {
|
|
2958
|
-
success("\n\u2705 Environment layout upgrade completed successfully.");
|
|
2959
|
-
return;
|
|
2960
|
-
}
|
|
2961
|
-
success("\n\u2705 Environment layout already uses the current structure.");
|
|
2962
|
-
}
|
|
2963
|
-
var import_fs5, import_path5, import_kleur5;
|
|
2964
|
-
var init_upgrade = __esm({
|
|
2965
|
-
"src/environment/upgrade.ts"() {
|
|
2966
|
-
"use strict";
|
|
2967
|
-
import_fs5 = require("fs");
|
|
2968
|
-
import_path5 = require("path");
|
|
2969
|
-
import_kleur5 = __toESM(require("kleur"));
|
|
2970
|
-
init_logger();
|
|
2971
|
-
init_paths();
|
|
2972
|
-
init_update_workflows();
|
|
2973
2868
|
}
|
|
2974
2869
|
});
|
|
2975
2870
|
|
|
@@ -2982,7 +2877,7 @@ async function select4(options) {
|
|
|
2982
2877
|
const inquirer = await import("@inquirer/prompts");
|
|
2983
2878
|
return inquirer.select(options);
|
|
2984
2879
|
}
|
|
2985
|
-
async function selectInventoryFile(dirPath = "./
|
|
2880
|
+
async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inventory/") {
|
|
2986
2881
|
if (!fs4.existsSync(dirPath)) {
|
|
2987
2882
|
warn(`\u26A0\uFE0F No environment configuration directory found at ${dirPath}`);
|
|
2988
2883
|
warn(
|
|
@@ -2990,20 +2885,22 @@ async function selectInventoryFile(dirPath = "./environments") {
|
|
|
2990
2885
|
);
|
|
2991
2886
|
return null;
|
|
2992
2887
|
}
|
|
2993
|
-
const
|
|
2994
|
-
const filePath = path4.join(dirPath,
|
|
2995
|
-
|
|
2888
|
+
const files = fs4.readdirSync(dirPath).filter((file) => {
|
|
2889
|
+
const filePath = path4.join(dirPath, file);
|
|
2890
|
+
const isFile = fs4.statSync(filePath).isFile();
|
|
2891
|
+
const ext = path4.extname(file).slice(1).toLowerCase();
|
|
2892
|
+
return isFile && (ext === "yml" || ext === "yaml");
|
|
2996
2893
|
}).sort();
|
|
2997
|
-
if (
|
|
2894
|
+
if (files.length === 0) {
|
|
2998
2895
|
warn(`\u26A0\uFE0F No environment configuration files found at ${dirPath}`);
|
|
2999
2896
|
warn(
|
|
3000
2897
|
"Hint: If this is a new infrastructure repository, run `opencrvs environment init` first."
|
|
3001
2898
|
);
|
|
3002
2899
|
return null;
|
|
3003
2900
|
}
|
|
3004
|
-
const choices =
|
|
3005
|
-
name:
|
|
3006
|
-
value:
|
|
2901
|
+
const choices = files.map((file) => ({
|
|
2902
|
+
name: path4.basename(file, path4.extname(file)),
|
|
2903
|
+
value: path4.join(dirPath, file)
|
|
3007
2904
|
}));
|
|
3008
2905
|
const selectedFile = await select4({
|
|
3009
2906
|
message: "Select environment (inventory file) to load users:",
|
|
@@ -3012,34 +2909,33 @@ async function selectInventoryFile(dirPath = "./environments") {
|
|
|
3012
2909
|
return selectedFile;
|
|
3013
2910
|
}
|
|
3014
2911
|
async function manageEnvironmentUsers() {
|
|
3015
|
-
console.log("\n",
|
|
2912
|
+
console.log("\n", import_kleur5.default.bold().underline("Manage users"), "\n");
|
|
3016
2913
|
const inventory_file = await selectInventoryFile();
|
|
3017
2914
|
if (!inventory_file) {
|
|
3018
2915
|
return;
|
|
3019
2916
|
}
|
|
3020
2917
|
await manageUsers(inventory_file);
|
|
3021
2918
|
}
|
|
3022
|
-
var fs4, path4,
|
|
2919
|
+
var fs4, path4, import_kleur5;
|
|
3023
2920
|
var init_users = __esm({
|
|
3024
2921
|
"src/environment/users.ts"() {
|
|
3025
2922
|
"use strict";
|
|
3026
2923
|
fs4 = __toESM(require("fs"));
|
|
3027
2924
|
path4 = __toESM(require("path"));
|
|
3028
|
-
|
|
2925
|
+
import_kleur5 = __toESM(require("kleur"));
|
|
3029
2926
|
init_manage_users();
|
|
3030
2927
|
init_logger();
|
|
3031
|
-
init_paths();
|
|
3032
2928
|
}
|
|
3033
2929
|
});
|
|
3034
2930
|
|
|
3035
2931
|
// src/environment/swarm-to-k8s.ts
|
|
3036
2932
|
var swarm_to_k8s_exports = {};
|
|
3037
|
-
var path5,
|
|
2933
|
+
var path5, import_kleur6, import_core2;
|
|
3038
2934
|
var init_swarm_to_k8s = __esm({
|
|
3039
2935
|
"src/environment/swarm-to-k8s.ts"() {
|
|
3040
2936
|
"use strict";
|
|
3041
2937
|
path5 = __toESM(require("path"));
|
|
3042
|
-
|
|
2938
|
+
import_kleur6 = __toESM(require("kleur"));
|
|
3043
2939
|
init_logger();
|
|
3044
2940
|
init_utils();
|
|
3045
2941
|
init_templates();
|
|
@@ -3048,7 +2944,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
3048
2944
|
init_github();
|
|
3049
2945
|
(async () => {
|
|
3050
2946
|
log(
|
|
3051
|
-
|
|
2947
|
+
import_kleur6.default.bold(
|
|
3052
2948
|
"------------------------------------------------\nOpenCRVS Infrastructure migration script: \nMigrating Swarm configurations to Kubernetes\n------------------------------------------------\n"
|
|
3053
2949
|
)
|
|
3054
2950
|
);
|
|
@@ -3079,7 +2975,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
3079
2975
|
);
|
|
3080
2976
|
process.exit(0);
|
|
3081
2977
|
}
|
|
3082
|
-
log(
|
|
2978
|
+
log(import_kleur6.default.bold().underline("Migration properties:"));
|
|
3083
2979
|
log(` \u2713 Environment: ${environment}`);
|
|
3084
2980
|
const old_inventory_path = process.env.OLD_INVENTORY_PATH || "";
|
|
3085
2981
|
if (!old_inventory_path) {
|
|
@@ -3397,9 +3293,8 @@ async function runUpgrade(dockerSwarm) {
|
|
|
3397
3293
|
}
|
|
3398
3294
|
|
|
3399
3295
|
// src/environment/index.ts
|
|
3400
|
-
var
|
|
3401
|
-
var
|
|
3402
|
-
init_paths();
|
|
3296
|
+
var import_fs4 = require("fs");
|
|
3297
|
+
var import_path4 = require("path");
|
|
3403
3298
|
var REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
3404
3299
|
".github/workflows",
|
|
3405
3300
|
"environments",
|
|
@@ -3409,7 +3304,7 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3409
3304
|
const missingDirectories = REQUIRED_REPOSITORY_DIRECTORIES.filter(
|
|
3410
3305
|
(directory) => {
|
|
3411
3306
|
try {
|
|
3412
|
-
return !(0,
|
|
3307
|
+
return !(0, import_fs4.statSync)((0, import_path4.resolve)(repositoryRoot, directory)).isDirectory();
|
|
3413
3308
|
} catch {
|
|
3414
3309
|
return true;
|
|
3415
3310
|
}
|
|
@@ -3423,14 +3318,8 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3423
3318
|
}
|
|
3424
3319
|
async function runEnvironmentInit() {
|
|
3425
3320
|
validateRepositoryStructure();
|
|
3426
|
-
assertNoOldInventoryLayout();
|
|
3427
3321
|
await Promise.resolve().then(() => (init_setup_environment(), setup_environment_exports));
|
|
3428
3322
|
}
|
|
3429
|
-
async function runEnvironmentUpgrade() {
|
|
3430
|
-
validateRepositoryStructure();
|
|
3431
|
-
const { upgradeEnvironmentLayout: upgradeEnvironmentLayout2 } = await Promise.resolve().then(() => (init_upgrade(), upgrade_exports));
|
|
3432
|
-
await upgradeEnvironmentLayout2();
|
|
3433
|
-
}
|
|
3434
3323
|
async function runEnvironmentUpdateWorkflows() {
|
|
3435
3324
|
validateRepositoryStructure();
|
|
3436
3325
|
const { updateWorkflowEnvironments: updateWorkflowEnvironments2 } = await Promise.resolve().then(() => (init_update_workflows(), update_workflows_exports));
|
|
@@ -3500,7 +3389,6 @@ Usage: opencrvs environment <subcommand>
|
|
|
3500
3389
|
|
|
3501
3390
|
Subcommands:
|
|
3502
3391
|
init Initialise a new environment
|
|
3503
|
-
upgrade Upgrade existing environment configuration layout
|
|
3504
3392
|
update-workflows Update workflow environment options
|
|
3505
3393
|
users Manage environment users
|
|
3506
3394
|
swarm-to-k8s Migrate Docker Swarm configuration to Kubernetes
|
|
@@ -3511,8 +3399,6 @@ Subcommands:
|
|
|
3511
3399
|
switch (subcommand) {
|
|
3512
3400
|
case "init":
|
|
3513
3401
|
return runEnvironmentCommand("initialisation", runEnvironmentInit);
|
|
3514
|
-
case "upgrade":
|
|
3515
|
-
return runEnvironmentCommand("environment upgrade", runEnvironmentUpgrade);
|
|
3516
3402
|
case "update-workflows":
|
|
3517
3403
|
return runEnvironmentCommand(
|
|
3518
3404
|
"workflow update",
|
|
@@ -3533,10 +3419,10 @@ Subcommands:
|
|
|
3533
3419
|
async function runEnvironmentCommand(operation, command) {
|
|
3534
3420
|
try {
|
|
3535
3421
|
await command();
|
|
3536
|
-
} catch (
|
|
3422
|
+
} catch (error4) {
|
|
3537
3423
|
console.error(
|
|
3538
3424
|
`Environment ${operation} failed:`,
|
|
3539
|
-
|
|
3425
|
+
error4 instanceof Error ? error4.message : error4
|
|
3540
3426
|
);
|
|
3541
3427
|
process.exit(1);
|
|
3542
3428
|
}
|
|
@@ -3562,8 +3448,8 @@ async function handleUpgrade() {
|
|
|
3562
3448
|
try {
|
|
3563
3449
|
await runUpgrade(dockerSwarm);
|
|
3564
3450
|
console.log("Upgrade completed successfully!");
|
|
3565
|
-
} catch (
|
|
3566
|
-
console.error("Upgrade failed:",
|
|
3451
|
+
} catch (error4) {
|
|
3452
|
+
console.error("Upgrade failed:", error4);
|
|
3567
3453
|
process.exit(1);
|
|
3568
3454
|
}
|
|
3569
3455
|
}
|
|
@@ -7834,8 +7834,8 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
7834
7834
|
email?: string | undefined;
|
|
7835
7835
|
status?: string | undefined;
|
|
7836
7836
|
primaryOfficeId?: string | undefined;
|
|
7837
|
-
count
|
|
7838
|
-
skip
|
|
7837
|
+
count: number;
|
|
7838
|
+
skip: number;
|
|
7839
7839
|
sortBy?: "createdAt" | "email" | "firstname" | "role" | "status" | "surname" | "username" | undefined;
|
|
7840
7840
|
sortOrder: "asc" | "desc";
|
|
7841
7841
|
};
|
|
@@ -8242,6 +8242,23 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8242
8242
|
responseSummary: {
|
|
8243
8243
|
clientId: string;
|
|
8244
8244
|
};
|
|
8245
|
+
} | {
|
|
8246
|
+
id: string;
|
|
8247
|
+
clientId: string;
|
|
8248
|
+
clientType: "system" | "user";
|
|
8249
|
+
createdAt: string;
|
|
8250
|
+
operation: "administrativeAreas.create" | "locations.create";
|
|
8251
|
+
requestData: {
|
|
8252
|
+
id: string;
|
|
8253
|
+
versionId: string;
|
|
8254
|
+
name: string;
|
|
8255
|
+
externalId?: string | null | undefined;
|
|
8256
|
+
administrativeAreaId?: string | null | undefined;
|
|
8257
|
+
parentId?: string | null | undefined;
|
|
8258
|
+
locationType?: string | null | undefined;
|
|
8259
|
+
effectiveFrom: string;
|
|
8260
|
+
status: string;
|
|
8261
|
+
};
|
|
8245
8262
|
} | {
|
|
8246
8263
|
id: string;
|
|
8247
8264
|
clientId: string;
|
|
@@ -8374,6 +8391,34 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8374
8391
|
output: void;
|
|
8375
8392
|
meta: object;
|
|
8376
8393
|
}>;
|
|
8394
|
+
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
8395
|
+
input: {
|
|
8396
|
+
id?: string | undefined;
|
|
8397
|
+
versionId?: string | undefined;
|
|
8398
|
+
name: string;
|
|
8399
|
+
externalId?: string | null | undefined;
|
|
8400
|
+
administrativeAreaId: string | null;
|
|
8401
|
+
locationType: string | null;
|
|
8402
|
+
effectiveFrom?: string | undefined;
|
|
8403
|
+
status?: "active" | "inactive" | undefined;
|
|
8404
|
+
};
|
|
8405
|
+
output: {
|
|
8406
|
+
id: string & import("zod").$brand<"UUID">;
|
|
8407
|
+
name: string;
|
|
8408
|
+
externalId?: string | null | undefined;
|
|
8409
|
+
administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
|
|
8410
|
+
locationType: string | null;
|
|
8411
|
+
status: "active" | "inactive";
|
|
8412
|
+
versions: {
|
|
8413
|
+
versionId: string & import("zod").$brand<"UUID">;
|
|
8414
|
+
effectiveFrom: string;
|
|
8415
|
+
name: string;
|
|
8416
|
+
externalId?: string | null | undefined;
|
|
8417
|
+
status: "active" | "inactive";
|
|
8418
|
+
}[];
|
|
8419
|
+
};
|
|
8420
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
8421
|
+
}>;
|
|
8377
8422
|
get: import("@trpc/server").TRPCQueryProcedure<{
|
|
8378
8423
|
input: {
|
|
8379
8424
|
id: string;
|
|
@@ -8820,6 +8865,32 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8820
8865
|
output: void;
|
|
8821
8866
|
meta: object;
|
|
8822
8867
|
}>;
|
|
8868
|
+
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
8869
|
+
input: {
|
|
8870
|
+
id?: string | undefined;
|
|
8871
|
+
versionId?: string | undefined;
|
|
8872
|
+
name: string;
|
|
8873
|
+
externalId?: string | null | undefined;
|
|
8874
|
+
parentId: string | null;
|
|
8875
|
+
effectiveFrom?: string | undefined;
|
|
8876
|
+
status?: "active" | "inactive" | undefined;
|
|
8877
|
+
};
|
|
8878
|
+
output: {
|
|
8879
|
+
id: string & import("zod").$brand<"UUID">;
|
|
8880
|
+
name: string;
|
|
8881
|
+
externalId?: string | null | undefined;
|
|
8882
|
+
parentId: (string & import("zod").$brand<"UUID">) | null;
|
|
8883
|
+
status: "active" | "inactive";
|
|
8884
|
+
versions: {
|
|
8885
|
+
versionId: string & import("zod").$brand<"UUID">;
|
|
8886
|
+
effectiveFrom: string;
|
|
8887
|
+
name: string;
|
|
8888
|
+
externalId?: string | null | undefined;
|
|
8889
|
+
status: "active" | "inactive";
|
|
8890
|
+
}[];
|
|
8891
|
+
};
|
|
8892
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
8893
|
+
}>;
|
|
8823
8894
|
}>>;
|
|
8824
8895
|
integrations: import("@trpc/server").TRPCBuiltRouter<{
|
|
8825
8896
|
ctx: Partial<{
|