Skip to content

Commit c0e553e

Browse files
scaffolding
1 parent e5f4fe5 commit c0e553e

14 files changed

+2436
-4338
lines changed

.clang-format

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
BasedOnStyle: Google
2+
AllowShortFunctionsOnASingleLine: Empty
3+
AllowShortIfStatementsOnASingleLine: false
4+
AllowShortLoopsOnASingleLine: false
5+
BinPackArguments: false
6+
BinPackParameters: false
7+
ColumnLimit: 100
8+
Cpp11BracedListStyle: true
9+
DerivePointerAlignment: false
10+
IndentWidth: 4
11+
MaxEmptyLinesToKeep: 1
12+
NamespaceIndentation: None
13+
SpaceBeforeAssignmentOperators: true
14+
Standard: Cpp11
15+
UseTab: Never

.eslintrc.json

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:prettier/recommended",
6+
"plugin:@typescript-eslint/eslint-recommended",
7+
"plugin:@typescript-eslint/recommended"
8+
],
9+
"ignorePatterns": "lib/**/*",
10+
"env": {
11+
"node": true,
12+
"mocha": true,
13+
"es6": true
14+
},
15+
"parserOptions": {
16+
"ecmaVersion": 2019
17+
},
18+
"plugins": [
19+
"@typescript-eslint",
20+
"prettier"
21+
],
22+
"rules": {
23+
"no-restricted-properties": [
24+
"error",
25+
{
26+
"object": "describe",
27+
"property": "only"
28+
},
29+
{
30+
"object": "it",
31+
"property": "only"
32+
},
33+
{
34+
"object": "context",
35+
"property": "only"
36+
}
37+
],
38+
"prettier/prettier": "error",
39+
"no-console": "error",
40+
"valid-typeof": "error",
41+
"eqeqeq": [
42+
"error",
43+
"always",
44+
{
45+
"null": "ignore"
46+
}
47+
],
48+
"strict": [
49+
"error",
50+
"global"
51+
],
52+
"no-restricted-syntax": [
53+
"error",
54+
{
55+
"selector": "TSEnumDeclaration",
56+
"message": "Do not declare enums"
57+
},
58+
{
59+
"selector": "BinaryExpression[operator=/[=!]==/] Identifier[name='undefined']",
60+
"message": "Do not strictly check undefined"
61+
},
62+
{
63+
"selector": "BinaryExpression[operator=/[=!]==/] Literal[raw='null']",
64+
"message": "Do not strictly check null"
65+
},
66+
{
67+
"selector": "BinaryExpression[operator=/[=!]==?/] Literal[value='undefined']",
68+
"message": "Do not strictly check typeof undefined (NOTE: currently this rule only detects the usage of 'undefined' string literal so this could be a misfire)"
69+
}
70+
],
71+
"@typescript-eslint/no-require-imports": "off"
72+
},
73+
"overrides": [
74+
{
75+
"files": [
76+
"test/**/*ts"
77+
],
78+
"rules": {
79+
// chat `expect(..)` style chaining is considered
80+
// an unused expression
81+
"@typescript-eslint/no-unused-expressions": "off"
82+
}
83+
}
84+
]
85+
}

