UNPKG

@sfdx-falcon/builder-library

Version:

Collection of functions for building pre-defined SFDX-Falcon Tasks, Questions, and Task Bundles. Allows developers to quickly build common Task and Interview-driven workflows in their CLI plugins. Part of the SFDX-Falcon Library.

83 lines 5.7 kB
"use strict"; //─────────────────────────────────────────────────────────────────────────────────────────────────┐ /** * @author Vivek M. Chawla <@VivekMChawla> * @copyright 2019, Vivek M. Chawla / Salesforce. All rights reserved. * @license BSD-3-Clause For full license text, see the LICENSE file in the repo root or * `https://opensource.org/licenses/BSD-3-Clause` * @file packages/builder-library/src/questions/general.ts * @summary Exports `Builder` classes for general questions. * @description Exports `Builder` classes for general questions. */ //─────────────────────────────────────────────────────────────────────────────────────────────────┘ // Import External Libraries, Modules, and Types Object.defineProperty(exports, "__esModule", { value: true }); // Import SFDX-Falcon Libraries const validator_1 = require("@sfdx-falcon/validator"); // Library of Type Validation helper functions. // Import SFDX-Falcon Classes & Functions const builder_1 = require("@sfdx-falcon/builder"); // Class. Classes derived from QuestionsBuilder can be used to build an Inquirer Questions object. const debug_1 = require("@sfdx-falcon/debug"); // Class. Provides custom "debugging" services (ie. debug-style info to console.log()). // Set the File Local Debug Namespace const dbgNs = '@sfdx-falcon:builder-library:questions'; debug_1.SfdxFalconDebug.msg(`${dbgNs}:`, `Debugging initialized for ${dbgNs}(general)`); //─────────────────────────────────────────────────────────────────────────────────────────────────┐ /** * @class ConfirmProceedRestart * @extends InterviewQuestionsBuilder * @description Asks the user to confirm that they want to proceed with an operation based on the * values that they have previously provided during an Interview. If they say "no", * they will be asked if they want to restart. If they choose not to restart, they * are effectively aborting the operation. * @public */ //─────────────────────────────────────────────────────────────────────────────────────────────────┘ class ConfirmProceedRestart extends builder_1.InterviewQuestionsBuilder { //───────────────────────────────────────────────────────────────────────────┐ /** * @constructs ConfirmProceedRestart * @param {ConfirmProceedRestartOptions} opts Required. */ //───────────────────────────────────────────────────────────────────────────┘ constructor(opts) { // Call the superclass constructor. super(opts); // Initialize debug for this method. const dbgNS = this.initializeDebug(dbgNs, `constructor`, arguments); // Validate optional arguments. if (opts.msgStrings.promptConfirmation) validator_1.TypeValidator.throwOnEmptyNullInvalidString(opts.msgStrings.promptConfirmation, `${dbgNS.ext}`, `msgStrings.promptConfirmation`); if (opts.msgStrings.promptStartOver) validator_1.TypeValidator.throwOnEmptyNullInvalidString(opts.msgStrings.promptStartOver, `${dbgNS.ext}`, `msgStrings.promptStartOver`); // Initialize member variables. this.promptConfirmation = opts.msgStrings.promptConfirmation || `Would you like to proceed based on the above settings?`; this.promptStartOver = opts.msgStrings.promptStartOver || `Would you like to start again and enter new values?`; } //───────────────────────────────────────────────────────────────────────────┐ /** * @method build * @returns {Questions} * @description Builds the Interview Questions. * @public */ //───────────────────────────────────────────────────────────────────────────┘ build() { return [ { type: 'confirm', name: 'proceed', message: this.promptConfirmation, default: false, when: true }, { type: 'confirm', name: 'restart', message: this.promptStartOver, default: true, when: answerHash => !answerHash.proceed } ]; } } exports.ConfirmProceedRestart = ConfirmProceedRestart; //# sourceMappingURL=general.js.map