@ds-sfdc/sfparty 1.3.2 → 1.3.4

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/README.md CHANGED
@@ -46,7 +46,7 @@ sfparty combine
46
46
  -f, --format format to use yaml (default) or json
47
47
  -s, --source package directory path specified in sfdx-project.json
48
48
  -t, --target target path to directory to create yaml/json files
49
- -g, --git process files based on git commits. This option does not require a value.
49
+ -g, --git combine files based on git commits
50
50
  -h, --help Show help
51
51
  ```
52
52
 
@@ -139,6 +139,9 @@ sfparty combine --git
139
139
  ## CI/CD
140
140
  sfparty is meant to be a supplemental addition to your CI/CD process. Your pipeline should already build out a `package.xml` and `destructiveChanges.xml`. When sfparty runs it will do a `git diff` and append changes to the files. You can use a utility like [sfdx-git-delta](https://www.npmjs.com/package/sfdx-git-delta) to build out the package.
141
141
  ```
142
+ Command:
143
+ sfparty combine --git
144
+
142
145
  Required:
143
146
  -g, --git process files based on git commits. This option does not require a value.
144
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ds-sfdc/sfparty",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Salesforce metadata XML splitter for CI/CD",
5
5
  "type": "module",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -11,7 +11,7 @@ import convertHrtime from 'convert-hrtime'
11
11
  import axios from 'axios'
12
12
  import { marked } from 'marked'
13
13
  import markedTerminal from 'marked-terminal'
14
-
14
+ import * as pkgObj from '../package.json' assert { type: "json" }
15
15
  import * as fileUtils from './lib/fileUtils.js'
16
16
  import * as yargOptions from './meta/yargs.js'
17
17
  import * as metadataSplit from './party/split.js'
@@ -23,7 +23,6 @@ import * as workflowDefinition from './meta/Workflows.js'
23
23
  import { checkVersion } from './lib/checkVersion.js'
24
24
  import * as git from './lib/gitUtils.js'
25
25
 
26
- const pkgObj = fileUtils.readFile('package.json')
27
26
  const processStartTime = process.hrtime.bigint()
28
27
 
29
28
  marked.setOptions({
@@ -140,7 +139,7 @@ yargs(hideBin(process.argv))
140
139
  .check(yargCheck)
141
140
  },
142
141
  handler: (argv) => {
143
- checkVersion(axios, exec, pkgObj.version, true)
142
+ checkVersion(axios, exec, pkgObj.default.version, true)
144
143
  }
145
144
  })
146
145
  .command({
@@ -155,7 +154,7 @@ yargs(hideBin(process.argv))
155
154
  .check(yargCheck)
156
155
  },
157
156
  handler: (argv) => {
158
- checkVersion(axios, exec, pkgObj.version)
157
+ checkVersion(axios, exec, pkgObj.default.version)
159
158
  global.format = argv.format
160
159
  splitHandler(argv, processStartTime)
161
160
  }
@@ -172,7 +171,7 @@ yargs(hideBin(process.argv))
172
171
  .check(yargCheck)
173
172
  },
