Repository: Accenture/sfmc-devtools (js)

Issue:
[FEATURE] allow importing certain parts of mcdev directly
after moving to es6 modules we should now be able to play with exports in package.json:
https://nodejs.org/api/packages.html#exports

prettier seems to be doing that nicely in their 3.0.0: https://github.com/prettier/prettier/blob/main/package.json
`import { format } from "prettier/standalone";`

goal should be that our copado extensions needs are covered - and maybe a few additional ones.


need to understand [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) for that and [subpath-exports](https://nodejs.org/api/packages.html#subpath-exports)

Pull request description:
Feature/1108 allow importing certain parts of mcdev directly
# PR details

## What changes did you make? (Give an overview)

- closes #1108



## Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] test scripts updated
- [ ] Wiki updated (if applicable)


Patch:
diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml
index 461f21e5..fb7efa77 100644
--- a/.github/ISSUE_TEMPLATE/bug.yml
+++ b/.github/ISSUE_TEMPLATE/bug.yml
@@ -39,6 +39,7 @@ body:
           label: Version
           description: What version of our software are you running? (mcdev --version)
           options:
+              - 6.0.0
               - 5.3.0
               - 5.2.0
               - 5.1.0
diff --git a/.prettierrc b/.prettierrc
index 8d68fa3f..946dd787 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -10,6 +10,12 @@
                 "parser": "json"
             }
         },
