Merge branch 'develop' into main

This commit is contained in:
Nils Ramstoeck
2023-11-04 17:12:23 +01:00
2 changed files with 98 additions and 13 deletions

View File

@@ -2,7 +2,7 @@
This is a template for using any external editor for Bitburner. This Template supports JSX, TS and TSX out of the box.
## How to use
## How to get started
1. If you dont already have it installed, install [NodeJS](https://nodejs.org) v20 or newer
1. Clone this repository
@@ -14,14 +14,99 @@ This is a template for using any external editor for Bitburner. This Template su
1. press connect
Now any changes made to scripts inside the server folders will automatically be uploaded to Bitburner.
To upload new scripts steps 5-7 will have to be repeated after their creation. (I plan on improving that)
## Using React
For more in-depth details have a look at the [plugin](https://github.com/NilsRamstoeck/esbuild-bitburner-plugin) powering this template!
The React and ReactDOM instance from the game can simply be imported as ESModules
## Features
### esbuild
This template uses [esbuild](https://esbuild.github.io/) to bundle your scripts.
### Using React
This template allows you to use the ingame instances of `React` and `ReactDOM` simply by importing them as ESModule as you usually would.
```jsx
import React, {useState} from 'react';
export MyComponent(){
const [count, setCount] = useState(0);
return <div>Count {count} <button onClick={() => setCount(count + 1)}>Add to count</button></div>;
}
```js
import React from 'react' //and
import ReactDOM from 'react-dom'
```
For more in-depth details and features have a look at the [plugin](https://github.com/NilsRamstoeck/esbuild-bitburner-plugin) powering this template!
### Developing on multiple servers
Simply create a new folder with the name of the server you want in the 'servers' directory to develop on to start developing on that server!
### Bidirectional Mirroring
You can enable mirroring like this
```js
const createContext = async () => await context({
entryPoints: [
'servers/**/*.js',
'servers/**/*.jsx',
'servers/**/*.ts',
'servers/**/*.tsx',
],
outbase: "./servers",
outdir: "./build",
plugins: [BitburnerPlugin({
port: 12525,
types: 'NetscriptDefinitions.d.ts',
mirror: {
'local/path': ['home', 'and/or other servers']
}
})],
bundle: true,
format: 'esm',
platform: 'browser',
logLevel: 'info'
});
let ctx = await createContext();
ctx.watch();
```
This will mirror all listed servers for a path to a specified location.
While mirroring, all changes in the game will be synced with your editor and vice versa.
### Automatic Distribution
You can specify folders with a list of servers to automatically distribute your files to these servers like this:
```js
const createContext = async () => await context({
entryPoints: [
'servers/**/*.js',
'servers/**/*.jsx',
'servers/**/*.ts',
'servers/**/*.tsx',
],
outbase: "./servers",
outdir: "./build",
plugins: [BitburnerPlugin({
port: 12525,
types: 'NetscriptDefinitions.d.ts',
distribute: {
'build/home/dist': ['server-1', 'server-2', 'server-3']
}
})],
bundle: true,
format: 'esm',
platform: 'browser',
logLevel: 'info'
});
let ctx = await createContext();
ctx.watch();
```
In this example all files that are developed in 'servers/home/dist' will not only be uploaded to 'home' but also 'server-1', 'server-2' and 'server-3'.

View File

@@ -9,15 +9,15 @@ const createContext = async () => await context({
'servers/**/*.tsx',
],
outbase: "./servers",
outdir: "./dist",
outdir: "./build",
plugins: [
BitburnerPlugin({
port: 12525,
types: 'NetscriptDefinitions.d.ts',
// mirror: { //uncomment to enable file mirroring
// 'mirror/own': ['home'],
// 'mirror/other': ['n00dles']
// }
mirror: {
},
distribute: {
}
})
],
bundle: true,
@@ -27,4 +27,4 @@ const createContext = async () => await context({
});
let ctx = await createContext();
ctx.watch();
ctx.watch();