Skip to content

Design the Boilerplate

Yu Chung-Jen edited this page Jun 28, 2018 · 3 revisions

Targets

  • Environment Template
    • Features:
      • It's the general base of all projects, but the derivative content may differentiate by projects.
    • The actions we need are:
      • Init new project base on the template
      • Update the old project with new template
    • Contains:
      • HTML template
      • Package dependencies (package.json)
      • Bundle tools (webpack, babel)
      • Development tools (eslint)
      • Tests ([TODO] check if the elements that all projects should have exist when build)
  • Deployment Tool
    • Features:
      • Only need to config the setting once when init (to tell the tool your project id and bucket name).
      • Deploy all projects with the latest deployment tool (There's no need to use the older versions),
      • Take a config file or send arguments through cli.
    • The actions we need are:
      • Deploy. Options are:
        • to production or staging
        • select which files to be uploaded
        • automatically detect which files have changed and just upload them / upload and overwrite all files
        • the cache time of the files to be upload
      • Set cache time of uploaded files.

Solutions

There are three possible solutions:

  1. Build the functions as an independent npm package.
  2. Separate the projects as subfolder, handle the functions at the root of the folder.
  3. Separate the projects into different branches.

Check if each soluton meets our target features and actions needed:

Environment Template

independent package handle at the top of projects separate projects into branches
Properties
the derivative content may differentiate by projects O O O
The actions we need
Init new project base on the template O O O
Update the old project with new template X X O

Deployment Tool

independent package handle at the top of projects separate projects into branches (save the tools in template branch)
Properties
Only need to config the setting once when init O (if it is globally installed) O O
Deploy all projects with the latest deployment tool O (if it is globally installed) O X (need to update the project manually after scripts updated)
Take a config file or send arguments through cli O O O
The actions we need
Deploy with options O O O
Set cache time of uploaded files O O O

Conclusion:

  1. For environment template, only separate projects into branches can help us "update the old project with new template" with simple git merge.
  2. But if we save deployment tools in the template branch, we need to update the project manually after template updated. So we have to abstract deployment tools out of the project.
  3. We can use "globally installed package" or make a new repo that handle the deployment of its subfolder. But former is much more flexible (no need to place the folder to be uploaded under the handler).
Clone this wiki locally