@adobe/aem-cs-source-migration-repository-modernizer 1.2.2 → 1.2.3

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.
@@ -21,6 +21,7 @@ const constants = require("./util/constants");
21
21
  const fs = require("fs");
22
22
  const path = require("path");
23
23
  const xmljs = require("xml-js");
24
+ const dJSON = require("dirty-json");
24
25
 
25
26
  var RestructureContent = {
26
27
  /**
@@ -504,10 +505,11 @@ async function formatConfig(osgiConfigFilePath, conversionStep) {
504
505
  */
505
506
  function removeUnwantedChars(key, val, filePath) {
506
507
  //replace \ with empty space
507
- val = val.replace(/\\/g, "");
508
508
  let str = "";
509
509
  if (filePath.endsWith(constants.XML_EXTENSION)) {
510
510
  if (val.charAt(0) == "{") {
511
+ //json element logic
512
+ val = val.replace(/\\/g, "");
511
513
  let type;
512
514
  if (
513
515
  constants.ALL_CONFIGS_TYPES.includes(
@@ -529,20 +531,50 @@ function removeUnwantedChars(key, val, filePath) {
529
531
  str = '"' + key + ":" + type + '"' + ":" + val;
530
532
  }
531
533
  } else if (val.charAt(0) == "[") {
534
+ //json array logic
532
535
  str = '"' + key + '"' + ":" + "[";
533
536
  let tokens = val.substring(1, val.indexOf("]"));
537
+
534
538
  if (tokens.length > 0) {
535
539
  tokens = tokens.split(",");
536
540
  for (let i = 0; i < tokens.length; i++) {
537
541
  if (i == tokens.length - 1) {
538
- str = str + '"' + tokens[i] + '"';
542
+ if (
543
+ tokens[i].trim().charAt(0) == "{" ||
544
+ tokens[i].trim().charAt(0) == "["
545
+ ) {
546
+ //remove \\ and \u002c which is encoded ','
547
+ const modifiedStr = tokens[i]
548
+ .trim()
549
+ .replace(/\\u002c/g, "")
550
+ .replace(/\\/g, "");
551
+ //remove errors from dirty json
552
+ const json = dJSON.parse(modifiedStr);
553
+ str = str + JSON.stringify(json);
554
+ } else {
555
+ str = str + '"' + tokens[i] + '"';
556
+ }
539
557
  } else {
540
- str = str + '"' + tokens[i] + '"' + ",";
558
+ if (
559
+ tokens[i].trim().charAt(0) == "{" ||
560
+ tokens[i].trim().charAt(0) == "["
561
+ ) {
562
+ const modifiedStr = tokens[i]
563
+ .trim()
564
+ .replace(/\\u002c/g, "")
565
+ .replace(/\\/g, "");
566
+ const json = dJSON.parse(modifiedStr);
567
+ str = str + JSON.stringify(json) + ",";
568
+ } else {
569
+ str = str + '"' + tokens[i] + '"' + ",";
570
+ }
541
571
  }
542
572
  }
543
573
  }
574
+
544
575
  str = str + "]";
545
576
  } else {
577
+ val = val.replace(/\\/g, "");
546
578
  val = val.replace(/[^\x20-\x7E]/gim, "");
547
579
  str = '"' + key + '"' + ":" + '"' + val + '"';
548
580
  }
package/target/result.log CHANGED
@@ -1,2 +1,2 @@
1
- Wed, 06 Oct 2021 10:04:58 | info: RestructureConfig: Formatted OSGi config file 'com.adobe.config.test.xml' to 'com.adobe.config.test.cfg.json'.
2
- Wed, 06 Oct 2021 10:04:58 | info: RestructureConfig: Formatted OSGi config file 'com.adobe.test.config' to 'com.adobe.test.cfg.json'.
1
+ Fri, 23 Jan 2026 09:37:03 | info: RestructureConfig: Formatted OSGi config file 'com.adobe.config.test.xml' to 'com.adobe.config.test.cfg.json'.
2
+ Fri, 23 Jan 2026 09:37:03 | info: RestructureConfig: Formatted OSGi config file 'com.adobe.test.config' to 'com.adobe.test.cfg.json'.
@@ -13,12 +13,15 @@ jest.mock("@adobe/aem-cs-source-migration-commons");
13
13
  jest.mock("../src/util/pom-manipulation-util");
14
14
  jest.mock("fs");
15
15
  jest.mock("fs-extra");
16
- jest.mock("node-pom-parser", () => {
17
- const pomObj = {
18
- artifactId: "test.artifactId",
19
- version: "1.0.0",
16
+ jest.mock("xml-js", () => {
17
+ return {
18
+ xml2js: jest.fn(() => ({
19
+ project: {
20
+ artifactId: { _text: "test.artifactId" },
21
+ version: { _text: "1.0.0" },
22
+ },
23
+ })),
20
24
  };
21
- return { parsePom: jest.fn(() => pomObj) };
22
25
  });
23
26
 
24
27
  const {
@@ -1,4 +1,5 @@
1
1
  {
2
+ "localeLangSettings":[{"localeLanguage":"us-en_us","destinationPath":"/content/hbtbt/us/en/products","byCategoryPath":"/content/hbtbt/us/en/products/by-category","categoryFragmentPath":"/content/experience-fragments/hbtbt/us/en/products","alternativeProductsTitle":"Related Products","productDocumentType":"Product","navigationTitle":"","heroTitleField":"longLabel"},{"localeLanguage":"in-en","destinationPath":"/content/hbtbt/in/en/products","byCategoryPath":"/content/hbtbt/in/en/products/by-category","categoryFragmentPath":"/content/experience-fragments/hbtbt/in/en/products","alternativeProductsTitle":"Related Products","productDocumentType":"Product","navigationTitle":"","heroTitleField":"longLabel"},{"localeLanguage":"gb-en_gb","destinationPath":"/content/hbtbt/gb/en/products","byCategoryPath":"/content/hbtbt/gb/en/products/by-category","categoryFragmentPath":"/content/experience-fragments/hbtbt/gb/en/products","alternativeProductsTitle":"Related Products","productDocumentType":"Product","navigationTitle":"","heroTitleField":"longLabel"},{"localeLanguage":"de-de_de","destinationPath":"/content/hbtbt/de/de/products","byCategoryPath":"/content/hbtbt/de/de/products/by-category","categoryFragmentPath":"/content/experience-fragments/hbtbt/de/de/products","alternativeProductsTitle":"Related Products","productDocumentType":"Product","navigationTitle":"","heroTitleField":"longLabel"}],
2
3
  "enabled:Boolean":true,
3
4
  "error-page.system-path":"/content/404",
4
5
  "serve-authenticated-from-cache:Boolean":true,
@@ -1,6 +1,48 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
3
3
  jcr:primaryType="sling:OsgiConfig"
4
+ localeLangSettings="[
5
+ {
6
+ localeLanguage:'us-en_us'\u002c
7
+ destinationPath:'/content/hbtbt/us/en/products'\u002c
8
+ byCategoryPath:'/content/hbtbt/us/en/products/by-category'\u002c
9
+ categoryFragmentPath:'/content/experience-fragments/hbtbt/us/en/products'\u002c
10
+ alternativeProductsTitle:'Related Products'\u002c
11
+ productDocumentType:'Product'\u002c
12
+ navigationTitle:''\u002c
13
+ heroTitleField:'longLabel'
14
+ },
15
+ {
16
+ localeLanguage:'in-en'\u002c
17
+ destinationPath:'/content/hbtbt/in/en/products'\u002c
18
+ byCategoryPath:'/content/hbtbt/in/en/products/by-category'\u002c
19
+ categoryFragmentPath:'/content/experience-fragments/hbtbt/in/en/products'\u002c
20
+ alternativeProductsTitle:'Related Products'\u002c
21
+ productDocumentType:'Product'\u002c
22
+ navigationTitle:''\u002c
23
+ heroTitleField:'longLabel'
24
+ },
25
+ {
26
+ localeLanguage:'gb-en_gb'\u002c
27
+ destinationPath:'/content/hbtbt/gb/en/products'\u002c
28
+ byCategoryPath:'/content/hbtbt/gb/en/products/by-category'\u002c
29
+ categoryFragmentPath:'/content/experience-fragments/hbtbt/gb/en/products'\u002c
30
+ alternativeProductsTitle:'Related Products'\u002c
31
+ productDocumentType:'Product'\u002c
32
+ navigationTitle:''\u002c
33
+ heroTitleField:'longLabel'
34
+ },
35
+ {
36
+ localeLanguage:'de-de_de'\u002c
37
+ destinationPath:'/content/hbtbt/de/de/products'\u002c
38
+ byCategoryPath:'/content/hbtbt/de/de/products/by-category'\u002c
39
+ categoryFragmentPath:'/content/experience-fragments/hbtbt/de/de/products'\u002c
40
+ alternativeProductsTitle:'Related Products'\u002c
41
+ productDocumentType:'Product'\u002c
42
+ navigationTitle:''\u002c
43
+ heroTitleField:'longLabel'
44
+ }
45
+ ]"
4
46
  enabled="{Boolean}true"
5
47
  error-page.system-path="{String}/content/404"
6
48
  serve-authenticated-from-cache="{Boolean}true"