UNPKG

qforce

Version:

Commands to help with salesforce development.

51 lines (50 loc) 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = require("@oclif/command"); const path = require('path'); const fs = require('fs'); const sfdx = require('sfdx-node'); class Open extends command_1.Command { async run() { const { args, flags } = this.parse(Open); let settings = {}, sfdxConfig = {}; if (fs.existsSync(path.join(process.cwd(), '.qforce', 'settings.json'))) { settings = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.qforce', 'settings.json'))); } if (fs.existsSync(path.join(process.cwd(), '.sfdx', 'sfdx-config.json'))) { sfdxConfig = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.sfdx', 'sfdx-config.json'))); } let targetusername = args.username || settings.targetusername || sfdxConfig.defaultusername; let openPath = ''; if (args.path) { const idRegex = RegExp('[a-zA-Z0-9]{18}|[a-zA-Z0-9]{15}'); if (args.path == 'setup') openPath = 'lightning/setup/SetupOneHome/home'; else if (args.path == 'console') openPath = '_ui/common/apex/debug/ApexCSIPage'; else if (idRegex.test(args.path)) openPath = `/${args.path}`; else openPath = args.path; } let options = {}; if (targetusername) options.targetusername = targetusername; if (openPath) options.path = openPath; sfdx.org.open(options); } } exports.default = Open; Open.description = 'Open an org.'; Open.aliases = ['open', 'dx:open', 'o']; Open.examples = [ `$ q dx:open uat`, ]; Open.flags = { help: command_1.flags.help({ char: 'h' }), }; Open.args = [ { name: 'username', required: true }, { name: 'path', required: false }, ];