Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @inexorgame/inexor-flex with all npm packages installed. Try it out:

@inexorgame/inexor-flex lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("@inexorgame/inexor-flex/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@inexorgame/inexor-flex v0.9.8

Scripting environment for Inexor.

Inexor Flex

npm version Build Status Build status Dependency Status NSP Status

Inexor Flex is platform for managing Inexor Core instances and the Inexor Tree API and provides a scripting environment for servers and clients. Inexor Flex also makes multiple user interfaces using web technologies available.

The reference documentation can be found at GitHub pages Further introduction and overview: https://github.com/inexorgame/inexor-core/wiki/Inexor-Flex

Introduction

Hello there and welcome to the inexor-flex documentation!

Now, you're wondering what inexor-flex actually is, and what it does?

Below is a brief explanation about inexor-flex:

  • we wanted to create a way in which we can easily configure and extend our game
  • that's why we created _the tree_. It means that all the settings (variables) in the game can be edited in real-time in a tree structure
  • but this tree was hard to access. It's sent over the wire in a compressed format, that's hard to work with for "casual users"
  • next: we created inexor-flex. It makes this tree available via a web service (and webviewer). On your local computer.
  • not only can you edit the game in real time with flex, it also does a bunch of things for you
    • read configuration. e.g for maps, or servers
    • read the server list
    • only your imagination is the limit (...)

How to set up inexor-flex

You can choose from one of our graphical installers at our website.

If you're a little bit more of a techy, here are the command line instructions to install flex

  • you need to have Node.js installed from nodejs.org. The latest stable release is recommended.
  • open a terminal/shell
  • install the yarn package manager via npm i -g yarn
  • install flex via yarn i -g @inexorgame/inexor-flex
  • you can start flex via inexor-flex directly at your fingertips

NOTE: If you're curious what the graphical installer does. No suprise. Exactly the same.

What's this "instances" thing?

Since nowadays, all configuration is done via inexor-flex, we have introduced a system called instances. Each Inexor client or server is an instance. You can have multiple clients (or servers), with different configurations, even running different versions of the game. No problemo.

Now let's go fancy. Right at your browser.

If you want to be little bit more of a power user, we also ship a graphical interface for flex. Right there. When you download it.

Just go to http://localhost:31416/api/v1/interfaces/ui-flex And even more fancy. You can see the inexor tree at http://localhost:31416/api/v1/interfaces/ui-flex/#/instances/31417

Developer section

How to set up inexor-flex as a developer

To set up inexor-flex follow the below instructions.

Given that you have cloned inexor-flex and are in the inexor-flex directory:

yarn install
yarn start # start flex

The command line

inexor-flex brings a verbose command line that can easily be accessed with it's name. Just call inexor-flex from your command line (shell, prompt, terminal), and you can have a lot of options to configure flex from the command line.

Folder structure

Flex is structure in two main folders:

  • src is where the utilities of flex reside
  • server is where the actual flex server resides. The web server is started here, and all run-time functionality (such as paths) are determined here.

All of the above components are wired together using the Application Context module.

After the "wire" individual components, such as the package manager are started.

The API is exposed as a RESTfull API.

Architectual

inexor-flex was initially born to serve the tree of inexor-core and this is how it works nowadays.

  • we create a mother inexor root node using the @inexorgame/tree module
  • each instance of Inexor Core has a src/instances/Connector attached
  • this Connector will create a tree at /instance/INSTANCEID
  • other modules can be hooked in other namespaces than /instances. e.g for the ReleaseManager, the namespace is /releases

Interfaces

Interfaces are graphical user interfaces for inexor-flex and inexor-core. An interface is basically just a HTML5/CSS/JavaScript folder, which will be made available via the REST API.

Below is a list of the default interfaces shipped with inexor-flex:

NOTE: For the ui modules also uses yarn

Adding an own interface

An interface should follow the below directory structure:

  • Your interface must expose a dist folder with all it's assets
  • package.json
  • dist
    • img
    • js
    • css
    • index.html
    • (...)
  • Your dependencies will be served from http(s)://flex_url/static
  • Your interface will be served from http(s)://flex_url/api/v1/interfaces/NAME

You can then use the interfaces command line to add your newly written.

Documentation and style guide

We use JSDoc for documentation. All modules from src and server are automatically added to the documentation, when following the standards.

We endorse the eslint:recommended rule set, combined with some custom rules. You can make sure your module matches our standard by running npm run lint in the main directory.

When writting a module, please keep the following in mind

  • if you write a larger block of code or seperate functionality, consider creating a new module
  • by default unit tests with mocha are done for any file that matches *_test.js, though it is highly recommended to add a test folder to your module
  • if necessary (for important or big modules), we urge that you add a separate README.md to the respective module

We also try to apply the changes detected by the [security/recommended] standard.

The REST API

The REST API (v1) is wired together in server/api/v1/index.js Documentation via swagger should follow soon enough.

Writing an own module

Essentially to write your very first own module, you should go like this

  • mkdir src/YOURMODULE
  • cd src/YOURMODULE & npm init which will ask you a bunch of questions
  • the name of your module should ideally be @inexorgame/YOURMODULE
  • your module should export a index.js file with it's functionality

Now you can use npm link inside the directory. Later on your module can be used via

const yourmodule = require('@inexorgame/yourmodule')

You can have a look at the src/types module, for a very simple and basic module example.

Using the API

We have specifically designed the module @inexorgame/treeclient to work with the v1 API. You can have a look at one of the many command-line tasks in server/commands/cli/ which will give a fine example on how to use the treeclient library.

Flex won't start. Resolving conflicts with the module manager

If flex won't start for strange reasons the most likely thing is that you've worked with a earlier revision in which an individual module is broken. Try the following:

npm unlink @inexorgame && npm un -g @inexorgame/inexor-flex rm -rf node_modules And then install again.

Future features

This is either to-do or nice to have

  • [ ] add example modules and user documentation a-la readthedocs
  • [ ] test everything extensively, fix passages that are marked with TODO (and add unit tests!)
  • [ ] authentication via OAuth
  • [ ] more secure server
  • [ ] sandbox-based plugin system
  • [ ] server lister and package lister
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free