@opencrvs/toolkit 2.0.0-rc.a26ae04 → 2.0.0-rc.a3c1fd8

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.
Files changed (29) hide show
  1. package/create-countryconfig/index.js +73 -0
  2. package/create-countryconfig/package.json +11 -0
  3. package/dist/application-config/index.js +5 -3
  4. package/dist/cli.js +192 -96
  5. package/dist/commons/api/router.d.ts +20 -20
  6. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  7. package/dist/commons/events/FieldConfig.d.ts +5 -0
  8. package/dist/conditionals/index.js +5 -3
  9. package/dist/events/index.js +5 -3
  10. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  11. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  12. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -2
  13. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +9 -1
  14. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -1
  15. package/dist/migrations/v2.0/delete-infrastructure-directory.js +66 -20
  16. package/dist/migrations/v2.0/index.d.ts +5 -3
  17. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  18. package/dist/migrations/v2.0/index.js +192 -96
  19. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +11 -1
  20. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -1
  21. package/dist/migrations/v2.0/merge-infrastructure-directory.js +17 -16
  22. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  23. package/dist/migrations/v2.0/migrate-workqueue-configs.js +140 -59
  24. package/dist/notification/index.js +5 -3
  25. package/dist/scopes/index.d.ts +6 -1
  26. package/dist/scopes/index.js +5 -3
  27. package/opencrvs-toolkit-2.0.0-rc.a3c1fd8.tgz +0 -0
  28. package/package.json +1 -1
  29. package/opencrvs-toolkit-2.0.0-rc.a26ae04.tgz +0 -0
@@ -2308,12 +2308,14 @@ var SystemScopeType = z3.enum([
2308
2308
  "organisation.read-locations",
2309
2309
  "user.read",
2310
2310
  "user.create",
2311
- "user.edit"
2311
+ "user.edit",
2312
+ "user.search"
2312
2313
  ]);
2313
2314
  var UserScopeType = SystemScopeType.extract([
2314
2315
  "user.read",
2315
2316
  "user.create",
2316
- "user.edit"
2317
+ "user.edit",
2318
+ "user.search"
2317
2319
  ]);
2318
2320
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
2319
2321
  var UserScopeV2 = z3.discriminatedUnion("type", [
@@ -2322,7 +2324,7 @@ var UserScopeV2 = z3.discriminatedUnion("type", [
2322
2324
  options: AllUserScopeOptions.optional()
2323
2325
  }),
2324
2326
  z3.object({
2325
- type: UserScopeType.extract(["user.read"]),
2327
+ type: UserScopeType.extract(["user.read", "user.search"]),
2326
2328
  options: AccessLevelOptions.optional()
2327
2329
  })
2328
2330
  ]);
@@ -3684,6 +3686,10 @@ var ACTION_PROPERTY_NAME2 = "action";
3684
3686
  var CONDITIONALS_PROPERTY_NAME = "conditionals";
3685
3687
  var TYPE_PROPERTY_NAME7 = "type";
3686
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} }`;
3687
3693
  var SUPPORTED_WORKQUEUE_ACTION_TYPES = /* @__PURE__ */ new Set([
3688
3694
  "READ",
3689
3695
  "DELETE",
@@ -3731,91 +3737,137 @@ function isUnsupportedActionType(action) {
3731
3737
  }
3732
3738
  return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
3733
3739
  }
3734
- function migrateWorkqueueActions(workqueue, relPath) {
3735
- const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
3736
- if (!actionsProperty || !import_ts_morph17.Node.isPropertyAssignment(actionsProperty)) {
3737
- return 0;
3738
- }
3739
- const actionsInitializer = actionsProperty.getInitializer();
3740
- if (!actionsInitializer || !import_ts_morph17.Node.isArrayLiteralExpression(actionsInitializer)) {
3741
- return 0;
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
+ }
3742
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) {
3743
3769
  const workqueueLabel = getWorkqueueLabel(workqueue);
3744
- const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
3745
- if (existingActionProperty) {
3746
- if (import_ts_morph17.Node.isPropertyAssignment(existingActionProperty)) {
3747
- const existingActionInitializer = existingActionProperty.getInitializer();
3748
- if (existingActionInitializer && import_ts_morph17.Node.isObjectLiteralExpression(existingActionInitializer)) {
3749
- const conditionalsProperty2 = existingActionInitializer.getProperty(
3750
- CONDITIONALS_PROPERTY_NAME
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)
3751
3799
  );
3752
- if (conditionalsProperty2) {
3753
- conditionalsProperty2.remove();
3800
+ if (actionCandidates.length === 0) {
3801
+ actionsProperty.remove();
3754
3802
  console.log(
3755
- ` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`
3803
+ ` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
3756
3804
  );
