Skip to content

Commit

Permalink
✨ Update kata names to match slug
Browse files Browse the repository at this point in the history
  • Loading branch information
w3cj committed Feb 28, 2019
1 parent 1ee1b90 commit a2efb1d
Show file tree
Hide file tree
Showing 50 changed files with 1,017 additions and 1,183 deletions.
212 changes: 106 additions & 106 deletions README.md

Large diffs are not rendered by default.

217 changes: 0 additions & 217 deletions episode_000/contents.md

This file was deleted.

74 changes: 74 additions & 0 deletions episode_000/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const { promises: fs } = require('fs');
const axios = require('axios');
const { items: videos } = require('./videos.json');

(async () => {
const katas = [];
let tableOfContents = `# Code Katas
Search / Filter solutions [here](https://code-katas.now.sh/)
# Episodes
`;
const files = await fs.readdir('../', 'utf8');
files.reverse();
for (const directory of files) {
if (directory.startsWith('episode') && directory !== 'episode_000') {
const episodeNum = +directory.replace('episode_', '');
const solutions = await fs.readdir(`../${directory}`, 'utf8');

const {
snippet: {
resourceId: {
videoId
}
}
} = videos[episodeNum - 1];

const video = `https://www.youtube.com/watch?v=${videoId}`;

tableOfContents += `
## [Episode ${episodeNum}](./${directory})
[Watch on YouTube](${video})
`
const episodeKatas = [];
for (const name of solutions) {
if (name.endsWith('.js')) {
const slug = name.replace('.js', '');
const githubUrl = `https://github.com/CodingGarden/code-katas/blob/master/${directory}/${name}`;
try {
const { data: { name: kataName, url, rank: { name: kyu, id } } } = await axios.get(`https://www.codewars.com/api/v1/code-challenges/${slug}`);
const link = `[${kataName}](./${directory}/${name})`;
console.log(slug, kyu);
episodeKatas.push({
id,
item: `* ${link} - [${kyu}](${url})\n`,
kata: {
episodeNum,
video,
slug,
githubUrl,
kataName,
kyu
}
});
} catch (error) {
console.log(slug, 'not found...')
}
}
}
episodeKatas.sort((a, b) => a.id - b.id);
episodeKatas.forEach(({ item, kata }) => {
tableOfContents += item;
katas.push(kata);
});
}
}

await fs.writeFile('katas.json', JSON.stringify(katas, null, 2), 'utf8');
await fs.writeFile('../README.md', tableOfContents, 'utf8');
})();

57 changes: 0 additions & 57 deletions episode_000/generateJSON.js

This file was deleted.

47 changes: 0 additions & 47 deletions episode_000/generateReadme.js

This file was deleted.

Loading

0 comments on commit a2efb1d

Please sign in to comment.