Skip to content

Commit

Permalink
chore: setup project
Browse files Browse the repository at this point in the history
  • Loading branch information
Rue-pro committed Mar 6, 2024
0 parents commit ef8d8b5
Show file tree
Hide file tree
Showing 35 changed files with 4,818 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"type-enum": [
2,
"always",
[
"ci",
"chore",
"docs",
"ticket",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test"
]
]
}
}
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
public
dist
coverage
.scannerwork
12 changes: 12 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['prettier'],
}
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local
coverage
.scannerwork

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
5 changes: 5 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# npm run coverage
# npm run test
7 changes: 7 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"*.{js,jsx,ts,tsx}": [
"eslint --quiet --fix",
"prettier --write --ignore-unknown"
],
"*.{json,html}": ["prettier --write --ignore-unknown"]
}
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
public
dist
coverage
.scannerwork
23 changes: 23 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"bracketSpacing": true,
"jsxBracketSameLine": true,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"printWidth": 80,
"semi": false,
"arrowParens": "always",
"endOfLine": "auto",
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrder": [
"^@app/(.*)$",
"^@widgets/(.*)$",
"^@features/(.*)$",
"^@entities/(.*)$",
"^@shared/(.*)$",
"^@tests/(.*)$",
"^[./]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
}
11 changes: 11 additions & 0 deletions e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect, test } from '@playwright/test'

test('Test for testing playwright functionality, should visit google.com', async ({
page,
}) => {
await page.goto('https://www.google.com/')

const mailText = page.getByText('Gmail')

expect(mailText).toBeDefined()
})
10 changes: 10 additions & 0 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@app/*": ["../src/app/*"],
"@entities/*": ["../src/entities/*"],
"@shared/*": ["../src/shared/*"]
}
}
}
50 changes: 50 additions & 0 deletions package copy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "flashcardis",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build && vite build --config=vite.config.ankiWeb.ts && vite build --config=vite.config.dictionary.ts && vite build --config=vite.config.background.ts",
"preview": "vite preview",
"test": "vitest",
"test:e2e": "playwright test",
"coverage": "vitest run --coverage",
"clean": "vite clean",
"prepare": "husky install"
},
"dependencies": {
"lodash": "4.17.21",
"preact": "10.19.3",
"uuid": "9.0.1"
},
"devDependencies": {
"@commitlint/cli": "18.4.4",
"@commitlint/config-conventional": "18.4.4",
"@playwright/test": "1.42.1",
"@preact/preset-vite": "2.7.0",
"@testing-library/preact": "3.2.3",
"@testing-library/preact-hooks": "1.1.0",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@types/chrome": "0.0.254",
"@types/lodash": "4.14.202",
"@types/node": "20.10.6",
"@types/uuid": "9.0.7",
"@typescript-eslint/eslint-plugin": "6.17.0",
"@typescript-eslint/parser": "6.17.0",
"@vitest/coverage-v8": "1.1.3",
"autoprefixer": "10.4.17",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.2",
"husky": "8.0.3",
"jest-webextension-mock": "3.8.9",
"jsdom": "24.0.0",
"lint-staged": "15.2.0",
"prettier": "3.1.1",
"sass": "1.70.0",
"typescript": "5.2.2",
"vite": "5.0.8",
"vitest": "1.1.3"
}
}
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "flashcardis",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "vite dev --config=vite.config.popup.ts",
"build": "tsc && vite build --config=vite.config.popup.ts && vite build --config=vite.config.ankiWeb.ts && vite build --config=vite.config.dictionary.ts && vite build --config=vite.config.background.ts",
"test": "vitest",
"test:e2e": "playwright test",
"coverage": "vitest run --coverage",
"clean": "vite clean",
"prepare": "husky install"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"preact": "10.19.6"
},
"devDependencies": {
"@commitlint/cli": "19.0.3",
"@commitlint/config-conventional": "19.0.3",
"@playwright/test": "1.42.1",
"@preact/preset-vite": "2.8.1",
"@testing-library/preact": "3.2.3",
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@types/chrome": "0.0.262",
"@types/node": "20.11.25",
"@typescript-eslint/eslint-plugin": "7.1.1",
"@typescript-eslint/parser": "7.1.1",
"@vitest/coverage-v8": "1.3.1",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"husky": "9.0.11",
"jsdom": "24.0.0",
"lint-staged": "15.2.2",
"prettier": "3.2.5",
"sass": "1.71.1",
"typescript": "5.4.2",
"vite": "5.1.5",
"vitest": "1.3.1"
}
}
68 changes: 68 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { defineConfig, devices } from '@playwright/test'

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
headless: false,
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
})
Loading

0 comments on commit ef8d8b5

Please sign in to comment.