@ionic/cli-framework
Advanced tools
Comparing version 2.1.7 to 2.1.8
@@ -6,2 +6,10 @@ # Change Log | ||
## [2.1.8](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework@2.1.7...@ionic/cli-framework@2.1.8) (2019-10-14) | ||
**Note:** Version bump only for package @ionic/cli-framework | ||
## [2.1.7](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework@2.1.6...@ionic/cli-framework@2.1.7) (2019-09-18) | ||
@@ -8,0 +16,0 @@ |
@@ -1,81 +0,1 @@ | ||
export declare type Inquirer = import('inquirer').Inquirer; | ||
export declare type Question = import('inquirer').Question; | ||
export declare type Separator = import('inquirer').objects.Separator; | ||
export interface PromptQuestionBase extends Question { | ||
/** | ||
* The prompt type for this question. | ||
* - 'confirm': Y/n | ||
* - 'checkbox': Multi-value selection. | ||
* - 'input': Text input. | ||
* - 'password': Masked text input. | ||
* - 'list': Single-value selection. | ||
*/ | ||
type: PromptType; | ||
/** | ||
* The question to print. | ||
*/ | ||
message: string; | ||
/** | ||
* The fallback value to use in non-TTY mode. | ||
*/ | ||
fallback?: PromptValue; | ||
/** | ||
* Default value to use if nothing is entered. | ||
*/ | ||
default?: PromptValue; | ||
} | ||
export declare type PromptTypeConfirm = 'confirm'; | ||
export declare type PromptTypeCheckbox = 'checkbox'; | ||
export declare type PromptTypeOther = 'input' | 'password' | 'list'; | ||
export declare type PromptType = PromptTypeConfirm | PromptTypeCheckbox | PromptTypeOther; | ||
export declare type PromptValueConfirm = boolean; | ||
export declare type PromptValueCheckbox = string[]; | ||
export declare type PromptValueOther = string; | ||
export declare type PromptValue = PromptValueConfirm | PromptValueCheckbox | PromptValueOther; | ||
export interface PromptQuestionConfirm extends PromptQuestionBase { | ||
type: PromptTypeConfirm; | ||
fallback?: PromptValueConfirm; | ||
default?: PromptValueConfirm; | ||
} | ||
export interface PromptQuestionCheckbox extends PromptQuestionBase { | ||
type: PromptTypeCheckbox; | ||
fallback?: PromptValueCheckbox; | ||
default?: PromptValueCheckbox; | ||
} | ||
export interface PromptQuestionOther extends PromptQuestionBase { | ||
type: PromptTypeOther; | ||
fallback?: PromptValueOther; | ||
default?: PromptValueOther; | ||
} | ||
export declare type PromptQuestion = PromptQuestionConfirm | PromptQuestionCheckbox | PromptQuestionOther; | ||
export interface PromptModule { | ||
readonly _inquirer: Inquirer; | ||
(question: PromptQuestionConfirm): Promise<PromptValueConfirm>; | ||
(question: PromptQuestionCheckbox): Promise<PromptValueCheckbox>; | ||
(question: PromptQuestionOther): Promise<PromptValueOther>; | ||
} | ||
export interface CreatePromptModuleOptions { | ||
readonly interactive?: boolean; | ||
readonly onFallback?: (question: PromptQuestion) => PromptValue | void; | ||
} | ||
/** | ||
* Create a reusable CLI prompt module. | ||
* | ||
* A prompt module is a function that generates prompts. A prompt opens an | ||
* interactive session with the user to gather input. When a prompt is | ||
* resolved, the user has finished providing input. | ||
* | ||
* If non-TTY mode is detected, a system of fallbacks goes into effect: | ||
* 1. If the question provided 'fallback', the fallback value is resolved. | ||
* 2. If the prompt module has 'onFallback', it is used to generate a | ||
* fallback for the question. | ||
* 3. If the question provided 'default', the default value is resolved. | ||
* 4. Finally, a falsy value suitable for the question type is resolved. | ||
* | ||
* @param options.interactive Force non-TTY mode by providing 'false'. TTY mode | ||
* cannot be forced if non-TTY mode is detected. | ||
* @param options.onFallback Generate a non-TTY fallback for a question without | ||
* a 'fallback'. | ||
*/ | ||
export declare function createPromptModule({ interactive, onFallback }?: CreatePromptModuleOptions): Promise<PromptModule>; | ||
export declare function createPromptChoiceSeparator(): Separator; | ||
export * from '@ionic/cli-framework-prompts'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_terminal_1 = require("@ionic/utils-terminal"); | ||
const Debug = require("debug"); | ||
const debug = Debug('ionic:cli-framework:lib:prompts'); | ||
let _inquirer; | ||
async function loadInquirer() { | ||
if (!_inquirer) { | ||
_inquirer = await Promise.resolve().then(() => require('inquirer')); | ||
} | ||
return _inquirer; | ||
} | ||
/** | ||
* Create a reusable CLI prompt module. | ||
* | ||
* A prompt module is a function that generates prompts. A prompt opens an | ||
* interactive session with the user to gather input. When a prompt is | ||
* resolved, the user has finished providing input. | ||
* | ||
* If non-TTY mode is detected, a system of fallbacks goes into effect: | ||
* 1. If the question provided 'fallback', the fallback value is resolved. | ||
* 2. If the prompt module has 'onFallback', it is used to generate a | ||
* fallback for the question. | ||
* 3. If the question provided 'default', the default value is resolved. | ||
* 4. Finally, a falsy value suitable for the question type is resolved. | ||
* | ||
* @param options.interactive Force non-TTY mode by providing 'false'. TTY mode | ||
* cannot be forced if non-TTY mode is detected. | ||
* @param options.onFallback Generate a non-TTY fallback for a question without | ||
* a 'fallback'. | ||
*/ | ||
async function createPromptModule({ interactive, onFallback } = {}) { | ||
const inquirer = await loadInquirer(); | ||
const { createPromptModule: createInquirerPromptModule } = inquirer; | ||
const promptModule = createInquirerPromptModule(); | ||
async function createPrompter(question) { | ||
const { fallback, ...promptQuestion } = question; | ||
if (!utils_terminal_1.TERMINAL_INFO.tty || interactive === false) { | ||
if (typeof fallback !== 'undefined') { | ||
debug('Answering with provided fallback value for non-tty mode: %o', fallback); | ||
return fallback; | ||
} | ||
else if (onFallback) { | ||
const generatedFallback = onFallback(question); | ||
if (typeof generatedFallback !== 'undefined') { | ||
debug(`Answering with fallback value from 'onFallback' for non-tty mode: %o`, generatedFallback); | ||
return generatedFallback; | ||
} | ||
} | ||
if (typeof promptQuestion.default !== 'undefined') { | ||
return promptQuestion.default; | ||
} | ||
if (question.type === 'confirm') { | ||
return false; | ||
} | ||
else if (question.type === 'checkbox') { | ||
return []; | ||
} | ||
return ''; | ||
} | ||
const name = 'name'; | ||
const prompt = promptModule({ ...promptQuestion, name }); | ||
const result = (await prompt)[name]; | ||
if (typeof result === 'undefined' || result === null) { | ||
return ''; | ||
} | ||
if (typeof result !== 'string' && typeof result !== 'boolean' && !Array.isArray(result)) { | ||
return String(result); | ||
} | ||
return result; | ||
} | ||
Object.defineProperties(createPrompter, { | ||
_inquirer: { value: inquirer }, | ||
}); | ||
return createPrompter; | ||
} | ||
exports.createPromptModule = createPromptModule; | ||
function createPromptChoiceSeparator() { | ||
if (!_inquirer) { | ||
throw new Error(`Prompt module not initialized. Call 'createPromptModule' first.`); | ||
} | ||
return new _inquirer.Separator(); | ||
} | ||
exports.createPromptChoiceSeparator = createPromptChoiceSeparator; | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("@ionic/cli-framework-prompts"), exports); |
{ | ||
"name": "@ionic/cli-framework", | ||
"version": "2.1.7", | ||
"version": "2.1.8", | ||
"description": "The foundation framework of the Ionic CLI", | ||
@@ -22,12 +22,12 @@ "homepage": "https://ionicframework.com/", | ||
"dependencies": { | ||
"@ionic/cli-framework-prompts": "1.0.1", | ||
"@ionic/utils-array": "1.2.1", | ||
"@ionic/utils-fs": "2.0.7", | ||
"@ionic/utils-fs": "2.0.8", | ||
"@ionic/utils-object": "1.0.5", | ||
"@ionic/utils-process": "1.0.5", | ||
"@ionic/utils-stream": "2.0.4", | ||
"@ionic/utils-subprocess": "1.0.8", | ||
"@ionic/utils-subprocess": "1.0.9", | ||
"@ionic/utils-terminal": "1.0.5", | ||
"chalk": "^2.3.0", | ||
"debug": "^4.0.0", | ||
"inquirer": "^7.0.0", | ||
"lodash": "^4.17.5", | ||
@@ -47,3 +47,2 @@ "log-update": "^3.2.0", | ||
"@types/debug": "^4.1.1", | ||
"@types/inquirer": "0.0.43", | ||
"@types/jest": "^24.0.3", | ||
@@ -64,3 +63,3 @@ "@types/lodash": "^4.14.104", | ||
}, | ||
"gitHead": "f5d4ca71fb24b5117fb815569e683fbc617903ac" | ||
"gitHead": "1b5436ea024b6e27644e2aabdd5afbe678ef40b0" | ||
} |
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
15
154617
3371
+ Added@ionic/cli-framework-prompts@1.0.1(transitive)
+ Added@ionic/utils-fs@2.0.8(transitive)
+ Added@ionic/utils-subprocess@1.0.9(transitive)
- Removedinquirer@^7.0.0
- Removed@ionic/utils-fs@2.0.7(transitive)
- Removed@ionic/utils-subprocess@1.0.8(transitive)
Updated@ionic/utils-fs@2.0.8