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

compilex

v0.7.4

Published

compilex is a node.js library which is used to build online code editor/compiler websites and webservices.

Downloads

276

Readme

compilex

NPM version Build Status Dependency Status Download Status License Gitter

This package is DEPRECATED. Please read the deprecation notice.

compilex is a node.js library which is used to build online code compiler/interpreter websites and webservices.

You can compile and respond back outputs for all the languages that can be compiled by the server.

Some of the online code compiling/judging websites are

compilex is an experimental package , however , if you want to build your site quickly , you can prefer to use the API of the above said services. Node.js Wrapper modules for those API are available. You can try HackerRank SDK and HackerEarth SDK.

Typical scenarios in which you have to go with wrapper modules instead of compilex are

  • If you don't want to have the pain of configuring compilers on your server.
  • If you don't have the access to the VM on which your site is hosted
  • If you feel tired of configuring compilex over SSH.

Deprecation Notice

compilex is not under active development. It started as an experiment and served its purpose well. But over the time, new technologies like docker emerged. The existence of such technology and nature of node.js prove that compilex would not scale well and be production ready with its current state.

Before a production ready rewrite of architecture and code, I considered looking at already existing solutions, which seem to be powerful enough to make me not to rewrite compilex. Here are they,

APIs

There are serveral battle tested APIs, that can help compile code online without the hassle of configuration and infrastructure. Some of them are

Container Based Solution

Docker containers prove to be best fit for running code in an isolated environment ensuring security. Instead of rolling out compilex on the server itself, it would be more sensible to run compilex inside a docker container. For that to happen, we will be needing to build docker images for each language and their versions.

Luckily, there is already a well managed and open source solution called glot.io. It seems to be one stop solution which includes web editor, docker based code runner, more language suppport and production ready. So, I highly recommend looking at glot.io, if the intention is to run a code compiling service on your own infrastructure.

Steps forward

  • compilex won't be unpublished from npm. This is to ensure that, projects using compilex is not affected.
  • No PRs will be merged, except bug fixes. compilex will never reach 1.x.x version ( how sad :( ). This is to enforce people to use alternate solutions ( right solutions ) mentioned above.

"I thank people for their responses and support over mail, gitter, quora etc." - scriptnull

Supported Languages

compilex is currently in initial development stage . As the library grows , so does the list here .

| Language | Support | |---------|:-------:| |C |✔| |C++ | ✔ | |Java | ✔ | |Python | ✔ | |C# | ✔ | |Visual Basic | ✔ |

Work Flow

  1. Get the program as input from the client as a request
  2. Use compilex modules to compile the program
  3. Get the output and errors in json and string formats
  4. Respond the output to the client

Setting Up Compilers

Inorder to compile any programming language , you need to first have the compiler for that programming language in the server machine.

Documentation

var compiler = require('compilex');
var options = {stats : true}; //prints stats on console 
compiler.init(options);

init() creates a folder named temp in your project directory which is used for storage purpose. Before using other methods , make sure to call init() method.

    //if windows  
    var envData = { OS : "windows" , cmd : "g++"}; // (uses g++ command to compile )
    //else
    var envData = { OS : "linux" , cmd : "gcc" }; // ( uses gcc command to compile )
    compiler.compileCPP(envData , code , function (data) {
        res.send(data);
        //data.error = error message 
        //data.output = output value
    });
    
    //res is the response object
    //if windows  
    var envData = { OS : "windows" , cmd : "g++"}; // (uses g++ command to compile )
    //else
    var envData = { OS : "linux" , cmd : "gcc" }; // ( uses gcc command to compile )
    compiler.compileCPPWithInput(envData , code , input , function (data) {
        res.send(data);
    });
    //if windows  
    var envData = { OS : "windows"}; 
    //else
    var envData = { OS : "linux" }; // (Support for Linux in Next version)
    compiler.compileJava( envData , code , function(data){
        res.send(data);
    });    
    //if windows  
    var envData = { OS : "windows"}; 
    //else
    var envData = { OS : "linux" }; // (Support for Linux in Next version)
    compiler.compileJavaWithInput( envData , code , input ,  function(data){
        res.send(data);
    });
    //if windows  
    var envData = { OS : "windows"}; 
    //else
    var envData = { OS : "linux" }; 
    compiler.compilePython( envData , code , function(data){
        res.send(data);
    });    
    //if windows  
    var envData = { OS : "windows"}; 
    //else
    var envData = { OS : "linux" }; 
    compiler.compilePythonWithInput( envData , code , input ,  function(data){
        res.send(data);        
    });
    var envData = { OS : "windows"}; 
    //mono modules for linux is not included till now
    compiler.compileCS( envData , code , function(data){
        res.send(data);
    });    

    var envData = { OS : "windows"}; 
    //mono modules for linux is not included till now
    compiler.compileCSWithInput( envData , code , input ,  function(data){
        res.send(data);        
    });
    var envData = { OS : "windows"}; 
    compiler.compileVB( envData , code , function(data){
        res.send(data);
    });    

    var envData = { OS : "windows"}; 
    compiler.compileVBWithInput( envData , code , input ,  function(data){
        res.send(data);        
    });

All the temporary files ( source code and executables ) are created in your temp directory. flush and flushSync helps you to free the memory by deleting the temporary files.

    compiler.flush(function(){
    console.log('All temporary files flushed !'); 
    });

Synchronous version of flush

    compiler.flushSync();

Getting statistics about your compilex server has been taken care. fullStat returns json data about your server.

    compiler.fullStat(function(data){
        res.send(data);
    });

Examples

You can find examples here.The examples are downloaded everytime you download compilex via npm. you can begin with editing CSS and publish your site in minutes. Here is the screenshot of the demo. alt text

License

All the contents in this repository are released under the MIT License .