Skip to content
Leonid Fenko edited this page Dec 12, 2018 · 23 revisions

Устройство репозитория

Бойлерплейт состоит из двух отдельных проектов:

  • Frontend Server - сервер для отдачи статики, SSR, сессий и склеивания GraphQL-схем. Им занимаются бэкенд-разработчики.
  • Frontend - клиентская часть фронтенда, предоставляет Frontend Server статику и middleware для SSR. Им занимаются фронтенд-разработчики.

При сборке нужно сначала собрать Frontend, а затем Frontend Server. При этом Frontend скопируется в node_modules Frontend Server, т.е. деплоить нужно только его.

Почему Frontend Server - это отдельный проект

  • Он делается другими людьми и в другом контексте, нежели Frontend.
  • Никто не хочет оставлять его в Backend или Frontend.
  • Получилось вынести его, не ломая текущий деплой.

Почему монорепозиторий

  • Frontend и Frontend Server должны четко соответствовать друг другу.
  • Так проще управлять ветками.

NOTE: It's mandatory to install git hooks before working on individual projects.

NOTE: Each package is individual project and must be opened in separate IDE window.

NOTE: There is no such thing as common dependencies hoist. Treat each package individually (list all dependencies in corresponding package.json).

Root project for high-level operations:

  • bootstrapping new project;
  • versioning;
  • git hooks installation;
  • git configuration.

Prerequisites

  • Yarn v1.9.4;
  • Node v8.11.1 (with npm v5.6.0);
  • Latest WebStorm or Visual Studio Code;

Bootstrapping new project

TBD.

Versioning

Use yarn lerna version. Simple yarn lerna version minor should be enough. Don't forget to install dependencies first: yarn i.

Git hooks installation

Just run yarn i.

Git configuration

Use yarn git:configure. Don't forget to install dependencies first: yarn i.

Yarn scripts

Package management

NOTE: It's mandatory to use yarn i instead of yarn or yarn install

  • yarn i: install dependencies with frozen lockfile;
  • yarn a: shortcut for yarn add -T -D;
  • yarn r: shortcut for yarn remove.

Prettier

NOTE: Prettier reformats code before commit.

  • prettier:all: reformat all possible files with prettier.

Linters

NOTE: Code is checked before commit.

  • lint:js: run eslint;

Git config

  • yarn git:configure: set global git config to conventional.

Git hooks (debug only)

NOTE: pre-commit yarn script should be defined in each package using lint-staged. All pre-commit scripts will be run via husky on actual commit.

  • yarn prepare-commit-msg: add task prefix to commit message, if necessary;
  • yarn commit-msg: validate commit message;
  • yarn pre-commit: linters, ts compiler errors, prettier, yarn.lock and package.json check;
  • yarn post-commit: hack to update repository in IDE.

Назад | Наверх | Внутрь | Далее

Clone this wiki locally