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

codewars-runner

v0.1.5

Published

Codewars.com code sandbox capabilities

Readme

codewars-runner

This project is both a command-line utility and server, used by Codewars to execute small sets of code within various languages, using various testing frameworks.

You can run node run --help to view information about which arguments are supported.

Purpose

The purpose of this project is to provide a low level ability to run 'Kata'. It provides a mechanism for executing different configurations of code using various languages and testing frameworks.

Docker can be utilized in order to sandbox code execution. A server is provided that can accept 'run' requests and execute them within a Docker container.

Supported Languages and Testing Frameworks

  • JavaScript

    • mocha (comming soon...)
    • codewars
  • CoffeeScript

    • mocha (comming soon...)
    • codewars
  • Ruby

    • rspec
    • codewars
  • Python

    • unittest
    • codewars
  • Java

    • junit
  • C#

    • nunit (comming soon...)
    • codewars

Examples:

Basic Usage

The CLI capabilities can be used without having to run Docker. As long as you have the language and frameworks installed on your host machine, you will be able to run the CLI tool standalone.

If you just wanted to execute some code and return its output, you can do so like the following:

Ruby

node run -l ruby -c 'puts 123'

JavaScript

node run -l js -c 'console.log(123)'

Python

node run -l py -c 'print 123'

Kata Usage

You can also provide a test fixture to be run along with the code. The output returned is the same output that is parsed by Codewars to render its kata output.

Ruby

node run -l ruby -c 'a = 1' -f 'Test.expect a == 1'

JavaScript

node run -l js -c 'a = 1' -f 'Test.expect(a == 1)'

Python

node run -l py -c 'a = 1' -f 'test.expect(a == 1)'

Docker

Build

docker build -t codewars/cli-runner .

Run Help

docker run --rm codewars/cli-runner --help

Run Ruby Kata

docker run --rm codewars/cli-runner run -l ruby -c 'a = 1' -f 'Test.expect a == 1'

Run JavaScript Kata

docker run --rm codewars/cli-runner run -l js -c 'a = 1' -f 'Test.expect(a == 1)'

Run Python Kata

docker run --rm codewars/cli-runner run -l py -c 'a = 1' -f 'test.expect(a == 1)'

Server

You can run a server which wraps the CLI and runs it within a Docker container. If you have Docker installed on your machine and the Codewars image built, all you need to do to start the server is run node server. You can then make posts requests to localhost:8080/run and provide the same arguments that you would for the CLI tool.

Vagrant

Version 1.6.3 or higher is required.

A fully working environment is provided via Vagrant. These steps will get a working server running:

vagrant up
vagrant ssh
cd /vagrant
node build
supervisor server.js

You should now have a fully working server with Docker support. You can access the server using localhost:8080. You can post requests to /run with the same arguments that the CLI accepts.

Notes about image versioning

The Docker images used by server.js are tagged within a version number. Some utilities have been provided to make it easier to manage versioned images.

build.js

simply run node build to build the latest versioned image

Droplet setup

grab the files

cd /
git clone https://github.com/entrefuse/codewars-runner
cd /codewars-runner/setup

create a non-root user and give it permissions

sh create-user.sh

provision the machine

sh provision.sh

set up the production environment

sh prod.sh

set up the hourly docker restart

bash restarer.sh