@ds-sfdc/sfparty 1.4.7 → 1.4.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ds-sfdc/sfparty",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "description": "Salesforce metadata XML splitter for CI/CD",
5
5
  "type": "module",
6
6
  "repository": {
@@ -4,21 +4,36 @@ import * as path from 'path'
4
4
  import * as yaml from 'js-yaml'
5
5
  import { Parser } from 'xml2js'
6
6
 
7
+ String.prototype.replaceSpecialChars = function () {
8
+ return this.replace(/\*/g, '\u002a')
9
+ .replace(/\?/g, '\u003f')
10
+ .replace(/</g, '\u003c')
11
+ .replace(/>/g, '\u003e')
12
+ .replace(/"/g, '\u0022')
13
+ .replace(/\|/g, '\u007c')
14
+ .replace(/\\/g, '\u005c')
15
+ .replace(/:/g, '\u003a')
16
+ }
17
+
7
18
  export function directoryExists({ dirPath, fs }) {
19
+ dirPath = dirPath.replaceSpecialChars()
8
20
  return fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory()
9
21
  }
10
22
 
11
23
  export function fileExists({ filePath, fs }) {
24
+ filePath = filePath.replaceSpecialChars()
12
25
  return fs.existsSync(filePath) && fs.statSync(filePath).isFile()
13
26
  }
14
27
 
15
28
  export function createDirectory(dirPath, fsTmp = fs) {
29
+ dirPath = dirPath.replaceSpecialChars()
16
30
  if (!fsTmp.existsSync(dirPath)) {
17
31
  fsTmp.mkdirSync(dirPath, { recursive: true })
18
32
  }
19
33
  }
20
34
 
21
35
  export function deleteDirectory(dirPath, recursive = false, fsTmp = fs) {
36
+ dirPath = dirPath.replaceSpecialChars()
22
37
  if (!directoryExists({ dirPath, fs: fsTmp })) {
23
38
  return false
24
39
  } else {
@@ -39,6 +54,7 @@ export function deleteDirectory(dirPath, recursive = false, fsTmp = fs) {
39
54
  }
40
55
 
41
56
  export function getFiles(dirPath, filter = undefined, fsTmp = fs) {
57
+ dirPath = dirPath.replaceSpecialChars()
42
58
  const filesList = []
43
59
  if (directoryExists({ dirPath, fs: fsTmp })) {
44
60
  fsTmp.readdirSync(dirPath).forEach((file) => {
@@ -62,6 +78,7 @@ export function getFiles(dirPath, filter = undefined, fsTmp = fs) {
62
78
  }
63
79
 
64
80
  export function getDirectories(dirPath, fsTmp = fs) {
81
+ dirPath = dirPath.replaceSpecialChars()
65
82
  if (directoryExists({ dirPath, fs: fsTmp })) {
66
83
  return fsTmp
67
84
  .readdirSync(dirPath, { withFileTypes: true })
@@ -73,6 +90,7 @@ export function getDirectories(dirPath, fsTmp = fs) {
73
90
  }
74
91
 
75
92
  export function deleteFile(filePath, fsTmp = fs) {
93
+ filePath = filePath.replaceSpecialChars()
76
94
  if (!fileExists({ filePath, fs: fsTmp })) {
77
95
  return false
78
96
  } else {
@@ -81,6 +99,7 @@ export function deleteFile(filePath, fsTmp = fs) {
81
99
  }
82
100
 
83
101
  export function fileInfo(filePath, fsTmp = fs) {
102
+ filePath = filePath.replaceSpecialChars()
84
103
  return {
85
104
  dirname: path.join(path.dirname(filePath)), //something/folder/example
86
105
  basename: path.basename(filePath, path.extname(filePath)), //example
@@ -100,6 +119,7 @@ export function saveFile(
100
119
  fsTmp = fs,
101
120
  ) {
102
121
  try {
122
+ fileName = fileName.replaceSpecialChars()
103
123
  switch (format) {
104
124
  case 'json':
105
125
  let jsonString = JSON.stringify(json, null, '\t')
@@ -119,6 +139,7 @@ export function saveFile(
119
139
 
120
140
  export function readFile(filePath, convert = true, fsTmp = fs) {
121
141
  try {
142
+ filePath = filePath.replaceSpecialChars()
122
143
  let result = undefined
123
144
  if (fileExists({ filePath, fs: fsTmp })) {
124
145
  const data = fsTmp.readFileSync(filePath, {
@@ -167,6 +188,7 @@ export function writeFile(
167
188
  fsTmp = fs,
168
189
  ) {
169
190
  try {
191
+ fileName = fileName.replaceSpecialChars()
170
192
  // write data to the file
171
193
  fsTmp.writeFileSync(fileName, data)
172
194
 
@@ -188,6 +210,7 @@ export function find(filename, root, fsTmp = fs) {
188
210
  root = root || process.cwd()
189
211
 
190
212
  if (!filename) throw new Error('filename is required')
213
+ filename = filename.replaceSpecialChars()
191
214
 
192
215
  if (filename.indexOf('/') !== -1 || filename === '..') {
193
216
  throw new Error('filename must be just a filename and not a path')
@@ -20,7 +20,7 @@ export const metadataDefinition = {
20
20
  sortKeys: {
21
21
  alerts: 'fullName',
22
22
  fieldUpdates: 'fullName',
23
- flowActions: 'label',
23
+ flowActions: 'fullName',
24
24
  knowledgePublishes: 'label',
25
25
  outboundMessages: 'fullName',
26
26
  rules: 'fullName',