forked from herveDarritchon/FoundryVTT-SWES
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
83 lines (72 loc) · 2.28 KB
/
build.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import path from 'path';
import fs from 'fs';
import { Command } from 'commander';
import {compilePack, extractPack} from '@foundryvtt/foundryvtt-cli';
/* -------------------------------------------- */
/* Build Configuration */
/* -------------------------------------------- */
const CONFIG = {
dataPath: "packs",
sourcePath: "_source",
databases: [
"adversary-talents",
"ancestry",
"archetype",
"armor",
"background",
"playtest",
"pregens",
"rules",
"summons",
"talent",
"taxonomy",
"weapon"
],
yaml: true
};
/* -------------------------------------------- */
/* Task Handlers */
/* -------------------------------------------- */
/**
* Extract LevelDB databases to YAML files
*/
export async function extract() {
for ( const db of CONFIG.databases ) {
const dbPath = path.join(CONFIG.dataPath, db);
const sourcePath = path.join(CONFIG.sourcePath, db);
await extractPack(dbPath, sourcePath, {yaml: CONFIG.yaml, clean: true} );
console.log(`Extracted database: ${db}`);
}
console.log(`Successfully extracted ${CONFIG.databases.length} databases.`);
}
/**
* Compile YAML files to LevelDB databases
*/
export async function compile() {
for ( const db of CONFIG.databases ) {
const dbPath = path.join(CONFIG.dataPath, db);
const sourcePath = path.join(CONFIG.sourcePath, db);
await compilePack(sourcePath, dbPath, {yaml: CONFIG.yaml} );
console.log(`Compiled database: ${db}`);
}
console.log(`Successfully compiled ${CONFIG.databases.length} databases.`);
}
/* -------------------------------------------- */
/* Command Definition */
/* -------------------------------------------- */
const startup = new Command();
startup
.name('foundrybuild')
.description('Module development and packaging tools')
/* LevelDB format compiling from extracted plain-text files */
startup
.command('compile')
.description('Constructs binary databases from plain-text source files.')
.action(compile);
/* Plain-text format extraction from LevelDB directory */
startup
.command('extract')
.description('Unpacks binary databases into plain-text source files.')
.action(extract);
/* Start program and parse commands */
startup.parseAsync();