Skip to content

Commit

Permalink
Big redesign and refactoring (#375)
Browse files Browse the repository at this point in the history
* Start new project

* Update docs

* Improve dev docs

* Update tools and dependencies

* Move to monorepo

* Add server dir

* Update dependencies

* Add wikipedia article links

* Add browsers icons

* Add test JSON data for client

* Add test backend with v1 format

* Add test JSON data for client

* Fixed wikipedia link

* Remove server start with debugging

* Remove importing JSON only from node_modules

* Remove TypeScript from Lint script

* Update server response format

* Add fetching data from backend

* Add getting data about the region coverage

* Show browserslist erorr messages

* Update default query fixture

* Remove forced `defaults` addition to the output

* Split server and getting information about the browser

* Update client JSON test data

* Update client data fetching

* Add node.js icon and wikipedia link

* Handle all `getBrowsers()` errors

* Remove old png icons

* Remove client fixtures

* Show status 400 if the request contains errors

* Parse region with `browserslist.parse`

* Add 404 error

* Removed unnecessary assignment `GLOBAL_REGION`

* Simplified getting version data

* Getting data about Wikipedia links on client

* Output browserslist and caniuse versions on client

* Add TODO for client side data fetching

* Output server errors in JSON { message: ... }


Output server errors in JSON { message: ... }

* Throw unknown region name getRegionCoverage

* Fix error message output

* Change API endpoint to /api

* Throw unknown region error for dangerous values

* Generate 2 different errors for region

* Add TODO sort version keys by coverage

* Add `uvu` test runner to the project

* Move response generation to another files

* Add integration tests for HTTP server

* Add unit tests for response generation

* Fix regions caniuse path

* Reject `getBrowser()` errors as `Error` instances

* Get `region` from request with fallback from query (MVP)

* Update Node.js and pnpm

* Add support `Node > 0` query

* Fix pnpm cache (#295)

* Fix docs

* Simplify asdf steps

* Fix code indent in docs

* Update the API endpoint URL on the client

* Take region only from GET parameter (#297)

* Remove smart region recognition from a query

* Remove test for deleted smart region recognition

* Create `regions.json` on client's `postinstall` step (#298)

* Moved the client's data to `client/data`

* Add caniuse-lite to the client as devDependency

* Add postinstall step for generate `client/data/regions.json`

* Temporarily handled the ESLint error

* Remove `--ignore-scripts` for `postinstall` working from CI

* Remove unused wikipedia-links.json

* Show creating `region.json` message without `console.info`

* Restored `--ignore-scripts` flag for security (CI)

* Add `<select>` control for region. Fix .size-limit test (#299)

* Add `<select>` control for region in the client

* Get country names from from `window.Intl` (js 5.46kb → 4.46 kB)

* Remove unused DOMContentLoaded handler

* Added an explicit `build:regions` script

* Rename region generator script to`build-regions`

* Add `pnpm start` script for monorepo (#300)

* Added a script `pnpm start` for monorepo

* Show `Server listening on a port` in console

* Update pnpm

* Run all tests in parallel (#301)

* Typo

* Remove old code

* Migrate tests from `uvu` to `node:test` (#304)

* Migrate tests from `uvu` to `node:test`

* Use module `node:assert` with prefix like `node:test'

* Add node: prefix to all node imports

* Update npm dependencies (#307)

* Showing browser usage in the specified region (#309)

* MVP frontend (#306)

* remove reset css

* Add test JSON data for client

* add html content, remove pug

* add basic styles

* fix fixture

* add styles and generation for stats view

* fix eslint

* fix table layout

* Update browserslist 4.21.3

* Change API endpoint to /api

* add connect with backend

* submit form by enter click, refactor js code

* fix colors for dark theme (not final)

* fix show stats functions

* add showing tools versions

* move styles to separate files

* add logos, refactor introduction layout

* better styles for browser stats

* better styles for form

* add browser logos icons

* fix submit form by press enter

* add and_qq icon

* add badges about twitter and github at header

* add correct behaviour for stats placeholder

* add showing errors

* add query links

* add TODO and small fixes

* add the QueryLink component and fix link in the interactivePlaceholder

* add the real documentation and styles for them

* fix display errors

* fix display stats table at small screens

* separate Link component to the file

* add minimum of adaptivity

* remove the fixtures

* add role=presentation for all images

* remove one-letter caa variables

* fix BEM

* refactor project files structure

* code review fix (change way to set css-variables)

* add href for link to supporters

* add text for screen readers

* fix way to connect html and js to data-id attribute

* regenerate lock-file

* change way to hide texts for screen readers

* replace three dots to one symbol

* remove function private market

* remove server/index.js as an artefact after merge

* code review fix

* increase size for size-limit

* Add 3 browser icons

* Fix server URL endpoint

* fix eslint config

* remove comment code form TODO

* fix one-letter css variables

* add alt for the logo

* add link about monospace, monospace

* remove !important from styles

* format js-code

* replace role="presentation" to alt=""

Co-authored-by: Alexander Chabin <[email protected]>

* Update dependencies

* Update pnpm

* Update PostCSS

* Fix incorrect display of UTF-8 characters

* Сhange url when form are submitted and check urk when page are loaded (#321)

* change url when form are submitted and check urk when page are loaded

* rename url parameter (code review)

* handle popstate event

* Add `<select>` and coverage stats output (#303)

* Add `<select>` and coverage stats output

* Replace querySelector by `.class` to `[data-id=*]`

* Increase .size-limit with 5 KB step

* Rename `coverageCounter` to `coverageHeader`

* Remove the results from the `<form>` tag

* Add favicon, .webmanifest, OG and meta-tags (#324)

* Add favicon, .webmanifest, OG and meta-tags

* Optimize favicons

* Optimize browsers icons

* Increase size limit for site icons

* Move site icons to `/public` folder to serve static

* Add cache buster to `apple-touch-icon.png`

* Disable Vite's static convert to `base64`

* Add page `<title>`

* Fix description

* Fix merge conflict

Co-authored-by: Andrey Sitnik <[email protected]>

* Update dependencies

* Add Prettier to pre-commit hook (#329)

* remove initialization functions (close #323) (#326)

* use key name instead of keyCode (close #327) (#330)

Co-authored-by: Andrey Sitnik <[email protected]>

* Improve dx of query links (#333)

* attribute data-query is not require now

* remove attribute data-query in unnecessary places

* Add form loader (#320)

* add loader

* change loader animation function

* change loader animation function

* Add current region to URL (#335)

* handle network and 500 errors (#336)

* Add wikipedia URL to `wikipedia-links` data (#337)

* Add OG image (#325)

* Add `./` for image's path in `assets` and `public` folders

* Clear server error after use query link (#341)

* Improve browsers icons (#340)

* Add cache busters to icons `file.213213123.svg`

* Renamed and moved browsers logos files

* Add a check for the existence of the icon

* Increase size-limit for downloadable files

* Fix hover for query-link and some colors (#334)

* fix hover for query-link and some colors

* fix some typo

* design small fixes

* fix overflow for Article for does not display scrollbar

* Add static files serving to Node.js server (#319)

* Add static files serving to Node.js server

* Сaching in memory `index.html` for 3 min

* Add integrational tests for static requests
Add integrational tests for static requests

* Added a static response from the `/assets` folder

* Set caching `index.html`, remove useless `setInterval`

* Add `.html` and `.webmanifest` mime-types

* Update `sendResponse` functions

* Update `Cache-Control` for requests with cache busters

* Separated `api-` handler from another handlers

* Fix getting 404 and 500 errors in parallel

* Add `.ico` mime type

* Add tests for static files

* Update pnpm monorepo/server scripts

* Create `getFileData` function

* Add `Content-Length` header to responses

* Create script `build-static` for server

* Hot-reload build server start

* Fix running server and client build-watcher parallel

* Update `start`, `production`, `test` scripts

* Add `node:` to imports

* Add `index.html` caching only for production mode

* styles for regions select (#343)

* fix some small bugs (#346)

* Update pnpm

* Update dependencies

* Do not call `pnpm test -r` twice on CI (#347)

* Fix submit bugs. Reset `region` query-parameter (#349)

* Reset wrong `&region` in URL

* Remove form submit on page start

* Fix firefox submit with page reload

* Added tweets about browserlist (#345)

* added tweets

* optimize images

* code review fix

* fix for adaptivity

* increase size limit

* fix for adaptivity

* code review fix

Co-authored-by: Andrey Sitnik <[email protected]>

Co-authored-by: Andrey Sitnik <[email protected]>

* Hide default region from query parameters

* Add hedgehog image (#350)

* add images

* add style fot images

* replace png to svg

* add gaps for hedgehog

* increase size limit

* Update alignment and typography for `toolsVersions` block (#356)

* Use English name in countries list for consistency (#358)

* Fix extra scrolls in the query area (#359)

* Scroll into view by clicking on `queryLink` (#355)

* Show `toolsVersions` caption at the bottom (sticky footer) (#357)

* Update Size Limit and Vite

* fix #361, #354 and some other bugs (#364)

* Change default URL

* Design review fixes (#365)

* fix #361, #354 and some other bugs

* design review fix

* Move assets to components (#368)

* Sort versions by name not popularity (#363)

* Remove double vertical scroll (#370)

* Improve static file server (#369)

* Remove callbacks in `get-file-data.js`

* Add `favicon.ico` to memory cache as `index.html`

* Improve HTTP error handling (#371)

* Add deploy (#367)

* Clean up server from old logic

* Typo

* Clean up scripts for future ssdeploy CLI

* Dockernize application

* Add ssdeploy

* Fix CI

* Fix regions on preview

* Try to fix region build

* Fix client dependencies

* Fix imports

* Add deploy script

* Typo

* Simplify API url

Co-authored-by: Alexander Chabin <[email protected]>
Co-authored-by: Sofi Valitova <[email protected]>
  • Loading branch information
3 people authored Aug 13, 2022
1 parent f18f79e commit 2e62087
Show file tree
Hide file tree
Showing 143 changed files with 5,841 additions and 513 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules/

server/test/
client/
!client/dist/

.*
README.md
LICENSE
nano-staged.json
simple-git-hooks.json
Dockerfile
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.svg]
insert_final_newline = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@logux/eslint-config/esm"
}
17 changes: 0 additions & 17 deletions .eslintrc.json

This file was deleted.

165 changes: 165 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: CI
on:
push:
branches:
- main
pull_request:
env:
FORCE_COLOR: 2
jobs:

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Install asdf
uses: asdf-vm/actions/setup@v1
- name: Cache asdf
id: asdf-cache
uses: actions/cache@v3
with:
path: ~/.asdf
key: asdf-${{ hashFiles('**/.tool-versions') }}
- name: Install asdf tools
if: steps.asdf-cache.outputs.cache-hit != 'true'
uses: asdf-vm/actions/install@v1
- name: Cache pnpm modules
uses: actions/cache@v3
env:
cache-name: cache-pnpm-modules
with:
path: ~/.local/share/pnpm/
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build regions
run: pnpm -r build:regions
- name: Run tests
run: pnpm test

deploy:
name: Deploy
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Notify about new deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: production
- name: Checkout the repository
uses: actions/checkout@v3
- name: Install asdf
uses: asdf-vm/actions/setup@v1
- name: Cache asdf
id: asdf-cache
uses: actions/cache@v3
with:
path: ~/.asdf
key: asdf-${{ hashFiles('**/.tool-versions') }}
- name: Cache pnpm modules
uses: actions/cache@v3
env:
cache-name: cache-pnpm-modules
with:
path: ~/.local/share/pnpm/
key: pnpm-production-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install production dependencies
run: pnpm install --prod --frozen-lockfile --ignore-scripts
- name: Build regions
run: pnpm -r build:regions
- name: Build static files
run: pnpm build
- name: Auth Google Cloud
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCLOUD_AUTH }}
- name: Install Google Cloud
uses: google-github-actions/setup-gcloud@v0
- name: Deploy files
id: deploy
run: ./node_modules/.bin/ssdeploy deploy --verbose
env:
GCLOUD_APP: ${{ secrets.GCLOUD_APP }}
GCLOUD_PROJECT: ${{ secrets.GCLOUD_PROJECT }}
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
- name: Update deployment status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
env_url: ${{ steps.deploy.outputs.url }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}

preview:
name: Preview
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps:
- name: Notify about new deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
env: preview-${{ github.event.number }}
- name: Checkout the repository
uses: actions/checkout@v3
- name: Install asdf
uses: asdf-vm/actions/setup@v1
- name: Cache asdf
id: asdf-cache
uses: actions/cache@v3
with:
path: ~/.asdf
key: asdf-${{ hashFiles('**/.tool-versions') }}
- name: Install asdf tools
if: steps.asdf-cache.outputs.cache-hit != 'true'
uses: asdf-vm/actions/install@v1
- name: Cache pnpm modules
uses: actions/cache@v3
env:
cache-name: cache-pnpm-modules
with:
path: ~/.local/share/pnpm/
key: pnpm-production-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install production dependencies
run: pnpm install --prod --frozen-lockfile --ignore-scripts
- name: Build regions
run: pnpm -r build:regions
- name: Build static files
run: pnpm build
- name: Auth Google Cloud
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCLOUD_AUTH }}
- name: Install Google Cloud
uses: google-github-actions/setup-gcloud@v0
- name: Deploy files
id: deploy
run: ./node_modules/.bin/ssdeploy preview $PR --verbose
env:
PR: ${{ github.event.number }}
GCLOUD_APP: ${{ secrets.GCLOUD_APP }}
GCLOUD_PROJECT: ${{ secrets.GCLOUD_PROJECT }}
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
- name: Update deployment status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
env_url: ${{ steps.deploy.outputs.url }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
50 changes: 50 additions & 0 deletions .github/workflows/close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Clean Preview
on:
pull_request:
types: [ closed ]
jobs:
close:
runs-on: ubuntu-latest
steps:
- name: Clean from GitHub
uses: bobheadxi/deployments@v1
with:
step: delete-env
token: ${{ secrets.GITHUB_TOKEN }}
env: preview-${{ github.event.number }}
- name: Checkout the repository
uses: actions/checkout@v3
- name: Install asdf
uses: asdf-vm/actions/setup@v1
- name: Cache asdf
id: asdf-cache
uses: actions/cache@v3
with:
path: ~/.asdf
key: asdf-${{ hashFiles('**/.tool-versions') }}
- name: Install asdf tools
if: steps.asdf-cache.outputs.cache-hit != 'true'
uses: asdf-vm/actions/install@v1
- name: Cache pnpm modules
uses: actions/cache@v3
env:
cache-name: cache-pnpm-modules
with:
path: ~/.local/share/pnpm/
key: pnpm-production-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install --prod --frozen-lockfile --ignore-scripts
- name: Auth Google Cloud
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCLOUD_AUTH }}
- name: Install Google Cloud
uses: google-github-actions/setup-gcloud@v0
- name: Clean from Google Cloud
run: ./node_modules/.bin/ssdeploy close $PR --verbose
env:
PR: ${{ github.event.number }}
GCLOUD_APP: ${{ secrets.GCLOUD_APP }}
GCLOUD_PROJECT: ${{ secrets.GCLOUD_PROJECT }}
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/test.yml

This file was deleted.

8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
node_modules
*.log
.DS_Store
package-lock.json

.vercel
node_modules/
dist/
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "avoid",
"jsxSingleQuote": false,
"quoteProps": "consistent",
"semi": false,
"singleQuote": true,
"trailingComma": "none"
}
11 changes: 11 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@logux/stylelint-config",
"ignoreFiles": ["dist/**/*"],
"rules": {
"function-disallowed-list": ["rgb", "rgba", "hsl", "hsla"],
"alpha-value-notation": "percentage",
"color-named": "never",
"declaration-block-no-redundant-longhand-properties": null,
"font-family-no-duplicate-names": [true, { "ignoreFontFamilyNames":"monospace"}]
}
}
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodejs 18.7.0
pnpm 7.9.1
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:18-alpine

ENV NODE_ENV production
WORKDIR /var/www
COPY --chown=node:node . /var/www

RUN corepack enable
RUN corepack prepare [email protected] --activate
COPY ./pnpm-workspace.yaml /var/www/
COPY ./package.json /var/www/
COPY ./pnpm-lock.yaml /var/www/
COPY ./server/ /var/www/server/
RUN pnpm install --filter ./server --prod --frozen-lockfile --ignore-scripts
COPY ./client/dist/ /var/www/client/dist/

CMD "node" "server/index.js"
Loading

0 comments on commit 2e62087

Please sign in to comment.