From d71e11faa23c049ff6f997127b038b8f86ebc761 Mon Sep 17 00:00:00 2001 From: Min Kim Date: Sun, 29 Sep 2024 16:52:38 -0400 Subject: [PATCH] Create a new built-in prompt for npm registry Signed-off-by: Min Kim --- .../cli/src/lib/new/factories/common/prompts.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/cli/src/lib/new/factories/common/prompts.ts b/packages/cli/src/lib/new/factories/common/prompts.ts index 428ba8f9d3..45c933af30 100644 --- a/packages/cli/src/lib/new/factories/common/prompts.ts +++ b/packages/cli/src/lib/new/factories/common/prompts.ts @@ -49,6 +49,22 @@ export function moduleIdIdPrompt(): Prompt<{ moduleId: string }> { }; } +export function npmRegistryPrompt(): Prompt<{ npmRegistry: string }> { + return { + type: 'input', + name: 'npmRegistry', + message: 'Please specify your NPM registry [optional]', + validate: (value: string) => { + if (!value) { + return 'Please enter the URL of your NPM registry'; + } else if (!/^http*$/.test(value)) { + return 'Invalid URL.'; + } + return true; + }, + }; +} + export function ownerPrompt(): Prompt<{ owner?: string; codeOwnersPath?: string;