.github/workflows/test.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
on:
2+
push:
3+
branches: [main]
4+
pull_request:
5+
branches: [main]
6+
workflow_dispatch: {}
7+
8+
name: Test
9+
10+
jobs:
11+
host_tests:
12+
strategy:
13+
matrix:
14+
# os: [macos-latest, windows-2019]
15+
os: ['ubuntu-latest']
16+
node: [16.x, 18.x, 20.x, 22.x]
17+
runs-on: ${{ matrix.os }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node }}
24+
cache: 'npm'
25+
registry-url: 'https://registry.npmjs.org'
26+
27+
- name: Build with Node.js ${{ matrix.node }} on ${{ matrix.os }}
28+
run: npm install && npm run compile
29+
shell: bash
30+
31+
- name: Test ${{ matrix.os }}
32+
shell: bash
33+
run: npm test
34+
35+
# container_tests:
36+
# runs-on: ubuntu-latest
37+
# strategy:
38+
# matrix:
39+
# linux_arch: [s390x, arm64, amd64]
40+
# node: [16.x, 18.x, 20.x, 22.x]
41+
# steps:
42+
# - uses: actions/checkout@v4
43+
44+
# - uses: actions/setup-node@v4
45+
# with:
46+
# node-version: ${{ matrix.node }}
47+
48+
# - name: Get Full Node.js Version
49+
# id: get_nodejs_version
50+
# shell: bash
51+
# run: |
52+
# echo "version=$(node --print 'process.version.slice(1)')" >> "$GITHUB_OUTPUT"
53+
# echo "ubuntu_version=$(node --print '(+process.version.slice(1).split(`.`).at(0)) > 16 ? `noble` : `bionic`')" >> "$GITHUB_OUTPUT"
54+
55+
# - name: Set up QEMU
56+
# uses: docker/setup-qemu-action@v3
57+
58+
# - name: Set up Docker Buildx
59+
# uses: docker/setup-buildx-action@v3
60+
61+
# - name: Run Buildx
62+
# run: |
63+
# docker buildx create --name builder --bootstrap --use
64+
# docker buildx build \
65+
# --platform linux/${{ matrix.linux_arch }} \
66+
# --build-arg="NODE_ARCH=${{ matrix.linux_arch == 'amd64' && 'x64' || matrix.linux_arch }}" \
67+
# --build-arg="NODE_VERSION=${{ steps.get_nodejs_version.outputs.version }}" \
68+
# --build-arg="UBUNTU_VERSION=${{ steps.get_nodejs_version.outputs.ubuntu_version }}" \
69+
# --build-arg="RUN_TEST=true" \
70+
# --output type=local,dest=./prebuilds,platform-split=false \
71+
# -f ./.github/docker/Dockerfile.glibc \
72+
# .

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ lib-cov
1010
.DS_Store
1111

1212
.vscode
13-
13+
xunit.xml
1414
pids
1515
logs
1616
results

.mocharc.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/mocharc.json",
3+
"require": [
4+
"source-map-support/register",
5+
"test/tools/chai-addons.js"
6+
],
7+
"extension": [
8+
"ts"
9+
],
10+
"recursive": true,
11+
"failZero": true,
12+
"reporter": "test/tools/mongodb_reporter.js",
13+
"color": true
14+
}

.prettierrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"tabWidth": 2,
4+
"printWidth": 100,
5+
"arrowParens": "avoid",
6+
"trailingComma": "none"
7+
}

binding.gyp

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
'targets': [{
3+
'target_name': 'zstd',
4+
'type': 'loadable_module',
5+
'defines': ['ZSTD_STATIC_LINKING_ONLY'],
6+
'include_dirs': [
7+
"<!(node -p \"require('node-addon-api').include_dir\")"
8+
],
9+
'variables': {
10+
'ARCH': '<(host_arch)',
11+
'libmongocrypt_link_type%': 'static',
12+
'mongocrypt_avoid_openssl_crypto%': 'false',
13+
'built_with_electron%': 0
14+
},
15+
'sources': [
16+
'src/addon.cpp'
17+
],
18+
'xcode_settings': {
19+
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
20+
'CLANG_CXX_LIBRARY': 'libc++',
21+
'MACOSX_DEPLOYMENT_TARGET': '10.12',
22+
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
23+
},
24+
'cflags!': [ '-fno-exceptions' ],
25+
'cflags_cc!': [ '-fno-exceptions' ],
26+
'cflags_cc': [ '-std=c++17' ],
27+
'msvs_settings': {
28+
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
29+
}
30+
}]
31+
}

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { compress: _compress, decompress: _decompress } = require('./bindings');
1+
const { compress: _compress, decompress: _decompress } = require('bindings')('zstd');
22

33
// Error objects created via napi don't have JS stacks; wrap them so .stack is present
44
// https://github.com/nodejs/node/issues/25318#issuecomment-451068073

0 commit comments

Comments
 (0)