qforce
Version:
Commands to help with salesforce development.
70 lines (69 loc) • 3.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("@oclif/command");
const utility_1 = require("../../helper/utility");
const path = require('path');
const fs = require('fs');
class DevConfig extends command_1.Command {
doInit(flags) {
if (!fs.existsSync(utility_1.getAbsolutePath('.qforce'))) {
fs.mkdirSync(utility_1.getAbsolutePath('.qforce'));
}
if (!fs.existsSync(utility_1.getAbsolutePath('.qforce/query.soql'))) {
fs.writeFileSync(utility_1.getAbsolutePath('.qforce/query.soql'), 'SELECT Id, Name FROM Account LIMIT 1', { encoding: 'utf-8' });
}
if (!fs.existsSync(utility_1.getAbsolutePath('.qforce/exe.cls'))) {
fs.writeFileSync(utility_1.getAbsolutePath('.qforce/exe.cls'), 'System.debug(UserInfo.getUserName());', { encoding: 'utf-8' });
}
if (fs.existsSync(utility_1.getAbsolutePath('.qforce/settings.json')))
return;
const defaultSettings = {
queryFilePath: ".qforce/query.soql",
queryResultsPath: ".qforce/query.csv",
exeFilePath: ".qforce/exe.cls",
exeResultsPath: ".qforce/exe.log"
};
fs.writeFileSync(utility_1.getAbsolutePath('.qforce/settings.json'), JSON.stringify(defaultSettings, null, 2), { encoding: 'utf-8' });
}
setConfig(flags) {
let settings;
if (fs.existsSync(utility_1.getAbsolutePath('.qforce/settings.json'))) {
settings = JSON.parse(fs.readFileSync(utility_1.getAbsolutePath('.qforce/settings.json')));
}
for (let key in flags) {
settings[key] = flags[key];
}
if (settings) {
fs.writeFileSync(utility_1.getAbsolutePath('.qforce/settings.json'), JSON.stringify(settings, null, 2), { encoding: 'utf-8' });
}
}
async run() {
const { args, flags } = this.parse(DevConfig);
if (flags.init)
this.doInit(flags);
else
this.setConfig(flags);
}
}
exports.default = DevConfig;
DevConfig.description = 'describe the command here';
DevConfig.aliases = ['config', 'dev:config'];
DevConfig.flags = {
help: command_1.flags.help({ char: 'h' }),
init: command_1.flags.boolean({ description: 'Initiate qforce settings.' }),
global: command_1.flags.boolean({ char: 'g', description: 'To set or retrieve setting from global.' }),
targetusername: command_1.flags.string({ char: 'u', description: 'Set or retrieve targetusername.' }),
queryFilePath: command_1.flags.string({ description: 'Path of query file to use with query command.' }),
queryResultsPath: command_1.flags.string({ description: 'Path to save results of query command.' }),
exeFilePath: command_1.flags.string({ description: 'Path to file to execute for exe command.' }),
exeResultsPath: command_1.flags.string({ description: 'Path to save log of exe command execution.' }),
bulkStatusRetries: command_1.flags.integer({ description: 'Number of retries to poll status of bulk job.' }),
bulkStatusInterval: command_1.flags.integer({ description: 'Interval in milliseconds for polling bluk job status.' }),
lastDeployCommit: command_1.flags.string({ description: 'Commit hash of the last commit that was deployed.' }),
developBranch: command_1.flags.string({ description: 'Name of default develop branch.' }),
patchPath: command_1.flags.string({ description: 'Path to save the patch file when running patch command' }),
featureYamlPath: command_1.flags.string({ description: 'Path to save the feature YAML file' }),
featureMetaPath: command_1.flags.string({ description: 'Path to save the retrieved metadata files based on YAML' }),
packageBasePath: command_1.flags.string({ description: 'Base path for sfdc package' }),
};
DevConfig.args = [{ name: 'file' }];