()
| 14 | import { getInputType } from './helpers/get-input-type.js'; |
| 15 | |
| 16 | const insertChallenge = async () => { |
| 17 | const challenges = getMetaData().challengeOrder; |
| 18 | const challengeAfterId = await select<string>({ |
| 19 | message: 'Which challenge should come AFTER this new one?', |
| 20 | choices: challenges.map(({ id, title }) => ({ |
| 21 | name: title, |
| 22 | value: id |
| 23 | })) |
| 24 | }); |
| 25 | const challengeLang = getChallenge(challengeAfterId)?.lang; |
| 26 | |
| 27 | const indexToInsert = challenges.findIndex( |
| 28 | ({ id }) => id === challengeAfterId |
| 29 | ); |
| 30 | |
| 31 | const newTaskTitle = 'Task 0'; |
| 32 | |
| 33 | const { challengeType } = await newTaskPrompts(); |
| 34 | |
| 35 | const inputType = await getInputType(challengeType, challengeLang); |
| 36 | const options = { |
| 37 | title: newTaskTitle, |
| 38 | dashedName: 'task-0', |
| 39 | challengeType, |
| 40 | ...{ ...(challengeLang && { challengeLang }) }, |
| 41 | ...{ ...(inputType && { inputType }) } |
| 42 | }; |
| 43 | |
| 44 | const path = getProjectPath(); |
| 45 | const template = getTemplate(challengeType); |
| 46 | const challengeId = new ObjectId(); |
| 47 | const challengeText = template({ ...options, challengeId }); |
| 48 | |
| 49 | const challengeIdString = challengeId.toString(); |
| 50 | |
| 51 | createChallengeFile(challengeIdString, challengeText, path); |
| 52 | console.log('Finished creating new task markdown file.'); |
| 53 | |
| 54 | await insertChallengeIntoMeta({ |
| 55 | index: indexToInsert, |
| 56 | id: challengeId, |
| 57 | title: newTaskTitle |
| 58 | }); |
| 59 | console.log(`Finished inserting task into 'meta.json' file.`); |
| 60 | |
| 61 | await updateTaskMeta(); |
| 62 | console.log("Finished updating tasks in 'meta.json'."); |
| 63 | |
| 64 | updateTaskMarkdownFiles(); |
| 65 | console.log('Finished updating task markdown files.'); |
| 66 | }; |
| 67 | |
| 68 | void insertChallenge(); |
no test coverage detected