Skip to content

Commit

Permalink
feat: update core deps (#120)
Browse files Browse the repository at this point in the history
* feat: use swc.rs instead of babel

* BREAKING CHANGE: now we use swc.rs as main bundler and transpiler instead of babel
  - jest now uses swc
  - rollup now uses swc

* feat: benchmark now separate package with `npm start` and colored output
  - benchmark as separate package with error throw if package drops performance

* feat: all lerna packages now using scripts/pkg-task

* feat(github): publish to npm and github registry
  - when release was created this action automaticly publish packages to npm and github

* feat(github): move all from Travis CI to Github Actions
  - code analysis and tests now using github actions

* test: increase tests coverage
  - add more tests for @bbob/react, @bbob/vue2 and @bbob/parser
  • Loading branch information
JiLiZART committed Nov 28, 2021
1 parent 86d1dde commit da6709d
Show file tree
Hide file tree
Showing 66 changed files with 11,328 additions and 19,587 deletions.
8 changes: 3 additions & 5 deletions .eslintrc
@@ -1,11 +1,9 @@
{
"extends": "airbnb",
"plugins": [
"jest"
"extends": [
"airbnb"
],
"env": {
"node": true,
"jest/globals": true
"node": true
},
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/benchmark.yml
@@ -0,0 +1,19 @@
name: Benchmark
on:
push:
pull_request:
jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
run: cd benchmark && npm ci
- name: Run benchmark
run: cd benchmark && npm start
5 changes: 0 additions & 5 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -36,11 +36,6 @@ jobs:
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/npm-publish.yml
@@ -0,0 +1,50 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,41 @@
name: Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install Codecov
run: npm install -g codecov

- name: Install dependencies
run: npm ci

- name: Bootstrap packages
run: npm run bootstrap

- name: Run the lint
run: npm run lint

- name: Run the coverage
run: npm run cover

- name: Run the coverage
run: codecov
32 changes: 32 additions & 0 deletions .swcrc
@@ -0,0 +1,32 @@
{
"module": {
"type": "es6"
},
"env": {
"loose": true,
"targets": "> 0.25%, not dead"
},
"jsc": {
"loose": true,
"parser": {
"syntax": "ecmascript",
"jsx": true,
"numericSeparator": false,
"classPrivateProperty": false,
"privateMethod": false,
"classProperty": false,
"functionBind": false,
"decorators": false,
"decoratorsBeforeExport": false
},
"transform": {
"react": {
"pragma": "React.createElement",
"pragmaFrag": "React.Fragment",
"throwIfNamespace": true,
"development": false,
"useBuiltins": false
}
}
}
}
13 changes: 13 additions & 0 deletions .swcrc-commonjs
@@ -0,0 +1,13 @@
{
"module": {
"type": "commonjs",
"strict": false,
"strictMode": true,
"lazy": false,
"noInterop": false,
"ignoreDynamic": false
},
"jsc": {
"loose": true
}
}
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

56 changes: 0 additions & 56 deletions babel.config.js

This file was deleted.

31 changes: 24 additions & 7 deletions benchmark/index.js
@@ -1,7 +1,15 @@
/* eslint-disable global-require */
const Benchmark = require('benchmark');
const pico = require('picocolors');

const stub = require('./test/stub');

function formatNumber(number) {
return String(number)
// .replace(/\d{3}$/, ',$&')
.replace(/^(\d|\d\d)(\d{3},)/, '$1,$2');
}

const suite = new Benchmark.Suite();

suite
Expand Down Expand Up @@ -40,27 +48,36 @@ suite
});
})
.add('@bbob/parser lexer old', () => {
const lexer1 = require('../packages/bbob-parser/lib/lexer_old');
const lexer1 = require('@bbob/parser/lib/lexer_old');

return require('../packages/bbob-parser/lib/index').parse(stub, {
return require('@bbob/parser/lib/index').parse(stub, {
onlyAllowTags: ['ch'],
createTokenizer: lexer1.createLexer,
});
})
.add('@bbob/parser lexer', () => {
const lexer2 = require('../packages/bbob-parser/lib/lexer');
const lexer2 = require('@bbob/parser/lib/lexer');

return require('../packages/bbob-parser/lib/index').parse(stub, {
return require('@bbob/parser/lib/index').parse(stub, {
onlyAllowTags: ['ch'],
createTokenizer: lexer2.createLexer,
});
})
// add listeners
.on('cycle', (event) => {
console.log(String(event.target));
const name = event.target.name.padEnd('@bbob/parser lexer old'.length);
const hz = formatNumber(event.target.hz.toFixed(0)).padStart(10);

process.stdout.write(`${name}${pico.bold(hz)}${pico.dim(' ops/sec')}\n`);
})
.on('complete', function onComplete() {
console.log(`Fastest is ${this.filter('fastest').map('name')}`);
const name = this.filter('fastest').map('name').toString();

process.stdout.write(`Fastest is ${pico.bold(name)}`);

if (name.indexOf('@bbob') === -1) {
process.exit(1);
}
})
// run async
.run({ async: false });
.run();
53 changes: 53 additions & 0 deletions benchmark/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions benchmark/package.json
@@ -0,0 +1,22 @@
{
"name": "benchmark",
"main": "index.js",
"private": true,
"directories": {
"test": "test"
},
"scripts": {
"start": "node index.js"
},
"author": {
"name": "Nikolay Kostyurin <jilizart@gmail.com>",
"url": "https://artkost.ru/"
},
"dependencies": {
"@bbob/parser": "^2.7.1",
"benchmark": "2.1.4",
"picocolors": "1.0.0",
"xbbcode-parser": "0.1.2",
"ya-bbcode": "1.0.12"
}
}

0 comments on commit da6709d

Please sign in to comment.