npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@uday-rana/codeshift

v3.0.0

Published

Transform code from one language to another

Downloads

234

Readme

codeshift

Codeshift is a command-line tool to translate and transform source code files between programming languages.

codeshift tool demo: translating an express.js server to rust

Features

  • Select output language to convert source code into
  • Support for multiple input files
  • Output results to a file or stream directly to stdout
  • Customize model and provider selection for optimal performance
  • Supports leading AI providers:

Requirements

  • Node.js (Requires Node.js 20.17.0+)
  • An API key from any of the following providers:

Installation

  • Run npm install -g @uday-rana/codeshift.

  • Run npx codeshift. This will generate a .codeshift.config.toml file in your current directory.

  • In .codeshift.config.toml, set the base URL for your preferred provider and add your API key. It should look something like this:

    # .codeshift.config.toml
    
    [settings]
    baseUrl="https://openrouter.ai/api/v1"
    apiKey="sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    outputFile="xxxxxxxxxxx"
    model=""
    tokenUsage=true
    stream=true
    • The following base URLs are supported. Others may be used but are not supported and may cause errors:
      • OpenAI: https://api.openai.com/v1
      • OpenRouter: https://openrouter.ai/api/v1
      • Groq: https://api.groq.com/openai/v1.
    • For a list of models for supported providers, see:

Usage

npx codeshift [options] <output-language> <input-files...>

Arguments

  • <output-language>: The desired language to convert source files to
  • <input-files...>: Paths to the source files, separated by spaces

Options

  • -o, --output-file: Specify filename to write output to
  • -t, --token-usage: Display the number of tokens used by the AI for processing
  • -s, --stream: Stream the response from the LLM.
  • -h, --help: Display the help message explaining usage, options, and arguments
  • -v, --version: Display the program name and version number

Example

# Converts a JavaScript file (index.js) to Go, saving the output in index.go
npx codeshift -o index.go go examples/index.js

codeshift file output demo

Contributing

See CONTRIBUTING.md

License

This project is licensed under the MIT License. See the LICENSE file for more details.