@opencrvs/toolkit 2.0.0-rc.3c7efd6 → 2.0.0-rc.43258ca
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 +7 -37
- package/dist/cli.js +149 -1420
- package/dist/commons/api/router.d.ts +66 -44
- package/dist/commons/conditionals/conditionals.d.ts +6 -6
- package/dist/commons/events/FieldConfig.d.ts +0 -10
- package/dist/commons/events/locations.d.ts +1 -17
- package/dist/conditionals/index.js +7 -37
- package/dist/events/index.js +7 -75
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +4 -3
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -19
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +13 -17
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +5 -4
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +5 -4
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
- package/dist/migrations/v2.0/create-events-index.js +2 -1
- package/dist/migrations/v2.0/index.d.ts +4 -8
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +146 -1388
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +6 -5
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +7 -6
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +4 -3
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +4 -3
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +4 -3
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +3 -2
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +4 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +2 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +4 -3
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +4 -3
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-api-paths.js +4 -3
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +4 -3
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +2 -1
- package/dist/notification/index.js +7 -37
- package/dist/scopes/index.d.ts +10 -87
- package/dist/scopes/index.js +8 -43
- package/opencrvs-toolkit-2.0.0-rc.43258ca.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -3
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -77
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -3
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -221
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-application-config-url.js +0 -342
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
- package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
- package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
- package/dist/migrations/v2.0/update-package-json.js +0 -105
- package/opencrvs-toolkit-2.0.0-rc.3c7efd6.tgz +0 -0
package/dist/cli.js
CHANGED
|
@@ -91,7 +91,7 @@ function processFile(filePath, project) {
|
|
|
91
91
|
if (wasRemoved) {
|
|
92
92
|
removedCount++;
|
|
93
93
|
console.log(
|
|
94
|
-
` [${import_path.default.relative(
|
|
94
|
+
` [${import_path.default.relative(getCwd(), filePath)}] Removed 'review' from REGISTER action`
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -99,7 +99,7 @@ function processFile(filePath, project) {
|
|
|
99
99
|
return removedCount;
|
|
100
100
|
}
|
|
101
101
|
async function main() {
|
|
102
|
-
const srcDir = import_path.default.join(
|
|
102
|
+
const srcDir = import_path.default.join(getCwd(), "src");
|
|
103
103
|
console.log(`Scanning for defineConfig calls in: ${srcDir}
|
|
104
104
|
`);
|
|
105
105
|
const project = new import_ts_morph.Project({
|
|
@@ -135,7 +135,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
135
135
|
for (const filePath of modifiedFiles) {
|
|
136
136
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
137
137
|
await sourceFile.save();
|
|
138
|
-
console.log(` Saved: ${import_path.default.relative(
|
|
138
|
+
console.log(` Saved: ${import_path.default.relative(getCwd(), filePath)}`);
|
|
139
139
|
}
|
|
140
140
|
console.log(
|
|
141
141
|
`
|
|
@@ -338,7 +338,7 @@ function processFile2(filePath, project) {
|
|
|
338
338
|
const eventType = resolveEventType(configArg);
|
|
339
339
|
if (!eventType) {
|
|
340
340
|
console.warn(
|
|
341
|
-
` [${import_path2.default.relative(
|
|
341
|
+
` [${import_path2.default.relative(getCwd(), configArg.getSourceFile().getFilePath())}] Could not resolve root 'type' from defineConfig \u2014 skipping auditHistoryLabel id generation`
|
|
342
342
|
);
|
|
343
343
|
}
|
|
344
344
|
let fileNeedsImports = false;
|
|
@@ -354,7 +354,7 @@ function processFile2(filePath, project) {
|
|
|
354
354
|
fileNeedsImports = true;
|
|
355
355
|
configHadValidateAction = true;
|
|
356
356
|
console.log(
|
|
357
|
-
` [${import_path2.default.relative(
|
|
357
|
+
` [${import_path2.default.relative(getCwd(), filePath)}] Transformed VALIDATE action to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'`
|
|
358
358
|
);
|
|
359
359
|
}
|
|
360
360
|
}
|
|
@@ -375,7 +375,7 @@ function processFile2(filePath, project) {
|
|
|
375
375
|
]`
|
|
376
376
|
});
|
|
377
377
|
console.log(
|
|
378
|
-
` [${import_path2.default.relative(
|
|
378
|
+
` [${import_path2.default.relative(getCwd(), filePath)}] Added top-level 'flags' array to defineConfig`
|
|
379
379
|
);
|
|
380
380
|
}
|
|
381
381
|
if (fileNeedsImports) {
|
|
@@ -385,7 +385,7 @@ function processFile2(filePath, project) {
|
|
|
385
385
|
return transformedCount;
|
|
386
386
|
}
|
|
387
387
|
async function main2() {
|
|
388
|
-
const srcDir = import_path2.default.join(
|
|
388
|
+
const srcDir = import_path2.default.join(getCwd(), "src");
|
|
389
389
|
console.log(`Scanning for defineConfig calls in: ${srcDir}
|
|
390
390
|
`);
|
|
391
391
|
const project = new import_ts_morph2.Project({
|
|
@@ -420,7 +420,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
420
420
|
for (const filePath of modifiedFiles) {
|
|
421
421
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
422
422
|
await sourceFile.save();
|
|
423
|
-
console.log(` Saved: ${import_path2.default.relative(
|
|
423
|
+
console.log(` Saved: ${import_path2.default.relative(getCwd(), filePath)}`);
|
|
424
424
|
}
|
|
425
425
|
console.log(
|
|
426
426
|
`
|
|
@@ -491,14 +491,14 @@ function processFile3(filePath, project) {
|
|
|
491
491
|
actionsInitializer.removeElement(index);
|
|
492
492
|
removedCount++;
|
|
493
493
|
console.log(
|
|
494
|
-
` [${import_path3.default.relative(
|
|
494
|
+
` [${import_path3.default.relative(getCwd(), filePath)}] Removed DELETE action at index ${index}`
|
|
495
495
|
);
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
return removedCount;
|
|
499
499
|
}
|
|
500
500
|
async function main3() {
|
|
501
|
-
const srcDir = import_path3.default.join(
|
|
501
|
+
const srcDir = import_path3.default.join(getCwd(), "src");
|
|
502
502
|
console.log(`Scanning for defineConfig calls in: ${srcDir}
|
|
503
503
|
`);
|
|
504
504
|
const project = new import_ts_morph3.Project({
|
|
@@ -533,7 +533,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
533
533
|
for (const filePath of modifiedFiles) {
|
|
534
534
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
535
535
|
await sourceFile.save();
|
|
536
|
-
console.log(` Saved: ${import_path3.default.relative(
|
|
536
|
+
console.log(` Saved: ${import_path3.default.relative(getCwd(), filePath)}`);
|
|
537
537
|
}
|
|
538
538
|
console.log(
|
|
539
539
|
`
|
|
@@ -607,19 +607,19 @@ function processFile4(filePath, project) {
|
|
|
607
607
|
if (result === "converted-to-heading") {
|
|
608
608
|
changedCount++;
|
|
609
609
|
console.log(
|
|
610
|
-
` [${import_path4.default.relative(
|
|
610
|
+
` [${import_path4.default.relative(getCwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`
|
|
611
611
|
);
|
|
612
612
|
} else if (result === "removed-font-variant") {
|
|
613
613
|
changedCount++;
|
|
614
614
|
console.log(
|
|
615
|
-
` [${import_path4.default.relative(
|
|
615
|
+
` [${import_path4.default.relative(getCwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`
|
|
616
616
|
);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
return changedCount;
|
|
620
620
|
}
|
|
621
621
|
async function main4() {
|
|
622
|
-
const srcDir = import_path4.default.join(
|
|
622
|
+
const srcDir = import_path4.default.join(getCwd(), "src");
|
|
623
623
|
console.log(`Scanning for FieldType.PARAGRAPH fields in: ${srcDir}
|
|
624
624
|
`);
|
|
625
625
|
const project = new import_ts_morph4.Project({
|
|
@@ -653,7 +653,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
653
653
|
for (const filePath of modifiedFiles) {
|
|
654
654
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
655
655
|
await sourceFile.save();
|
|
656
|
-
console.log(` Saved: ${import_path4.default.relative(
|
|
656
|
+
console.log(` Saved: ${import_path4.default.relative(getCwd(), filePath)}`);
|
|
657
657
|
}
|
|
658
658
|
console.log(`
|
|
659
659
|
Done. Processed ${totalChanged} FieldType.PARAGRAPH field(s).`);
|
|
@@ -803,7 +803,7 @@ function processFile5(filePath, project) {
|
|
|
803
803
|
if (changed > 0) {
|
|
804
804
|
migratedCount += changed;
|
|
805
805
|
console.log(
|
|
806
|
-
` [${import_path5.default.relative(
|
|
806
|
+
` [${import_path5.default.relative(getCwd(), filePath)}] Migrated ${changed} clause(s): VALIDATED status \u2192 flags.anyOf`
|
|
807
807
|
);
|
|
808
808
|
}
|
|
809
809
|
}
|
|
@@ -811,7 +811,7 @@ function processFile5(filePath, project) {
|
|
|
811
811
|
return migratedCount;
|
|
812
812
|
}
|
|
813
813
|
async function main5() {
|
|
814
|
-
const srcDir = import_path5.default.join(
|
|
814
|
+
const srcDir = import_path5.default.join(getCwd(), "src");
|
|
815
815
|
console.log(`Scanning for defineWorkqueues calls in: ${srcDir}
|
|
816
816
|
`);
|
|
817
817
|
const project = new import_ts_morph5.Project({
|
|
@@ -845,7 +845,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
845
845
|
for (const filePath of modifiedFiles) {
|
|
846
846
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
847
847
|
await sourceFile.save();
|
|
848
|
-
console.log(` Saved: ${import_path5.default.relative(
|
|
848
|
+
console.log(` Saved: ${import_path5.default.relative(getCwd(), filePath)}`);
|
|
849
849
|
}
|
|
850
850
|
console.log(
|
|
851
851
|
`
|
|
@@ -1063,7 +1063,7 @@ function processFile6(filePath, project) {
|
|
|
1063
1063
|
const sourceFile = project.getSourceFile(filePath);
|
|
1064
1064
|
if (!sourceFile) return 0;
|
|
1065
1065
|
let totalChanges = 0;
|
|
1066
|
-
const relPath = import_path6.default.relative(
|
|
1066
|
+
const relPath = import_path6.default.relative(getCwd(), filePath);
|
|
1067
1067
|
const callExpressions = sourceFile.getDescendantsOfKind(
|
|
1068
1068
|
import_ts_morph6.SyntaxKind.CallExpression
|
|
1069
1069
|
);
|
|
@@ -1104,7 +1104,7 @@ function processFile6(filePath, project) {
|
|
|
1104
1104
|
return totalChanges;
|
|
1105
1105
|
}
|
|
1106
1106
|
async function main6() {
|
|
1107
|
-
const srcDir = import_path6.default.join(
|
|
1107
|
+
const srcDir = import_path6.default.join(getCwd(), "src");
|
|
1108
1108
|
console.log(
|
|
1109
1109
|
`Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}
|
|
1110
1110
|
`
|
|
@@ -1140,7 +1140,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
1140
1140
|
for (const filePath of modifiedFiles) {
|
|
1141
1141
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
1142
1142
|
await sourceFile.save();
|
|
1143
|
-
console.log(` Saved: ${import_path6.default.relative(
|
|
1143
|
+
console.log(` Saved: ${import_path6.default.relative(getCwd(), filePath)}`);
|
|
1144
1144
|
}
|
|
1145
1145
|
console.log(
|
|
1146
1146
|
`
|
|
@@ -1177,14 +1177,14 @@ function processFile7(filePath, project) {
|
|
|
1177
1177
|
array3.removeElement(index);
|
|
1178
1178
|
removedCount++;
|
|
1179
1179
|
console.log(
|
|
1180
|
-
` [${import_path7.default.relative(
|
|
1180
|
+
` [${import_path7.default.relative(getCwd(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`
|
|
1181
1181
|
);
|
|
1182
1182
|
}
|
|
1183
1183
|
}
|
|
1184
1184
|
return removedCount;
|
|
1185
1185
|
}
|
|
1186
1186
|
async function main7() {
|
|
1187
|
-
const srcDir = import_path7.default.join(
|
|
1187
|
+
const srcDir = import_path7.default.join(getCwd(), "src");
|
|
1188
1188
|
console.log(
|
|
1189
1189
|
`Scanning for InherentFlags.PENDING_CERTIFICATION array elements in: ${srcDir}
|
|
1190
1190
|
`
|
|
@@ -1220,7 +1220,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
1220
1220
|
for (const filePath of modifiedFiles) {
|
|
1221
1221
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
1222
1222
|
await sourceFile.save();
|
|
1223
|
-
console.log(` Saved: ${import_path7.default.relative(
|
|
1223
|
+
console.log(` Saved: ${import_path7.default.relative(getCwd(), filePath)}`);
|
|
1224
1224
|
}
|
|
1225
1225
|
console.log(
|
|
1226
1226
|
`
|
|
@@ -1278,13 +1278,13 @@ function processFile8(filePath, project) {
|
|
|
1278
1278
|
propAccess.getNameNode().replaceWithText(NEW_PROPERTY_NAME);
|
|
1279
1279
|
renamedCount++;
|
|
1280
1280
|
console.log(
|
|
1281
|
-
` [${import_path8.default.relative(
|
|
1281
|
+
` [${import_path8.default.relative(getCwd(), filePath)}] Renamed Location.${OLD_PROPERTY_NAME} \u2192 Location.${NEW_PROPERTY_NAME}`
|
|
1282
1282
|
);
|
|
1283
1283
|
}
|
|
1284
1284
|
return renamedCount;
|
|
1285
1285
|
}
|
|
1286
1286
|
async function main8() {
|
|
1287
|
-
const srcDir = import_path8.default.join(
|
|
1287
|
+
const srcDir = import_path8.default.join(getCwd(), "src");
|
|
1288
1288
|
console.log(
|
|
1289
1289
|
`Scanning for Location.${OLD_PROPERTY_NAME} references in: ${srcDir}
|
|
1290
1290
|
`
|
|
@@ -1320,7 +1320,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
1320
1320
|
for (const filePath of modifiedFiles) {
|
|
1321
1321
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
1322
1322
|
await sourceFile.save();
|
|
1323
|
-
console.log(` Saved: ${import_path8.default.relative(
|
|
1323
|
+
console.log(` Saved: ${import_path8.default.relative(getCwd(), filePath)}`);
|
|
1324
1324
|
}
|
|
1325
1325
|
console.log(
|
|
1326
1326
|
`
|
|
@@ -1387,7 +1387,7 @@ function processFile9(filePath, project) {
|
|
|
1387
1387
|
const sourceFile = project.getSourceFile(filePath);
|
|
1388
1388
|
if (!sourceFile) return 0;
|
|
1389
1389
|
let renamedCount = 0;
|
|
1390
|
-
const relPath = import_path9.default.relative(
|
|
1390
|
+
const relPath = import_path9.default.relative(getCwd(), filePath);
|
|
1391
1391
|
const candidates = sourceFile.getDescendantsOfKind(
|
|
1392
1392
|
import_ts_morph9.SyntaxKind.ObjectLiteralExpression
|
|
1393
1393
|
);
|
|
@@ -1402,7 +1402,7 @@ function processFile9(filePath, project) {
|
|
|
1402
1402
|
return renamedCount;
|
|
1403
1403
|
}
|
|
1404
1404
|
async function main9() {
|
|
1405
|
-
const srcDir = import_path9.default.join(
|
|
1405
|
+
const srcDir = import_path9.default.join(getCwd(), "src");
|
|
1406
1406
|
console.log(`Scanning for Hapi route configs in: ${srcDir}
|
|
1407
1407
|
`);
|
|
1408
1408
|
console.log("Active path renames:");
|
|
@@ -1439,7 +1439,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
1439
1439
|
for (const filePath of modifiedFiles) {
|
|
1440
1440
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
1441
1441
|
await sourceFile.save();
|
|
1442
|
-
console.log(` Saved: ${import_path9.default.relative(
|
|
1442
|
+
console.log(` Saved: ${import_path9.default.relative(getCwd(), filePath)}`);
|
|
1443
1443
|
}
|
|
1444
1444
|
console.log(`
|
|
1445
1445
|
Done. Renamed ${totalRenamed} route path(s).`);
|
|
@@ -1813,9 +1813,9 @@ function updateRouteHandlers(sourceFiles, group, srcDir, relCwd) {
|
|
|
1813
1813
|
}
|
|
1814
1814
|
return replacedCount;
|
|
1815
1815
|
}
|
|
1816
|
-
function resolveConfigChain(configObj,
|
|
1816
|
+
function resolveConfigChain(configObj, path17) {
|
|
1817
1817
|
let current = configObj;
|
|
1818
|
-
for (const key of
|
|
1818
|
+
for (const key of path17) {
|
|
1819
1819
|
if (!import_ts_morph10.Node.isObjectLiteralExpression(current)) return null;
|
|
1820
1820
|
const prop = current.getProperty(key);
|
|
1821
1821
|
if (!prop || !import_ts_morph10.Node.isPropertyAssignment(prop)) return null;
|
|
@@ -1860,8 +1860,8 @@ function ensureJoinImport(sf) {
|
|
|
1860
1860
|
});
|
|
1861
1861
|
}
|
|
1862
1862
|
async function main10() {
|
|
1863
|
-
const srcDir = import_path10.default.join(
|
|
1864
|
-
const relCwd = (fp) => import_path10.default.relative(
|
|
1863
|
+
const srcDir = import_path10.default.join(getCwd(), "src");
|
|
1864
|
+
const relCwd = (fp) => import_path10.default.relative(getCwd(), fp);
|
|
1865
1865
|
console.log("Phase 1: Converting JS config files to TypeScript...\n");
|
|
1866
1866
|
let convertedCount = 0;
|
|
1867
1867
|
for (const group of CONFIG_GROUPS) {
|
|
@@ -1949,7 +1949,7 @@ async function main10() {
|
|
|
1949
1949
|
ensureJoinImport(sf);
|
|
1950
1950
|
}
|
|
1951
1951
|
console.log(
|
|
1952
|
-
` Inlined applicationConfig.${accessPath.join(".")} \u2192 ${adjustedValue} in ${import_path10.default.relative(
|
|
1952
|
+
` Inlined applicationConfig.${accessPath.join(".")} \u2192 ${adjustedValue} in ${import_path10.default.relative(getCwd(), sf.getFilePath())}`
|
|
1953
1953
|
);
|
|
1954
1954
|
filesToSaveAfterInlining.add(sf);
|
|
1955
1955
|
madeReplacement = true;
|
|
@@ -1961,7 +1961,7 @@ async function main10() {
|
|
|
1961
1961
|
for (const sf of Array.from(filesToSaveAfterInlining)) {
|
|
1962
1962
|
await sf.save();
|
|
1963
1963
|
console.log(
|
|
1964
|
-
` Saved (inlined): ${import_path10.default.relative(
|
|
1964
|
+
` Saved (inlined): ${import_path10.default.relative(getCwd(), sf.getFilePath())}`
|
|
1965
1965
|
);
|
|
1966
1966
|
}
|
|
1967
1967
|
for (const prop of [...propsToRemove].reverse()) {
|
|
@@ -2110,10 +2110,6 @@ var scopeByEvent = z3.preprocess(
|
|
|
2110
2110
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2111
2111
|
z3.array(z3.string()).optional()
|
|
2112
2112
|
).describe("Event type, e.g. birth, death");
|
|
2113
|
-
var userRole = z3.preprocess(
|
|
2114
|
-
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2115
|
-
z3.array(z3.string()).optional()
|
|
2116
|
-
).describe("User role, e.g. admin, field agent");
|
|
2117
2113
|
var scopeOptionsPlaceEvent = z3.object({
|
|
2118
2114
|
event: scopeByEvent,
|
|
2119
2115
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -2137,9 +2133,6 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
2137
2133
|
var AccessLevelOptions = z3.object({
|
|
2138
2134
|
accessLevel: JurisdictionFilter.optional()
|
|
2139
2135
|
});
|
|
2140
|
-
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
2141
|
-
role: userRole.optional()
|
|
2142
|
-
});
|
|
2143
2136
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
2144
2137
|
ids: z3.preprocess(
|
|
2145
2138
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -2149,7 +2142,6 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
2149
2142
|
var AllScopeOptions = z3.object({
|
|
2150
2143
|
...AllRecordScopeOptions.shape,
|
|
2151
2144
|
...AccessLevelOptions.shape,
|
|
2152
|
-
...AllUserScopeOptions.shape,
|
|
2153
2145
|
...WorkqueueOrDashboardOptions.shape
|
|
2154
2146
|
});
|
|
2155
2147
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -2222,30 +2214,6 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2222
2214
|
]).describe(
|
|
2223
2215
|
"Scopes used to check user's permission to perform actions on a record."
|
|
2224
2216
|
);
|
|
2225
|
-
var SystemScopeType = z3.enum([
|
|
2226
|
-
"organisation.read-locations",
|
|
2227
|
-
"user.read",
|
|
2228
|
-
"user.create",
|
|
2229
|
-
"user.edit",
|
|
2230
|
-
"user.search"
|
|
2231
|
-
]);
|
|
2232
|
-
var UserScopeType = SystemScopeType.extract([
|
|
2233
|
-
"user.read",
|
|
2234
|
-
"user.create",
|
|
2235
|
-
"user.edit",
|
|
2236
|
-
"user.search"
|
|
2237
|
-
]);
|
|
2238
|
-
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
2239
|
-
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
2240
|
-
z3.object({
|
|
2241
|
-
type: ScopesWithRoleOption,
|
|
2242
|
-
options: AllUserScopeOptions.optional()
|
|
2243
|
-
}),
|
|
2244
|
-
z3.object({
|
|
2245
|
-
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
2246
|
-
options: AccessLevelOptions.optional()
|
|
2247
|
-
})
|
|
2248
|
-
]);
|
|
2249
2217
|
var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
2250
2218
|
z3.object({
|
|
2251
2219
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -2266,14 +2234,16 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2266
2234
|
}).optional()
|
|
2267
2235
|
})
|
|
2268
2236
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
2237
|
+
var SystemScopeType = z3.enum([
|
|
2238
|
+
"organisation.read-locations",
|
|
2239
|
+
"user.read",
|
|
2240
|
+
"user.create",
|
|
2241
|
+
"user.edit"
|
|
2242
|
+
]);
|
|
2269
2243
|
var Scope2 = z3.discriminatedUnion("type", [
|
|
2270
2244
|
z3.object({ type: PlainScopeType }),
|
|
2271
2245
|
...RecordScopeV2.options,
|
|
2272
|
-
|
|
2273
|
-
z3.object({
|
|
2274
|
-
type: z3.literal("organisation.read-locations"),
|
|
2275
|
-
options: AccessLevelOptions.optional()
|
|
2276
|
-
}),
|
|
2246
|
+
z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
2277
2247
|
z3.object({
|
|
2278
2248
|
type: z3.literal("workqueue"),
|
|
2279
2249
|
options: WorkqueueOrDashboardOptions
|
|
@@ -2608,7 +2578,7 @@ function migrateScopesArrays(rolesFilePath, project) {
|
|
|
2608
2578
|
const scopeKey = resolveScopeKeyFromElementAccess(element);
|
|
2609
2579
|
if (scopeKey && !(scopeKey in SCOPES)) {
|
|
2610
2580
|
console.warn(
|
|
2611
|
-
` [${import_path11.default.relative(
|
|
2581
|
+
` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`
|
|
2612
2582
|
);
|
|
2613
2583
|
initializer.removeElement(index);
|
|
2614
2584
|
removedCount++;
|
|
@@ -2617,7 +2587,7 @@ function migrateScopesArrays(rolesFilePath, project) {
|
|
|
2617
2587
|
const legacyScope = resolveLegacyScopeFromElement(element);
|
|
2618
2588
|
if (!legacyScope) {
|
|
2619
2589
|
console.warn(
|
|
2620
|
-
` [${import_path11.default.relative(
|
|
2590
|
+
` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Skipping non-literal scope expression: ${element.getText()}`
|
|
2621
2591
|
);
|
|
2622
2592
|
continue;
|
|
2623
2593
|
}
|
|
@@ -2626,7 +2596,7 @@ function migrateScopesArrays(rolesFilePath, project) {
|
|
|
2626
2596
|
const scope = decodeScope(migratedScope);
|
|
2627
2597
|
if (!scope) {
|
|
2628
2598
|
console.warn(
|
|
2629
|
-
` [${import_path11.default.relative(
|
|
2599
|
+
` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`
|
|
2630
2600
|
);
|
|
2631
2601
|
continue;
|
|
2632
2602
|
}
|
|
@@ -2634,14 +2604,14 @@ function migrateScopesArrays(rolesFilePath, project) {
|
|
|
2634
2604
|
migratedCount++;
|
|
2635
2605
|
} catch (error) {
|
|
2636
2606
|
console.warn(
|
|
2637
|
-
` [${import_path11.default.relative(
|
|
2607
|
+
` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`
|
|
2638
2608
|
);
|
|
2639
2609
|
}
|
|
2640
2610
|
}
|
|
2641
2611
|
}
|
|
2642
2612
|
if (removedCount > 0) {
|
|
2643
2613
|
console.log(
|
|
2644
|
-
` Removed ${removedCount} unknown SCOPES reference(s) from '${import_path11.default.relative(
|
|
2614
|
+
` Removed ${removedCount} unknown SCOPES reference(s) from '${import_path11.default.relative(getCwd(), rolesFilePath)}'.`
|
|
2645
2615
|
);
|
|
2646
2616
|
}
|
|
2647
2617
|
return { migratedCount, removedCount };
|
|
@@ -2763,9 +2733,9 @@ function removeRoleTypeDefinitionAndUnusedImports(rolesFilePath, project) {
|
|
|
2763
2733
|
return removed;
|
|
2764
2734
|
}
|
|
2765
2735
|
async function main11() {
|
|
2766
|
-
const
|
|
2767
|
-
const srcDir = import_path11.default.join(
|
|
2768
|
-
const rolesFilePath = import_path11.default.join(
|
|
2736
|
+
const cwd2 = getCwd();
|
|
2737
|
+
const srcDir = import_path11.default.join(cwd2, "src");
|
|
2738
|
+
const rolesFilePath = import_path11.default.join(cwd2, ROLES_FILE_RELATIVE_PATH);
|
|
2769
2739
|
console.log(`Scanning roles scopes in: ${rolesFilePath}`);
|
|
2770
2740
|
const project = new import_ts_morph11.Project({
|
|
2771
2741
|
tsConfigFilePath: import_path11.default.resolve(srcDir, "../tsconfig.json"),
|
|
@@ -2829,13 +2799,13 @@ function processFile10(filePath, project) {
|
|
|
2829
2799
|
decl.remove();
|
|
2830
2800
|
}
|
|
2831
2801
|
console.log(
|
|
2832
|
-
` [${import_path12.default.relative(
|
|
2802
|
+
` [${import_path12.default.relative(getCwd(), filePath)}] Removed ${matchingNamedImports.length} deprecated '${DEPRECATED_IMPORT}' import(s) from '${decl.getModuleSpecifierValue()}'`
|
|
2833
2803
|
);
|
|
2834
2804
|
}
|
|
2835
2805
|
return removedCount;
|
|
2836
2806
|
}
|
|
2837
2807
|
async function main12() {
|
|
2838
|
-
const srcDir = import_path12.default.join(
|
|
2808
|
+
const srcDir = import_path12.default.join(getCwd(), "src");
|
|
2839
2809
|
console.log(`Scanning for deprecated imports in: ${srcDir}
|
|
2840
2810
|
`);
|
|
2841
2811
|
const project = new import_ts_morph12.Project({
|
|
@@ -2866,738 +2836,15 @@ async function main12() {
|
|
|
2866
2836
|
Saving ${modifiedFiles.length} modified file(s)...`);
|
|
2867
2837
|
for (const filePath of modifiedFiles) {
|
|
2868
2838
|
await project.getSourceFileOrThrow(filePath).save();
|
|
2869
|
-
console.log(` Saved: ${import_path12.default.relative(
|
|
2839
|
+
console.log(` Saved: ${import_path12.default.relative(getCwd(), filePath)}`);
|
|
2870
2840
|
}
|
|
2871
2841
|
console.log(`
|
|
2872
2842
|
Done. Removed ${totalRemoved} deprecated import(s).`);
|
|
2873
2843
|
}
|
|
2874
2844
|
|
|
2875
|
-
// src/migrations/v2.0/remove-unused-environment-variables.ts
|
|
2876
|
-
var import_path13 = __toESM(require("path"));
|
|
2877
|
-
var import_ts_morph13 = require("ts-morph");
|
|
2878
|
-
var UNUSED_ENV_VARS = /* @__PURE__ */ new Set([
|
|
2879
|
-
"APPLICATION_CONFIG_URL",
|
|
2880
|
-
"FHIR_URL",
|
|
2881
|
-
"CONFIRM_REGISTRATION_URL"
|
|
2882
|
-
]);
|
|
2883
|
-
var ENVIRONMENT_FILE_RELATIVE = "src/environment.ts";
|
|
2884
|
-
var CONSTANTS_FILE_RELATIVE = "src/constants.ts";
|
|
2885
|
-
function cleanEnvironmentFile(project, filePath) {
|
|
2886
|
-
const sourceFile = project.getSourceFile(filePath);
|
|
2887
|
-
if (!sourceFile) return [];
|
|
2888
|
-
const removed = [];
|
|
2889
|
-
const cleanEnvCall = sourceFile.getDescendantsOfKind(import_ts_morph13.SyntaxKind.CallExpression).find((call) => {
|
|
2890
|
-
const expr = call.getExpression();
|
|
2891
|
-
return import_ts_morph13.Node.isIdentifier(expr) && expr.getText() === "cleanEnv";
|
|
2892
|
-
});
|
|
2893
|
-
if (!cleanEnvCall) return removed;
|
|
2894
|
-
const schemaArg = cleanEnvCall.getArguments()[1]?.asKind(import_ts_morph13.SyntaxKind.ObjectLiteralExpression);
|
|
2895
|
-
if (!schemaArg) return removed;
|
|
2896
|
-
for (const name of UNUSED_ENV_VARS) {
|
|
2897
|
-
const prop = schemaArg.getProperty(name);
|
|
2898
|
-
if (!prop) continue;
|
|
2899
|
-
if (prop.isKind(import_ts_morph13.SyntaxKind.PropertyAssignment) || prop.isKind(import_ts_morph13.SyntaxKind.ShorthandPropertyAssignment)) {
|
|
2900
|
-
prop.remove();
|
|
2901
|
-
removed.push(name);
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
return removed;
|
|
2905
|
-
}
|
|
2906
|
-
function extractEnvAccess(initText) {
|
|
2907
|
-
if (!initText) return null;
|
|
2908
|
-
const match = /\benv\.([A-Z][A-Z0-9_]*)\b/.exec(initText);
|
|
2909
|
-
return match ? match[1] : null;
|
|
2910
|
-
}
|
|
2911
|
-
function cleanConstantsFile(project, filePath) {
|
|
2912
|
-
const sourceFile = project.getSourceFile(filePath);
|
|
2913
|
-
if (!sourceFile) return [];
|
|
2914
|
-
const removed = [];
|
|
2915
|
-
for (const stmt of [...sourceFile.getVariableStatements()]) {
|
|
2916
|
-
const declarations = [...stmt.getDeclarations()];
|
|
2917
|
-
const declarationsToRemove = declarations.filter((decl) => {
|
|
2918
|
-
const name = decl.getName();
|
|
2919
|
-
const accessedEnvVar = extractEnvAccess(decl.getInitializer()?.getText());
|
|
2920
|
-
return UNUSED_ENV_VARS.has(name) || accessedEnvVar !== null && UNUSED_ENV_VARS.has(accessedEnvVar);
|
|
2921
|
-
});
|
|
2922
|
-
if (declarationsToRemove.length === 0) continue;
|
|
2923
|
-
const namesToRemove = declarationsToRemove.map((decl) => decl.getName());
|
|
2924
|
-
removed.push(...namesToRemove);
|
|
2925
|
-
if (declarationsToRemove.length === declarations.length) {
|
|
2926
|
-
stmt.remove();
|
|
2927
|
-
} else {
|
|
2928
|
-
for (const decl of declarationsToRemove) {
|
|
2929
|
-
decl.remove();
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2932
|
-
}
|
|
2933
|
-
return removed;
|
|
2934
|
-
}
|
|
2935
|
-
async function main13() {
|
|
2936
|
-
const project = new import_ts_morph13.Project({
|
|
2937
|
-
tsConfigFilePath: import_path13.default.resolve(process.cwd(), "tsconfig.json"),
|
|
2938
|
-
skipAddingFilesFromTsConfig: false
|
|
2939
|
-
});
|
|
2940
|
-
console.log(
|
|
2941
|
-
`Removing unused environment variable(s) (${[...UNUSED_ENV_VARS].join(", ")})...
|
|
2942
|
-
`
|
|
2943
|
-
);
|
|
2944
|
-
const envFilePath = import_path13.default.join(process.cwd(), ENVIRONMENT_FILE_RELATIVE);
|
|
2945
|
-
const constsFilePath = import_path13.default.join(process.cwd(), CONSTANTS_FILE_RELATIVE);
|
|
2946
|
-
const envRemoved = cleanEnvironmentFile(project, envFilePath);
|
|
2947
|
-
if (envRemoved.length > 0) {
|
|
2948
|
-
await project.getSourceFileOrThrow(envFilePath).save();
|
|
2949
|
-
console.log(
|
|
2950
|
-
` [${ENVIRONMENT_FILE_RELATIVE}] Removed schema entr${envRemoved.length === 1 ? "y" : "ies"}: ${envRemoved.join(", ")}`
|
|
2951
|
-
);
|
|
2952
|
-
} else if (project.getSourceFile(envFilePath)) {
|
|
2953
|
-
console.log(
|
|
2954
|
-
` [${ENVIRONMENT_FILE_RELATIVE}] No matching schema entries \u2014 nothing to remove.`
|
|
2955
|
-
);
|
|
2956
|
-
} else {
|
|
2957
|
-
console.log(
|
|
2958
|
-
` [${ENVIRONMENT_FILE_RELATIVE}] File not found \u2014 skipping.`
|
|
2959
|
-
);
|
|
2960
|
-
}
|
|
2961
|
-
const constsRemoved = cleanConstantsFile(project, constsFilePath);
|
|
2962
|
-
if (constsRemoved.length > 0) {
|
|
2963
|
-
await project.getSourceFileOrThrow(constsFilePath).save();
|
|
2964
|
-
console.log(
|
|
2965
|
-
` [${CONSTANTS_FILE_RELATIVE}] Removed declaration(s): ${constsRemoved.join(", ")}`
|
|
2966
|
-
);
|
|
2967
|
-
} else if (project.getSourceFile(constsFilePath)) {
|
|
2968
|
-
console.log(
|
|
2969
|
-
` [${CONSTANTS_FILE_RELATIVE}] No matching declarations \u2014 nothing to remove.`
|
|
2970
|
-
);
|
|
2971
|
-
} else {
|
|
2972
|
-
console.log(` [${CONSTANTS_FILE_RELATIVE}] File not found \u2014 skipping.`);
|
|
2973
|
-
}
|
|
2974
|
-
if (envRemoved.length === 0 && constsRemoved.length === 0) {
|
|
2975
|
-
console.log("\nNothing to do.");
|
|
2976
|
-
return;
|
|
2977
|
-
}
|
|
2978
|
-
console.log(
|
|
2979
|
-
`
|
|
2980
|
-
Done. NOTE: usages of these constants elsewhere in 'src/' may now produce TypeScript errors and need manual review.`
|
|
2981
|
-
);
|
|
2982
|
-
}
|
|
2983
|
-
|
|
2984
|
-
// src/migrations/v2.0/remove-fhir-url-helpers.ts
|
|
2985
|
-
var import_path14 = __toESM(require("path"));
|
|
2986
|
-
var import_ts_morph14 = require("ts-morph");
|
|
2987
|
-
var FHIR_IMPORT = "FHIR_URL";
|
|
2988
|
-
var HELPER_NAMES = /* @__PURE__ */ new Set([
|
|
2989
|
-
"getFromFhir",
|
|
2990
|
-
"updateResourceFromHearth",
|
|
2991
|
-
"updateResourceInHearth"
|
|
2992
|
-
]);
|
|
2993
|
-
function removeHelpers(sourceFilePath, project) {
|
|
2994
|
-
const sourceFile = project.getSourceFile(sourceFilePath);
|
|
2995
|
-
if (!sourceFile) {
|
|
2996
|
-
return {
|
|
2997
|
-
removedHelpers: [],
|
|
2998
|
-
removedImportCount: 0,
|
|
2999
|
-
remainingFhirReferences: 0
|
|
3000
|
-
};
|
|
3001
|
-
}
|
|
3002
|
-
const removedHelpers = [];
|
|
3003
|
-
let removedImportCount = 0;
|
|
3004
|
-
for (const fn of sourceFile.getFunctions()) {
|
|
3005
|
-
const name = fn.getName();
|
|
3006
|
-
if (!name || !HELPER_NAMES.has(name)) continue;
|
|
3007
|
-
removedHelpers.push(name);
|
|
3008
|
-
fn.remove();
|
|
3009
|
-
}
|
|
3010
|
-
for (const stmt of [...sourceFile.getVariableStatements()]) {
|
|
3011
|
-
const declarations = [...stmt.getDeclarations()];
|
|
3012
|
-
const toRemove = declarations.filter((decl) => HELPER_NAMES.has(decl.getName()));
|
|
3013
|
-
if (toRemove.length === 0) continue;
|
|
3014
|
-
removedHelpers.push(...toRemove.map((decl) => decl.getName()));
|
|
3015
|
-
if (toRemove.length === declarations.length) {
|
|
3016
|
-
stmt.remove();
|
|
3017
|
-
} else {
|
|
3018
|
-
for (const decl of toRemove) decl.remove();
|
|
3019
|
-
}
|
|
3020
|
-
}
|
|
3021
|
-
for (const decl of sourceFile.getImportDeclarations()) {
|
|
3022
|
-
const matches = decl.getNamedImports().filter((ni) => ni.getName() === FHIR_IMPORT);
|
|
3023
|
-
if (matches.length === 0) continue;
|
|
3024
|
-
for (const named of matches) {
|
|
3025
|
-
named.remove();
|
|
3026
|
-
removedImportCount++;
|
|
3027
|
-
}
|
|
3028
|
-
const hasAnyNamedImportsLeft = decl.getNamedImports().length > 0;
|
|
3029
|
-
const hasDefaultImport = !!decl.getDefaultImport();
|
|
3030
|
-
const hasNamespaceImport = !!decl.getNamespaceImport();
|
|
3031
|
-
if (!hasAnyNamedImportsLeft && !hasDefaultImport && !hasNamespaceImport) {
|
|
3032
|
-
decl.remove();
|
|
3033
|
-
}
|
|
3034
|
-
}
|
|
3035
|
-
const remainingFhirReferences = sourceFile.getDescendantsOfKind(import_ts_morph14.SyntaxKind.Identifier).filter((id) => id.getText() === FHIR_IMPORT).filter((id) => !id.getFirstAncestorByKind(import_ts_morph14.SyntaxKind.ImportDeclaration)).length;
|
|
3036
|
-
return { removedHelpers, removedImportCount, remainingFhirReferences };
|
|
3037
|
-
}
|
|
3038
|
-
async function main14() {
|
|
3039
|
-
const project = new import_ts_morph14.Project({
|
|
3040
|
-
tsConfigFilePath: import_path14.default.resolve(process.cwd(), "tsconfig.json"),
|
|
3041
|
-
skipAddingFilesFromTsConfig: false
|
|
3042
|
-
});
|
|
3043
|
-
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
3044
|
-
const fp = sf.getFilePath();
|
|
3045
|
-
return fp.includes("/src/") && !fp.includes("/node_modules/");
|
|
3046
|
-
});
|
|
3047
|
-
console.log(`Removing legacy FHIR_URL helpers in ${sourceFiles.length} source file(s)...
|
|
3048
|
-
`);
|
|
3049
|
-
let totalRemovedImports = 0;
|
|
3050
|
-
let totalRemovedHelpers = 0;
|
|
3051
|
-
const modifiedFiles = [];
|
|
3052
|
-
const warnings = [];
|
|
3053
|
-
for (const sourceFile of sourceFiles) {
|
|
3054
|
-
const filePath = sourceFile.getFilePath();
|
|
3055
|
-
const rel = import_path14.default.relative(process.cwd(), filePath);
|
|
3056
|
-
const result = removeHelpers(filePath, project);
|
|
3057
|
-
const changed = result.removedImportCount > 0 || result.removedHelpers.length > 0;
|
|
3058
|
-
if (changed) {
|
|
3059
|
-
modifiedFiles.push(filePath);
|
|
3060
|
-
totalRemovedImports += result.removedImportCount;
|
|
3061
|
-
totalRemovedHelpers += result.removedHelpers.length;
|
|
3062
|
-
if (result.removedHelpers.length > 0) {
|
|
3063
|
-
console.log(
|
|
3064
|
-
` [${rel}] Removed helper(s): ${result.removedHelpers.join(", ")}`
|
|
3065
|
-
);
|
|
3066
|
-
}
|
|
3067
|
-
if (result.removedImportCount > 0) {
|
|
3068
|
-
console.log(
|
|
3069
|
-
` [${rel}] Removed ${result.removedImportCount} '${FHIR_IMPORT}' import(s)`
|
|
3070
|
-
);
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
if (result.remainingFhirReferences > 0) {
|
|
3074
|
-
warnings.push(
|
|
3075
|
-
`${rel}: ${result.remainingFhirReferences} remaining '${FHIR_IMPORT}' reference(s)`
|
|
3076
|
-
);
|
|
3077
|
-
}
|
|
3078
|
-
}
|
|
3079
|
-
if (modifiedFiles.length === 0 && warnings.length === 0) {
|
|
3080
|
-
console.log("No FHIR_URL imports/helpers found. Nothing to do.");
|
|
3081
|
-
return;
|
|
3082
|
-
}
|
|
3083
|
-
if (modifiedFiles.length > 0) {
|
|
3084
|
-
console.log(`
|
|
3085
|
-
Saving ${modifiedFiles.length} modified file(s)...`);
|
|
3086
|
-
for (const filePath of modifiedFiles) {
|
|
3087
|
-
await project.getSourceFileOrThrow(filePath).save();
|
|
3088
|
-
console.log(` Saved: ${import_path14.default.relative(process.cwd(), filePath)}`);
|
|
3089
|
-
}
|
|
3090
|
-
}
|
|
3091
|
-
if (warnings.length > 0) {
|
|
3092
|
-
console.warn(
|
|
3093
|
-
`
|
|
3094
|
-
WARNING: Some '${FHIR_IMPORT}' usages remain and need manual cleanup:
|
|
3095
|
-
` + warnings.map((line) => ` - ${line}`).join("\n")
|
|
3096
|
-
);
|
|
3097
|
-
}
|
|
3098
|
-
console.log(
|
|
3099
|
-
`
|
|
3100
|
-
Done. Removed ${totalRemovedHelpers} helper declaration(s) and ${totalRemovedImports} '${FHIR_IMPORT}' import(s).`
|
|
3101
|
-
);
|
|
3102
|
-
}
|
|
3103
|
-
|
|
3104
|
-
// src/migrations/v2.0/migrate-application-config-url.ts
|
|
3105
|
-
var import_path15 = __toESM(require("path"));
|
|
3106
|
-
var import_ts_morph15 = require("ts-morph");
|
|
3107
|
-
var TARGET_IDENTIFIER = "APPLICATION_CONFIG_URL";
|
|
3108
|
-
var REPLACEMENT_IDENTIFIER = "applicationConfig";
|
|
3109
|
-
var REPLACEMENT_MODULE = "@countryconfig/api/application/application-config";
|
|
3110
|
-
var FUNCTION_LIKE_KINDS = [
|
|
3111
|
-
import_ts_morph15.SyntaxKind.FunctionDeclaration,
|
|
3112
|
-
import_ts_morph15.SyntaxKind.FunctionExpression,
|
|
3113
|
-
import_ts_morph15.SyntaxKind.ArrowFunction,
|
|
3114
|
-
import_ts_morph15.SyntaxKind.MethodDeclaration
|
|
3115
|
-
];
|
|
3116
|
-
function describeFunction(node) {
|
|
3117
|
-
if (import_ts_morph15.Node.isFunctionDeclaration(node) || import_ts_morph15.Node.isMethodDeclaration(node)) {
|
|
3118
|
-
return node.getName() ?? "<anonymous>";
|
|
3119
|
-
}
|
|
3120
|
-
const parent = node.getParent();
|
|
3121
|
-
if (parent && import_ts_morph15.Node.isVariableDeclaration(parent)) {
|
|
3122
|
-
return parent.getName();
|
|
3123
|
-
}
|
|
3124
|
-
if (parent && import_ts_morph15.Node.isPropertyAssignment(parent)) {
|
|
3125
|
-
return parent.getName();
|
|
3126
|
-
}
|
|
3127
|
-
if (import_ts_morph15.Node.isFunctionExpression(node) && node.getNameNode() !== void 0) {
|
|
3128
|
-
return node.getNameNode()?.getText() ?? "<anonymous>";
|
|
3129
|
-
}
|
|
3130
|
-
return "<anonymous>";
|
|
3131
|
-
}
|
|
3132
|
-
function hasBlockBody(node) {
|
|
3133
|
-
if (import_ts_morph15.Node.isFunctionDeclaration(node) || import_ts_morph15.Node.isFunctionExpression(node) || import_ts_morph15.Node.isMethodDeclaration(node)) {
|
|
3134
|
-
return node.getBody() !== void 0;
|
|
3135
|
-
}
|
|
3136
|
-
if (import_ts_morph15.Node.isArrowFunction(node)) {
|
|
3137
|
-
return node.getBody().getKind() === import_ts_morph15.SyntaxKind.Block;
|
|
3138
|
-
}
|
|
3139
|
-
return false;
|
|
3140
|
-
}
|
|
3141
|
-
function isConfigFetcher(node) {
|
|
3142
|
-
let referencesTarget = false;
|
|
3143
|
-
let callsFetch = false;
|
|
3144
|
-
for (const id of node.getDescendantsOfKind(import_ts_morph15.SyntaxKind.Identifier)) {
|
|
3145
|
-
const text = id.getText();
|
|
3146
|
-
if (!referencesTarget && text === TARGET_IDENTIFIER) referencesTarget = true;
|
|
3147
|
-
if (!callsFetch && text === "fetch") {
|
|
3148
|
-
const parent = id.getParent();
|
|
3149
|
-
if (import_ts_morph15.Node.isCallExpression(parent) && parent.getExpression() === id) {
|
|
3150
|
-
callsFetch = true;
|
|
3151
|
-
}
|
|
3152
|
-
}
|
|
3153
|
-
if (referencesTarget && callsFetch) return true;
|
|
3154
|
-
}
|
|
3155
|
-
return false;
|
|
3156
|
-
}
|
|
3157
|
-
function processFile11(sourceFile) {
|
|
3158
|
-
const importsWithTarget = sourceFile.getImportDeclarations().filter(
|
|
3159
|
-
(decl) => decl.getNamedImports().some((ni) => ni.getName() === TARGET_IDENTIFIER)
|
|
3160
|
-
);
|
|
3161
|
-
if (importsWithTarget.length === 0) {
|
|
3162
|
-
return { changed: false, rewrittenFunctions: [], renamedReferences: 0 };
|
|
3163
|
-
}
|
|
3164
|
-
const collidingLocals = sourceFile.getDescendantsOfKind(import_ts_morph15.SyntaxKind.Identifier).filter((id) => id.getText() === REPLACEMENT_IDENTIFIER).filter((id) => {
|
|
3165
|
-
const parent = id.getParent();
|
|
3166
|
-
const kind = parent.getKind();
|
|
3167
|
-
return kind === import_ts_morph15.SyntaxKind.VariableDeclaration || kind === import_ts_morph15.SyntaxKind.FunctionDeclaration || kind === import_ts_morph15.SyntaxKind.ClassDeclaration || kind === import_ts_morph15.SyntaxKind.Parameter;
|
|
3168
|
-
});
|
|
3169
|
-
if (collidingLocals.length > 0) {
|
|
3170
|
-
return {
|
|
3171
|
-
changed: false,
|
|
3172
|
-
rewrittenFunctions: [],
|
|
3173
|
-
renamedReferences: 0,
|
|
3174
|
-
skippedReason: `local declaration named '${REPLACEMENT_IDENTIFIER}' would collide`
|
|
3175
|
-
};
|
|
3176
|
-
}
|
|
3177
|
-
const candidateFunctions = FUNCTION_LIKE_KINDS.flatMap(
|
|
3178
|
-
(kind) => sourceFile.getDescendantsOfKind(kind)
|
|
3179
|
-
);
|
|
3180
|
-
candidateFunctions.sort((a, b) => a.getStart() - b.getStart());
|
|
3181
|
-
const rewrittenFunctions = [];
|
|
3182
|
-
const rewrittenSet = /* @__PURE__ */ new Set();
|
|
3183
|
-
for (const fn of candidateFunctions) {
|
|
3184
|
-
if (!hasBlockBody(fn)) continue;
|
|
3185
|
-
if (!isConfigFetcher(fn)) continue;
|
|
3186
|
-
let inRewrittenAncestor = false;
|
|
3187
|
-
let cursor = fn.getParent();
|
|
3188
|
-
while (cursor) {
|
|
3189
|
-
if (rewrittenSet.has(cursor)) {
|
|
3190
|
-
inRewrittenAncestor = true;
|
|
3191
|
-
break;
|
|
3192
|
-
}
|
|
3193
|
-
cursor = cursor.getParent();
|
|
3194
|
-
}
|
|
3195
|
-
if (inRewrittenAncestor) continue;
|
|
3196
|
-
const start = fn.getStart();
|
|
3197
|
-
const line = sourceFile.getLineAndColumnAtPos(start).line;
|
|
3198
|
-
const name = describeFunction(fn);
|
|
3199
|
-
if (import_ts_morph15.Node.isFunctionDeclaration(fn) || import_ts_morph15.Node.isFunctionExpression(fn) || import_ts_morph15.Node.isMethodDeclaration(fn) || import_ts_morph15.Node.isArrowFunction(fn)) {
|
|
3200
|
-
fn.setBodyText(`return ${REPLACEMENT_IDENTIFIER}`);
|
|
3201
|
-
}
|
|
3202
|
-
rewrittenFunctions.push({ name, line });
|
|
3203
|
-
rewrittenSet.add(fn);
|
|
3204
|
-
}
|
|
3205
|
-
for (const decl of importsWithTarget) {
|
|
3206
|
-
const targetNamed = decl.getNamedImports().find((ni) => ni.getName() === TARGET_IDENTIFIER);
|
|
3207
|
-
targetNamed?.remove();
|
|
3208
|
-
const isNowEmpty = decl.getNamedImports().length === 0 && !decl.getDefaultImport() && !decl.getNamespaceImport();
|
|
3209
|
-
if (isNowEmpty) decl.remove();
|
|
3210
|
-
}
|
|
3211
|
-
const existing = sourceFile.getImportDeclaration(
|
|
3212
|
-
(decl) => decl.getModuleSpecifierValue() === REPLACEMENT_MODULE
|
|
3213
|
-
);
|
|
3214
|
-
if (existing) {
|
|
3215
|
-
const alreadyImported = existing.getNamedImports().some((ni) => ni.getName() === REPLACEMENT_IDENTIFIER);
|
|
3216
|
-
if (!alreadyImported) existing.addNamedImport(REPLACEMENT_IDENTIFIER);
|
|
3217
|
-
} else {
|
|
3218
|
-
sourceFile.addImportDeclaration({
|
|
3219
|
-
moduleSpecifier: REPLACEMENT_MODULE,
|
|
3220
|
-
namedImports: [REPLACEMENT_IDENTIFIER]
|
|
3221
|
-
});
|
|
3222
|
-
}
|
|
3223
|
-
const renameTargets = sourceFile.getDescendantsOfKind(import_ts_morph15.SyntaxKind.Identifier).filter((id) => id.getText() === TARGET_IDENTIFIER).filter((id) => !id.getFirstAncestorByKind(import_ts_morph15.SyntaxKind.ImportDeclaration)).filter((id) => {
|
|
3224
|
-
const parent = id.getParent();
|
|
3225
|
-
const parentKind = parent.getKind();
|
|
3226
|
-
if (parentKind === import_ts_morph15.SyntaxKind.PropertyAccessExpression) {
|
|
3227
|
-
const pae = parent.asKind(import_ts_morph15.SyntaxKind.PropertyAccessExpression);
|
|
3228
|
-
if (pae.getNameNode() === id) return false;
|
|
3229
|
-
}
|
|
3230
|
-
if (parentKind === import_ts_morph15.SyntaxKind.PropertyAssignment) {
|
|
3231
|
-
const pa = parent.asKind(import_ts_morph15.SyntaxKind.PropertyAssignment);
|
|
3232
|
-
if (pa.getNameNode() === id) return false;
|
|
3233
|
-
}
|
|
3234
|
-
if (parentKind === import_ts_morph15.SyntaxKind.ShorthandPropertyAssignment) {
|
|
3235
|
-
return false;
|
|
3236
|
-
}
|
|
3237
|
-
return true;
|
|
3238
|
-
}).sort((a, b) => b.getPos() - a.getPos());
|
|
3239
|
-
for (const id of renameTargets) {
|
|
3240
|
-
id.replaceWithText(REPLACEMENT_IDENTIFIER);
|
|
3241
|
-
}
|
|
3242
|
-
return {
|
|
3243
|
-
changed: true,
|
|
3244
|
-
rewrittenFunctions,
|
|
3245
|
-
renamedReferences: renameTargets.length
|
|
3246
|
-
};
|
|
3247
|
-
}
|
|
3248
|
-
async function main15() {
|
|
3249
|
-
const project = new import_ts_morph15.Project({
|
|
3250
|
-
tsConfigFilePath: import_path15.default.resolve(process.cwd(), "tsconfig.json"),
|
|
3251
|
-
skipAddingFilesFromTsConfig: false
|
|
3252
|
-
});
|
|
3253
|
-
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
3254
|
-
const fp = sf.getFilePath();
|
|
3255
|
-
return fp.includes("/src/") && !fp.includes("/node_modules/");
|
|
3256
|
-
});
|
|
3257
|
-
console.log(
|
|
3258
|
-
`Migrating '${TARGET_IDENTIFIER}' \u2192 '${REPLACEMENT_IDENTIFIER}' across ${sourceFiles.length} source file(s)...
|
|
3259
|
-
`
|
|
3260
|
-
);
|
|
3261
|
-
let changedFiles = 0;
|
|
3262
|
-
let totalRewrittenFunctions = 0;
|
|
3263
|
-
let totalRenamedReferences = 0;
|
|
3264
|
-
const skipped = [];
|
|
3265
|
-
for (const sourceFile of sourceFiles) {
|
|
3266
|
-
const filePath = sourceFile.getFilePath();
|
|
3267
|
-
const rel = import_path15.default.relative(process.cwd(), filePath);
|
|
3268
|
-
const result = processFile11(sourceFile);
|
|
3269
|
-
if (result.skippedReason) {
|
|
3270
|
-
skipped.push(`${rel} (${result.skippedReason})`);
|
|
3271
|
-
continue;
|
|
3272
|
-
}
|
|
3273
|
-
if (!result.changed) continue;
|
|
3274
|
-
await sourceFile.save();
|
|
3275
|
-
changedFiles++;
|
|
3276
|
-
totalRewrittenFunctions += result.rewrittenFunctions.length;
|
|
3277
|
-
totalRenamedReferences += result.renamedReferences;
|
|
3278
|
-
for (const fn of result.rewrittenFunctions) {
|
|
3279
|
-
console.log(
|
|
3280
|
-
` [${rel}:${fn.line}] Rewrote '${fn.name}' body \u2192 'return ${REPLACEMENT_IDENTIFIER}' (config fetch eliminated)`
|
|
3281
|
-
);
|
|
3282
|
-
}
|
|
3283
|
-
if (result.renamedReferences > 0) {
|
|
3284
|
-
console.log(
|
|
3285
|
-
` [${rel}] Renamed ${result.renamedReferences} stray reference(s) ${TARGET_IDENTIFIER} \u2192 ${REPLACEMENT_IDENTIFIER}`
|
|
3286
|
-
);
|
|
3287
|
-
}
|
|
3288
|
-
}
|
|
3289
|
-
if (skipped.length > 0) {
|
|
3290
|
-
console.warn(
|
|
3291
|
-
`
|
|
3292
|
-
${skipped.length} file(s) skipped:
|
|
3293
|
-
` + skipped.map((s) => ` - ${s}`).join("\n")
|
|
3294
|
-
);
|
|
3295
|
-
}
|
|
3296
|
-
if (changedFiles === 0) {
|
|
3297
|
-
console.log(`
|
|
3298
|
-
No files reference '${TARGET_IDENTIFIER}'. Nothing to do.`);
|
|
3299
|
-
return;
|
|
3300
|
-
}
|
|
3301
|
-
console.log(
|
|
3302
|
-
`
|
|
3303
|
-
Done. Updated ${changedFiles} file(s): ${totalRewrittenFunctions} fetch function(s) rewritten, ${totalRenamedReferences} bare reference(s) renamed.`
|
|
3304
|
-
);
|
|
3305
|
-
if (totalRewrittenFunctions > 0) {
|
|
3306
|
-
console.log(
|
|
3307
|
-
`NOTE: rewriting fetch functions discards any custom logic that lived inside them. Review the diff and re-apply any country-specific adjustments on top of '${REPLACEMENT_IDENTIFIER}'.`
|
|
3308
|
-
);
|
|
3309
|
-
}
|
|
3310
|
-
}
|
|
3311
|
-
|
|
3312
|
-
// src/migrations/v2.0/remove-old-statistics-service.ts
|
|
3313
|
-
var import_path16 = __toESM(require("path"));
|
|
3314
|
-
var import_ts_morph16 = require("ts-morph");
|
|
3315
|
-
var ROUTE_PATH = "/statistics";
|
|
3316
|
-
var HANDLER_NAME = "statisticsHandler";
|
|
3317
|
-
function isStatisticsRouteObject(obj) {
|
|
3318
|
-
const pathProp = obj.getProperty("path");
|
|
3319
|
-
if (!pathProp || !import_ts_morph16.Node.isPropertyAssignment(pathProp)) return false;
|
|
3320
|
-
const init = pathProp.getInitializer();
|
|
3321
|
-
if (!init) return false;
|
|
3322
|
-
if (import_ts_morph16.Node.isStringLiteral(init) || import_ts_morph16.Node.isNoSubstitutionTemplateLiteral(init)) {
|
|
3323
|
-
return init.getLiteralValue() === ROUTE_PATH;
|
|
3324
|
-
}
|
|
3325
|
-
return false;
|
|
3326
|
-
}
|
|
3327
|
-
function removeStatisticsRoutes(sourceFile) {
|
|
3328
|
-
let removed = 0;
|
|
3329
|
-
const callExpressions = [
|
|
3330
|
-
...sourceFile.getDescendantsOfKind(import_ts_morph16.SyntaxKind.CallExpression)
|
|
3331
|
-
];
|
|
3332
|
-
for (const call of callExpressions) {
|
|
3333
|
-
if (call.wasForgotten()) continue;
|
|
3334
|
-
const expr = call.getExpression();
|
|
3335
|
-
if (!import_ts_morph16.Node.isPropertyAccessExpression(expr)) continue;
|
|
3336
|
-
if (expr.getName() !== "route") continue;
|
|
3337
|
-
const args2 = call.getArguments();
|
|
3338
|
-
if (args2.length === 0) continue;
|
|
3339
|
-
const firstArg = args2[0];
|
|
3340
|
-
if (import_ts_morph16.Node.isObjectLiteralExpression(firstArg)) {
|
|
3341
|
-
if (!isStatisticsRouteObject(firstArg)) continue;
|
|
3342
|
-
const stmt = call.getFirstAncestorByKind(import_ts_morph16.SyntaxKind.ExpressionStatement);
|
|
3343
|
-
if (stmt) {
|
|
3344
|
-
stmt.remove();
|
|
3345
|
-
removed++;
|
|
3346
|
-
} else {
|
|
3347
|
-
call.replaceWithText("");
|
|
3348
|
-
removed++;
|
|
3349
|
-
}
|
|
3350
|
-
continue;
|
|
3351
|
-
}
|
|
3352
|
-
if (import_ts_morph16.Node.isArrayLiteralExpression(firstArg)) {
|
|
3353
|
-
const matchingIndexes = firstArg.getElements().map((el, idx) => ({ el, idx })).filter(
|
|
3354
|
-
({ el }) => import_ts_morph16.Node.isObjectLiteralExpression(el) && isStatisticsRouteObject(el)
|
|
3355
|
-
).map(({ idx }) => idx);
|
|
3356
|
-
matchingIndexes.sort((a, b) => b - a).forEach((idx) => {
|
|
3357
|
-
firstArg.removeElement(idx);
|
|
3358
|
-
removed++;
|
|
3359
|
-
});
|
|
3360
|
-
}
|
|
3361
|
-
}
|
|
3362
|
-
return removed;
|
|
3363
|
-
}
|
|
3364
|
-
function removeStatisticsHandlerImports(sourceFile) {
|
|
3365
|
-
let changed = false;
|
|
3366
|
-
for (const decl of sourceFile.getImportDeclarations()) {
|
|
3367
|
-
const targetNamed = decl.getNamedImports().find((ni) => ni.getName() === HANDLER_NAME);
|
|
3368
|
-
if (!targetNamed) continue;
|
|
3369
|
-
targetNamed.remove();
|
|
3370
|
-
changed = true;
|
|
3371
|
-
const isNowEmpty = decl.getNamedImports().length === 0 && !decl.getDefaultImport() && !decl.getNamespaceImport();
|
|
3372
|
-
if (isNowEmpty) decl.remove();
|
|
3373
|
-
}
|
|
3374
|
-
return changed;
|
|
3375
|
-
}
|
|
3376
|
-
function processFile12(sourceFile) {
|
|
3377
|
-
const routesRemoved = removeStatisticsRoutes(sourceFile);
|
|
3378
|
-
const importsCleaned = removeStatisticsHandlerImports(sourceFile);
|
|
3379
|
-
return { routesRemoved, importsCleaned };
|
|
3380
|
-
}
|
|
3381
|
-
function collectLocalImportsInSubtree(sourceFile, subtreeRoot) {
|
|
3382
|
-
const result = [];
|
|
3383
|
-
for (const decl of sourceFile.getImportDeclarations()) {
|
|
3384
|
-
const moduleSf = decl.getModuleSpecifierSourceFile();
|
|
3385
|
-
if (!moduleSf) continue;
|
|
3386
|
-
const fp = moduleSf.getFilePath();
|
|
3387
|
-
if (!fp.startsWith(subtreeRoot)) continue;
|
|
3388
|
-
result.push(fp);
|
|
3389
|
-
}
|
|
3390
|
-
return result;
|
|
3391
|
-
}
|
|
3392
|
-
function deleteOrphanedDescendants(project, startingFile, subtreeRoot) {
|
|
3393
|
-
const initialCandidates = collectLocalImportsInSubtree(
|
|
3394
|
-
startingFile,
|
|
3395
|
-
subtreeRoot
|
|
3396
|
-
);
|
|
3397
|
-
const startingPath = startingFile.getFilePath();
|
|
3398
|
-
const deleted = /* @__PURE__ */ new Set([startingPath]);
|
|
3399
|
-
const seen = /* @__PURE__ */ new Set();
|
|
3400
|
-
const worklist = [...initialCandidates];
|
|
3401
|
-
const orphans = [];
|
|
3402
|
-
while (worklist.length > 0) {
|
|
3403
|
-
const candidate = worklist.shift();
|
|
3404
|
-
if (seen.has(candidate)) continue;
|
|
3405
|
-
seen.add(candidate);
|
|
3406
|
-
if (deleted.has(candidate)) continue;
|
|
3407
|
-
if (!candidate.startsWith(subtreeRoot)) continue;
|
|
3408
|
-
const candidateSf = project.getSourceFile(candidate);
|
|
3409
|
-
if (!candidateSf) continue;
|
|
3410
|
-
const stillImported = project.getSourceFiles().some((sf) => {
|
|
3411
|
-
const sfPath = sf.getFilePath();
|
|
3412
|
-
if (deleted.has(sfPath)) return false;
|
|
3413
|
-
if (sfPath === candidate) return false;
|
|
3414
|
-
return sf.getImportDeclarations().some(
|
|
3415
|
-
(decl) => decl.getModuleSpecifierSourceFile()?.getFilePath() === candidate
|
|
3416
|
-
);
|
|
3417
|
-
});
|
|
3418
|
-
if (stillImported) continue;
|
|
3419
|
-
const next = collectLocalImportsInSubtree(candidateSf, subtreeRoot);
|
|
3420
|
-
worklist.push(...next);
|
|
3421
|
-
candidateSf.delete();
|
|
3422
|
-
deleted.add(candidate);
|
|
3423
|
-
orphans.push(candidate);
|
|
3424
|
-
}
|
|
3425
|
-
return orphans;
|
|
3426
|
-
}
|
|
3427
|
-
function processHandlerFile(project) {
|
|
3428
|
-
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
3429
|
-
const fp = sf.getFilePath();
|
|
3430
|
-
return fp.includes("/src/") && !fp.includes("/node_modules/");
|
|
3431
|
-
});
|
|
3432
|
-
for (const sf of sourceFiles) {
|
|
3433
|
-
const fn = sf.getFunction(HANDLER_NAME);
|
|
3434
|
-
if (!fn) continue;
|
|
3435
|
-
const filePath = sf.getFilePath();
|
|
3436
|
-
const exportsByName = [...sf.getExportedDeclarations().keys()];
|
|
3437
|
-
const otherExports = exportsByName.filter((name) => name !== HANDLER_NAME);
|
|
3438
|
-
if (otherExports.length === 0) {
|
|
3439
|
-
const subtreeRoot = import_path16.default.dirname(filePath) + import_path16.default.sep;
|
|
3440
|
-
const orphansDeleted = deleteOrphanedDescendants(
|
|
3441
|
-
project,
|
|
3442
|
-
sf,
|
|
3443
|
-
subtreeRoot
|
|
3444
|
-
);
|
|
3445
|
-
sf.delete();
|
|
3446
|
-
return { filePath, action: "deleted", orphansDeleted };
|
|
3447
|
-
}
|
|
3448
|
-
fn.remove();
|
|
3449
|
-
return {
|
|
3450
|
-
filePath,
|
|
3451
|
-
action: "function-removed",
|
|
3452
|
-
remainingExports: otherExports,
|
|
3453
|
-
orphansDeleted: []
|
|
3454
|
-
};
|
|
3455
|
-
}
|
|
3456
|
-
return { filePath: "", action: "not-found", orphansDeleted: [] };
|
|
3457
|
-
}
|
|
3458
|
-
async function main16() {
|
|
3459
|
-
const project = new import_ts_morph16.Project({
|
|
3460
|
-
tsConfigFilePath: import_path16.default.resolve(process.cwd(), "tsconfig.json"),
|
|
3461
|
-
skipAddingFilesFromTsConfig: false
|
|
3462
|
-
});
|
|
3463
|
-
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
3464
|
-
const fp = sf.getFilePath();
|
|
3465
|
-
return fp.includes("/src/") && !fp.includes("/node_modules/");
|
|
3466
|
-
});
|
|
3467
|
-
console.log(
|
|
3468
|
-
`Removing legacy 'GET ${ROUTE_PATH}' route and '${HANDLER_NAME}' across ${sourceFiles.length} source file(s)...
|
|
3469
|
-
`
|
|
3470
|
-
);
|
|
3471
|
-
let totalRoutesRemoved = 0;
|
|
3472
|
-
let totalFilesWithImportsCleaned = 0;
|
|
3473
|
-
let totalFilesWithRoutesRemoved = 0;
|
|
3474
|
-
for (const sourceFile of sourceFiles) {
|
|
3475
|
-
const filePath = sourceFile.getFilePath();
|
|
3476
|
-
const rel = import_path16.default.relative(process.cwd(), filePath);
|
|
3477
|
-
const result = processFile12(sourceFile);
|
|
3478
|
-
if (result.routesRemoved > 0) {
|
|
3479
|
-
console.log(
|
|
3480
|
-
` [${rel}] Removed ${result.routesRemoved} '${ROUTE_PATH}' route(s)`
|
|
3481
|
-
);
|
|
3482
|
-
totalRoutesRemoved += result.routesRemoved;
|
|
3483
|
-
totalFilesWithRoutesRemoved++;
|
|
3484
|
-
}
|
|
3485
|
-
if (result.importsCleaned) {
|
|
3486
|
-
console.log(` [${rel}] Cleaned up '${HANDLER_NAME}' import`);
|
|
3487
|
-
totalFilesWithImportsCleaned++;
|
|
3488
|
-
}
|
|
3489
|
-
if (result.routesRemoved > 0 || result.importsCleaned) {
|
|
3490
|
-
await sourceFile.save();
|
|
3491
|
-
}
|
|
3492
|
-
}
|
|
3493
|
-
const handlerResult = processHandlerFile(project);
|
|
3494
|
-
switch (handlerResult.action) {
|
|
3495
|
-
case "deleted": {
|
|
3496
|
-
const rel = import_path16.default.relative(process.cwd(), handlerResult.filePath);
|
|
3497
|
-
console.log(
|
|
3498
|
-
` [${rel}] Deleted handler file ('${HANDLER_NAME}' was the sole export).`
|
|
3499
|
-
);
|
|
3500
|
-
for (const orphanPath of handlerResult.orphansDeleted) {
|
|
3501
|
-
const orphanRel = import_path16.default.relative(process.cwd(), orphanPath);
|
|
3502
|
-
console.log(
|
|
3503
|
-
` [${orphanRel}] Deleted (no remaining importers in the project after handler removal).`
|
|
3504
|
-
);
|
|
3505
|
-
}
|
|
3506
|
-
await project.save();
|
|
3507
|
-
break;
|
|
3508
|
-
}
|
|
3509
|
-
case "function-removed": {
|
|
3510
|
-
const rel = import_path16.default.relative(process.cwd(), handlerResult.filePath);
|
|
3511
|
-
console.warn(
|
|
3512
|
-
` [${rel}] Removed '${HANDLER_NAME}' function but kept the file (other exports remain: ${handlerResult.remainingExports?.join(", ")}). Review whether the file is still needed.`
|
|
3513
|
-
);
|
|
3514
|
-
const sf = project.getSourceFile(handlerResult.filePath);
|
|
3515
|
-
if (sf) await sf.save();
|
|
3516
|
-
break;
|
|
3517
|
-
}
|
|
3518
|
-
case "not-found":
|
|
3519
|
-
break;
|
|
3520
|
-
}
|
|
3521
|
-
if (totalRoutesRemoved === 0 && totalFilesWithImportsCleaned === 0 && handlerResult.action === "not-found") {
|
|
3522
|
-
console.log(`
|
|
3523
|
-
No legacy '${ROUTE_PATH}' route or handler found. Nothing to do.`);
|
|
3524
|
-
return;
|
|
3525
|
-
}
|
|
3526
|
-
const orphansSummary = handlerResult.orphansDeleted.length > 0 ? ` and ${handlerResult.orphansDeleted.length} orphaned helper file(s)` : "";
|
|
3527
|
-
console.log(
|
|
3528
|
-
`
|
|
3529
|
-
Done. Removed ${totalRoutesRemoved} route(s) across ${totalFilesWithRoutesRemoved} file(s); cleaned ${HANDLER_NAME} import in ${totalFilesWithImportsCleaned} file(s)${orphansSummary}.`
|
|
3530
|
-
);
|
|
3531
|
-
}
|
|
3532
|
-
|
|
3533
|
-
// src/migrations/v2.0/update-package-json.ts
|
|
3534
|
-
var import_fs = require("fs");
|
|
3535
|
-
var import_path17 = __toESM(require("path"));
|
|
3536
|
-
var PACKAGE_JSON_RELATIVE = "package.json";
|
|
3537
|
-
var TARGET_VERSION = "2.0.0";
|
|
3538
|
-
var TARGET_ZOD_RANGE = "^4.2.1";
|
|
3539
|
-
async function main17() {
|
|
3540
|
-
const packageJsonPath = import_path17.default.join(process.cwd(), PACKAGE_JSON_RELATIVE);
|
|
3541
|
-
if (!(0, import_fs.existsSync)(packageJsonPath)) {
|
|
3542
|
-
console.log(`'${PACKAGE_JSON_RELATIVE}' not found in ${process.cwd()} \u2014 skipping.`);
|
|
3543
|
-
return;
|
|
3544
|
-
}
|
|
3545
|
-
const raw = (0, import_fs.readFileSync)(packageJsonPath, "utf8");
|
|
3546
|
-
let parsed;
|
|
3547
|
-
try {
|
|
3548
|
-
parsed = JSON.parse(raw);
|
|
3549
|
-
} catch (error) {
|
|
3550
|
-
console.warn(
|
|
3551
|
-
` [${PACKAGE_JSON_RELATIVE}] Failed to parse JSON \u2014 skipping update. ${error.message}`
|
|
3552
|
-
);
|
|
3553
|
-
return;
|
|
3554
|
-
}
|
|
3555
|
-
console.log(`Updating '${PACKAGE_JSON_RELATIVE}'...`);
|
|
3556
|
-
const previousVersion = parsed.version;
|
|
3557
|
-
const versionChanged = previousVersion !== TARGET_VERSION;
|
|
3558
|
-
parsed.version = TARGET_VERSION;
|
|
3559
|
-
if (versionChanged) {
|
|
3560
|
-
console.log(
|
|
3561
|
-
` Set version: ${previousVersion ?? "<unset>"} \u2192 ${TARGET_VERSION}`
|
|
3562
|
-
);
|
|
3563
|
-
} else {
|
|
3564
|
-
console.log(` Version already ${TARGET_VERSION} \u2014 no change.`);
|
|
3565
|
-
}
|
|
3566
|
-
let zodBucket = "dependencies";
|
|
3567
|
-
if (parsed.devDependencies && "zod" in parsed.devDependencies) {
|
|
3568
|
-
zodBucket = "devDependencies";
|
|
3569
|
-
}
|
|
3570
|
-
if (!parsed[zodBucket]) {
|
|
3571
|
-
parsed[zodBucket] = {};
|
|
3572
|
-
}
|
|
3573
|
-
const bucket = parsed[zodBucket];
|
|
3574
|
-
const previousZod = bucket.zod;
|
|
3575
|
-
const zodChanged = previousZod !== TARGET_ZOD_RANGE;
|
|
3576
|
-
bucket.zod = TARGET_ZOD_RANGE;
|
|
3577
|
-
if (zodChanged) {
|
|
3578
|
-
console.log(
|
|
3579
|
-
` Set ${zodBucket}.zod: ${previousZod ?? "<absent>"} \u2192 ${TARGET_ZOD_RANGE}`
|
|
3580
|
-
);
|
|
3581
|
-
} else {
|
|
3582
|
-
console.log(` ${zodBucket}.zod already ${TARGET_ZOD_RANGE} \u2014 no change.`);
|
|
3583
|
-
}
|
|
3584
|
-
const trailingNewline = raw.endsWith("\n") ? "\n" : "";
|
|
3585
|
-
const next = JSON.stringify(parsed, null, 2) + trailingNewline;
|
|
3586
|
-
if (next === raw) {
|
|
3587
|
-
console.log("\n No changes to write.");
|
|
3588
|
-
return;
|
|
3589
|
-
}
|
|
3590
|
-
(0, import_fs.writeFileSync)(packageJsonPath, next, "utf8");
|
|
3591
|
-
console.log(`
|
|
3592
|
-
Saved '${PACKAGE_JSON_RELATIVE}'.`);
|
|
3593
|
-
console.log(
|
|
3594
|
-
` NOTE: run \`yarn install\` (or your package manager equivalent) to install the updated dependency versions.`
|
|
3595
|
-
);
|
|
3596
|
-
}
|
|
3597
|
-
|
|
3598
2845
|
// src/migrations/v2.0/migrate-workqueue-configs.ts
|
|
3599
|
-
var
|
|
3600
|
-
var
|
|
2846
|
+
var import_ts_morph13 = require("ts-morph");
|
|
2847
|
+
var import_path13 = __toESM(require("path"));
|
|
3601
2848
|
var DEFINE_WORKQUEUES_NAME3 = "defineWorkqueues";
|
|
3602
2849
|
var ACTIONS_PROPERTY_NAME5 = "actions";
|
|
3603
2850
|
var ACTION_PROPERTY_NAME2 = "action";
|
|
@@ -3618,28 +2865,28 @@ var SUPPORTED_WORKQUEUE_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
|
3618
2865
|
]);
|
|
3619
2866
|
function getWorkqueueLabel(workqueue) {
|
|
3620
2867
|
const slugProperty = workqueue.getProperty(SLUG_PROPERTY_NAME);
|
|
3621
|
-
if (!slugProperty || !
|
|
2868
|
+
if (!slugProperty || !import_ts_morph13.Node.isPropertyAssignment(slugProperty)) {
|
|
3622
2869
|
return "(unknown slug)";
|
|
3623
2870
|
}
|
|
3624
2871
|
const slugInitializer = slugProperty.getInitializer();
|
|
3625
|
-
if (!slugInitializer || !
|
|
2872
|
+
if (!slugInitializer || !import_ts_morph13.Node.isStringLiteral(slugInitializer)) {
|
|
3626
2873
|
return "(unknown slug)";
|
|
3627
2874
|
}
|
|
3628
2875
|
return slugInitializer.getLiteralValue();
|
|
3629
2876
|
}
|
|
3630
2877
|
function getActionTypeName(action) {
|
|
3631
2878
|
const typeProperty = action.getProperty(TYPE_PROPERTY_NAME7);
|
|
3632
|
-
if (!typeProperty || !
|
|
2879
|
+
if (!typeProperty || !import_ts_morph13.Node.isPropertyAssignment(typeProperty)) {
|
|
3633
2880
|
return null;
|
|
3634
2881
|
}
|
|
3635
2882
|
const typeInitializer = typeProperty.getInitializer();
|
|
3636
2883
|
if (!typeInitializer) {
|
|
3637
2884
|
return null;
|
|
3638
2885
|
}
|
|
3639
|
-
if (
|
|
2886
|
+
if (import_ts_morph13.Node.isStringLiteral(typeInitializer)) {
|
|
3640
2887
|
return typeInitializer.getLiteralValue();
|
|
3641
2888
|
}
|
|
3642
|
-
if (
|
|
2889
|
+
if (import_ts_morph13.Node.isPropertyAccessExpression(typeInitializer)) {
|
|
3643
2890
|
return typeInitializer.getName();
|
|
3644
2891
|
}
|
|
3645
2892
|
return null;
|
|
@@ -3653,19 +2900,19 @@ function isUnsupportedActionType(action) {
|
|
|
3653
2900
|
}
|
|
3654
2901
|
function migrateWorkqueueActions(workqueue, relPath) {
|
|
3655
2902
|
const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
|
|
3656
|
-
if (!actionsProperty || !
|
|
2903
|
+
if (!actionsProperty || !import_ts_morph13.Node.isPropertyAssignment(actionsProperty)) {
|
|
3657
2904
|
return 0;
|
|
3658
2905
|
}
|
|
3659
2906
|
const actionsInitializer = actionsProperty.getInitializer();
|
|
3660
|
-
if (!actionsInitializer || !
|
|
2907
|
+
if (!actionsInitializer || !import_ts_morph13.Node.isArrayLiteralExpression(actionsInitializer)) {
|
|
3661
2908
|
return 0;
|
|
3662
2909
|
}
|
|
3663
2910
|
const workqueueLabel = getWorkqueueLabel(workqueue);
|
|
3664
2911
|
const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
|
|
3665
2912
|
if (existingActionProperty) {
|
|
3666
|
-
if (
|
|
2913
|
+
if (import_ts_morph13.Node.isPropertyAssignment(existingActionProperty)) {
|
|
3667
2914
|
const existingActionInitializer = existingActionProperty.getInitializer();
|
|
3668
|
-
if (existingActionInitializer &&
|
|
2915
|
+
if (existingActionInitializer && import_ts_morph13.Node.isObjectLiteralExpression(existingActionInitializer)) {
|
|
3669
2916
|
const conditionalsProperty2 = existingActionInitializer.getProperty(
|
|
3670
2917
|
CONDITIONALS_PROPERTY_NAME
|
|
3671
2918
|
);
|
|
@@ -3690,7 +2937,7 @@ function migrateWorkqueueActions(workqueue, relPath) {
|
|
|
3690
2937
|
return 1;
|
|
3691
2938
|
}
|
|
3692
2939
|
const actionCandidates = actionsInitializer.getElements().filter(
|
|
3693
|
-
(element) =>
|
|
2940
|
+
(element) => import_ts_morph13.Node.isObjectLiteralExpression(element)
|
|
3694
2941
|
);
|
|
3695
2942
|
if (actionCandidates.length === 0) {
|
|
3696
2943
|
actionsProperty.remove();
|
|
@@ -3732,36 +2979,36 @@ function migrateWorkqueueActions(workqueue, relPath) {
|
|
|
3732
2979
|
);
|
|
3733
2980
|
return 1;
|
|
3734
2981
|
}
|
|
3735
|
-
function
|
|
2982
|
+
function processFile11(filePath, project) {
|
|
3736
2983
|
const sourceFile = project.getSourceFile(filePath);
|
|
3737
2984
|
if (!sourceFile) return 0;
|
|
3738
2985
|
let migratedWorkqueues = 0;
|
|
3739
|
-
const relPath =
|
|
2986
|
+
const relPath = import_path13.default.relative(getCwd(), filePath);
|
|
3740
2987
|
const callExpressions = sourceFile.getDescendantsOfKind(
|
|
3741
|
-
|
|
2988
|
+
import_ts_morph13.SyntaxKind.CallExpression
|
|
3742
2989
|
);
|
|
3743
2990
|
for (const call of callExpressions) {
|
|
3744
2991
|
const expression = call.getExpression();
|
|
3745
|
-
if (!
|
|
2992
|
+
if (!import_ts_morph13.Node.isIdentifier(expression) || expression.getText() !== DEFINE_WORKQUEUES_NAME3) {
|
|
3746
2993
|
continue;
|
|
3747
2994
|
}
|
|
3748
2995
|
const args2 = call.getArguments();
|
|
3749
2996
|
if (args2.length === 0) continue;
|
|
3750
2997
|
const workqueuesArg = args2[0];
|
|
3751
|
-
if (!
|
|
2998
|
+
if (!import_ts_morph13.Node.isArrayLiteralExpression(workqueuesArg)) continue;
|
|
3752
2999
|
for (const element of workqueuesArg.getElements()) {
|
|
3753
|
-
if (!
|
|
3000
|
+
if (!import_ts_morph13.Node.isObjectLiteralExpression(element)) continue;
|
|
3754
3001
|
migratedWorkqueues += migrateWorkqueueActions(element, relPath);
|
|
3755
3002
|
}
|
|
3756
3003
|
}
|
|
3757
3004
|
return migratedWorkqueues;
|
|
3758
3005
|
}
|
|
3759
|
-
async function
|
|
3760
|
-
const srcDir =
|
|
3006
|
+
async function main13() {
|
|
3007
|
+
const srcDir = import_path13.default.join(getCwd(), "src");
|
|
3761
3008
|
console.log(`Scanning for defineWorkqueues calls in: ${srcDir}
|
|
3762
3009
|
`);
|
|
3763
|
-
const project = new
|
|
3764
|
-
tsConfigFilePath:
|
|
3010
|
+
const project = new import_ts_morph13.Project({
|
|
3011
|
+
tsConfigFilePath: import_path13.default.resolve(srcDir, "../tsconfig.json"),
|
|
3765
3012
|
skipAddingFilesFromTsConfig: false
|
|
3766
3013
|
});
|
|
3767
3014
|
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
@@ -3774,7 +3021,7 @@ async function main18() {
|
|
|
3774
3021
|
const modifiedFiles = [];
|
|
3775
3022
|
for (const sourceFile of sourceFiles) {
|
|
3776
3023
|
const filePath = sourceFile.getFilePath();
|
|
3777
|
-
const migrated =
|
|
3024
|
+
const migrated = processFile11(filePath, project);
|
|
3778
3025
|
if (migrated > 0) {
|
|
3779
3026
|
totalMigrated += migrated;
|
|
3780
3027
|
modifiedFiles.push(filePath);
|
|
@@ -3791,7 +3038,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
3791
3038
|
for (const filePath of modifiedFiles) {
|
|
3792
3039
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
3793
3040
|
await sourceFile.save();
|
|
3794
|
-
console.log(` Saved: ${
|
|
3041
|
+
console.log(` Saved: ${import_path13.default.relative(getCwd(), filePath)}`);
|
|
3795
3042
|
}
|
|
3796
3043
|
console.log(
|
|
3797
3044
|
`
|
|
@@ -3800,13 +3047,13 @@ Done. Migrated ${totalMigrated} deprecated workqueue 'actions' definition(s) to
|
|
|
3800
3047
|
}
|
|
3801
3048
|
|
|
3802
3049
|
// src/migrations/v2.0/remove-demo-scope.ts
|
|
3803
|
-
var
|
|
3804
|
-
var
|
|
3050
|
+
var import_path14 = __toESM(require("path"));
|
|
3051
|
+
var import_ts_morph14 = require("ts-morph");
|
|
3805
3052
|
var ROLES_HANDLER_RELATIVE_PATH = "src/data-seeding/roles/handler.ts";
|
|
3806
|
-
async function
|
|
3807
|
-
const rolesHandlerPath =
|
|
3808
|
-
const project = new
|
|
3809
|
-
tsConfigFilePath:
|
|
3053
|
+
async function main14() {
|
|
3054
|
+
const rolesHandlerPath = import_path14.default.join(getCwd(), ROLES_HANDLER_RELATIVE_PATH);
|
|
3055
|
+
const project = new import_ts_morph14.Project({
|
|
3056
|
+
tsConfigFilePath: import_path14.default.resolve(getCwd(), "tsconfig.json"),
|
|
3810
3057
|
skipAddingFilesFromTsConfig: false
|
|
3811
3058
|
});
|
|
3812
3059
|
const sourceFile = project.getSourceFile(rolesHandlerPath);
|
|
@@ -3855,7 +3102,7 @@ async function main19() {
|
|
|
3855
3102
|
|
|
3856
3103
|
// src/migrations/v2.0/remove-hearth-migrations.ts
|
|
3857
3104
|
var fs2 = __toESM(require("fs"));
|
|
3858
|
-
var
|
|
3105
|
+
var import_path15 = __toESM(require("path"));
|
|
3859
3106
|
var PATHS_TO_REMOVE = [
|
|
3860
3107
|
{
|
|
3861
3108
|
relativePath: "src/migrations/hearth",
|
|
@@ -3867,9 +3114,9 @@ var PATHS_TO_REMOVE = [
|
|
|
3867
3114
|
},
|
|
3868
3115
|
{ relativePath: "src/utils/hearth-helpers.ts", label: "Hearth helpers file" }
|
|
3869
3116
|
];
|
|
3870
|
-
async function
|
|
3117
|
+
async function main15() {
|
|
3871
3118
|
for (const { relativePath, label } of PATHS_TO_REMOVE) {
|
|
3872
|
-
const absolutePath =
|
|
3119
|
+
const absolutePath = import_path15.default.join(getCwd(), relativePath);
|
|
3873
3120
|
if (fs2.existsSync(absolutePath)) {
|
|
3874
3121
|
fs2.rmSync(absolutePath, { recursive: true, force: true });
|
|
3875
3122
|
console.log(`Removed ${label} '${relativePath}'.`);
|
|
@@ -3880,9 +3127,9 @@ async function main20() {
|
|
|
3880
3127
|
}
|
|
3881
3128
|
|
|
3882
3129
|
// src/migrations/v2.0/create-events-index.ts
|
|
3883
|
-
var
|
|
3884
|
-
var
|
|
3885
|
-
var
|
|
3130
|
+
var import_ts_morph15 = require("ts-morph");
|
|
3131
|
+
var import_fs = __toESM(require("fs"));
|
|
3132
|
+
var import_path16 = __toESM(require("path"));
|
|
3886
3133
|
var DEFINE_CONFIG_NAME5 = "defineConfig";
|
|
3887
3134
|
var HANDLER_FUNCTION_NAMES = /* @__PURE__ */ new Set([
|
|
3888
3135
|
"getCustomEventsHandler",
|
|
@@ -3904,7 +3151,7 @@ var LICENSE_HEADER = `/*
|
|
|
3904
3151
|
`;
|
|
3905
3152
|
function findEventConfigExports(project, srcDir) {
|
|
3906
3153
|
const found = [];
|
|
3907
|
-
const eventsIndexAbs =
|
|
3154
|
+
const eventsIndexAbs = import_path16.default.join(srcDir, "events", "index.ts");
|
|
3908
3155
|
for (const sourceFile of project.getSourceFiles()) {
|
|
3909
3156
|
const filePath = sourceFile.getFilePath();
|
|
3910
3157
|
if (!filePath.startsWith(srcDir) || filePath.includes("/node_modules/")) {
|
|
@@ -3916,10 +3163,10 @@ function findEventConfigExports(project, srcDir) {
|
|
|
3916
3163
|
for (const decl of statement.getDeclarations()) {
|
|
3917
3164
|
const initializer = decl.getInitializer();
|
|
3918
3165
|
if (!initializer) continue;
|
|
3919
|
-
const unwrapped =
|
|
3920
|
-
if (!
|
|
3166
|
+
const unwrapped = import_ts_morph15.Node.isAsExpression(initializer) ? initializer.getExpression() : initializer;
|
|
3167
|
+
if (!import_ts_morph15.Node.isCallExpression(unwrapped)) continue;
|
|
3921
3168
|
const callee = unwrapped.getExpression();
|
|
3922
|
-
if (!
|
|
3169
|
+
if (!import_ts_morph15.Node.isIdentifier(callee)) continue;
|
|
3923
3170
|
if (callee.getText() !== DEFINE_CONFIG_NAME5) continue;
|
|
3924
3171
|
found.push({ name: decl.getName(), filePath });
|
|
3925
3172
|
}
|
|
@@ -3928,8 +3175,8 @@ function findEventConfigExports(project, srcDir) {
|
|
|
3928
3175
|
return found;
|
|
3929
3176
|
}
|
|
3930
3177
|
function buildIndexImportSpecifier(eventConfigFilePath, srcDir) {
|
|
3931
|
-
const eventsIndexDir =
|
|
3932
|
-
let rel =
|
|
3178
|
+
const eventsIndexDir = import_path16.default.join(srcDir, "events");
|
|
3179
|
+
let rel = import_path16.default.relative(eventsIndexDir, eventConfigFilePath).split(import_path16.default.sep).join("/");
|
|
3933
3180
|
if (rel.endsWith(".ts")) rel = rel.slice(0, -".ts".length);
|
|
3934
3181
|
if (rel.endsWith("/index")) rel = rel.slice(0, -"/index".length);
|
|
3935
3182
|
if (!rel.startsWith(".")) rel = "./" + rel;
|
|
@@ -4006,17 +3253,17 @@ function modifyHandler(sourceFile, exportNames) {
|
|
|
4006
3253
|
);
|
|
4007
3254
|
}
|
|
4008
3255
|
for (const call of sourceFile.getDescendantsOfKind(
|
|
4009
|
-
|
|
3256
|
+
import_ts_morph15.SyntaxKind.CallExpression
|
|
4010
3257
|
)) {
|
|
4011
3258
|
const callee = call.getExpression();
|
|
4012
|
-
if (!
|
|
3259
|
+
if (!import_ts_morph15.Node.isPropertyAccessExpression(callee)) continue;
|
|
4013
3260
|
if (callee.getName() !== RESPONSE_METHOD_NAME) continue;
|
|
4014
3261
|
const args2 = call.getArguments();
|
|
4015
3262
|
if (args2.length !== 1) continue;
|
|
4016
3263
|
const [arg] = args2;
|
|
4017
|
-
if (!
|
|
3264
|
+
if (!import_ts_morph15.Node.isArrayLiteralExpression(arg)) continue;
|
|
4018
3265
|
if (arg.getElements().length === 0) continue;
|
|
4019
|
-
if (!arg.getElements().every((el) =>
|
|
3266
|
+
if (!arg.getElements().every((el) => import_ts_morph15.Node.isIdentifier(el))) continue;
|
|
4020
3267
|
arg.replaceWithText(EVENT_CONFIGS_IDENTIFIER);
|
|
4021
3268
|
changes.push(
|
|
4022
3269
|
`rewrote h.response([...]) \u2192 h.response(${EVENT_CONFIGS_IDENTIFIER})`
|
|
@@ -4024,13 +3271,13 @@ function modifyHandler(sourceFile, exportNames) {
|
|
|
4024
3271
|
}
|
|
4025
3272
|
return changes;
|
|
4026
3273
|
}
|
|
4027
|
-
async function
|
|
4028
|
-
const
|
|
4029
|
-
const srcDir =
|
|
3274
|
+
async function main16() {
|
|
3275
|
+
const cwd2 = getCwd();
|
|
3276
|
+
const srcDir = import_path16.default.join(cwd2, "src");
|
|
4030
3277
|
console.log(`Scanning for defineConfig event exports in: ${srcDir}
|
|
4031
3278
|
`);
|
|
4032
|
-
const project = new
|
|
4033
|
-
tsConfigFilePath:
|
|
3279
|
+
const project = new import_ts_morph15.Project({
|
|
3280
|
+
tsConfigFilePath: import_path16.default.resolve(srcDir, "../tsconfig.json"),
|
|
4034
3281
|
skipAddingFilesFromTsConfig: false
|
|
4035
3282
|
});
|
|
4036
3283
|
const eventConfigExports = findEventConfigExports(project, srcDir);
|
|
@@ -4042,15 +3289,15 @@ async function main21() {
|
|
|
4042
3289
|
}
|
|
4043
3290
|
console.log(`Found ${eventConfigExports.length} event config export(s):`);
|
|
4044
3291
|
for (const e of eventConfigExports) {
|
|
4045
|
-
console.log(` ${e.name} \u2190 ${
|
|
3292
|
+
console.log(` ${e.name} \u2190 ${import_path16.default.relative(cwd2, e.filePath)}`);
|
|
4046
3293
|
}
|
|
4047
|
-
const eventsIndexAbs =
|
|
4048
|
-
const eventsIndexRel =
|
|
4049
|
-
if (
|
|
3294
|
+
const eventsIndexAbs = import_path16.default.join(srcDir, "events", "index.ts");
|
|
3295
|
+
const eventsIndexRel = import_path16.default.relative(cwd2, eventsIndexAbs);
|
|
3296
|
+
if (import_fs.default.existsSync(eventsIndexAbs)) {
|
|
4050
3297
|
console.log(`
|
|
4051
3298
|
[${eventsIndexRel}] already exists \u2014 leaving untouched.`);
|
|
4052
3299
|
} else {
|
|
4053
|
-
|
|
3300
|
+
import_fs.default.mkdirSync(import_path16.default.dirname(eventsIndexAbs), { recursive: true });
|
|
4054
3301
|
const source = buildEventsIndexSource(eventConfigExports, srcDir);
|
|
4055
3302
|
const eventsIndexFile = project.createSourceFile(eventsIndexAbs, source, {
|
|
4056
3303
|
overwrite: false
|
|
@@ -4071,7 +3318,7 @@ No event-config handler file found (looked for exported function(s): ${Array.fro
|
|
|
4071
3318
|
);
|
|
4072
3319
|
return;
|
|
4073
3320
|
}
|
|
4074
|
-
const handlerRelPath =
|
|
3321
|
+
const handlerRelPath = import_path16.default.relative(cwd2, handler.getFilePath());
|
|
4075
3322
|
const exportNameSet = new Set(eventConfigExports.map((e) => e.name));
|
|
4076
3323
|
const changes = modifyHandler(handler, exportNameSet);
|
|
4077
3324
|
if (changes.length === 0) {
|
|
@@ -4091,13 +3338,12 @@ var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
|
|
|
4091
3338
|
var UPSTREAM_BRANCH = "develop";
|
|
4092
3339
|
var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
|
|
4093
3340
|
var FILES_TO_CHECKOUT = [
|
|
4094
|
-
"
|
|
4095
|
-
"
|
|
4096
|
-
"Dockerfile.assets"
|
|
3341
|
+
"infrastructure/postgres/setup-analytics.sh",
|
|
3342
|
+
"src/analytics/analytics.ts"
|
|
4097
3343
|
];
|
|
4098
3344
|
function runGit(args2, { silent = false } = {}) {
|
|
4099
3345
|
return (0, import_child_process.execFileSync)("git", args2, {
|
|
4100
|
-
cwd:
|
|
3346
|
+
cwd: getCwd(),
|
|
4101
3347
|
encoding: "utf8",
|
|
4102
3348
|
stdio: silent ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "inherit"]
|
|
4103
3349
|
});
|
|
@@ -4113,11 +3359,11 @@ function tryGit(args2) {
|
|
|
4113
3359
|
function assertIsGitRepo() {
|
|
4114
3360
|
if (!tryGit(["rev-parse", "--is-inside-work-tree"])) {
|
|
4115
3361
|
throw new Error(
|
|
4116
|
-
|
|
3362
|
+
`checkout-upstream-files: ${getCwd()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`
|
|
4117
3363
|
);
|
|
4118
3364
|
}
|
|
4119
3365
|
}
|
|
4120
|
-
async function
|
|
3366
|
+
async function main17() {
|
|
4121
3367
|
console.log(
|
|
4122
3368
|
`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${UPSTREAM_URL}@${UPSTREAM_BRANCH}...
|
|
4123
3369
|
`
|
|
@@ -4165,356 +3411,10 @@ async function main22() {
|
|
|
4165
3411
|
}
|
|
4166
3412
|
}
|
|
4167
3413
|
|
|
4168
|
-
// src/migrations/v2.0/add-resend-invite-notification.ts
|
|
4169
|
-
var import_fs3 = require("fs");
|
|
4170
|
-
var import_path22 = __toESM(require("path"));
|
|
4171
|
-
var import_ts_morph20 = require("ts-morph");
|
|
4172
|
-
var TS_MORPH_PROJECT_OPTIONS = {
|
|
4173
|
-
skipAddingFilesFromTsConfig: true,
|
|
4174
|
-
manipulationSettings: {
|
|
4175
|
-
indentationText: import_ts_morph20.IndentationText.TwoSpaces
|
|
4176
|
-
}
|
|
4177
|
-
};
|
|
4178
|
-
var EMAIL_TEMPLATES_INDEX = "src/api/notification/email-templates/index.ts";
|
|
4179
|
-
var NOTIFICATION_HANDLER = "src/api/notification/handler.ts";
|
|
4180
|
-
var USER_NOTIFICATION_ROUTES = "src/config/routes/userNotificationRoutes.ts";
|
|
4181
|
-
var SMS_SERVICE = "src/api/notification/sms-service.ts";
|
|
4182
|
-
var NOTIFICATION_CSV = "src/translations/notification.csv";
|
|
4183
|
-
var RESEND_INVITE_HTML = "src/api/notification/email-templates/other/resend-invite.html";
|
|
4184
|
-
var RESEND_INVITE_HTML_CONTENT = `<!doctype html>
|
|
4185
|
-
<html>
|
|
4186
|
-
<head>
|
|
4187
|
-
<link
|
|
4188
|
-
href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap"
|
|
4189
|
-
rel="stylesheet"
|
|
4190
|
-
/>
|
|
4191
|
-
<style type="text/css">
|
|
4192
|
-
body {
|
|
4193
|
-
font-family: 'Noto Sans', sans-serif;
|
|
4194
|
-
color: #222;
|
|
4195
|
-
padding: 16px 24px;
|
|
4196
|
-
}
|
|
4197
|
-
|
|
4198
|
-
h1 {
|
|
4199
|
-
font-size: 21px;
|
|
4200
|
-
margin-top: 32px;
|
|
4201
|
-
margin-bottom: 36px;
|
|
4202
|
-
font-weight: 700;
|
|
4203
|
-
}
|
|
4204
|
-
|
|
4205
|
-
p {
|
|
4206
|
-
font-weight: 400;
|
|
4207
|
-
font-size: 16px;
|
|
4208
|
-
line-height: 1.8;
|
|
4209
|
-
margin-bottom: 24px;
|
|
4210
|
-
}
|
|
4211
|
-
|
|
4212
|
-
i {
|
|
4213
|
-
color: #666;
|
|
4214
|
-
font-weight: 400;
|
|
4215
|
-
font-size: 16px;
|
|
4216
|
-
}
|
|
4217
|
-
</style>
|
|
4218
|
-
</head>
|
|
4219
|
-
|
|
4220
|
-
<body>
|
|
4221
|
-
<img
|
|
4222
|
-
src="{{countryLogo}}"
|
|
4223
|
-
alt="country_logo"
|
|
4224
|
-
style="max-height: 88px; max-width: 100%"
|
|
4225
|
-
/>
|
|
4226
|
-
<h1>Your {{applicationName}} account invitation</h1>
|
|
4227
|
-
<p>Hello {{firstname}},</p>
|
|
4228
|
-
<p>Your account invitation has been resent. Please use the following credentials to access your account:</p>
|
|
4229
|
-
<p>
|
|
4230
|
-
Username: <strong>{{username}}</strong><br />
|
|
4231
|
-
Password: <strong>{{temporaryPassword}}</strong>
|
|
4232
|
-
</p>
|
|
4233
|
-
<p>
|
|
4234
|
-
Please click the link below to complete your account setup and start using
|
|
4235
|
-
{{applicationName}}.
|
|
4236
|
-
</p>
|
|
4237
|
-
|
|
4238
|
-
<div style="margin-top: 32px; margin-bottom: 32px">
|
|
4239
|
-
<a href="{{loginURL}}">Complete setup</a>
|
|
4240
|
-
</div>
|
|
4241
|
-
<br />
|
|
4242
|
-
<p>
|
|
4243
|
-
Best regards, <br />
|
|
4244
|
-
{{applicationName}} Team
|
|
4245
|
-
</p>
|
|
4246
|
-
</body>
|
|
4247
|
-
</html>
|
|
4248
|
-
`;
|
|
4249
|
-
var CSV_ROW = "resendInviteNotification,The SMS message that is sent when a user invitation is resent,Your OpenCRVS account invitation was resent. Please login with your username: {{username}} and temporary password: {{temporaryPassword}},Votre invitation de compte OpenCRVS a \xE9t\xE9 renvoy\xE9e. Veuillez vous connecter avec votre nom d'utilisateur : {{username}} et votre mot de passe temporaire : {{temporaryPassword}}.\n";
|
|
4250
|
-
function getObjectLiteralFromConst(declaration) {
|
|
4251
|
-
if (!declaration) {
|
|
4252
|
-
return;
|
|
4253
|
-
}
|
|
4254
|
-
const initializer = declaration.getInitializer();
|
|
4255
|
-
if (!initializer) {
|
|
4256
|
-
return;
|
|
4257
|
-
}
|
|
4258
|
-
if (import_ts_morph20.Node.isObjectLiteralExpression(initializer)) {
|
|
4259
|
-
return initializer;
|
|
4260
|
-
}
|
|
4261
|
-
if (import_ts_morph20.Node.isAsExpression(initializer)) {
|
|
4262
|
-
const expression = initializer.getExpression();
|
|
4263
|
-
if (import_ts_morph20.Node.isObjectLiteralExpression(expression)) {
|
|
4264
|
-
return expression;
|
|
4265
|
-
}
|
|
4266
|
-
}
|
|
4267
|
-
if (import_ts_morph20.Node.isSatisfiesExpression(initializer)) {
|
|
4268
|
-
const expression = initializer.getExpression();
|
|
4269
|
-
if (import_ts_morph20.Node.isObjectLiteralExpression(expression)) {
|
|
4270
|
-
return expression;
|
|
4271
|
-
}
|
|
4272
|
-
}
|
|
4273
|
-
}
|
|
4274
|
-
function patchEmailTemplatesIndex() {
|
|
4275
|
-
const full = import_path22.default.join(process.cwd(), EMAIL_TEMPLATES_INDEX);
|
|
4276
|
-
if (!(0, import_fs3.existsSync)(full)) {
|
|
4277
|
-
console.log(` '${EMAIL_TEMPLATES_INDEX}' missing \u2014 skipping.`);
|
|
4278
|
-
return false;
|
|
4279
|
-
}
|
|
4280
|
-
const project = new import_ts_morph20.Project(TS_MORPH_PROJECT_OPTIONS);
|
|
4281
|
-
const sourceFile = project.addSourceFileAtPath(full);
|
|
4282
|
-
let changed = false;
|
|
4283
|
-
const triggerVariableObject = getObjectLiteralFromConst(
|
|
4284
|
-
sourceFile.getVariableDeclaration("TriggerVariable")
|
|
4285
|
-
);
|
|
4286
|
-
if (triggerVariableObject) {
|
|
4287
|
-
const hasResendInviteVariable = triggerVariableObject.getProperties().some((prop) => prop.getText().includes("[TriggerEvent.RESEND_INVITE]"));
|
|
4288
|
-
if (!hasResendInviteVariable) {
|
|
4289
|
-
const properties = triggerVariableObject.getProperties();
|
|
4290
|
-
const lastProperty = properties[properties.length - 1];
|
|
4291
|
-
if (lastProperty) {
|
|
4292
|
-
sourceFile.insertText(
|
|
4293
|
-
lastProperty.getEnd(),
|
|
4294
|
-
`,
|
|
4295
|
-
[TriggerEvent.RESEND_INVITE]: z.object({
|
|
4296
|
-
firstname: z.string(),
|
|
4297
|
-
username: z.string(),
|
|
4298
|
-
temporaryPassword: z.string(),
|
|
4299
|
-
completeSetupUrl: z.string(),
|
|
4300
|
-
loginURL: z.string()
|
|
4301
|
-
})`
|
|
4302
|
-
);
|
|
4303
|
-
changed = true;
|
|
4304
|
-
}
|
|
4305
|
-
}
|
|
4306
|
-
}
|
|
4307
|
-
const templatesObject = getObjectLiteralFromConst(
|
|
4308
|
-
sourceFile.getVariableDeclaration("templates")
|
|
4309
|
-
);
|
|
4310
|
-
if (templatesObject) {
|
|
4311
|
-
const hasResendInviteTemplate = templatesObject.getProperties().some(
|
|
4312
|
-
(prop) => prop.getText().includes("readOtherTemplate<TriggerVariable['resend-invite']>")
|
|
4313
|
-
);
|
|
4314
|
-
if (!hasResendInviteTemplate) {
|
|
4315
|
-
const userCreatedProp = templatesObject.getProperties().find((prop) => prop.getText().includes("[TriggerEvent.USER_CREATED]"));
|
|
4316
|
-
const anchor = userCreatedProp ?? templatesObject.getProperties()[templatesObject.getProperties().length - 1];
|
|
4317
|
-
if (anchor) {
|
|
4318
|
-
sourceFile.insertText(
|
|
4319
|
-
anchor.getEnd(),
|
|
4320
|
-
`,
|
|
4321
|
-
[TriggerEvent.RESEND_INVITE]: {
|
|
4322
|
-
type: 'resend-invite',
|
|
4323
|
-
subject: 'Your OpenCRVS account invitation',
|
|
4324
|
-
template:
|
|
4325
|
-
readOtherTemplate<TriggerVariable['resend-invite']>('resend-invite')
|
|
4326
|
-
}`
|
|
4327
|
-
);
|
|
4328
|
-
changed = true;
|
|
4329
|
-
}
|
|
4330
|
-
}
|
|
4331
|
-
}
|
|
4332
|
-
if (changed) {
|
|
4333
|
-
sourceFile.saveSync();
|
|
4334
|
-
}
|
|
4335
|
-
return changed;
|
|
4336
|
-
}
|
|
4337
|
-
function patchNotificationHandler() {
|
|
4338
|
-
const full = import_path22.default.join(process.cwd(), NOTIFICATION_HANDLER);
|
|
4339
|
-
if (!(0, import_fs3.existsSync)(full)) {
|
|
4340
|
-
return false;
|
|
4341
|
-
}
|
|
4342
|
-
const project = new import_ts_morph20.Project(TS_MORPH_PROJECT_OPTIONS);
|
|
4343
|
-
const sourceFile = project.addSourceFileAtPath(full);
|
|
4344
|
-
const convertFn = sourceFile.getFunction("convertPayloadToVariable");
|
|
4345
|
-
if (!convertFn) {
|
|
4346
|
-
return false;
|
|
4347
|
-
}
|
|
4348
|
-
const switchStmt = convertFn.getFirstDescendantByKind(
|
|
4349
|
-
import_ts_morph20.SyntaxKind.SwitchStatement
|
|
4350
|
-
);
|
|
4351
|
-
if (!switchStmt) {
|
|
4352
|
-
return false;
|
|
4353
|
-
}
|
|
4354
|
-
const clauses = switchStmt.getCaseBlock().getClauses();
|
|
4355
|
-
const hasResendInvite = clauses.some(
|
|
4356
|
-
(clause) => import_ts_morph20.Node.isCaseClause(clause) && clause.getExpression().getText() === "TriggerEvent.RESEND_INVITE"
|
|
4357
|
-
);
|
|
4358
|
-
if (hasResendInvite) {
|
|
4359
|
-
return false;
|
|
4360
|
-
}
|
|
4361
|
-
const userCreatedClauseIndex = clauses.findIndex(
|
|
4362
|
-
(clause) => import_ts_morph20.Node.isCaseClause(clause) && clause.getExpression().getText() === "TriggerEvent.USER_CREATED"
|
|
4363
|
-
);
|
|
4364
|
-
if (userCreatedClauseIndex < 0) {
|
|
4365
|
-
return false;
|
|
4366
|
-
}
|
|
4367
|
-
const userCreatedClause = clauses[userCreatedClauseIndex];
|
|
4368
|
-
sourceFile.insertText(
|
|
4369
|
-
userCreatedClause.getEnd(),
|
|
4370
|
-
`
|
|
4371
|
-
|
|
4372
|
-
case TriggerEvent.RESEND_INVITE:
|
|
4373
|
-
return {
|
|
4374
|
-
firstname,
|
|
4375
|
-
username: payload.username,
|
|
4376
|
-
temporaryPassword: payload.temporaryPassword,
|
|
4377
|
-
completeSetupUrl: LOGIN_URL,
|
|
4378
|
-
loginURL: LOGIN_URL
|
|
4379
|
-
}`
|
|
4380
|
-
);
|
|
4381
|
-
sourceFile.saveSync();
|
|
4382
|
-
return true;
|
|
4383
|
-
}
|
|
4384
|
-
function getReturnedArrayLiteral(functionFilePath, fnName) {
|
|
4385
|
-
const project = new import_ts_morph20.Project(TS_MORPH_PROJECT_OPTIONS);
|
|
4386
|
-
const sourceFile = project.addSourceFileAtPath(functionFilePath);
|
|
4387
|
-
const fn = sourceFile.getFunction(fnName);
|
|
4388
|
-
const returnStmt = fn?.getFirstDescendantByKind(import_ts_morph20.SyntaxKind.ReturnStatement);
|
|
4389
|
-
const expr = returnStmt?.getExpression();
|
|
4390
|
-
if (!expr || !import_ts_morph20.Node.isArrayLiteralExpression(expr)) {
|
|
4391
|
-
return { sourceFile, arrayLiteral: void 0 };
|
|
4392
|
-
}
|
|
4393
|
-
return { sourceFile, arrayLiteral: expr };
|
|
4394
|
-
}
|
|
4395
|
-
function patchUserNotificationRoutes() {
|
|
4396
|
-
const full = import_path22.default.join(process.cwd(), USER_NOTIFICATION_ROUTES);
|
|
4397
|
-
if (!(0, import_fs3.existsSync)(full)) {
|
|
4398
|
-
return false;
|
|
4399
|
-
}
|
|
4400
|
-
const { sourceFile, arrayLiteral } = getReturnedArrayLiteral(
|
|
4401
|
-
full,
|
|
4402
|
-
"getUserNotificationRoutes"
|
|
4403
|
-
);
|
|
4404
|
-
if (!arrayLiteral) {
|
|
4405
|
-
return false;
|
|
4406
|
-
}
|
|
4407
|
-
const elements = arrayLiteral.getElements();
|
|
4408
|
-
const routeExists = elements.some(
|
|
4409
|
-
(element) => element.getText().includes(`path: '/triggers/user/resend-invite'`)
|
|
4410
|
-
);
|
|
4411
|
-
if (routeExists) {
|
|
4412
|
-
return false;
|
|
4413
|
-
}
|
|
4414
|
-
const anchor = elements.find(
|
|
4415
|
-
(element) => element.getText().includes(`path: '/triggers/user/user-created'`)
|
|
4416
|
-
) ?? elements[elements.length - 1];
|
|
4417
|
-
if (!anchor) {
|
|
4418
|
-
return false;
|
|
4419
|
-
}
|
|
4420
|
-
sourceFile.insertText(
|
|
4421
|
-
anchor.getEnd(),
|
|
4422
|
-
`,
|
|
4423
|
-
{
|
|
4424
|
-
method: 'POST',
|
|
4425
|
-
path: '/triggers/user/resend-invite',
|
|
4426
|
-
handler: makeNotificationHandler('resend-invite'),
|
|
4427
|
-
options: {
|
|
4428
|
-
auth: false,
|
|
4429
|
-
tags: ['api'],
|
|
4430
|
-
description: 'Handles notification for resent user invite'
|
|
4431
|
-
}
|
|
4432
|
-
}`
|
|
4433
|
-
);
|
|
4434
|
-
sourceFile.saveSync();
|
|
4435
|
-
return true;
|
|
4436
|
-
}
|
|
4437
|
-
function patchSmsService() {
|
|
4438
|
-
const full = import_path22.default.join(process.cwd(), SMS_SERVICE);
|
|
4439
|
-
if (!(0, import_fs3.existsSync)(full)) {
|
|
4440
|
-
return false;
|
|
4441
|
-
}
|
|
4442
|
-
const project = new import_ts_morph20.Project(TS_MORPH_PROJECT_OPTIONS);
|
|
4443
|
-
const sourceFile = project.addSourceFileAtPath(full);
|
|
4444
|
-
let changed = false;
|
|
4445
|
-
const otherTemplatesObject = getObjectLiteralFromConst(
|
|
4446
|
-
sourceFile.getVariableDeclaration("otherTemplates")
|
|
4447
|
-
);
|
|
4448
|
-
if (otherTemplatesObject) {
|
|
4449
|
-
const hasResendTemplate = otherTemplatesObject.getProperties().some((prop) => prop.getText().includes("resendInviteNotification"));
|
|
4450
|
-
if (!hasResendTemplate) {
|
|
4451
|
-
const userCredentialsIndex = otherTemplatesObject.getProperties().findIndex((prop) => prop.getText().includes("userCredentialsNotification"));
|
|
4452
|
-
otherTemplatesObject.insertPropertyAssignment(
|
|
4453
|
-
userCredentialsIndex >= 0 ? userCredentialsIndex + 1 : otherTemplatesObject.getProperties().length,
|
|
4454
|
-
{
|
|
4455
|
-
name: "resendInviteNotification",
|
|
4456
|
-
initializer: `'resendInviteNotification'`
|
|
4457
|
-
}
|
|
4458
|
-
);
|
|
4459
|
-
changed = true;
|
|
4460
|
-
}
|
|
4461
|
-
}
|
|
4462
|
-
const triggerToSmsTemplateObject = getObjectLiteralFromConst(
|
|
4463
|
-
sourceFile.getVariableDeclaration("TriggerToSMSTemplate")
|
|
4464
|
-
);
|
|
4465
|
-
if (triggerToSmsTemplateObject) {
|
|
4466
|
-
const hasResendInviteMap = triggerToSmsTemplateObject.getProperties().some((prop) => prop.getText().includes(`['resend-invite']`));
|
|
4467
|
-
if (!hasResendInviteMap) {
|
|
4468
|
-
const userCreatedIndex = triggerToSmsTemplateObject.getProperties().findIndex((prop) => prop.getText().includes(`['user-created']`));
|
|
4469
|
-
triggerToSmsTemplateObject.insertPropertyAssignment(
|
|
4470
|
-
userCreatedIndex >= 0 ? userCreatedIndex + 1 : triggerToSmsTemplateObject.getProperties().length,
|
|
4471
|
-
{
|
|
4472
|
-
name: `['resend-invite']`,
|
|
4473
|
-
initializer: `'resendInviteNotification'`
|
|
4474
|
-
}
|
|
4475
|
-
);
|
|
4476
|
-
changed = true;
|
|
4477
|
-
}
|
|
4478
|
-
}
|
|
4479
|
-
if (changed) {
|
|
4480
|
-
sourceFile.saveSync();
|
|
4481
|
-
}
|
|
4482
|
-
return changed;
|
|
4483
|
-
}
|
|
4484
|
-
async function main23() {
|
|
4485
|
-
console.log("Adding RESEND_INVITE notification wiring\u2026");
|
|
4486
|
-
const touched = [];
|
|
4487
|
-
if (patchEmailTemplatesIndex()) touched.push(EMAIL_TEMPLATES_INDEX);
|
|
4488
|
-
if (patchNotificationHandler()) touched.push(NOTIFICATION_HANDLER);
|
|
4489
|
-
if (patchUserNotificationRoutes()) touched.push(USER_NOTIFICATION_ROUTES);
|
|
4490
|
-
if (patchSmsService()) touched.push(SMS_SERVICE);
|
|
4491
|
-
const csvPath = import_path22.default.join(process.cwd(), NOTIFICATION_CSV);
|
|
4492
|
-
if ((0, import_fs3.existsSync)(csvPath)) {
|
|
4493
|
-
let t = (0, import_fs3.readFileSync)(csvPath, "utf8");
|
|
4494
|
-
if (!/^resendInviteNotification,/m.test(t)) {
|
|
4495
|
-
if (!t.endsWith("\n")) t += "\n";
|
|
4496
|
-
(0, import_fs3.writeFileSync)(csvPath, t + CSV_ROW);
|
|
4497
|
-
touched.push(NOTIFICATION_CSV);
|
|
4498
|
-
}
|
|
4499
|
-
}
|
|
4500
|
-
const htmlPath = import_path22.default.join(process.cwd(), RESEND_INVITE_HTML);
|
|
4501
|
-
(0, import_fs3.mkdirSync)(import_path22.default.dirname(htmlPath), { recursive: true });
|
|
4502
|
-
if (!(0, import_fs3.existsSync)(htmlPath)) {
|
|
4503
|
-
(0, import_fs3.writeFileSync)(htmlPath, RESEND_INVITE_HTML_CONTENT);
|
|
4504
|
-
touched.push(RESEND_INVITE_HTML);
|
|
4505
|
-
}
|
|
4506
|
-
if (touched.length === 0) {
|
|
4507
|
-
console.log(" Nothing to update (already present or anchors not found).");
|
|
4508
|
-
return;
|
|
4509
|
-
}
|
|
4510
|
-
console.log(` Updated:
|
|
4511
|
-
${touched.map((f) => ` - ${f}`).join("\n")}`);
|
|
4512
|
-
}
|
|
4513
|
-
|
|
4514
3414
|
// src/migrations/v2.0/simplify-analytics-precalculations.ts
|
|
4515
|
-
var
|
|
4516
|
-
var
|
|
4517
|
-
var
|
|
3415
|
+
var import_ts_morph16 = require("ts-morph");
|
|
3416
|
+
var import_fs2 = __toESM(require("fs"));
|
|
3417
|
+
var import_path17 = __toESM(require("path"));
|
|
4518
3418
|
var ANALYTICS_FILE_REL = "src/analytics/analytics.ts";
|
|
4519
3419
|
var FUNCTION_NAME = "precalculateAdditionalAnalytics";
|
|
4520
3420
|
var IMPORT_NAMES_TO_REMOVE = /* @__PURE__ */ new Set(["Event", "precalculateBirthEvent"]);
|
|
@@ -4550,10 +3450,10 @@ function findPrecalculateFunction(sourceFile) {
|
|
|
4550
3450
|
return void 0;
|
|
4551
3451
|
}
|
|
4552
3452
|
function getFunctionBodyBlock(fn) {
|
|
4553
|
-
if (
|
|
3453
|
+
if (import_ts_morph16.Node.isFunctionDeclaration(fn)) return fn.getBody();
|
|
4554
3454
|
const initializer = fn.getInitializer();
|
|
4555
3455
|
if (!initializer) return void 0;
|
|
4556
|
-
if (!
|
|
3456
|
+
if (!import_ts_morph16.Node.isArrowFunction(initializer) && !import_ts_morph16.Node.isFunctionExpression(initializer)) {
|
|
4557
3457
|
return void 0;
|
|
4558
3458
|
}
|
|
4559
3459
|
return initializer.getBody();
|
|
@@ -4563,9 +3463,9 @@ function simplifyPrecalculateFunction(sourceFile) {
|
|
|
4563
3463
|
const fn = findPrecalculateFunction(sourceFile);
|
|
4564
3464
|
if (!fn) return log;
|
|
4565
3465
|
const body = getFunctionBodyBlock(fn);
|
|
4566
|
-
if (!body || !
|
|
3466
|
+
if (!body || !import_ts_morph16.Node.isBlock(body)) return log;
|
|
4567
3467
|
for (const statement of [...body.getStatements()]) {
|
|
4568
|
-
const references = statement.getDescendantsOfKind(
|
|
3468
|
+
const references = statement.getDescendantsOfKind(import_ts_morph16.SyntaxKind.Identifier).some((id) => IMPORT_NAMES_TO_REMOVE.has(id.getText()));
|
|
4569
3469
|
if (references) {
|
|
4570
3470
|
statement.remove();
|
|
4571
3471
|
log.push(`removed statement in ${FUNCTION_NAME} referencing removed imports`);
|
|
@@ -4573,7 +3473,7 @@ function simplifyPrecalculateFunction(sourceFile) {
|
|
|
4573
3473
|
}
|
|
4574
3474
|
const remaining = body.getStatements();
|
|
4575
3475
|
const last = remaining[remaining.length - 1];
|
|
4576
|
-
const alreadyCorrect = last &&
|
|
3476
|
+
const alreadyCorrect = last && import_ts_morph16.Node.isReturnStatement(last) && last.getExpression()?.getText() === RETURN_EXPRESSION_TEXT;
|
|
4577
3477
|
if (!alreadyCorrect) {
|
|
4578
3478
|
body.addStatements(`return ${RETURN_EXPRESSION_TEXT}`);
|
|
4579
3479
|
log.push(
|
|
@@ -4582,17 +3482,17 @@ function simplifyPrecalculateFunction(sourceFile) {
|
|
|
4582
3482
|
}
|
|
4583
3483
|
return log;
|
|
4584
3484
|
}
|
|
4585
|
-
async function
|
|
4586
|
-
const
|
|
4587
|
-
const absPath =
|
|
4588
|
-
if (!
|
|
3485
|
+
async function main18() {
|
|
3486
|
+
const cwd2 = getCwd();
|
|
3487
|
+
const absPath = import_path17.default.join(cwd2, ANALYTICS_FILE_REL);
|
|
3488
|
+
if (!import_fs2.default.existsSync(absPath)) {
|
|
4589
3489
|
console.log(
|
|
4590
3490
|
`[${ANALYTICS_FILE_REL}] does not exist \u2014 nothing to clean up.`
|
|
4591
3491
|
);
|
|
4592
3492
|
return;
|
|
4593
3493
|
}
|
|
4594
|
-
const project = new
|
|
4595
|
-
tsConfigFilePath:
|
|
3494
|
+
const project = new import_ts_morph16.Project({
|
|
3495
|
+
tsConfigFilePath: import_path17.default.resolve(cwd2, "tsconfig.json"),
|
|
4596
3496
|
skipAddingFilesFromTsConfig: false
|
|
4597
3497
|
});
|
|
4598
3498
|
const sourceFile = project.getSourceFile(absPath);
|
|
@@ -4619,158 +3519,26 @@ async function main24() {
|
|
|
4619
3519
|
Saved ${ANALYTICS_FILE_REL}.`);
|
|
4620
3520
|
}
|
|
4621
3521
|
|
|
4622
|
-
// src/migrations/v2.0/
|
|
4623
|
-
var
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
|
|
4628
|
-
var INFRASTRUCTURE_DIR = "infrastructure";
|
|
4629
|
-
var BASE_BRANCH = "release-v1.9";
|
|
4630
|
-
function gitShowBytes(ref, path23) {
|
|
4631
|
-
try {
|
|
4632
|
-
const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path23}`], {
|
|
4633
|
-
cwd: process.cwd(),
|
|
4634
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
4635
|
-
});
|
|
4636
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
4637
|
-
} catch {
|
|
4638
|
-
return null;
|
|
3522
|
+
// src/migrations/v2.0/index.ts
|
|
3523
|
+
var cwd;
|
|
3524
|
+
function getCwd() {
|
|
3525
|
+
if (!cwd) {
|
|
3526
|
+
throw new Error("Country config working directory not set.");
|
|
4639
3527
|
}
|
|
3528
|
+
return cwd;
|
|
4640
3529
|
}
|
|
4641
|
-
async function
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
);
|
|
4646
|
-
assertIsGitRepo();
|
|
4647
|
-
tryGit(["remote", "remove", TEMP_REMOTE2]);
|
|
4648
|
-
try {
|
|
4649
|
-
console.log(` Adding temporary remote '${TEMP_REMOTE2}' \u2192 ${UPSTREAM_URL}`);
|
|
4650
|
-
runGit(["remote", "add", TEMP_REMOTE2, UPSTREAM_URL], { silent: true });
|
|
4651
|
-
console.log(
|
|
4652
|
-
` Fetching ${TEMP_REMOTE2}/{${UPSTREAM_BRANCH},${BASE_BRANCH}} (depth 1)...`
|
|
4653
|
-
);
|
|
4654
|
-
runGit(["fetch", "--depth=1", TEMP_REMOTE2, UPSTREAM_BRANCH, BASE_BRANCH]);
|
|
4655
|
-
const ref = `${TEMP_REMOTE2}/${UPSTREAM_BRANCH}`;
|
|
4656
|
-
const baseRef = `${TEMP_REMOTE2}/${BASE_BRANCH}`;
|
|
4657
|
-
const upstreamFiles = runGit(
|
|
4658
|
-
[
|
|
4659
|
-
"ls-tree",
|
|
4660
|
-
"-r",
|
|
4661
|
-
"--name-only",
|
|
4662
|
-
"-z",
|
|
4663
|
-
ref,
|
|
4664
|
-
"--",
|
|
4665
|
-
`${INFRASTRUCTURE_DIR}/`
|
|
4666
|
-
],
|
|
4667
|
-
{ silent: true }
|
|
4668
|
-
).split("\0").filter(Boolean);
|
|
4669
|
-
if (upstreamFiles.length === 0) {
|
|
4670
|
-
console.log(
|
|
4671
|
-
` No files found under '${INFRASTRUCTURE_DIR}/' on ${ref}. Nothing to merge.`
|
|
4672
|
-
);
|
|
4673
|
-
return;
|
|
4674
|
-
}
|
|
4675
|
-
const tmpDir = (0, import_fs5.mkdtempSync)((0, import_path24.join)((0, import_os.tmpdir)(), "opencrvs-merge-infra-"));
|
|
4676
|
-
const baseTmp = (0, import_path24.join)(tmpDir, "base");
|
|
4677
|
-
const theirsTmp = (0, import_path24.join)(tmpDir, "theirs");
|
|
4678
|
-
let added = 0;
|
|
4679
|
-
let merged = 0;
|
|
4680
|
-
const conflictedFiles = [];
|
|
4681
|
-
for (const file of upstreamFiles) {
|
|
4682
|
-
const fullPath = (0, import_path24.join)(process.cwd(), file);
|
|
4683
|
-
if (!(0, import_fs5.existsSync)(fullPath)) {
|
|
4684
|
-
if (tryGit(["checkout", ref, "--", file])) {
|
|
4685
|
-
console.log(` + ${file} (new from upstream)`);
|
|
4686
|
-
added++;
|
|
4687
|
-
} else {
|
|
4688
|
-
console.warn(` [warn] failed to add new file ${file}`);
|
|
4689
|
-
}
|
|
4690
|
-
continue;
|
|
4691
|
-
}
|
|
4692
|
-
const theirContents = gitShowBytes(ref, file);
|
|
4693
|
-
if (theirContents === null) {
|
|
4694
|
-
console.warn(` [warn] could not read ${file} from ${ref} \u2014 skipping.`);
|
|
4695
|
-
continue;
|
|
4696
|
-
}
|
|
4697
|
-
(0, import_fs5.writeFileSync)(theirsTmp, theirContents);
|
|
4698
|
-
const baseContents = gitShowBytes(baseRef, file);
|
|
4699
|
-
(0, import_fs5.writeFileSync)(baseTmp, baseContents ?? new Uint8Array(0));
|
|
4700
|
-
try {
|
|
4701
|
-
(0, import_child_process2.execFileSync)("git", ["merge-file", fullPath, baseTmp, theirsTmp], {
|
|
4702
|
-
cwd: process.cwd(),
|
|
4703
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
4704
|
-
});
|
|
4705
|
-
runGit(["add", "--", file], { silent: true });
|
|
4706
|
-
merged++;
|
|
4707
|
-
} catch (err) {
|
|
4708
|
-
const status = err.status;
|
|
4709
|
-
if (typeof status === "number" && status > 0) {
|
|
4710
|
-
conflictedFiles.push(file);
|
|
4711
|
-
console.warn(
|
|
4712
|
-
` ! ${file} (${status} conflict${status > 1 ? "s" : ""})`
|
|
4713
|
-
);
|
|
4714
|
-
} else {
|
|
4715
|
-
conflictedFiles.push(file);
|
|
4716
|
-
console.warn(
|
|
4717
|
-
` [warn] merge failed for ${file} (likely binary or unreadable) \u2014 left untouched.`
|
|
4718
|
-
);
|
|
4719
|
-
}
|
|
4720
|
-
}
|
|
4721
|
-
}
|
|
4722
|
-
console.log(
|
|
4723
|
-
`
|
|
4724
|
-
Done. ${added} added, ${merged} merged cleanly, ${conflictedFiles.length} with conflicts.`
|
|
4725
|
-
);
|
|
4726
|
-
if (conflictedFiles.length > 0) {
|
|
4727
|
-
console.warn(
|
|
4728
|
-
`
|
|
4729
|
-
NOTE: ${conflictedFiles.length} file(s) under '${INFRASTRUCTURE_DIR}/' have merge conflicts that you must resolve manually.
|
|
4730
|
-
Look for the standard conflict markers (<<<<<<<, =======, >>>>>>>) in:
|
|
4731
|
-
` + conflictedFiles.map((f) => ` - ${f}`).join("\n") + `
|
|
4732
|
-
After resolving, stage the fixes with: git add ${INFRASTRUCTURE_DIR}/`
|
|
4733
|
-
);
|
|
4734
|
-
}
|
|
4735
|
-
} finally {
|
|
4736
|
-
if (tryGit(["remote", "remove", TEMP_REMOTE2])) {
|
|
4737
|
-
console.log(` Removed temporary remote '${TEMP_REMOTE2}'.`);
|
|
4738
|
-
}
|
|
3530
|
+
async function runUpgrade(ccwd) {
|
|
3531
|
+
if (ccwd) {
|
|
3532
|
+
console.log("Country config working directory:", ccwd);
|
|
3533
|
+
cwd = ccwd;
|
|
4739
3534
|
}
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
// src/migrations/v2.0/delete-infrastructure-directory.ts
|
|
4743
|
-
var import_fs6 = require("fs");
|
|
4744
|
-
var import_path25 = require("path");
|
|
4745
|
-
var INFRASTRUCTURE_DIR2 = "infrastructure";
|
|
4746
|
-
async function main26() {
|
|
4747
|
-
const fullPath = (0, import_path25.join)(process.cwd(), INFRASTRUCTURE_DIR2);
|
|
4748
|
-
if (!(0, import_fs6.existsSync)(fullPath)) {
|
|
3535
|
+
if (!ccwd) {
|
|
4749
3536
|
console.log(
|
|
4750
|
-
|
|
3537
|
+
"Will use current working directory as country config working directory."
|
|
4751
3538
|
);
|
|
4752
|
-
|
|
3539
|
+
cwd = process.cwd();
|
|
4753
3540
|
}
|
|
4754
|
-
|
|
4755
|
-
`);
|
|
4756
|
-
assertIsGitRepo();
|
|
4757
|
-
runGit(["rm", "-rf", "--ignore-unmatch", "--", `${INFRASTRUCTURE_DIR2}/`], {
|
|
4758
|
-
silent: true
|
|
4759
|
-
});
|
|
4760
|
-
console.log(` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR2}/'.`);
|
|
4761
|
-
if ((0, import_fs6.existsSync)(fullPath)) {
|
|
4762
|
-
(0, import_fs6.rmSync)(fullPath, { recursive: true, force: true });
|
|
4763
|
-
console.log(` Removed remaining untracked files under '${INFRASTRUCTURE_DIR2}/'.`);
|
|
4764
|
-
}
|
|
4765
|
-
console.log(
|
|
4766
|
-
`
|
|
4767
|
-
Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
|
|
4768
|
-
);
|
|
4769
|
-
}
|
|
4770
|
-
|
|
4771
|
-
// src/migrations/v2.0/index.ts
|
|
4772
|
-
async function runUpgrade(dockerSwarm) {
|
|
4773
|
-
await main18();
|
|
3541
|
+
await main13();
|
|
4774
3542
|
await main();
|
|
4775
3543
|
await main2();
|
|
4776
3544
|
await main3();
|
|
@@ -4783,22 +3551,11 @@ async function runUpgrade(dockerSwarm) {
|
|
|
4783
3551
|
await main10();
|
|
4784
3552
|
await main11();
|
|
4785
3553
|
await main12();
|
|
4786
|
-
await main13();
|
|
4787
3554
|
await main14();
|
|
4788
3555
|
await main15();
|
|
4789
3556
|
await main16();
|
|
4790
|
-
await main19();
|
|
4791
|
-
await main20();
|
|
4792
|
-
await main21();
|
|
4793
|
-
await main22();
|
|
4794
|
-
await main23();
|
|
4795
|
-
await main24();
|
|
4796
3557
|
await main17();
|
|
4797
|
-
|
|
4798
|
-
await main25();
|
|
4799
|
-
} else {
|
|
4800
|
-
await main26();
|
|
4801
|
-
}
|
|
3558
|
+
await main18();
|
|
4802
3559
|
}
|
|
4803
3560
|
|
|
4804
3561
|
// src/cli.ts
|
|
@@ -4813,20 +3570,7 @@ Commands:
|
|
|
4813
3570
|
|
|
4814
3571
|
Run 'opencrvs <command> --help' for more information on a command.
|
|
4815
3572
|
`.trim();
|
|
4816
|
-
|
|
4817
|
-
Usage: opencrvs upgrade [options]
|
|
4818
|
-
|
|
4819
|
-
Upgrade the country config in the current working directory to the next
|
|
4820
|
-
major version of OpenCRVS.
|
|
4821
|
-
|
|
4822
|
-
Options:
|
|
4823
|
-
--docker-swarm Keep and merge the 'infrastructure/' directory with
|
|
4824
|
-
upstream changes. Use this if your country deploys
|
|
4825
|
-
OpenCRVS via Docker Swarm. When omitted, the
|
|
4826
|
-
'infrastructure/' directory is deleted (default).
|
|
4827
|
-
-h, --help Show this message.
|
|
4828
|
-
`.trim();
|
|
4829
|
-
function main27() {
|
|
3573
|
+
function main19() {
|
|
4830
3574
|
const command = args[0];
|
|
4831
3575
|
if (!command || command === "--help" || command === "-h") {
|
|
4832
3576
|
console.log(USAGE);
|
|
@@ -4871,25 +3615,10 @@ Subcommands:
|
|
|
4871
3615
|
}
|
|
4872
3616
|
}
|
|
4873
3617
|
async function handleUpgrade() {
|
|
4874
|
-
const upgradeArgs = args.slice(1);
|
|
4875
|
-
if (upgradeArgs.includes("--help") || upgradeArgs.includes("-h")) {
|
|
4876
|
-
console.log(UPGRADE_USAGE);
|
|
4877
|
-
process.exit(0);
|
|
4878
|
-
}
|
|
4879
|
-
const KNOWN_FLAGS = /* @__PURE__ */ new Set(["--docker-swarm"]);
|
|
4880
|
-
const unknownFlags = upgradeArgs.filter(
|
|
4881
|
-
(arg) => arg.startsWith("-") && !KNOWN_FLAGS.has(arg)
|
|
4882
|
-
);
|
|
4883
|
-
if (unknownFlags.length > 0) {
|
|
4884
|
-
console.error(`Unknown option(s): ${unknownFlags.join(", ")}
|
|
4885
|
-
`);
|
|
4886
|
-
console.log(UPGRADE_USAGE);
|
|
4887
|
-
process.exit(1);
|
|
4888
|
-
}
|
|
4889
|
-
const dockerSwarm = upgradeArgs.includes("--docker-swarm");
|
|
4890
3618
|
console.log("Initiating upgrade...");
|
|
4891
3619
|
try {
|
|
4892
|
-
|
|
3620
|
+
const pathToCountryconfig = args[1];
|
|
3621
|
+
await runUpgrade(pathToCountryconfig);
|
|
4893
3622
|
console.log("Upgrade completed successfully!");
|
|
4894
3623
|
} catch (error) {
|
|
4895
3624
|
console.error("Upgrade failed:", error);
|
|
@@ -4901,4 +3630,4 @@ function handleCheckTranslations() {
|
|
|
4901
3630
|
console.warn("This command is not implemented yet!");
|
|
4902
3631
|
process.exit(1);
|
|
4903
3632
|
}
|
|
4904
|
-
|
|
3633
|
+
main19();
|