### Install and Run Torlink Source: https://github.com/baairon/torlink/blob/main/README.md To get started with torlink, install Node.js and then run the application directly from your terminal using npx. ```sh npx torlnk ``` -------------------------------- ### Set up torlink Development Environment Source: https://github.com/baairon/torlink/blob/main/CONTRIBUTING.md Clone the repository, install dependencies, and start the development server. The `npm run dev` command runs the live TUI without a build step. ```sh git clone https://github.com/baairon/torlink cd torlink npm install npm run dev ``` -------------------------------- ### Install Torlink for System (configuration.nix) Source: https://github.com/baairon/torlink/blob/main/nix/README.md Add the torlink package to the configuration.nix for system-wide installations. ```nix # configuration.nix { pkgs, inputs, ... }: { environment.systemPackages = with pkgs; [ ... inputs.torlink.packages.${pkgs.system}.default ... ]; } ``` -------------------------------- ### Install Torlink for User (home.nix) Source: https://github.com/baairon/torlink/blob/main/nix/README.md Add the torlink package to the home.nix configuration for user-specific installations. ```nix # home.nix { pkgs, inputs, ... }: { home.packages = with pkgs; [ ... inputs.torlink.packages.${pkgs.system}.default ... ]; } ``` -------------------------------- ### Install Dependencies for Development Source: https://github.com/baairon/torlink/blob/main/README.md Before contributing to torlink, clone the repository and install the necessary project dependencies using npm. ```sh npm install ``` -------------------------------- ### Cross-Platform Clipboard Functionality Source: https://github.com/baairon/torlink/blob/main/CONTRIBUTING.md Example of implementing cross-platform clipboard functionality, handling different commands for Windows, macOS, and Linux. This ensures the feature works on all target operating systems. ```typescript writeClipboard(text: string): boolean { if (process.platform === "win32") { // powershell on win32 return execSync(`Set-Clipboard -Value \"${text}\"`, { encoding: "utf8" }); } else if (process.platform === "darwin") { // pbcopy on darwin return execSync(`echo \"${text}\" | pbcopy`, { encoding: "utf8" }); } else { // wl-copy, xclip, xsel on linux try { execSync(`wl-copy`, { input: text, encoding: "utf8" }); } catch { try { execSync(`xclip -selection clipboard`, { input: text, encoding: "utf8" }); } catch { try { execSync(`xsel -selection clipboard`, { input: text, encoding: "utf8" }); } catch { return false; } } } } return true; } ``` -------------------------------- ### Run Development Version Source: https://github.com/baairon/torlink/blob/main/README.md To run the development version of torlink locally, use the npm run dev command after installing dependencies. ```sh npm run dev ``` -------------------------------- ### Mocking Child Process for Testing Source: https://github.com/baairon/torlink/blob/main/CONTRIBUTING.md Example of mocking the Node.js `child_process` module in a Vitest test. This allows testing code that interacts with the operating system's shell without actually executing shell commands. ```typescript vi.mock("node:child_process", () => ({ execSync: vi.fn(), })); const { execSync } = await import("node:child_process"); // ... test logic using mocked execSync ``` -------------------------------- ### Updating Keymap and Help Groups Source: https://github.com/baairon/torlink/blob/main/CONTRIBUTING.md Demonstrates updating both `HELP_GROUPS` and `footerHints` in `src/ui/keymap.ts` when a new keybinding is introduced. This ensures the user-facing help documentation is consistent with the available commands. ```typescript // In src/ui/keymap.ts // Update HELP_GROUPS const HELP_GROUPS = { // ... other groups "copy-magnet": { y: "copy magnet", }, }; // Update footerHints const footerHints = { // ... other hints y: "copy magnet", }; // ... rest of the file ``` -------------------------------- ### Build and Run Bundled Version Source: https://github.com/baairon/torlink/blob/main/README.md After development, you can build the project and run the bundled version of torlink using npm run build followed by npx torlnk. ```sh npm run build npx torlnk ``` -------------------------------- ### Adding Store Field and Preview Rendering Source: https://github.com/baairon/torlink/blob/main/CONTRIBUTING.md Illustrates the process of adding a new field to the `Store` interface and ensuring it's reflected in the preview rendering system. This involves updating `makeStore` in `scripts/render-previews-impl.tsx` to prevent `npm run previews` from breaking. ```typescript // In scripts/render-previews-impl.tsx function makeStore() { return { // ... other fields copyMagnet: false, // Added field }; } // ... rest of the file ``` -------------------------------- ### Run Typecheck and Tests Source: https://github.com/baairon/torlink/blob/main/CONTRIBUTING.md Before opening a pull request, ensure that the code passes type checking and all tests are green. This involves running `npm run typecheck` for TypeScript checks and `npm test` for Vitest. ```sh npm run typecheck # tsc --noEmit, zero errors ``` ```sh npm test # vitest, all green ``` -------------------------------- ### Add Torlink to Nix Flake Inputs Source: https://github.com/baairon/torlink/blob/main/nix/README.md Include the torlink repository in your flake.nix inputs. The package is built using the unstable channel by default. ```nix inputs = { ... torlink.url = "github:baairon/torlink"; ... } ``` -------------------------------- ### Graceful Failure for Node.js Version Source: https://github.com/baairon/torlink/blob/main/CONTRIBUTING.md Handles incompatible Node.js versions by displaying a user-friendly message and exiting cleanly, rather than crashing with a cryptic error. This improves the user experience on older Node.js runtimes. ```javascript if (process.versions.node < "18.0.0") { console.error("Please upgrade Node.js to version 18 or higher."); process.exit(1); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.