Conversation
- Updated .prettierrc to include new formatting options such as trailing commas and print width. - Added new scripts in package.json for format checking and TypeScript type checking. - Enhanced GitHub workflows for Docker publishing and PR validation, including testing steps and Node.js version matrix. - Removed outdated CHANGELOG.md file. - Refactored code for consistency and clarity across various files.
WalkthroughThis update introduces extensive formatting and configuration changes across the project. All code files are reformatted for concise single-line imports, function signatures, and arrow functions, without altering logic or control flow. Several GitHub Actions workflows are enhanced: CI jobs now test across multiple Node.js versions, add explicit type-checking and formatting checks, and improve Docker image building with multi-platform support, Buildx, and caching. The Prettier configuration is updated for stricter formatting rules, and two new npm scripts for format and type checks are added. The changelog file is removed, and its reference is deleted from the README. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant GitHub Actions
participant Node.js
participant Docker
Developer->>GitHub Actions: Push or PR event
GitHub Actions->>Node.js: Set up Node.js (matrix: 20.x-23.x)
GitHub Actions->>Node.js: Install dependencies (npm ci)
GitHub Actions->>Node.js: Run tests (npm run test)
GitHub Actions->>Node.js: Run typecheck (npm run typecheck)
GitHub Actions->>Node.js: Run format check (npm run format:check)
alt On Docker publish
GitHub Actions->>Docker: Set up Docker Buildx
GitHub Actions->>Docker: Build multi-platform image (amd64, arm64)
GitHub Actions->>Docker: Use cache for layers
GitHub Actions->>Docker: Push image to registry
end
Possibly related PRs
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
packages/api/src/api.ts (2)
8-8: Consider extracting cache entry type
The inline object type for cache entries is repetitive; defining a dedicated interface (e.g.,interface CacheEntry { data: EasynewsSearchResponse; timestamp: number }) and usingMap<string, CacheEntry>will improve readability and maintainability.
135-135: Preserve original abort error details
Throwing a newErroron timeout discards the original stack and message. You might wrap the abort in anErrorwith the original as acause, or rethrow the originalAbortErrorto retain diagnostic information:if (error.name === 'AbortError') { throw new Error(`Search timed out after 20s for '${query}'`, { cause: error }); }packages/cloudflare-worker/src/index.ts (1)
4-4: Remove unused import
getTranslationsis imported but never used in this file. Please remove it or implement its usage to avoid dead code..github/workflows/test.yml (1)
24-27: Consider adding lint and type-check steps
To enforce formatting and typings in CI, you could extend the job:- name: Check formatting run: npm run format:check - name: Type check run: npm run typecheck
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (19)
.github/workflows/docker-publish.yml(3 hunks).github/workflows/pr.yml(2 hunks).github/workflows/release.yml(2 hunks).github/workflows/test.yml(1 hunks).prettierrc(1 hunks)CHANGELOG.md(0 hunks)README.md(0 hunks)package.json(1 hunks)packages/addon/src/addon.ts(18 hunks)packages/addon/src/custom-server.ts(4 hunks)packages/addon/src/custom-template.ts(3 hunks)packages/addon/src/i18n/index.ts(3 hunks)packages/addon/src/meta.ts(3 hunks)packages/addon/src/sort-option.ts(2 hunks)packages/addon/src/utils.test.ts(1 hunks)packages/addon/src/utils.ts(17 hunks)packages/addon/stremio-addon-sdk-builder.d.ts(1 hunks)packages/api/src/api.ts(2 hunks)packages/cloudflare-worker/src/index.ts(4 hunks)
💤 Files with no reviewable changes (2)
- README.md
- CHANGELOG.md
🧰 Additional context used
🧬 Code Graph Analysis (4)
packages/addon/src/sort-option.ts (1)
packages/addon/src/utils.ts (1)
capitalizeFirstLetter(586-589)
packages/cloudflare-worker/src/index.ts (1)
packages/addon/src/manifest.ts (1)
manifest(61-116)
packages/addon/src/custom-template.ts (1)
packages/addon/src/i18n/index.ts (2)
translations(151-723)getTranslations(132-138)
packages/api/src/api.ts (1)
packages/api/src/types.ts (1)
EasynewsSearchResponse(5-31)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-and-push
🔇 Additional comments (85)
packages/addon/src/utils.test.ts (1)
24-24: Approve: Update expected output for ampersand replacement.
The test now correctly expects&to be replaced withand, which matches the implementation ofsanitizeTitle..prettierrc (1)
3-9: Approve Prettier configuration enhancements.
The additions oftrailingComma,printWidth,useTabs,bracketSpacing, andarrowParenswill enforce a more consistent and readable code style across the project, and the CI’sformat:checkstep will ensure compliance.packages/addon/src/sort-option.ts (4)
28-30: Approve: Simplify arrow function in humanReadableSortOptions.
Removing parentheses around the single parameter and condensing to a one-liner aligns with the project’s concise arrow‐function style.
42-42: Approve: Condense return in toHumanReadable.
Using nullish coalescing in a single-line return is a pure formatting change that preserves existing logic.
50-50: Approve: Streamlined find callback in fromHumanReadable.
Collapsing the callback into a single-line arrow function improves readability without functional impact.
55-57: Approve: Inline conditional in toDirection.
The concise one-liner return retains behavior and matches the concise style in other parts of the code.packages/addon/stremio-addon-sdk-builder.d.ts (1)
27-27: Approve: Single-line signature for defineCatalogHandler.
Consolidating the multiline declaration into one line keeps it consistent with other handler definitions and doesn’t change the API.package.json (1)
8-9: Approve: Add format:check and typecheck scripts.
Introducingnpm run format:checkandnpm run typecheckstrengthens the CI pipeline by enforcing formatting and type correctness before merging.packages/api/src/api.ts (1)
11-11: Reevaluate the runtimeoptionsnull check
Since TypeScript enforcesoptionsas a required parameter, theif (!options)check is unlikely to ever trigger. Consider either makingoptionsoptional in the signature or removing the redundant guard to streamline the code.packages/addon/src/meta.ts (6)
12-12: Formatting-only change approved
The async function signature was consolidated to a single line without altering behavior.
16-17: Formatting-only change approved
The.then()callbacks were reformatted into single-line arrow functions, improving conciseness.
43-43: Formatting-only change approved
Consistent single-line.then(res => res.json())style aligns with other promise chains.
67-67: Formatting-only change approved
Consolidated the function declaration to one line; functionality remains unchanged.
69-69: Formatting-only change approved
Predicate callback in the promise chain simplified; no logical changes.
76-76: Formatting-only change approved
Final.then()callback streamlined for readability.packages/addon/src/i18n/index.ts (3)
137-137: Formatting-only change approved
The ternary fallback for unsupported languages was collapsed into one line, preserving its logic.
562-562: Formatting-only change approved
Converted the ChinesestrictTitleMatchingstring to a single line without altering content.
677-677: Formatting-only change approved
Added missing trailing comma in the RomaniansortingOptionsblock; aligns with JSON/TS style conventions.packages/cloudflare-worker/src/index.ts (3)
29-29: Formatting-only change approved
The route handler declaration was consolidated to a single line; functionality is identical.
31-31: Formatting-only change approved
No-cache header calls were flattened to single-line statements, improving consistency.
60-60: Formatting-only change approved
Root redirect route definition follows the same concise arrow function style..github/workflows/test.yml (5)
6-7: Push trigger added formainbranch
Includingpushalongsidepull_requestensures workflows run on direct commits tomain.
11-13: Node.js version matrix introduced
Testing across[20.x, 21.x, 22.x, 23.x]provides broader compatibility coverage.
18-18: Dynamic Node.js setup step
Usingmatrix.node-versionaligns the setup with the matrix strategy.
21-22: Enable npm caching
Addingcache: 'npm'speeds up dependency installation in CI.
24-27: Separate install and test steps
Splittingnpm ciandnpm run testinto named steps improves workflow readability.packages/addon/src/addon.ts (15)
24-26: Consolidated imports for clarity
Single-line imports reduce verbosity and improve readability without altering functionality.
50-50: Streamlined initialization log
The one-liner for the addon initialization log is concise and retains full context.
91-91: Example custom title log formatted inline
Converting the loop’s log to a single template literal keeps the debug output clear.
129-129: MetaHandler signature condensed
The arrow function signature fordefineMetaHandleris now on one line, improving compactness without changing types or logic.
234-234: StreamHandler signature condensed
Similarly, thedefineStreamHandlersignature is simplified to a single line, maintaining type annotations intact.
272-277: Config parsing and logging made concise
ParsingstrictTitleMatchingand logging its state, as well as preferred language, are now inline and easy to follow.
349-349: No-direct-custom-title log
Inline log clarifies fallback path when no direct custom title is found.
381-381: Alternative-names count log
Logging the count of metadata alternative names in a single expression is clear and retains full detail.
388-390: Inline filtering of additional titles
The.filter(…)callback is now a concise arrow function, improving readability for title deduplication logic.
397-397: Search-title count log
Single-line log for the number of titles searched keeps debug output succinct.
431-431: Example result log inline
Formatting the example result log as a one-liner preserves detail while reducing line count.
442-442: Fallback search-with-year log
Inlining the log message when retrying with year keeps intent clear.
522-522: Series strict-match condition inline
Converting theif (!queries.some(…))check into a single line is concise and retains exact logic.
529-536: Variant matching logic inline
The.some(…)andmatchesTitlecall are now written inline, improving readability of the movie matching fallback.
808-808: Stream language logging inline
A one-liner for logging stream language info keeps the mapping function compact..github/workflows/release.yml (6)
1-1: Workflow renamed to improve clarity
Renaming to "Test and Release on GitHub" more accurately reflects the workflow’s scope.
10-13: Matrix testing across Node.js versions
Adding a Node.js version matrix (20.x–23.x) increases compatibility coverage.
17-22: Dynamic Node.js setup with caching
Usingactions/setup-nodewith${{ matrix.node-version }}andcache: 'npm'speeds up CI runs.
23-27: Separate install and test steps
Splitting dependency installation (npm ci) and test execution (npm run test) makes logs clearer and failures easier to diagnose.
29-29: Job dependency enforces test success
needs: testguarantees that the release job only runs if the tests pass.
39-42: Enable npm cache in release job
Caching dependencies in the release step further optimizes workflow duration..github/workflows/pr.yml (9)
1-1: Workflow renamed to "PR Validation"
The new name succinctly describes its purpose as a pull request validation pipeline.
11-12: Expanded permissions for content reading
Addingcontents: readalongsidepull-requests: readensures the workflow can fetch necessary files for validation.
15-17: Job renamed to validate
Changing the job ID and display name to "Validate PR" aligns nomenclature with its function.
19-22: Checkout with full history
Usingfetch-depth: 0is required for semantic title checks and type/format validations.
23-28: Node.js setup and caching in PR pipeline
Pinning to Node 23.x with npm cache improves speed and consistency for TypeScript and formatting checks.
29-31: Install dependencies step added
npm ciensures a clean install before running validations.
32-36: Semantic PR title validation integrated
Retaining the existing PR title check action within the expanded pipeline.
37-39: TypeScript type-checking added
Runningnpm run typecheckadds a critical layer of static analysis to catch type errors early.
40-42: Prettier formatting check added
npm run format:checkenforces code style automatically on every pull request.packages/addon/src/custom-server.ts (4)
18-18: InlinecreateManifestWithLanguagesignature
Condensing the function declaration to one line improves compactness without affecting behavior.
33-33: StreamlinedserveHTTPsignature
The export signature is now a single-line declaration with a default parameter, preserving functionality.
74-74: No-cache headers set in one line
Consolidating multiple statements into a singleres.setHeadercall for cache control is clear and concise.
104-104: Single-line directory existence check
Throwing an error in-line when the static directory doesn’t exist reduces boilerplate.packages/addon/src/custom-template.ts (4)
2-13: Consolidated import and UI language lookup
Combining imports and the.find()call into single‐line statements makes the initial setup more concise.
18-20: Condensed debug logging
Inlineconsole.logcalls for language and translation loading keep the template code compact.
33-87: Form field translation mapping streamlined
Collapsing multi-line conditional branches for translatingstrictTitleMatchingandpreferredLanguageinto single-line checks improves readability while keeping the logic intact.
88-121: Sorting preference translation mapping condensed
Simplifying the translation mapping forsortingPreferenceinto inline conditionals makes the code more maintainable without altering behavior..github/workflows/docker-publish.yml (6)
1-1: Workflow name updated for clarity
Renaming the workflow to “Test and publish Docker image” makes its intent explicit.
15-27: Introduce a dedicated test job
Adding a separatetestjob that runsnpm ciandnpm run testensures that builds don’t proceed on failing tests. Consider aligning the Node.js version here with your supported LTS or using a matrix if you need multi-version coverage.
30-35: Enforce test completion and grant security-event permissions
Requiringbuild-and-pushto depend ontestprevents premature image publication. Grantingsecurity-events: writeis appropriate for publishing SBOMs or vulnerability data.
41-43: Set up Docker Buildx for multi-platform builds
Insertingdocker/setup-buildx-action@v3prepares the runner for cross-architecture builds. This is a best practice for publishing bothamd64andarm64images.
65-65: Specify build platforms
Targetinglinux/amd64,linux/arm64covers the majority of deployment environments. Approved.
69-70: Enable GitHub Actions cache for Docker layers
Usingcache-from: type=ghaandcache-to: type=gha,mode=maxwill significantly speed up subsequent image builds by reusing layers.packages/addon/src/utils.ts (15)
103-105: Maintain strict-mode year matching logic
The trimmed comparison stripping the year before matching ensures exact title match plus year check. Formatting changes are correct and the logic remains intact.
130-134: ApproveallWordsMatchextraction
Refactoring the every-check into a standaloneallWordsMatchconstant improves readability. No functional change observed.
140-142: SimplifymatchingWordspredicate
Switching to a concise arrow function withinfilteris a pure style change. Approved.
145-146: ComputesignificantWordsinline
Collapsing the filter-and-lengthchain into one expression is consistent with the rest of the file.
192-192: StreamlinegetQualitysignature
Consolidating the function declaration onto one line aligns with project style. No behavior change.
222-222: CondensecreateThumbnailUrldeclaration
Moving from multi-line to single-line arrow signature is purely stylistic. Approved.
257-263: Enhance logging inloadCustomTitles
Adding logs for parsed title counts and sample entries improves debuggability when loading external JSON. Formatting is correct.
275-275: Log missing or inaccessible custom-titles file
Reporting the file absence vialogger.infoaids operational diagnostics. Approved.
330-330: Refactor custom-title replacement generation
Using a dynamicRegExpto replace the English title with its custom equivalent is unchanged logic, now formatted as intended.
345-345: Refactor English-title restoration logic
The mirrored replacement logic for custom-to-English titles is consistent and correctly formatted.
355-358: Log alternative-title discovery outcome
Informing whether alternatives were found (and how many) helps in understanding title fallback behavior at runtime. Good enhancement.
366-366: CompactbuildSearchQueryexport
Single-line function signatures for small utilities enhance readability. Approved.
436-436: Numeric log-level parsing guard
Verifying that parsed numbers fall within theLogLevelenum range is a solid defensive check. Formatting tweak only.
532-534: Approve consolidated logger method implementations
Collapsing each console logging call into a single-line template literal keeps the logger consistent and concise acrosstrace,debug,warn, anderror.Also applies to: 544-546, 566-568, 576-578
582-582: ExposelogErrorhelper function
Exporting a dedicatedlogErrorwrapper aligns with the rest of the logging utilities. No issues detected.
resolves #46
Summary by CodeRabbit
New Features
Style
Chores