@opencrvs/toolkit 2.0.0-rc.e52417d → 2.0.0-rc.e5254ee
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/create-countryconfig/index.js +73 -0
- package/create-countryconfig/package.json +11 -0
- package/dist/application-config/index.js +5 -3
- package/dist/cli.js +192 -96
- package/dist/commons/api/router.d.ts +20 -20
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/locations.d.ts +21 -0
- package/dist/commons/events/mocks.test.utils.d.ts +19 -0
- package/dist/commons/events/scopes.d.ts +24 -1
- package/dist/conditionals/index.js +5 -3
- package/dist/events/index.js +60 -3
- 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 +192 -96
- 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 +5 -3
- package/dist/scopes/index.d.ts +6 -1
- package/dist/scopes/index.js +5 -3
- package/opencrvs-toolkit-2.0.0-rc.e5254ee.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.0.0-rc.e52417d.tgz +0 -0
|
@@ -27,20 +27,28 @@ exports.main = main;
|
|
|
27
27
|
* via Docker Swarm. In that case the `infrastructure/` directory shipped
|
|
28
28
|
* with opencrvs-countryconfig is no longer needed and can be removed.
|
|
29
29
|
*
|
|
30
|
+
* Some non-Swarm deployments still need a small subset of
|
|
31
|
+
* `infrastructure/` (e.g. `postgres/` and `metabase/`). Pass `keep` to
|
|
32
|
+
* preserve those top-level subdirectories — everything else under
|
|
33
|
+
* `infrastructure/` is deleted, and the kept subdirectories can then be
|
|
34
|
+
* refreshed from upstream by `merge-infrastructure-directory.ts` with the
|
|
35
|
+
* matching `subdirs` option.
|
|
36
|
+
*
|
|
30
37
|
* Usage:
|
|
31
38
|
* ts-node -r tsconfig-paths/register src/migrations/v2.0/delete-infrastructure-directory.ts
|
|
32
39
|
*
|
|
33
40
|
* What it does:
|
|
34
41
|
* 1. Stages deletion of all tracked files under `infrastructure/` via
|
|
35
|
-
* `git rm -rf --ignore-unmatch --
|
|
36
|
-
*
|
|
42
|
+
* `git rm -rf --ignore-unmatch -- <path>`. This both removes the
|
|
43
|
+
* files from the working tree and records the deletion in the
|
|
37
44
|
* index, so it shows up in the upgrade commit alongside the other
|
|
38
|
-
* codemod changes.
|
|
45
|
+
* codemod changes. When `keep` is provided, deletion is scoped to
|
|
46
|
+
* the top-level entries that are NOT in `keep`.
|
|
39
47
|
* 2. Cleans up any untracked files / empty directory that `git rm` left
|
|
40
|
-
* behind, so the
|
|
48
|
+
* behind, so the deleted paths are fully gone from the working tree.
|
|
41
49
|
*
|
|
42
50
|
* Caveats:
|
|
43
|
-
* - Destructive: any local edits to
|
|
51
|
+
* - Destructive: any local edits to deleted paths are lost. Run on a
|
|
44
52
|
* clean working tree (or after committing your local changes).
|
|
45
53
|
* - If `infrastructure/` doesn't exist, this codemod is a no-op.
|
|
46
54
|
* - Requires git to be installed and the country config working directory
|
|
@@ -51,27 +59,65 @@ const path_1 = require("path");
|
|
|
51
59
|
const checkout_upstream_files_1 = require("./checkout-upstream-files");
|
|
52
60
|
const INFRASTRUCTURE_DIR = 'infrastructure';
|
|
53
61
|
function main() {
|
|
54
|
-
return __awaiter(this,
|
|
62
|
+
return __awaiter(this, arguments, void 0, function* ({ keep = [] } = {}) {
|
|
55
63
|
const fullPath = (0, path_1.join)(process.cwd(), INFRASTRUCTURE_DIR);
|
|
56
64
|
if (!(0, fs_1.existsSync)(fullPath)) {
|
|
57
65
|
console.log(`'${INFRASTRUCTURE_DIR}/' not found in ${process.cwd()} — nothing to delete.`);
|
|
58
66
|
return;
|
|
59
67
|
}
|
|
60
|
-
console.log(`Deleting '${INFRASTRUCTURE_DIR}/'...\n`);
|
|
61
68
|
(0, checkout_upstream_files_1.assertIsGitRepo)();
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
// ─── Whole-directory delete (legacy behavior) ────────────────────────
|
|
70
|
+
if (keep.length === 0) {
|
|
71
|
+
console.log(`Deleting '${INFRASTRUCTURE_DIR}/'...\n`);
|
|
72
|
+
// `git rm -rf --ignore-unmatch` removes tracked files (working tree +
|
|
73
|
+
// index) and is a no-op for paths with no tracked entries, so it's
|
|
74
|
+
// safe to run even when `infrastructure/` exists only as untracked
|
|
75
|
+
// files.
|
|
76
|
+
(0, checkout_upstream_files_1.runGit)(['rm', '-rf', '--ignore-unmatch', '--', `${INFRASTRUCTURE_DIR}/`], {
|
|
77
|
+
silent: true
|
|
78
|
+
});
|
|
79
|
+
console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR}/'.`);
|
|
80
|
+
// `git rm` leaves untracked files (and any now-empty directory) on
|
|
81
|
+
// disk; remove whatever's left so the path is fully gone.
|
|
82
|
+
if ((0, fs_1.existsSync)(fullPath)) {
|
|
83
|
+
(0, fs_1.rmSync)(fullPath, { recursive: true, force: true });
|
|
84
|
+
console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR}/'.`);
|
|
85
|
+
}
|
|
86
|
+
console.log(`\n Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR}/'`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// ─── Selective delete: keep listed top-level entries ─────────────────
|
|
90
|
+
const keepSet = new Set(keep);
|
|
91
|
+
console.log(`Deleting contents of '${INFRASTRUCTURE_DIR}/' except: ${[...keepSet]
|
|
92
|
+
.map((name) => `'${name}'`)
|
|
93
|
+
.join(', ')}\n`);
|
|
94
|
+
const topLevelEntries = (0, fs_1.readdirSync)(fullPath, { withFileTypes: true });
|
|
95
|
+
let deleted = 0;
|
|
96
|
+
for (const entry of topLevelEntries) {
|
|
97
|
+
if (keepSet.has(entry.name)) {
|
|
98
|
+
console.log(` Keeping '${INFRASTRUCTURE_DIR}/${entry.name}'.`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
// Append a trailing slash for directories so git treats it as a tree
|
|
102
|
+
// pathspec (matches the recursive behavior of `git rm -rf`).
|
|
103
|
+
const relPath = `${INFRASTRUCTURE_DIR}/${entry.name}${entry.isDirectory() ? '/' : ''}`;
|
|
104
|
+
(0, checkout_upstream_files_1.runGit)(['rm', '-rf', '--ignore-unmatch', '--', relPath], { silent: true });
|
|
105
|
+
const fullEntryPath = (0, path_1.join)(fullPath, entry.name);
|
|
106
|
+
if ((0, fs_1.existsSync)(fullEntryPath)) {
|
|
107
|
+
(0, fs_1.rmSync)(fullEntryPath, { recursive: true, force: true });
|
|
108
|
+
}
|
|
109
|
+
console.log(` Deleted '${relPath}'.`);
|
|
110
|
+
deleted++;
|
|
111
|
+
}
|
|
112
|
+
// Note any requested keeps that weren't actually present, so the dev
|
|
113
|
+
// notices typos / missing directories.
|
|
114
|
+
const presentNames = new Set(topLevelEntries.map((e) => e.name));
|
|
115
|
+
const missingKeeps = [...keepSet].filter((name) => !presentNames.has(name));
|
|
116
|
+
if (missingKeeps.length > 0) {
|
|
117
|
+
console.warn(` [warn] Requested to keep ${missingKeeps
|
|
118
|
+
.map((n) => `'${n}'`)
|
|
119
|
+
.join(', ')} but they don't exist under '${INFRASTRUCTURE_DIR}/'.`);
|
|
74
120
|
}
|
|
75
|
-
console.log(`\n Done. Review the staged
|
|
121
|
+
console.log(`\n Done. Deleted ${deleted} top-level entr${deleted === 1 ? 'y' : 'ies'}. Review the staged deletions with: git diff --cached -- '${INFRASTRUCTURE_DIR}/'`);
|
|
76
122
|
});
|
|
77
123
|
}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
* directory.
|
|
4
4
|
*
|
|
5
5
|
* @param dockerSwarm - When true, the local `infrastructure/` directory is
|
|
6
|
-
* merged with upstream changes (Docker Swarm deployments
|
|
7
|
-
* When false (the default),
|
|
8
|
-
*
|
|
6
|
+
* merged with upstream changes in its entirety (Docker Swarm deployments
|
|
7
|
+
* still need it all). When false (the default), everything under
|
|
8
|
+
* `infrastructure/` is deleted EXCEPT the subdirectories listed in
|
|
9
|
+
* `NON_SWARM_INFRA_SUBDIRS`, and those preserved subdirectories are then
|
|
10
|
+
* merged with upstream.
|
|
9
11
|
*/
|
|
10
12
|
export declare function runUpgrade(dockerSwarm: boolean): Promise<void>;
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AA6CA;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,OAAO,iBAgCpD"}
|
|
@@ -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
|
|
3735
|
-
const
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
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
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
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 (
|
|
3753
|
-
|
|
3800
|
+
if (actionCandidates.length === 0) {
|
|
3801
|
+
actionsProperty.remove();
|
|
3754
3802
|
console.log(
|
|
3755
|
-
` [${relPath}] Removed
|
|
3803
|
+
` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
|
|
3756
3804
|
);
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
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
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
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 (
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
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
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
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
|
-
|
|
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 = "
|
|
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
|
|
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
|
|
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
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
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
|
+
);
|
|
4844
4938
|
}
|
|
4845
4939
|
console.log(
|
|
4846
4940
|
`
|
|
4847
|
-
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}/'`
|
|
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
|
-
|
|
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"}
|