@opencrvs/toolkit 2.1.0-rc.193cdd8 → 2.1.0-rc.1bd2a41
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/dist/cli.js +164 -57
- package/dist/commons/api/router.d.ts +3267 -3248
- package/dist/commons/application-config/index.d.ts +6 -6
- package/dist/commons/conditionals/conditionals.d.ts +259 -2102
- package/dist/commons/events/ActionConfig.d.ts +105 -105
- package/dist/commons/events/ActionDocument.d.ts +113 -113
- package/dist/commons/events/ActionType.d.ts +62 -62
- package/dist/commons/events/AdvancedSearchConfig.d.ts +507 -507
- package/dist/commons/events/AuditLog.d.ts +43 -43
- package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
- package/dist/commons/events/Conditional.d.ts +3 -3
- package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
- package/dist/commons/events/Draft.d.ts +37 -37
- package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
- package/dist/commons/events/EventConfig.d.ts +5 -5
- package/dist/commons/events/EventDocument.d.ts +46 -46
- package/dist/commons/events/EventIndex.d.ts +62 -62
- package/dist/commons/events/EventMetadata.d.ts +40 -40
- package/dist/commons/events/FieldConfig.d.ts +336 -336
- package/dist/commons/events/FieldType.d.ts +51 -51
- package/dist/commons/events/FieldTypeMapping.d.ts +100 -100
- package/dist/commons/events/FieldValue.d.ts +12 -12
- package/dist/commons/events/Flag.d.ts +15 -15
- package/dist/commons/events/TemplateConfig.d.ts +1 -1
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
- package/dist/commons/events/WorkqueueConfig.d.ts +826 -826
- package/dist/commons/events/deduplication.d.ts +1 -1
- package/dist/commons/events/event.d.ts +2 -2
- package/dist/commons/events/field.d.ts +78 -895
- package/dist/commons/events/locations.d.ts +96 -6
- package/dist/commons/events/mocks.test.utils.d.ts +18 -4
- package/dist/commons/events/scopes.d.ts +4 -4
- package/dist/commons/events/state/index.d.ts +17 -17
- package/dist/commons/events/state/utils.d.ts +7 -7
- package/dist/commons/events/test.utils.d.ts +40 -40
- package/dist/commons/events/utils.d.ts +114 -114
- package/dist/commons/notification/UserNotifications.d.ts +10 -10
- package/dist/environment/derived-variables.d.ts +119 -119
- package/dist/environment/derived-variables.d.ts.map +1 -1
- 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.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/questions.d.ts +75 -74
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +10 -15
- 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 +4 -3
- package/dist/environment/upgrade.d.ts +2 -0
- package/dist/environment/upgrade.d.ts.map +1 -0
- package/dist/environment/upgrade.js +80 -0
- package/dist/environment/users.js +11 -13
- package/dist/environment/utils.d.ts +1 -1
- package/dist/events/deduplication.d.ts +1 -1
- package/dist/events/index.js +59 -52
- package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
- package/dist/notification/index.js +45 -52
- package/dist/scopes/index.d.ts +146 -146
- package/opencrvs-toolkit-2.1.0-rc.1bd2a41.tgz +0 -0
- package/package.json +3 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.1.0-rc.193cdd8.tgz +0 -0
package/README.md
CHANGED
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",
|
|
@@ -2752,11 +2782,11 @@ __export(update_workflows_exports, {
|
|
|
2752
2782
|
updateWorkflowEnvironments: () => updateWorkflowEnvironments
|
|
2753
2783
|
});
|
|
2754
2784
|
async function extractInfrastructureNames() {
|
|
2755
|
-
const files =
|
|
2756
|
-
const infraEnvironments = files.map((file) => (0,
|
|
2785
|
+
const files = glob2.sync((0, import_path4.join)("environments", "*", INVENTORY_FILE_NAME));
|
|
2786
|
+
const infraEnvironments = files.map((file) => (0, import_path4.basename)((0, import_path4.dirname)(file)));
|
|
2757
2787
|
if (infraEnvironments.length === 0) {
|
|
2758
2788
|
console.log(
|
|
2759
|
-
|
|
2789
|
+
`\u26A0\uFE0F Warning: No environment inventory files found at environments/*/${INVENTORY_FILE_NAME}`
|
|
2760
2790
|
);
|
|
2761
2791
|
return [];
|
|
2762
2792
|
}
|
|
@@ -2766,7 +2796,7 @@ async function extractInfrastructureNames() {
|
|
|
2766
2796
|
async function extractEnvironmentNames() {
|
|
2767
2797
|
const entries = await (0, import_promises.readdir)("environments");
|
|
2768
2798
|
const environments = entries.filter((entry) => {
|
|
2769
|
-
const fullPath = (0,
|
|
2799
|
+
const fullPath = (0, import_path4.join)("environments", entry);
|
|
2770
2800
|
return (0, import_fs3.statSync)(fullPath).isDirectory();
|
|
2771
2801
|
});
|
|
2772
2802
|
if (environments.length === 0) {
|
|
@@ -2803,13 +2833,13 @@ async function updateWorkflows(envList, config) {
|
|
|
2803
2833
|
const updatedContent = updateOptionsInYaml(fileContents, envList);
|
|
2804
2834
|
(0, import_fs3.writeFileSync)(workflowPath, updatedContent, "utf8");
|
|
2805
2835
|
log(` \u2713 Successfully updated ${workflowPath}`);
|
|
2806
|
-
} catch (
|
|
2836
|
+
} catch (error3) {
|
|
2807
2837
|
console.error(
|
|
2808
2838
|
`
|
|
2809
2839
|
\u26A0\uFE0F Error updating ${workflowPath} with environments: [${envList.join(", ")}]`
|
|
2810
2840
|
);
|
|
2811
|
-
console.error(`\u2717 Failed to update ${workflowPath}:`,
|
|
2812
|
-
throw
|
|
2841
|
+
console.error(`\u2717 Failed to update ${workflowPath}:`, error3);
|
|
2842
|
+
throw error3;
|
|
2813
2843
|
}
|
|
2814
2844
|
}
|
|
2815
2845
|
}
|
|
@@ -2850,21 +2880,89 @@ async function updateWorkflowEnvironments() {
|
|
|
2850
2880
|
} else {
|
|
2851
2881
|
log("\u2139\uFE0F No workflows were updated.");
|
|
2852
2882
|
}
|
|
2853
|
-
} catch (
|
|
2854
|
-
console.error("\n\u274C Error updating workflows:",
|
|
2883
|
+
} catch (error3) {
|
|
2884
|
+
console.error("\n\u274C Error updating workflows:", error3);
|
|
2855
2885
|
process.exit(1);
|
|
2856
2886
|
}
|
|
2857
2887
|
}
|
|
2858
|
-
var import_promises, import_fs3,
|
|
2888
|
+
var import_promises, import_fs3, import_path4, glob2, yaml2;
|
|
2859
2889
|
var init_update_workflows = __esm({
|
|
2860
2890
|
"src/environment/update-workflows.ts"() {
|
|
2861
2891
|
"use strict";
|
|
2862
2892
|
import_promises = require("fs/promises");
|
|
2863
2893
|
import_fs3 = require("fs");
|
|
2864
|
-
|
|
2865
|
-
|
|
2894
|
+
import_path4 = require("path");
|
|
2895
|
+
glob2 = __toESM(require("glob"));
|
|
2866
2896
|
yaml2 = __toESM(require("js-yaml"));
|
|
2867
2897
|
init_logger();
|
|
2898
|
+
init_paths();
|
|
2899
|
+
}
|
|
2900
|
+
});
|
|
2901
|
+
|
|
2902
|
+
// src/environment/upgrade.ts
|
|
2903
|
+
var upgrade_exports = {};
|
|
2904
|
+
__export(upgrade_exports, {
|
|
2905
|
+
upgradeEnvironmentLayout: () => upgradeEnvironmentLayout
|
|
2906
|
+
});
|
|
2907
|
+
function moveFileIfDestinationMissing(sourcePath, destinationPath) {
|
|
2908
|
+
if (!(0, import_fs4.existsSync)(sourcePath)) {
|
|
2909
|
+
return false;
|
|
2910
|
+
}
|
|
2911
|
+
if ((0, import_fs4.existsSync)(destinationPath)) {
|
|
2912
|
+
warn(
|
|
2913
|
+
`\u26A0\uFE0F Skipped ${sourcePath}; destination already exists at ${destinationPath}`
|
|
2914
|
+
);
|
|
2915
|
+
return false;
|
|
2916
|
+
}
|
|
2917
|
+
(0, import_fs4.mkdirSync)((0, import_path5.dirname)(destinationPath), { recursive: true });
|
|
2918
|
+
(0, import_fs4.renameSync)(sourcePath, destinationPath);
|
|
2919
|
+
log(` \u2713 Moved ${sourcePath} -> ${destinationPath}`);
|
|
2920
|
+
return true;
|
|
2921
|
+
}
|
|
2922
|
+
function migrateInventoryFiles() {
|
|
2923
|
+
const oldInventoryFiles = findOldInventoryFiles();
|
|
2924
|
+
if (oldInventoryFiles.length === 0) {
|
|
2925
|
+
log(`\u2139\uFE0F No old inventory files found at ${OLD_INVENTORY_DIR}`);
|
|
2926
|
+
return false;
|
|
2927
|
+
}
|
|
2928
|
+
log(import_kleur5.default.bold("\nMigrating Ansible inventory files"));
|
|
2929
|
+
let didMoveInventory = false;
|
|
2930
|
+
for (const oldInventoryFile of oldInventoryFiles) {
|
|
2931
|
+
const environment = getEnvironmentNameFromOldInventoryPath(oldInventoryFile);
|
|
2932
|
+
didMoveInventory = moveFileIfDestinationMissing(
|
|
2933
|
+
oldInventoryFile,
|
|
2934
|
+
getEnvironmentInventoryPath(environment)
|
|
2935
|
+
) || didMoveInventory;
|
|
2936
|
+
}
|
|
2937
|
+
try {
|
|
2938
|
+
if ((0, import_fs4.existsSync)(OLD_INVENTORY_DIR) && (0, import_fs4.readdirSync)(OLD_INVENTORY_DIR).length === 0) {
|
|
2939
|
+
(0, import_fs4.rmdirSync)(OLD_INVENTORY_DIR);
|
|
2940
|
+
log(` \u2713 Removed empty ${OLD_INVENTORY_DIR}`);
|
|
2941
|
+
}
|
|
2942
|
+
} catch {
|
|
2943
|
+
warn(`\u26A0\uFE0F Could not remove ${OLD_INVENTORY_DIR}; please review it manually`);
|
|
2944
|
+
}
|
|
2945
|
+
return didMoveInventory;
|
|
2946
|
+
}
|
|
2947
|
+
async function upgradeEnvironmentLayout() {
|
|
2948
|
+
const didMoveInventory = migrateInventoryFiles();
|
|
2949
|
+
await updateWorkflowEnvironments();
|
|
2950
|
+
if (didMoveInventory) {
|
|
2951
|
+
success("\n\u2705 Environment layout upgrade completed successfully.");
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
success("\n\u2705 Environment layout already uses the current structure.");
|
|
2955
|
+
}
|
|
2956
|
+
var import_fs4, import_path5, import_kleur5;
|
|
2957
|
+
var init_upgrade = __esm({
|
|
2958
|
+
"src/environment/upgrade.ts"() {
|
|
2959
|
+
"use strict";
|
|
2960
|
+
import_fs4 = require("fs");
|
|
2961
|
+
import_path5 = require("path");
|
|
2962
|
+
import_kleur5 = __toESM(require("kleur"));
|
|
2963
|
+
init_logger();
|
|
2964
|
+
init_paths();
|
|
2965
|
+
init_update_workflows();
|
|
2868
2966
|
}
|
|
2869
2967
|
});
|
|
2870
2968
|
|
|
@@ -2877,7 +2975,7 @@ async function select4(options) {
|
|
|
2877
2975
|
const inquirer = await import("@inquirer/prompts");
|
|
2878
2976
|
return inquirer.select(options);
|
|
2879
2977
|
}
|
|
2880
|
-
async function selectInventoryFile(dirPath = "./
|
|
2978
|
+
async function selectInventoryFile(dirPath = "./environments") {
|
|
2881
2979
|
if (!fs4.existsSync(dirPath)) {
|
|
2882
2980
|
warn(`\u26A0\uFE0F No environment configuration directory found at ${dirPath}`);
|
|
2883
2981
|
warn(
|
|
@@ -2885,22 +2983,20 @@ async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inve
|
|
|
2885
2983
|
);
|
|
2886
2984
|
return null;
|
|
2887
2985
|
}
|
|
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");
|
|
2986
|
+
const environments = fs4.readdirSync(dirPath).filter((entry) => {
|
|
2987
|
+
const filePath = path4.join(dirPath, entry);
|
|
2988
|
+
return fs4.statSync(filePath).isDirectory() && fs4.existsSync(getEnvironmentInventoryPath(entry));
|
|
2893
2989
|
}).sort();
|
|
2894
|
-
if (
|
|
2990
|
+
if (environments.length === 0) {
|
|
2895
2991
|
warn(`\u26A0\uFE0F No environment configuration files found at ${dirPath}`);
|
|
2896
2992
|
warn(
|
|
2897
2993
|
"Hint: If this is a new infrastructure repository, run `opencrvs environment init` first."
|
|
2898
2994
|
);
|
|
2899
2995
|
return null;
|
|
2900
2996
|
}
|
|
2901
|
-
const choices =
|
|
2902
|
-
name:
|
|
2903
|
-
value:
|
|
2997
|
+
const choices = environments.map((environment) => ({
|
|
2998
|
+
name: environment,
|
|
2999
|
+
value: getEnvironmentInventoryPath(environment)
|
|
2904
3000
|
}));
|
|
2905
3001
|
const selectedFile = await select4({
|
|
2906
3002
|
message: "Select environment (inventory file) to load users:",
|
|
@@ -2909,33 +3005,34 @@ async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inve
|
|
|
2909
3005
|
return selectedFile;
|
|
2910
3006
|
}
|
|
2911
3007
|
async function manageEnvironmentUsers() {
|
|
2912
|
-
console.log("\n",
|
|
3008
|
+
console.log("\n", import_kleur6.default.bold().underline("Manage users"), "\n");
|
|
2913
3009
|
const inventory_file = await selectInventoryFile();
|
|
2914
3010
|
if (!inventory_file) {
|
|
2915
3011
|
return;
|
|
2916
3012
|
}
|
|
2917
3013
|
await manageUsers(inventory_file);
|
|
2918
3014
|
}
|
|
2919
|
-
var fs4, path4,
|
|
3015
|
+
var fs4, path4, import_kleur6;
|
|
2920
3016
|
var init_users = __esm({
|
|
2921
3017
|
"src/environment/users.ts"() {
|
|
2922
3018
|
"use strict";
|
|
2923
3019
|
fs4 = __toESM(require("fs"));
|
|
2924
3020
|
path4 = __toESM(require("path"));
|
|
2925
|
-
|
|
3021
|
+
import_kleur6 = __toESM(require("kleur"));
|
|
2926
3022
|
init_manage_users();
|
|
2927
3023
|
init_logger();
|
|
3024
|
+
init_paths();
|
|
2928
3025
|
}
|
|
2929
3026
|
});
|
|
2930
3027
|
|
|
2931
3028
|
// src/environment/swarm-to-k8s.ts
|
|
2932
3029
|
var swarm_to_k8s_exports = {};
|
|
2933
|
-
var path5,
|
|
3030
|
+
var path5, import_kleur7, import_core2;
|
|
2934
3031
|
var init_swarm_to_k8s = __esm({
|
|
2935
3032
|
"src/environment/swarm-to-k8s.ts"() {
|
|
2936
3033
|
"use strict";
|
|
2937
3034
|
path5 = __toESM(require("path"));
|
|
2938
|
-
|
|
3035
|
+
import_kleur7 = __toESM(require("kleur"));
|
|
2939
3036
|
init_logger();
|
|
2940
3037
|
init_utils();
|
|
2941
3038
|
init_templates();
|
|
@@ -2944,7 +3041,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
2944
3041
|
init_github();
|
|
2945
3042
|
(async () => {
|
|
2946
3043
|
log(
|
|
2947
|
-
|
|
3044
|
+
import_kleur7.default.bold(
|
|
2948
3045
|
"------------------------------------------------\nOpenCRVS Infrastructure migration script: \nMigrating Swarm configurations to Kubernetes\n------------------------------------------------\n"
|
|
2949
3046
|
)
|
|
2950
3047
|
);
|
|
@@ -2975,7 +3072,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
2975
3072
|
);
|
|
2976
3073
|
process.exit(0);
|
|
2977
3074
|
}
|
|
2978
|
-
log(
|
|
3075
|
+
log(import_kleur7.default.bold().underline("Migration properties:"));
|
|
2979
3076
|
log(` \u2713 Environment: ${environment}`);
|
|
2980
3077
|
const old_inventory_path = process.env.OLD_INVENTORY_PATH || "";
|
|
2981
3078
|
if (!old_inventory_path) {
|
|
@@ -3293,8 +3390,9 @@ async function runUpgrade(dockerSwarm) {
|
|
|
3293
3390
|
}
|
|
3294
3391
|
|
|
3295
3392
|
// src/environment/index.ts
|
|
3296
|
-
var
|
|
3297
|
-
var
|
|
3393
|
+
var import_fs5 = require("fs");
|
|
3394
|
+
var import_path6 = require("path");
|
|
3395
|
+
init_paths();
|
|
3298
3396
|
var REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
3299
3397
|
".github/workflows",
|
|
3300
3398
|
"environments",
|
|
@@ -3304,7 +3402,7 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3304
3402
|
const missingDirectories = REQUIRED_REPOSITORY_DIRECTORIES.filter(
|
|
3305
3403
|
(directory) => {
|
|
3306
3404
|
try {
|
|
3307
|
-
return !(0,
|
|
3405
|
+
return !(0, import_fs5.statSync)((0, import_path6.resolve)(repositoryRoot, directory)).isDirectory();
|
|
3308
3406
|
} catch {
|
|
3309
3407
|
return true;
|
|
3310
3408
|
}
|
|
@@ -3318,8 +3416,14 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3318
3416
|
}
|
|
3319
3417
|
async function runEnvironmentInit() {
|
|
3320
3418
|
validateRepositoryStructure();
|
|
3419
|
+
assertNoOldInventoryLayout();
|
|
3321
3420
|
await Promise.resolve().then(() => (init_setup_environment(), setup_environment_exports));
|
|
3322
3421
|
}
|
|
3422
|
+
async function runEnvironmentUpgrade() {
|
|
3423
|
+
validateRepositoryStructure();
|
|
3424
|
+
const { upgradeEnvironmentLayout: upgradeEnvironmentLayout2 } = await Promise.resolve().then(() => (init_upgrade(), upgrade_exports));
|
|
3425
|
+
await upgradeEnvironmentLayout2();
|
|
3426
|
+
}
|
|
3323
3427
|
async function runEnvironmentUpdateWorkflows() {
|
|
3324
3428
|
validateRepositoryStructure();
|
|
3325
3429
|
const { updateWorkflowEnvironments: updateWorkflowEnvironments2 } = await Promise.resolve().then(() => (init_update_workflows(), update_workflows_exports));
|
|
@@ -3389,6 +3493,7 @@ Usage: opencrvs environment <subcommand>
|
|
|
3389
3493
|
|
|
3390
3494
|
Subcommands:
|
|
3391
3495
|
init Initialise a new environment
|
|
3496
|
+
upgrade Upgrade existing environment configuration
|
|
3392
3497
|
update-workflows Update workflow environment options
|
|
3393
3498
|
users Manage environment users
|
|
3394
3499
|
swarm-to-k8s Migrate Docker Swarm configuration to Kubernetes
|
|
@@ -3399,6 +3504,8 @@ Subcommands:
|
|
|
3399
3504
|
switch (subcommand) {
|
|
3400
3505
|
case "init":
|
|
3401
3506
|
return runEnvironmentCommand("initialisation", runEnvironmentInit);
|
|
3507
|
+
case "upgrade":
|
|
3508
|
+
return runEnvironmentCommand("environment upgrade", runEnvironmentUpgrade);
|
|
3402
3509
|
case "update-workflows":
|
|
3403
3510
|
return runEnvironmentCommand(
|
|
3404
3511
|
"workflow update",
|
|
@@ -3419,10 +3526,10 @@ Subcommands:
|
|
|
3419
3526
|
async function runEnvironmentCommand(operation, command) {
|
|
3420
3527
|
try {
|
|
3421
3528
|
await command();
|
|
3422
|
-
} catch (
|
|
3529
|
+
} catch (error3) {
|
|
3423
3530
|
console.error(
|
|
3424
3531
|
`Environment ${operation} failed:`,
|
|
3425
|
-
|
|
3532
|
+
error3 instanceof Error ? error3.message : error3
|
|
3426
3533
|
);
|
|
3427
3534
|
process.exit(1);
|
|
3428
3535
|
}
|
|
@@ -3448,8 +3555,8 @@ async function handleUpgrade() {
|
|
|
3448
3555
|
try {
|
|
3449
3556
|
await runUpgrade(dockerSwarm);
|
|
3450
3557
|
console.log("Upgrade completed successfully!");
|
|
3451
|
-
} catch (
|
|
3452
|
-
console.error("Upgrade failed:",
|
|
3558
|
+
} catch (error3) {
|
|
3559
|
+
console.error("Upgrade failed:", error3);
|
|
3453
3560
|
process.exit(1);
|
|
3454
3561
|
}
|
|
3455
3562
|
}
|