3757
- }
3758
- if (isUnsupportedActionType(existingActionInitializer)) {
3759
- existingActionProperty.remove();
3760
- console.log(
3761
- ` [${relPath}] Removed unsupported 'action' type on workqueue '${workqueueLabel}'`
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
3762
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
+ }
3763
3840
  }
3764
3841
  }
3765
3842
  }
3766
- actionsProperty.remove();
3767
- console.log(
3768
- ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
3769
- );
3770
- return 1;
3771
- }
3772
- const actionCandidates = actionsInitializer.getElements().filter(
3773
- (element) => import_ts_morph17.Node.isObjectLiteralExpression(element)
3774
- );
3775
- if (actionCandidates.length === 0) {
3776
- actionsProperty.remove();
3777
- console.log(
3778
- ` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
3779
- );
3780
- return 1;
3781
3843
  }
3782
- if (actionCandidates.length > 1) {
3783
- const droppedCount = actionCandidates.length - 1;
3784
- console.warn(
3785
- ` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
3786
- );
3787
- }
3788
- const conditionalsProperty = actionCandidates[0].getProperty(
3789
- CONDITIONALS_PROPERTY_NAME
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
3790
3853
  );
3791
- if (conditionalsProperty) {
3792
- conditionalsProperty.remove();
3793
- console.log(
3794
- ` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`
3795
- );
3796
- }
3797
- if (isUnsupportedActionType(actionCandidates[0])) {
3798
- actionsProperty.remove();
3799
- console.log(
3800
- ` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
3801
- );
3802
- 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;
3803
3860
  }
3804
- const firstActionText = actionCandidates[0].getText();
3805
- workqueue.addPropertyAssignment({
3806
- name: ACTION_PROPERTY_NAME2,
3807
- initializer: firstActionText
3861
+ sourceFile.addImportDeclaration({
3862
+ moduleSpecifier: TOOLKIT_EVENTS_MODULE2,
3863
+ namedImports: [ACTION_TYPE_IMPORT_NAME]
3808
3864
  });
3809
- actionsProperty.remove();
3810
- console.log(
3811
- ` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
3812
- );
3813
- return 1;
3814
3865
  }
