@opencrvs/toolkit 1.9.13-rc.9f087e5 → 1.9.13-rc.a0754c1
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 +850 -35
- 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 +97 -21
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +848 -33
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +6 -5
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +237 -0
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +3 -0
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-demo-scope.js +75 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts +3 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.js +78 -0
- package/opencrvs-toolkit-1.9.13-rc.a0754c1.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-1.9.13-rc.9f087e5.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"AAyuBA,wBAAsB,IAAI,kBAyPzB"}
|
|
@@ -318,25 +318,6 @@ function transformDashboardsValue(init, isProd) {
|
|
|
318
318
|
*/
|
|
319
319
|
function generateTsContent(configObj, exportName, group, isProd) {
|
|
320
320
|
var _a;
|
|
321
|
-
// ── File header ─────────────────────────────────────────────────────────────
|
|
322
|
-
const headerLines = [];
|
|
323
|
-
if (isProd) {
|
|
324
|
-
headerLines.push(`import { env } from './environment'`);
|
|
325
|
-
}
|
|
326
|
-
headerLines.push(`import { ${group.defineFn} } from '${group.importFrom}'`);
|
|
327
|
-
if (group.applicationConfigImportPath) {
|
|
328
|
-
headerLines.push(`import { applicationConfig } from '${group.applicationConfigImportPath}'`);
|
|
329
|
-
}
|
|
330
|
-
headerLines.push('');
|
|
331
|
-
if (isProd) {
|
|
332
|
-
headerLines.push(`const scheme = 'https'`);
|
|
333
|
-
headerLines.push(`const hostname = env.DOMAIN`);
|
|
334
|
-
headerLines.push(`const sentry = env.SENTRY_DSN`);
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
headerLines.push(`const scheme = 'http'`);
|
|
338
|
-
headerLines.push(`const hostname = 'localhost'`);
|
|
339
|
-
}
|
|
340
321
|
// ── Config properties ────────────────────────────────────────────────────────
|
|
341
322
|
const propertyLines = [];
|
|
342
323
|
const seenKeys = new Set();
|
|
@@ -379,6 +360,26 @@ function generateTsContent(configObj, exportName, group, isProd) {
|
|
|
379
360
|
propertyLines.push(` ${key}: applicationConfig.${key}`);
|
|
380
361
|
}
|
|
381
362
|
const body = propertyLines.join(',\n');
|
|
363
|
+
const headerLines = [];
|
|
364
|
+
headerLines.push(`import * as fs from 'fs'`);
|
|
365
|
+
headerLines.push(`import { join } from 'path'`);
|
|
366
|
+
if (isProd) {
|
|
367
|
+
headerLines.push(`import { env } from './environment'`);
|
|
368
|
+
}
|
|
369
|
+
headerLines.push(`import { ${group.defineFn} } from '${group.importFrom}'`);
|
|
370
|
+
if (group.applicationConfigImportPath) {
|
|
371
|
+
headerLines.push(`import { applicationConfig } from '${group.applicationConfigImportPath}'`);
|
|
372
|
+
}
|
|
373
|
+
headerLines.push('');
|
|
374
|
+
if (isProd) {
|
|
375
|
+
headerLines.push(`const scheme = 'https'`);
|
|
376
|
+
headerLines.push(`const hostname = env.DOMAIN`);
|
|
377
|
+
headerLines.push(`const sentry = env.SENTRY_DSN`);
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
headerLines.push(`const scheme = 'http'`);
|
|
381
|
+
headerLines.push(`const hostname = 'localhost'`);
|
|
382
|
+
}
|
|
382
383
|
return [
|
|
383
384
|
...headerLines,
|
|
384
385
|
'',
|
|
@@ -571,6 +572,64 @@ function resolveConfigChain(configObj, path) {
|
|
|
571
572
|
}
|
|
572
573
|
return current.getText();
|
|
573
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* When inlining a value from `application-config.ts` into a file in a
|
|
577
|
+
* different directory, `__dirname`-based paths (e.g. for reading image
|
|
578
|
+
* assets) must be adjusted so they continue to resolve to the original
|
|
579
|
+
* location — the referenced files themselves are NOT moved.
|
|
580
|
+
*
|
|
581
|
+
* Rewrites `join(__dirname, ...)` / `path.join(__dirname, ...)` /
|
|
582
|
+
* `resolve(__dirname, ...)` / `path.resolve(__dirname, ...)` by inserting
|
|
583
|
+
* the relative path from the target directory back to the source directory
|
|
584
|
+
* as an extra leading argument.
|
|
585
|
+
*
|
|
586
|
+
* Example: inlining from `src/api/application/` into `src/login-config.ts`
|
|
587
|
+
* join(__dirname, 'login-bg.jpg')
|
|
588
|
+
* → join(__dirname, 'api/application', 'login-bg.jpg')
|
|
589
|
+
*/
|
|
590
|
+
function rewriteDirnameRefs(text, relDir) {
|
|
591
|
+
if (!relDir || relDir === '.')
|
|
592
|
+
return text;
|
|
593
|
+
const relForward = relDir.replace(/\\/g, '/');
|
|
594
|
+
return text.replace(/\b((?:path\.)?(?:join|resolve))\s*\(\s*__dirname\s*,/g, `$1(__dirname, '${relForward}',`);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Ensures the source file has a namespace `fs` import (`import * as fs from 'fs'`).
|
|
598
|
+
* No-op if a namespace or default `fs` import is already present.
|
|
599
|
+
*/
|
|
600
|
+
function ensureFsImport(sf) {
|
|
601
|
+
const hasFs = sf
|
|
602
|
+
.getImportDeclarations()
|
|
603
|
+
.some((d) => d.getModuleSpecifierValue() === 'fs' &&
|
|
604
|
+
(d.getNamespaceImport() || d.getDefaultImport()));
|
|
605
|
+
if (hasFs)
|
|
606
|
+
return;
|
|
607
|
+
sf.addImportDeclaration({
|
|
608
|
+
moduleSpecifier: 'fs',
|
|
609
|
+
namespaceImport: 'fs'
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Ensures the source file has a named `join` import from 'path'.
|
|
614
|
+
* Merges into an existing 'path' import if present, otherwise adds a new
|
|
615
|
+
* `import { join } from 'path'` declaration.
|
|
616
|
+
*/
|
|
617
|
+
function ensureJoinImport(sf) {
|
|
618
|
+
const pathImports = sf
|
|
619
|
+
.getImportDeclarations()
|
|
620
|
+
.filter((d) => d.getModuleSpecifierValue() === 'path');
|
|
621
|
+
if (pathImports.some((d) => d.getNamedImports().some((ni) => ni.getName() === 'join'))) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
if (pathImports.length > 0) {
|
|
625
|
+
pathImports[0].addNamedImport('join');
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
sf.addImportDeclaration({
|
|
629
|
+
moduleSpecifier: 'path',
|
|
630
|
+
namedImports: ['join']
|
|
631
|
+
});
|
|
632
|
+
}
|
|
574
633
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
575
634
|
function main() {
|
|
576
635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -627,6 +686,7 @@ function main() {
|
|
|
627
686
|
// Before removing, inline every cross-file reference to each unknown key.
|
|
628
687
|
// Example: applicationConfig.BIRTH.LATE_REGISTRATION_TARGET → 45
|
|
629
688
|
const filesToSaveAfterInlining = new Set();
|
|
689
|
+
const appConfigDir = path_1.default.dirname(appConfigAbsPath);
|
|
630
690
|
for (const removedProp of propsToRemove) {
|
|
631
691
|
const key = removedProp.getName();
|
|
632
692
|
for (const sf of appConfigProject.getSourceFiles()) {
|
|
@@ -637,6 +697,12 @@ function main() {
|
|
|
637
697
|
continue;
|
|
638
698
|
if (sf.getFilePath().includes('/node_modules/'))
|
|
639
699
|
continue;
|
|
700
|
+
// Relative path from the target file's directory back to the
|
|
701
|
+
// applicationConfig's directory. Used to adjust `__dirname`-based
|
|
702
|
+
// paths in the inlined value (e.g. image asset references) since
|
|
703
|
+
// those assets are not moved.
|
|
704
|
+
const targetDir = path_1.default.dirname(sf.getFilePath());
|
|
705
|
+
const relDirFromTarget = path_1.default.relative(targetDir, appConfigDir);
|
|
640
706
|
// Break-and-restart after each replacement because replaceWithText()
|
|
641
707
|
// invalidates existing node references in the ts-morph tree
|
|
642
708
|
let madeReplacement = true;
|
|
@@ -664,8 +730,18 @@ function main() {
|
|
|
664
730
|
console.log(` Cannot resolve applicationConfig.${accessPath.join('.')} — skipping inline replacement`);
|
|
665
731
|
continue;
|
|
666
732
|
}
|
|
667
|
-
|
|
668
|
-
|
|
733
|
+
const adjustedValue = rewriteDirnameRefs(resolvedValue, relDirFromTarget);
|
|
734
|
+
node.replaceWithText(adjustedValue);
|
|
735
|
+
// If the inlined value references `fs` or `join`, ensure the
|
|
736
|
+
// target file has the corresponding imports — these are
|
|
737
|
+
// commonly used to read image assets from disk.
|
|
738
|
+
if (/\bfs\s*\./.test(adjustedValue)) {
|
|
739
|
+
ensureFsImport(sf);
|
|
740
|
+
}
|
|
741
|
+
if (/\bjoin\s*\(/.test(adjustedValue)) {
|
|
742
|
+
ensureJoinImport(sf);
|
|
743
|
+
}
|
|
744
|
+
console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative((0, _1.getCwd)(), sf.getFilePath())}`);
|
|
669
745
|
filesToSaveAfterInlining.add(sf);
|
|
670
746
|
madeReplacement = true;
|
|
671
747
|
break; // restart — tree has changed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AA4BA,wBAAgB,MAAM,WAMrB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,iBA2BxD"}
|