From 77b1297b6bf048a240297629486a3569818814b5 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 27 Dec 2024 20:23:51 +0100 Subject: [PATCH] chore: several minor adjustments chore: wip chore: wip --- .github/workflows/release.yml | 10 +-- README.md | 10 +-- docs/.vitepress/config.ts | 1 + docs/config.md | 112 ++++++++++++++++++++++++++++++++++ docs/install.md | 102 +++++++++++++++++++------------ docs/intro.md | 6 -- docs/usage.md | 2 - ltx => localtunnels | 0 package.json | 12 ++-- 9 files changed, 192 insertions(+), 63 deletions(-) create mode 100644 docs/config.md rename ltx => localtunnels (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6aed60c..c57a283 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,10 +43,10 @@ jobs: uses: softprops/action-gh-release@v2 with: files: | - bin/lpx-linux-x64 - bin/lpx-linux-arm64 - bin/lpx-windows-x64.exe - bin/lpx-darwin-x64 - bin/lpx-darwin-arm64 + bin/localtunnels-linux-x64 + bin/localtunnels-linux-arm64 + bin/localtunnels-windows-x64.exe + bin/localtunnels-darwin-x64 + bin/localtunnels-darwin-arm64 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 1d9232a..c45b1ed 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ ## Install -```bash +```sh bun install -d localtunnels ``` @@ -71,13 +71,13 @@ export default config _Then run:_ -```bash +```sh ./localtunnels start ``` ### CLI -```bash +```sh localtunnels start --from localhost:5173 --subdomain test --verbose localtunnels --help localtunnels --version @@ -87,7 +87,7 @@ To learn more, head over to the [documentation](https://localtunnels.sh/). ## Testing -```bash +```sh bun test ``` diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index f131e0f..c4ac9fc 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -55,6 +55,7 @@ const sidebar = [ { text: 'Intro', link: '/intro' }, { text: 'Install', link: '/install' }, { text: 'Usage', link: '/usage' }, + { text: 'Config', link: '/config' }, ], }, { text: 'Showcase', link: '/Showcase' }, diff --git a/docs/config.md b/docs/config.md new file mode 100644 index 0000000..649319a --- /dev/null +++ b/docs/config.md @@ -0,0 +1,112 @@ +# Configuration + +`localtunnels` can be configured with the following options: + +```ts +// tunnel.config.{ts,js} +import type { LocalTunnelOptions } from 'localtunnels' + +const config: LocalTunnelOptions = { + /** + * The port to listen on for incoming HTTP requests. + * We default to 5173 to create a seamless Vite experience. + * @default 5173 + * @type {number} + * @example + * port: 5173 + */ + port: 5173, + + /** + * The host to listen on for incoming HTTP requests. + * @default 'localhost' + * @type {string} + * @example + * host: 'localhost' + */ + host: 'localtunnel.sh', + + /** + * The subdomain to use for the tunnel. + * @default null + * @type {string} + * @example + * subdomain: 'my-tunnel' + */ + subdomain: 'my-tunnel', + + /** + * Whether to use HTTPS for the tunnel. + * @default false + * @type {boolean} + * @example + * secure: true + */ + secure: true, + + /** + * The port to listen on for incoming HTTPS requests. + * @default 3443 + * @type {number} + * @example + * localPort: 3443 + */ + localPort: 3443, + + /** + * The host to listen on for incoming HTTPS requests. + * @default 'localhost' + * @type {string} + * @example + * localHost: 'localhost' + */ + localHost: 'localhost', + + /** + * The maximum number of tunnels to allow. + * @default 4 + * @type {number} + * @example + * maxTunnels: 4 + */ + maxTunnels: 4, + + /** + * The maximum number of requests to allow per tunnel. + * @default 10 + * @type {number} + * @example + * maxRequests: 10 + */ + maxRequests: 10, + + + /** + * SSL private key, certificate, and CA certificate to use for the tunnel. + * @default null + * @type {object} + * @example + * ssl: { + * key: 'path/to/key.pem', + * cert: 'path/to/cert.pem', + * ca: 'path/to/ca.pem', + * } + */ + ssl: { + key: 'path/to/key.pem', + cert: 'path/to/cert.pem', + ca: 'path/to/ca.pem', + }, + + /** + * Whether to print debug information to the console. + * @default false + * @type {boolean} + * @example + * verbose: true + */ + verbose: true, +} + +export default config +``` diff --git a/docs/install.md b/docs/install.md index ba486c4..9750900 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,29 +1,67 @@ # Install -## Bun & Node.js +Installing `localtunnels` is easy. Simply pull it in via your package manager of choice, or download the binary directly. -```bash -bun install -d localtunnels -npm install -g localtunnels +## Package Managers -# or, invoke immediately -bunx localtunnels -npx localtunnels +Choose your package manager of choice: + +::: code-group + +```sh [npm] +npm install --save-dev localtunnels +# npm i -d localtunnels + +# or, install globally via +npm i -g localtunnels ``` -_We are looking to publish this package npm under the name `localtunnels`. We are also hoping npm will release the name for us._ +```sh [bun] +bun install --dev localtunnels +# bun add --dev localtunnels +# bun i -d localtunnels -## Binaries +# or, install globally via +bun add --global localtunnels +``` + +```sh [pnpm] +pnpm add --save-dev localtunnels +# pnpm i -d localtunnels + +# or, install globally via +pnpm add --global localtunnels +``` + +```sh [yarn] +yarn add --dev localtunnels +# yarn i -d localtunnels + +# or, install globally via +yarn global add localtunnels +``` + +```sh [brew] +brew install localtunnels # coming soon +``` + +```sh [pkgx] +pkgx localtunnels # coming soon +``` -For now, you can download the `localtunnels` binaries from the [releases page](https://github.com/stacksjs/localtunnels/releases/tag/v0.1.1). Choose the binary that matches your platform and architecture: +::: + +Read more about how to use it in the Usage section of the documentation. + +## Binaries -## macOS (Darwin) +Choose the binary that matches your platform and architecture: -For M1/M2 Macs (arm64): +::: code-group -```bash +```sh [macOS (arm64)] # Download the binary -curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.1.0/lpx-darwin-arm64 -o localtunnels +curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.2.0/lpx-darwin-arm64 -o localtunnels # Make it executable chmod +x localtunnels @@ -32,11 +70,9 @@ chmod +x localtunnels mv localtunnels /usr/local/bin/localtunnels ``` -For Intel Macs (amd64): - -```bash +```sh [macOS (x64)] # Download the binary -curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.1.0/lpx-darwin-x64 -o localtunnels +curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.2.0/localtunnels-darwin-x64 -o localtunnels # Make it executable chmod +x localtunnels @@ -45,13 +81,9 @@ chmod +x localtunnels mv localtunnels /usr/local/bin/localtunnels ``` -## Linux - -For ARM64: - -```bash +```sh [Linux (arm64)] # Download the binary -curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.1.0/lpx-linux-arm64 -o localtunnels +curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.2.0/localtunnels-linux-arm64 -o localtunnels # Make it executable chmod +x localtunnels @@ -60,11 +92,9 @@ chmod +x localtunnels mv localtunnels /usr/local/bin/localtunnels ``` -For x64: - -```bash +```sh [Linux (x64)] # Download the binary -curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.1.0/lpx-linux-x64 -o localtunnels +curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.2.0/localtunnels-linux-x64 -o localtunnels # Make it executable chmod +x localtunnels @@ -73,20 +103,14 @@ chmod +x localtunnels mv localtunnels /usr/local/bin/localtunnels ``` -## Windows - -For x64: - -```bash +```sh [Windows (x64)] # Download the binary -curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.1.0/lpx-windows-x64.exe -o localtunnels.exe +curl -L https://github.com/stacksjs/localtunnels/releases/download/v0.2.0/localtunnels-windows-x64.exe -o localtunnels.exe # Move it to your PATH (adjust the path as needed) move localtunnels.exe C:\Windows\System32\localtunnels.exe ``` - +::: tip +You can also find the `localtunnels` binaries in GitHub [releases](https://github.com/stacksjs/localtunnels/releases). +::: diff --git a/docs/intro.md b/docs/intro.md index 2d917ca..09d9dd9 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -30,12 +30,6 @@ For casual chit-chat with others using this package: [Join the Stacks Discord Server](https://discord.gg/stacksjs) -## Postcardware - -Two things are true: Stacks OSS will always stay open-source, and we do love to receive postcards from wherever Stacks is used! 🌍 _We also publish them on our website. And thank you, Spatie_ - -Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094 - ## Sponsors We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us. diff --git a/docs/usage.md b/docs/usage.md index 00a5f4a..945181e 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -49,5 +49,3 @@ localtunnels start --from localhost:5173 --subdomain test --verbose localtunnels --help localtunnels --version ``` - -To learn more, head over to the [documentation](https://localtunnels.sh/). diff --git a/ltx b/localtunnels similarity index 100% rename from ltx rename to localtunnels diff --git a/package.json b/package.json index c8e80f9..d1440a2 100644 --- a/package.json +++ b/package.json @@ -35,13 +35,13 @@ "files": ["README.md", "dist"], "scripts": { "build": "bun build.ts && bun run compile", - "compile": "bun build ./bin/cli.ts --compile --minify --outfile bin/lpx", + "compile": "bun build ./bin/cli.ts --compile --minify --outfile bin/localtunnels", "compile:all": "bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64", - "compile:linux-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/lpx-linux-x64", - "compile:linux-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/lpx-linux-arm64", - "compile:windows-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/lpx-windows-x64.exe", - "compile:darwin-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/lpx-darwin-x64", - "compile:darwin-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/lpx-darwin-arm64", + "compile:linux-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/localtunnels-linux-x64", + "compile:linux-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/localtunnels-linux-arm64", + "compile:windows-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/localtunnels-windows-x64.exe", + "compile:darwin-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/localtunnels-darwin-x64", + "compile:darwin-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/localtunnels-darwin-arm64", "lint": "bunx --bun eslint --flag unstable_ts_config .", "lint:fix": "bunx --bun eslint --flag unstable_ts_config . --fix", "fresh": "bunx rimraf node_modules/ bun.lock && bun i",