diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea7..9b77ea7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,10 +1,9 @@ --- name: Bug report about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - +title: "" +labels: "" +assignees: "" --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] **Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7..2bc5d5f 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,10 +1,9 @@ --- name: Feature request about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - +title: "" +labels: "" +assignees: "" --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cd45ac..399ad32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,13 +2,12 @@ name: CI on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: build: - runs-on: ubuntu-latest strategy: @@ -16,11 +15,11 @@ jobs: node-version: [20.x] steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npx prettier --check src/ + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - run: npm ci + - run: npx prettier --check src/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 0fd2fe7..ef3b194 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the +- Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or +- The use of sexualized language or imagery, and sexual attention or advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an +standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9845abb..163462b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,41 +5,44 @@ We welcome contributions to improve codeshift! Whether it's reporting a bug, sug ## How to Contribute 1. Fork the repository - - Click the "Fork" button on the top right of the repository page. + + - Click the "Fork" button on the top right of the repository page. 2. Clone your fork - ```bash - git clone https://github.com//codeshift.git - cd codeshift - ``` + ```bash + git clone https://github.com//codeshift.git + cd codeshift + ``` 3. Create a branch for your feature or fix - ```bash - git checkout -b feature/my-awesome-feature - ``` + ```bash + git checkout -b feature/my-awesome-feature + ``` 4. Make your changes - - Ensure that your code follows the existing style and conventions. - - Run tests and ensure everything is working as expected. + + - Ensure that your code follows the existing style and conventions. + - Run tests and ensure everything is working as expected. 5. Commit your changes - - Follow the Conventional Commits format for commit messages. - ```bash - git commit -m "feat(scope): add new feature description" - ``` + - Follow the Conventional Commits format for commit messages. + + ```bash + git commit -m "feat(scope): add new feature description" + ``` 6. Push to your fork - ```bash - git push origin feature/my-awesome-feature - ``` + ```bash + git push origin feature/my-awesome-feature + ``` 7. Submit a pull request - - Go to the original repository, navigate to the "Pull Requests" tab, and open a new pull request. - - Provide a clear description of your changes, explaining the problem it solves or the feature it adds. + - Go to the original repository, navigate to the "Pull Requests" tab, and open a new pull request. + - Provide a clear description of your changes, explaining the problem it solves or the feature it adds. ## Guidelines diff --git a/README.md b/README.md index d33b85f..4bed47b 100644 --- a/README.md +++ b/README.md @@ -28,32 +28,34 @@ Codeshift is a command-line tool to translate and transform source code files be - Clone the repository with [Git](https://git-scm.com/): - ```bash - git clone https://github.com/uday-rana/codeshift.git - ``` + ```bash + git clone https://github.com/uday-rana/codeshift.git + ``` - Alternatively, download the repository as a .zip from the GitHub page and extract it - In the repository's root directory (where `package.json` is located), run `npm install`: - ```bash - cd codeshift/ - npm install - ``` + ```bash + cd codeshift/ + npm install + ``` - To be able to run the program without prefixing `node`, run `npm install -g .` or `npm link` within the project directory: - ```bash - npm install -g . - ``` + ```bash + npm install -g . + ``` - Create a file called `.env` by copying the `.env.example` file - Add your API key, preferred base URL, and preferred model. It should look similar to the example below: + - For OpenAI, use the base URL `https://api.openai.com/v1` - For OpenRouter, use the base URL `https://openrouter.ai/api/v1` - For Groq, use the base URL `https://api.groq.com/openai/v1`. - For a list of models for each provider, see: + - [OpenAI models](https://platform.openai.com/docs/models) - [OpenRouter models](https://openrouter.ai/models) - [Groq models](https://console.groq.com/docs/models) diff --git a/examples/index.js b/examples/index.js index 724df7c..cb54129 100644 --- a/examples/index.js +++ b/examples/index.js @@ -1,10 +1,10 @@ -const express = require('express'); +const express = require("express"); const app = express(); const port = 3000; // Basic route to handle GET requests -app.get('/', (req, res) => { - res.send('Hello, World!'); +app.get("/", (req, res) => { + res.send("Hello, World!"); }); // Starting the server diff --git a/src/model.js b/src/model.js index b7f092c..c24c107 100644 --- a/src/model.js +++ b/src/model.js @@ -19,13 +19,13 @@ let model = process.env.MODEL; // Find match in supportedProviders based on baseURL const provider = Object.values(supportedProviders).find((supportedProvider) => - baseURL.startsWith(supportedProvider.baseURL) + baseURL.startsWith(supportedProvider.baseURL), ); if (!model) { if (!provider) { throw new Error( - `Unsupported provider for BASE_URL ${process.env.BASE_URL}. Please set a valid MODEL environment variable.` + `Unsupported provider for BASE_URL ${process.env.BASE_URL}. Please set a valid MODEL environment variable.`, ); } model = provider.defaultModel;