Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amplify-prompts

Package Overview
Dependencies
Maintainers
1
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amplify-prompts - npm Package Compare versions

Comparing version 1.7.0-beta.0 to 2.0.0-beta.1.0

41

CHANGELOG.md

@@ -6,5 +6,44 @@ # Change Log

# [1.7.0-beta.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@1.5.1...amplify-prompts@1.7.0-beta.0) (2021-11-23)
# [2.0.0-beta.1.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@1.6.3...amplify-prompts@2.0.0-beta.1.0) (2022-04-05)
### Bug Fixes
* use prompter and handle deletions ([#10122](https://github.com/aws-amplify/amplify-cli/issues/10122)) ([7eebb98](https://github.com/aws-amplify/amplify-cli/commit/7eebb98c77c6cbd218a9cbead36eabfa86c99a09))
### BREAKING CHANGES
* package name update requires version bump in order to keep in sync with lerna.
## [1.6.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@1.6.2...amplify-prompts@1.6.3) (2022-01-27)
### Bug Fixes
* validation for s3 bucketname in s3-cli walkthrough ([#9555](https://github.com/aws-amplify/amplify-cli/issues/9555)) ([1daf720](https://github.com/aws-amplify/amplify-cli/commit/1daf72029bda79645ee95997c40a887741499164))
## [1.6.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@1.6.0...amplify-prompts@1.6.2) (2022-01-10)
## 7.6.7 (2022-01-10)
**Note:** Version bump only for package amplify-prompts
# [1.6.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-prompts@1.5.1...amplify-prompts@1.6.0) (2021-11-23)
### Features

@@ -11,0 +50,0 @@

5

lib/prompter.js

@@ -60,5 +60,6 @@ "use strict";

this.input = async (message, ...options) => {
const opts = (options === null || options === void 0 ? void 0 : options[0]) || {};
var _a;
const opts = (_a = options === null || options === void 0 ? void 0 : options[0]) !== null && _a !== void 0 ? _a : {};
if (flags_1.isYes) {
if (opts.initial) {
if (opts.initial !== undefined) {
return opts.initial;

@@ -65,0 +66,0 @@ }

export declare type Validator = (value: string) => true | string | Promise<true | string>;
export declare const alphanumeric: (message?: string) => Validator;
export declare const matchRegex: (validatorRegex: RegExp, message?: string | undefined) => Validator;
export declare const integer: (message?: string) => Validator;

@@ -4,0 +5,0 @@ export declare const maxLength: (maxLen: number, message?: string | undefined) => Validator;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.not = exports.or = exports.and = exports.exact = exports.minLength = exports.maxLength = exports.integer = exports.alphanumeric = void 0;
exports.not = exports.or = exports.and = exports.exact = exports.minLength = exports.maxLength = exports.integer = exports.matchRegex = exports.alphanumeric = void 0;
const alphanumeric = (message = 'Input must be alphanumeric') => (input) => /^[a-zA-Z0-9]+$/.test(input) ? true : message;
exports.alphanumeric = alphanumeric;
const matchRegex = (validatorRegex, message) => (input) => validatorRegex.test(input) ? true : message || `Input does not match the regular expression ${validatorRegex}`;
exports.matchRegex = matchRegex;
const integer = (message = 'Input must be a number') => (input) => /^[0-9]+$/.test(input) ? true : message;

@@ -7,0 +9,0 @@ exports.integer = integer;

{
"name": "amplify-prompts",
"version": "1.7.0-beta.0",
"version": "2.0.0-beta.1.0",
"description": "Utility functions for Amplify CLI terminal I/O",

@@ -51,3 +51,3 @@ "main": "lib/index.js",

},
"gitHead": "94b64e9325704c2dfd22c1486e5bc52f9a425297"
"gitHead": "b02f7644f21c626b1ffbfba5538c125c92d240a8"
}

@@ -1,2 +0,2 @@

import { alphanumeric, and, integer, maxLength, minLength, not, or } from '../validators';
import { alphanumeric, and, integer, maxLength, minLength, not, or, matchRegex } from '../validators';

@@ -108,1 +108,19 @@ describe('alphanumeric', () => {

});
describe('regexpValidator', () => {
it('returns true for strings matching regexp', () => {
expect(matchRegex(/^[a-z0-9-]+$/, 'regExp test')('test-logs-20220118')).toBe(true);
});
it('returns default error message for strings not matching regexp', () => {
expect(matchRegex(/^[a-z0-9-]+$/, undefined)('test_logs_*')).toMatchInlineSnapshot(
`"Input does not match the regular expression /^[a-z0-9-]+$/"`,
);
});
it('returns specified error message for strings not matching regexp', () => {
expect(matchRegex(/^[a-z0-9-]+$/, 'Only alphanumeric chars and hyphen allowed in string')('test_logs_*')).toMatchInlineSnapshot(
`"Only alphanumeric chars and hyphen allowed in string"`,
);
});
});

@@ -66,5 +66,5 @@ import { prompt } from 'enquirer';

input = async <RS extends ReturnSize = 'one', T = string>(message: string, ...options: MaybeOptionalInputOptions<RS, T>) => {
const opts = options?.[0] || {};
const opts = options?.[0] ?? ({} as InputOptions<RS, T>);
if (isYes) {
if (opts.initial) {
if (opts.initial !== undefined) {
return opts.initial as PromptReturn<RS, T>;

@@ -92,3 +92,3 @@ } else {

if (Array.isArray(result)) {
return (await Promise.all(result.map(async part => (opts.transform as Function)(part) as T))) as PromptReturn<RS, T>;
return (await Promise.all(result.map(async part => (opts.transform as Function)(part) as T))) as unknown as PromptReturn<RS, T>;
}

@@ -95,0 +95,0 @@ return opts.transform(result as string) as unknown as PromptReturn<RS, T>;

@@ -20,2 +20,7 @@ export type Validator = (value: string) => true | string | Promise<true | string>;

export const matchRegex =
(validatorRegex : RegExp, message?: string): Validator =>
(input: string) =>
validatorRegex.test(input) ? true : message || `Input does not match the regular expression ${validatorRegex}`;
export const integer =

@@ -22,0 +27,0 @@ (message: string = 'Input must be a number'): Validator =>

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc