generate-code-context
v1.0.19
Published
This npm package reads all files in a directory (excluding specified ones) and writes their contents to a `.txt` file.
Downloads
12
Maintainers
Readme
Generate Code Context of your Project
This npm package reads all files in a directory (excluding specified ones) and writes their contents to a .txt
file.
Installation
npm i generate-code-context
Usuage
Create a file named generate.js in your project directory.
Add the following code to generate.js:
const { run } = require('generate-code-context');
const path = require('path');
const startDir = __dirname; // Root directory
const excludeDirs = ['node_modules', 'dist', 'build'];
const excludeFiles = ['package.json', 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml'];
const outputFilePath = path.join(__dirname, 'code_context.txt'); // Save in root directory
run(startDir, excludeDirs, excludeFiles, outputFilePath);
Get Gemini API Key from https://aistudio.google.com and paste it in .env file
API_KEY=your_google_api_key_here
RUN
node generate.js