Commit Graph

25 Commits

Author SHA1 Message Date
Tony 0ab18ff80e
test: refactor tests (#22677)
* test: refactor tests

* test: run *.worker.ts unit tests inside workerd
2026-07-10 23:26:43 +08:00
dependabot[bot] 417ab04f06
chore(deps-dev): bump eslint-plugin-unicorn from 66.0.0 to 68.0.0 (#22310)
* chore(deps-dev): bump eslint-plugin-unicorn from 66.0.0 to 68.0.0

Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 66.0.0 to 68.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v66.0.0...v68.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-version: 68.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* style: fix no-useless-coercion

* style: fix prefer-boolean-return

* style: fix no-useless-logical-operand

* style: fix prefer-single-replace

* style: fix consistent-conditional-object-spread

* style: fix no-useless-else

* style: fix prefer-unicode-code-point-escapes

* style: fix operator-assignment

* style: fix prefer-continue

* style: fix prefer-math-constants

* style: fix prefer-hoisting-branch-code

* style: fix prefer-array-slice

* style: fix consistent-class-member-order

* style: fix no-return-array-push

* style: fix prefer-promise-with-resolvers

* style: fix no-array-concat-in-loop

* style: fix no-loop-iterable-mutation

* style: fix no-invalid-argument-count

* style: fix no-duplicate-if-branches

* style: fix prefer-else-if

* style: fix no-unreadable-for-of-expression

* style: fix logical-assignment-operators

* style: fix default-export-style

* style: revert false positve in prefer-type-literal-last in #22274

* style: fix arrow-body-style

* style: add v68 recommended preset

* style: refactor GraphQL queries to use template literals for better readability

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
2026-06-20 23:11:27 +08:00
dependabot[bot] 873618e99d
chore(deps-dev): bump eslint-plugin-unicorn from 65.0.1 to 66.0.0 (#22274)
* chore(deps-dev): bump eslint-plugin-unicorn from 65.0.1 to 66.0.0

Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 65.0.1 to 66.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v65.0.1...v66.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-version: 66.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* style: fix unicorn-js/prefer-url-href

* style: oxlint disable

* style: fix unicorn-js/no-useless-else

* style: no-unsafe-string-replacement

* style: fix no-duplicate-loops

* style: fix prefer-number-is-safe-integer

* style: fix prefer-single-array-predicate

* style: fix no-object-methods-with-collections

* style: fix no-useless-boolean-cast

* style: fix no-useless-template-literals

* style: fix no-negated-array-predicate

* style: fix prefer-direct-iteration

* style: fix consistent-optional-chaining

* style: fix prefer-simple-sort-comparator

* style: fix prefer-global-number-constants

* style: fix prefer-type-literal-last

* style: fix require-array-sort-compare.

* style: fix prefer-early-return

* style: fix prefer-short-arrow-method

* style: fix prefer-array-from-map

* style: fix prefer-scoped-selector

* style: fix no-global-object-property-assignment

* style: fix no-unnecessary-global-this

* style: fix no-unreadable-object-destructuring

* style: fix no-invalid-argument-count

* style: fix prefer-smaller-scope

* style: fix prefer-iterator-to-array.

* style: fix prefer-object-iterable-methods

* style: fix typo

* style: fix max-nested-calls

* style: fix no-incorrect-template-string-interpolation

* style: fix no-break-in-nested-loop

* style: fix prefer-await

* style: fix no-computed-property-existence-check

* style: fix prefer-number-coercion

* style: fix no-empty-file

* style: update eslint unicorn v66 recommended preset

* style: add unicorn/prefer-spread to oxlint-disable comments

* style: fix no-array-reduce

* style: delete github/no-then as it's covered by unicorn/prefer-await

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
2026-06-16 14:43:42 +08:00
dependabot[bot] 07834413f5
chore(deps-dev): bump eslint-plugin-unicorn from 64.0.0 to 65.0.0 (#22219)
* chore(deps-dev): bump eslint-plugin-unicorn from 64.0.0 to 65.0.0

Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 64.0.0 to 65.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v64.0.0...v65.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-version: 65.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: no-array-from-fill

* fix: unicorn-js/no-duplicate-set-values

* fix: no-this-outside-of-class

* fix: no-unnecessary-nested-ternary

* fix: prefer-array-last-methods

* fix: prefer-queue-microtask

* fix: prefer-split-limit

* fix: no-array-from-fill

* fix: no-unused-array-method-return

* fix: prefer-single-call

* fix: prefer-includes-over-repeated-comparisons

* fix: consistent-compound-words

* fix: prefer-includes-over-repeated-comparisons

* chore: add eslint-plugin-unicorn v65 recommended preset

* fix: correct duration parsing logic in parseDuration function

* fix: update oxlint-disable

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
2026-06-09 00:08:15 +08:00
Tony 4390cabb21
feat(utils/playwright): add PLAYWRIGHT_CDP_ENDPOINT support (#22212)
* feat(utils/playwright): add PLAYWRIGHT_CDP_ENDPOINT support

* fix: close browser
2026-06-08 10:31:39 +08:00
DIYgod 566f028aaf
refactor: migrate browser automation to Playwright (#21901)
* refactor: migrate browser automation to Playwright

* ci: update browser checks for Playwright
2026-05-04 21:16:18 +08:00
Tony 7ab0d1eff4
fix(ua): ensure header-generator and custom ua are effective with each other (#21546)
* fix(ua): ensure header-generator and custom ua are effective with each other

* fix(ua): review comment
2026-03-29 22:47:56 +08:00
DIYgod 1131350b5f
feat: deploy RSSHub to Cloudflare Workers (#20804)
* feat: deploy RSSHub to Cloudflare Workers

- Create Worker entry point (lib/worker.ts) with polyfills
- Implement Worker-specific app configuration (lib/app.worker.tsx)
- Add automatic .worker.ts resolution plugin for cleaner config
- Simplify build configuration with only 3 essential shims
- Enable static asset serving via Cloudflare Static Assets feature
- Support dynamic route loading with proper module aliasing

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* feat(worker): add puppeteer and request-rewriter support

- Add @cloudflare/puppeteer for Browser Rendering API support
- Create puppeteer.worker.ts with Cloudflare Browser binding
- Add request-rewriter Worker version with static browser headers
- Add vm module shim to node-module.ts for JSDOM compatibility
- Configure __dirname/__filename in tsdown for CommonJS compat
- Update wrangler.toml with BROWSER binding configuration
- Dynamically extract namespaces from foloAnalysisTop100 for routes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(cache): restore synchronous initialization for tests

The async initialization caused cache tests to fail because the cache
module wasn't ready when tests ran. Restored synchronous imports while
keeping Worker-specific no-op behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(worker): add automated Worker integration tests

- Add miniflare for Worker environment simulation
- Create lib/worker.worker.test.ts with integration tests
- Test basic routes (/test/1, /, unknown routes)
- Test RSS feed routes (hackernews, v2ex)
- Test error handling for puppeteer routes without BROWSER binding
- Add worker-test npm script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(worker): use test routes for Worker integration tests

- Replace third-party routes (hackernews, v2ex, weibo) with /test/* routes
- Remove miniflare dependency (wrangler includes it internally)
- Simplify test setup using wrangler's unstable_dev API

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(test): make header-generator test less flaky

The header-generator library may return different platform values due to
internal randomness. Update test to check for valid format instead of
exact value.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(test): exclude worker tests from vitest coverage run

Worker tests require the dist-worker bundle to be built first,
which is not part of the regular CI test workflow. These tests
should be run separately using 'pnpm worker-test'.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(worker): add automated Worker integration tests

- Add worker-build step to CI workflow before running tests
- Revert exclusion of worker tests from vitest coverage run
- Worker tests now run as part of the regular test suite

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(worker): fix routes.js alias path in worker build config

Change alias key from absolute path to relative import path to match
how it's imported in lib/registry.ts. This fixes the worker build
failing with "Could not resolve '../assets/build/routes.js'" error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* ci: trigger CI re-run

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(ci): build worker routes before worker-build

The worker build requires routes-worker.js which is generated by
running build:routes with WORKER_BUILD=true. This was missing in CI,
causing the worker build to fail with "Could not resolve routes.js".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(test): increase timeout for Worker integration tests

Worker tests need more time in CI environments. Increase individual
test timeouts from default 10s to 30s for each test case.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-04 09:22:05 +08:00
DIYgod 81ff849337
feat(tests): add comprehensive unit tests for various utility functions and views (#20779)
* feat(tests): add comprehensive unit tests for various utility functions and views

- Implement tests for cache utility to ensure proper behavior with no cache and TTL keys.
- Add tests for common utilities including string manipulation and path handling.
- Introduce tests for directory import functionality to validate file imports and pattern matching.
- Create tests for git hash retrieval to handle fallback scenarios.
- Develop tests for deprecated got utility to verify response handling and retry logic.
- Enhance got utility tests to include request hooks and search parameter handling.
- Mock header generator tests to validate user agent handling.
- Expand helpers tests to cover current path retrieval and duration parsing.
- Implement tests for ofetch utility to ensure proper proxy handling and logging.
- Add OpenTelemetry metric tests to validate metric serialization.
- Create proxy tests to verify multi-proxy selection and failure handling.
- Introduce request rewriter tests to validate fetch and get wrapper functionality.
- Add timezone utility tests to handle various input types.
- Implement view tests for Atom and RSS rendering to ensure correct output.
- Create index view tests to validate debug information display based on configuration.

* refactor: remove deprecated got implementation and associated tests

* test: expand coverage for api, middleware, and utils
2025-12-29 17:34:48 +08:00
github-actions[bot] a28890a135 style: auto format 2025-11-27 02:55:46 +00:00
Tony 2ae10a7a02
feat: replace rand-user-agent with header-generator (#20480)
* Initial plan

* Replace @tonyrl/rand-user-agent with header-generator and add sec-ch-* headers

Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>

* Extract unwanted UA validation into standalone isValidUserAgent function

Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>

* Add headerGeneratorPreset option to got and ofetch utilities

* Replace randUserAgent usage in lib/routes with headerGeneratorPreset option

Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>

* chore: pin header-generator to exact match

* fix: replace randUserAgent with a static user agent string in config

* Remove deprecated _randUserAgent function and related tests

Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>

* refactor: rename to header-generator

* Changes before error encountered

Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>

* fix: update generateHeaders parameter type to Partial<HeaderGeneratorOptions>

* fix: add ios preset

* fix: rename headerGeneratorPreset to headerGeneratorOptions

* feat: add MODERN_IOS preset and update header-generator patch hash

* fix: use ios preset

* fix: update FetchOptions to include headerGeneratorOptions type

* refactor: simplify header generation and update header inclusion list

* fix: remove header-generator patch

* refactor: update user-agent handling in requests and tests

* test: remove redundant headerGeneratorOptions test and add new ofetch header preset test

* test: add custom user-agent test for ofetch

* test: update user-agent expectation in ofetch headers test

* Update lib/utils/ofetch.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* refactor: replace hardcoded headers with generatedHeaders in fetch and get request handlers

* refactor: rename test suite from rand-user-agent to header-generator and remove unused dependency

* Update lib/utils/header-generator.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TonyRL <11386903+TonyRL@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-14 00:49:41 +08:00
pseudoyu 3d9ac5c6ee
feat(lib/proxy): support multiple proxier by `PROXY_URIS` env 2025-06-24 11:05:14 +08:00
Tony 4e404a7328
chore: disable remote debugger by default (#17498) 2024-11-08 04:08:05 +08:00
bugyaluwang ff1ff8d940
feat(dev): visualize network requests in the development environment on Chrome Devtools's network tab (#17308)
* chore: add node-network-devtools to enhance development experience

* feat(dev): visualize network requests in the development environment on Chrome Devtools's network tab

* chore(deps): update node-network-devtools

* fix: lock error when ci

* chore: update node-network-devtools to v1.0.18

* chore: update node-network-devtools

* chore: use node-network-devtools v1.0.20

* feat: use hook to add custom headers for fetch

* fix: complex method 16

* test: add test for fetch

* fix: test type error

* fix: hard code

* chore(cr): rename the fetch.spec.ts to fetch.test.ts and use exact version

* chore: fix lock error

---------
2024-11-06 04:50:43 +08:00
DIYgod 3a9e9914d8
feat: increase maxQueueSize 2024-09-26 15:23:12 +08:00
DIYgod 58912d5dcf
fix: dispatcher conflict 2024-07-13 23:08:49 +08:00
DIYgod 9fbbed6b04
feat: x-prefer-proxy 2024-07-13 18:20:28 +08:00
DIYgod 99bf04cfad
feat: proxy strategy 2024-07-13 00:15:41 +08:00
DIYgod 5cf1de9445
feat: more logs 2024-07-12 22:07:32 +08:00
DIYgod e16f95c546
feat: add outgoing request rate limit 2024-05-26 17:18:48 +08:00
Mg Pig 8eccccc59c
fix(core): request-rewriter proxy ignore loopback address and puppeteer ws endpoint (#15293) 2024-04-19 23:58:43 +08:00
DIYgod f7048d4c24
fix: ignore url parsing error 2024-03-31 02:45:40 +08:00
DIYgod 8c50e2f96f
test: request-rewriter 2024-03-31 02:28:58 +08:00
DIYgod d83c951d8c
fix: proxy auth 2024-03-31 02:28:26 +08:00
DIYgod a828b3dd1c
feat: request rewriter 2024-03-30 18:21:14 +08:00