sfdx-md-merge-driver
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -5,2 +5,10 @@ # Changelog | ||
### [0.1.5](https://github.com/jayree/sfdx-md-merge-driver/compare/v0.1.4...v0.1.5) (2020-05-12) | ||
### Bug Fixes | ||
* update dependencies ([7c89e90](https://github.com/jayree/sfdx-md-merge-driver/commit/7c89e90e0cda4f646bb00aebd84177e6f031761d)) | ||
* update dependencies (use fixed version of tslib due to Cannot redefine property: default error) ([9425100](https://github.com/jayree/sfdx-md-merge-driver/commit/942510016e15db93f853285372eacdafae81add7)) | ||
### [0.1.4](https://github.com/jayree/sfdx-md-merge-driver/compare/v0.1.3...v0.1.4) (2020-02-06) | ||
@@ -7,0 +15,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MergeDriverBase = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -4,0 +5,0 @@ const command_1 = require("@oclif/command"); |
@@ -12,85 +12,88 @@ "use strict"; | ||
const pjson = new PackageJson(); | ||
class Install extends base_1.MergeDriverBase { | ||
async run() { | ||
const { flags } = this.parse(Install); | ||
if (pjson.name !== 'sfdx-md-merge-driver') { | ||
const attrFile = path.join(pjson.path, this.findAttributes(flags.global, pjson.path).replace(/^\s*~\//, process.env.HOME + '/')); | ||
const opts = flags.global ? '--global' : '--local'; | ||
shell.exec(`git config ${opts} merge."${flags.name}".name "A custom merge driver for Salesforce profiles"`, { | ||
cwd: pjson.path, | ||
}); | ||
shell.exec(`git config ${opts} merge."${flags.name}".driver "${flags.driver}"`, { | ||
cwd: pjson.path, | ||
}); | ||
shell.exec(`git config ${opts} merge."${flags.name}".recursive binary`, { | ||
cwd: pjson.path, | ||
}); | ||
mkdirp.sync(path.dirname(attrFile)); | ||
let attrContents = ''; | ||
try { | ||
const RE = new RegExp(`.* merge\\s*=\\s*${flags.name}$`); | ||
attrContents = fs | ||
.readFileSync(attrFile, 'utf8') | ||
.split(/\r?\n/) | ||
.filter(line => !line.match(RE)) | ||
let Install = /** @class */ (() => { | ||
class Install extends base_1.MergeDriverBase { | ||
async run() { | ||
const { flags } = this.parse(Install); | ||
if (pjson.name !== 'sfdx-md-merge-driver') { | ||
const attrFile = path.join(pjson.path, this.findAttributes(flags.global, pjson.path).replace(/^\s*~\//, process.env.HOME + '/')); | ||
const opts = flags.global ? '--global' : '--local'; | ||
shell.exec(`git config ${opts} merge."${flags.name}".name "A custom merge driver for Salesforce profiles"`, { | ||
cwd: pjson.path, | ||
}); | ||
shell.exec(`git config ${opts} merge."${flags.name}".driver "${flags.driver}"`, { | ||
cwd: pjson.path, | ||
}); | ||
shell.exec(`git config ${opts} merge."${flags.name}".recursive binary`, { | ||
cwd: pjson.path, | ||
}); | ||
mkdirp.sync(path.dirname(attrFile)); | ||
let attrContents = ''; | ||
try { | ||
const RE = new RegExp(`.* merge\\s*=\\s*${flags.name}$`); | ||
attrContents = fs | ||
.readFileSync(attrFile, 'utf8') | ||
.split(/\r?\n/) | ||
.filter(line => !line.match(RE)) | ||
.join('\n'); | ||
} | ||
catch (error) { } | ||
if (attrContents && !attrContents.match(/[\n\r]$/g)) { | ||
attrContents = '\n'; | ||
} | ||
attrContents += flags.files | ||
.map(f => `${f} merge=${flags.name}`) | ||
.join('\n'); | ||
attrContents += '\n'; | ||
fs.writeFileSync(attrFile, attrContents); | ||
console.error('sfdx-md-merge-driver:', flags.name, 'installed to `git config', opts + '`', 'and', attrFile); | ||
} | ||
catch (error) { } | ||
if (attrContents && !attrContents.match(/[\n\r]$/g)) { | ||
attrContents = '\n'; | ||
} | ||
attrContents += flags.files | ||
.map(f => `${f} merge=${flags.name}`) | ||
.join('\n'); | ||
attrContents += '\n'; | ||
fs.writeFileSync(attrFile, attrContents); | ||
console.error('sfdx-md-merge-driver:', flags.name, 'installed to `git config', opts + '`', 'and', attrFile); | ||
} | ||
} | ||
} | ||
Install.description = 'Set up the merge driver in the current git repository.'; | ||
/* static examples = [ | ||
`$ sfdx-md-merge-driver hello | ||
hello world from ./src/hello.ts! | ||
` | ||
]; */ | ||
Install.flags = { | ||
help: command_1.flags.help({ char: 'h' }), | ||
global: command_1.flags.boolean({ | ||
char: 'g', | ||
description: 'install to your user-level git configuration', | ||
}), | ||
driver: command_1.flags.string({ | ||
char: 'd', | ||
description: 'string to install as the driver in the git configuration', | ||
default: 'npx sfdx-md-merge-driver merge %O %A %B %P', | ||
}), | ||
name: command_1.flags.string({ | ||
char: 'n', | ||
description: 'String to use as the merge driver name in your configuration.', | ||
default: 'sfdx-md-merge-driver', | ||
}), | ||
files: command_1.flags.string({ | ||
char: 't', | ||
description: 'Filenames that will trigger this driver.', | ||
multiple: true, | ||
options: [ | ||
'*.profile', | ||
'*.profile-meta.xml', | ||
'*.permissionset', | ||
'*.permissionset-meta.xml', | ||
'*.labels', | ||
'*.labels-meta.xml', | ||
], | ||
default: [ | ||
'*.profile', | ||
'*.profile-meta.xml', | ||
'*.permissionset', | ||
'*.permissionset-meta.xml', | ||
'*.labels', | ||
'*.labels-meta.xml', | ||
], | ||
}), | ||
}; | ||
return Install; | ||
})(); | ||
exports.default = Install; | ||
Install.description = 'Set up the merge driver in the current git repository.'; | ||
/* static examples = [ | ||
`$ sfdx-md-merge-driver hello | ||
hello world from ./src/hello.ts! | ||
` | ||
]; */ | ||
Install.flags = { | ||
help: command_1.flags.help({ char: 'h' }), | ||
global: command_1.flags.boolean({ | ||
char: 'g', | ||
description: 'install to your user-level git configuration', | ||
}), | ||
driver: command_1.flags.string({ | ||
char: 'd', | ||
description: 'string to install as the driver in the git configuration', | ||
default: 'npx sfdx-md-merge-driver merge %O %A %B %P', | ||
}), | ||
name: command_1.flags.string({ | ||
char: 'n', | ||
description: 'String to use as the merge driver name in your configuration.', | ||
default: 'sfdx-md-merge-driver', | ||
}), | ||
files: command_1.flags.string({ | ||
char: 't', | ||
description: 'Filenames that will trigger this driver.', | ||
multiple: true, | ||
options: [ | ||
'*.profile', | ||
'*.profile-meta.xml', | ||
'*.permissionset', | ||
'*.permissionset-meta.xml', | ||
'*.labels', | ||
'*.labels-meta.xml', | ||
], | ||
default: [ | ||
'*.profile', | ||
'*.profile-meta.xml', | ||
'*.permissionset', | ||
'*.permissionset-meta.xml', | ||
'*.labels', | ||
'*.labels-meta.xml', | ||
], | ||
}), | ||
}; | ||
//# sourceMappingURL=install.js.map |
@@ -13,92 +13,22 @@ "use strict"; | ||
}); | ||
class Merge extends base_1.MergeDriverBase { | ||
async run() { | ||
const { args } = this.parse(Merge); | ||
const md = new (require('../utils/metadata-merger'))(args['%O'], args['%A'], args['%B']); | ||
const base = md.getBaseNodes(); | ||
const ancientNodes = md.getNodes(args['%O']); // ancestor’s version of the conflicting file | ||
const oursNodes = md.getNodes(args['%A']); // current version of the conflicting file | ||
const theirsNodes = md.getNodes(args['%B']); // other branch's version of the conflicting file | ||
console.error('sfdx-md-merge-driver: merging', args['%P']); | ||
const ancient = []; | ||
Object.keys(ancientNodes).forEach(localpart => { | ||
let nodelist = ancientNodes[localpart]; | ||
if (!Array.isArray(nodelist)) { | ||
nodelist = [nodelist]; | ||
} | ||
nodelist.forEach(node => { | ||
const uniqueNodeKey = md.buildUniqueKey(node, localpart); | ||
if (uniqueNodeKey) { | ||
ancient[uniqueNodeKey] = { | ||
nodeType: localpart, | ||
node: node, | ||
}; | ||
let Merge = /** @class */ (() => { | ||
class Merge extends base_1.MergeDriverBase { | ||
async run() { | ||
const { args } = this.parse(Merge); | ||
const md = new (require('../utils/metadata-merger'))(args['%O'], args['%A'], args['%B']); | ||
const base = md.getBaseNodes(); | ||
const ancientNodes = md.getNodes(args['%O']); // ancestor’s version of the conflicting file | ||
const oursNodes = md.getNodes(args['%A']); // current version of the conflicting file | ||
const theirsNodes = md.getNodes(args['%B']); // other branch's version of the conflicting file | ||
console.error('sfdx-md-merge-driver: merging', args['%P']); | ||
const ancient = []; | ||
Object.keys(ancientNodes).forEach(localpart => { | ||
let nodelist = ancientNodes[localpart]; | ||
if (!Array.isArray(nodelist)) { | ||
nodelist = [nodelist]; | ||
} | ||
}); | ||
}); | ||
const ours = {}; | ||
let oursIds = []; | ||
let unmatchedNodeCount = 0; | ||
Object.keys(oursNodes).forEach(localpart => { | ||
let nodelist = oursNodes[localpart]; | ||
if (!Array.isArray(nodelist)) { | ||
nodelist = [nodelist]; | ||
} | ||
nodelist.forEach(node => { | ||
const uniqueNodeKey = md.buildUniqueKeyCount(node, localpart, unmatchedNodeCount++); | ||
oursIds.push(uniqueNodeKey); | ||
ours[uniqueNodeKey] = { | ||
nodeType: localpart, | ||
node: node, | ||
// eslint-disable-next-line no-eq-null, eqeqeq | ||
existsInAncient: ancient[uniqueNodeKey] != null, | ||
isEqualsToAncient: md.areNodesEqual(node, ancient[uniqueNodeKey], localpart)[0], | ||
isEqualsToAncientFailedList: md.areNodesEqual(node, ancient[uniqueNodeKey], localpart)[1], | ||
}; | ||
}); | ||
}); | ||
let conflictCounter = 0; | ||
Object.keys(theirsNodes).forEach(localpart => { | ||
let nodelist = theirsNodes[localpart]; | ||
if (!Array.isArray(nodelist)) { | ||
nodelist = [nodelist]; | ||
} | ||
nodelist.forEach(node => { | ||
const uniqueNodeKey = md.buildUniqueKey(node, localpart); | ||
if (uniqueNodeKey) { | ||
// eslint-disable-next-line no-eq-null, eqeqeq | ||
const existsInAncient = ancient[uniqueNodeKey] != null; | ||
const isEqualsToAncient = md.areNodesEqual(node, ancient[uniqueNodeKey], localpart)[0]; | ||
let existsInOurs; /* = oursIds.filter(function(value, index, arr) { | ||
return value !== uniqueNodeKey | ||
}) */ | ||
if (oursIds.includes(uniqueNodeKey)) { | ||
existsInOurs = true; | ||
// oursIds = oursIds.filter(function(value, index, arr) { | ||
oursIds = oursIds.filter(function (value) { | ||
return value !== uniqueNodeKey; | ||
}); | ||
} | ||
else { | ||
existsInOurs = false; | ||
} | ||
const isEqualsToOurs = md.areNodesEqual(node, ours[uniqueNodeKey], localpart)[0]; | ||
const isEqualsToOursFailedList = md.areNodesEqual(node, ours[uniqueNodeKey], localpart)[1]; | ||
if ((!existsInAncient && existsInOurs && isEqualsToOurs) || | ||
(existsInAncient && | ||
((existsInOurs && (isEqualsToOurs || isEqualsToAncient)) || | ||
(!existsInOurs && isEqualsToAncient)))) { | ||
// Keep OURS | ||
// do nothing | ||
} | ||
else if (existsInAncient && | ||
existsInOurs && | ||
ours[uniqueNodeKey].isEqualsToAncient) { | ||
// existed before, not modified in ours, use theirs (incomming) | ||
// Use THEIRS | ||
ours[uniqueNodeKey].node = node; | ||
} | ||
else if (!existsInAncient && !existsInOurs) { | ||
// Use THEIRS | ||
ours[uniqueNodeKey] = { | ||
nodelist.forEach(node => { | ||
const uniqueNodeKey = md.buildUniqueKey(node, localpart); | ||
if (uniqueNodeKey) { | ||
ancient[uniqueNodeKey] = { | ||
nodeType: localpart, | ||
@@ -108,29 +38,68 @@ node: node, | ||
} | ||
else { | ||
// CONFLICT detected | ||
isEqualsToOursFailedList.forEach(entry => { | ||
// eslint-disable-next-line no-eq-null, eqeqeq | ||
if (entry == null) { | ||
Object.keys(node).forEach(nkey => { | ||
conflictCounter++; | ||
node[nkey][0] = | ||
'\n<<<<<<< CURRENT\n=======\n' + | ||
node[nkey][0] + | ||
'\n>>>>>>> OTHER\n'; | ||
}); | ||
} | ||
else { | ||
conflictCounter++; | ||
node[entry.key][0] = | ||
'\n<<<<<<< CURRENT\n' + | ||
entry.value + | ||
'\n=======\n' + | ||
node[entry.key][0] + | ||
'\n>>>>>>> OTHER\n'; | ||
} | ||
}); | ||
if (existsInOurs) { | ||
}); | ||
}); | ||
const ours = {}; | ||
let oursIds = []; | ||
let unmatchedNodeCount = 0; | ||
Object.keys(oursNodes).forEach(localpart => { | ||
let nodelist = oursNodes[localpart]; | ||
if (!Array.isArray(nodelist)) { | ||
nodelist = [nodelist]; | ||
} | ||
nodelist.forEach(node => { | ||
const uniqueNodeKey = md.buildUniqueKeyCount(node, localpart, unmatchedNodeCount++); | ||
oursIds.push(uniqueNodeKey); | ||
ours[uniqueNodeKey] = { | ||
nodeType: localpart, | ||
node: node, | ||
// eslint-disable-next-line no-eq-null, eqeqeq | ||
existsInAncient: ancient[uniqueNodeKey] != null, | ||
isEqualsToAncient: md.areNodesEqual(node, ancient[uniqueNodeKey], localpart)[0], | ||
isEqualsToAncientFailedList: md.areNodesEqual(node, ancient[uniqueNodeKey], localpart)[1], | ||
}; | ||
}); | ||
}); | ||
let conflictCounter = 0; | ||
Object.keys(theirsNodes).forEach(localpart => { | ||
let nodelist = theirsNodes[localpart]; | ||
if (!Array.isArray(nodelist)) { | ||
nodelist = [nodelist]; | ||
} | ||
nodelist.forEach(node => { | ||
const uniqueNodeKey = md.buildUniqueKey(node, localpart); | ||
if (uniqueNodeKey) { | ||
// eslint-disable-next-line no-eq-null, eqeqeq | ||
const existsInAncient = ancient[uniqueNodeKey] != null; | ||
const isEqualsToAncient = md.areNodesEqual(node, ancient[uniqueNodeKey], localpart)[0]; | ||
let existsInOurs; /* = oursIds.filter(function(value, index, arr) { | ||
return value !== uniqueNodeKey | ||
}) */ | ||
if (oursIds.includes(uniqueNodeKey)) { | ||
existsInOurs = true; | ||
// oursIds = oursIds.filter(function(value, index, arr) { | ||
oursIds = oursIds.filter(function (value) { | ||
return value !== uniqueNodeKey; | ||
}); | ||
} | ||
else { | ||
existsInOurs = false; | ||
} | ||
const isEqualsToOurs = md.areNodesEqual(node, ours[uniqueNodeKey], localpart)[0]; | ||
const isEqualsToOursFailedList = md.areNodesEqual(node, ours[uniqueNodeKey], localpart)[1]; | ||
if ((!existsInAncient && existsInOurs && isEqualsToOurs) || | ||
(existsInAncient && | ||
((existsInOurs && (isEqualsToOurs || isEqualsToAncient)) || | ||
(!existsInOurs && isEqualsToAncient)))) { | ||
// Keep OURS | ||
// do nothing | ||
} | ||
else if (existsInAncient && | ||
existsInOurs && | ||
ours[uniqueNodeKey].isEqualsToAncient) { | ||
// existed before, not modified in ours, use theirs (incomming) | ||
// Use THEIRS | ||
ours[uniqueNodeKey].node = node; | ||
} | ||
else { | ||
else if (!existsInAncient && !existsInOurs) { | ||
// Use THEIRS | ||
ours[uniqueNodeKey] = { | ||
@@ -141,74 +110,108 @@ nodeType: localpart, | ||
} | ||
else { | ||
// CONFLICT detected | ||
isEqualsToOursFailedList.forEach(entry => { | ||
// eslint-disable-next-line no-eq-null, eqeqeq | ||
if (entry == null) { | ||
Object.keys(node).forEach(nkey => { | ||
conflictCounter++; | ||
node[nkey][0] = | ||
'\n<<<<<<< CURRENT\n=======\n' + | ||
node[nkey][0] + | ||
'\n>>>>>>> OTHER\n'; | ||
}); | ||
} | ||
else { | ||
conflictCounter++; | ||
node[entry.key][0] = | ||
'\n<<<<<<< CURRENT\n' + | ||
entry.value + | ||
'\n=======\n' + | ||
node[entry.key][0] + | ||
'\n>>>>>>> OTHER\n'; | ||
} | ||
}); | ||
if (existsInOurs) { | ||
ours[uniqueNodeKey].node = node; | ||
} | ||
else { | ||
ours[uniqueNodeKey] = { | ||
nodeType: localpart, | ||
node: node, | ||
}; | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
oursIds.forEach(id => { | ||
if (ours[id]) { | ||
if (ours[id].existsInAncient && !ours[id].isEqualsToAncient) { | ||
// not exists in theirs branch, modified in ours | ||
Object.keys(ours[id].node).forEach(nkey => { | ||
conflictCounter++; | ||
ours[id].node[nkey][0] = | ||
'\n<<<<<<< CURRENT\n' + | ||
ours[id].node[nkey][0] + | ||
'\n=======\n>>>>>>> OTHER\n'; | ||
}); | ||
} | ||
else if (ours[id].isEqualsToAncient) { | ||
delete ours[id]; // deleted in theirs branch, delete in ours | ||
} | ||
} | ||
}); | ||
}); | ||
oursIds.forEach(id => { | ||
if (ours[id]) { | ||
if (ours[id].existsInAncient && !ours[id].isEqualsToAncient) { | ||
// not exists in theirs branch, modified in ours | ||
Object.keys(ours[id].node).forEach(nkey => { | ||
conflictCounter++; | ||
ours[id].node[nkey][0] = | ||
'\n<<<<<<< CURRENT\n' + | ||
ours[id].node[nkey][0] + | ||
'\n=======\n>>>>>>> OTHER\n'; | ||
}); | ||
Object.keys(ours) | ||
.sort() | ||
.forEach(function (key) { | ||
// eslint-disable-next-line no-negated-condition | ||
if (ours[key].nodeType !== '$') { | ||
if (!Array.isArray(base[md.metadataType][ours[key].nodeType])) { | ||
base[md.metadataType][ours[key].nodeType] = []; | ||
} | ||
base[md.metadataType][ours[key].nodeType].push(ours[key].node); | ||
} | ||
else if (ours[id].isEqualsToAncient) { | ||
delete ours[id]; // deleted in theirs branch, delete in ours | ||
else { | ||
base[md.metadataType][ours[key].nodeType] = ours[key].node; | ||
} | ||
}); | ||
fs.writeFileSync(args['%A'], builder | ||
.buildObject(base) | ||
.split('<<<<<<<') | ||
.join('<<<<<<<') | ||
.split('>>>>>>>') | ||
.join('>>>>>>>')); | ||
if (conflictCounter > 0) { | ||
console.error('Conflicts Found: ' + conflictCounter); | ||
// eslint-disable-next-line unicorn/no-process-exit, no-process-exit | ||
process.exit(conflictCounter); | ||
} | ||
}); | ||
Object.keys(ours) | ||
.sort() | ||
.forEach(function (key) { | ||
// eslint-disable-next-line no-negated-condition | ||
if (ours[key].nodeType !== '$') { | ||
if (!Array.isArray(base[md.metadataType][ours[key].nodeType])) { | ||
base[md.metadataType][ours[key].nodeType] = []; | ||
} | ||
base[md.metadataType][ours[key].nodeType].push(ours[key].node); | ||
} | ||
else { | ||
base[md.metadataType][ours[key].nodeType] = ours[key].node; | ||
console.error('sfdx-md-merge-driver:', args['%P'], 'successfully merged.'); | ||
// eslint-disable-next-line unicorn/no-process-exit, no-process-exit | ||
process.exit(0); | ||
} | ||
}); | ||
fs.writeFileSync(args['%A'], builder | ||
.buildObject(base) | ||
.split('<<<<<<<') | ||
.join('<<<<<<<') | ||
.split('>>>>>>>') | ||
.join('>>>>>>>')); | ||
if (conflictCounter > 0) { | ||
console.error('Conflicts Found: ' + conflictCounter); | ||
// eslint-disable-next-line unicorn/no-process-exit, no-process-exit | ||
process.exit(conflictCounter); | ||
} | ||
else { | ||
console.error('sfdx-md-merge-driver:', args['%P'], 'successfully merged.'); | ||
// eslint-disable-next-line unicorn/no-process-exit, no-process-exit | ||
process.exit(0); | ||
} | ||
} | ||
} | ||
Merge.description = 'Check for conflicts and merge them if possible.'; | ||
/* static examples = [ | ||
`$ sfdx-md-merge-driver hello | ||
hello world from ./src/hello.ts! | ||
` | ||
]; */ | ||
Merge.flags = { | ||
help: command_1.flags.help({ char: 'h' }), | ||
}; | ||
Merge.args = [ | ||
{ name: '%O', description: 'ancestor’s version', required: true }, | ||
{ name: '%A', description: 'current version', required: true }, | ||
{ name: '%B', description: "other branches' version", required: true }, | ||
{ | ||
name: '%P', | ||
description: 'pathname in which the merged result will be stored', | ||
}, | ||
]; | ||
return Merge; | ||
})(); | ||
exports.default = Merge; | ||
Merge.description = 'Check for conflicts and merge them if possible.'; | ||
/* static examples = [ | ||
`$ sfdx-md-merge-driver hello | ||
hello world from ./src/hello.ts! | ||
` | ||
]; */ | ||
Merge.flags = { | ||
help: command_1.flags.help({ char: 'h' }), | ||
}; | ||
Merge.args = [ | ||
{ name: '%O', description: 'ancestor’s version', required: true }, | ||
{ name: '%A', description: 'current version', required: true }, | ||
{ name: '%B', description: "other branches' version", required: true }, | ||
{ | ||
name: '%P', | ||
description: 'pathname in which the merged result will be stored', | ||
}, | ||
]; | ||
//# sourceMappingURL=merge.js.map |
@@ -11,53 +11,56 @@ "use strict"; | ||
const pjson = new PackageJson(); | ||
class Uninstall extends base_1.MergeDriverBase { | ||
async run() { | ||
const { flags } = this.parse(Uninstall); | ||
if (pjson.name !== 'sfdx-md-merge-driver') { | ||
const attrFile = path.join(pjson.path, this.findAttributes(flags.global, pjson.path)); | ||
const opts = flags.global ? '--global' : '--local'; | ||
try { | ||
shell.exec(`git config ${opts} --remove-section merge."${flags.name}"`, { | ||
cwd: pjson.path, | ||
silent: true, | ||
}); | ||
let Uninstall = /** @class */ (() => { | ||
class Uninstall extends base_1.MergeDriverBase { | ||
async run() { | ||
const { flags } = this.parse(Uninstall); | ||
if (pjson.name !== 'sfdx-md-merge-driver') { | ||
const attrFile = path.join(pjson.path, this.findAttributes(flags.global, pjson.path)); | ||
const opts = flags.global ? '--global' : '--local'; | ||
try { | ||
shell.exec(`git config ${opts} --remove-section merge."${flags.name}"`, { | ||
cwd: pjson.path, | ||
silent: true, | ||
}); | ||
} | ||
catch (error) { } | ||
let currAttrs; | ||
try { | ||
currAttrs = fs.readFileSync(attrFile, 'utf8').split('\n'); | ||
} | ||
catch (error) { } | ||
if (currAttrs) { | ||
let newAttrs = ''; | ||
currAttrs.forEach(attr => { | ||
const match = attr.match(/ merge=(.*)$/i); | ||
if (!match || match[1].trim() !== flags.name) { | ||
newAttrs += attr + '\n'; | ||
} | ||
}); | ||
fs.writeFileSync(attrFile, newAttrs.trim()); | ||
} | ||
console.error('sfdx-md-merge-driver:', flags.name, 'uninstalled from `git config', opts + '`', 'and', attrFile); | ||
} | ||
catch (error) { } | ||
let currAttrs; | ||
try { | ||
currAttrs = fs.readFileSync(attrFile, 'utf8').split('\n'); | ||
} | ||
catch (error) { } | ||
if (currAttrs) { | ||
let newAttrs = ''; | ||
currAttrs.forEach(attr => { | ||
const match = attr.match(/ merge=(.*)$/i); | ||
if (!match || match[1].trim() !== flags.name) { | ||
newAttrs += attr + '\n'; | ||
} | ||
}); | ||
fs.writeFileSync(attrFile, newAttrs.trim()); | ||
} | ||
console.error('sfdx-md-merge-driver:', flags.name, 'uninstalled from `git config', opts + '`', 'and', attrFile); | ||
} | ||
} | ||
} | ||
Uninstall.description = 'Remove a previously configured driver'; | ||
/* static examples = [ | ||
`$ sfdx-md-merge-driver hello | ||
hello world from ./src/hello.ts! | ||
` | ||
]; */ | ||
Uninstall.flags = { | ||
help: command_1.flags.help({ char: 'h' }), | ||
global: command_1.flags.boolean({ | ||
char: 'g', | ||
description: 'install to your user-level git configuration', | ||
}), | ||
name: command_1.flags.string({ | ||
char: 'n', | ||
description: 'String to use as the merge driver name in your configuration.', | ||
default: 'sfdx-md-merge-driver', | ||
}), | ||
}; | ||
return Uninstall; | ||
})(); | ||
exports.default = Uninstall; | ||
Uninstall.description = 'Remove a previously configured driver'; | ||
/* static examples = [ | ||
`$ sfdx-md-merge-driver hello | ||
hello world from ./src/hello.ts! | ||
` | ||
]; */ | ||
Uninstall.flags = { | ||
help: command_1.flags.help({ char: 'h' }), | ||
global: command_1.flags.boolean({ | ||
char: 'g', | ||
description: 'install to your user-level git configuration', | ||
}), | ||
name: command_1.flags.string({ | ||
char: 'n', | ||
description: 'String to use as the merge driver name in your configuration.', | ||
default: 'sfdx-md-merge-driver', | ||
}), | ||
}; | ||
//# sourceMappingURL=uninstall.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var command_1 = require("@oclif/command"); | ||
exports.run = command_1.run; | ||
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return command_1.run; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
{"version":"0.1.4","commands":{"install":{"id":"install","description":"Set up the merge driver in the current git repository.","pluginName":"sfdx-md-merge-driver","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"global":{"name":"global","type":"boolean","char":"g","description":"install to your user-level git configuration","allowNo":false},"driver":{"name":"driver","type":"option","char":"d","description":"string to install as the driver in the git configuration","default":"npx sfdx-md-merge-driver merge %O %A %B %P"},"name":{"name":"name","type":"option","char":"n","description":"String to use as the merge driver name in your configuration.","default":"sfdx-md-merge-driver"},"files":{"name":"files","type":"option","char":"t","description":"Filenames that will trigger this driver.","options":["*.profile","*.profile-meta.xml","*.permissionset","*.permissionset-meta.xml","*.labels","*.labels-meta.xml"],"default":["*.profile","*.profile-meta.xml","*.permissionset","*.permissionset-meta.xml","*.labels","*.labels-meta.xml"]}},"args":[]},"merge":{"id":"merge","description":"Check for conflicts and merge them if possible.","pluginName":"sfdx-md-merge-driver","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"%O","description":"ancestor’s version","required":true},{"name":"%A","description":"current version","required":true},{"name":"%B","description":"other branches' version","required":true},{"name":"%P","description":"pathname in which the merged result will be stored"}]},"uninstall":{"id":"uninstall","description":"Remove a previously configured driver","pluginName":"sfdx-md-merge-driver","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"global":{"name":"global","type":"boolean","char":"g","description":"install to your user-level git configuration","allowNo":false},"name":{"name":"name","type":"option","char":"n","description":"String to use as the merge driver name in your configuration.","default":"sfdx-md-merge-driver"}},"args":[]}}} | ||
{"version":"0.1.5","commands":{"install":{"id":"install","description":"Set up the merge driver in the current git repository.","pluginName":"sfdx-md-merge-driver","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"global":{"name":"global","type":"boolean","char":"g","description":"install to your user-level git configuration","allowNo":false},"driver":{"name":"driver","type":"option","char":"d","description":"string to install as the driver in the git configuration","default":"npx sfdx-md-merge-driver merge %O %A %B %P"},"name":{"name":"name","type":"option","char":"n","description":"String to use as the merge driver name in your configuration.","default":"sfdx-md-merge-driver"},"files":{"name":"files","type":"option","char":"t","description":"Filenames that will trigger this driver.","options":["*.profile","*.profile-meta.xml","*.permissionset","*.permissionset-meta.xml","*.labels","*.labels-meta.xml"],"default":["*.profile","*.profile-meta.xml","*.permissionset","*.permissionset-meta.xml","*.labels","*.labels-meta.xml"]}},"args":[]},"merge":{"id":"merge","description":"Check for conflicts and merge them if possible.","pluginName":"sfdx-md-merge-driver","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"%O","description":"ancestor’s version","required":true},{"name":"%A","description":"current version","required":true},{"name":"%B","description":"other branches' version","required":true},{"name":"%P","description":"pathname in which the merged result will be stored"}]},"uninstall":{"id":"uninstall","description":"Remove a previously configured driver","pluginName":"sfdx-md-merge-driver","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"global":{"name":"global","type":"boolean","char":"g","description":"install to your user-level git configuration","allowNo":false},"name":{"name":"name","type":"option","char":"n","description":"String to use as the merge driver name in your configuration.","default":"sfdx-md-merge-driver"}},"args":[]}}} |
{ | ||
"name": "sfdx-md-merge-driver", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "git merge driver specific for Salesforce.com Metadata", | ||
@@ -12,9 +12,9 @@ "author": "jayree @jayree", | ||
"dependencies": { | ||
"@oclif/command": "^1.5.19", | ||
"@oclif/config": "^1.13.3", | ||
"@oclif/plugin-help": "^2.2.3", | ||
"mkdirp": "0.5.1", | ||
"@oclif/command": "^1.6.1", | ||
"@oclif/config": "^1.15.1", | ||
"@oclif/plugin-help": "^3.0.0", | ||
"mkdirp": "1.0.4", | ||
"pkg-dir": "4.2.0", | ||
"shelljs": "0.8.3", | ||
"tslib": "^1.10.0", | ||
"shelljs": "0.8.4", | ||
"tslib": "1.11.1", | ||
"xml2js": "0.4.23" | ||
@@ -26,32 +26,32 @@ }, | ||
"@oclif/test": "^1.2.5", | ||
"@types/chai": "^4.2.7", | ||
"@types/mkdirp": "0.5.2", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^13.1.8", | ||
"@types/shelljs": "0.8.6", | ||
"@types/chai": "^4.2.11", | ||
"@types/mkdirp": "1.0.0", | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "^13.13.5", | ||
"@types/shelljs": "0.8.7", | ||
"@types/xml2js": "0.4.5", | ||
"@typescript-eslint/eslint-plugin": "2.16.0", | ||
"@typescript-eslint/parser": "2.16.0", | ||
"@typescript-eslint/eslint-plugin": "2.32.0", | ||
"@typescript-eslint/parser": "2.32.0", | ||
"chai": "^4.2.0", | ||
"eslint": "6.8.0", | ||
"eslint": "7.0.0", | ||
"eslint-config-oclif": "^3.1.0", | ||
"eslint-config-oclif-typescript": "^0.1.0", | ||
"eslint-config-prettier": "6.9.0", | ||
"eslint-config-prettier": "6.11.0", | ||
"eslint-import-resolver-typescript": "2.0.0", | ||
"eslint-plugin-import": "2.20.0", | ||
"eslint-plugin-prettier": "3.1.2", | ||
"eslint-plugin-import": "2.20.2", | ||
"eslint-plugin-prettier": "3.1.3", | ||
"globby": "^11.0.0", | ||
"husky": "^4.0.10", | ||
"lint-staged": "^9.5.0", | ||
"marked": "0.8.0", | ||
"husky": "^4.2.5", | ||
"lint-staged": "^10.2.2", | ||
"marked": "1.0.0", | ||
"marked-man": "^0.7.0", | ||
"mocha": "^7.0.0", | ||
"nyc": "15.0.0", | ||
"prettier": "1.19.1", | ||
"prettier-standard": "^16.1.0", | ||
"standard": "^14.3.1", | ||
"standard-version": "^7.0.1", | ||
"tap": "^14.10.6", | ||
"ts-node": "8.6.2", | ||
"typescript": "^3.7.5" | ||
"mocha": "^7.1.2", | ||
"nyc": "15.0.1", | ||
"prettier": "2.0.5", | ||
"prettier-standard": "^16.3.0", | ||
"standard": "^14.3.4", | ||
"standard-version": "^8.0.0", | ||
"tap": "^14.10.7", | ||
"ts-node": "8.10.1", | ||
"typescript": "3.9.2" | ||
}, | ||
@@ -58,0 +58,0 @@ "engines": { |
@@ -65,3 +65,3 @@ # sfdx-md-merge-driver | ||
$ sfdx-md-merge-driver (-v|--version|version) | ||
sfdx-md-merge-driver/0.1.4 darwin-x64 node-v12.13.0 | ||
sfdx-md-merge-driver/0.1.5 darwin-x64 node-v12.16.1 | ||
$ sfdx-md-merge-driver --help [COMMAND] | ||
@@ -111,3 +111,3 @@ USAGE | ||
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_ | ||
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.0.0/src/commands/help.ts)_ | ||
@@ -140,3 +140,3 @@ ## `sfdx-md-merge-driver install` | ||
_See code: [src/commands/install.ts](https://github.com/jayree/sfdx-md-merge-driver/blob/v0.1.4/src/commands/install.ts)_ | ||
_See code: [src/commands/install.ts](https://github.com/jayree/sfdx-md-merge-driver/blob/v0.1.5/src/commands/install.ts)_ | ||
@@ -161,3 +161,3 @@ ## `sfdx-md-merge-driver merge %O %A %B [%P]` | ||
_See code: [src/commands/merge.ts](https://github.com/jayree/sfdx-md-merge-driver/blob/v0.1.4/src/commands/merge.ts)_ | ||
_See code: [src/commands/merge.ts](https://github.com/jayree/sfdx-md-merge-driver/blob/v0.1.5/src/commands/merge.ts)_ | ||
@@ -178,3 +178,3 @@ ## `sfdx-md-merge-driver uninstall` | ||
_See code: [src/commands/uninstall.ts](https://github.com/jayree/sfdx-md-merge-driver/blob/v0.1.4/src/commands/uninstall.ts)_ | ||
_See code: [src/commands/uninstall.ts](https://github.com/jayree/sfdx-md-merge-driver/blob/v0.1.5/src/commands/uninstall.ts)_ | ||
<!-- commandsstop --> | ||
@@ -181,0 +181,0 @@ |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64542
852
+ Added@oclif/config@1.18.2(transitive)
+ Added@oclif/errors@1.3.5(transitive)
+ Added@oclif/plugin-help@3.3.1(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addedshelljs@0.8.4(transitive)
+ Addedtslib@1.11.1(transitive)
- Removed@oclif/plugin-help@2.2.3(transitive)
- Removedansi-regex@3.0.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedemoji-regex@7.0.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedlodash._reinterpolate@3.0.0(transitive)
- Removedlodash.template@4.5.0(transitive)
- Removedlodash.templatesettings@4.2.0(transitive)
- Removedminimist@0.0.8(transitive)
- Removedmkdirp@0.5.1(transitive)
- Removedshelljs@0.8.3(transitive)
- Removedstring-width@2.1.13.1.0(transitive)
- Removedstrip-ansi@4.0.05.2.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtslib@1.14.1(transitive)
- Removedwidest-line@2.0.1(transitive)
- Removedwrap-ansi@4.0.0(transitive)
Updated@oclif/command@^1.6.1
Updated@oclif/config@^1.15.1
Updated@oclif/plugin-help@^3.0.0
Updatedmkdirp@1.0.4
Updatedshelljs@0.8.4
Updatedtslib@1.11.1