@opencrvs/toolkit 2.0.0-rc.fc7f7fc → 2.0.0-rc.fef9d21
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/cli.js +1383 -142
- package/dist/commons/api/router.d.ts +42 -63
- 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 +3 -4
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.js +373 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +17 -13
- 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 +4 -5
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
- package/dist/migrations/v2.0/create-events-index.js +1 -2
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
- package/dist/migrations/v2.0/index.d.ts +8 -4
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +1351 -139
- 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 +5 -6
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +6 -7
- 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 +3 -4
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +3 -4
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
- 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 +3 -4
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-api-paths.js +3 -4
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
- package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
- package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
- package/dist/migrations/v2.0/update-package-json.js +105 -0
- package/opencrvs-toolkit-2.0.0-rc.fef9d21.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.fc7f7fc.tgz +0 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.main = main;
|
|
26
|
+
/**
|
|
27
|
+
* Codemod: Remove the legacy `GET /statistics` Hapi route and its handler.
|
|
28
|
+
*
|
|
29
|
+
* Background:
|
|
30
|
+
* In v1.x country configs exposed a `GET /statistics` route used by the
|
|
31
|
+
* demo data-generator script to seed location statistics. In v2.0 this is
|
|
32
|
+
* no longer part of the country config surface — the data-generator (where
|
|
33
|
+
* it remains) talks to the Core FHIR APIs directly.
|
|
34
|
+
*
|
|
35
|
+
* What it does (per source file under `src/`):
|
|
36
|
+
* 1. Removes any `<receiver>.route({ method: 'GET', path: '/statistics', ... })`
|
|
37
|
+
* call. Both single-route (`server.route({...})`) and array-route
|
|
38
|
+
* (`server.route([{...}, {...}])`) forms are handled — for the array
|
|
39
|
+
* form only the matching object is removed, the other routes stay.
|
|
40
|
+
* 2. Removes any `statisticsHandler` named import. If that empties an
|
|
41
|
+
* import declaration, the whole declaration is dropped.
|
|
42
|
+
* 3. Finds the file that defines `export async function statisticsHandler`
|
|
43
|
+
* (typically `src/api/data-generator/handler.ts`):
|
|
44
|
+
* - If `statisticsHandler` is the file's *only* export → the whole
|
|
45
|
+
* file is deleted.
|
|
46
|
+
* - Otherwise → just the function declaration is removed and a
|
|
47
|
+
* warning is logged so the developer can decide what to do with
|
|
48
|
+
* the rest of the file.
|
|
49
|
+
* 4. After deleting the handler file, performs a transitive orphan sweep
|
|
50
|
+
* bounded to the handler's directory subtree (e.g.
|
|
51
|
+
* `src/api/data-generator/`):
|
|
52
|
+
* - Each project-local import the handler had is checked. If no
|
|
53
|
+
* remaining file in the project imports that module, the module
|
|
54
|
+
* file is deleted too.
|
|
55
|
+
* - Recursive: a deleted file's own local imports are then checked
|
|
56
|
+
* the same way. The directory boundary prevents this from ever
|
|
57
|
+
* touching shared utilities outside the handler's subtree.
|
|
58
|
+
* This is what reaches `service.ts` (and friends) once nothing else
|
|
59
|
+
* uses it.
|
|
60
|
+
*
|
|
61
|
+
* Caveats:
|
|
62
|
+
* - Only project-local imports inside the handler's directory are
|
|
63
|
+
* considered for orphan deletion. Helpers in shared locations (e.g.
|
|
64
|
+
* `src/utils/`, `src/constants.ts`) are never auto-deleted.
|
|
65
|
+
* - Files that are still referenced by *anything* in the project (other
|
|
66
|
+
* handlers, scripts, demo/data-generators) are kept untouched.
|
|
67
|
+
* - The codemod is a no-op when the route doesn't exist (already
|
|
68
|
+
* migrated country configs).
|
|
69
|
+
*/
|
|
70
|
+
const path_1 = __importDefault(require("path"));
|
|
71
|
+
const ts_morph_1 = require("ts-morph");
|
|
72
|
+
const ROUTE_PATH = '/statistics';
|
|
73
|
+
const HANDLER_NAME = 'statisticsHandler';
|
|
74
|
+
/**
|
|
75
|
+
* Returns true if the given object literal has a property `path` whose
|
|
76
|
+
* value (string literal or no-substitution template literal) equals
|
|
77
|
+
* `ROUTE_PATH`.
|
|
78
|
+
*/
|
|
79
|
+
function isStatisticsRouteObject(obj) {
|
|
80
|
+
const pathProp = obj.getProperty('path');
|
|
81
|
+
if (!pathProp || !ts_morph_1.Node.isPropertyAssignment(pathProp))
|
|
82
|
+
return false;
|
|
83
|
+
const init = pathProp.getInitializer();
|
|
84
|
+
if (!init)
|
|
85
|
+
return false;
|
|
86
|
+
if (ts_morph_1.Node.isStringLiteral(init) || ts_morph_1.Node.isNoSubstitutionTemplateLiteral(init)) {
|
|
87
|
+
return init.getLiteralValue() === ROUTE_PATH;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Removes `<receiver>.route({...})` and `<receiver>.route([{...}, ...])`
|
|
93
|
+
* calls whose route object has `path: '/statistics'`. For the array form
|
|
94
|
+
* only the matching element is removed; siblings are preserved.
|
|
95
|
+
*
|
|
96
|
+
* Returns the number of routes removed in this file.
|
|
97
|
+
*/
|
|
98
|
+
function removeStatisticsRoutes(sourceFile) {
|
|
99
|
+
let removed = 0;
|
|
100
|
+
// Snapshot first — we'll be mutating the AST during iteration.
|
|
101
|
+
const callExpressions = [
|
|
102
|
+
...sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression)
|
|
103
|
+
];
|
|
104
|
+
for (const call of callExpressions) {
|
|
105
|
+
if (call.wasForgotten())
|
|
106
|
+
continue;
|
|
107
|
+
const expr = call.getExpression();
|
|
108
|
+
if (!ts_morph_1.Node.isPropertyAccessExpression(expr))
|
|
109
|
+
continue;
|
|
110
|
+
if (expr.getName() !== 'route')
|
|
111
|
+
continue;
|
|
112
|
+
const args = call.getArguments();
|
|
113
|
+
if (args.length === 0)
|
|
114
|
+
continue;
|
|
115
|
+
const firstArg = args[0];
|
|
116
|
+
// Single-route form: `server.route({ method, path, handler, ... })`
|
|
117
|
+
if (ts_morph_1.Node.isObjectLiteralExpression(firstArg)) {
|
|
118
|
+
if (!isStatisticsRouteObject(firstArg))
|
|
119
|
+
continue;
|
|
120
|
+
// Drop the whole `server.route({...})` statement, not just the call,
|
|
121
|
+
// so we don't leave a dangling `;` behind.
|
|
122
|
+
const stmt = call.getFirstAncestorByKind(ts_morph_1.SyntaxKind.ExpressionStatement);
|
|
123
|
+
if (stmt) {
|
|
124
|
+
stmt.remove();
|
|
125
|
+
removed++;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Fallback (shouldn't happen at top level): replace the call.
|
|
129
|
+
call.replaceWithText('');
|
|
130
|
+
removed++;
|
|
131
|
+
}
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
// Array-route form: `server.route([{...}, {...}])`
|
|
135
|
+
if (ts_morph_1.Node.isArrayLiteralExpression(firstArg)) {
|
|
136
|
+
const matchingIndexes = firstArg
|
|
137
|
+
.getElements()
|
|
138
|
+
.map((el, idx) => ({ el, idx }))
|
|
139
|
+
.filter(({ el }) => ts_morph_1.Node.isObjectLiteralExpression(el) && isStatisticsRouteObject(el))
|
|
140
|
+
.map(({ idx }) => idx);
|
|
141
|
+
// Highest index first so each removal doesn't shift the index of
|
|
142
|
+
// matches we haven't dropped yet.
|
|
143
|
+
matchingIndexes
|
|
144
|
+
.sort((a, b) => b - a)
|
|
145
|
+
.forEach((idx) => {
|
|
146
|
+
firstArg.removeElement(idx);
|
|
147
|
+
removed++;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return removed;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Removes any `statisticsHandler` named import. Returns true if the file
|
|
155
|
+
* was modified.
|
|
156
|
+
*/
|
|
157
|
+
function removeStatisticsHandlerImports(sourceFile) {
|
|
158
|
+
let changed = false;
|
|
159
|
+
for (const decl of sourceFile.getImportDeclarations()) {
|
|
160
|
+
const targetNamed = decl
|
|
161
|
+
.getNamedImports()
|
|
162
|
+
.find((ni) => ni.getName() === HANDLER_NAME);
|
|
163
|
+
if (!targetNamed)
|
|
164
|
+
continue;
|
|
165
|
+
targetNamed.remove();
|
|
166
|
+
changed = true;
|
|
167
|
+
const isNowEmpty = decl.getNamedImports().length === 0 &&
|
|
168
|
+
!decl.getDefaultImport() &&
|
|
169
|
+
!decl.getNamespaceImport();
|
|
170
|
+
if (isNowEmpty)
|
|
171
|
+
decl.remove();
|
|
172
|
+
}
|
|
173
|
+
return changed;
|
|
174
|
+
}
|
|
175
|
+
function processFile(sourceFile) {
|
|
176
|
+
const routesRemoved = removeStatisticsRoutes(sourceFile);
|
|
177
|
+
const importsCleaned = removeStatisticsHandlerImports(sourceFile);
|
|
178
|
+
return { routesRemoved, importsCleaned };
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Returns local-project import paths from the given source file that
|
|
182
|
+
* resolve to a file inside `subtreeRoot`. External (npm) imports and
|
|
183
|
+
* imports outside the subtree are excluded.
|
|
184
|
+
*/
|
|
185
|
+
function collectLocalImportsInSubtree(sourceFile, subtreeRoot) {
|
|
186
|
+
const result = [];
|
|
187
|
+
for (const decl of sourceFile.getImportDeclarations()) {
|
|
188
|
+
const moduleSf = decl.getModuleSpecifierSourceFile();
|
|
189
|
+
if (!moduleSf)
|
|
190
|
+
continue;
|
|
191
|
+
const fp = moduleSf.getFilePath();
|
|
192
|
+
if (!fp.startsWith(subtreeRoot))
|
|
193
|
+
continue;
|
|
194
|
+
result.push(fp);
|
|
195
|
+
}
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Walks files reachable from a deleted starting file via local imports
|
|
200
|
+
* within `subtreeRoot`, deleting any that nobody else imports. Recursive
|
|
201
|
+
* via worklist — when a file is deleted, its own local imports become
|
|
202
|
+
* candidates for the next round.
|
|
203
|
+
*/
|
|
204
|
+
function deleteOrphanedDescendants(project, startingFile, subtreeRoot) {
|
|
205
|
+
const initialCandidates = collectLocalImportsInSubtree(startingFile, subtreeRoot);
|
|
206
|
+
const startingPath = startingFile.getFilePath();
|
|
207
|
+
const deleted = new Set([startingPath]);
|
|
208
|
+
const seen = new Set();
|
|
209
|
+
const worklist = [...initialCandidates];
|
|
210
|
+
const orphans = [];
|
|
211
|
+
while (worklist.length > 0) {
|
|
212
|
+
const candidate = worklist.shift();
|
|
213
|
+
if (seen.has(candidate))
|
|
214
|
+
continue;
|
|
215
|
+
seen.add(candidate);
|
|
216
|
+
if (deleted.has(candidate))
|
|
217
|
+
continue;
|
|
218
|
+
if (!candidate.startsWith(subtreeRoot))
|
|
219
|
+
continue;
|
|
220
|
+
const candidateSf = project.getSourceFile(candidate);
|
|
221
|
+
if (!candidateSf)
|
|
222
|
+
continue;
|
|
223
|
+
// Anyone left in the project still importing this file (including
|
|
224
|
+
// files outside the subtree)? If so, it's not actually orphaned.
|
|
225
|
+
const stillImported = project.getSourceFiles().some((sf) => {
|
|
226
|
+
const sfPath = sf.getFilePath();
|
|
227
|
+
if (deleted.has(sfPath))
|
|
228
|
+
return false;
|
|
229
|
+
if (sfPath === candidate)
|
|
230
|
+
return false;
|
|
231
|
+
return sf
|
|
232
|
+
.getImportDeclarations()
|
|
233
|
+
.some((decl) => { var _a; return ((_a = decl.getModuleSpecifierSourceFile()) === null || _a === void 0 ? void 0 : _a.getFilePath()) === candidate; });
|
|
234
|
+
});
|
|
235
|
+
if (stillImported)
|
|
236
|
+
continue;
|
|
237
|
+
// Capture local imports BEFORE deletion — `delete()` invalidates the
|
|
238
|
+
// node, so we wouldn't be able to read them afterwards.
|
|
239
|
+
const next = collectLocalImportsInSubtree(candidateSf, subtreeRoot);
|
|
240
|
+
worklist.push(...next);
|
|
241
|
+
candidateSf.delete();
|
|
242
|
+
deleted.add(candidate);
|
|
243
|
+
orphans.push(candidate);
|
|
244
|
+
}
|
|
245
|
+
return orphans;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Finds the file that exports `statisticsHandler` and either deletes the
|
|
249
|
+
* whole file (when it's the sole export) or just removes the function
|
|
250
|
+
* declaration. When the file is deleted, also performs a transitive
|
|
251
|
+
* orphan sweep bounded to the file's directory.
|
|
252
|
+
*/
|
|
253
|
+
function processHandlerFile(project) {
|
|
254
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
255
|
+
const fp = sf.getFilePath();
|
|
256
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
257
|
+
});
|
|
258
|
+
for (const sf of sourceFiles) {
|
|
259
|
+
const fn = sf.getFunction(HANDLER_NAME);
|
|
260
|
+
if (!fn)
|
|
261
|
+
continue;
|
|
262
|
+
const filePath = sf.getFilePath();
|
|
263
|
+
const exportsByName = [...sf.getExportedDeclarations().keys()];
|
|
264
|
+
const otherExports = exportsByName.filter((name) => name !== HANDLER_NAME);
|
|
265
|
+
if (otherExports.length === 0) {
|
|
266
|
+
// Sole export — delete the file, then sweep orphans inside its
|
|
267
|
+
// directory subtree.
|
|
268
|
+
const subtreeRoot = path_1.default.dirname(filePath) + path_1.default.sep;
|
|
269
|
+
const orphansDeleted = deleteOrphanedDescendants(project, sf, subtreeRoot);
|
|
270
|
+
sf.delete();
|
|
271
|
+
return { filePath, action: 'deleted', orphansDeleted };
|
|
272
|
+
}
|
|
273
|
+
// Other exports exist; surgically remove just this function.
|
|
274
|
+
// We don't run the orphan sweep here — the file isn't gone, so
|
|
275
|
+
// anything it imports is presumably still in use.
|
|
276
|
+
fn.remove();
|
|
277
|
+
return {
|
|
278
|
+
filePath,
|
|
279
|
+
action: 'function-removed',
|
|
280
|
+
remainingExports: otherExports,
|
|
281
|
+
orphansDeleted: []
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return { filePath: '', action: 'not-found', orphansDeleted: [] };
|
|
285
|
+
}
|
|
286
|
+
function main() {
|
|
287
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
288
|
+
var _a;
|
|
289
|
+
const project = new ts_morph_1.Project({
|
|
290
|
+
tsConfigFilePath: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
|
|
291
|
+
skipAddingFilesFromTsConfig: false
|
|
292
|
+
});
|
|
293
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
294
|
+
const fp = sf.getFilePath();
|
|
295
|
+
return fp.includes('/src/') && !fp.includes('/node_modules/');
|
|
296
|
+
});
|
|
297
|
+
console.log(`Removing legacy 'GET ${ROUTE_PATH}' route and '${HANDLER_NAME}' across ${sourceFiles.length} source file(s)...\n`);
|
|
298
|
+
let totalRoutesRemoved = 0;
|
|
299
|
+
let totalFilesWithImportsCleaned = 0;
|
|
300
|
+
let totalFilesWithRoutesRemoved = 0;
|
|
301
|
+
for (const sourceFile of sourceFiles) {
|
|
302
|
+
const filePath = sourceFile.getFilePath();
|
|
303
|
+
const rel = path_1.default.relative(process.cwd(), filePath);
|
|
304
|
+
const result = processFile(sourceFile);
|
|
305
|
+
if (result.routesRemoved > 0) {
|
|
306
|
+
console.log(` [${rel}] Removed ${result.routesRemoved} '${ROUTE_PATH}' route(s)`);
|
|
307
|
+
totalRoutesRemoved += result.routesRemoved;
|
|
308
|
+
totalFilesWithRoutesRemoved++;
|
|
309
|
+
}
|
|
310
|
+
if (result.importsCleaned) {
|
|
311
|
+
console.log(` [${rel}] Cleaned up '${HANDLER_NAME}' import`);
|
|
312
|
+
totalFilesWithImportsCleaned++;
|
|
313
|
+
}
|
|
314
|
+
if (result.routesRemoved > 0 || result.importsCleaned) {
|
|
315
|
+
yield sourceFile.save();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const handlerResult = processHandlerFile(project);
|
|
319
|
+
switch (handlerResult.action) {
|
|
320
|
+
case 'deleted': {
|
|
321
|
+
const rel = path_1.default.relative(process.cwd(), handlerResult.filePath);
|
|
322
|
+
console.log(` [${rel}] Deleted handler file ('${HANDLER_NAME}' was the sole export).`);
|
|
323
|
+
for (const orphanPath of handlerResult.orphansDeleted) {
|
|
324
|
+
const orphanRel = path_1.default.relative(process.cwd(), orphanPath);
|
|
325
|
+
console.log(` [${orphanRel}] Deleted (no remaining importers in the project after handler removal).`);
|
|
326
|
+
}
|
|
327
|
+
// `delete()` schedules deletion; `save()` writes it to disk.
|
|
328
|
+
yield project.save();
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
case 'function-removed': {
|
|
332
|
+
const rel = path_1.default.relative(process.cwd(), handlerResult.filePath);
|
|
333
|
+
console.warn(` [${rel}] Removed '${HANDLER_NAME}' function but kept the file (other exports remain: ${(_a = handlerResult.remainingExports) === null || _a === void 0 ? void 0 : _a.join(', ')}). Review whether the file is still needed.`);
|
|
334
|
+
// Save the source file with the function removed.
|
|
335
|
+
const sf = project.getSourceFile(handlerResult.filePath);
|
|
336
|
+
if (sf)
|
|
337
|
+
yield sf.save();
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
case 'not-found':
|
|
341
|
+
// Either already migrated or the handler lives somewhere unexpected.
|
|
342
|
+
// Not an error — continue silently.
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
if (totalRoutesRemoved === 0 &&
|
|
346
|
+
totalFilesWithImportsCleaned === 0 &&
|
|
347
|
+
handlerResult.action === 'not-found') {
|
|
348
|
+
console.log(`\nNo legacy '${ROUTE_PATH}' route or handler found. Nothing to do.`);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const orphansSummary = handlerResult.orphansDeleted.length > 0
|
|
352
|
+
? ` and ${handlerResult.orphansDeleted.length} orphaned helper file(s)`
|
|
353
|
+
: '';
|
|
354
|
+
console.log(`\nDone. Removed ${totalRoutesRemoved} route(s) across ${totalFilesWithRoutesRemoved} file(s); cleaned ${HANDLER_NAME} import in ${totalFilesWithImportsCleaned} file(s)${orphansSummary}.`);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-pending-certification-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-pending-certification-flag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove-pending-certification-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-pending-certification-flag.ts"],"names":[],"mappings":"AAyEA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -38,7 +38,6 @@ exports.main = main;
|
|
|
38
38
|
*/
|
|
39
39
|
const ts_morph_1 = require("ts-morph");
|
|
40
40
|
const path_1 = __importDefault(require("path"));
|
|
41
|
-
const _1 = require(".");
|
|
42
41
|
const INHERENT_FLAGS_ENUM_NAME = 'InherentFlags';
|
|
43
42
|
const PENDING_CERTIFICATION_MEMBER = 'PENDING_CERTIFICATION';
|
|
44
43
|
function isPendingCertificationFlag(node) {
|
|
@@ -67,14 +66,14 @@ function processFile(filePath, project) {
|
|
|
67
66
|
for (const index of indicesToRemove.reverse()) {
|
|
68
67
|
array.removeElement(index);
|
|
69
68
|
removedCount++;
|
|
70
|
-
console.log(` [${path_1.default.relative(
|
|
69
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
return removedCount;
|
|
74
73
|
}
|
|
75
74
|
function main() {
|
|
76
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
const srcDir = path_1.default.join(
|
|
76
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
78
77
|
console.log(`Scanning for InherentFlags.PENDING_CERTIFICATION array elements in: ${srcDir}\n`);
|
|
79
78
|
const project = new ts_morph_1.Project({
|
|
80
79
|
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
@@ -103,7 +102,7 @@ function main() {
|
|
|
103
102
|
for (const filePath of modifiedFiles) {
|
|
104
103
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
105
104
|
yield sourceFile.save();
|
|
106
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
105
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
107
106
|
}
|
|
108
107
|
console.log(`\nDone. Removed ${totalRemoved} InherentFlags.PENDING_CERTIFICATION element(s) from array(s).`);
|
|
109
108
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-review-from-register-action.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-review-from-register-action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove-review-from-register-action.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-review-from-register-action.ts"],"names":[],"mappings":"AAkJA,iBAAe,IAAI,kBAkDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -39,7 +39,6 @@ exports.main = main;
|
|
|
39
39
|
*/
|
|
40
40
|
const ts_morph_1 = require("ts-morph");
|
|
41
41
|
const path_1 = __importDefault(require("path"));
|
|
42
|
-
const _1 = require(".");
|
|
43
42
|
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
44
43
|
const ACTIONS_PROPERTY_NAME = 'actions';
|
|
45
44
|
const TYPE_PROPERTY_NAME = 'type';
|
|
@@ -117,7 +116,7 @@ function processFile(filePath, project) {
|
|
|
117
116
|
const wasRemoved = removeReviewFromRegisterActions(element);
|
|
118
117
|
if (wasRemoved) {
|
|
119
118
|
removedCount++;
|
|
120
|
-
console.log(` [${path_1.default.relative(
|
|
119
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed 'review' from REGISTER action`);
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
}
|
|
@@ -125,7 +124,7 @@ function processFile(filePath, project) {
|
|
|
125
124
|
}
|
|
126
125
|
function main() {
|
|
127
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
const srcDir = path_1.default.join(
|
|
127
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
129
128
|
console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
|
|
130
129
|
const project = new ts_morph_1.Project({
|
|
131
130
|
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
@@ -157,7 +156,7 @@ function main() {
|
|
|
157
156
|
for (const filePath of modifiedFiles) {
|
|
158
157
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
159
158
|
yield sourceFile.save();
|
|
160
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
159
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
161
160
|
}
|
|
162
161
|
console.log(`\nDone. Removed ${totalRemoved} 'review' property assignment(s) from REGISTER action(s).`);
|
|
163
162
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-unused-environment-variables.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/remove-unused-environment-variables.ts"],"names":[],"mappings":"AAsJA,iBAAe,IAAI,kBAmDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.main = main;
|
|
26
|
+
/**
|
|
27
|
+
* Codemod: Remove environment variables that are no longer consumed by
|
|
28
|
+
* country config code in v2.0.
|
|
29
|
+
*
|
|
30
|
+
* Targets:
|
|
31
|
+
* - APPLICATION_CONFIG_URL
|
|
32
|
+
* - FHIR_URL
|
|
33
|
+
* - CONFIRM_REGISTRATION_URL
|
|
34
|
+
*
|
|
35
|
+
* What it does:
|
|
36
|
+
* 1. In `src/environment.ts`, removes the matching properties from the
|
|
37
|
+
* `cleanEnv(process.env, { ... })` schema object.
|
|
38
|
+
* 2. In `src/constants.ts`, removes the matching top-level `const`
|
|
39
|
+
* declarations — by name OR by `env.<NAME>` reference (so that
|
|
40
|
+
* country forks that renamed the constant but still read the same env
|
|
41
|
+
* var are also cleaned up).
|
|
42
|
+
*
|
|
43
|
+
* Caveats:
|
|
44
|
+
* - Removing these constants may produce TypeScript errors at usage
|
|
45
|
+
* sites elsewhere in `src/` (e.g. files that imported `FHIR_URL` from
|
|
46
|
+
* `@countryconfig/constants`). Those usages are intentionally left
|
|
47
|
+
* for the developer to resolve, since the right replacement is
|
|
48
|
+
* country-specific.
|
|
49
|
+
* - The codemod is a no-op when the target files or properties don't
|
|
50
|
+
* exist (e.g. the country config has already removed them).
|
|
51
|
+
*/
|
|
52
|
+
const path_1 = __importDefault(require("path"));
|
|
53
|
+
const ts_morph_1 = require("ts-morph");
|
|
54
|
+
const UNUSED_ENV_VARS = new Set([
|
|
55
|
+
'APPLICATION_CONFIG_URL',
|
|
56
|
+
'FHIR_URL',
|
|
57
|
+
'CONFIRM_REGISTRATION_URL'
|
|
58
|
+
]);
|
|
59
|
+
const ENVIRONMENT_FILE_RELATIVE = 'src/environment.ts';
|
|
60
|
+
const CONSTANTS_FILE_RELATIVE = 'src/constants.ts';
|
|
61
|
+
/**
|
|
62
|
+
* Strip matching properties from the `cleanEnv(process.env, { ... })` call
|
|
63
|
+
* in `src/environment.ts`. Returns the names that were removed.
|
|
64
|
+
*/
|
|
65
|
+
function cleanEnvironmentFile(project, filePath) {
|
|
66
|
+
var _a;
|
|
67
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
68
|
+
if (!sourceFile)
|
|
69
|
+
return [];
|
|
70
|
+
const removed = [];
|
|
71
|
+
// IMPORTANT: never iterate all call expressions while mutating this object.
|
|
72
|
+
// Removing a property deletes nested `url(...)` nodes, and touching those
|
|
73
|
+
// forgotten nodes later causes `InvalidOperationError`.
|
|
74
|
+
const cleanEnvCall = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression).find((call) => {
|
|
75
|
+
const expr = call.getExpression();
|
|
76
|
+
return ts_morph_1.Node.isIdentifier(expr) && expr.getText() === 'cleanEnv';
|
|
77
|
+
});
|
|
78
|
+
if (!cleanEnvCall)
|
|
79
|
+
return removed;
|
|
80
|
+
const schemaArg = (_a = cleanEnvCall
|
|
81
|
+
.getArguments()[1]) === null || _a === void 0 ? void 0 : _a.asKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
82
|
+
if (!schemaArg)
|
|
83
|
+
return removed;
|
|
84
|
+
// Remove by explicit property-name lookup to avoid iterating over a live
|
|
85
|
+
// node list while mutating the object literal.
|
|
86
|
+
for (const name of UNUSED_ENV_VARS) {
|
|
87
|
+
const prop = schemaArg.getProperty(name);
|
|
88
|
+
if (!prop)
|
|
89
|
+
continue;
|
|
90
|
+
if (prop.isKind(ts_morph_1.SyntaxKind.PropertyAssignment) ||
|
|
91
|
+
prop.isKind(ts_morph_1.SyntaxKind.ShorthandPropertyAssignment)) {
|
|
92
|
+
prop.remove();
|
|
93
|
+
removed.push(name);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return removed;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Match `env.<NAME>` in an initializer (allowing surrounding parens / `as`
|
|
100
|
+
* casts that ts-morph emits in `getText()` as e.g. `(env.X as string)`).
|
|
101
|
+
* Returns the env var name if matched, or null.
|
|
102
|
+
*/
|
|
103
|
+
function extractEnvAccess(initText) {
|
|
104
|
+
if (!initText)
|
|
105
|
+
return null;
|
|
106
|
+
const match = /\benv\.([A-Z][A-Z0-9_]*)\b/.exec(initText);
|
|
107
|
+
return match ? match[1] : null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Strip top-level `const` declarations in `src/constants.ts` whose name is
|
|
111
|
+
* in `UNUSED_ENV_VARS` OR whose initializer reads `env.<NAME>` for one of
|
|
112
|
+
* those names. Returns the declaration names that were removed.
|
|
113
|
+
*/
|
|
114
|
+
function cleanConstantsFile(project, filePath) {
|
|
115
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
116
|
+
if (!sourceFile)
|
|
117
|
+
return [];
|
|
118
|
+
const removed = [];
|
|
119
|
+
for (const stmt of [...sourceFile.getVariableStatements()]) {
|
|
120
|
+
const declarations = [...stmt.getDeclarations()];
|
|
121
|
+
const declarationsToRemove = declarations.filter((decl) => {
|
|
122
|
+
var _a;
|
|
123
|
+
const name = decl.getName();
|
|
124
|
+
const accessedEnvVar = extractEnvAccess((_a = decl.getInitializer()) === null || _a === void 0 ? void 0 : _a.getText());
|
|
125
|
+
return (UNUSED_ENV_VARS.has(name) ||
|
|
126
|
+
(accessedEnvVar !== null && UNUSED_ENV_VARS.has(accessedEnvVar)));
|
|
127
|
+
});
|
|
128
|
+
if (declarationsToRemove.length === 0)
|
|
129
|
+
continue;
|
|
130
|
+
// Resolve all names before mutating the AST; once a declaration or its
|
|
131
|
+
// parent statement is removed, ts-morph marks old nodes as forgotten.
|
|
132
|
+
const namesToRemove = declarationsToRemove.map((decl) => decl.getName());
|
|
133
|
+
removed.push(...namesToRemove);
|
|
134
|
+
if (declarationsToRemove.length === declarations.length) {
|
|
135
|
+
// All declarations in this statement are unused → drop the whole line
|
|
136
|
+
// (handles the dominant pattern: `export const X = env.X`).
|
|
137
|
+
stmt.remove();
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// Mixed statement (e.g. `const A = env.A, B = somethingElse`) — keep
|
|
141
|
+
// the survivors by removing matching declarators in place.
|
|
142
|
+
for (const decl of declarationsToRemove) {
|
|
143
|
+
decl.remove();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return removed;
|
|
148
|
+
}
|
|
149
|
+
function main() {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
const project = new ts_morph_1.Project({
|
|
152
|
+
tsConfigFilePath: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
|
|
153
|
+
skipAddingFilesFromTsConfig: false
|
|
154
|
+
});
|
|
155
|
+
console.log(`Removing unused environment variable(s) (${[...UNUSED_ENV_VARS].join(', ')})...\n`);
|
|
156
|
+
const envFilePath = path_1.default.join(process.cwd(), ENVIRONMENT_FILE_RELATIVE);
|
|
157
|
+
const constsFilePath = path_1.default.join(process.cwd(), CONSTANTS_FILE_RELATIVE);
|
|
158
|
+
const envRemoved = cleanEnvironmentFile(project, envFilePath);
|
|
159
|
+
if (envRemoved.length > 0) {
|
|
160
|
+
yield project.getSourceFileOrThrow(envFilePath).save();
|
|
161
|
+
console.log(` [${ENVIRONMENT_FILE_RELATIVE}] Removed schema entr${envRemoved.length === 1 ? 'y' : 'ies'}: ${envRemoved.join(', ')}`);
|
|
162
|
+
}
|
|
163
|
+
else if (project.getSourceFile(envFilePath)) {
|
|
164
|
+
console.log(` [${ENVIRONMENT_FILE_RELATIVE}] No matching schema entries — nothing to remove.`);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.log(` [${ENVIRONMENT_FILE_RELATIVE}] File not found — skipping.`);
|
|
168
|
+
}
|
|
169
|
+
const constsRemoved = cleanConstantsFile(project, constsFilePath);
|
|
170
|
+
if (constsRemoved.length > 0) {
|
|
171
|
+
yield project.getSourceFileOrThrow(constsFilePath).save();
|
|
172
|
+
console.log(` [${CONSTANTS_FILE_RELATIVE}] Removed declaration(s): ${constsRemoved.join(', ')}`);
|
|
173
|
+
}
|
|
174
|
+
else if (project.getSourceFile(constsFilePath)) {
|
|
175
|
+
console.log(` [${CONSTANTS_FILE_RELATIVE}] No matching declarations — nothing to remove.`);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
console.log(` [${CONSTANTS_FILE_RELATIVE}] File not found — skipping.`);
|
|
179
|
+
}
|
|
180
|
+
if (envRemoved.length === 0 && constsRemoved.length === 0) {
|
|
181
|
+
console.log('\nNothing to do.');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
console.log(`\nDone. NOTE: usages of these constants elsewhere in 'src/' may now produce TypeScript errors and need manual review.`);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-api-paths.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-api-paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rename-api-paths.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/rename-api-paths.ts"],"names":[],"mappings":"AAuJA,iBAAe,IAAI,kBAgDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -43,7 +43,6 @@ exports.main = main;
|
|
|
43
43
|
*/
|
|
44
44
|
const ts_morph_1 = require("ts-morph");
|
|
45
45
|
const path_1 = __importDefault(require("path"));
|
|
46
|
-
const _1 = require(".");
|
|
47
46
|
// ─── Path rename table ────────────────────────────────────────────────────────
|
|
48
47
|
// Add new renames here as further API paths are changed between versions.
|
|
49
48
|
const PATH_RENAMES = {
|
|
@@ -130,7 +129,7 @@ function processFile(filePath, project) {
|
|
|
130
129
|
if (!sourceFile)
|
|
131
130
|
return 0;
|
|
132
131
|
let renamedCount = 0;
|
|
133
|
-
const relPath = path_1.default.relative(
|
|
132
|
+
const relPath = path_1.default.relative(process.cwd(), filePath);
|
|
134
133
|
// Collect candidates first to avoid iterating a mutating tree
|
|
135
134
|
const candidates = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
136
135
|
for (const obj of candidates) {
|
|
@@ -147,7 +146,7 @@ function processFile(filePath, project) {
|
|
|
147
146
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
148
147
|
function main() {
|
|
149
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
const srcDir = path_1.default.join(
|
|
149
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
151
150
|
console.log(`Scanning for Hapi route configs in: ${srcDir}\n`);
|
|
152
151
|
console.log('Active path renames:');
|
|
153
152
|
for (const [from, to] of Object.entries(PATH_RENAMES)) {
|
|
@@ -181,7 +180,7 @@ function main() {
|
|
|
181
180
|
for (const filePath of modifiedFiles) {
|
|
182
181
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
183
182
|
yield sourceFile.save();
|
|
184
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
183
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
185
184
|
}
|
|
186
185
|
console.log(`\nDone. Renamed ${totalRenamed} route path(s).`);
|
|
187
186
|
});
|