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

51 lines
1.5 KiB
TypeScript

import { select, confirm } from '@inquirer/prompts';
import { getMetaData, updateMetaData } from './helpers/project-metadata.js';
const updateChallengeOrder = async () => {
const oldChallengeOrder = getMetaData().challengeOrder;
console.log('Current challenge order is: ');
console.table(oldChallengeOrder.map(({ title }) => ({ title })));
const newChallengeOrder: { id: string; title: string }[] = [];
while (oldChallengeOrder.length) {
const nextChallengeId = await select<string>({
message: newChallengeOrder.length
? `What challenge comes after ${
newChallengeOrder[newChallengeOrder.length - 1].title
}?`
: 'What is the first challenge?',
choices: oldChallengeOrder.map(({ id, title }) => ({
name: title,
value: id
}))
});
const nextChallengeIndex = oldChallengeOrder.findIndex(
({ id }) => id === nextChallengeId
);
const targetChallenge = oldChallengeOrder[nextChallengeIndex];
oldChallengeOrder.splice(nextChallengeIndex, 1);
newChallengeOrder.push(targetChallenge);
}
console.log('New challenge order is: ');
console.table(newChallengeOrder.map(({ title }) => ({ title })));
const isCorrect = await confirm({
message: 'Is this correct?',
default: false
});
if (!isCorrect) {
console.error('Aborting.');
return;
}
const meta = getMetaData();
meta.challengeOrder = newChallengeOrder;
await updateMetaData(meta);
};
void (async () => await updateChallengeOrder())();