From 448fa22705129e1603a4cf3116fdeea05a5bd675 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 30 Apr 2023 15:55:44 +0300 Subject: [PATCH] git hooks --- .editorconfig | 5 +++++ .githooks/pre-commit | 23 +++++++++++++++++++++++ README.md | 14 +++++++++++++- docs/ru.md | 42 ++++++++++++++++++++++++++++++++++++++++++ src/js/main.js | 3 +-- 5 files changed, 84 insertions(+), 3 deletions(-) create mode 100755 .githooks/pre-commit create mode 100644 docs/ru.md diff --git a/.editorconfig b/.editorconfig index 24fe3d2..7973a62 100644 --- a/.editorconfig +++ b/.editorconfig @@ -26,6 +26,11 @@ indent_size = 4 [*.md] trim_trailing_whitespace = false +indent_size = unset + +[.githooks/**] +indent_style = space +indent_size = 2 [{node_modules/**,.git/**}] charset = unset diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..de22584 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,23 @@ +#!/bin/sh + +# prettier +echo "Checking by Prettier..." +prettier --check . &> /dev/null + +if [[ "$?" == 0 ]]; then + echo "✅ Prettier" +else + echo "⛔ Prettier error" + exit 1 +fi + +# editorconfig +echo "Checking by EditorConfig..." +ec . &> /dev/null + +if [[ "$?" == 0 ]]; then + echo "✅ EditorConfig" +else + echo "⛔ EditorConfig error" + exit 1 +fi diff --git a/README.md b/README.md index 23f22a2..17bce1e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![engine_icon](/src/icons/apple-touch-icon.png) -## Build `ENGINE` +# Build `ENGINE` ```sh # install rollup @@ -10,3 +10,15 @@ npm install --global rollup cd src/js/ rollup main.js --file engine.js --format es ``` + +# Contribute + +## Git hooks + +### pre-commit + +**Requiments:** + +1. NPM module `prettier`. +2. [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) + (_Go application_). diff --git a/docs/ru.md b/docs/ru.md new file mode 100644 index 0000000..902eb98 --- /dev/null +++ b/docs/ru.md @@ -0,0 +1,42 @@ +# Документация + +## App + +Основной класс движка. + +При инициализации самостоятельно добавляет HTML элемент `` +в тег ``. + +### Параметры + +- `w` — ширина холста в пикселях. +- `h` — высота холста в пикселях. +- `options` — объект опций. + +**Имеет следующую структуру:** + +```text +{ + backgroundColor: '#ffcc68', + welcome: true, +} +``` + +- backgroundColor — фон холста. + По умолчанию `#ffcc68`. + +- welcome — `bool` тип. + Отображает информацию о движке в **Console**. + По умолчанию `true`. + +### Пример использования + +```javascript +// init app +let app = new App(400, 400); + +// add app view in document +window.addEventListener('DOMContentLoaded', () => { + document.body.appendChild(app.view); +}); +``` diff --git a/src/js/main.js b/src/js/main.js index 6fb27c2..c355af5 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -7,7 +7,6 @@ export class App { #version; constructor( - canvas, w, h, options = { @@ -15,7 +14,7 @@ export class App { welcome: true, } ) { - this.#version = '0.1.0'; + this.#version = 'beeeeeeta'; this.view = document.createElement('canvas');