3815
3866
  function processFile13(filePath, project) {
3816
3867
  const sourceFile = project.getSourceFile(filePath);
3817
3868
  if (!sourceFile) return 0;
3818
3869
  let migratedWorkqueues = 0;
3870
+ let needsActionTypeImport = false;
3819
3871
  const relPath = import_path18.default.relative(process.cwd(), filePath);
3820
3872
  const callExpressions = sourceFile.getDescendantsOfKind(
3821
3873
  import_ts_morph17.SyntaxKind.CallExpression
@@ -3831,9 +3883,14 @@ function processFile13(filePath, project) {
3831
3883
  if (!import_ts_morph17.Node.isArrayLiteralExpression(workqueuesArg)) continue;
3832
3884
  for (const element of workqueuesArg.getElements()) {
3833
3885
  if (!import_ts_morph17.Node.isObjectLiteralExpression(element)) continue;
3834
- migratedWorkqueues += migrateWorkqueueActions(element, relPath);
3886
+ const result = migrateWorkqueueActions(element, relPath);
3887
+ if (result.changed) migratedWorkqueues++;
3888
+ if (result.usedReadFallback) needsActionTypeImport = true;
3835
3889
  }
3836
3890
  }
3891
+ if (needsActionTypeImport) {
3892
+ ensureActionTypeImport(sourceFile);
3893
+ }
3837
3894
  return migratedWorkqueues;
3838
3895
  }
3839
3896
  async function main18() {
@@ -4168,7 +4225,7 @@ Saved ${handlerRelPath}.`);
4168
4225
  // src/migrations/v2.0/checkout-upstream-files.ts
4169
4226
  var import_child_process = require("child_process");
4170
4227
  var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
4171
- var UPSTREAM_BRANCH = "develop";
4228
+ var UPSTREAM_BRANCH = "release-v2.0.0";
4172
4229
  var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
4173
4230
  var FILES_TO_CHECKOUT = [
4174
4231
  "src/analytics/analytics.ts",
@@ -4718,9 +4775,13 @@ function gitShowBytes(ref, path23) {
4718
4775
  return null;
4719
4776
  }
4720
4777
  }
4721
- 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(", ");
4722
4783
  console.log(
4723
- `Merging '${INFRASTRUCTURE_DIR}/' from ${UPSTREAM_URL}@${UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...
4784
+ `Merging ${scopeLabel} from ${UPSTREAM_URL}@${UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...
4724
4785
  `
4725
4786
  );
4726
4787
  assertIsGitRepo();
@@ -4735,20 +4796,12 @@ async function main25() {
4735
4796
  const ref = `${TEMP_REMOTE2}/${UPSTREAM_BRANCH}`;
4736
4797
  const baseRef = `${TEMP_REMOTE2}/${BASE_BRANCH}`;
4737
4798
  const upstreamFiles = runGit(
4738
- [
4739
- "ls-tree",
4740
- "-r",
4741
- "--name-only",
4742
- "-z",
4743
- ref,
4744
- "--",
4745
- `${INFRASTRUCTURE_DIR}/`
4746
- ],
4799
+ ["ls-tree", "-r", "--name-only", "-z", ref, "--", ...pathspecs],
4747
4800
  { silent: true }
4748
4801
  ).split("\0").filter(Boolean);
4749
4802
  if (upstreamFiles.length === 0) {
4750
4803
  console.log(
4751
- ` No files found under '${INFRASTRUCTURE_DIR}/' on ${ref}. Nothing to merge.`
4804
+ ` No files found under ${scopeLabel} on ${ref}. Nothing to merge.`
4752
4805
  );
4753
4806
  return;
4754
4807
  }
@@ -4823,7 +4876,9 @@ async function main25() {
4823
4876
  var import_fs6 = require("fs");
4824
4877
  var import_path25 = require("path");
4825
4878
  var INFRASTRUCTURE_DIR2 = "infrastructure";
4826
- async function main26() {
4879
+ async function main26({
4880
+ keep = []
4881
+ } = {}) {
4827
4882
  const fullPath = (0, import_path25.join)(process.cwd(), INFRASTRUCTURE_DIR2);
4828
4883
  if (!(0, import_fs6.existsSync)(fullPath)) {
4829
4884
  console.log(
@@ -4831,24 +4886,64 @@ async function main26() {
4831
4886
  );
4832
4887
  return;
4833
4888
  }
4834
- console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
4835
- `);
4836
4889
  assertIsGitRepo();
4837
- runGit(["rm", "-rf", "--ignore-unmatch", "--", `${INFRASTRUCTURE_DIR2}/`], {
4838
- silent: true
4839
- });
4840
- console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR2}/'.`);
4841
- if ((0, import_fs6.existsSync)(fullPath)) {
4842
- (0, import_fs6.rmSync)(fullPath, { recursive: true, force: true });
4843
- console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR2}/'.`);
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
+ );
4844
4938
  }
4845
4939
  console.log(
4846
4940
  `
4847
- Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
4941
+ Done. Deleted ${deleted} top-level entr${deleted === 1 ? "y" : "ies"}. Review the staged deletions with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
4848
4942
  );
4849
4943
  }
4850
4944
 
4851
4945
  // src/migrations/v2.0/index.ts
4946
+ var NON_SWARM_INFRA_SUBDIRS = ["postgres", "metabase"];
4852
4947
  async function runUpgrade(dockerSwarm) {
4853
4948
  await main18();
4854
4949
  await main();
@@ -4877,6 +4972,7 @@ async function runUpgrade(dockerSwarm) {
4877
4972
  if (dockerSwarm) {
4878
4973
  await main25();
4879
4974
  } else {
4880
- await main26();
4975
+ await main26({ keep: NON_SWARM_INFRA_SUBDIRS });
4976
+ await main25({ subdirs: NON_SWARM_INFRA_SUBDIRS });
4881
4977
  }
4882
4978
  }
@@ -1,3 +1,13 @@
1
- declare function main(): Promise<void>;
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,IAAI,OAAO,CAAC,IAAI,CAAC,CAkInC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
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", performs
37
- * a file-scoped 3-way merge:
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, void 0, void 0, function* () {
120
- console.log(`Merging '${INFRASTRUCTURE_DIR}/' from ${checkout_upstream_files_1.UPSTREAM_URL}@${checkout_upstream_files_1.UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...\n`);
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
- const upstreamFiles = (0, checkout_upstream_files_1.runGit)([
136
- 'ls-tree',
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 '${INFRASTRUCTURE_DIR}/' on ${ref}. Nothing to merge.`);
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":"AA+OA,iBAAe,IAAI,kBAqDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
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"}