Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

47 lines
1.3 KiB
TypeScript

import { input, select } from '@inquirer/prompts';
import { challengeTypes } from '@freecodecamp/shared/config/challenge-types';
import { getLastStep } from './get-last-step-file-number.js';
export const newChallengePrompts = async (): Promise<{
title: string;
dashedName: string;
challengeType: string;
}> => {
const challengeType = await select<string>({
message: 'What type of challenge is this?',
choices: Object.entries(challengeTypes).map(([key, value]) => ({
name: key,
value: value.toString()
}))
});
const lastStep = getLastStep().stepNum;
const defaultTitle = `Step ${lastStep + 1}`;
const defaultDashedName = `step-${lastStep + 1}`;
const dashedName = await input({
message: 'What is the dashed name (in kebab-case) for this challenge?',
default: defaultDashedName,
validate: (block: string) => {
if (!block.length) {
return 'please enter a dashed name';
}
if (/[^a-z0-9-]/.test(block)) {
return 'please use alphanumerical characters and kebab case';
}
return true;
},
transformer: (block: string) => block.toLowerCase()
});
const title = await input({
message: 'What is the title of this challenge?',
default: defaultTitle
});
return {
title,
dashedName,
challengeType
};
};