Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 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
28 changes: 0 additions & 28 deletions .github/workflows/nodejs-16.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/nodejs-old-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Node.js old versions CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
concurrency:
group: nodejs-old-versions-test-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.node }})
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
node: ['16', '18']

steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
- run: npm install
- name: Patch vitest imports
run: |
for f in test/*.test.ts; do [ -e "$f" ] || exit 0; sed --version >/dev/null 2>&1 && sed -i "s@'vite-plus/test'@'vitest'@g" "$f" || sed -i '' "s@'vite-plus/test'@'vitest'@g" "$f"; done
sed --version >/dev/null 2>&1 && sed -i "s@'vite-plus'@'vite'@g" vite.config.ts || sed -i '' "s@'vite-plus'@'vite'@g" vite.config.ts
jq 'del(.overrides)' package.json > package.json.tmp && mv package.json.tmp package.json
npm install -D vitest@3 vite@7
- run: npx vitest && npm run build:ts && npm run build:version && npm pack && npx attw --pack
env:
NODE_OPTIONS: --require ./test/patch-for-node16-18.cjs
- run: npm run test-node16
42 changes: 18 additions & 24 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,38 @@ jobs:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: '24'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup Vite+
uses: voidzero-dev/setup-vite-plus-action@v1
with:
cache: true
run-install: true

- name: Run lint
run: pnpm run lint
run: vite run lint

- name: Check dedupe
run: pnpm dedupe --check
run: vite dedupe --check

- name: Run typecheck
run: pnpm run typecheck
run: vite run typecheck

- name: Run format check
run: pnpm run fmtcheck
run: vite run fmtcheck

- name: Run build
run: pnpm run build
- name: Run build check
run: vite run build

test:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
node: ['18', '20', '22', '24']
node: ['20', '22', '24', '25']

name: Test (${{ matrix.os }}, ${{ matrix.node }})
runs-on: ${{ matrix.os }}
Expand All @@ -65,24 +64,19 @@ jobs:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4

- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Downgrade vitest for Node 18
if: matrix.node == '18'
run: pnpm add vitest@3 @vitest/coverage-v8@3 --save-dev --ignore-scripts
- name: Setup Vite+
uses: voidzero-dev/setup-vite-plus-action@v1
with:
cache: true
run-install: true

- name: Run tests
run: pnpm run ci
run: vite run ci

- name: Code Coverage
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/pkg.pr.new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on: [push, pull_request]

jobs:
build:
concurrency:
group: pkg-pr-new-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest

steps:
Expand All @@ -12,12 +15,15 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: 20
node-version: 22

- name: Install dependencies
run: npm install
- name: Setup Vite+
uses: voidzero-dev/setup-vite-plus-action@v1
with:
cache: true
run-install: true

- name: Build
run: npm run prepublishOnly
run: vite run build

- run: npx pkg-pr-new publish
- run: vite dlx pkg-pr-new publish
18 changes: 0 additions & 18 deletions .oxfmtrc.json

This file was deleted.

128 changes: 0 additions & 128 deletions .oxlintrc.json

This file was deleted.

53 changes: 53 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,56 @@ Tests use Vitest with:
- Request/response events published via `diagnostics_channel` (`urllib:request`, `urllib:response`)
- Streaming requests disable retry/redirect functionality
- User-Agent header: `node-urllib/{version} Node.js/{version} ({platform}; {arch})`

<!--VITE PLUS START-->
# Using Vite+, the Unified Toolchain for the Web

This project is using Vite+, a modern toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, and Oxfmt. Vite+ wraps these tools and package manager commands in a single, global CLI called `vite`. Vite+ is distinct from Vite, but it invokes Vite through `vite dev` and `vite build`.

## Vite+ Workflow

`vite` is a global binary that handles the full development lifecycle. Run `vite help` to print a list of commands and `vite <command> --help` for information about a specific command.

### Vite+ Commands

- dev - Run the development server
- build - Build for production
- lint - Lint code
- test - Run tests
- fmt - Format code
- lib - Build library
- new - Create a new monorepo package (in-project) or a new project (global)
- run - Run tasks from `package.json` scripts

These commands map to their corresponding tools. For example, `vite dev --port 3000` runs Vite's dev server and works the same as Vite. `vite test` runs JavaScript tests through the bundled Vitest. The versions of individual tools can be checked using `vite <command> --version`. For example, `vite lint --version` prints the bundled Oxlint version, and `vite test --version` prints the bundled Vitest version. This is useful when researching documentation, features, and bugs.

### Package Manager Commands

Vite+ automatically detects and wraps the underlying package manager such as pnpm, npm, or Yarn through the `packageManager` field in `package.json` or package manager-specific lockfiles.

- install - Install all dependencies, or add packages if package names are provided
- add - Add packages to dependencies
- remove - Remove packages from dependencies
- dlx - Execute a package binary without installing it as a dependency
- info - View package information from the registry, including latest versions
- link - Link packages for local development
- outdated - Check for outdated packages
- pm - Forward a command to the package manager
- unlink - Unlink packages
- update - Update packages to their latest versions
- why - Show why a package is installed

## Common Pitfalls

- **Using the package manager directly:** Do not use pnpm, npm, or Yarn directly. Vite+ can handle all package manager operations.
- **Always use Vite commands to run tools:** Don't attempt to run `vite vitest` or `vite oxlint`. They do not exist. Use `vite test` and `vite lint` instead.
- **Running scripts:** Vite+ commands take precedence over `package.json` scripts. If there is a `test` script defined in `scripts` that conflicts with the built-in `vite test` command, run it using `vite run test`.
- **Do not install Vitest, Oxlint, Oxfmt, or tsdown directly:** Vite+ wraps these tools. They must not be installed directly. You cannot upgrade these tools by installing their latest versions. Always use Vite+ commands.
- **Import JavaScript modules from `vite-plus`:** Instead of importing from `vite` or `vitest`, all modules should be imported from the project's `vite-plus` dependency. For example, `import { defineConfig } from 'vite-plus';` or `import { expect, test, vi } from 'vite-plus/test';`. You must not install `vitest` to import test utilities.
- **Type-Aware Linting:** There is no need to install `oxlint-tsgolint`, `vite lint --type-aware` works out of the box.

## Review Checklist for Agents

- [ ] Run `vite install` after pulling remote changes and before getting started.
- [ ] Run `vite lint`, `vite fmt`, and `vite test` to validate changes.
<!--VITE PLUS END-->
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[![Node.js Version](https://img.shields.io/node/v/urllib.svg?style=flat)](https://nodejs.org/en/download/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/node-modules/urllib)
[![pkg.pr.new](https://pkg.pr.new/badge/node-modules/urllib)](https://pkg.pr.new/~/node-modules/urllib)

[npm-image]: https://img.shields.io/npm/v/urllib.svg?style=flat-square
[npm-url]: https://npmjs.org/package/urllib
Expand Down
Loading
Loading