From 3f679e8e0919260b02dd0bb4005b04dfbf6cb60b Mon Sep 17 00:00:00 2001 From: Artem Derevnjuk Date: Fri, 27 May 2022 14:02:20 +0300 Subject: [PATCH] chore: initial commit --- .eslintignore | 9 + .eslintrc.json | 255 + .github/workflows/auto-build.yml | 45 + .github/workflows/release.yml | 38 + .gitignore | 44 + .husky/.gitignore | 1 + .husky/commit-msg | 4 + .husky/post-commit | 4 + .husky/pre-commit | 4 + .npmignore | 8 + .prettierignore | 9 + .prettierrc | 9 + .releaserc | 59 + CONTRIBUTING.md | 206 + LICENSE | 21 + README.md | 17 + jest.config.js | 24 + package-lock.json | 18643 +++++++++++++++++++++++++++++ package.json | 73 + src/.gitkeep | 0 tsconfig.json | 34 + 21 files changed, 19507 insertions(+) create mode 100644 .eslintignore create mode 100644 .eslintrc.json create mode 100644 .github/workflows/auto-build.yml create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100644 .husky/.gitignore create mode 100755 .husky/commit-msg create mode 100755 .husky/post-commit create mode 100755 .husky/pre-commit create mode 100644 .npmignore create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 .releaserc create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 jest.config.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/.gitkeep create mode 100644 tsconfig.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..0d6b71b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,9 @@ +# Add files here to ignore them from eslint + +**/.* +/tmp +/dist +/coverage +/node_modules +*-lock.json +*.lock diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..8423c0a --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,255 @@ +{ + "root": true, + "env": { + "es6": true, + "node": true + }, + "extends": [ + "prettier", + "eslint:recommended", + "plugin:import/typescript", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/eslint-recommended" + ], + "settings": { + "import/parsers": { + "@typescript-eslint/parser": [".ts"] + }, + "import/resolver": { + "typescript": { + "project": "./tsconfig.json" + } + }, + "import/extensions": [".ts"] + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "./tsconfig.json" + }, + "plugins": ["@typescript-eslint", "import"], + "rules": { + "@typescript-eslint/explicit-member-accessibility": [ + "error", + { + "accessibility": "explicit", + "overrides": { + "accessors": "no-public", + "constructors": "no-public" + } + } + ], + "@typescript-eslint/consistent-indexed-object-style": ["error", "record"], + "@typescript-eslint/member-ordering": [ + "error", + { + "default": [ + "public-static-field", + "protected-static-field", + "private-static-field", + "public-instance-field", + "protected-instance-field", + "private-instance-field", + "constructor", + "public-static-method", + "protected-static-method", + "private-static-method", + "public-abstract-method", + "protected-abstract-method", + "private-abstract-method", + "public-instance-method", + "protected-instance-method", + "private-instance-method" + ] + } + ], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "default", + "format": ["camelCase"], + "leadingUnderscore": "forbid", + "trailingUnderscore": "forbid" + }, + { + "selector": "enumMember", + "format": ["UPPER_CASE"] + }, + { + "selector": "typeLike", + "format": ["PascalCase"] + }, + { + "selector": "function", + "format": ["PascalCase", "camelCase"] + }, + { + "selector": "variable", + "format": ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"] + }, + { + "selector": "method", + "format": ["camelCase", "PascalCase"], + "modifiers": ["static"] + }, + { + "selector": "property", + "format": ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"], + "leadingUnderscore": "allow" + }, + // https://github.com/typescript-eslint/typescript-eslint/issues/1510#issuecomment-580593245 + { + "selector": "parameter", + "format": ["camelCase"], + "leadingUnderscore": "allow" + } + ], + "@typescript-eslint/no-inferrable-types": [ + "error", + { + "ignoreParameters": true, + "ignoreProperties": true + } + ], + "@typescript-eslint/default-param-last": "error", + "@typescript-eslint/consistent-type-assertions": "error", + "@typescript-eslint/no-duplicate-imports": "error", + "@typescript-eslint/no-non-null-assertion": "error", + "@typescript-eslint/unified-signatures": "error", + "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", + "@typescript-eslint/no-parameter-properties": "off", + "@typescript-eslint/typedef": [ + "error", + { + "arrayDestructuring": true, + "arrowParameter": false, + "memberVariableDeclaration": false, + "variableDeclarationIgnoreFunction": true + } + ], + "@typescript-eslint/no-shadow": [ + "error", + { + "hoist": "all" + } + ], + "@typescript-eslint/array-type": [ + "error", + { + "default": "array", + "readonly": "array" + } + ], + "@typescript-eslint/no-floating-promises": [ + "error", + { + "ignoreVoid": true, + "ignoreIIFE": true + } + ], + "@typescript-eslint/return-await": ["error", "in-try-catch"], + "@typescript-eslint/require-await": "error", + "require-await": "off", + "no-return-await": "off", + "arrow-body-style": "error", + "camelcase": "off", + "complexity": [ + "error", + { + "max": 10 + } + ], + "eqeqeq": ["error", "smart"], + "guard-for-in": "error", + "import/no-namespace": "error", + "import/no-self-import": "error", + "import/no-absolute-path": "error", + "import/no-duplicates": "error", + "import/no-extraneous-dependencies": [ + "error", + { + "devDependencies": ["scripts/**/*.ts"], + "optionalDependencies": false, + "peerDependencies": false + } + ], + "import/no-useless-path-segments": [ + "error", + { + "noUselessIndex": true + } + ], + "import/order": [ + "error", + { + "groups": [ + "index", + ["sibling", "parent"], + "internal", + "external", + "builtin" + ] + } + ], + "max-classes-per-file": ["error", 1], + "max-depth": [ + "error", + { + "max": 2 + } + ], + "default-param-last": "off", + "no-bitwise": "error", + "no-caller": "error", + "no-console": "error", + "no-eval": "error", + "no-restricted-syntax": ["error", "ForInStatement"], + "no-throw-literal": "error", + "no-undef-init": "error", + "object-shorthand": "error", + "one-var": ["error", "never"], + "padding-line-between-statements": [ + "error", + { + "blankLine": "always", + "next": "return", + "prev": "*" + } + ], + "prefer-arrow-callback": "error", + "prefer-const": "error", + "prefer-rest-params": "error", + "prefer-spread": "error", + "no-new-func": "error", + "no-new-wrappers": "error", + "radix": "error" + }, + "overrides": [ + { + "files": ["*.js", "*.jsx"], + "rules": { + "@typescript-eslint/naming-convention": "off", + "@typescript-eslint/no-var-requires": "off", + "import/no-extraneous-dependencies": "off" + } + }, + { + "env": { + "jest": true + }, + "extends": ["plugin:jest/recommended"], + "files": ["*.spec.ts", "*.spec.tsx"], + "rules": { + "jest/prefer-expect-resolves": "error", + "jest/prefer-todo": "error", + "import/no-extraneous-dependencies": [ + "error", + { + "devDependencies": true + } + ] + } + } + ] +} diff --git a/.github/workflows/auto-build.yml b/.github/workflows/auto-build.yml new file mode 100644 index 0000000..f578e0e --- /dev/null +++ b/.github/workflows/auto-build.yml @@ -0,0 +1,45 @@ +name: CI / Automated testing + +on: + pull_request: + branches: + - '**' + +env: + DEPENDENCIES_CACHE: npm-cache + +jobs: + build-and-test: + runs-on: ubuntu-latest + needs: install-deps + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set Node.js + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: Cache npm modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ env.DEPENDENCIES_CACHE }}- + + - name: Install deps in quiet mode + run: npm ci -q + + - name: Lint application + run: npm run lint + + - name: Check formatting + run: npm run format + + - name: Build application + run: npm run build + + - name: Run tests + run: npm run test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..67f9b1c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Semantic release + +on: + push: + branches: + - master + +env: + DEPENDENCIES_CACHE: npm-cache + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + token: ${{ secrets.GPR_TOKEN }} + + - name: Set Node.js + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: Cache npm modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ env.DEPENDENCIES_CACHE }}- + + - name: Install deps in quiet mode + run: npm ci -q + + - name: Release a new version + run: npm run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6de7854 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp +/out-tsc + +# dependencies +/node_modules + +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/.coverage +/coverage +/.nyc_output +/libpeerconnection.log +npm-debug.log +yarn-error.log +testem.log +/typings + +# System Files +.DS_Store +Thumbs.db + +# Config Files +.env diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000..31354ec --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..5426a93 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx commitlint --edit $1 diff --git a/.husky/post-commit b/.husky/post-commit new file mode 100755 index 0000000..ec13430 --- /dev/null +++ b/.husky/post-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +git update-index --again diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..a165ed2 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged --relative diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..5fe91f5 --- /dev/null +++ b/.npmignore @@ -0,0 +1,8 @@ +# Add files here to ignore them from npm publishing + +/node_modules +/src +/coverage +/typings +/.idea +**/.* diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..bb79ffe --- /dev/null +++ b/.prettierignore @@ -0,0 +1,9 @@ +# Add files here to ignore them from prettier formatting + +**/.* +/tmp +/dist +/coverage +/node_modules +*-lock.json +*.lock diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..77ffc85 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "tabWidth": 2, + "singleQuote": true, + "bracketSpacing": true, + "printWidth": 80, + "trailingComma": "none", + "arrowParens": "avoid", + "quoteProps": "consistent" +} diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..ad46691 --- /dev/null +++ b/.releaserc @@ -0,0 +1,59 @@ +{ + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "parserOpts": { + "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"] + } + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "angular", + "parserOpts": { + "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"] + }, + "writerOpts": { + "commitsSort": ["subject", "scope"] + } + } + ], + [ + "@semantic-release/npm", + { + "npmPublish": false + } + ], + [ + "@semantic-release/exec", + { + "prepareCmd": "npm version --no-git-tag-version --allow-same-version ${nextRelease.version}" + } + ], + [ + "@semantic-release/git", + { + "assets": ["package*.json"], + "message": "chore(release): cut the ${nextRelease.version} release [skip ci]" + } + ], + [ + "@semantic-release/github", + { + "labels": false, + "releasedLabels": false, + "failTitle": false, + "failComment": false, + "successComment": false + } + ] + ], + "branches": [ + { + "name": "master" + } + ], + "ci": true +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a5a9259 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,206 @@ +# How to contribute to Sec Tester SDK Demo + +- [Your First Contribution](#your-first-contribution) +- [Forks and Branches](#forks-and-branches) + - [Start a feature branch](#start-a-feature-branch) + - [Commit Message Format](#commit-message-format) +- [How to work on Sec Tester SDK Demo](#how-to-work-on-sec-tester-sdk-demo) +- [Installation](#installation) + - [Build](#build) + - [Tests](#tests) + - [Linting](#linting) + - [Formatting](#formatting) + +## Your First Contribution + +Working on your first Pull Request? You can learn how from this free series, [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github). + +## Forks and Branches + +All contributions must be submitted as a [Pull Request (PR)](https://help.github.com/articles/about-pull-requests/) so you need to [fork this repo](https://help.github.com/articles/fork-a-repo/) on your GitHub account. + +The main branch aka mainline is `master`, it contains the latest code, and it is undergoing major development. Any other branch is temporary and could be deleted. You can read more about the [Trank-based development](https://trunkbaseddevelopment.com/) to get a deep understanding of how it works. + +> ⚡ All PRs must be against the `master` branch to be considered. + +A valid PR must follow these points: + +- Unit test is correctly implemented and covers the new scenario. +- If the code introduces a new feature, please add documentation or describe the feature in the PR description. +- The commit message follows [the conventional commit](#commit-message-format). +- The reviewer is assigned from the developers of the same project or code owners, possibly related to the task designed or a component affected. +- If you are going to work on new features or fix bugs or make significant architecture changes, create an issue before sending a PR, use [close keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) to link an issue, and PR. + +The PR, which is **NOT** planned to be merged, has to be converted to draft PR. + +To release a new version, you should issue the following commands: + +```bash +git fetch origin +git checkout master +git merge --squash branch-name +git commit -m 'message' +``` + +Use `--squash`, to leave the history of commits in feature-branch and prevents the Git merge command from creating a merge commit. + +### Start a feature branch + +To create a feature branch you should issue the following commands: + +```bash +git fetch +git checkout --no-track -b branch-name origin/master +``` + +Each branch name consists of a **type**, **ref,** and **subject**. + +``` +[#]/ +``` + +Where `type` - can accept one of the values are described [below](#commit-message-format), `ref` \- reference GitHub issues, Jira tickets, or other PRs. + +e.g. `fix-#184/multiple-hosts-are-duplicated` or `fix/multiple-hosts-are-duplicated` + +The `type` and `subject` are mandatory, the `ref` is optional. + +### Commit Message Format + +The commits must follow the [https://www.conventionalcommits.org/en/v1.0.0/](https://www.conventionalcommits.org/en/v1.0.0/) naming convention. Please make sure to read the full guideline. + +Each commit message consists of a **header**, a **body**, and a **footer**. + +``` +
+ + + +