chore: import upstream snapshot with attribution
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
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
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import { ObjectId } from 'bson';
|
||||
import { select } from '@inquirer/prompts';
|
||||
import { getTemplate } from './helpers/get-challenge-template.js';
|
||||
import { newTaskPrompts } from './helpers/new-task-prompts.js';
|
||||
import { getProjectPath } from './helpers/get-project-info.js';
|
||||
import {
|
||||
createChallengeFile,
|
||||
getChallenge,
|
||||
insertChallengeIntoMeta,
|
||||
updateTaskMeta,
|
||||
updateTaskMarkdownFiles
|
||||
} from './utils.js';
|
||||
import { getMetaData } from './helpers/project-metadata.js';
|
||||
import { getInputType } from './helpers/get-input-type.js';
|
||||
|
||||
const insertChallenge = async () => {
|
||||
const challenges = getMetaData().challengeOrder;
|
||||
const challengeAfterId = await select<string>({
|
||||
message: 'Which challenge should come AFTER this new one?',
|
||||
choices: challenges.map(({ id, title }) => ({
|
||||
name: title,
|
||||
value: id
|
||||
}))
|
||||
});
|
||||
const challengeLang = getChallenge(challengeAfterId)?.lang;
|
||||
|
||||
const indexToInsert = challenges.findIndex(
|
||||
({ id }) => id === challengeAfterId
|
||||
);
|
||||
|
||||
const newTaskTitle = 'Task 0';
|
||||
|
||||
const { challengeType } = await newTaskPrompts();
|
||||
|
||||
const inputType = await getInputType(challengeType, challengeLang);
|
||||
const options = {
|
||||
title: newTaskTitle,
|
||||
dashedName: 'task-0',
|
||||
challengeType,
|
||||
...{ ...(challengeLang && { challengeLang }) },
|
||||
...{ ...(inputType && { inputType }) }
|
||||
};
|
||||
|
||||
const path = getProjectPath();
|
||||
const template = getTemplate(challengeType);
|
||||
const challengeId = new ObjectId();
|
||||
const challengeText = template({ ...options, challengeId });
|
||||
|
||||
const challengeIdString = challengeId.toString();
|
||||
|
||||
createChallengeFile(challengeIdString, challengeText, path);
|
||||
console.log('Finished creating new task markdown file.');
|
||||
|
||||
await insertChallengeIntoMeta({
|
||||
index: indexToInsert,
|
||||
id: challengeId,
|
||||
title: newTaskTitle
|
||||
});
|
||||
console.log(`Finished inserting task into 'meta.json' file.`);
|
||||
|
||||
await updateTaskMeta();
|
||||
console.log("Finished updating tasks in 'meta.json'.");
|
||||
|
||||
updateTaskMarkdownFiles();
|
||||
console.log('Finished updating task markdown files.');
|
||||
};
|
||||
|
||||
void insertChallenge();
|
||||
Reference in New Issue
Block a user