From 897e98de3ad2e8dca2c607d0fee4244b26c0a843 Mon Sep 17 00:00:00 2001 From: Nikolay Makhonin Date: Sun, 26 Jun 2022 09:26:28 +0400 Subject: [PATCH 01/14] develop: module template... --- .babelrc.cjs | 22 + .browserslistrc | 7 + .eslintignore | 13 +- .eslintrc | 8 - .eslintrc.cjs | 7 + .gitattributes | 1 + .github/workflows/test.yml | 100 + .gitignore | 16 +- .idea/.gitignore | 9 + .idea/inspectionProfiles/Project_Default.xml | 19 + .idea/jsLibraryMappings.xml | 8 + .idea/jsLinters/eslint.xml | 8 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/rdtsc.iml | 16 + .idea/runConfigurations.xml | 10 + .idea/runConfigurations/build.xml | 12 + .idea/runConfigurations/coverage_check.xml | 12 + .idea/runConfigurations/coveralls.xml | 12 + .idea/runConfigurations/karma.xml | 11 + .idea/runConfigurations/lint.xml | 12 + .idea/runConfigurations/lint_fix.xml | 12 + .idea/runConfigurations/lint_wizard.xml | 12 + .idea/runConfigurations/mocha.xml | 14 + .idea/runConfigurations/mocha_perf.xml | 14 + .idea/runConfigurations/mocha_watch.xml | 14 + .idea/runConfigurations/prepublishOnly.xml | 12 + .idea/runConfigurations/test_mocha.xml | 12 + .idea/runConfigurations/test_mocha_ci.xml | 12 + .../runConfigurations/test_mocha_coverage.xml | 12 + .idea/vcs.xml | 6 + .mocharc.cjs | 14 + .npmignore | 5 + .nycrc.json | 10 - .travis.yml | 52 - @types/register/index.d.ts | 1 + LICENSE | 119 +- README.md | 15 +- docs/pnpm.md | 7 + karma.conf.js | 156 + nyc.config.mjs | 7 + package.json | 117 +- pnpm-lock.yaml | 6480 +++++++++++++++++ rollup.config.js | 244 + src/index.ts | 3 + test/.eslintrc | 5 - tsconfig.eslint.json | 3 + tsconfig.json | 45 + 48 files changed, 7482 insertions(+), 238 deletions(-) create mode 100644 .babelrc.cjs create mode 100644 .browserslistrc delete mode 100644 .eslintrc create mode 100644 .eslintrc.cjs create mode 100644 .gitattributes create mode 100644 .github/workflows/test.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/jsLibraryMappings.xml create mode 100644 .idea/jsLinters/eslint.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/rdtsc.iml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/runConfigurations/build.xml create mode 100644 .idea/runConfigurations/coverage_check.xml create mode 100644 .idea/runConfigurations/coveralls.xml create mode 100644 .idea/runConfigurations/karma.xml create mode 100644 .idea/runConfigurations/lint.xml create mode 100644 .idea/runConfigurations/lint_fix.xml create mode 100644 .idea/runConfigurations/lint_wizard.xml create mode 100644 .idea/runConfigurations/mocha.xml create mode 100644 .idea/runConfigurations/mocha_perf.xml create mode 100644 .idea/runConfigurations/mocha_watch.xml create mode 100644 .idea/runConfigurations/prepublishOnly.xml create mode 100644 .idea/runConfigurations/test_mocha.xml create mode 100644 .idea/runConfigurations/test_mocha_ci.xml create mode 100644 .idea/runConfigurations/test_mocha_coverage.xml create mode 100644 .idea/vcs.xml create mode 100644 .mocharc.cjs create mode 100644 .npmignore delete mode 100644 .nycrc.json delete mode 100644 .travis.yml create mode 100644 @types/register/index.d.ts create mode 100644 docs/pnpm.md create mode 100644 karma.conf.js create mode 100644 nyc.config.mjs create mode 100644 pnpm-lock.yaml create mode 100644 rollup.config.js create mode 100644 src/index.ts delete mode 100644 test/.eslintrc create mode 100644 tsconfig.eslint.json create mode 100644 tsconfig.json diff --git a/.babelrc.cjs b/.babelrc.cjs new file mode 100644 index 0000000..27c6ea5 --- /dev/null +++ b/.babelrc.cjs @@ -0,0 +1,22 @@ +'use strict' + +module.exports = function (api) { + api.cache(true) + + return { + presets: [ + ['@babel/preset-env', { + loose: true, // simple set property instead readonly defineProperty; +support named export for rollup-plugin-commonjs + }], + ], + plugins: [ + '@babel/plugin-syntax-dynamic-import', + ['@babel/plugin-transform-runtime', { + corejs : 3, // for support flatMap etc... + useESModules: true, + }], + // preset/env no loose: + ['@babel/plugin-transform-classes', {loose: false}], + ], + } +} diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 0000000..2ad4e3b --- /dev/null +++ b/.browserslistrc @@ -0,0 +1,7 @@ +> 1% +not IE <= 20 +safari >= 10 # iPhone >= 5 +chrome >= 39 # Android >= 5.1 +UCAndroid >= 12 +op_mob >= 39 +FirefoxAndroid >= 11 diff --git a/.eslintignore b/.eslintignore index 62562b7..d4757dd 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,11 @@ -coverage -node_modules +# copy of .gitignore +/dist/**/test/** +/dist/**/*.test.* +/tmp/ +/node_modules/ + +# additional rules +/.idea/ +/.github/ +/dist/ +/docs/ diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index c529225..0000000 --- a/.eslintrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "standard", - "rules": { - "indent": ["error", "tab"], - "no-tabs": ["error", { allowIndentationTabs: true }], - "no-trailing-spaces": ["off"] - } -} diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..1dba69d --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,7 @@ +'use strict' + +module.exports = { + 'extends': [ + 'pro', + ], +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..42180bd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,100 @@ +name: Test +'on': + push: + branches: + - 'master' + pull_request: + branches: + - 'master' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 14.x] + + steps: + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Check secrets + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + run: | + node -e "o=['COVERALLS_REPO_TOKEN'].filter(o=>!process.env[o]);o.length&&(console.log('You should set env variables: '+o.join(', ')),process.exit(1))" + + - uses: actions/checkout@v2 + + # from: https://github.com/pnpm/action-setup + - name: Install pnpm + id: pnpm-install + uses: pnpm/action-setup@v2.1.0 + with: + version: 7 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: | + pnpm install --frozen-lockfile + + - name: Lint + shell: bash + run: | + pnpm run audit + pnpm run lint + + - name: Build + shell: bash + run: | + pnpm run build + + - name: Mocha tests + shell: bash + run: | + pnpm run test:mocha:ci + + - name: Install chromium dependencies + if: ${{ matrix.node-version == '18.x' }} + run: | + sudo apt install libudev-dev libgtk2.0-0 + sudo ln -sf /lib/$(arch)-linux-gnu/libudev.so.1 /lib/$(arch)-linux-gnu/libudev.so.0 + + - name: Install chromium + if: ${{ matrix.node-version == '18.x' }} + uses: browser-actions/setup-chrome@latest + with: + chrome-version: 297097 # Chromium 39.0.2171.99 (Android - 5.1.0) + + - name: Karma tests + if: ${{ matrix.node-version == '18.x' }} + uses: GabrielBB/xvfb-action@v1 + env: + CHROMIUM_BIN: /opt/hostedtoolcache/chromium/297097/x64/chrome + with: + run: | + pnpm run test:karma + + - name: Coveralls + if: ${{ matrix.node-version == '18.x' }} + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + shell: bash + run: | + pnpm add coveralls -D + pnpm run coveralls diff --git a/.gitignore b/.gitignore index c99439c..dfa9daf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ -/build -node_modules -/.idea -*.bak -*.cmd +/dist/**/test/** +/dist/**/*.test.* +/tmp/ +/node_modules/ +/*.log + +/.eslintcache /package-lock.json -tmp \ No newline at end of file +/yarn.lock +/yarn-error.log +/.pnpm-debug.log diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5af313d --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,9 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ +/codestream.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..06d9205 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..6e3cd52 --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jsLinters/eslint.xml b/.idea/jsLinters/eslint.xml new file mode 100644 index 0000000..2938fb2 --- /dev/null +++ b/.idea/jsLinters/eslint.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5bd1f3a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rdtsc.iml b/.idea/rdtsc.iml new file mode 100644 index 0000000..8ee1f82 --- /dev/null +++ b/.idea/rdtsc.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/build.xml b/.idea/runConfigurations/build.xml new file mode 100644 index 0000000..0a4f98f --- /dev/null +++ b/.idea/runConfigurations/build.xml @@ -0,0 +1,12 @@ + + + + + +