Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 2
indent_style = space
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
dist
lib
esm
next
coverage
.nyc_output
*.d.ts
target
114 changes: 114 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
parser: '@typescript-eslint/parser'

parserOptions:
ecmaVersion: 2020
sourceType: module

env:
browser: true
es6: true
node: true
jest: true

globals:
# false means readonly
globalThis: false

plugins:
- import
- sonarjs

extends:
- eslint:recommended
- plugin:sonarjs/recommended
- plugin:prettier/recommended

settings:
react:
pragma: React
version: 16.12.0

rules:
# 0 = off, 1 = warn, 2 = error
'no-undef': 2
'no-console': [2, { allow: ['error', 'warn', 'info', 'assert'] }]
'comma-dangle': ['error', 'only-multiline']
'no-unused-vars': 0
'no-var': 2
'one-var-declaration-per-line': 2
'prefer-const': 2
'no-const-assign': 2
'no-duplicate-imports': 2
'no-use-before-define': [2, { 'functions': false, 'classes': false }]
'eqeqeq': [2, 'always', { 'null': 'ignore' }]
'no-case-declarations': 0
'no-restricted-syntax':
[
2,
{
'selector': 'BinaryExpression[operator=/(==|===|!=|!==)/][left.raw=true], BinaryExpression[operator=/(==|===|!=|!==)/][right.raw=true]',
'message': Don't compare for equality against boolean literals,
},
]

'import/first': 2
'import/newline-after-import': 2

'sonarjs/cognitive-complexity': 0
'sonarjs/no-duplicate-string': 0
'sonarjs/no-big-function': 0
'sonarjs/no-identical-functions': 0
'sonarjs/no-small-switch': 0

overrides:
- files:
- packages/**/*.ts
rules:
'no-unused-vars': [2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]

- files:
- packages/**/*.ts
plugins:
- '@typescript-eslint'
parserOptions:
project: ./tsconfig.json
rules:
# constructor(private readonly foo: string) {} style declaration
'no-useless-constructor': 0
'@typescript-eslint/no-useless-constructor': 2

# conflict function override
'no-dupe-class-members': 0
'@typescript-eslint/no-dupe-class-members': 2

# constructor(private readonly foo: string) {} style declaration
'no-empty-function': 0

'@typescript-eslint/no-empty-function': 2

'@typescript-eslint/no-unused-vars':
[2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
'@typescript-eslint/member-ordering':
[
2,
{
default:
[
'public-static-field',
'protected-static-field',
'private-static-field',
'public-static-method',
'protected-static-method',
'private-static-method',
'public-instance-field',
'protected-instance-field',
'private-instance-field',
'public-constructor',
'protected-constructor',
'private-constructor',
'public-instance-method',
'protected-instance-method',
'private-instance-method',
],
},
]
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [Brooooooklyn]
144 changes: 144 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: CI

on: [push, pull_request]

jobs:
lint_and_build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

name: stable - ${{ matrix.os }} - node@12
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 12

- name: Set platform name
run: |
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
echo "::set-env name=PLATFORM_NAME::$NODE_PLATFORM_NAME"
shell: bash

- name: Install llvm
if: matrix.os == 'windows-latest'
run: choco install -y llvm

- name: Set llvm path
if: matrix.os == 'windows-latest'
uses: allenevans/set-env@v1.0.0
with:
LIBCLANG_PATH: 'C:\Program Files\LLVM\bin'

- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: stable-${{ matrix.os }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-${{ matrix.os }}gnu-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: stable-${{ matrix.os }}gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}

- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-${{ hashFiles('yarn.lock') }}
restore-keys: |
npm-cache-

- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org

- name: 'Lint'
run: yarn lint
if: matrix.os == 'ubuntu-latest'

- name: typecheck
run: yarn typecheck
if: matrix.os == 'ubuntu-latest'

- name: Run build
run: npx lerna run build --stream -- --platform

- name: Upload crc32 artifact
uses: actions/upload-artifact@v1
with:
name: crc32.${{ env.PLATFORM_NAME }}.node
path: packages/crc32/crc32.${{ env.PLATFORM_NAME }}.node

- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache

test_binding:
name: Test bindings on ${{ matrix.os }} - node@${{ matrix.node }}
needs: lint_and_build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['10', '12', '14']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Set platform name
run: |
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
echo "::set-env name=PLATFORM_NAME::$NODE_PLATFORM_NAME"
shell: bash

- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-${{ hashFiles('yarn.lock') }}
restore-keys: |
npm-cache-

- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org

- name: Download crc32 artifact
uses: actions/download-artifact@v1
with:
name: crc32.${{ env.PLATFORM_NAME }}.node
path: packages/crc32

- name: Test bindings
run: yarn test
25 changes: 25 additions & 0 deletions .github/workflows/dependabot-auto-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Dependabot auto merge

on:
check_suite:
types:
- completed
pull_request:
types:
- labeled
- unlabeled
- synchronize
- opened
- edited
- ready_for_review
- reopened
- unlocked

jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- name: auto-merge
uses: ridedott/dependabot-auto-merge-action@master
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,5 @@ temp/

# End of https://www.gitignore.io/api/node

*.node
*.node
lib
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
node_modules
lib
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
members = [
"./packages/png"
"./packages/crc32"
]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# node-rs

When `NodeJS` meet `Rust` = 🚀
6 changes: 2 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"packages": [
"packages/*"
],
"packages": ["packages/*"],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.0.0"
"version": "independent"
}
Loading