Skip to content

Setting up a dev environment

Scott Macmillan edited this page Jul 4, 2024 · 7 revisions

Dev Environment Setup

This details setting up a dev environment on a Mac; if you're setting up on another system and find incompatibilities, we will update with alternate procedures.

Goal

The goal with this setup is to have our development target for foundry running on the local system with Node, a separate foundry data directory, and the sinless-foundry-system repo present. We'll symlink the sinless-foundry-system repo into our data directory. This setup leaves our structure only lightly coupled and leaves the flexibility to install and use different versions of foundry and Node as needed.

Assumptions

  • Foundry version 12.328
  • Node v20.12.1
  • fnm as your node manager, installed via brew
  • You own a Foundry license and have a foundryvtt.com login

Directory Structure

This is the overall directory structure we will be using. Creation of it is laid out step-by-step below, but here's a reference so you can see where we're headed:

foundry
├── 12.328  # can be multiple directories with foundry versions at this level, if needed
├── server_data
│   └── v11 # can be multiple directories with foundry data at this level, if needed
└── start_current.sh
sinless-foundry-system # cloned from remote
├── CHANGELOG.md
├── LICENSE.txt
├── README.md
└── (rest of the repo contents)

Setup Steps

  1. Clone this repo into your root project directory with git clone [email protected]:CommanderTso/sinless-foundry-system.git

  2. Create foundry directory structure

    mkdir -p foundry/12.328
    mkdir -p server_data/v11
    
  3. Install a Node manager if you need one. fnm is a great candidate (make sure you do the step to add it to your shell's rc file and source that).

  4. Install Node with fnm install v20.12.1

  5. Install Foundry by getting a timed download link for the NodeJS Foundry package. You can get this link from the Download Software page at https://foundryvtt.com/. Install with:

    cd foundry
    wget -O FoundryVTT-12.328.zip "PASTED-URL-FROM-FOUNDRY-WEBSITE-HERE"
    unzip FoundryVTT-12.328.zip -d 12.328
    
  6. Create a bash script in foundry called start_current.sh (or whatever you like) to start up your Foundry server locally. Don't forget to chmod +x if needed to make it executable. Script contents:

    #! /bin/bash
    
    /opt/homebrew/bin/fnm use v20.12.1
    node <your_root_project_directory>/foundry/12.328/resources/app/main.js --dataPath=<your_root_project_directory>/projects/foundry/server_data/v11/data
    
  7. Start up Foundry with your bash script so it will initialize the data directories, then shut it down. On a Mac, you may need to allow the process in the Security settings; you'll get a popup if you need to do that.

  8. Symlink in the Sinless system module directory:

    cd <your_root_project_directory>/foundry/server_data/v11/data/Data/systems`
    ln -s <your_root_project_directory>/sinless-foundry-system
    
  9. You should be all set! Running start_current.sh should bring up Foundry on localhost:30000, and the Sinless system module should be present in the Systems tab.

  10. Optional - in VS code with this setup, any Foundry level objects will get linter errors as not being defined. Following ChaosOS' advice in the Foundry discord, you can symlink the foundry code directory (foundry/12.328) into the system module's module directory (sinless-foundry-system/module). VS Code will then take advantage of the symlink to utilize the checked-in jsconfig.json to look at the Foundry code for IntelliSense stuff.