Skip to content

Commit ff90247

Browse files
feat: brand new client api; hooks; refactor (#4)
1 parent 010c72d commit ff90247

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+9840
-2340
lines changed

.githooks/pre-commit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
repo_root="$(git rev-parse --show-toplevel)"
5+
cd "$repo_root"
6+
7+
echo "pre-commit: running lint autofix"
8+
npm run lint:fix
9+
10+
echo "pre-commit: running formatter"
11+
npm run format
12+
13+
git add -A -- src

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ body:
3131
description: Minimal code to reproduce the issue
3232
render: typescript
3333
placeholder: |
34-
import { request } from 'node-wreq';
34+
import { fetch } from 'node-wreq';
3535
36-
const response = await request({
37-
url: 'https://example.com',
36+
const response = await fetch('https://example.com', {
3837
browser: 'chrome_131'
3938
});
4039
validations:

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: 📚 Documentation
4-
url: https://github.com/will-work-for-meal/node-wreq#readme
4+
url: https://github.com/StopMakingThatBigFace/node-wreq#readme
55
about: Read the documentation and guides

.github/workflows/build.yml

Lines changed: 123 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ jobs:
2020
- host: ubuntu-latest
2121
target: x86_64-unknown-linux-gnu
2222
build: npm run build:rust -- --target x86_64-unknown-linux-gnu
23+
- host: ubuntu-24.04-arm
24+
target: aarch64-unknown-linux-gnu
25+
build: npm run build:rust -- --target aarch64-unknown-linux-gnu
26+
- host: ubuntu-latest
27+
target: x86_64-unknown-linux-musl
28+
setup: |
29+
set -eux
30+
TOOLCHAIN_URL="https://github.com/troglobit/misc/releases/download/11-20211120/x86_64-linux-musl-cross.tgz"
31+
TOOLCHAIN_ROOT="$HOME/musl-cross"
32+
TOOLCHAIN_DIR="$TOOLCHAIN_ROOT/x86_64-linux-musl-cross"
33+
34+
if [ ! -d "$TOOLCHAIN_DIR" ]; then
35+
mkdir -p "$TOOLCHAIN_ROOT"
36+
curl -L "$TOOLCHAIN_URL" -o /tmp/x86_64-linux-musl-cross.tgz
37+
tar -xzf /tmp/x86_64-linux-musl-cross.tgz -C "$TOOLCHAIN_ROOT"
38+
fi
39+
40+
echo "$TOOLCHAIN_DIR/bin" >> "$GITHUB_PATH"
41+
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
2342
- host: windows-latest
2443
target: x86_64-pc-windows-msvc
2544
build: npm run build:rust -- --target x86_64-pc-windows-msvc
@@ -40,6 +59,10 @@ jobs:
4059
with:
4160
targets: ${{ matrix.settings.target }}
4261

62+
- name: Install target toolchain dependencies
63+
if: matrix.settings.setup != ''
64+
run: ${{ matrix.settings.setup }}
65+
4366
- name: Install dependencies
4467
run: npm install
4568

@@ -54,44 +77,132 @@ jobs:
5477
if-no-files-found: error
5578

5679
publish:
57-
name: Publish to npm
80+
name: Publish platform package - ${{ matrix.settings.target }}
5881
runs-on: ubuntu-latest
5982
needs: build
6083
if: github.event_name == 'release'
6184
permissions:
6285
contents: read
6386
id-token: write
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
settings:
91+
- target: x86_64-apple-darwin
92+
- target: aarch64-apple-darwin
93+
- target: x86_64-unknown-linux-gnu
94+
- target: aarch64-unknown-linux-gnu
95+
- target: x86_64-unknown-linux-musl
96+
- target: x86_64-pc-windows-msvc
6497

6598
steps:
6699
- uses: actions/checkout@v4
67100

68101
- name: Setup Node.js
69102
uses: actions/setup-node@v4
70103
with:
71-
node-version: 20
104+
node-version: 24
72105
registry-url: 'https://registry.npmjs.org'
73106

107+
- name: Determine npm dist-tag
108+
id: dist_tag
109+
shell: bash
110+
run: |
111+
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
112+
echo "value=rc" >> "$GITHUB_OUTPUT"
113+
else
114+
echo "value=latest" >> "$GITHUB_OUTPUT"
115+
fi
116+
117+
- name: Determine publish version
118+
id: publish_version
119+
shell: bash
120+
run: |
121+
tag="${{ github.event.release.tag_name }}"
122+
version="${tag#v}"
123+
124+
if [[ -z "$version" ]]; then
125+
echo "Release tag produced an empty version" >&2
126+
exit 1
127+
fi
128+
129+
echo "value=$version" >> "$GITHUB_OUTPUT"
130+
74131
- name: Install dependencies
75132
run: npm ci
76133

77-
- name: Download all artifacts
134+
- name: Download artifact
78135
uses: actions/download-artifact@v4
79136
with:
137+
name: bindings-${{ matrix.settings.target }}
80138
path: artifacts
81139

82-
- name: Move artifacts to rust directory
140+
- name: Prepare scoped platform package
141+
shell: bash
142+
env:
143+
NODE_WREQ_PUBLISH_VERSION: ${{ steps.publish_version.outputs.value }}
144+
run: |
145+
BINARY_PATH="$(find artifacts -name '*.node' | head -n 1)"
146+
node ./scripts/prepare-platform-package.mjs \
147+
--target "${{ matrix.settings.target }}" \
148+
--binary "$BINARY_PATH" \
149+
--outDir ".release/${{ matrix.settings.target }}"
150+
151+
- name: Publish scoped platform package
152+
run: npm publish ".release/${{ matrix.settings.target }}" --access public --tag "${{ steps.dist_tag.outputs.value }}"
153+
154+
publish-main:
155+
name: Publish main package
156+
runs-on: ubuntu-latest
157+
needs: publish
158+
if: github.event_name == 'release'
159+
permissions:
160+
contents: read
161+
id-token: write
162+
163+
steps:
164+
- uses: actions/checkout@v4
165+
166+
- name: Setup Node.js
167+
uses: actions/setup-node@v4
168+
with:
169+
node-version: 24
170+
registry-url: 'https://registry.npmjs.org'
171+
172+
- name: Determine npm dist-tag
173+
id: dist_tag
83174
shell: bash
84175
run: |
85-
mkdir -p rust
86-
# Copy all .node files from artifacts to rust/
87-
find artifacts -name "*.node" -exec cp {} rust/ \;
88-
echo "Collected binaries:"
89-
ls -la rust/*.node
176+
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
177+
echo "value=rc" >> "$GITHUB_OUTPUT"
178+
else
179+
echo "value=latest" >> "$GITHUB_OUTPUT"
180+
fi
181+
182+
- name: Determine publish version
183+
id: publish_version
184+
shell: bash
185+
run: |
186+
tag="${{ github.event.release.tag_name }}"
187+
version="${tag#v}"
188+
189+
if [[ -z "$version" ]]; then
190+
echo "Release tag produced an empty version" >&2
191+
exit 1
192+
fi
193+
194+
echo "value=$version" >> "$GITHUB_OUTPUT"
195+
196+
- name: Install dependencies
197+
run: npm ci
90198

91199
- name: Build TypeScript
92200
run: npm run build:ts
93201

94-
- name: Publish to npm
95-
run: npm publish --provenance --access public
202+
- name: Prepare main npm package
96203
env:
97-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
204+
NODE_WREQ_PUBLISH_VERSION: ${{ steps.publish_version.outputs.value }}
205+
run: npm run prepare:publish:main -- .release/main-package
206+
207+
- name: Publish main package
208+
run: npm publish .release/main-package --access public --tag "${{ steps.dist_tag.outputs.value }}"

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,8 @@ jobs:
8282
- name: Check TypeScript types
8383
run: npx tsc --noEmit
8484

85+
- name: Run oxlint
86+
run: npm run lint
87+
8588
- name: Check code formatting
8689
run: npm run format:check

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ node_modules/
33

44
# Build outputs
55
dist/
6+
.release/
7+
.release-stubs/
8+
.tmp-release/
69
rust/target/
710
rust/node-wreq.node
811
*.node
@@ -28,4 +31,4 @@ yarn-debug.log*
2831
yarn-error.log*
2932

3033
# Agents
31-
.claude/
34+
.claude/

.oxfmtrc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"sortPackageJson": false,
4+
"sortImports": {
5+
"sortSideEffects": true,
6+
"newlinesBetween": false
7+
},
8+
"ignorePatterns": [
9+
"**/dist/**",
10+
"**/node_modules/**",
11+
],
12+
"semi": true,
13+
"trailingComma": "es5",
14+
"singleQuote": true,
15+
"bracketSpacing": true,
16+
"tabWidth": 2,
17+
"printWidth": 100,
18+
"endOfLine": "lf"
19+
}

.oxlintrc.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"jsPlugins": [
4+
{
5+
"name": "stylistic",
6+
"specifier": "@stylistic/eslint-plugin"
7+
}
8+
],
9+
"rules": {
10+
"stylistic/padding-line-between-statements": [
11+
"error",
12+
{
13+
"blankLine": "always",
14+
"prev": [
15+
"const",
16+
"let",
17+
"var"
18+
],
19+
"next": "*"
20+
},
21+
{
22+
"blankLine": "always",
23+
"prev": "*",
24+
"next": "return"
25+
},
26+
{
27+
"blankLine": "any",
28+
"prev": [
29+
"const",
30+
"let",
31+
"var"
32+
],
33+
"next": [
34+
"const",
35+
"let",
36+
"var"
37+
]
38+
}
39+
]
40+
}
41+
}

.prettierignore

Lines changed: 0 additions & 22 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)