174
173
  handler: (argv) => {
175
- checkVersion(axios, exec, pkgObj.version)
174
+ checkVersion(axios, exec, pkgObj.default.version)
176
175
  global.format = argv.format
177
176
  const startProm = new Promise((resolve, reject) => {
178
177
  if (argv.git !== undefined) {
@@ -603,7 +602,7 @@ function displayHeader() {
603
602
  horizontal: '─',
604
603
  vertical: '│',
605
604
  }
606
- let versionString = `sfparty v${pkgObj.version}${(process.stdout.columns > pkgObj.description.length + 15) ? ' - ' + pkgObj.description : ''}`
605
+ let versionString = `sfparty v${pkgObj.default.version}${(process.stdout.columns > pkgObj.default.description.length + 15) ? ' - ' + pkgObj.default.description : ''}`
607
606
  let titleMessage = `${global.icons.party} ${chalk.yellowBright(versionString)} ${global.icons.party}`
608
607
  titleMessage = titleMessage.padEnd((process.stdout.columns / 2) + versionString.length / 1.65)
609
608
  titleMessage = titleMessage.padStart(process.stdout.columns)
@@ -5,10 +5,11 @@ import * as fileUtils from './fileUtils.js'
5
5
  import * as packageDefinition from '../meta/Package.js'
6
6
 
7
7
  export class Package {
8
- #packageJSON = undefined
8
+
9
9
 
10
10
  constructor(xmlPath) {
11
11
  this.xmlPath = xmlPath
12
+ this.packageJSON = undefined
12
13
  }
13
14
 
14
15
  getPackageXML() {
@@ -16,7 +17,7 @@ export class Package {
16
17
  return new Promise((resolve, reject) => {
17
18
  if (that.xmlPath === undefined) throw new Error('Package not initialized')
18
19
 
19
- let fileName = path.join(global.__basedir, that.xmlPath)
20
+ let fileName = path.resolve(that.xmlPath)
20
21
  if (fileUtils.fileExists(fileName) && global.git.append) {
21
22
  let data = fileUtils.readFile(fileName)
22
23
  data
@@ -40,18 +41,18 @@ export class Package {
40
41
  } catch (error) {
41
42
  json.Package.version = packageDefinition.metadataDefinition.fallbackVersion
42
43
  }
43
- that.#packageJSON = json
44
+ that.packageJSON = json
44
45
  if (json.Package.types !== undefined) transformJSON(json.Package.types)
45
46
  }
46
47
  }
47
48
 
48
49
  addMember(type, member) {
49
50
  const that = this
50
- if (that.#packageJSON === undefined) throw new Error('getPackageXML must be called before adding members')
51
+ if (that.packageJSON === undefined) throw new Error('getPackageXML must be called before adding members')
51
52
  if (type === undefined) throw new Error('An undefined type was received when attempting to add a member')
52
53
  if (member === undefined) throw new Error('An undefined member was received when attempting to add a member')
53
54
 
54
- const packageJSON = that.#packageJSON
55
+ const packageJSON = that.packageJSON
55
56
  let foundMember = false
56
57
  let foundAsterisk = false
57
58
  let typeJSON = undefined
@@ -83,7 +84,7 @@ export class Package {
83
84
  // exit if member already exists
84
85
  if (foundMember) return
85
86
  if (foundAsterisk) {
86
- global.logger.warn(`Found ${chalk.bgBlackBright('*')} in type: ${type}.`)
87
+ // global.logger.warn(`Found ${chalk.bgBlackBright('*')} in type: ${type}.`)
87
88
  return
88
89
  }
89
90
 
@@ -107,7 +108,7 @@ export class Package {
107
108
 
108
109
  savePackage() {
109
110
  let that = this
110
- let json = that.#packageJSON.Package
111
+ let json = that.packageJSON.Package
111
112
  json.$.xmlns = json.$.xmlns.replace('http:', 'https:')
112
113
 
113
114
  const builder = new xml2js.Builder(
@@ -153,3 +154,5 @@ function xml2json(currentValue) {
153
154
  if (currentValue == 'false') currentValue = false
154
155
  return currentValue
155
156
  }
157
+
158
+ // Create JEST tests that cover 100% of the code
@@ -130,7 +130,9 @@ export class Combine {
130
130
  function processStart(that) {
131
131
  let success = getXML(that)
132
132
  if (success) {
133
- if (!that.metadataDefinition.packageTypeIsDirectory) that.#addPkg.addMember(that.#root, that.#fileName.shortName)
133
+ if (!that.metadataDefinition.packageTypeIsDirectory && global.git.enabled) {
134
+ that.#addPkg.addMember(that.#root, that.#fileName.shortName)
135
+ }
134
136
  saveXML(that)
135
137
  if (global.git.enabled) savePackageXML(that)
136
138
  return true
@@ -143,7 +145,9 @@ export class Combine {
143
145
  .replace('[%5]', that.#fileName.shortName)
144
146
  )
145
147
  logUpdate.done()
146
- if (!that.metadataDefinition.packageTypeIsDirectory) that.#desPkg.addMember(that.#root, that.#fileName.shortName)
148
+ if (!that.metadataDefinition.packageTypeIsDirectory && global.git.enabled) {
149
+ that.#desPkg.addMember(that.#root, that.#fileName.shortName)
150
+ }
147
151
  deleteFile(that.#fileName.fullName)
148
152
  if (global.git.enabled) savePackageXML(that)
149
153
  return 'deleted'
@@ -270,7 +274,9 @@ export class Combine {
270
274
  }
271
275
 
272
276
  if (that.metadataDefinition.packageTypeIsDirectory) {
273
- that.#desPkg.addMember(that.#root, fileObj.shortName.replace(`.${global.format}`, ''))
277
+ if (global.git.enabled) {
278
+ that.#desPkg.addMember(that.#root, fileObj.shortName.replace(`.${global.format}`, ''))
279
+ }
274
280
  }
275
281
  return true
276
282
  }
@@ -313,7 +319,9 @@ export class Combine {
313
319
 
314
320
  if (that.metadataDefinition.packageTypeIsDirectory) {
315
321
  if (fileObj.fullName !== path.join(that.sourceDir, that.metaDir, `main.${global.format}`)) {
316
- that.#addPkg.addMember(that.#root, fileObj.shortName.replace(`.${global.format}`, ''))
322
+ if (global.git.enabled) {
323
+ that.#addPkg.addMember(that.#root, fileObj.shortName.replace(`.${global.format}`, ''))
324
+ }
317
325
  }
318
326
  }
319
327