mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Add setup script for development (#981)
This commit is contained in:
parent
505ee6d3cf
commit
e692f3814d
6 changed files with 82 additions and 16 deletions
2
.env.example
Normal file
2
.env.example
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
FOUNDRY_MAIN_PATH=/path/to/foundry/resources/app/main.js
|
||||
FOUNDRY_DATA_PATH=/path/to/foundry/data
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
|||
.vscode
|
||||
.env
|
||||
node_modules
|
||||
/packs
|
||||
Build
|
||||
|
|
|
|||
43
README.md
43
README.md
|
|
@ -24,23 +24,40 @@ You can find the documentation here: https://github.com/Foundryborne/daggerheart
|
|||
|
||||
## Development Setup
|
||||
|
||||
- Open a terminal in the directory with the repo `cd <path>/<to>/<repo>`
|
||||
- NOTE: The repo should be placed in the system files are or somewhere else and a link (if on linux) is placed in the system directory
|
||||
- NOTE: Linux link can be made using `ln -snf <path to development folder> daggerheart` inside the system folder
|
||||
- Install npm `npm install`
|
||||
- Update package.json to match your profile
|
||||
|
||||
```
|
||||
"start": "concurrently \"rollup -c --watch\" \"node C:/FoundryDev/resources/app/main.js --dataPath=C:/FoundryDevFiles --noupnp\" \"gulp\"",
|
||||
"start-test": "node C:/FoundryDev/resources/app/main.js --dataPath=C:/FoundryDevFiles && rollup -c --watch && gulp",
|
||||
1. **Navigate to the repo directory:**
|
||||
|
||||
```bash
|
||||
cd <path>/<to>/<repo>
|
||||
```
|
||||
|
||||
- Replace `C:/FoundryDev/resources/app/main.js` with `<your>/<path>/<to>/<foundry>/<main.js>`
|
||||
- The main is likely in `<Foundry Install Location>/resouces/app/main.js`
|
||||
- Replace `--dataPath=C:/FoundryDevFiles` with `<your>/<path>/<to>/<foundry>/<data>`
|
||||
2. **Install dependencies:**
|
||||
|
||||
Now you should be able to build the app using `npm start`
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
3. **Configure your Foundry paths:**
|
||||
|
||||
```bash
|
||||
npm run setup:dev -- --foundry-path="/path/to/foundry/main.js" --data-path="/path/to/data"
|
||||
```
|
||||
|
||||
4. **Start developing:**
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
### Available Scripts
|
||||
|
||||
- `npm start` - Start development with file watching and Foundry launching
|
||||
- `npm run build` - One-time build
|
||||
- `npm run setup:dev -- --foundry-path="<path>" --data-path="<path>"` - Configure development environment
|
||||
|
||||
### Notes
|
||||
|
||||
- The repo should be placed in your Foundry `Data/systems/` directory or symlinked there
|
||||
- Linux symlink can be made using `ln -snf <path to development folder> daggerheart` inside the systems folder
|
||||
- Your `.env` file is ignored by git, so each developer can have their own configuration
|
||||
[Foundry VTT Website][1]
|
||||
|
||||
[1]: https://foundryvtt.com/
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
"rollup": "^4.40.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "concurrently \"rollup -c --watch\" \"node ../../../../FoundryDev/main.js --dataPath=../../../ --noupnp\" \"gulp\"",
|
||||
"start": "node ./tools/run-start.mjs",
|
||||
"start-test": "node ./resources/app/main.js --dataPath=./ && rollup -c --watch && gulp",
|
||||
"build": "npm run rollup && npm run gulp",
|
||||
"rollup": "rollup -c",
|
||||
|
|
@ -16,7 +16,8 @@
|
|||
"pushLDBtoYML": "node ./tools/pushLDBtoYML.mjs",
|
||||
"pullYMLtoLDB": "node ./tools/pullYMLtoLDB.mjs",
|
||||
"pullYMLtoLDBBuild": "node ./tools/pullYMLtoLDBBuild.mjs",
|
||||
"createSymlink": "node ./tools/create-symlink.mjs"
|
||||
"createSymlink": "node ./tools/create-symlink.mjs",
|
||||
"setup:dev": "node ./tools/dev-setup.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@foundryvtt/foundryvtt-cli": "^1.0.2",
|
||||
|
|
|
|||
18
tools/dev-setup.mjs
Normal file
18
tools/dev-setup.mjs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env node
|
||||
import fs from 'fs';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const foundryPath = args.find(arg => arg.startsWith('--foundry-path='))?.split('=')[1];
|
||||
const dataPath = args.find(arg => arg.startsWith('--data-path='))?.split('=')[1];
|
||||
|
||||
if (!foundryPath || !dataPath) {
|
||||
console.log('Usage: npm run setup:dev -- --foundry-path="/path/to/foundry/main.js" --data-path="/path/to/data"');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const envContent = `FOUNDRY_MAIN_PATH=${foundryPath}
|
||||
FOUNDRY_DATA_PATH=${dataPath}
|
||||
`;
|
||||
|
||||
fs.writeFileSync('.env', envContent);
|
||||
console.log(`✅ Development environment configured: ${foundryPath}, ${dataPath}`);
|
||||
27
tools/run-start.mjs
Normal file
27
tools/run-start.mjs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env node
|
||||
import { spawn } from 'child_process';
|
||||
import fs from 'fs';
|
||||
|
||||
// Load .env file if it exists
|
||||
if (fs.existsSync('.env')) {
|
||||
const envFile = fs.readFileSync('.env', 'utf8');
|
||||
envFile.split('\n').forEach(line => {
|
||||
const [key, value] = line.split('=');
|
||||
if (key && value) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Set defaults if not in environment
|
||||
const foundryPath = process.env.FOUNDRY_MAIN_PATH || '../../../../FoundryDev/main.js';
|
||||
const dataPath = process.env.FOUNDRY_DATA_PATH || '../../../';
|
||||
|
||||
// Run the original command with proper environment
|
||||
const args = ['rollup -c --watch', `node "${foundryPath}" --dataPath="${dataPath}" --noupnp`, 'gulp'];
|
||||
|
||||
spawn('npx', ['concurrently', ...args.map(arg => `"${arg}"`)], {
|
||||
stdio: 'inherit',
|
||||
cwd: process.cwd(),
|
||||
shell: true
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue