Before opening an issue try to search the existing ones for the same problem.
Make sure to include on your issue the following information:
- Node.js Version
- package manager version
- Operational System (name and version)
- Package version
- Logs of the installation
The package manager used on this project is pnpm
The addon lib code is written in Typescript, while the addon itself is written in C++.
Folders ./scripts and ./tools contain scripts in Javascript, those are used mostly during installation and on CI.
C/C++ code is written following Google style guide (with some minor changes), and clang-format can/should be used to automatically format the code. There is already a .clang-format on the repository.
cpplint is used to lint C/C++ code
TS/JS code should be formatted using prettier
ts-lint is used to lint TS code, while JS code is using eslint.
If on Windows, first you will need to grab the deps:
$ node scripts/update-deps.jsInstall the dependencies, this will also build the addon:
$ pnpm installIf you made some change to the C++ code, you can just build the addon again:
$ pnpm pregyp buildIn case you need to rebuild:
$ pnpm pregyp rebuildIf on unix and using the build.sh scripts, you also need to provide the path to the curl config file:
npm_config_macos_universal_build=true \
npm_config_curl_config_bin=~/deps/libcurl/build/x.y.z/bin/curl-config \
pnpm pregyp build --debugIf you have any issues with the build process, please refer to a readme build troubleshooting section.
If you want to include a new libcurl option on the addon, those are the basic steps:
- Add the option to their correct category on
Curl.ccThere are different vectors there for the expected type of the option's value, likecurlOptionInteger,curlOptionString, etc. Make sure to use a#ifdirective to include this option only if building against a libcurl version that supports it, otherwise there will be an compilation error on older versions. - In case the option expects a value of type other than
number | string | boolean, you must also add it to their respective key on the objectoptionKindMapinside./scripts/data/options.js. In case you add it to theotherkey, which means this option has a specific value, you must also add the option expected value type to the objectoptionKindValueMapright below, on that same file. - If the option may use an
enum, you should also create or update the existing enum. For example, libcurl 7.75.0 added AWS Sig v4 authentication method, for that a new option and constant were added in libcurl,CURLOPT_AWS_SIGV4andCURLAUTH_AWS_SIGV4. To add support for that option we:- Added the
CURLOPT_AWS_SIGV4constant as theAwsSigV4member in theCurlAuthenum. To get the value we looked at the libcurl source code. - Added the
CURLOPT_AWS_SIGV4as a string option. Full commit with the above changes is available here.
- Added the
- Run
node ./scripts/build-constants.js, this will generate an updated list of options on./lib/generated/, and also update the files [./lib/Curl.ts] and [./lib/Easy.ts] with overloads for thesetOptmethod. Make sure the options added are correct. - If running the above adds extra options that you do not want to add / are not related to the options you are adding, please feel free to remove them manually from the generated output. We will try to improve this experience later, but for now you have to manually remove them.
We use vcpkg for this. Simply change the version on the file vcpkg.template.json
Sample command you could use from the root of this repository:
LIBCURL_RELEASE=8.17.0 PUBLISH_BINARY="false" ./scripts/ci/build.sh
npm_config_curl_config_bin=~/deps/libcurl/build/8.17.0/bin/curl-config \
npm_config_curl_static_build=true \
npm_config_runtime=electron \
npm_config_target=21.2.0 \
npm_config_disturl=https://www.electronjs.org/headers \
pnpm pregyp rebuild --debugYou can also use electron-rebuild, e.g for macOS:
npm_config_curl_static_build=true \
npm_config_macos_universal_build=true \
npm_config_curl_config_bin=~/deps/libcurl/build/8.17.0/bin/curl-config \
pnpm exec electron-rebuild- Install lldb On Debian based linux:
sudo apt-get install lldb
- Install Node.js lldb plugin:
pnpm i -g llnode
or:
brew install llnode
# then follow instructions
- Run script that causes core dump
llnode -- /path/to/bin/node --abort_on_uncaught_exception script.js
- Profit
More information go to https://github.com/nodejs/llnode
For publishing there is a GitHub action workflow to publish new releases at: https://github.com/JCMais/node-libcurl/actions/workflows/publish.yml
We are using np for releases.
- Checkout
master - Merge changes from
develop - Create version
- Publish
So basically:
git checkout master
git merge developAnd then:
npx np [major|minor|patch]or if you are having trouble with np:
pnpm publishor even if you are having trouble with pnpm:
npm version [major|minor|patch]
npm publishAnd finally
git push --follow-tags
git checkout develop
git merge master
git pushFor prereleases, use something like this from the develop branch:
$ pnpm exec np prerelease --any-branch --tag nextIf for some reason np fails to run, you can use this command to skip cleaning up and use npm to publish:
$ pnpm exec np prerelease --no-cleanup --any-branch --tag nextWe are using three CI providers:
- CircleCI
- GitHub Actions
- AppVeyor
Each CI provider is responsible for some builds:
CircleCI:
- Node.js (Alpine)
- Electron (linux)
- NW.js (linux)
GitHub Actions:
- Node.js (Linux, macOS)
- Electron (macOS)
- NW.js (macOS)
AppVeyor:
- Node.js (Win64, Win32)
- Electron (Win64, Win32)
GitHub Actions are also used to lint PRs, for that a build runs on Linux.