Statements | Branches | Functions | Lines |
---|---|---|---|
- NodeJS (v8+)
$ cd compose
- Create a file called ".env" with the following text under compose folder
NODE_ENV=development
SERVER_PORT=8080
Note - The file .env.sample
can be renamed as .env
For more information on dotenv files: https://www.npmjs.com/package/dotenv
- Install necessary node packages
npm install
- Run using developer tools (nodemon enabled). This allows changes to the source code to be reflected by the server as soon as changes are saved.
npm run dev
- Run without developer tools
npm start
- How to access web interface. To use a port other than 8080 change the SERVER_PORT variable in .env.
localhost:8080
- How to access typedoc (auto-generated documentation)
localhost:8080/docs
Other Node Commands:
npm lint
- run linting over source code.
npm run test
- run test suite and generate coverage reports.
npm run apidoc
- update the API documentation found at server:port/docs
(i.e. localhost:8080/docs
) and in the /dist folder.
Users can bypass the GUI interface and make requests through HTTP and a program like cURL or HTTPie. Web API found below.
- Note: API documentation is generated from api.raml, to get most up to date api documentation run
npm run dev
and go tolocalhost:8080/docs/api.html
To simplify the process of uploading code to code competition websites.
- Languages supported currently
- Javascript
- Python
- Languages in development
- C++
This project runs off a general web MVC architecture implemented by Node Express.
/src/api/
contains the model logic including the language specific logic
/src/controllers
and /src/views/
contain the logic for controllers and views respectively.
/src/routes/
contains HTTP routing instructions for Node Express.
tests/api/
Contains the tests. New tests can be added, using the JEST framework. The test suite can be run with the node command npm run test
New languages can be easily added and registered to the program. First make a new class that extends the abstract class /src/api/language.ts
. At a minimum, the class variables name, exts, and comment are likely to need to be defined for the new language. However, the most important function is the compose function.
The compose function takes two parameters. The first is a dictionary of the user uploaded zip file. The dictionary's values are the files converted to string arrays (line by line, preserving whitespacing). The keys are the full filepaths of each file including the name of the zip as the top level directory. For example, foo/__init__.py is zipped into a folder named mydir, that file's key would be my_dir/foo/__init__.py. The other parameter is the user defined entry or main filename in the same format. The function needs to return the single, combined, file as a string.
src/api/languages.ts
is where the program keeps track of included languages. Simply add new languages to the dictionary and the front end will automatically incorporate it, and the backend will know how to call it. The is how the app will recognize the language in HTTP requests and is how it will display on the view, so make sure it's recognizable.
- Compose uses Jest as the testing framework
- Add unit tests in the
test/api/
directory in a file named<common language name>.test.ts
- Once your language is implemented create test directories and source files
- go to
test/files/
and create a directory with the name the same as the common language name - In that directory create a config.json which has the following structure
- go to
{
"command": {"win32": string, "else": string} | string, //the command format string with a single %s
"entry": string, //full path from root of zip archive to the main file
<name of test sub directories :string>: string, // the expected result from running the command
}
-
- Now create the sub directories with test source files, run them, copy the outputs to the corresponding JSON property in the config.json
- The Language methods are implemented and the comment guard wrapping source files is of the form of a single line comment followed by the begin guard or end guard.
- The begin and end guard must be distinct and not a substring of one another.
- Any edits to the source between guards must be done in a way that it can be undone by a per-line map function. The Language class has a protected member function, processLine, that can be overwritten by language imeplementations to facilitate this, an example can be found in python class.
- Sign into travis-ci.com using your GitHub account.
- Activate your repository through Travis CI.
- Builds can either be triggered manually or will automatically build during the next update to the repository.
- The revert function when using linux has a root directory named "undefined" but otherwise reproduces the source zip file. The issue was narrowed to the mock file system called in the revert function.