From 17662b01b9ab4bc2520b85f149826d16f339ccce Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 17:22:09 +0100 Subject: [PATCH] Add development CLI to docs --- .docs/content/4.extra-topics/0.development.md | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/.docs/content/4.extra-topics/0.development.md b/.docs/content/4.extra-topics/0.development.md index 1978908..13cc1df 100644 --- a/.docs/content/4.extra-topics/0.development.md +++ b/.docs/content/4.extra-topics/0.development.md @@ -10,5 +10,63 @@ TODO - How to make new sources/embeds (link to the page) - How to use the fetchers, when to use proxiedFetcher - How to use the context -- Testing of contributions --> + +## Testing using the CLI + +Testing can be quite difficult for this library, unit tests can't really be made because of the unreliable nature of scrapers. +But manually testing by writing an entrypoint is also really annoying. + +Our solution is to make a CLI that you can use to run the scrapers, for everything else there are unit tests. + +### Setup +Make a `.env` file in the root of the repository and add a TMDB api key: `MOVIE_WEB_TMDB_API_KEY=KEY_HERE`. +Then make sure you've ran `npm i` to get all the dependencies. + +### Mode 1 - interactive + +To run the CLI without needing to learn all the arguments, simply run the following command and go with the flow. + +```sh +npm run cli +``` + +### Mode 2 - arguments + +For repeatability, it can be useful to specify the arguments one by one. +To see all the arguments, you can run the help command: +```sh +npm run cli -- -h +``` + +Then just run it with your arguments, for example: +```sh +npm run cli -- -sid showbox -tid 556574 +``` + +### Examples + +```sh +# Spirited away - showbox +npm run cli -- -sid showbox -tid 129 + +# Hamilton - flixhq +npm run cli -- -sid flixhq -tid 556574 + +# Arcane S1E1 - showbox +npm run cli -- -sid zoechip -tid 94605 -s 1 -e 1 + +# febbox mp4 - +npm run cli -- -sid febbox-mp4 -u URL_HERE +``` + +### Fetcher options + +The CLI comes with a few built-in fetchers: + - `node-fetch`: Fetch using the "node-fetch" library. + - `native`: Use the new fetch built into nodejs (undici). + - `browser`: Start up headless chrome, and run the library in that context using a proxied fetcher. + +::alert{type="warning"} +The browser fetcher will require you to run `npm run build` before running the CLI. Otherwise you will get outdated results. +::