MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getProjectName

Function getProjectName

npm_modules/cli/src/commands/bootstrap.ts:99–141  ·  view source on GitHub ↗
(argv: ArgumentsResolver<CommandParameters>)

Source from the content-addressed store, hash-verified

97}
98
99async function getProjectName(argv: ArgumentsResolver<CommandParameters>): Promise<string> {
100 return argv.getArgumentOrResolve('projectName', async () => {
101 let projectName = '';
102 let isValid = false;
103
104 while (!isValid) {
105 const result = await inquirer.prompt<{ projectName: string }>([
106 {
107 type: 'input',
108 name: 'projectName',
109 message: 'Please provide a name for this project:',
110 default: defaultProjectName,
111 },
112 ]);
113
114 projectName = result.projectName;
115 const validationError = validateProjectName(projectName);
116
117 if (validationError) {
118 console.log(wrapInColor(`\n❌ ${validationError}\n`, ANSI_COLORS.RED_COLOR));
119 continue;
120 }
121
122 const sanitized = sanitizeProjectName(projectName);
123 if (sanitized !== projectName) {
124 console.log(
125 wrapInColor(
126 `\n⚠️ Project name will be sanitized from "${projectName}" to "${sanitized}"`,
127 ANSI_COLORS.YELLOW_COLOR,
128 ),
129 );
130 const confirm = await getUserConfirmation('Do you want to continue with this name?', true);
131 if (!confirm) {
132 continue;
133 }
134 }
135
136 isValid = true;
137 }
138
139 return sanitizeProjectName(projectName);
140 });
141}
142
143function resolveValdiReleaseTag(
144 argv: ArgumentsResolver<CommandParameters>,

Callers 1

valdiBootstrapFunction · 0.85

Calls 6

validateProjectNameFunction · 0.90
wrapInColorFunction · 0.90
sanitizeProjectNameFunction · 0.90
getUserConfirmationFunction · 0.90
getArgumentOrResolveMethod · 0.80
logMethod · 0.65

Tested by

no test coverage detected