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
13 changes: 13 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -eu

repo_root="$(git rev-parse --show-toplevel)"
cd "$repo_root"

echo "pre-commit: running lint autofix"
npm run lint:fix

echo "pre-commit: running formatter"
npm run format

git add -A -- src
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ body:
description: Minimal code to reproduce the issue
render: typescript
placeholder: |
import { request } from 'node-wreq';
import { fetch } from 'node-wreq';

const response = await request({
url: 'https://example.com',
const response = await fetch('https://example.com', {
browser: 'chrome_131'
});
validations:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 📚 Documentation
url: https://github.com/will-work-for-meal/node-wreq#readme
url: https://github.com/StopMakingThatBigFace/node-wreq#readme
about: Read the documentation and guides
135 changes: 123 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ jobs:
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: npm run build:rust -- --target x86_64-unknown-linux-gnu
- host: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
build: npm run build:rust -- --target aarch64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
setup: |
set -eux
TOOLCHAIN_URL="https://github.com/troglobit/misc/releases/download/11-20211120/x86_64-linux-musl-cross.tgz"
TOOLCHAIN_ROOT="$HOME/musl-cross"
TOOLCHAIN_DIR="$TOOLCHAIN_ROOT/x86_64-linux-musl-cross"

if [ ! -d "$TOOLCHAIN_DIR" ]; then
mkdir -p "$TOOLCHAIN_ROOT"
curl -L "$TOOLCHAIN_URL" -o /tmp/x86_64-linux-musl-cross.tgz
tar -xzf /tmp/x86_64-linux-musl-cross.tgz -C "$TOOLCHAIN_ROOT"
fi

echo "$TOOLCHAIN_DIR/bin" >> "$GITHUB_PATH"
build: CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++ AR_x86_64_unknown_linux_musl=x86_64-linux-musl-ar RANLIB_x86_64_unknown_linux_musl=x86_64-linux-musl-ranlib npm run build:rust -- --target x86_64-unknown-linux-musl
- host: windows-latest
target: x86_64-pc-windows-msvc
build: npm run build:rust -- --target x86_64-pc-windows-msvc
Expand All @@ -40,6 +59,10 @@ jobs:
with:
targets: ${{ matrix.settings.target }}

- name: Install target toolchain dependencies
if: matrix.settings.setup != ''
run: ${{ matrix.settings.setup }}

- name: Install dependencies
run: npm install

Expand All @@ -54,44 +77,132 @@ jobs:
if-no-files-found: error

publish:
name: Publish to npm
name: Publish platform package - ${{ matrix.settings.target }}
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
settings:
- target: x86_64-apple-darwin
- target: aarch64-apple-darwin
- target: x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
- target: x86_64-pc-windows-msvc

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24
registry-url: 'https://registry.npmjs.org'

- name: Determine npm dist-tag
id: dist_tag
shell: bash
run: |
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
echo "value=rc" >> "$GITHUB_OUTPUT"
else
echo "value=latest" >> "$GITHUB_OUTPUT"
fi

- name: Determine publish version
id: publish_version
shell: bash
run: |
tag="${{ github.event.release.tag_name }}"
version="${tag#v}"

if [[ -z "$version" ]]; then
echo "Release tag produced an empty version" >&2
exit 1
fi

echo "value=$version" >> "$GITHUB_OUTPUT"

- name: Install dependencies
run: npm ci

- name: Download all artifacts
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: artifacts

- name: Move artifacts to rust directory
- name: Prepare scoped platform package
shell: bash
env:
NODE_WREQ_PUBLISH_VERSION: ${{ steps.publish_version.outputs.value }}
run: |
BINARY_PATH="$(find artifacts -name '*.node' | head -n 1)"
node ./scripts/prepare-platform-package.mjs \
--target "${{ matrix.settings.target }}" \
--binary "$BINARY_PATH" \
--outDir ".release/${{ matrix.settings.target }}"

- name: Publish scoped platform package
run: npm publish ".release/${{ matrix.settings.target }}" --access public --tag "${{ steps.dist_tag.outputs.value }}"

publish-main:
name: Publish main package
runs-on: ubuntu-latest
needs: publish
if: github.event_name == 'release'
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'

- name: Determine npm dist-tag
id: dist_tag
shell: bash
run: |
mkdir -p rust
# Copy all .node files from artifacts to rust/
find artifacts -name "*.node" -exec cp {} rust/ \;
echo "Collected binaries:"
ls -la rust/*.node
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
echo "value=rc" >> "$GITHUB_OUTPUT"
else
echo "value=latest" >> "$GITHUB_OUTPUT"
fi

- name: Determine publish version
id: publish_version
shell: bash
run: |
tag="${{ github.event.release.tag_name }}"
version="${tag#v}"

if [[ -z "$version" ]]; then
echo "Release tag produced an empty version" >&2
exit 1
fi

echo "value=$version" >> "$GITHUB_OUTPUT"

- name: Install dependencies
run: npm ci

- name: Build TypeScript
run: npm run build:ts

- name: Publish to npm
run: npm publish --provenance --access public
- name: Prepare main npm package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_WREQ_PUBLISH_VERSION: ${{ steps.publish_version.outputs.value }}
run: npm run prepare:publish:main -- .release/main-package

- name: Publish main package
run: npm publish .release/main-package --access public --tag "${{ steps.dist_tag.outputs.value }}"
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,8 @@ jobs:
- name: Check TypeScript types
run: npx tsc --noEmit

- name: Run oxlint
run: npm run lint

- name: Check code formatting
run: npm run format:check
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ node_modules/

# Build outputs
dist/
.release/
.release-stubs/
.tmp-release/
rust/target/
rust/node-wreq.node
*.node
Expand All @@ -28,4 +31,4 @@ yarn-debug.log*
yarn-error.log*

# Agents
.claude/
.claude/
19 changes: 19 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"sortPackageJson": false,
"sortImports": {
"sortSideEffects": true,
"newlinesBetween": false
},
"ignorePatterns": [
"**/dist/**",
"**/node_modules/**",
],
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"bracketSpacing": true,
"tabWidth": 2,
"printWidth": 100,
"endOfLine": "lf"
}
41 changes: 41 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"jsPlugins": [
{
"name": "stylistic",
"specifier": "@stylistic/eslint-plugin"
}
],
"rules": {
"stylistic/padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": [
"const",
"let",
"var"
],
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "return"
},
{
"blankLine": "any",
"prev": [
"const",
"let",
"var"
],
"next": [
"const",
"let",
"var"
]
}
]
}
}
22 changes: 0 additions & 22 deletions .prettierignore

This file was deleted.

10 changes: 0 additions & 10 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 will-work-for-meal
Copyright (c) 2025 StopMakingThatBigFace

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading
Loading