Coder Social home page Coder Social logo

cha0sg0d / df-plugin-dev-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from projectsophon/df-plugin-dev-server

0.0 0.0 0.0 18 KB

An ESBuild server for Dark Forest plugin development.

License: MIT License

JavaScript 96.91% Dockerfile 3.09%

df-plugin-dev-server's Introduction

@projectsophon/df-plugin-dev-server

An ESBuild server for Dark Forest plugin development.

Installation

You can install the command globally using:

npm i -g @projectsophon/df-plugin-dev-server

Usage

Once installed, you should have access to the command:

df-plugin-dev-server

You can see the supported flags by running:

df-plugin-dev-server

Start a Dark Forest plugin development server.

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --dir      The directory to load     [deprecated: use --glob instead] [string]
  --ext      Extensions to process      [deprecated: use --glob instead] [array]
  --glob     Glob for finding plugins   [array] [default: ["plugins/*.(js|ts)"]]

And then run the server:

df-plugin-dev-server
ESBuild for /Users/user/sophon-plugins/plugins on port 2221
Development server started on http://127.0.0.1:2222/

Adblock & Security

I noticed that Brave Browser's built-in Adblock stops any requests to 127.0.0.1, so you'll need to disable that if you are building plugins against https://zkga.me directly.

You'll also need to "Allow Insecure Content" since this development server doesn't provide an HTTPS certificate.

Plugins

The easiest way to load plugins while developing would be to use something like this in the Dark Forest UI:

// This maps to ./plugins/PluginTemplate.js or ./plugins/PluginTemplate.ts by default
export { default } from "http://127.0.0.1:2222/PluginTemplate.js";

However, Dark Forest plugins are cached, so you'd need to do some sort of cache busting each time you make a change. Luckily, we've taken care of that for you! To get free cache busting, you can add ?dev to the end of your plugin URL.

// Notice the ?dev
export { default } from "http://127.0.0.1:2222/PluginTemplate.js?dev";

Doing the above will proxy your plugin through a cache busting plugin!

Docker image installation and running

From main directory you can execute commands to build and start docker image:

To build & run without getting prompted for docker output simply run (with -d):

docker-compose -f docker-compose.yml up -d --build --remove-orphans

To run an existing image without building, remove --build --remove-orphans:

docker-compose -f docker-compose.yml up -d

To stop you should use stop. To stop and delete use down:

docker-compose -f docker-compose.yml stop
docker-compose -f docker-compose.yml down

To only build the docker image:

docker-compose -f docker-compose.yml build

If your image is already built, you can use the docker command directly:

docker start plugin_server
docker stop plugin_server

Security notes for docker containers

Docker is working on another layer meaning your internet connection from docker containers is bridged through your network interface by default. Starting this container with default configuration using commands from above opens port to this docker container to any incoming IP subnet existing (bind 0.0.0.0). Default system firewall configuration will not prevent access from outside world if your router does not block ports by default. KEEP THIS IN MIND. Storing vulnerable data inside container is not recommended with this configuration. You should edit docker network of plugin_server to make it harden. The easiest way is to set flag --internal for specific docker network, to prevent access from other computers.

License

MIT

df-plugin-dev-server's People

Contributors

pawlowskiadrian avatar phated avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.