|
| 1 | +# GitHub RAG Examples |
| 2 | + |
| 3 | +A Node.js project that demonstrates running TypeScript files natively without transpilation using Node.js v22.15.0+ and the experimental type stripping feature. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Node.js v22.15.0 or higher |
| 8 | +- npm (comes with Node.js) |
| 9 | + |
| 10 | +## Setup |
| 11 | + |
| 12 | +1. Clone this repository: |
| 13 | + ```bash |
| 14 | + git clone https://github.com/codenote-net/github-rag-examples.git |
| 15 | + cd github-rag-examples |
| 16 | + ``` |
| 17 | + |
| 18 | +2. Install dependencies: |
| 19 | + ```bash |
| 20 | + npm install |
| 21 | + ``` |
| 22 | + |
| 23 | +## Running TypeScript Natively |
| 24 | + |
| 25 | +This project is configured to run TypeScript files directly with Node.js without the need for transpilation, using the `--experimental-strip-types` flag. |
| 26 | + |
| 27 | +### Basic TypeScript Example |
| 28 | + |
| 29 | +Run the basic example: |
| 30 | + |
| 31 | +```bash |
| 32 | +npm start |
| 33 | +``` |
| 34 | + |
| 35 | +This executes the `src/index.ts` file directly using Node.js. |
| 36 | + |
| 37 | +## GitHub Repository Clone Script |
| 38 | + |
| 39 | +This project includes a script to clone a GitHub repository using a GitHub App installation token. The script uses the x-access-token authentication method as described in the [GitHub documentation](https://docs.github.com/ja/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation). |
| 40 | + |
| 41 | +### Usage |
| 42 | + |
| 43 | +1. Set the required environment variables: |
| 44 | + |
| 45 | +```bash |
| 46 | +export GITHUB_TOKEN="your_github_app_installation_token" |
| 47 | +export REPO_OWNER="repository_owner" |
| 48 | +export REPO_NAME="repository_name" |
| 49 | +export CLONE_DIR="./cloned-repo" # Optional, defaults to './cloned-repo' |
| 50 | +``` |
| 51 | + |
| 52 | +2. Run the clone script: |
| 53 | + |
| 54 | +```bash |
| 55 | +npm run clone |
| 56 | +``` |
| 57 | + |
| 58 | +This will clone the specified repository using the GitHub App installation token with the specified branch or tag. |
| 59 | + |
| 60 | +## How It Works |
| 61 | + |
| 62 | +Starting with Node.js v22.6.0, Node.js has experimental support for TypeScript syntax through "type stripping". This allows you to run valid TypeScript code directly in Node.js without the need to transpile it first. |
| 63 | + |
| 64 | +From Node.js v23.6.0 onwards, type stripping is enabled by default, but this project explicitly uses the flag for compatibility with Node.js v22.x. |
| 65 | + |
| 66 | +## Project Structure |
| 67 | + |
| 68 | +- `/src` - TypeScript source files |
| 69 | +- `package.json` - Project configuration |
0 commit comments