2020-06-22 03:00:16 -04:00
# Development
2022-08-13 22:44:35 -04:00
> Requires [Node 14+](https://nodejs.org) and [Yarn](https://yarnpkg.com).
2020-06-22 03:00:16 -04:00
EightBittr development is managed using a few popular web technologies you'll want to be at least a little familiar with:
- [Lerna ](https://lerna.js.org ): A tool for managing JavaScript projects with multiple packages.
- [Mocha ](https://mochajs.org ): The simple, fun, flexible JavaScript testing framework.
- [TypeScript ](https://typescriptlang.org ): Like JavaScript, but with glorious type declarations.
- [Yarn ](https://yarnpkg.com ): A package manager with great performance and project linking.
2022-08-13 23:15:45 -04:00
> If you're on a MacOS M1/M2 chip, you'll likely need to install Chromium with Homebrew:
>
> ```shell
> brew install homebrew
> xattr -cr /Applications/Chromium.app
> ```
>
> ...and add the following in your `~/.zshrc` or equivalent:
>
> ```shell
> export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
> export PUPPETEER_EXECUTABLE_PATH=/opt/homebrew/bin/chromium
> ```
2020-06-22 03:00:16 -04:00
## Setup
After [forking the repo from GitHub ](https://help.github.com/articles/fork-a-repo ), you'll want to clone it, install dependencies, and prepare its packages for development:
``` cmd
git clone https://github.com/< your-name> /EightBittr
cd EightBittr
yarn
yarn lerna bootstrap
yarn run hydrate
```
2020-06-22 03:07:44 -04:00
### Local Development
In practical use, you'll generally want at least two terminals open:
- One running `yarn compile -w` from this repository root to run TypeScript in watch mode.
- One free for other commands, such as `cd` ing into packages and running `yarn test:setup` to regenerate test files.
### Root Commands
2020-06-22 03:00:16 -04:00
The following common commands from [`package.json` ](../package.json ) can be run from the repository root to work across all packages:
- `compile` : Builds [TypeScript ](https://typescriptlang.org ) source files in `src/` into JavaScript files in `lib/` .
- `format` : Runs [Prettier ](https://prettier.io ) to flag incorrectly formatted source files.
- `format:write` : Fixes those source files for you.
- `lint` : Runs [ESLint ](https://eslint.org ) on source files to find linting complaints.
- `test` : Rebuilds all packages' test infrastructures and runs their tests.
2020-06-26 15:24:08 -04:00
### Code Directories
2020-06-26 19:29:27 -04:00
Once built, there will be up to three directories in this package containing code, in order of build process:
2020-06-26 15:24:08 -04:00
1. `src/` : The "source of truth" containing TypeScript source files.
2. `lib/` : JavaScript source files, declaration files, and source maps generated by TypeScript from `src/` .
2022-08-15 06:50:45 -04:00
3. `dist/` : Bundled, minified versions of JavaScript files generated by [Webpack ](https://webpack.js.org ) from `lib/` -- if `package.json` contains a `"dist": true` under `"shenanigans"` .
2020-06-22 03:00:16 -04:00
### `shenanigans-manager`
You may notice some commands use the `shenanigans-manager` package, a utility package included in this monorepo.
It automates useful commands common to packages here, such as scaffolding package scripts and shared documentation.
See its docs in [packages/shenanigans-manager ](../packages/shenanigans-manager/README.md ).
2020-06-22 03:07:44 -04:00
## Package Linking
2020-06-22 03:00:16 -04:00
If you're developing a game that uses EightBittr and would like to use your local EightBittr monorepo for its npm packages, you can do so in two steps:
1. From this repository, make all packages globally available using [Yarn link ](https://classic.yarnpkg.com/en/docs/cli/link ) to set up [symlinks ](https://en.wikipedia.org/wiki/Symbolic_link ):
```cmd
yarn run link
` ``
2. From the game's repository, point its ` node_modules/` to those global symlinks using ` shenanigans-manager`'s ` link-packages` command:
` ``cmd
yarn shenanigans-manager link-packages
` ``