diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3ef734 --- /dev/null +++ b/.gitignore @@ -0,0 +1,133 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# Netscript Type Definitions. These are pulled from the game +NetscriptDefinitions.d.ts diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d10c341 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Nils Ramstoeck + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..58ef80e --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# bb-external-editor + +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 + +1. If you dont already have it installed, install [NodeJS](https://nodejs.org) +1. Clone this repository +1. navigate to the template (`cd path/to/the/template`) inside your console +1. run `npm install` in your console to install all dependencies +1. run `npm start` in your console to start the RemoteAPI server +1. open Bitburner and navigate to the settings +1. open the tab labeled 'Remote API' and enter the port '12525' +1. press connect + +Now any changes made to scripts inside the server folders will automatically be uploaded to Bitburner. + +## Using React + +The React and ReactDOM instance from the game can simply be imported as ESModules + +```js +import React from 'react' //and +import ReactDOM from 'react-dom' +``` + +For more in-depth details have a look at the [plugin](https://github.com/NilsRamstoeck/esbuild-bitburner-plugin) powering this template! diff --git a/build.mjs b/build.mjs new file mode 100644 index 0000000..75149a8 --- /dev/null +++ b/build.mjs @@ -0,0 +1,26 @@ +import { context } from 'esbuild'; +import { BitburnerPlugin } from 'esbuild-bitburner-plugin'; + +const createContext = async () => await context({ + entryPoints: [ + 'servers/**/*.js', + 'servers/**/*.jsx', + 'servers/**/*.ts', + 'servers/**/*.tsx', + ], + outbase: "./servers", + outdir: "./dist", + plugins: [ + BitburnerPlugin({ + port: 12525, + types: 'NetscriptDefinitions.d.ts' + }) + ], + bundle: true, + format: 'esm', + platform: 'browser', + logLevel: 'info' +}); + +let ctx = await createContext(); +ctx.watch(); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..0701798 Binary files /dev/null and b/package-lock.json differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..da34bc8 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "bb-external-editor", + "version": "1.0.0", + "description": "template for external editors for the game bitburner", + "main": "index.js", + "scripts": { + "start": "node ./build.mjs" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/NilsRamstoeck/bb-external-editor.git" + }, + "author": "Nils Ramstöck", + "license": "MIT", + "bugs": { + "url": "https://github.com/NilsRamstoeck/bb-external-editor/issues" + }, + "homepage": "https://github.com/NilsRamstoeck/bb-external-editor#readme", + "dependencies": { + "@types/react": "^18.2.25", + "@types/react-dom": "^18.2.10", + "esbuild": "^0.19.4", + "esbuild-bitburner-plugin": "^1.0.1", + "glob": "^10.3.10" + } +} diff --git a/src/no-ports/auto-upgrade.js b/servers/home/no-ports/auto-upgrade.js similarity index 100% rename from src/no-ports/auto-upgrade.js rename to servers/home/no-ports/auto-upgrade.js diff --git a/src/no-ports/hack-all.js b/servers/home/no-ports/hack-all.js similarity index 100% rename from src/no-ports/hack-all.js rename to servers/home/no-ports/hack-all.js diff --git a/src/no-ports/hack-args.js b/servers/home/no-ports/hack-args.js similarity index 100% rename from src/no-ports/hack-args.js rename to servers/home/no-ports/hack-args.js diff --git a/src/no-ports/hack.js b/servers/home/no-ports/hack.js similarity index 100% rename from src/no-ports/hack.js rename to servers/home/no-ports/hack.js diff --git a/src/no-ports/recursive-copy.js b/servers/home/no-ports/recursive-copy.js similarity index 100% rename from src/no-ports/recursive-copy.js rename to servers/home/no-ports/recursive-copy.js diff --git a/src/no-ports/recursive-kill.js b/servers/home/no-ports/recursive-kill.js similarity index 100% rename from src/no-ports/recursive-kill.js rename to servers/home/no-ports/recursive-kill.js diff --git a/src/no-ports/recursive-run.js b/servers/home/no-ports/recursive-run.js similarity index 100% rename from src/no-ports/recursive-run.js rename to servers/home/no-ports/recursive-run.js diff --git a/src/no-ports/root.js b/servers/home/no-ports/root.js similarity index 100% rename from src/no-ports/root.js rename to servers/home/no-ports/root.js diff --git a/src/no-ports/run.js b/servers/home/no-ports/run.js similarity index 100% rename from src/no-ports/run.js rename to servers/home/no-ports/run.js diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..9eef447 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "esnext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "node", + "esModuleInterop": true, + "lib": [ + "esnext", + "dom", + "dom.iterable" + ], + "baseUrl": "./", + "jsx": "react", + "paths": { + "@/*": [ + "src/*" + ], + "NetscriptDefinitions" : ["NetscriptDefinitions.d.ts"] + } + }, + "include": [ + "servers/**/*.ts*" + ] +}