bitburner-connect
v0.2.2
Published
CLI to build and sync files to a Bitburner client.
Downloads
20
Readme
bitburner-connect
Yet another tool for syncing files to Bitburner.
Setup
npm install -D bitburner-connect- Run
npx bitburner-connectto sync .js, .ts, .jsx and .tsx files from your current directory to your home server. - Import NetScript types from
bitburner-connect/typesor add"types": ["bitburner-connect/types/global"]to your tsconfig.json to have the types available globally like in the in-game editor.
To customise further, create a bitburner-connect.config.json file in your directory. Here's an example configuration:
{
"$schema": "./node_modules/bitburner-connect/schema.json",
// Directory to watch for changes.
"watchDir": "./src",
// Directory to sync to within Bitburner.
"targetDir": "/scripts",
// Servers to sync to. Can contain glob patterns (e.g. "server-*" with match "server-abc123", etc).
"servers": ["home"],
// Files (or patterns) to delete from Bitburner servers when syncing. e.g. the below will delete existing scripts.
"deleteFiles": ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx"],
// Builder customisation. See builder documentation below.
// This example will run `npm run build` whenever a file changes, and sync the contents of the `dist` directory to Bitburner.
"builder": {
"name": "run",
"command": "npm run build",
"outDir": "./dist"
}
}Builders
Builders are used to perform custom build steps before syncing files to Bitburner. For example, you may want to compile TypeScript files to JavaScript, perform bundling with a tool like Rolldown, or sync a different directory which is being compiled by a separate watcher process.
Dir
The dir builder simply syncs all files from a given directory to the target directory in Bitburner. This is the default builder if no builder configuration is provided.
| Option | Description | Type |
| --------- | ---------------------------------------------------------------------------------------------- | ---------- |
| name | The name of the builder. Must be dir for this builder. | "dir" |
| syncDir | The directory to sync files from. Defaults to watch directory. | string |
| files | Glob patterns for files that should be synced. Defaults to all .js, .jsx, .ts, and .tsx files. | string[] |
Run
The run builder runs a custom command on file change before syncing files to Bitburner.
| Option | Description | Type |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| name | The name of the builder. Must be run for this builder. | "run" |
| command | Command to run to process files. | string |
| cwd | Working directory to run the command in. Defaults to current directory. | string |
| outDir | Directory containing processed files. Relative to current working directory. | string |
| files | Glob patterns for files that should be synced from the output directory once the command has been executed. Defaults to all .js, .jsx, .ts, and .tsx files. | string[] |
| timeout | Maximum time in milliseconds to wait for the process to complete. Defaults to 5000 milliseconds. | number |
Rolldown
The rolldown builder uses Rolldown to bundle files before syncing to Bitburner. This is a convenient option for users who want to import npm packages in their Bitburner scripts.
| Option | Description | Type |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| name | The name of the builder. Must be rolldown for this builder. | "rolldown" |
| input | Input files to pass to Rolldown, relative to current working directory. May include glob patterns, which will be expanded before being passed. | string \| string[] |
| preserveModules | By default, Rolldown will output a single bundled file for each entry point containing all dependencies. Setting preserveModules to true will cause Rolldown to output separate files for each module, preserving the directory structure of the input files. | boolean |
| preserveModulesRoot | When preserveModules is true, this option specifies a directory within the input files to treat as the root when determining the output directory structure. For example, if your input files are all under src/ and you set preserveModulesRoot to src/, then the output files will have the same directory structure but without the src/ prefix. If not specified, the common prefix of all input files will be used. Relative to current working directory. | string |
| outDir | Output directory for the bundled files. If not specified, Rolldown will not write files to disk. Relative to current working directory. | string |
