@opencrvs/toolkit 2.1.0-rc.99061f0 → 2.1.0-rc.9c04c04
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 -2
- package/dist/cli.js +58 -174
- package/dist/commons/api/router.d.ts +1591 -1574
- package/dist/commons/application-config/index.d.ts +6 -6
- package/dist/commons/conditionals/conditionals.d.ts +2102 -259
- package/dist/commons/events/ActionConfig.d.ts +105 -105
- package/dist/commons/events/ActionDocument.d.ts +119 -119
- package/dist/commons/events/ActionInput.d.ts +6 -0
- 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 +48 -48
- 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 +337 -337
- 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 +820 -820
- 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 +895 -78
- package/dist/commons/events/locations.d.ts +6 -96
- package/dist/commons/events/mocks.test.utils.d.ts +4 -18
- 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 +43 -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 +0 -1
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +0 -10
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/questions.d.ts +74 -75
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +15 -10
- 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 +5 -17
- package/dist/environment/users.js +13 -11
- package/dist/environment/utils.d.ts +1 -1
- package/dist/events/deduplication.d.ts +1 -1
- package/dist/events/index.js +58 -62
- package/dist/migrations/v2.0/migrate-application-config-url.js +3 -4
- package/dist/notification/index.js +57 -48
- package/dist/scopes/index.d.ts +146 -146
- package/opencrvs-toolkit-2.1.0-rc.9c04c04.tgz +0 -0
- package/package.json +4 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/environment/paths.d.ts +0 -7
- package/dist/environment/paths.d.ts.map +0 -1
- package/dist/environment/paths.js +0 -72
- package/dist/environment/upgrade.d.ts +0 -2
- package/dist/environment/upgrade.d.ts.map +0 -1
- package/dist/environment/upgrade.js +0 -82
- package/opencrvs-toolkit-2.1.0-rc.99061f0.tgz +0 -0
package/README.md
CHANGED
|
@@ -989,10 +989,9 @@ var NotifiedAction = ActionBase.extend(
|
|
|
989
989
|
var EditAction = ActionBase.extend(
|
|
990
990
|
z13.object({
|
|
991
991
|
type: z13.literal(ActionType.EDIT),
|
|
992
|
-
/** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
|
|
993
992
|
content: z13.object({
|
|
994
993
|
comment: z13.string().describe("Comment for the edit action.").optional()
|
|
995
|
-
})
|
|
994
|
+
})
|
|
996
995
|
}).shape
|
|
997
996
|
);
|
|
998
997
|
var PrintContent = z13.object({
|
package/dist/cli.js
CHANGED
|
@@ -30,42 +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 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
|
-
|
|
69
33
|
// src/environment/logger.ts
|
|
70
34
|
var import_kleur, log, warn, success, info, error;
|
|
71
35
|
var init_logger = __esm({
|
|
@@ -509,7 +473,7 @@ function storeSecrets(environment, answers) {
|
|
|
509
473
|
envConfig = import_dotenv.default.parse(
|
|
510
474
|
(0, import_fs.readFileSync)(`${process.cwd()}/.env.${environment}`)
|
|
511
475
|
);
|
|
512
|
-
} catch (
|
|
476
|
+
} catch (error4) {
|
|
513
477
|
envConfig = {};
|
|
514
478
|
}
|
|
515
479
|
const linesFromAnswers = answers.map(
|
|
@@ -534,8 +498,8 @@ function writeYamlFile(filePath, data) {
|
|
|
534
498
|
sortKeys: false
|
|
535
499
|
});
|
|
536
500
|
import_fs.default.writeFileSync(filePath, yamlContent, "utf8");
|
|
537
|
-
} catch (
|
|
538
|
-
throw new Error(`Failed to write inventory file: ${
|
|
501
|
+
} catch (error4) {
|
|
502
|
+
throw new Error(`Failed to write inventory file: ${error4}`);
|
|
539
503
|
}
|
|
540
504
|
}
|
|
541
505
|
var import_fs, yaml, import_dotenv;
|
|
@@ -595,8 +559,8 @@ function extractWorkerNodes(data) {
|
|
|
595
559
|
return worker_hosts;
|
|
596
560
|
}
|
|
597
561
|
function copyChartsValues(env, values) {
|
|
598
|
-
const srcDir =
|
|
599
|
-
const destDir =
|
|
562
|
+
const srcDir = import_path2.default.resolve(__dirname, "templates", "charts-values");
|
|
563
|
+
const destDir = import_path2.default.resolve(process.cwd(), "environments", env);
|
|
600
564
|
import_fs2.default.mkdirSync(destDir, { recursive: true });
|
|
601
565
|
values["lets_encrypt"] = values["traefik_mode"] === "lets_encrypt";
|
|
602
566
|
values["static_ssl"] = values["traefik_mode"] === "static_ssl";
|
|
@@ -606,7 +570,7 @@ function copyChartsValues(env, values) {
|
|
|
606
570
|
if (stat.isDirectory()) {
|
|
607
571
|
import_fs2.default.mkdirSync(dest, { recursive: true });
|
|
608
572
|
for (const item of import_fs2.default.readdirSync(src)) {
|
|
609
|
-
copyRecursive(
|
|
573
|
+
copyRecursive(import_path2.default.join(src, item), import_path2.default.join(dest, item));
|
|
610
574
|
}
|
|
611
575
|
} else {
|
|
612
576
|
const content = import_fs2.default.readFileSync(src, "utf8");
|
|
@@ -628,31 +592,36 @@ function copyChartsValues(env, values) {
|
|
|
628
592
|
`);
|
|
629
593
|
}
|
|
630
594
|
function generateInventory(env, values) {
|
|
631
|
-
const templatePath =
|
|
595
|
+
const templatePath = import_path2.default.join(
|
|
632
596
|
__dirname,
|
|
633
597
|
"templates",
|
|
634
598
|
"inventory",
|
|
635
599
|
"inventory.template.yml"
|
|
636
600
|
);
|
|
637
|
-
const outputPath =
|
|
601
|
+
const outputPath = import_path2.default.join(
|
|
602
|
+
process.cwd(),
|
|
603
|
+
"infrastructure",
|
|
604
|
+
"server-setup",
|
|
605
|
+
"inventory",
|
|
606
|
+
`${env}.yml`
|
|
607
|
+
);
|
|
638
608
|
const templateFile = import_fs2.default.readFileSync(templatePath, "utf-8");
|
|
639
609
|
const template = import_handlebars.default.compile(templateFile);
|
|
640
610
|
values["single_node"] = values["kube_worker_nodes"].length > 0 || values["backup_host"] ? "false" : "true";
|
|
641
611
|
const updated = template(values);
|
|
642
|
-
import_fs2.default.mkdirSync(
|
|
612
|
+
import_fs2.default.mkdirSync(import_path2.default.dirname(outputPath), { recursive: true });
|
|
643
613
|
import_fs2.default.writeFileSync(outputPath, updated);
|
|
644
614
|
log(`
|
|
645
615
|
\u2705 Generated inventory file at ${outputPath}
|
|
646
616
|
`);
|
|
647
617
|
}
|
|
648
|
-
var import_fs2,
|
|
618
|
+
var import_fs2, import_path2, import_handlebars;
|
|
649
619
|
var init_templates = __esm({
|
|
650
620
|
"src/environment/templates.ts"() {
|
|
651
621
|
"use strict";
|
|
652
622
|
import_fs2 = __toESM(require("fs"));
|
|
653
|
-
|
|
623
|
+
import_path2 = __toESM(require("path"));
|
|
654
624
|
init_logger();
|
|
655
|
-
init_paths();
|
|
656
625
|
import_handlebars = __toESM(require("handlebars"));
|
|
657
626
|
import_handlebars.default.registerHelper("data_label_idx", function(value) {
|
|
658
627
|
return parseInt(value) + 2;
|
|
@@ -1268,7 +1237,7 @@ function getCurrentUserSSHKeys() {
|
|
|
1268
1237
|
keys.push(keyContent);
|
|
1269
1238
|
}
|
|
1270
1239
|
}
|
|
1271
|
-
} catch (
|
|
1240
|
+
} catch (error4) {
|
|
1272
1241
|
continue;
|
|
1273
1242
|
}
|
|
1274
1243
|
}
|
|
@@ -1804,7 +1773,6 @@ var init_setup_environment = __esm({
|
|
|
1804
1773
|
init_editor_questions();
|
|
1805
1774
|
init_questions_helper();
|
|
1806
1775
|
init_manage_users();
|
|
1807
|
-
init_paths();
|
|
1808
1776
|
ALL_QUESTIONS = [];
|
|
1809
1777
|
ALL_ANSWERS = [];
|
|
1810
1778
|
ALL_QUESTIONS.push(
|
|
@@ -1968,7 +1936,9 @@ var init_setup_environment = __esm({
|
|
|
1968
1936
|
);
|
|
1969
1937
|
const kubeWorkerNodes = infrastructure.kubeWorkerNodes ? infrastructure.kubeWorkerNodes.split(",").map((ip) => ip.trim()) : [];
|
|
1970
1938
|
log("\n", import_kleur4.default.bold().underline("SSH Users"), "\n");
|
|
1971
|
-
const users = await manageUsers(
|
|
1939
|
+
const users = await manageUsers(
|
|
1940
|
+
`infrastructure/server-setup/inventory/${environment}.yml`
|
|
1941
|
+
);
|
|
1972
1942
|
log("\n", import_kleur4.default.bold().underline("Traefik SSL Certificate"), "\n");
|
|
1973
1943
|
const sslCertExists = findExistingValue(
|
|
1974
1944
|
"SSL_CRT",
|
|
@@ -2781,19 +2751,12 @@ var update_workflows_exports = {};
|
|
|
2781
2751
|
__export(update_workflows_exports, {
|
|
2782
2752
|
updateWorkflowEnvironments: () => updateWorkflowEnvironments
|
|
2783
2753
|
});
|
|
2784
|
-
function isDirectory(path6) {
|
|
2785
|
-
try {
|
|
2786
|
-
return (0, import_fs3.statSync)(path6).isDirectory();
|
|
2787
|
-
} catch {
|
|
2788
|
-
return false;
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
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,9 +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
|
|
2807
|
-
|
|
2808
|
-
return isDirectory(environmentPath) && (0, import_fs3.existsSync)(opencrvsServicesPath) && isDirectory(opencrvsServicesPath);
|
|
2769
|
+
const fullPath = (0, import_path3.join)("environments", entry);
|
|
2770
|
+
return (0, import_fs3.statSync)(fullPath).isDirectory();
|
|
2809
2771
|
});
|
|
2810
2772
|
if (environments.length === 0) {
|
|
2811
2773
|
console.log(
|
|
@@ -2841,13 +2803,13 @@ async function updateWorkflows(envList, config) {
|
|
|
2841
2803
|
const updatedContent = updateOptionsInYaml(fileContents, envList);
|
|
2842
2804
|
(0, import_fs3.writeFileSync)(workflowPath, updatedContent, "utf8");
|
|
2843
2805
|
log(` \u2713 Successfully updated ${workflowPath}`);
|
|
2844
|
-
} catch (
|
|
2806
|
+
} catch (error4) {
|
|
2845
2807
|
console.error(
|
|
2846
2808
|
`
|
|
2847
2809
|
\u26A0\uFE0F Error updating ${workflowPath} with environments: [${envList.join(", ")}]`
|
|
2848
2810
|
);
|
|
2849
|
-
console.error(`\u2717 Failed to update ${workflowPath}:`,
|
|
2850
|
-
throw
|
|
2811
|
+
console.error(`\u2717 Failed to update ${workflowPath}:`, error4);
|
|
2812
|
+
throw error4;
|
|
2851
2813
|
}
|
|
2852
2814
|
}
|
|
2853
2815
|
}
|
|
@@ -2888,90 +2850,21 @@ async function updateWorkflowEnvironments() {
|
|
|
2888
2850
|
} else {
|
|
2889
2851
|
log("\u2139\uFE0F No workflows were updated.");
|
|
2890
2852
|
}
|
|
2891
|
-
} catch (
|
|
2892
|
-
console.error("\n\u274C Error updating workflows:",
|
|
2853
|
+
} catch (error4) {
|
|
2854
|
+
console.error("\n\u274C Error updating workflows:", error4);
|
|
2893
2855
|
process.exit(1);
|
|
2894
2856
|
}
|
|
2895
2857
|
}
|
|
2896
|
-
var import_promises, import_fs3,
|
|
2858
|
+
var import_promises, import_fs3, import_path3, glob, yaml2;
|
|
2897
2859
|
var init_update_workflows = __esm({
|
|
2898
2860
|
"src/environment/update-workflows.ts"() {
|
|
2899
2861
|
"use strict";
|
|
2900
2862
|
import_promises = require("fs/promises");
|
|
2901
2863
|
import_fs3 = require("fs");
|
|
2902
|
-
|
|
2903
|
-
|
|
2864
|
+
import_path3 = require("path");
|
|
2865
|
+
glob = __toESM(require("glob"));
|
|
2904
2866
|
yaml2 = __toESM(require("js-yaml"));
|
|
2905
2867
|
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();
|
|
2975
2868
|
}
|
|
2976
2869
|
});
|
|
2977
2870
|
|
|
@@ -2984,7 +2877,7 @@ async function select4(options) {
|
|
|
2984
2877
|
const inquirer = await import("@inquirer/prompts");
|
|
2985
2878
|
return inquirer.select(options);
|
|
2986
2879
|
}
|
|
2987
|
-
async function selectInventoryFile(dirPath = "./
|
|
2880
|
+
async function selectInventoryFile(dirPath = "./infrastructure/server-setup/inventory/") {
|
|
2988
2881
|
if (!fs4.existsSync(dirPath)) {
|
|
2989
2882
|
warn(`\u26A0\uFE0F No environment configuration directory found at ${dirPath}`);
|
|
2990
2883
|
warn(
|
|
@@ -2992,20 +2885,22 @@ async function selectInventoryFile(dirPath = "./environments") {
|
|
|
2992
2885
|
);
|
|
2993
2886
|
return null;
|
|
2994
2887
|
}
|
|
2995
|
-
const
|
|
2996
|
-
const filePath = path4.join(dirPath,
|
|
2997
|
-
|
|
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");
|
|
2998
2893
|
}).sort();
|
|
2999
|
-
if (
|
|
2894
|
+
if (files.length === 0) {
|
|
3000
2895
|
warn(`\u26A0\uFE0F No environment configuration files found at ${dirPath}`);
|
|
3001
2896
|
warn(
|
|
3002
2897
|
"Hint: If this is a new infrastructure repository, run `opencrvs environment init` first."
|
|
3003
2898
|
);
|
|
3004
2899
|
return null;
|
|
3005
2900
|
}
|
|
3006
|
-
const choices =
|
|
3007
|
-
name:
|
|
3008
|
-
value:
|
|
2901
|
+
const choices = files.map((file) => ({
|
|
2902
|
+
name: path4.basename(file, path4.extname(file)),
|
|
2903
|
+
value: path4.join(dirPath, file)
|
|
3009
2904
|
}));
|
|
3010
2905
|
const selectedFile = await select4({
|
|
3011
2906
|
message: "Select environment (inventory file) to load users:",
|
|
@@ -3014,34 +2909,33 @@ async function selectInventoryFile(dirPath = "./environments") {
|
|
|
3014
2909
|
return selectedFile;
|
|
3015
2910
|
}
|
|
3016
2911
|
async function manageEnvironmentUsers() {
|
|
3017
|
-
console.log("\n",
|
|
2912
|
+
console.log("\n", import_kleur5.default.bold().underline("Manage users"), "\n");
|
|
3018
2913
|
const inventory_file = await selectInventoryFile();
|
|
3019
2914
|
if (!inventory_file) {
|
|
3020
2915
|
return;
|
|
3021
2916
|
}
|
|
3022
2917
|
await manageUsers(inventory_file);
|
|
3023
2918
|
}
|
|
3024
|
-
var fs4, path4,
|
|
2919
|
+
var fs4, path4, import_kleur5;
|
|
3025
2920
|
var init_users = __esm({
|
|
3026
2921
|
"src/environment/users.ts"() {
|
|
3027
2922
|
"use strict";
|
|
3028
2923
|
fs4 = __toESM(require("fs"));
|
|
3029
2924
|
path4 = __toESM(require("path"));
|
|
3030
|
-
|
|
2925
|
+
import_kleur5 = __toESM(require("kleur"));
|
|
3031
2926
|
init_manage_users();
|
|
3032
2927
|
init_logger();
|
|
3033
|
-
init_paths();
|
|
3034
2928
|
}
|
|
3035
2929
|
});
|
|
3036
2930
|
|
|
3037
2931
|
// src/environment/swarm-to-k8s.ts
|
|
3038
2932
|
var swarm_to_k8s_exports = {};
|
|
3039
|
-
var path5,
|
|
2933
|
+
var path5, import_kleur6, import_core2;
|
|
3040
2934
|
var init_swarm_to_k8s = __esm({
|
|
3041
2935
|
"src/environment/swarm-to-k8s.ts"() {
|
|
3042
2936
|
"use strict";
|
|
3043
2937
|
path5 = __toESM(require("path"));
|
|
3044
|
-
|
|
2938
|
+
import_kleur6 = __toESM(require("kleur"));
|
|
3045
2939
|
init_logger();
|
|
3046
2940
|
init_utils();
|
|
3047
2941
|
init_templates();
|
|
@@ -3050,7 +2944,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
3050
2944
|
init_github();
|
|
3051
2945
|
(async () => {
|
|
3052
2946
|
log(
|
|
3053
|
-
|
|
2947
|
+
import_kleur6.default.bold(
|
|
3054
2948
|
"------------------------------------------------\nOpenCRVS Infrastructure migration script: \nMigrating Swarm configurations to Kubernetes\n------------------------------------------------\n"
|
|
3055
2949
|
)
|
|
3056
2950
|
);
|
|
@@ -3081,7 +2975,7 @@ var init_swarm_to_k8s = __esm({
|
|
|
3081
2975
|
);
|
|
3082
2976
|
process.exit(0);
|
|
3083
2977
|
}
|
|
3084
|
-
log(
|
|
2978
|
+
log(import_kleur6.default.bold().underline("Migration properties:"));
|
|
3085
2979
|
log(` \u2713 Environment: ${environment}`);
|
|
3086
2980
|
const old_inventory_path = process.env.OLD_INVENTORY_PATH || "";
|
|
3087
2981
|
if (!old_inventory_path) {
|
|
@@ -3399,9 +3293,8 @@ async function runUpgrade(dockerSwarm) {
|
|
|
3399
3293
|
}
|
|
3400
3294
|
|
|
3401
3295
|
// src/environment/index.ts
|
|
3402
|
-
var
|
|
3403
|
-
var
|
|
3404
|
-
init_paths();
|
|
3296
|
+
var import_fs4 = require("fs");
|
|
3297
|
+
var import_path4 = require("path");
|
|
3405
3298
|
var REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
3406
3299
|
".github/workflows",
|
|
3407
3300
|
"environments",
|
|
@@ -3411,7 +3304,7 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3411
3304
|
const missingDirectories = REQUIRED_REPOSITORY_DIRECTORIES.filter(
|
|
3412
3305
|
(directory) => {
|
|
3413
3306
|
try {
|
|
3414
|
-
return !(0,
|
|
3307
|
+
return !(0, import_fs4.statSync)((0, import_path4.resolve)(repositoryRoot, directory)).isDirectory();
|
|
3415
3308
|
} catch {
|
|
3416
3309
|
return true;
|
|
3417
3310
|
}
|
|
@@ -3425,14 +3318,8 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
3425
3318
|
}
|
|
3426
3319
|
async function runEnvironmentInit() {
|
|
3427
3320
|
validateRepositoryStructure();
|
|
3428
|
-
assertNoOldInventoryLayout();
|
|
3429
3321
|
await Promise.resolve().then(() => (init_setup_environment(), setup_environment_exports));
|
|
3430
3322
|
}
|
|
3431
|
-
async function runEnvironmentUpgrade() {
|
|
3432
|
-
validateRepositoryStructure();
|
|
3433
|
-
const { upgradeEnvironmentLayout: upgradeEnvironmentLayout2 } = await Promise.resolve().then(() => (init_upgrade(), upgrade_exports));
|
|
3434
|
-
await upgradeEnvironmentLayout2();
|
|
3435
|
-
}
|
|
3436
3323
|
async function runEnvironmentUpdateWorkflows() {
|
|
3437
3324
|
validateRepositoryStructure();
|
|
3438
3325
|
const { updateWorkflowEnvironments: updateWorkflowEnvironments2 } = await Promise.resolve().then(() => (init_update_workflows(), update_workflows_exports));
|
|
@@ -3502,7 +3389,6 @@ Usage: opencrvs environment <subcommand>
|
|
|
3502
3389
|
|
|
3503
3390
|
Subcommands:
|
|
3504
3391
|
init Initialise a new environment
|
|
3505
|
-
upgrade Upgrade existing environment configuration
|
|
3506
3392
|
update-workflows Update workflow environment options
|
|
3507
3393
|
users Manage environment users
|
|
3508
3394
|
swarm-to-k8s Migrate Docker Swarm configuration to Kubernetes
|
|
@@ -3513,8 +3399,6 @@ Subcommands:
|
|
|
3513
3399
|
switch (subcommand) {
|
|
3514
3400
|
case "init":
|
|
3515
3401
|
return runEnvironmentCommand("initialisation", runEnvironmentInit);
|
|
3516
|
-
case "upgrade":
|
|
3517
|
-
return runEnvironmentCommand("environment upgrade", runEnvironmentUpgrade);
|
|
3518
3402
|
case "update-workflows":
|
|
3519
3403
|
return runEnvironmentCommand(
|
|
3520
3404
|
"workflow update",
|
|
@@ -3535,10 +3419,10 @@ Subcommands:
|
|
|
3535
3419
|
async function runEnvironmentCommand(operation, command) {
|
|
3536
3420
|
try {
|
|
3537
3421
|
await command();
|
|
3538
|
-
} catch (
|
|
3422
|
+
} catch (error4) {
|
|
3539
3423
|
console.error(
|
|
3540
3424
|
`Environment ${operation} failed:`,
|
|
3541
|
-
|
|
3425
|
+
error4 instanceof Error ? error4.message : error4
|
|
3542
3426
|
);
|
|
3543
3427
|
process.exit(1);
|
|
3544
3428
|
}
|
|
@@ -3564,8 +3448,8 @@ async function handleUpgrade() {
|
|
|
3564
3448
|
try {
|
|
3565
3449
|
await runUpgrade(dockerSwarm);
|
|
3566
3450
|
console.log("Upgrade completed successfully!");
|
|
3567
|
-
} catch (
|
|
3568
|
-
console.error("Upgrade failed:",
|
|
3451
|
+
} catch (error4) {
|
|
3452
|
+
console.error("Upgrade failed:", error4);
|
|
3569
3453
|
process.exit(1);
|
|
3570
3454
|
}
|
|
3571
3455
|
}
|