+        {
+            "files": "package.json",
+            "options": {
+                "printWidth": 40
+            }
+        },
         {
             "files": "*.ssjs",
             "options": {
diff --git a/docs/dist/documentation.md b/docs/dist/documentation.md
index 8d609630..c9d9205d 100644
--- a/docs/dist/documentation.md
+++ b/docs/dist/documentation.md
@@ -137,9 +137,6 @@ Provides default functionality that can be overwritten by child metadata type cl
 ## Constants
 
 <dl>
-<dt><a href="#MetadataTypeInfo">MetadataTypeInfo</a></dt>
-<dd><p>Provides access to all metadataType classes</p>
-</dd>
 <dt><a href="#BusinessUnit">BusinessUnit</a></dt>
 <dd><p>Helper that handles retrieval of BU info</p>
 </dd>
@@ -521,6 +518,7 @@ main class
 **Kind**: global class  
 
 * [Mcdev](#Mcdev)
+    * [.version()](#Mcdev.version) ⇒ <code>string</code>
     * [.setSkipInteraction([skipInteraction])](#Mcdev.setSkipInteraction) ⇒ <code>void</code>
     * [.setLoggingLevel(argv)](#Mcdev.setLoggingLevel) ⇒ <code>void</code>
     * [.setOptions(argv)](#Mcdev.setOptions) ⇒ <code>void</code>
@@ -547,6 +545,11 @@ main class
     * [.pause(businessUnit, [selectedType], [keys])](#Mcdev.pause) ⇒ <code>Promise.&lt;Object.&lt;string, Array.&lt;string&gt;&gt;&gt;</code>
     * [.fixKeys(businessUnit, selectedType, [keys])](#Mcdev.fixKeys) ⇒ <code>Promise.&lt;Object.&lt;string, Array.&lt;string&gt;&gt;&gt;</code>
 
+<a name="Mcdev.version"></a>
+
+### Mcdev.version() ⇒ <code>string</code>
+**Kind**: static method of [<code>Mcdev</code>](#Mcdev)  
+**Returns**: <code>string</code> - current version of mcdev  
 <a name="Mcdev.setSkipInteraction"></a>
 
 ### Mcdev.setSkipInteraction([skipInteraction]) ⇒ <code>void</code>
@@ -6284,12 +6287,6 @@ helper for [Retriever.retrieve](Retriever.retrieve) to get all dependencies of t
 | --- | --- | --- |
 | metadataTypes | <code>Array.&lt;TYPE.SupportedMetadataTypes&gt;</code> | list of metadata types to retrieve; can include subtypes! |
 
-<a name="MetadataTypeInfo"></a>
-
-## MetadataTypeInfo
-Provides access to all metadataType classes
-
-**Kind**: global constant  
 <a name="BusinessUnit"></a>
 
 ## BusinessUnit
diff --git a/lib/MetadataTypeDefinitions.js b/lib/MetadataTypeDefinitions.js
index 89fb7dee..d34eeeef 100644
--- a/lib/MetadataTypeDefinitions.js
+++ b/lib/MetadataTypeDefinitions.js
@@ -37,7 +37,7 @@ import user from './metadataTypes/definitions/User.definition.js';
 import verification from './metadataTypes/definitions/Verification.definition.js';
 
 /**
- * Provides access to all metadataType classes
+ * Provides access to definitions of all metadataType classes
  */
 export default {
     asset,
diff --git a/lib/MetadataTypeInfo.js b/lib/MetadataTypeInfo.js
index 0234b069..17ae9d19 100644
--- a/lib/MetadataTypeInfo.js
+++ b/lib/MetadataTypeInfo.js
@@ -39,7 +39,7 @@ import verification from './metadataTypes/Verification.js';
 /**
  * Provides access to all metadataType classes
  */
-const MetadataTypeInfo = {
+export default {
     asset,
     attributeGroup,
     attributeSet,
@@ -76,5 +76,3 @@ const MetadataTypeInfo = {
     user,
     verification,
 };
-
-export default MetadataTypeInfo;
diff --git a/lib/index.js b/lib/index.js
index 2e974969..01e55314 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -21,6 +21,13 @@ import cache from './util/cache.js';
  * main class
  */
 class Mcdev {
+    /**
+     * @returns {string} current version of mcdev
+     */
+    static version() {
+        console.log('mcdev v' + Util.packageJsonMcdev.version); // eslint-disable-line no-console
+        return Util.packageJsonMcdev.version;
+    }
     /**
      * helper method to use unattended mode when including mcdev as a package
      *
diff --git a/package-lock.json b/package-lock.json
index d0938404..31d821ca 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
     "name": "mcdev",
-    "version": "5.3.0",
+    "version": "6.0.0",
     "lockfileVersion": 3,
     "requires": true,
     "packages": {
         "": {
             "name": "mcdev",
-            "version": "5.3.0",
+            "version": "6.0.0",
             "license": "MIT",
             "dependencies": {
                 "beauty-amp-core": "0.3.7",
@@ -3225,9 +3225,9 @@
             }
         },
         "node_modules/get-func-name": {
-            "version": "2.0.0",
-            "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
-            "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
+            "version": "2.0.2",
+            "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz",
+            "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==",
             "dev": true,
             "engines": {
                 "node": "*"
@@ -6362,6 +6362,19 @@
                 "url": "https://github.com/prettier/prettier?sponsor=1"
             }
         },
+        "node_modules/prettier-eslint/node_modules/typescript": {
+            "version": "4.9.5",
+            "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
+            "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
+            "dev": true,
+            "bin": {
+                "tsc": "bin/tsc",
+                "tsserver": "bin/tsserver"
+            },
+            "engines": {
+                "node": ">=4.2.0"
+            }
+        },
         "node_modules/prettier-linter-helpers": {
             "version": "1.0.0",
             "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
@@ -7722,16 +7735,17 @@
             }
         },
         "node_modules/typescript": {
-            "version": "4.6.4",
-            "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz",
-            "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==",
+            "version": "5.2.2",
+            "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
+            "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
             "dev": true,
+            "peer": true,
             "bin": {
                 "tsc": "bin/tsc",
                 "tsserver": "bin/tsserver"
             },
             "engines": {
-                "node": ">=4.2.0"
+                "node": ">=14.17"
             }
         },
         "node_modules/typical": {
diff --git a/package.json b/package.json
index 52e85645..01473340 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mcdev",
-    "version": "5.3.0",
+    "version": "6.0.0",
     "description": "Accenture Salesforce Marketing Cloud DevTools",
     "author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas",
     "license": "MIT",
@@ -31,6 +31,12 @@
         "rest"
     ],
     "main": "./lib/index.js",
+    "exports": {
+        ".": {
+            "default": "./lib/index.js"
+        },
+        "./*": "./*.js"
+    },
     "bin": {
         "mcdev": "./lib/cli.js"
     },
@@ -104,7 +110,9 @@
         "fsevents": "*"
     },
     "lint-staged": {
-        "*.{js,jsx,ts,tsx}": ["eslint --fix"]
+        "*.{js,jsx,ts,tsx}": [
+            "eslint --fix"
+        ]
     },
     "type": "module"
 }


Test patch:
diff --git a/test/mockRoot/.mcdevrc.json b/test/mockRoot/.mcdevrc.json
index 30c384a2..266fb2dc 100644
--- a/test/mockRoot/.mcdevrc.json
+++ b/test/mockRoot/.mcdevrc.json
@@ -78,5 +78,5 @@
             "triggeredSend"
         ]
     },
-    "version": "5.3.0"
+    "version": "6.0.0"
 }