Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sfdx-git-delta

Package Overview
Dependencies
Maintainers
1
Versions
360
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sfdx-git-delta - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

lib/metadata/v47.json

4

__mocks__/fs.js

@@ -16,3 +16,3 @@ 'use strict'

const dir = path.basename(path.dirname(file))
mockFiles[dir] = mockFiles[dir] || []
mockFiles[dir] = mockFiles[dir] ?? []
mockFiles[dir].push(path.basename(file))

@@ -23,3 +23,3 @@ mockContent[file] = newMockFiles[file]

fs.readdirSync = directoryPath => mockFiles[path.basename(directoryPath)] || []
fs.readdirSync = directoryPath => mockFiles[path.basename(directoryPath)] ?? []

@@ -26,0 +26,0 @@ fs.existsSync = filePath => filePathList.has(path.basename(filePath))

'use strict'
const metadataManager = require('../../lib/metadata/metadataManager')
global.globalMetadata = metadataManager.getDefinition('directoryName', 48)
global.globalMetadata = metadataManager.getDefinition('directoryName', 49)
global.testHandlerHelper = testContext => {

@@ -6,0 +6,0 @@ describe(`test if ${testContext.handler.name}`, () => {

@@ -63,3 +63,4 @@ 'use strict'

describe(`test if package constructor`, () => {
const packageConstructor = new PackageConstructor(options)
// eslint-disable-next-line no-undef
const packageConstructor = new PackageConstructor(options, globalMetadata)
test.each(tests)(

@@ -66,0 +67,0 @@ 'can build %s destructiveChanges.xml',

@@ -14,2 +14,7 @@ 'use strict'

],
[
'territory2Models',
'force-app/main/default/territory2Models/EU/EU.territory2Model-meta.xml',
new Set(['EU']),
],
],

@@ -16,0 +21,0 @@ work: {

'use strict'
const InFile = require('../../../../lib/service/inFileHandler')
const gc = require('../../../../lib/utils/gitConstants')
const mc = require('../../../../lib/utils/metadataConstants')
const child_process = require('child_process')

@@ -37,7 +38,13 @@ const fsMocked = require('fs')

expectedData: {
workflows: { alerts: new Set(['Account.TestEA']) },
labels: { label: new Set(['TestLabel1', 'TestLabel2']) },
sharingRules: { sharingCriteriaRules: new Set(['Account.TestCBS']) },
workflows: { 'workflows.alerts': new Set(['Account.TestEA']) },
labels: {},
sharingRules: {
'sharingRules.sharingCriteriaRules': new Set(['Account.TestCBS']),
},
},
}
testContext.expectedData.labels[mc.LABEL_DIRECTORY_NAME] = new Set([
'TestLabel1',
'TestLabel2',
])

@@ -44,0 +51,0 @@ fsMocked.__setMockFiles({

@@ -27,3 +27,3 @@ 'use strict'

// eslint-disable-next-line no-undef
describe('test inTranslation', () => {
describe('test inTranslation with delta generation', () => {
beforeAll(() => {

@@ -41,1 +41,11 @@ require('fs').__setMockFiles({

})
// eslint-disable-next-line no-undef
describe('test inTranslation without delta generation', () => {
beforeAll(() => {
testContext.work.config.generateDelta = false
})
// eslint-disable-next-line no-undef
testHandlerHelper(testContext)
})

@@ -13,2 +13,12 @@ 'use strict'

],
[
'rules',
'force-app/main/default/territory2Models/EU/rules/Location.territory2Rule-meta.xml',
new Set(['EU.Location']),
],
[
'territories',
'force-app/main/default/territory2Models/EU/territories/France.territory2-meta.xml',
new Set(['EU.France']),
],
],

@@ -15,0 +25,0 @@ work: {

@@ -14,3 +14,4 @@ 'use strict'

}))
const work = repoGitDiff({ output: '', repo: '' })
// eslint-disable-next-line no-undef
const work = repoGitDiff({ output: '', repo: '' }, globalMetadata)
expect(work).toStrictEqual(output)

@@ -26,3 +27,4 @@ })

}))
const work = repoGitDiff({ output: '', repo: '' })
// eslint-disable-next-line no-undef
const work = repoGitDiff({ output: '', repo: '' }, globalMetadata)
expect(work).toMatchObject(output)

@@ -38,3 +40,4 @@ })

}))
const work = repoGitDiff({ output: '', repo: '' })
// eslint-disable-next-line no-undef
const work = repoGitDiff({ output: '', repo: '' }, globalMetadata)
expect(work).toStrictEqual(output)

