@opencrvs/toolkit 2.1.0-rc.a2d8806 → 2.1.0-rc.a434ca3
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 +1 -0
- package/create-countryconfig/index.js +59 -24
- package/dist/application-config/index.js +227 -196
- package/dist/cli.js +174 -58
- package/dist/commons/api/router.d.ts +193 -20
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/conditionals/validate.d.ts +8 -1
- package/dist/commons/events/ActionDocument.d.ts +1 -7
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
- package/dist/commons/events/AuditLog.d.ts +110 -0
- package/dist/commons/events/EventConfig.d.ts +3 -0
- package/dist/commons/events/EventIndex.d.ts +3 -26
- package/dist/commons/events/FieldConfig.d.ts +65 -53
- package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
- package/dist/commons/events/Flag.d.ts +42 -0
- package/dist/commons/events/SummaryConfig.d.ts +249 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
- package/dist/commons/events/event.d.ts +12 -0
- package/dist/conditionals/index.js +302 -55
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +10 -0
- package/dist/environment/logger.d.ts +12 -3
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/paths.d.ts +7 -0
- package/dist/environment/paths.d.ts.map +1 -0
- package/dist/environment/paths.js +72 -0
- package/dist/environment/setup-environment.js +2 -1
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +2 -1
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +17 -5
- package/dist/environment/upgrade.d.ts +2 -0
- package/dist/environment/upgrade.d.ts.map +1 -0
- package/dist/environment/upgrade.js +82 -0
- package/dist/environment/users.js +11 -13
- package/dist/events/index.js +3438 -3250
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
- package/dist/notification/index.js +1771 -1049
- package/dist/scopes/index.d.ts +248 -25
- package/dist/scopes/index.js +303 -55
- package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
- package/dist/templates/charts-values/opentelemetry/values.yaml +73 -0
- package/opencrvs-toolkit-2.1.0-rc.a434ca3.tgz +0 -0
- package/package.json +5 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.1.0-rc.a2d8806.tgz +0 -0
package/dist/cli.js
CHANGED
|
@@ -30,6 +30,42 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
mod
|
|
31
31
|
));
|
|
32
32
|
|
|
33
|
+
// src/environment/paths.ts
|
|
34
|
+
function getEnvironmentInventoryPath(environment) {
|
|
35
|
+
return (0, import_path2.join)("environments", environment, INVENTORY_FILE_NAME);
|
|
36
|
+
}
|
|
37
|
+
function findOldInventoryFiles() {
|
|
38
|
+
return glob.sync((0, import_path2.join)(OLD_INVENTORY_DIR, "*.yml")).sort();
|
|
39
|
+
}
|
|
40
|
+
function getEnvironmentNameFromOldInventoryPath(filePath) {
|
|
41
|
+
return (0, import_path2.basename)(filePath, ".yml");
|
|
42
|
+
}
|
|
43
|
+
function assertNoOldInventoryLayout() {
|
|
44
|
+
if (findOldInventoryFiles().length === 0) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
throw new Error(
|
|
48
|
+
[
|
|
49
|
+
`Old inventory layout detected at ${OLD_INVENTORY_DIR}.`,
|
|
50
|
+
"Please run `yarn environment:upgrade` before running `yarn environment:init`."
|
|
51
|
+
].join(" ")
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
var import_path2, glob, OLD_INVENTORY_DIR, INVENTORY_FILE_NAME;
|
|
55
|
+
var init_paths = __esm({
|
|
56
|
+
"src/environment/paths.ts"() {
|
|
57
|
+
"use strict";
|
|
58
|
+
import_path2 = require("path");
|
|
59
|
+
glob = __toESM(require("glob"));
|
|
60
|
+
OLD_INVENTORY_DIR = (0, import_path2.join)(
|
|
61
|
+
"infrastructure",
|
|
62
|
+
"server-setup",
|
|
63
|
+
"inventory"
|
|
64
|
+
);
|
|
65
|
+
INVENTORY_FILE_NAME = "inventory.yml";
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
33
69
|
// src/environment/logger.ts
|
|
34
70
|
var import_kleur, log, warn, success, info, error;
|
|
35
71
|
var init_logger = __esm({
|
|
@@ -473,7 +509,7 @@ function storeSecrets(environment, answers) {
|
|
|
473
509
|
envConfig = import_dotenv.default.parse(
|
|
474
510
|
(0, import_fs.readFileSync)(`${process.cwd()}/.env.${environment}`)
|
|
475
511
|
);
|
|
476
|
-
} catch (
|
|
512
|
+
} catch (error3) {
|
|
477
513
|
envConfig = {};
|
|
478
514
|
}
|
|
479
515
|
const linesFromAnswers = answers.map(
|
|
@@ -498,8 +534,8 @@ function writeYamlFile(filePath, data) {
|
|
|
498
534
|
sortKeys: false
|
|
499
535
|
});
|
|
500
536
|
import_fs.default.writeFileSync(filePath, yamlContent, "utf8");
|
|
501
|
-
} catch (
|
|
502
|
-
throw new Error(`Failed to write inventory file: ${
|
|
537
|
+
} catch (error3) {
|
|
538
|
+
throw new Error(`Failed to write inventory file: ${error3}`);
|
|
503
539
|
}
|
|
504
540
|
}
|
|
505
541
|
var import_fs, yaml, import_dotenv;
|
|
@@ -559,8 +595,8 @@ function extractWorkerNodes(data) {
|
|
|
559
595
|
return worker_hosts;
|
|
560
596
|
}
|
|
561
597
|
function copyChartsValues(env, values) {
|
|
562
|
-
const srcDir =
|
|
563
|
-
const destDir =
|
|
598
|
+
const srcDir = import_path3.default.resolve(__dirname, "templates", "charts-values");
|
|
599
|
+
const destDir = import_path3.default.resolve(process.cwd(), "environments", env);
|
|
564
600
|
import_fs2.default.mkdirSync(destDir, { recursive: true });
|
|
565
601
|
values["lets_encrypt"] = values["traefik_mode"] === "lets_encrypt";
|
|
566
602
|
values["static_ssl"] = values["traefik_mode"] === "static_ssl";
|
|
@@ -570,7 +606,7 @@ function copyChartsValues(env, values) {
|
|
|
570
606
|
if (stat.isDirectory()) {
|
|
571
607
|
import_fs2.default.mkdirSync(dest, { recursive: true });
|
|
572
608
|
for (const item of import_fs2.default.readdirSync(src)) {
|
|
573
|
-
copyRecursive(
|
|
609
|
+
copyRecursive(import_path3.default.join(src, item), import_path3.default.join(dest, item));
|
|
574
610
|
}
|
|
575
611
|
} else {
|
|
576
612
|
const content = import_fs2.default.readFileSync(src, "utf8");
|
|
@@ -592,36 +628,31 @@ function copyChartsValues(env, values) {
|
|
|
592
628
|
`);
|
|
593
629
|
}
|
|
594
630
|
function generateInventory(env, values) {
|
|
595
|
-
const templatePath =
|
|
631
|
+
const templatePath = import_path3.default.join(
|
|
596
632
|
__dirname,
|
|
597
633
|
"templates",
|
|
598
634
|
"inventory",
|
|
599
635
|
"inventory.template.yml"
|
|
600
636
|
);
|
|
601
|
-
const outputPath =
|
|
602
|
-
process.cwd(),
|
|
603
|
-
"infrastructure",
|
|
604
|
-
"server-setup",
|
|
605
|
-
"inventory",
|
|
606
|
-
`${env}.yml`
|
|
607
|
-
);
|
|
637
|
+
const outputPath = import_path3.default.resolve(process.cwd(), getEnvironmentInventoryPath(env));
|
|
608
638
|
const templateFile = import_fs2.default.readFileSync(templatePath, "utf-8");
|
|
609
639
|
const template = import_handlebars.default.compile(templateFile);
|
|
610
640
|
values["single_node"] = values["kube_worker_nodes"].length > 0 || values["backup_host"] ? "false" : "true";
|
|
611
641
|
const updated = template(values);
|
|
612
|
-
import_fs2.default.mkdirSync(
|
|
642
|
+
import_fs2.default.mkdirSync(import_path3.default.dirname(outputPath), { recursive: true });
|
|
613
643
|
import_fs2.default.writeFileSync(outputPath, updated);
|
|
614
644
|
log(`
|
|
615
645
|
\u2705 Generated inventory file at ${outputPath}
|
|
616
646
|
`);
|
|
617
647
|
}
|
|
618
|
-
var import_fs2,
|
|
648
|
+
var import_fs2, import_path3, import_handlebars;
|
|
619
649
|
var init_templates = __esm({
|
|
620
650
|
"src/environment/templates.ts"() {
|
|
621
651
|
"use strict";
|
|
622
652
|
import_fs2 = __toESM(require("fs"));
|
|
623
|
-
|
|
653
|
+
import_path3 = __toESM(require("path"));
|
|
624
654
|
init_logger();
|
|
655
|
+
init_paths();
|
|
625
656
|
import_handlebars = __toESM(require("handlebars"));
|
|
626
657
|
import_handlebars.default.registerHelper("data_label_idx", function(value) {
|
|
627
658
|
return parseInt(value) + 2;
|
|
@@ -1237,7 +1268,7 @@ function getCurrentUserSSHKeys() {
|
|
|
1237
1268
|
keys.push(keyContent);
|
|
1238
1269
|
}
|
|
1239
1270
|
}
|
|
1240
|
-
} catch (
|
|
1271
|
+
} catch (error3) {
|
|
1241
1272
|
continue;
|
|
1242
1273
|
}
|
|
1243
1274
|
}
|
|
@@ -1773,6 +1804,7 @@ var init_setup_environment = __esm({
|
|
|
1773
1804
|
init_editor_questions();
|
|
1774
1805
|
init_questions_helper();
|
|
1775
1806
|
init_manage_users();
|
|
1807
|
+
init_paths();
|
|
1776
1808
|
ALL_QUESTIONS = [];
|
|
1777
1809
|
ALL_ANSWERS = [];
|
|
1778
1810
|
ALL_QUESTIONS.push(
|
|
@@ -1936,9 +1968,7 @@ var init_setup_environment = __esm({
|
|
|
1936
1968
|
);
|
|
1937
1969
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes ? infrastructure.kubeWorkerNodes.split(",").map((ip) => ip.trim()) : [];
|
|
1938
1970
|
log("\n", import_kleur4.default.bold().underline("SSH Users"), "\n");
|
|
1939
|
-
const users = await manageUsers(
|
|
1940
|
-
`infrastructure/server-setup/inventory/${environment}.yml`
|
|
1941
|
-
);
|
|
1971
|
+
const users = await manageUsers(getEnvironmentInventoryPath(environment));
|
|
1942
1972
|
log("\n", import_kleur4.default.bold().underline("Traefik SSL Certificate"), "\n");
|
|
1943
1973
|
const sslCertExists = findExistingValue(
|
|
1944
1974
|
"SSL_CRT",
|
|
@@ -2751,12 +2781,19 @@ var update_workflows_exports = {};
|
|
|
2751
2781
|
__export(update_workflows_exports, {
|
|
2752
2782
|
updateWorkflowEnvironments: () => updateWorkflowEnvironments
|
|
2753
2783
|
});
|
|
2784
|
+
function isDirectory(path6) {
|
|
2785
|
+
try {
|
|
2786
|
+
return (0, import_fs3.statSync)(path6).isDirectory();
|
|
2787
|
+
} catch {
|
|
2788
|
+
return false;
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2754
2791
|
async function extractInfrastructureNames() {
|
|
2755
|
-
const files =
|
|
2756
|
-
const infraEnvironments = files.map((file) => (0,
|
|
2792
|
+
const files = glob2.sync((0, import_path4.join)("environments", "*", INVENTORY_FILE_NAME));
|
|
2793
|
+
const infraEnvironments = files.map((file) => (0, import_path4.basename)((0, import_path4.dirname)(file)));
|
|
2757
2794
|
if (infraEnvironments.length === 0) {
|
|
2758
2795
|
console.log(
|
|
2759
|
-
|
|
2796
|
+
`\u26A0\uFE0F Warning: No environment inventory files found at environments/*/${INVENTORY_FILE_NAME}`
|
|
2760
2797
|
);
|
|
2761
2798
|
return [];
|
|
2762
2799
|
}
|
|
@@ -2766,8 +2803,9 @@ async function extractInfrastructureNames() {
|
|
|
2766
2803
|
async function extractEnvironmentNames() {
|
|
2767
2804
|
const entries = await (0, import_promises.readdir)("environments");
|
|
2768
2805
|
const environments = entries.filter((entry) => {
|
|
2769
|
-
const
|
|
2770
|
-
|
|
2806
|
+
const environmentPath = (0, import_path4.join)("environments", entry);
|
|
2807
|
+
const opencrvsServicesPath = (0, import_path4.join)(environmentPath, "opencrvs-services");
|
|
2808
|
+
return isDirectory(environmentPath) && (0, import_fs3.existsSync)(opencrvsServicesPath) && isDirectory(opencrvsServicesPath);
|
|
2771
2809
|
});
|
|
2772
2810
|
if (environments.length === 0) {
|
|
2773
2811
|
console.log(
|
|
@@ -2803,13 +2841,13 @@ async function updateWorkflows(envList, config) {
|
|
|
2803
2841
|
const updatedContent = updateOptionsInYaml(fileContents, envList);
|
|
2804
2842
|
(0, import_fs3.writeFileSync)(workflowPath, updatedContent, "utf8");
|
|
2805
2843
|
log(` \u2713 Successfully updated ${workflowPath}`);
|
|
2806
|
-
} catch (
|
|
2844
|
+
} catch (error3) {
|
|
2807
2845
|
console.error(
|
|
2808
2846
|
`
|
|
2809
2847
|
\u26A0\uFE0F Error updating ${workflowPath} with environments: [${envList.join(", ")}]`
|
|
2810
2848
|
);
|
|
2811
|
-
console.error(`\u2717 Failed to update ${workflowPath}:`,
|
|
2812
|
-
throw
|
|
2849
|
+
console.error(`\u2717 Failed to update ${workflowPath}:`, error3);
|
|
2850
|
+
throw error3;
|
|
2813
2851
|
}
|
|
2814
2852
|
}
|
|
2815
2853
|
}
|
|
@@ -2850,21 +2888,90 @@ async function updateWorkflowEnvironments() {
|
|
|
2850
2888
|
} else {
|
|
2851
2889
|
log("\u2139\uFE0F No workflows were updated.");
|
|
2852
2890
|
}
|
|
2853
|
-
} catch (
|
|
2854
|
-
console.error("\n\u274C Error updating workflows:",
|
|
2891
|
+
} catch (error3) {
|
|
2892
|
+
console.error("\n\u274C Error updating workflows:", error3);
|
|
2855
2893
|
process.exit(1);
|
|
2856
2894
|
}
|
|
2857
2895
|
}
|
|
2858
|
-
var import_promises, import_fs3,
|
|
2896
|
+
var import_promises, import_fs3, import_path4, glob2, yaml2;
|
|
2859
2897
|
var init_update_workflows = __esm({
|
|
2860
2898
|
"src/environment/update-workflows.ts"() {
|
|
2861
2899
|
"use strict";
|
|
2862
2900
|
import_promises = require("fs/promises");
|
|
2863
2901
|
import_fs3 = require("fs");
|
|
2864
|
-
|
|
2865
|
-
|
|
2902
|
+
import_path4 = require("path");
|
|
2903
|
+
glob2 = __toESM(require("glob"));
|
|
2866
2904
|
yaml2 = __toESM(require("js-yaml"));
|
|
2867
2905
|
init_logger();
|
|
2906
|
+
init_paths();
|
|
2907
|
+
}
|
|
2908
|
+
});
|
|
2909
|
+
|
|
2910
|
+
// src/environment/upgrade.ts
|
|
2911
|
+
var upgrade_exports = {};
|
|
2912
|
+
__export(upgrade_exports, {
|
|
2913
|
+
upgradeEnvironmentLayout: () => upgradeEnvironmentLayout
|
|
2914
|
+
});
|
|
2915
|
+
function moveFileIfDestinationMissing(sourcePath, destinationPath) {
|
|
2916
|
+
if (!(0, import_fs4.existsSync)(sourcePath)) {
|
|
2917
|
+
return false;
|
|
2918
|
+
}
|
|
2919
|
+
if ((0, import_fs4.existsSync)(destinationPath)) {
|
|
2920
|
+
warn(
|
|
2921
|
+
`\u26A0\uFE0F Skipped ${sourcePath}; destination already exists at ${destinationPath}`
|
|
2922
|
+
);
|
|
2923
|
+
return false;
|
|
2924
|
+
}
|
|
2925
|
+
(0, import_fs4.mkdirSync)((0, import_path5.dirname)(destinationPath), { recursive: true });
|
|
2926
|
+
(0, import_fs4.renameSync)(sourcePath, destinationPath);
|
|
2927
|
+
log(` \u2713 Moved ${sourcePath} -> ${destinationPath}`);
|
|
2928
|
+
return true;
|
|
2929
|
+
}
|
|
2930
|
+
function migrateInventoryFiles() {
|
|
2931
|
+
const oldInventoryFiles = findOldInventoryFiles();
|
|
2932
|
+
if (oldInventoryFiles.length === 0) {
|
|
2933
|
+
log(`\u2139\uFE0F No old inventory files found at ${OLD_INVENTORY_DIR}`);
|
|
2934
|
+
return false;
|
|
2935
|
+
}
|
|
2936
|
+
log(import_kleur5.default.bold("\nMigrating Ansible inventory files"));
|
|
2937
|
+
let didMoveInventory = false;
|
|
2938
|
+
for (const oldInventoryFile of oldInventoryFiles) {
|
|
2939
|
+
const environment = getEnvironmentNameFromOldInventoryPath(oldInventoryFile);
|
|
2940
|
+
didMoveInventory = moveFileIfDestinationMissing(
|
|
2941
|
+
oldInventoryFile,
|
|
2942
|
+
getEnvironmentInventoryPath(environment)
|
|
2943
|
+
) || didMoveInventory;
|
|
2944
|
+
}
|
|
2945
|
+
try {
|
|
2946
|
+
if ((0, import_fs4.existsSync)(OLD_INVENTORY_DIR) && (0, import_fs4.readdirSync)(OLD_INVENTORY_DIR).length === 0) {
|
|
2947
|
+
(0, import_fs4.rmdirSync)(OLD_INVENTORY_DIR);
|
|
2948
|
+
log(` \u2713 Removed empty ${OLD_INVENTORY_DIR}`);
|
|
2949
|
+
}
|
|
2950
|
+
} catch {
|
|
2951
|
+
warn(`\u26A0\uFE0F Could not remove ${OLD_INVENTORY_DIR}; please review it manually`);
|
|
2952
|
+
}
|
|
2953
|
+
return didMoveInventory;
|
|
2954
|
+
}
|
|
2955
|
+
async function upgradeEnvironmentLayout() {
|
|
2956
|
+
const didMoveInventory = migrateInventoryFiles();
|
|
2957
|
+
await updateWorkflowEnvironments();
|
|
2958
|
+
if (didMoveInventory) {
|
|
2959
|
+
success("\n\u2705 Environment layout upgrade completed successfully.");
|
|
2960
|
+
} else {
|
|
2961
|
+
success("\n\u2705 Environment layout already uses the current structure.");
|
|
2962
|
+
}
|
|
2963
|
+
log("\nCommit changes into git after upgrade");
|
|
2964
|
+
}
|
|
2965
|
+
var import_fs4, import_path5, import_kleur5;
|
|
2966
|
+
var init_upgrade = __esm({
|
|
2967
|
+
"src/environment/upgrade.ts"() {
|
|
2968
|
+
"use strict";
|
|
2969
|
+
import_fs4 = require("fs");
|
|
2970
|
+
import_path5 = require("path");
|
|
2971
|
+
import_kleur5 = __toESM(require("kleur"));
|
|
2972
|
+
init_logger();
|
|
2973
|
+
init_paths();
|
|
2974
|
+
init_update_workflows();
|
|
2868
2975
|
}
|
|
2869
2976
|
});
|
|
2870
2977
|
|
|
@@ -2877,7 +2984,7 @@ async function select4(options) {
|
|
|
2877
2984
|
const inquirer = await import("@inquirer/prompts");
|
|
2878
2985
|
return inquirer.select(options);
|
|
2879
2986
|
}
|
|
2880
|
-
async function selectInventoryFile(dirPath = "./
|
|
2987
|
+
async function selectInventoryFile(dirPath = "./environments") {
|
|
2881
2988
|
if (!fs4.existsSync(dirPath)) {
|
|
2882
2989
|
warn(`\u26A0\uFE0F No environment configuration directory found at ${dirPath}`);
|
|
2883
2990
|
warn(
|
|
@@ -2885,22 +2992,20 @@ async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inve
|
|
|
2885
2992
|
);
|
|
2886
2993
|
return null;
|
|
2887
2994
|
}
|
|
2888
|
-
const
|
|
2889
|
-
const filePath = path4.join(dirPath,
|
|
2890
|
-
|
|
2891
|
-
const ext = path4.extname(file).slice(1).toLowerCase();
|
|
2892
|
-
return isFile && (ext === "yml" || ext === "yaml");
|
|
2995
|
+
const environments = fs4.readdirSync(dirPath).filter((entry) => {
|
|
2996
|
+
const filePath = path4.join(dirPath, entry);
|
|
2997
|
+
return fs4.statSync(filePath).isDirectory() && fs4.existsSync(getEnvironmentInventoryPath(entry));
|
|
2893
2998
|
}).sort();
|
|
2894
|
-
if (
|
|
2999
|
+
if (environments.length === 0) {
|
|
2895
3000
|
warn(`\u26A0\uFE0F No environment configuration files found at ${dirPath}`);
|
|
2896
3001
|
warn(
|
|
2897
3002
|
"Hint: If this is a new infrastructure repository, run `opencrvs environment init` first."
|
|
2898
3003
|
);
|
|
2899
3004
|
return null;
|
|
2900
3005
|
}
|
|
2901
|
-
const choices =
|
|
2902
|
-
name:
|
|
2903
|
-
value:
|
|
3006
|
+
const choices = environments.map((environment) => ({
|
|
3007
|
+
name: environment,
|
|
3008
|
+
value: getEnvironmentInventoryPath(environment)
|
|
2904
3009
|
}));
|
|
2905
3010
|
const selectedFile = await select4({
|
|
2906
3011
|
message: "Select environment (inventory file) to load users:",
|
|
@@ -2909,33 +3014,34 @@ async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inve
|
|
|
2909
3014
|
return selectedFile;
|
|
2910
3015
|
}
|
|
2911
3016
|
async function manageEnvironmentUsers() {
|
|
2912
|
-
console.log("\n",
|
|
3017
|
+
console.log("\n", import_kleur6.default.bold().underline("Manage users"), "\n");
|
|
2913
3018
|
const inventory_file = await selectInventoryFile();
|
|
2914
3019
|
if (!inventory_file) {
|
|
2915
3020
|
return;
|
|
2916
3021
|
}
|
|
2917
3022
|
await manageUsers(inventory_file);
|
|
2918
3023
|
}
|
|
2919
|
-
var fs4, path4,
|
|
3024
|
+
var fs4, path4, import_kleur6;
|
|
2920
3025
|
var init_users = __esm({
|
|
2921
3026
|
"src/environment/users.ts"() {
|
|
2922
3027
|
"use strict";
|
|
2923
3028
|
fs4 = __toESM(require("fs"));
|
|
2924
3029
|
path4 = __toESM(require("path"));
|
|
2925
|
-
|
|
3030
|
+
import_kleur6 = __toESM(require("kleur"));
|
|
2926
3031
|
init_manage_users();
|
|
2927
3032
|
init_logger();
|
|
3033
|
+
init_paths();
|
|
2928
3034
|
}
|
|
2929
3035
|
});
|
|
2930
3036
|
|
|
2931
3037
|
// src/environment/swarm-to-k8s.ts
|
|
2932
3038
|
var swarm_to_k8s_exports = {};
|
|
2933
|
-
var path5,
|
|
3039
|
+
var path5, import_kleur7, import_core2;
|
|
2934
3040
|
var init_swarm_to_k8s = __esm({
|
|
2935
3041
|
"src/environment/swarm-to-k8s.ts"() {
|
|
2936
3042
|
"use strict";
|
|
2937
3043
|
path5 = __toESM(require("path"));
|
|
2938
|
-
|
|
3044
|
+
import_kleur7 = __toESM(require("kleur"));
|
|
2939
3045
|
init_logger();
|
|
2940
3046
|
init_utils();
|
|
2941
3047
|
init_templates();
|
|
@@ -2944,7 +3050,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
2944
3050
|
init_github();
|
|
2945
3051
|
(async () => {
|
|
2946
3052
|
log(
|
|
2947
|
-
|
|
3053
|
+
import_kleur7.default.bold(
|
|
2948
3054
|
"------------------------------------------------\nOpenCRVS Infrastructure migration script: \nMigrating Swarm configurations to Kubernetes\n------------------------------------------------\n"
|
|
2949
3055
|
)
|
|
2950
3056
|
);
|
|
@@ -2975,7 +3081,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
2975
3081
|
);
|
|
2976
3082
|
process.exit(0);
|
|
2977
3083
|
}
|
|
2978
|
-
log(
|
|
3084
|
+
log(import_kleur7.default.bold().underline("Migration properties:"));
|
|
2979
3085
|
log(` \u2713 Environment: ${environment}`);
|
|
2980
3086
|
const old_inventory_path = process.env.OLD_INVENTORY_PATH || "";
|
|
2981
3087
|
if (!old_inventory_path) {
|
|
@@ -3293,8 +3399,9 @@ async function runUpgrade(dockerSwarm) {
|
|
|
3293
3399
|
}
|
|
3294
3400
|
|
|
3295
3401
|
// src/environment/index.ts
|
|
3296
|
-
var
|
|
3297
|
-
var
|
|
3402
|
+
var import_fs5 = require("fs");
|
|
3403
|
+
var import_path6 = require("path");
|
|
3404
|
+
init_paths();
|
|
3298
3405
|
var REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
3299
3406
|
".github/workflows",
|
|
3300
3407
|
"environments",
|
|
@@ -3304,7 +3411,7 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3304
3411
|
const missingDirectories = REQUIRED_REPOSITORY_DIRECTORIES.filter(
|
|
3305
3412
|
(directory) => {
|
|
3306
3413
|
try {
|
|
3307
|
-
return !(0,
|
|
3414
|
+
return !(0, import_fs5.statSync)((0, import_path6.resolve)(repositoryRoot, directory)).isDirectory();
|
|
3308
3415
|
} catch {
|
|
3309
3416
|
return true;
|
|
3310
3417
|
}
|
|
@@ -3318,8 +3425,14 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3318
3425
|
}
|
|
3319
3426
|
async function runEnvironmentInit() {
|
|
3320
3427
|
validateRepositoryStructure();
|
|
3428
|
+
assertNoOldInventoryLayout();
|
|
3321
3429
|
await Promise.resolve().then(() => (init_setup_environment(), setup_environment_exports));
|
|
3322
3430
|
}
|
|
3431
|
+
async function runEnvironmentUpgrade() {
|
|
3432
|
+
validateRepositoryStructure();
|
|
3433
|
+
const { upgradeEnvironmentLayout: upgradeEnvironmentLayout2 } = await Promise.resolve().then(() => (init_upgrade(), upgrade_exports));
|
|
3434
|
+
await upgradeEnvironmentLayout2();
|
|
3435
|
+
}
|
|
3323
3436
|
async function runEnvironmentUpdateWorkflows() {
|
|
3324
3437
|
validateRepositoryStructure();
|
|
3325
3438
|
const { updateWorkflowEnvironments: updateWorkflowEnvironments2 } = await Promise.resolve().then(() => (init_update_workflows(), update_workflows_exports));
|
|
@@ -3389,6 +3502,7 @@ Usage: opencrvs environment <subcommand>
|
|
|
3389
3502
|
|
|
3390
3503
|
Subcommands:
|
|
3391
3504
|
init Initialise a new environment
|
|
3505
|
+
upgrade Upgrade existing environment configuration
|
|
3392
3506
|
update-workflows Update workflow environment options
|
|
3393
3507
|
users Manage environment users
|
|
3394
3508
|
swarm-to-k8s Migrate Docker Swarm configuration to Kubernetes
|
|
@@ -3399,6 +3513,8 @@ Subcommands:
|
|
|
3399
3513
|
switch (subcommand) {
|
|
3400
3514
|
case "init":
|
|
3401
3515
|
return runEnvironmentCommand("initialisation", runEnvironmentInit);
|
|
3516
|
+
case "upgrade":
|
|
3517
|
+
return runEnvironmentCommand("environment upgrade", runEnvironmentUpgrade);
|
|
3402
3518
|
case "update-workflows":
|
|
3403
3519
|
return runEnvironmentCommand(
|
|
3404
3520
|
"workflow update",
|
|
@@ -3419,10 +3535,10 @@ Subcommands:
|
|
|
3419
3535
|
async function runEnvironmentCommand(operation, command) {
|
|
3420
3536
|
try {
|
|
3421
3537
|
await command();
|
|
3422
|
-
} catch (
|
|
3538
|
+
} catch (error3) {
|
|
3423
3539
|
console.error(
|
|
3424
3540
|
`Environment ${operation} failed:`,
|
|
3425
|
-
|
|
3541
|
+
error3 instanceof Error ? error3.message : error3
|
|
3426
3542
|
);
|
|
3427
3543
|
process.exit(1);
|
|
3428
3544
|
}
|
|
@@ -3448,8 +3564,8 @@ async function handleUpgrade() {
|
|
|
3448
3564
|
try {
|
|
3449
3565
|
await runUpgrade(dockerSwarm);
|
|
3450
3566
|
console.log("Upgrade completed successfully!");
|
|
3451
|
-
} catch (
|
|
3452
|
-
console.error("Upgrade failed:",
|
|
3567
|
+
} catch (error3) {
|
|
3568
|
+
console.error("Upgrade failed:", error3);
|
|
3453
3569
|
process.exit(1);
|
|
3454
3570
|
}
|
|
3455
3571
|
}
|