mcdev 4.1.10 → 4.1.11

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.
@@ -39,6 +39,7 @@ body:
39
39
  label: Version
40
40
  description: What version of our software are you running? (mcdev --version)
41
41
  options:
42
+ - 4.1.11
42
43
  - 4.1.10
43
44
  - 4.1.9
44
45
  - 4.1.8
package/README.md CHANGED
@@ -123,7 +123,7 @@ If you experience issues installing Accenture SFMC DevTools, please check out th
123
123
  1. Install Accenture SFMC DevTools by running `npm install -g mcdev` (prefix with `sudo` on MacOS)
124
124
  - If you get an error, please see the below troubleshooting section.
125
125
 
126
- When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.10`).
126
+ When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.11`).
127
127
 
128
128
  > **_Side note for proud nerds_:**
129
129
  >
@@ -277,10 +277,10 @@ _Note: Regardless of which tag or branch you install_
277
277
  **Install specific version (using a version tag on npm):**
278
278
 
279
279
  ```bash
280
- npm install -g mcdev@4.1.10
280
+ npm install -g mcdev@4.1.11
281
281
  ```
282
282
 
283
- **Warning**: When you used the above method to install Accenture SFMC DevTools for a specific version or tag, trying to [update Accenture SFMC DevTools](#updating-mcdev) might not download the most recently published official version but instead stay on the version or branch you previously selected (in the above examples: develop, 4.1.10)!
283
+ **Warning**: When you used the above method to install Accenture SFMC DevTools for a specific version or tag, trying to [update Accenture SFMC DevTools](#updating-mcdev) might not download the most recently published official version but instead stay on the version or branch you previously selected (in the above examples: develop, 4.1.11)!
284
284
 
285
285
  > **Note**: The version is currently _not_ updated on the developer branch until a new release is published. Hence, you will not see a change if you run `mcdev --version`.
286
286
 
@@ -1505,7 +1505,7 @@ Assuming you cloned Accenture SFMC DevTools into `C:\repos\sfmc-devtools\` (or `
1505
1505
 
1506
1506
  This should tell npm to create a symlink to your cloned local directory, allowing you to see updates you make in your mcdev repo instantly.
1507
1507
 
1508
- To test your new **global** developer setup, run `mcdev --version` in CLI which should return the current version (e.g. `4.1.10`). Then, go into your mcdev repo and update the version with the suffix `-dev`, e.g. to `4.1.10-dev` and then run `mcdev --version` again to verify that your change propagates instantly.
1508
+ To test your new **global** developer setup, run `mcdev --version` in CLI which should return the current version (e.g. `4.1.11`). Then, go into your mcdev repo and update the version with the suffix `-dev`, e.g. to `4.1.11-dev` and then run `mcdev --version` again to verify that your change propagates instantly.
1509
1509
 
1510
1510
  > **Not recommended:** Alternatively, you can install it locally only by opening a terminal in your project directory and executing `npm install --save-dev "C:\repos\sfmc-devtools"`
1511
1511
  > To run the local version you need to prepend "npx" before your commands, e.g. `npx mcdev --version`
@@ -1543,7 +1543,7 @@ The following explains how you _could_ install it locally for certain edge cases
1543
1543
  4. Afterwards, install Accenture SFMC DevTools by running `npm install --save-dev mcdev`
1544
1544
  - If you get an error, please see the below troubleshooting section.
1545
1545
 
1546
- When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.10`).
1546
+ When completed run `mcdev --version` and it will show you which version you installed (e.g. `4.1.11`).
1547
1547
 
1548
1548
  ### 9.3. NPM Scripts
1549
1549
 
@@ -4105,6 +4105,7 @@ Script MetadataType
4105
4105
  * [.buildTemplateForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#Script.buildTemplateForNested) ⇒ <code>Promise.&lt;Array.&lt;Array.&lt;string&gt;&gt;&gt;</code>
4106
4106
  * [._buildForNested(templateDir, targetDir, metadata, templateVariables, templateName, mode)](#Script._buildForNested) ⇒ <code>Promise.&lt;Array.&lt;Array.&lt;string&gt;&gt;&gt;</code>
4107
4107
  * [.parseMetadata(metadata)](#Script.parseMetadata) ⇒ <code>TYPE.CodeExtractItem</code>
4108
+ * [.prepExtractedCode(metadataScript, metadataName)](#Script.prepExtractedCode) ⇒ <code>Object</code>
4108
4109
  * [.getFilesToCommit(keyArr)](#Script.getFilesToCommit) ⇒ <code>Array.&lt;string&gt;</code>
4109
4110
 
4110
4111
  <a name="Script.retrieve"></a>
@@ -4276,6 +4277,19 @@ Splits the script metadata into two parts and parses in a standard manner
4276
4277
  | --- | --- | --- |
4277
4278
  | metadata | <code>TYPE.ScriptItem</code> | a single script activity definition |
4278
4279
 
4280
+ <a name="Script.prepExtractedCode"></a>
4281
+
4282
+ ### Script.prepExtractedCode(metadataScript, metadataName) ⇒ <code>Object</code>
4283
+ helper for [parseMetadata](parseMetadata) and [_buildForNested](_buildForNested)
4284
+
4285
+ **Kind**: static method of [<code>Script</code>](#Script)
4286
+ **Returns**: <code>Object</code> - returns found extension and file content
4287
+
4288
+ | Param | Type | Description |
4289
+ | --- | --- | --- |
4290
+ | metadataScript | <code>string</code> | the code of the file |
4291
+ | metadataName | <code>string</code> | the name of the metadata |
4292
+
4279
4293
  <a name="Script.getFilesToCommit"></a>
4280
4294
 
4281
4295
  ### Script.getFilesToCommit(keyArr) ⇒ <code>Array.&lt;string&gt;</code>
@@ -214,6 +214,11 @@ class Script extends MetadataType {
214
214
  ) {
215
215
  // get SSJS from filesystem
216
216
  let code = await this._mergeCode(metadata, templateDir, templateName);
217
+ // try to remove script tags and decide on file extension (html/ssjs)
218
+ const file = Script.prepExtractedCode(code, metadata.name);
219
+ const fileExt = file.fileExt;
220
+ code = fileExt === 'ssjs' ? file.code.replace(/^\n/, '') : file.code;
221
+ // apply templating
217
222
  try {
218
223
  if (mode === 'definition') {
219
224
  // replace template variables with their values
@@ -241,13 +246,13 @@ class Script extends MetadataType {
241
246
  File.writeToFile(
242
247
  [targetDir, this.definition.type],
243
248
  fileName + '.' + this.definition.type + '-meta',
244
- 'ssjs',
249
+ fileExt,
245
250
  code
246
251
  );
247
252
  nestedFilePaths.push([
248
253
  targetDir,
249
254
  this.definition.type,
250
- fileName + '.' + this.definition.type + '-meta.ssjs',
255
+ fileName + '.' + this.definition.type + '-meta.' + fileExt,
251
256
  ]);
252
257
  }
253
258
  return nestedFilePaths;
@@ -266,30 +271,42 @@ class Script extends MetadataType {
266
271
  // extract SSJS
267
272
  const codeArr = [];
268
273
  // keep between tags
274
+ const { fileExt, code } = Script.prepExtractedCode(metadata.script, metadata.name);
275
+ delete metadata.script;
276
+ codeArr.push({
277
+ subFolder: null,
278
+ fileName: metadata.key,
279
+ fileExt: fileExt,
280
+ content: code,
281
+ });
282
+
283
+ return { json: metadata, codeArr: codeArr, subFolder: null };
284
+ }
285
+ /**
286
+ * helper for {@link parseMetadata} and {@link _buildForNested}
287
+ *
288
+ * @param {string} metadataScript the code of the file
289
+ * @param {string} metadataName the name of the metadata
290
+ * @returns {{fileExt:string,code:string}} returns found extension and file content
291
+ */
292
+ static prepExtractedCode(metadataScript, metadataName) {
269
293
  const regex = /<\s*script .*?>(.+?)<\s*\/script>/gms;
270
- let ssjs;
294
+ let code;
271
295
  let fileExt;
272
- const regexMatches = regex.exec(metadata.script);
296
+ const regexMatches = regex.exec(metadataScript);
273
297
  if (regexMatches?.length > 1) {
274
- ssjs = regexMatches[1];
298
+ code = regexMatches[1];
275
299
  fileExt = 'ssjs';
276
300
  } else {
277
- ssjs = metadata.script;
301
+ code = metadataScript;
278
302
  fileExt = 'html';
279
303
  Util.logger.warn(
280
- ` - Could not find script tags, saving code in ${metadata.name}.script-meta.html instead of as SSJS file.`
304
+ ` - Could not find script tags, saving code in ${metadataName}.script-meta.html instead of as SSJS file.`
281
305
  );
282
306
  }
283
- delete metadata.script;
284
- codeArr.push({
285
- subFolder: null,
286
- fileName: metadata.key,
287
- fileExt: fileExt,
288
- content: ssjs,
289
- });
290
-
291
- return { json: metadata, codeArr: codeArr, subFolder: null };
307
+ return { fileExt, code };
292
308
  }
309
+
293
310
  /**
294
311
  * should return only the json for all but asset, query and script that are saved as multiple files
295
312
  * additionally, the documentation for dataExtension and automation should be returned
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcdev",
3
- "version": "4.1.10",
3
+ "version": "4.1.11",
4
4
  "description": "Accenture Salesforce Marketing Cloud DevTools",
5
5
  "author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas",
6
6
  "license": "MIT",
@@ -64,10 +64,10 @@
64
64
  "assert": "2.0.0",
65
65
  "axios-mock-adapter": "1.21.2",
66
66
  "chai": "4.3.6",
67
- "eslint": "8.26.0",
67
+ "eslint": "8.27.0",
68
68
  "eslint-config-prettier": "8.5.0",
69
69
  "eslint-config-ssjs": "1.1.11",
70
- "eslint-plugin-jsdoc": "39.4.0",
70
+ "eslint-plugin-jsdoc": "39.6.2",
71
71
  "eslint-plugin-mocha": "10.1.0",
72
72
  "eslint-plugin-prettier": "4.2.1",
73
73
  "eslint-plugin-unicorn": "44.0.2",
@@ -63,5 +63,5 @@
63
63
  "triggeredSendDefinition"
64
64
  ]
65
65
  },
66
- "version": "4.1.10"
66
+ "version": "4.1.11"
67
67
  }