Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// create a temp project so we can leverage force:source:convert for destructiveChanges
let tmpDeleteProj: string;
let tempDeleteProjConverted: string;
if (hasDeletions) {
tmpDeleteProj = await this.setupTmpProject(diffResults.removed, toBranch);
tempDeleteProjConverted = await this.mkTempDir();
await spawnPromise('sfdx', ['force:source:convert', '-d', tempDeleteProjConverted], { shell: true, cwd: tmpDeleteProj });
}
// create a temp project so we can leverage force:source:convert for primary deploy
const tmpProject = await this.setupTmpProject(diffResults.changed, fromBranch);
const outDir = isAbsolute(this.flags.outputdir) ? this.flags.outputdir : join(this.projectPath, this.flags.outputdir);
try {
const stat = await fs.stat(outDir);
if (stat.isDirectory()) {
let purge = false;
if (this.flags.purge) {
purge = true;
} else {
const resp = await this.ux.prompt(`The output path ${outDir} already exists. How would you like to continue? (purge | merge | exit)`);
if (resp.toLocaleLowerCase() === 'purge') {
purge = true;
} else if (resp.toLocaleLowerCase() !== 'merge') {
this.exit(1);
return;
}
}
if (purge) {
this.ux.log(`Removing all files inside of ${outDir}`);
try {
let fetchedCount = 0;
let fetchedCountPerObject = {};
am.on('dumpProgress', status => {
fetchedCount = status.fetchedCount;
fetchedCountPerObject = status.fetchedCountPerObject;
const perObjectCount = Object.keys(fetchedCountPerObject).map(object => `${object}: ${fetchedCountPerObject[object]}`).join(', ');
const message = `fetched count: ${fetchedCount}, ${perObjectCount}`;
this.ux.setSpinnerStatus(message);
});
this.ux.startSpinner('dumping records');
const csvs = await am.dumpAsCSVData(config.targets);
this.ux.stopSpinner();
this.ux.log(`fetched count: ${fetchedCount}`);
try {
await fs.stat(config.outputDir);
} catch (e) {
await fs.mkdirp(config.outputDir);
}
const results = await Promise.all(
config.targets.map(async ({ object }, i) => {
const csv = csvs[i];
const count = fetchedCountPerObject[object] || 0;
const filename = `${object}.csv`;
const filepath = path.join(config.outputDir, filename);
const bom = this.flags.excludebom ? '' : '\ufeff';
await writeFile(filepath, bom + csv, 'utf8');
return { filepath, count };
})
);
this.ux.log();
this.ux.table(