-
Notifications
You must be signed in to change notification settings - Fork 12
feat(NODE-6539): add base napi C++ template with standard Node team tooling #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c0e553e
scaffolding
baileympearson fde99ea
remove FLE stuff from bindings
baileympearson 769acd3
remove c++ standard
baileympearson c254630
last changes
baileympearson ed8eeba
comments
baileympearson 7b31810
last comment
baileympearson da5d215
remove unused dependencies and tooling
baileympearson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| BasedOnStyle: Google | ||
| AllowShortFunctionsOnASingleLine: Empty | ||
| AllowShortIfStatementsOnASingleLine: false | ||
| AllowShortLoopsOnASingleLine: false | ||
| BinPackArguments: false | ||
| BinPackParameters: false | ||
| ColumnLimit: 100 | ||
| Cpp11BracedListStyle: true | ||
| DerivePointerAlignment: false | ||
| IndentWidth: 4 | ||
| MaxEmptyLinesToKeep: 1 | ||
| NamespaceIndentation: None | ||
| SpaceBeforeAssignmentOperators: true | ||
| Standard: Cpp11 | ||
| UseTab: Never | ||
| InsertNewlineAtEOF: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| !.eslintrc.json | ||
| !.mocharc.json | ||
| !.prettierrc.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| { | ||
| "root": true, | ||
| "extends": [ | ||
| "eslint:recommended", | ||
| "plugin:prettier/recommended", | ||
| "plugin:@typescript-eslint/eslint-recommended", | ||
| "plugin:@typescript-eslint/recommended" | ||
| ], | ||
| "env": { | ||
| "node": true, | ||
| "mocha": true, | ||
| "es6": true | ||
| }, | ||
| "parserOptions": { | ||
| "ecmaVersion": 2019 | ||
| }, | ||
| "plugins": ["@typescript-eslint", "prettier"], | ||
| "rules": { | ||
| "no-restricted-properties": [ | ||
| "error", | ||
| { | ||
| "object": "describe", | ||
| "property": "only" | ||
| }, | ||
| { | ||
| "object": "it", | ||
| "property": "only" | ||
| }, | ||
| { | ||
| "object": "context", | ||
| "property": "only" | ||
| } | ||
| ], | ||
| "prettier/prettier": "error", | ||
| "no-console": "error", | ||
| "valid-typeof": "error", | ||
| "eqeqeq": [ | ||
| "error", | ||
| "always", | ||
| { | ||
| "null": "ignore" | ||
| } | ||
| ], | ||
| "strict": ["error", "global"], | ||
| "no-restricted-syntax": [ | ||
| "error", | ||
| { | ||
| "selector": "TSEnumDeclaration", | ||
| "message": "Do not declare enums" | ||
| }, | ||
| { | ||
| "selector": "BinaryExpression[operator=/[=!]==/] Identifier[name='undefined']", | ||
| "message": "Do not strictly check undefined" | ||
| }, | ||
| { | ||
| "selector": "BinaryExpression[operator=/[=!]==/] Literal[raw='null']", | ||
| "message": "Do not strictly check null" | ||
| }, | ||
| { | ||
| "selector": "BinaryExpression[operator=/[=!]==?/] Literal[value='undefined']", | ||
| "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)" | ||
| } | ||
| ], | ||
| "@typescript-eslint/no-require-imports": "off" | ||
| }, | ||
| "overrides": [ | ||
| { | ||
| "files": ["test/**/*ts"], | ||
| "rules": { | ||
| // chat `expect(..)` style chaining is considered | ||
| // an unused expression | ||
| "@typescript-eslint/no-unused-expressions": "off" | ||
| } | ||
| }, | ||
| { | ||
| // json configuration files | ||
| "files": [".*.json"], | ||
| "rules": { | ||
| "@typescript-eslint/no-unused-expressions": "off" | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: {} | ||
|
|
||
| name: Test | ||
|
|
||
| jobs: | ||
| host_tests: | ||
| strategy: | ||
| matrix: | ||
| # os: [macos-latest, windows-2019] | ||
| os: ['ubuntu-latest'] | ||
| node: [16.20.1, 18.x, 20.x, 22.x] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node }} | ||
| cache: 'npm' | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
| - name: Build with Node.js ${{ matrix.node }} on ${{ matrix.os }} | ||
| run: npm install && npm run compile | ||
| shell: bash | ||
|
|
||
| - name: Test ${{ matrix.os }} | ||
| shell: bash | ||
| run: npm test | ||
|
|
||
| # container_tests: | ||
| # runs-on: ubuntu-latest | ||
| # strategy: | ||
| # matrix: | ||
| # linux_arch: [s390x, arm64, amd64] | ||
| # node: [16.x, 18.x, 20.x, 22.x] | ||
| # steps: | ||
| # - uses: actions/checkout@v4 | ||
|
|
||
| # - uses: actions/setup-node@v4 | ||
| # with: | ||
| # node-version: ${{ matrix.node }} | ||
|
|
||
| # - name: Get Full Node.js Version | ||
| # id: get_nodejs_version | ||
| # shell: bash | ||
| # run: | | ||
| # echo "version=$(node --print 'process.version.slice(1)')" >> "$GITHUB_OUTPUT" | ||
| # echo "ubuntu_version=$(node --print '(+process.version.slice(1).split(`.`).at(0)) > 16 ? `noble` : `bionic`')" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # - name: Set up QEMU | ||
| # uses: docker/setup-qemu-action@v3 | ||
|
|
||
| # - name: Set up Docker Buildx | ||
| # uses: docker/setup-buildx-action@v3 | ||
|
|
||
| # - name: Run Buildx | ||
| # run: | | ||
| # docker buildx create --name builder --bootstrap --use | ||
| # docker buildx build \ | ||
| # --platform linux/${{ matrix.linux_arch }} \ | ||
| # --build-arg="NODE_ARCH=${{ matrix.linux_arch == 'amd64' && 'x64' || matrix.linux_arch }}" \ | ||
| # --build-arg="NODE_VERSION=${{ steps.get_nodejs_version.outputs.version }}" \ | ||
| # --build-arg="UBUNTU_VERSION=${{ steps.get_nodejs_version.outputs.ubuntu_version }}" \ | ||
| # --build-arg="RUN_TEST=true" \ | ||
| # --output type=local,dest=./prebuilds,platform-split=false \ | ||
| # -f ./.github/docker/Dockerfile.glibc \ | ||
| # . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ lib-cov | |
| .DS_Store | ||
|
|
||
| .vscode | ||
|
|
||
| xunit.xml | ||
| pids | ||
| logs | ||
| results | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/mocharc.json", | ||
| "extension": ["ts"], | ||
| "recursive": true, | ||
| "failZero": true, | ||
| "color": true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "singleQuote": true, | ||
nbbeeken marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "tabWidth": 2, | ||
| "printWidth": 100, | ||
| "arrowParens": "avoid", | ||
| "trailingComma": "none" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #include <napi.h> | ||
|
|
||
| using namespace Napi; | ||
|
|
||
| Napi::String Compress(const Napi::CallbackInfo& info) { | ||
| auto string = Napi::String::New(info.Env(), "compress()"); | ||
| return string; | ||
| } | ||
| Napi::String Decompress(const Napi::CallbackInfo& info) { | ||
| auto string = Napi::String::New(info.Env(), "decompress()"); | ||
| return string; | ||
| } | ||
|
|
||
| Napi::Object Init(Napi::Env env, Napi::Object exports) { | ||
| exports.Set(Napi::String::New(env, "compress"), Napi::Function::New(env, Compress)); | ||
| exports.Set(Napi::String::New(env, "decompress"), Napi::Function::New(env, Decompress)); | ||
| return exports; | ||
| } | ||
|
|
||
| NODE_API_MODULE(zstd, Init) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| 'targets': [{ | ||
| 'target_name': 'zstd', | ||
| 'type': 'loadable_module', | ||
| 'defines': ['ZSTD_STATIC_LINKING_ONLY'], | ||
| 'include_dirs': [ | ||
| "<!(node -p \"require('node-addon-api').include_dir\")" | ||
| ], | ||
| 'variables': { | ||
| 'ARCH': '<(host_arch)', | ||
| 'built_with_electron%': 0 | ||
| }, | ||
| 'sources': [ | ||
| 'addon/zstd.cpp' | ||
| ], | ||
| 'xcode_settings': { | ||
| 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', | ||
| 'CLANG_CXX_LIBRARY': 'libc++', | ||
| 'MACOSX_DEPLOYMENT_TARGET': '10.12', | ||
| 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden | ||
| }, | ||
| 'cflags!': [ '-fno-exceptions' ], | ||
| 'cflags_cc!': [ '-fno-exceptions' ], | ||
| 'msvs_settings': { | ||
| 'VCCLCompilerTool': { 'ExceptionHandling': 1 }, | ||
| } | ||
| }] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| export declare function compress(data: Buffer, level?: number | undefined | null): Promise<Buffer> | ||
| export declare function decompress(data: Buffer): Promise<Buffer> | ||
| export declare function compress(data: Buffer, level?: number | undefined | null): Promise<Buffer>; | ||
| export declare function decompress(data: Buffer): Promise<Buffer>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.