@@ -50,3 +53,4 @@ })

}))
const work = repoGitDiff({ output: '', repo: '' })
// eslint-disable-next-line no-undef
const work = repoGitDiff({ output: '', repo: '' }, globalMetadata)
expect(work).toStrictEqual(output)

@@ -53,0 +57,0 @@ })

@@ -16,3 +16,3 @@ {

"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2020
},

@@ -19,0 +19,0 @@ "rules": {

@@ -5,3 +5,4 @@ {

"semi": false,
"arrowParens": "avoid",
"singleQuote": true
}

@@ -7,3 +7,2 @@ # Contributing to SFDX-Git-Delta

- [Installation](#installation)
- [Building LWC](#building-lwc)
- [Testing](#testing)

@@ -64,3 +63,3 @@ - [Git Workflow](#git-workflow)

1. [Fork the LWC repo](#fork-the-lwc-repo)
1. [Fork the sfdx-git-delta repo](#fork-the-sfdx-git-delta-repo)
1. [Create a feature branch](#create-a-feature-branch)

@@ -73,3 +72,3 @@ 1. [Make your changes](#make-your-changes)

### Fork the LWC repo
### Fork the sfdx-git-delta repo

@@ -144,3 +143,3 @@ [Fork][fork-a-repo] the [scolladon/sfdx-git-delta](https://github.com/scolladon/sfdx-git-delta) repo. Clone your fork in your local workspace and [configure][configuring-a-remote-for-a-fork] your remote repository settings.

If you've never created a pull request before, follow [these
instructions][creating-a-pull-request]. Pull request samples can be found [here](https://github.com/salesforce/lwc/pulls)
instructions][creating-a-pull-request]. Pull request samples can be found [here](https://github.com/salesforce/sfdx-git-delta/pulls)

@@ -147,0 +146,0 @@ ### Update the pull request

@@ -54,3 +54,3 @@ 'use strict'

const work = treatDiff(config, lines, metadata)
treatPackages(work.diffs, config)
treatPackages(work.diffs, config, metadata)
return work

@@ -72,4 +72,4 @@ }

const treatPackages = (dcJson, config) => {
const pc = new PackageConstructor(config)
const treatPackages = (dcJson, config, metadata) => {
const pc = new PackageConstructor(config, metadata)
;[

@@ -76,0 +76,0 @@ {

@@ -328,2 +328,9 @@ [

{
"directoryName": "portals",
"inFolder": false,
"metaFile": false,
"suffix": "portal",
"xmlName": "Portal"
},
{
"directoryName": "customMetadata",

@@ -357,2 +364,3 @@ "inFolder": false,

"WorkflowOutboundMessage",
"WorkflowFlowAction",
"WorkflowRule"

@@ -616,2 +624,9 @@ ],

{
"directoryName": "workSkillRoutings",
"inFolder": false,
"metaFile": false,
"suffix": "workSkillRouting",
"xmlName": "WorkSkillRouting"
},
{
"directoryName": "authproviders",

@@ -671,2 +686,9 @@ "inFolder": false,

{
"directoryName": "iframeWhiteListUrlSettings",
"inFolder": false,
"metaFile": false,
"suffix": "iframeWhiteListUrlSettings",
"xmlName": "IframeWhiteListUrlSettings"
},
{
"directoryName": "communities",

@@ -735,2 +757,9 @@ "inFolder": false,

{
"directoryName": "appointmentSchedulingPolicies",
"inFolder": false,
"metaFile": false,
"suffix": "policy",
"xmlName": "AppointmentSchedulingPolicy"
},
{
"directoryName": "Canvases",

@@ -848,2 +877,9 @@ "inFolder": false,

{
"directoryName": "audience",
"inFolder": false,
"metaFile": false,
"suffix": "audience",
"xmlName": "Audience"
},
{
"directoryName": "flowCategories",

@@ -934,2 +970,30 @@ "inFolder": false,

{
"directoryName": "territory2Types",
"inFolder": false,
"metaFile": false,
"suffix": "territory2Type",
"xmlName": "Territory2Type"
},
{
"directoryName": "territory2Models",
"inFolder": false,
"metaFile": false,
"suffix": "territory2Model",
"xmlName": "Territory2Model"
},
{
"directoryName": "rules",
"inFolder": false,
"metaFile": false,
"suffix": "territory2Rule",
"xmlName": "Territory2Rule"
},
{
"directoryName": "territories",
"inFolder": false,
"metaFile": false,
"suffix": "territory2",
"xmlName": "Territory2"
},
{
"directoryName": "campaignInfluenceModels",

@@ -1103,3 +1167,3 @@ "inFolder": false,

{
"directoryName": "alerts",
"directoryName": "workflows.alerts",
"inFolder": false,

@@ -1112,3 +1176,3 @@ "metaFile": false,

{
"directoryName": "fieldUpdates",
"directoryName": "workflows.fieldUpdates",
"inFolder": false,

@@ -1121,3 +1185,3 @@ "metaFile": false,

{
"directoryName": "label",
"directoryName": "labels.labels",
"inFolder": false,

@@ -1130,3 +1194,3 @@ "metaFile": false,

{
"directoryName": "outboundMessages",
"directoryName": "workflows.outboundMessages",
"inFolder": false,

@@ -1139,3 +1203,3 @@ "metaFile": false,

{
"directoryName": "rules",
"directoryName": "workflows.rules",
"inFolder": false,

@@ -1148,3 +1212,3 @@ "metaFile": false,

{
"directoryName": "sharingCriteriaRules",
"directoryName": "sharingRules.sharingCriteriaRules",
"inFolder": false,

@@ -1157,3 +1221,3 @@ "metaFile": false,

{
"directoryName": "sharingGuestRules",
"directoryName": "sharingRules.sharingGuestRules",
"inFolder": false,

@@ -1166,3 +1230,3 @@ "metaFile": false,

{
"directoryName": "sharingOwnerRules",
"directoryName": "sharingRules.sharingOwnerRules",
"inFolder": false,

@@ -1175,3 +1239,3 @@ "metaFile": false,

{
"directoryName": "sharingTerritoryRules",
"directoryName": "sharingRules.sharingTerritoryRules",
"inFolder": false,

@@ -1184,3 +1248,3 @@ "metaFile": false,

{
"directoryName": "tasks",
"directoryName": "workflows.tasks",
"inFolder": false,

@@ -1187,0 +1251,0 @@ "metaFile": false,

@@ -777,3 +777,3 @@ [

{
"directoryName": "territory2Models",
"directoryName": "rules",
"inFolder": false,

@@ -785,3 +785,3 @@ "metaFile": false,

{
"directoryName": "territory2Models",
"directoryName": "territories",
"inFolder": false,

@@ -912,3 +912,3 @@ "metaFile": false,

{
"directoryName": "alerts",
"directoryName": "workflows.alerts",
"inFolder": false,

@@ -921,3 +921,3 @@ "metaFile": false,

{
"directoryName": "fieldUpdates",
"directoryName": "workflows.fieldUpdates",
"inFolder": false,

@@ -930,3 +930,3 @@ "metaFile": false,

{
"directoryName": "label",
"directoryName": "labels.labels",
"inFolder": false,

@@ -939,3 +939,3 @@ "metaFile": false,

{
"directoryName": "outboundMessages",
"directoryName": "workflows.outboundMessages",
"inFolder": false,

@@ -948,3 +948,3 @@ "metaFile": false,

{
"directoryName": "rules",
"directoryName": "workflows.rules",
"inFolder": false,

@@ -957,3 +957,3 @@ "metaFile": false,

{
"directoryName": "sharingCriteriaRules",
"directoryName": "sharingRules.sharingCriteriaRules",
"inFolder": false,

@@ -966,3 +966,3 @@ "metaFile": false,

{
"directoryName": "sharingGuestRules",
"directoryName": "sharingRules.sharingGuestRules",
"inFolder": false,

@@ -975,3 +975,3 @@ "metaFile": false,

{
"directoryName": "sharingOwnerRules",
"directoryName": "sharingRules.sharingOwnerRules",
"inFolder": false,

@@ -984,3 +984,3 @@ "metaFile": false,

{
"directoryName": "sharingTerritoryRules",
"directoryName": "sharingRules.sharingTerritoryRules",
"inFolder": false,

@@ -993,3 +993,3 @@ "metaFile": false,

{
"directoryName": "tasks",
"directoryName": "workflows.tasks",
"inFolder": false,

@@ -996,0 +996,0 @@ "metaFile": false,

'use strict'
const xmlbuilder = require('xmlbuilder')
const metadataManager = require('./metadata/metadataManager')
const xmlConf = { indent: ' ', newline: '\n', pretty: true }
module.exports = class PackageConstructor {
constructor(config) {
constructor(config, metadata) {
this.config = config
this.metadata = metadata
}

@@ -15,9 +15,6 @@

}
const metadata = metadataManager.getDefinition(
'directoryName',
this.config.apiVersion
)
const xml = getXML()
Object.keys(strucDiffPerType)
.filter(type => Object.prototype.hasOwnProperty.call(metadata, type))
.filter(type => Object.prototype.hasOwnProperty.call(this.metadata, type))
.forEach(metadataType =>

@@ -30,3 +27,3 @@ [...strucDiffPerType[metadataType]] // transform set to array

.ele('name')
.t(metadata[metadataType].xmlName)
.t(this.metadata[metadataType].xmlName)
)

@@ -33,0 +30,0 @@ xml.ele('version').t(`${this.config.apiVersion}.0`)

@@ -8,6 +8,8 @@ 'use strict'

const OBJECT_TYPE = 'objects'
class CustomObjectHandler extends StandardHandler {
handleAddition() {
super.handleAddition()
if (!this.config.generateDelta) return
if (!this.config.generateDelta || this.type !== OBJECT_TYPE) return
const fieldsFolder = path.join(

@@ -14,0 +16,0 @@ path.parse(this.line).dir,

@@ -14,3 +14,3 @@ 'use strict'

const FULLNAME_XML_TAG = new RegExp(`<${FULLNAME}>(.*)</${FULLNAME}>`)
const XML_TAG = new RegExp('<(.*)>')
const XML_TAG = new RegExp(`^[${gc.MINUS}${gc.PLUS}]?\\s*<([^(/><.)]+)>\\s*$`)
const XML_HEADER = '<?xml version="1.0" encoding="utf-8"?>\n'

@@ -30,3 +30,3 @@ const XML_PARSER_OPTION = {

super(line, type, work, metadata)
this.customLabelMetadata = this.metadata[mc.LABEL_DIRECTORY_NAME]
this.parentMetadata = this.metadata[this.type]
this.xmlObjectToPackageType = Object.keys(this.metadata)

@@ -36,2 +36,3 @@ .filter(meta => !!this.metadata[meta].xmlTag)

acc[this.metadata[meta].xmlTag] = this.metadata[meta]
return acc

@@ -61,4 +62,6 @@ }, {})

subType =>
(metadataContent[subType] = metadataContent[subType].filter(
elem => toAdd[subType] && toAdd[subType].has(elem.fullName)
(metadataContent[subType] = metadataContent[subType].filter(elem =>
toAdd[this.xmlObjectToPackageType[subType].directoryName]?.has(
elem.fullName
)
))

@@ -79,13 +82,15 @@ )

fullName = line.match(FULLNAME_XML_TAG)[1]
subType = potentialType
} else if (XML_TAG.test(line)) {
potentialType = line.match(XML_TAG)[1]
subType = `${this.parentMetadata.directoryName}.${potentialType}`
}
const xmlTagMatchResult = line.match(XML_TAG)
if (!!xmlTagMatchResult && !!xmlTagMatchResult[1]) {
potentialType = xmlTagMatchResult[1]
}
if (!subType || !fullName) return
if (line.startsWith(gc.MINUS) && line.includes(FULLNAME)) {
toRemove[subType] = toRemove[subType] || new Set()
toRemove[subType] = toRemove[subType] ?? new Set()
toRemove[subType].add(fullName)
subType = fullName = null
} else if (line.startsWith(gc.PLUS) || line.startsWith(gc.MINUS)) {
toAdd[subType] = toAdd[subType] || new Set()
toAdd[subType] = toAdd[subType] ?? new Set()
toAdd[subType].add(fullName)

@@ -136,6 +141,11 @@ }

result.authorizedKeys.forEach(subType => {
let meta = metadataContent[subType]
if (!Array.isArray(meta)) meta = [meta]
const meta = Array.isArray(metadataContent[subType])
? metadataContent[subType]
: [metadataContent[subType]]
meta.forEach(value =>
this._fillPackageFromDiff(packageObject, subType, value.fullName)
this._fillPackageFromDiff(
packageObject,
`${this.parentMetadata.directoryName}.${subType}`,
value.fullName
)
)

@@ -146,12 +156,10 @@ })

_fillPackageFromDiff(packageObject, subType, value) {
const _type =
subType === this.customLabelMetadata.xmlTag
? this.customLabelMetadata.directoryName
: subType
const elementFullName = `${(_type !== this.customLabelMetadata.directoryName
? `${path.basename(this.line).split('.')[0]}.`
: '') + value}`
const elementFullName = `${
(subType !== mc.LABEL_DIRECTORY_NAME
? `${path.basename(this.line).split('.')[0]}.`
: '') + value
}`
packageObject[_type] = packageObject[_type] || new Set()
packageObject[_type].add(elementFullName)
packageObject[subType] = packageObject[subType] ?? new Set()
packageObject[subType].add(elementFullName)
}

@@ -158,0 +166,0 @@ }

@@ -26,5 +26,6 @@ 'use strict'

)
folderName = `${folderName}.${this.metadata[
this.type
].xmlName.toLowerCase() + mc.INFOLDER_METAFILE_SUFFIX}`
folderName = `${folderName}.${
this.metadata[this.type].xmlName.toLowerCase() +
mc.INFOLDER_METAFILE_SUFFIX
}`

@@ -38,3 +39,3 @@ this._copyFiles(

_fillPackage(packageObject) {
packageObject[this.type] = packageObject[this.type] || new Set()
packageObject[this.type] = packageObject[this.type] ?? new Set()

@@ -41,0 +42,0 @@ packageObject[this.type].add(

@@ -82,3 +82,3 @@ 'use strict'

_fillPackage(packageObject) {
packageObject[this.type] = packageObject[this.type] || new Set()
packageObject[this.type] = packageObject[this.type] ?? new Set()
packageObject[this.type].add(this._getElementName())

@@ -85,0 +85,0 @@ }

@@ -20,3 +20,3 @@ 'use strict'

})
if (!!data && data.includes(mc.MASTER_DETAIL_TAG)) {
if (data?.includes(mc.MASTER_DETAIL_TAG)) {
const customObjectDirPath = this.splittedLine

@@ -42,3 +42,3 @@ .slice(0, [this.splittedLine.indexOf(this.type)])

_fillPackage(packageObject) {
packageObject[this.type] = packageObject[this.type] || new Set()
packageObject[this.type] = packageObject[this.type] ?? new Set()
const prefix = this.splittedLine[this.splittedLine.indexOf(this.type) - 1]

@@ -45,0 +45,0 @@

@@ -31,5 +31,8 @@ 'use strict'

reports: InFolder,
rules: SubCustomObject,
sharingReasons: SubCustomObject,
sharingRules: InFile,
staticresources: InResource,
territories: SubCustomObject,
territory2Models: CustomObject,
validationRules: SubCustomObject,

@@ -36,0 +39,0 @@ webLinks: SubCustomObject,

@@ -6,3 +6,3 @@ 'use strict'

const FIELD_DIRECTORY_NAME = 'fields'
const LABEL_DIRECTORY_NAME = 'label'
const LABEL_DIRECTORY_NAME = 'labels.labels'
const OBJECT_TRANSLATION_META_XML_SUFFIX = `objectTranslation${METAFILE_SUFFIX}`

@@ -9,0 +9,0 @@ const INFOLDER_METAFILE_SUFFIX = `Folder${METAFILE_SUFFIX}`

'use strict'
const childProcess = require('child_process')
const cpUtils = require('./childProcessUtils')
const metadataManager = require('../metadata/metadataManager')
const gc = require('./gitConstants')

@@ -11,8 +10,3 @@ const os = require('os')

module.exports = config => {
const metadata = metadataManager.getDefinition(
'directoryName',
config.apiVersion
)
module.exports = (config, metadata) => {
const { stdout: diff } = childProcess.spawnSync(

@@ -19,0 +13,0 @@ 'git',

{
"name": "sfdx-git-delta",
"version": "3.3.0",
"version": "3.3.1",
"description": "Generate the sfdx content in source format and destructive change from two git commits",

@@ -12,3 +12,3 @@ "keyword": [

"engines": {
"node": ">=10.16.0"
"node": ">=14.6.0"
},

@@ -43,5 +43,5 @@ "main": "index.js",

"fast-xml-parser": "^3.17.4",
"fs-extra": "^8.1.0",
"fs-extra": "^9.0.1",
"git-state": "^4.1.0",
"xmlbuilder": "^13.0.2"
"xmlbuilder": "^15.1.1"
},

@@ -62,10 +62,10 @@ "license": "MIT",

"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"husky": "^3.0.2",
"jest": "^26.0.1",
"lint-staged": "^9.2.1",
"prettier": "^1.19.1",
"prettier-eslint": "^9.0.0"
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"jest": "^26.1.0",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"prettier-eslint": "^11.0.0"
},

@@ -72,0 +72,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc