Created by Chandler 'Deafwave' Ferry to ease the programming strain of making Botmaker scripts.
- https://ko-fi.com/deafwave
- ETH/ERC-20:
0x6dEb51c4f253781d9354af86C3c0205eFf75Bf52
- BNB/BEP-20:
0x40D84bA476FDEc7485F33eB3b82286366d0022aa
- TRX/TRC-20:
TN6t6ZZSz1JQwXtFoo7sbmQAYXiw8JNeCt
- BTC:
bc1qetcfw0pj4t3harm8glx8p0jkyeayhcu60emzzc
There are several outlined improvements in Github Issues.
Take one on, submit a Pull Request!
- Create a Private Fork OR
git clone https://github.com/ChandlerFerry/osrs-botmaker-typescript
pnpm i
npm i -g nx typescript ts-patch
- Install VSCode Extensions (ESLint, TypeScript, Prettier, Prettier-ESLint, Jest, Nx Console, GitLens)
nx run-many -t=build
- View output in
dist/packages/.../index.js
nx run api:test
nx run cakestall:test
This process will become easier once #1 is solved.
- Duplicate the
cakestall
folder & rename it to<NewPackageName>
- Find and replace
cakestall
inside of the new folder with<NewPackageName>
- Update
tsconfig.base.json
compilerOptions.paths
, adding"@packages/<NewPackageName>": ["packages/<NewPackageName>/src/index.ts"]
(this section)
I'm still learning about this one as it's new to TypeScript >5.0.
For now, do not set composite: true, and ignore the error.
- Run
pnpm i
inside of theosrs-botmaker-typescript
folder - Reload VSCode window
- Open Powershell as Admin
- Run
Set-ExecutionPolicy RemoteSigned
- Restart VSCode
With proper extensions, this repository will twist your programming style to its opinions to make this easy.
Install the suggested VSCode extensions and listen to what VSCode tells you.
Start by creating .ts
files and writing the same exact JavaScript code you are familiar with.
ESLint and TypeScript will tell you when you're doing something improper. Follow the guidance, you will write better code over time.
Execute Program is the most valuable interactive course I've found (16 free lessons).
TypeScript Handbook is a valuable 'raw' resource.
Stick this at the top of your .js
files to ignore linting (TEMPORARY)
/* eslint-disable unicorn/no-abusive-eslint-disable */
/* eslint-disable */
Then start modularizing your code, split things out to utils folders, etc. Use .ts
files to do this, and fix the ESLint errors that occur as you do so.
- Open your repositories Github Actions
- Click on the latest workflow run
- If the workflow run failed, diagnose why and fix it!
- Once you have a successful workflow run, click
botmaker-scripts
in the Arifacts section
Update the packages/<PackageName>/project.json
, adding additionalEntryPoints
of every bundle that you would like to create:
"main": "packages/cakestall/src/index.ts",
"additionalEntryPoints": [
"packages/cakestall/src/quest1/quest1.ts",
"packages/cakestall/src/quest2/quest2.ts"
],
No! .d.ts
files are meant for external dependencies that do not have typings such as Runelite & Sox.
All .ts
files automatically generate declaration files.
- Update
tsconfig.base.json
:"extends": ["@tsconfig/node20/tsconfig"]
- ->
"extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node20/tsconfig"],
- Update
eslint.config.js
:...__configs.recommendedTypeChecked
- ->
...__configs.strictTypeChecked
Botmaker requires scripts to be compiled down to rhino 1.7.14, then bundled.
This presents a challenge that is easily overcome by separating scripts into bundle targets and leveraging monorepo architecture to combine bundle targets when necessary.
- Integrated Nx Monorepo uses
nx graph
to identify dependencies- Integrated paths fetched from
tsconfig.base.json
'scompilerOptions.paths
- Package dependencies based on e.g.
import {...} from "@packages/cakestall"
- Integrated paths fetched from
- Nx executes
build
with dependsOn^build
to build dependencies in reverse order - During build, Nx passes the files to the customRollup plugin which executes the Rollup Bundler
- Rollup fetches the required files, and manipulates them based on the
rollup.cjs
- During Rollup bundling, alias() is called to merge packages, and cleanup() is called to remove all comments
- On Rollup bundle output, getBabelOutputPlugin() is called with a target of
rhino: '1.7.14'
to compile the final bundle to our required target
Resources:
- Monorepo - Nx
- Modern solution to sustainable monorepos in TypeScript (still extremely time consuming though!)
- Bundler - Rollup
- Used solely because it supports Babel, preferred is esbuild
- Compiler - Babel
- Used solely because it supports Rhino 1.7.14, preferred is tsc