amplify-prompts
Advanced tools
Comparing version 2.6.2 to 2.6.3-upgrade-graphql15-2.0
@@ -6,2 +6,19 @@ # Change Log | ||
## [2.6.3-upgrade-graphql15-2.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@2.6.2...amplify-prompts@2.6.3-upgrade-graphql15-2.0) (2023-01-18) | ||
### Bug Fixes | ||
* automatic lint fixes ([#11636](https://github.com/aws-amplify/amplify-cli/issues/11636)) ([0e7f70b](https://github.com/aws-amplify/amplify-cli/commit/0e7f70befbe72d17dfb11f5fed1c8609a13d4a97)) | ||
* make prompter multi-select indicator more distinct ([#11742](https://github.com/aws-amplify/amplify-cli/issues/11742)) ([4531c38](https://github.com/aws-amplify/amplify-cli/commit/4531c3819fbf9850d603df443380ae310c85b129)) | ||
### Reverts | ||
* Revert "chore: fixing main to dev merge conflicts (#11696)" ([00fec46](https://github.com/aws-amplify/amplify-cli/commit/00fec4608096390b5ae2563b5c69453cd48bfa45)), closes [#11696](https://github.com/aws-amplify/amplify-cli/issues/11696) | ||
## [2.6.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@2.6.1...amplify-prompts@2.6.2) (2023-01-03) | ||
@@ -8,0 +25,0 @@ |
@@ -47,3 +47,3 @@ "use strict"; | ||
if (this.flowData && input) { | ||
const finalInput = (redact) ? '*'.repeat(input.length) : input; | ||
const finalInput = redact ? '*'.repeat(input.length) : input; | ||
this.flowData.pushInteractiveFlow(promptString, finalInput); | ||
@@ -94,3 +94,7 @@ } | ||
const opts = (_a = options === null || options === void 0 ? void 0 : options[0]) !== null && _a !== void 0 ? _a : {}; | ||
const enquirerPromptType = 'hidden' in opts && opts.hidden ? EnquirerPromptType.INVISIBLE : opts.returnSize === 'many' ? EnquirerPromptType.LIST : EnquirerPromptType.INPUT; | ||
const enquirerPromptType = 'hidden' in opts && opts.hidden | ||
? EnquirerPromptType.INVISIBLE | ||
: opts.returnSize === 'many' | ||
? EnquirerPromptType.LIST | ||
: EnquirerPromptType.INPUT; | ||
if (flags_1.isYes) { | ||
@@ -134,3 +138,4 @@ if (opts.initial !== undefined) { | ||
const genericChoices = typeof choices[0] === 'string' | ||
? choices.map(choice => ({ name: choice, value: choice })) | ||
? | ||
choices.map(choice => ({ name: choice, value: choice })) | ||
: choices; | ||
@@ -181,2 +186,5 @@ const initialIndexes = initialOptsToIndexes(genericChoices.map(choice => choice.value), opts.initial); | ||
}, | ||
indicator(_, choice) { | ||
return choice.enabled ? chalk_1.default.cyan('●') : '○'; | ||
}, | ||
validate() { | ||
@@ -183,0 +191,0 @@ var _a, _b; |
{ | ||
"name": "amplify-prompts", | ||
"version": "2.6.2", | ||
"version": "2.6.3-upgrade-graphql15-2.0", | ||
"description": "Utility functions for Amplify CLI terminal I/O", | ||
@@ -53,3 +53,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "dea54cd4bc5745ba7645808964d29f5a395fe6f7" | ||
"gitHead": "a9179c71eceb850a395f81e2d3b9623b3eb7663c" | ||
} |
@@ -23,3 +23,3 @@ /* eslint-disable @typescript-eslint/ban-types */ | ||
class AmplifyPrompter implements Prompter { | ||
flowData: IFlowData|undefined; // interactive cli flow data journal | ||
flowData: IFlowData | undefined; // interactive cli flow data journal | ||
stopWatch: Stopwatch; | ||
@@ -40,10 +40,10 @@ constructor(private readonly prompter: typeof prompt = prompt, private readonly print: typeof printer = printer) { | ||
private throwLoggedError = (message: string, errorMsg : string) : void => { | ||
private throwLoggedError = (message: string, errorMsg: string): void => { | ||
this.flowData?.pushInteractiveFlow(message, errorMsg); | ||
throw new Error(errorMsg); | ||
} | ||
}; | ||
setFlowData = (flowData: IFlowData): void => { | ||
this.flowData = flowData; | ||
} | ||
}; | ||
@@ -53,7 +53,7 @@ private pushInteractiveFlow = (promptString: string, input: unknown, redact = false) => { | ||
if (this.flowData && input) { | ||
const finalInput = (redact) ? '*'.repeat((input as string).length) : input; | ||
const finalInput = redact ? '*'.repeat((input as string).length) : input; | ||
this.flowData.pushInteractiveFlow(promptString, finalInput); | ||
} | ||
} | ||
} | ||
}; | ||
@@ -122,5 +122,13 @@ /** | ||
*/ | ||
input = async <RS extends ReturnSize = 'one', T = string>(message: string, ...options: MaybeOptionalInputOptions<RS, T>): Promise<PromptReturn<RS, T>> => { | ||
input = async <RS extends ReturnSize = 'one', T = string>( | ||
message: string, | ||
...options: MaybeOptionalInputOptions<RS, T> | ||
): Promise<PromptReturn<RS, T>> => { | ||
const opts = options?.[0] ?? ({} as InputOptions<RS, T>); | ||
const enquirerPromptType : EnquirerPromptType = 'hidden' in opts && opts.hidden ? EnquirerPromptType.INVISIBLE : opts.returnSize === 'many' ? EnquirerPromptType.LIST : EnquirerPromptType.INPUT; | ||
const enquirerPromptType: EnquirerPromptType = | ||
'hidden' in opts && opts.hidden | ||
? EnquirerPromptType.INVISIBLE | ||
: opts.returnSize === 'many' | ||
? EnquirerPromptType.LIST | ||
: EnquirerPromptType.INPUT; | ||
@@ -154,5 +162,7 @@ if (isYes) { | ||
if (Array.isArray(result)) { | ||
functionResult = (await Promise.all(result.map(async part => (opts.transform as Function)(part) as T))) as unknown as PromptReturn<RS, T>; | ||
functionResult = ((await Promise.all( | ||
result.map(async part => (opts.transform as Function)(part) as T), | ||
)) as unknown) as PromptReturn<RS, T>; | ||
} else { | ||
functionResult = opts.transform(result as string) as unknown as PromptReturn<RS, T>; | ||
functionResult = (opts.transform(result as string) as unknown) as PromptReturn<RS, T>; | ||
} | ||
@@ -164,3 +174,3 @@ this.pushInteractiveFlow(message, functionResult, enquirerPromptType == EnquirerPromptType.INVISIBLE); | ||
this.pushInteractiveFlow(message, result, enquirerPromptType == EnquirerPromptType.INVISIBLE); | ||
return result as unknown as PromptReturn<RS, T>; | ||
return (result as unknown) as PromptReturn<RS, T>; | ||
}; | ||
@@ -194,6 +204,7 @@ | ||
// map string[] choices into GenericChoice<T>[] | ||
const genericChoices: GenericChoice<T>[] = typeof choices[0] === 'string' | ||
// this assertion is safe because the choice array can only be a string[] if the generic type is a string | ||
? ((choices as string[]).map(choice => ({ name: choice, value: choice })) as unknown as GenericChoice<T>[]) | ||
: (choices as GenericChoice<T>[]); | ||
const genericChoices: GenericChoice<T>[] = | ||
typeof choices[0] === 'string' | ||
? // this assertion is safe because the choice array can only be a string[] if the generic type is a string | ||
(((choices as string[]).map(choice => ({ name: choice, value: choice })) as unknown) as GenericChoice<T>[]) | ||
: (choices as GenericChoice<T>[]); | ||
@@ -265,2 +276,5 @@ const initialIndexes = initialOptsToIndexes( | ||
}, | ||
indicator(_: unknown, choice: { enabled: boolean }) { | ||
return choice.enabled ? chalk.cyan('●') : '○'; | ||
}, | ||
validate() { | ||
@@ -301,3 +315,3 @@ if (opts && ('pickAtLeast' in opts || 'pickAtMost' in opts)) { | ||
getTotalPromptElapsedTime = () : number => this.stopWatch.getElapsedMilliseconds() | ||
getTotalPromptElapsedTime = (): number => this.stopWatch.getElapsedMilliseconds(); | ||
} | ||
@@ -313,5 +327,4 @@ | ||
*/ | ||
export const byValues = <T>(selection: T[], equals: EqualsFunction<T> = defaultEquals): MultiFilterFunction<T> => ( | ||
choices: T[], | ||
) => selection.map(sel => choices.findIndex(choice => equals(choice, sel))).filter(idx => idx >= 0); | ||
export const byValues = <T>(selection: T[], equals: EqualsFunction<T> = defaultEquals): MultiFilterFunction<T> => (choices: T[]) => | ||
selection.map(sel => choices.findIndex(choice => equals(choice, sel))).filter(idx => idx >= 0); | ||
@@ -379,4 +392,4 @@ /** | ||
: { | ||
hidden?: boolean; | ||
}; | ||
hidden?: boolean; | ||
}; | ||
@@ -400,4 +413,4 @@ // The initial selection for a pick prompt can be specified either by index or a selection function that generates indexes. | ||
: { | ||
pickAtLeast?: number; | ||
}; | ||
pickAtLeast?: number; | ||
}; | ||
@@ -407,4 +420,4 @@ type MultiSelectMaximum<RS extends ReturnSize> = RS extends 'one' | ||
: { | ||
pickAtMost?: number; | ||
}; | ||
pickAtMost?: number; | ||
}; | ||
@@ -425,7 +438,7 @@ type ValidateValueOption = { | ||
? { | ||
returnSize: 'many'; | ||
} | ||
returnSize: 'many'; | ||
} | ||
: { | ||
returnSize?: 'one'; | ||
}; | ||
returnSize?: 'one'; | ||
}; | ||
@@ -467,5 +480,5 @@ type Choices<T> = T extends string ? GenericChoice<T>[] | string[] : GenericChoice<T>[]; | ||
enum EnquirerPromptType { | ||
INVISIBLE = 'invisible', | ||
LIST = 'list', | ||
INPUT = 'input' | ||
INVISIBLE = 'invisible', | ||
LIST = 'list', | ||
INPUT = 'input', | ||
} |
@@ -16,3 +16,3 @@ export type Validator = (value: string) => true | string | Promise<true | string>; | ||
export const alphanumeric = | ||
(message: string = 'Input must be alphanumeric'): Validator => | ||
(message = 'Input must be alphanumeric'): Validator => | ||
(input: string) => | ||
@@ -27,3 +27,3 @@ /^[a-zA-Z0-9]+$/.test(input) ? true : message; | ||
export const integer = | ||
(message: string = 'Input must be a number'): Validator => | ||
(message = 'Input must be a number'): Validator => | ||
(input: string) => | ||
@@ -30,0 +30,0 @@ /^[0-9]+$/.test(input) ? true : message; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
259329
42837
3147
1