Forget Boilerplate, Use Repository Templates
Forget Boilerplate, Use Repository Templates! - Better Programming
Save time and focus on your project-specific tasksPhoto by José Manuel Benito on WikipediaDevelopers usually spend a lot of time bootstrapping their new projects using their favorite tools and libraries. But this approach is inconvenient when they are often prototyping new ideas.Luckily, there is a feature that allows developers to deal with boilerplate code only once, avoiding all the extra work every time they want to try something new.This feature is called “template repository” and is available on GitHub. Gitlab also offers the same feature for Premium users.Repository TemplatesWhen a repository is labeled as a template, it can be later reused as a baseline project, meaning that developers need to set up everything only once.To be able to generate a baseline template repository, first, it is required to create a normal repository, and then the developer needs to transform it into a template.This feature allows devs to reuse the “base code” the next time they need to work on a new project, focusing only on the project tasks, centering their attention on the main features very quickly.How to Reuse a Template as a Baseline for a New ProjectIf you see a repository in GitHub marked as a template, you can use the option called “Use this template”.Pressing the button takes you to a configuration page, where you enter the name of the new project, allowing you to bootstrap your application using that codebase in seconds.Available Templates on GitHubOfficial project teams are able to provide proper templates with different options like React/Redux or React/Mobx ready to use for the dev community.It is also very simple for devs to extend those base templates or build their own ones on top of the existing official starters. They just need to add their own personal libraries for that specific codebase, and even still to convert it to another new template and reuse it later on. There are many non-template starter repositories on GitHub that can be converted to templates repositories, marking them as “Template”.This feature was available from June 2019 in GitHub.Example of Libraries and Configuration for a Baseline JS TemplateThese are some of the libraries and configuration I included in my template project:ReactJS & TypeScript: run npx create-react-app my-app — typescript and then convert the project to a template.ESLintPrettierWebpack and have the definitions of the scripts you like to run..gitignoreAdd .editorConfigOnce you have your own perfect setup, then you mark it as a template. You can start using it as a base point in the future.Templates are extremely useful for people in research and innovation teams that prototype a lot.Thanks for reading! If you have any suggestions or ideas, please let me know.