@opencrvs/toolkit 2.0.0-rc.c661677 → 2.0.0-rc.c7f111d
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/dist/application-config/index.js +15 -20
- package/dist/cli.js +187 -93
- package/dist/commons/api/router.d.ts +15 -27
- package/dist/commons/events/ActionInput.d.ts +36 -0
- package/dist/commons/events/Draft.d.ts +1 -0
- package/dist/commons/events/EventIndex.d.ts +1 -0
- package/dist/commons/events/EventMetadata.d.ts +1 -0
- package/dist/commons/events/state/index.d.ts +2 -1
- package/dist/events/index.js +16 -20
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +1 -2
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +9 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +66 -20
- package/dist/migrations/v2.0/index.d.ts +5 -3
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +187 -93
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +11 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +17 -16
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +140 -59
- package/dist/notification/index.js +16 -20
- package/opencrvs-toolkit-2.0.0-rc.c7f111d.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.0.0-rc.c661677.tgz +0 -0
|
@@ -3686,6 +3686,10 @@ var ACTION_PROPERTY_NAME2 = "action";
|
|
|
3686
3686
|
var CONDITIONALS_PROPERTY_NAME = "conditionals";
|
|
3687
3687
|
var TYPE_PROPERTY_NAME7 = "type";
|
|
3688
3688
|
var SLUG_PROPERTY_NAME = "slug";
|
|
3689
|
+
var READ_ACTION_TYPE = "READ";
|
|
3690
|
+
var ACTION_TYPE_IMPORT_NAME = "ActionType";
|
|
3691
|
+
var TOOLKIT_EVENTS_MODULE2 = "@opencrvs/toolkit/events";
|
|
3692
|
+
var READ_ACTION_FALLBACK_INITIALIZER = `{ type: ${ACTION_TYPE_IMPORT_NAME}.${READ_ACTION_TYPE} }`;
|
|
3689
3693
|
var SUPPORTED_WORKQUEUE_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
3690
3694
|
"READ",
|
|
3691
3695
|
"DELETE",
|
|
@@ -3733,91 +3737,137 @@ function isUnsupportedActionType(action) {
|
|
|
3733
3737
|
}
|
|
3734
3738
|
return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
|
|
3735
3739
|
}
|
|
3736
|
-
function
|
|
3737
|
-
const
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3740
|
+
function ensureValidAction(workqueue, relPath) {
|
|
3741
|
+
const workqueueLabel = getWorkqueueLabel(workqueue);
|
|
3742
|
+
const actionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
|
|
3743
|
+
if (actionProperty && import_ts_morph17.Node.isPropertyAssignment(actionProperty)) {
|
|
3744
|
+
const initializer = actionProperty.getInitializer();
|
|
3745
|
+
if (initializer && import_ts_morph17.Node.isObjectLiteralExpression(initializer)) {
|
|
3746
|
+
if (!isUnsupportedActionType(initializer)) {
|
|
3747
|
+
return { changed: false, usedReadFallback: false };
|
|
3748
|
+
}
|
|
3749
|
+
actionProperty.set({
|
|
3750
|
+
name: ACTION_PROPERTY_NAME2,
|
|
3751
|
+
initializer: READ_ACTION_FALLBACK_INITIALIZER
|
|
3752
|
+
});
|
|
3753
|
+
console.log(
|
|
3754
|
+
` [${relPath}] Replaced unsupported 'action' type with '${ACTION_TYPE_IMPORT_NAME}.${READ_ACTION_TYPE}' on workqueue '${workqueueLabel}'`
|
|
3755
|
+
);
|
|
3756
|
+
return { changed: true, usedReadFallback: true };
|
|
3757
|
+
}
|
|
3744
3758
|
}
|
|
3759
|
+
workqueue.addPropertyAssignment({
|
|
3760
|
+
name: ACTION_PROPERTY_NAME2,
|
|
3761
|
+
initializer: READ_ACTION_FALLBACK_INITIALIZER
|
|
3762
|
+
});
|
|
3763
|
+
console.log(
|
|
3764
|
+
` [${relPath}] Added default 'action: ${READ_ACTION_FALLBACK_INITIALIZER}' to workqueue '${workqueueLabel}'`
|
|
3765
|
+
);
|
|
3766
|
+
return { changed: true, usedReadFallback: true };
|
|
3767
|
+
}
|
|
3768
|
+
function migrateWorkqueueActions(workqueue, relPath) {
|
|
3745
3769
|
const workqueueLabel = getWorkqueueLabel(workqueue);
|
|
3746
|
-
const
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3770
|
+
const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
|
|
3771
|
+
let actionsArrayMigrated = false;
|
|
3772
|
+
if (actionsProperty && import_ts_morph17.Node.isPropertyAssignment(actionsProperty)) {
|
|
3773
|
+
const actionsInitializer = actionsProperty.getInitializer();
|
|
3774
|
+
if (actionsInitializer && import_ts_morph17.Node.isArrayLiteralExpression(actionsInitializer)) {
|
|
3775
|
+
const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
|
|
3776
|
+
if (existingActionProperty) {
|
|
3777
|
+
if (import_ts_morph17.Node.isPropertyAssignment(existingActionProperty)) {
|
|
3778
|
+
const existingActionInitializer = existingActionProperty.getInitializer();
|
|
3779
|
+
if (existingActionInitializer && import_ts_morph17.Node.isObjectLiteralExpression(existingActionInitializer)) {
|
|
3780
|
+
const conditionalsProperty = existingActionInitializer.getProperty(
|
|
3781
|
+
CONDITIONALS_PROPERTY_NAME
|
|
3782
|
+
);
|
|
3783
|
+
if (conditionalsProperty) {
|
|
3784
|
+
conditionalsProperty.remove();
|
|
3785
|
+
console.log(
|
|
3786
|
+
` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`
|
|
3787
|
+
);
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
actionsProperty.remove();
|
|
3792
|
+
console.log(
|
|
3793
|
+
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
|
|
3794
|
+
);
|
|
3795
|
+
actionsArrayMigrated = true;
|
|
3796
|
+
} else {
|
|
3797
|
+
const actionCandidates = actionsInitializer.getElements().filter(
|
|
3798
|
+
(element) => import_ts_morph17.Node.isObjectLiteralExpression(element)
|
|
3753
3799
|
);
|
|
3754
|
-
if (
|
|
3755
|
-
|
|
3800
|
+
if (actionCandidates.length === 0) {
|
|
3801
|
+
actionsProperty.remove();
|
|
3756
3802
|
console.log(
|
|
3757
|
-
` [${relPath}] Removed
|
|
3803
|
+
` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
|
|
3758
3804
|
);
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3805
|
+
actionsArrayMigrated = true;
|
|
3806
|
+
} else {
|
|
3807
|
+
if (actionCandidates.length > 1) {
|
|
3808
|
+
const droppedCount = actionCandidates.length - 1;
|
|
3809
|
+
console.warn(
|
|
3810
|
+
` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
|
|
3811
|
+
);
|
|
3812
|
+
}
|
|
3813
|
+
const conditionalsProperty = actionCandidates[0].getProperty(
|
|
3814
|
+
CONDITIONALS_PROPERTY_NAME
|
|
3764
3815
|
);
|
|
3816
|
+
if (conditionalsProperty) {
|
|
3817
|
+
conditionalsProperty.remove();
|
|
3818
|
+
console.log(
|
|
3819
|
+
` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`
|
|
3820
|
+
);
|
|
3821
|
+
}
|
|
3822
|
+
if (isUnsupportedActionType(actionCandidates[0])) {
|
|
3823
|
+
actionsProperty.remove();
|
|
3824
|
+
console.log(
|
|
3825
|
+
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
|
|
3826
|
+
);
|
|
3827
|
+
actionsArrayMigrated = true;
|
|
3828
|
+
} else {
|
|
3829
|
+
const firstActionText = actionCandidates[0].getText();
|
|
3830
|
+
workqueue.addPropertyAssignment({
|
|
3831
|
+
name: ACTION_PROPERTY_NAME2,
|
|
3832
|
+
initializer: firstActionText
|
|
3833
|
+
});
|
|
3834
|
+
actionsProperty.remove();
|
|
3835
|
+
console.log(
|
|
3836
|
+
` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
|
|
3837
|
+
);
|
|
3838
|
+
actionsArrayMigrated = true;
|
|
3839
|
+
}
|
|
3765
3840
|
}
|
|
3766
3841
|
}
|
|
3767
3842
|
}
|
|
3768
|
-
actionsProperty.remove();
|
|
3769
|
-
console.log(
|
|
3770
|
-
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
|
|
3771
|
-
);
|
|
3772
|
-
return 1;
|
|
3773
|
-
}
|
|
3774
|
-
const actionCandidates = actionsInitializer.getElements().filter(
|
|
3775
|
-
(element) => import_ts_morph17.Node.isObjectLiteralExpression(element)
|
|
3776
|
-
);
|
|
3777
|
-
if (actionCandidates.length === 0) {
|
|
3778
|
-
actionsProperty.remove();
|
|
3779
|
-
console.log(
|
|
3780
|
-
` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
|
|
3781
|
-
);
|
|
3782
|
-
return 1;
|
|
3783
3843
|
}
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3844
|
+
const fallback = ensureValidAction(workqueue, relPath);
|
|
3845
|
+
return {
|
|
3846
|
+
changed: actionsArrayMigrated || fallback.changed,
|
|
3847
|
+
usedReadFallback: fallback.usedReadFallback
|
|
3848
|
+
};
|
|
3849
|
+
}
|
|
3850
|
+
function ensureActionTypeImport(sourceFile) {
|
|
3851
|
+
const existingImport = sourceFile.getImportDeclaration(
|
|
3852
|
+
(decl) => decl.getModuleSpecifierValue() === TOOLKIT_EVENTS_MODULE2
|
|
3792
3853
|
);
|
|
3793
|
-
if (
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
if (isUnsupportedActionType(actionCandidates[0])) {
|
|
3800
|
-
actionsProperty.remove();
|
|
3801
|
-
console.log(
|
|
3802
|
-
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
|
|
3803
|
-
);
|
|
3804
|
-
return 1;
|
|
3854
|
+
if (existingImport) {
|
|
3855
|
+
const alreadyImported = existingImport.getNamedImports().some((ni) => ni.getName() === ACTION_TYPE_IMPORT_NAME);
|
|
3856
|
+
if (!alreadyImported) {
|
|
3857
|
+
existingImport.addNamedImport(ACTION_TYPE_IMPORT_NAME);
|
|
3858
|
+
}
|
|
3859
|
+
return;
|
|
3805
3860
|
}
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
initializer: firstActionText
|
|
3861
|
+
sourceFile.addImportDeclaration({
|
|
3862
|
+
moduleSpecifier: TOOLKIT_EVENTS_MODULE2,
|
|
3863
|
+
namedImports: [ACTION_TYPE_IMPORT_NAME]
|
|
3810
3864
|
});
|
|
3811
|
-
actionsProperty.remove();
|
|
3812
|
-
console.log(
|
|
3813
|
-
` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
|
|
3814
|
-
);
|
|
3815
|
-
return 1;
|
|
3816
3865
|
}
|
|
3817
3866
|
function processFile13(filePath, project) {
|
|
3818
3867
|
const sourceFile = project.getSourceFile(filePath);
|
|
3819
3868
|
if (!sourceFile) return 0;
|
|
3820
3869
|
let migratedWorkqueues = 0;
|
|
3870
|
+
let needsActionTypeImport = false;
|
|
3821
3871
|
const relPath = import_path18.default.relative(process.cwd(), filePath);
|
|
3822
3872
|
const callExpressions = sourceFile.getDescendantsOfKind(
|
|
3823
3873
|
import_ts_morph17.SyntaxKind.CallExpression
|
|
@@ -3833,9 +3883,14 @@ function processFile13(filePath, project) {
|
|
|
3833
3883
|
if (!import_ts_morph17.Node.isArrayLiteralExpression(workqueuesArg)) continue;
|
|
3834
3884
|
for (const element of workqueuesArg.getElements()) {
|
|
3835
3885
|
if (!import_ts_morph17.Node.isObjectLiteralExpression(element)) continue;
|
|
3836
|
-
|
|
3886
|
+
const result = migrateWorkqueueActions(element, relPath);
|
|
3887
|
+
if (result.changed) migratedWorkqueues++;
|
|
3888
|
+
if (result.usedReadFallback) needsActionTypeImport = true;
|
|
3837
3889
|
}
|
|
3838
3890
|
}
|
|
3891
|
+
if (needsActionTypeImport) {
|
|
3892
|
+
ensureActionTypeImport(sourceFile);
|
|
3893
|
+
}
|
|
3839
3894
|
return migratedWorkqueues;
|
|
3840
3895
|
}
|
|
3841
3896
|
async function main18() {
|
|
@@ -4170,7 +4225,7 @@ Saved ${handlerRelPath}.`);
|
|
|
4170
4225
|
// src/migrations/v2.0/checkout-upstream-files.ts
|
|
4171
4226
|
var import_child_process = require("child_process");
|
|
4172
4227
|
var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
|
|
4173
|
-
var UPSTREAM_BRANCH = "
|
|
4228
|
+
var UPSTREAM_BRANCH = "release-v2.0.0";
|
|
4174
4229
|
var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
|
|
4175
4230
|
var FILES_TO_CHECKOUT = [
|
|
4176
4231
|
"src/analytics/analytics.ts",
|
|
@@ -4720,9 +4775,13 @@ function gitShowBytes(ref, path23) {
|
|
|
4720
4775
|
return null;
|
|
4721
4776
|
}
|
|
4722
4777
|
}
|
|
4723
|
-
async function main25(
|
|
4778
|
+
async function main25({
|
|
4779
|
+
subdirs = []
|
|
4780
|
+
} = {}) {
|
|
4781
|
+
const pathspecs = subdirs.length > 0 ? subdirs.map((s) => `${INFRASTRUCTURE_DIR}/${s}/`) : [`${INFRASTRUCTURE_DIR}/`];
|
|
4782
|
+
const scopeLabel = pathspecs.map((p) => `'${p}'`).join(", ");
|
|
4724
4783
|
console.log(
|
|
4725
|
-
`Merging
|
|
4784
|
+
`Merging ${scopeLabel} from ${UPSTREAM_URL}@${UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...
|
|
4726
4785
|
`
|
|
4727
4786
|
);
|
|
4728
4787
|
assertIsGitRepo();
|
|
@@ -4737,20 +4796,12 @@ async function main25() {
|
|
|
4737
4796
|
const ref = `${TEMP_REMOTE2}/${UPSTREAM_BRANCH}`;
|
|
4738
4797
|
const baseRef = `${TEMP_REMOTE2}/${BASE_BRANCH}`;
|
|
4739
4798
|
const upstreamFiles = runGit(
|
|
4740
|
-
[
|
|
4741
|
-
"ls-tree",
|
|
4742
|
-
"-r",
|
|
4743
|
-
"--name-only",
|
|
4744
|
-
"-z",
|
|
4745
|
-
ref,
|
|
4746
|
-
"--",
|
|
4747
|
-
`${INFRASTRUCTURE_DIR}/`
|
|
4748
|
-
],
|
|
4799
|
+
["ls-tree", "-r", "--name-only", "-z", ref, "--", ...pathspecs],
|
|
4749
4800
|
{ silent: true }
|
|
4750
4801
|
).split("\0").filter(Boolean);
|
|
4751
4802
|
if (upstreamFiles.length === 0) {
|
|
4752
4803
|
console.log(
|
|
4753
|
-
` No files found under
|
|
4804
|
+
` No files found under ${scopeLabel} on ${ref}. Nothing to merge.`
|
|
4754
4805
|
);
|
|
4755
4806
|
return;
|
|
4756
4807
|
}
|
|
@@ -4825,7 +4876,9 @@ async function main25() {
|
|
|
4825
4876
|
var import_fs6 = require("fs");
|
|
4826
4877
|
var import_path25 = require("path");
|
|
4827
4878
|
var INFRASTRUCTURE_DIR2 = "infrastructure";
|
|
4828
|
-
async function main26(
|
|
4879
|
+
async function main26({
|
|
4880
|
+
keep = []
|
|
4881
|
+
} = {}) {
|
|
4829
4882
|
const fullPath = (0, import_path25.join)(process.cwd(), INFRASTRUCTURE_DIR2);
|
|
4830
4883
|
if (!(0, import_fs6.existsSync)(fullPath)) {
|
|
4831
4884
|
console.log(
|
|
@@ -4833,24 +4886,64 @@ async function main26() {
|
|
|
4833
4886
|
);
|
|
4834
4887
|
return;
|
|
4835
4888
|
}
|
|
4836
|
-
console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
|
|
4837
|
-
`);
|
|
4838
4889
|
assertIsGitRepo();
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
console.log(
|
|
4890
|
+
if (keep.length === 0) {
|
|
4891
|
+
console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
|
|
4892
|
+
`);
|
|
4893
|
+
runGit(["rm", "-rf", "--ignore-unmatch", "--", `${INFRASTRUCTURE_DIR2}/`], {
|
|
4894
|
+
silent: true
|
|
4895
|
+
});
|
|
4896
|
+
console.log(
|
|
4897
|
+
` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR2}/'.`
|
|
4898
|
+
);
|
|
4899
|
+
if ((0, import_fs6.existsSync)(fullPath)) {
|
|
4900
|
+
(0, import_fs6.rmSync)(fullPath, { recursive: true, force: true });
|
|
4901
|
+
console.log(
|
|
4902
|
+
` Removed remaining untracked files under '${INFRASTRUCTURE_DIR2}/'.`
|
|
4903
|
+
);
|
|
4904
|
+
}
|
|
4905
|
+
console.log(
|
|
4906
|
+
`
|
|
4907
|
+
Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
|
|
4908
|
+
);
|
|
4909
|
+
return;
|
|
4910
|
+
}
|
|
4911
|
+
const keepSet = new Set(keep);
|
|
4912
|
+
console.log(
|
|
4913
|
+
`Deleting contents of '${INFRASTRUCTURE_DIR2}/' except: ${[...keepSet].map((name) => `'${name}'`).join(", ")}
|
|
4914
|
+
`
|
|
4915
|
+
);
|
|
4916
|
+
const topLevelEntries = (0, import_fs6.readdirSync)(fullPath, { withFileTypes: true });
|
|
4917
|
+
let deleted = 0;
|
|
4918
|
+
for (const entry of topLevelEntries) {
|
|
4919
|
+
if (keepSet.has(entry.name)) {
|
|
4920
|
+
console.log(` Keeping '${INFRASTRUCTURE_DIR2}/${entry.name}'.`);
|
|
4921
|
+
continue;
|
|
4922
|
+
}
|
|
4923
|
+
const relPath = `${INFRASTRUCTURE_DIR2}/${entry.name}${entry.isDirectory() ? "/" : ""}`;
|
|
4924
|
+
runGit(["rm", "-rf", "--ignore-unmatch", "--", relPath], { silent: true });
|
|
4925
|
+
const fullEntryPath = (0, import_path25.join)(fullPath, entry.name);
|
|
4926
|
+
if ((0, import_fs6.existsSync)(fullEntryPath)) {
|
|
4927
|
+
(0, import_fs6.rmSync)(fullEntryPath, { recursive: true, force: true });
|
|
4928
|
+
}
|
|
4929
|
+
console.log(` Deleted '${relPath}'.`);
|
|
4930
|
+
deleted++;
|
|
4931
|
+
}
|
|
4932
|
+
const presentNames = new Set(topLevelEntries.map((e) => e.name));
|
|
4933
|
+
const missingKeeps = [...keepSet].filter((name) => !presentNames.has(name));
|
|
4934
|
+
if (missingKeeps.length > 0) {
|
|
4935
|
+
console.warn(
|
|
4936
|
+
` [warn] Requested to keep ${missingKeeps.map((n) => `'${n}'`).join(", ")} but they don't exist under '${INFRASTRUCTURE_DIR2}/'.`
|
|
4937
|
+
);
|
|
4846
4938
|
}
|
|
4847
4939
|
console.log(
|
|
4848
4940
|
`
|
|
4849
|
-
Done. Review the staged
|
|
4941
|
+
Done. Deleted ${deleted} top-level entr${deleted === 1 ? "y" : "ies"}. Review the staged deletions with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
|
|
4850
4942
|
);
|
|
4851
4943
|
}
|
|
4852
4944
|
|
|
4853
4945
|
// src/migrations/v2.0/index.ts
|
|
4946
|
+
var NON_SWARM_INFRA_SUBDIRS = ["postgres", "metabase"];
|
|
4854
4947
|
async function runUpgrade(dockerSwarm) {
|
|
4855
4948
|
await main18();
|
|
4856
4949
|
await main();
|
|
@@ -4879,6 +4972,7 @@ async function runUpgrade(dockerSwarm) {
|
|
|
4879
4972
|
if (dockerSwarm) {
|
|
4880
4973
|
await main25();
|
|
4881
4974
|
} else {
|
|
4882
|
-
await main26();
|
|
4975
|
+
await main26({ keep: NON_SWARM_INFRA_SUBDIRS });
|
|
4976
|
+
await main25({ subdirs: NON_SWARM_INFRA_SUBDIRS });
|
|
4883
4977
|
}
|
|
4884
4978
|
}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
interface MergeInfrastructureOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Top-level subdirectories of `infrastructure/` to scope the merge to.
|
|
4
|
+
* When omitted or empty, the entire `infrastructure/` tree is merged
|
|
5
|
+
* (legacy behavior). Each name is relative to `infrastructure/` —
|
|
6
|
+
* e.g. `['postgres', 'metabase']` merges only
|
|
7
|
+
* `infrastructure/postgres/` and `infrastructure/metabase/`.
|
|
8
|
+
*/
|
|
9
|
+
subdirs?: string[];
|
|
10
|
+
}
|
|
11
|
+
declare function main({ subdirs }?: MergeInfrastructureOptions): Promise<void>;
|
|
2
12
|
export { main };
|
|
3
13
|
//# sourceMappingURL=merge-infrastructure-directory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-infrastructure-directory.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/merge-infrastructure-directory.ts"],"names":[],"mappings":"AAsHA,iBAAe,IAAI,
|
|
1
|
+
{"version":3,"file":"merge-infrastructure-directory.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/merge-infrastructure-directory.ts"],"names":[],"mappings":"AAsHA,UAAU,0BAA0B;IAClC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAID,iBAAe,IAAI,CAAC,EAClB,OAAY,EACb,GAAE,0BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoIjD;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -22,7 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.main = main;
|
|
23
23
|
/**
|
|
24
24
|
* Codemod: Merge upstream changes into the local `infrastructure/` directory
|
|
25
|
-
* from opencrvs/opencrvs-countryconfig.
|
|
25
|
+
* (or selected subdirectories of it) from opencrvs/opencrvs-countryconfig.
|
|
26
26
|
*
|
|
27
27
|
* Usage:
|
|
28
28
|
* ts-node -r tsconfig-paths/register src/migrations/v2.0/merge-infrastructure-directory.ts
|
|
@@ -33,8 +33,10 @@ exports.main = main;
|
|
|
33
33
|
* - the upstream "theirs" branch (v2.0) → `UPSTREAM_BRANCH`
|
|
34
34
|
* - the synthetic merge-base branch (latest 1.9 release line)
|
|
35
35
|
* → `BASE_BRANCH`
|
|
36
|
-
* 2. For every file under `infrastructure/` on upstream "theirs",
|
|
37
|
-
*
|
|
36
|
+
* 2. For every file under `infrastructure/` on upstream "theirs" (or, when
|
|
37
|
+
* `subdirs` is provided, only files under
|
|
38
|
+
* `infrastructure/<subdir>/` for each requested subdir), performs a
|
|
39
|
+
* file-scoped 3-way merge:
|
|
38
40
|
* - new file on upstream → checked out and staged
|
|
39
41
|
* - existing file → 3-way merged in place via `git merge-file`,
|
|
40
42
|
* using the BASE_BRANCH version of the file
|
|
@@ -116,8 +118,14 @@ function gitShowBytes(ref, path) {
|
|
|
116
118
|
}
|
|
117
119
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
118
120
|
function main() {
|
|
119
|
-
return __awaiter(this,
|
|
120
|
-
|
|
121
|
+
return __awaiter(this, arguments, void 0, function* ({ subdirs = [] } = {}) {
|
|
122
|
+
// Build the pathspec list passed to `git ls-tree`. Trailing slashes make
|
|
123
|
+
// git treat them as tree paths (recurse into them).
|
|
124
|
+
const pathspecs = subdirs.length > 0
|
|
125
|
+
? subdirs.map((s) => `${INFRASTRUCTURE_DIR}/${s}/`)
|
|
126
|
+
: [`${INFRASTRUCTURE_DIR}/`];
|
|
127
|
+
const scopeLabel = pathspecs.map((p) => `'${p}'`).join(', ');
|
|
128
|
+
console.log(`Merging ${scopeLabel} from ${checkout_upstream_files_1.UPSTREAM_URL}@${checkout_upstream_files_1.UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...\n`);
|
|
121
129
|
(0, checkout_upstream_files_1.assertIsGitRepo)();
|
|
122
130
|
// Best-effort cleanup of a stale temp remote from a previous aborted run.
|
|
123
131
|
(0, checkout_upstream_files_1.tryGit)(['remote', 'remove', TEMP_REMOTE]);
|
|
@@ -131,20 +139,13 @@ function main() {
|
|
|
131
139
|
const ref = `${TEMP_REMOTE}/${checkout_upstream_files_1.UPSTREAM_BRANCH}`;
|
|
132
140
|
const baseRef = `${TEMP_REMOTE}/${BASE_BRANCH}`;
|
|
133
141
|
// -z gives NUL-separated paths so filenames with spaces or newlines
|
|
134
|
-
// survive the round-trip.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
'-r',
|
|
138
|
-
'--name-only',
|
|
139
|
-
'-z',
|
|
140
|
-
ref,
|
|
141
|
-
'--',
|
|
142
|
-
`${INFRASTRUCTURE_DIR}/`
|
|
143
|
-
], { silent: true })
|
|
142
|
+
// survive the round-trip. Multiple pathspecs after `--` are unioned
|
|
143
|
+
// by git, which scopes the listing to the requested subdirectories.
|
|
144
|
+
const upstreamFiles = (0, checkout_upstream_files_1.runGit)(['ls-tree', '-r', '--name-only', '-z', ref, '--', ...pathspecs], { silent: true })
|
|
144
145
|
.split('\0')
|
|
145
146
|
.filter(Boolean);
|
|
146
147
|
if (upstreamFiles.length === 0) {
|
|
147
|
-
console.log(` No files found under
|
|
148
|
+
console.log(` No files found under ${scopeLabel} on ${ref}. Nothing to merge.`);
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
150
151
|
const tmpDir = (0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), 'opencrvs-merge-infra-'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-workqueue-configs.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-workqueue-configs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrate-workqueue-configs.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/migrate-workqueue-configs.ts"],"names":[],"mappings":"AAgVA,iBAAe,IAAI,kBAqDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|