IMPORTANT NOTE: This repository contains scripts for processing data into DSM files for the Dasu project. Ensure you have the necessary environment variables configured before running the scripts. For support or issues, refer to the troubleshooting section or contact the project maintainers.
This repository hosts a collection of Node.js scripts designed to automate the process of downloading, processing, validating, and building Daemon Summoner Module (DSM) files from CSV data sourced from Google Spreadsheets into JSON format for the Dasu project. A DSM is essentially a zip file that uses the .dsm extension, structured to store various data types including metadata, entities, and categorized game elements in JSON format.
These scripts form a complete data pipeline, transforming raw CSV data into structured JSON files, validating their integrity, and packaging them into DSM archives for distribution. Each script serves a distinct role in this workflow, ensuring data consistency and compatibility with the Daemon Summoner system.
If you are looking to contribute or customize the data processing pipeline, this document provides detailed information on each script's purpose, usage, and configuration. For additional support, review the troubleshooting tips or reach out to the project community.
To quickly set up and run the pipeline, follow the instructions in the Running the Pipeline section. For detailed configuration, refer to Environment Variables and Prerequisites. Lastly, for item type schema, refer to Item Type Syntax.
The scripts are located in the scripts/ directory and are designed to be executed via Node.js. Below is a comprehensive breakdown of each script, its purpose, and how to use it.
- Purpose: Downloads CSV files from a specified Google Spreadsheet.
- Usage:
node scripts/download.js <spreadsheet-name> - Details: Retrieves data for various sheets (e.g., manifest, daemons, archetypes) based on environment variables for spreadsheet IDs and names. The downloaded CSV files are saved in the
input/<spreadsheet-name>/directory.
- Purpose: Converts CSV files to JSON format with data processing.
- Usage:
node scripts/convert.js <folder-name> - Details: Reads CSV files from
input/<folder-name>/, processes the data (e.g., converting values, handling dot notation), and writes the results as JSON tooutput/<folder-name>/. Excludesdaemons.csvwhich is handled separately byconvertd.js.
- Purpose: Validates JSON files in a specified output folder.
- Usage:
node scripts/validate.js <folder-name> - Details: Checks all JSON files in
output/<folder-name>/for valid JSON structure. Reports any parsing errors and stops the process if invalid files are found, ensuring data integrity before further processing.
- Purpose: Converts
daemons.csvto JSON with extensive data validation and enrichment. - Usage:
node scripts/convertd.js <folder-name> - Details: Processes
daemons.csvfrominput/<folder-name>/, builds complex daemon objects with validation against predefined lookup data, and outputs the result tooutput/<folder-name>/daemons.json.
- Purpose: Builds an archive file from the processed output data.
- Usage:
node scripts/build.js <folder-name> - Details: Reads a manifest file from
output/<folder-name>/manifest.jsonto determine the ID and version, then creates a.dsmarchive of the folder contents in thebuild/directory.
- Purpose: Copies processed data to specified destinations.
- Usage:
node scripts/copy.js - Details: Copies contents of
input/,output/, andbuild/directories to locations defined in environment variables. Supports an overwrite option for the build directory viaOVERWRITE_DSM=true.
- Purpose: Orchestrates the full data processing pipeline.
- Usage:
node scripts/start.js <spreadsheet-name>ornode scripts/start.js all - Details: Runs the entire sequence of scripts (
download.js,convert.js,validate.js,convertd.js,build.js,copy.js) for a given spreadsheet name, automating the complete workflow from data retrieval to distribution. Usingallas the argument will process all valid spreadsheets defined in the .env file.
The scripts rely on environment variables defined in a .env file for configuration. Below are the key variables used:
| Variable Name | Description |
|---|---|
SPREADNAME_OPTION1 to SPREADNAME_OPTION5 |
Define spreadsheet names for selection in download.js and start.js. |
SPREADSHEET_OPTION1 to SPREADSHEET_OPTION5 |
Define spreadsheet IDs corresponding to the names above. |
CPY_CSV_LOCATION |
Destination path for copying CSV input files. |
CPY_JSON_LOCATION |
Destination path for copying JSON output files. |
CPY_DSM_LOCATION |
Destination path for copying DSM build files. |
OVERWRITE_DSM |
Boolean flag (true/false) to enable overwriting in copy.js for the DSM build directory. |
A template for setting up your .env file is provided in .env.example. Copy this file to .env and fill in your specific values.
Before running the scripts, ensure the following are in place:
- Node.js: Installed on your system to execute the scripts.
- Dependencies: Install required Node.js packages using
npm install. Key dependencies includeaxios,fs-extra,papaparse, andzip-lib. - Environment Setup: A
.envfile with necessary variables for spreadsheet access and file destinations must be created in the root directory.
To process data for a specific spreadsheet, follow these steps:
- Ensure environment variables are set in your
.envfile. - Execute the full pipeline with
node scripts/start.js <spreadsheet-name>to automate the process from download to copy.
Alternatively, you can run individual scripts for specific steps in the process if manual control is needed. Refer to the Script Details section for individual script usage.
The scripts generate files in the following directory structure:
input/<folder-name>/: Contains downloaded CSV files from the specified spreadsheet.output/<folder-name>/: Contains processed JSON files after conversion and validation.build/: Contains the final.dsmarchive files ready for distribution.
Below is the proper JSON syntax for each item type processed by these scripts. These structures are used in the output JSON files and are validated against predefined schemas where applicable.
Defines the metadata for a module, necessary for the webapp to process the DSM file.
{
"id": string,
"name": string,
"author"?: string,
"version"?: string,
"description"?: string,
"image_url"?: string,
"website"?: string
}Represents a summonable entity.
{
"id": string,
"dsid": string,
"publishId": string,
"type": string,
"name": string,
"image": {
"src": string,
"credit"?: string,
"crop"?: {
"x": number,
"y": number
},
"zoom"?: number,
"croppedAreaPixels"?: {
"x": number,
"y": number,
"width": number,
"height": number
}
},
"level": number,
"merit": number,
"origin"?: string[],
"archetypes": {
"id"?: string,
"name"?: string,
"category"?: string,
"description"?: string,
"benefits"?: string
},
"subtypes": {
"id"?: string,
"name"?: string,
"category"?: string,
"description"?: string,
"benefits"?: string
},
"roles": Array<{
"id"?: string,
"name"?: string,
"category"?: string,
"description"?: string
}>,
"attributes": {
"pow": { "base": number, "mod": number },
"dex": { "base": number, "mod": number },
"will": { "base": number, "mod": number },
"sta": { "base": number, "mod": number }
},
"stats": {
"hp": { "mod": number, "multiplier": number },
"wp": { "mod": number, "multiplier": number },
"avoid": { "mod": number, "multiplier": number },
"def": { "mod": number, "multiplier": number },
"toHit": { "mod": number, "multiplier": number },
"toLand": { "mod": number, "multiplier": number },
"willStrain": { "mod": number, "multiplier": number }
},
"attributePoints"?: {
"pow": number,
"dex": number,
"will": number,
"sta": number
},
"aptitudes": {
"f": number, "i": number, "el": number, "w": number, "ea": number, "l": number, "d": number,
"dp": number, "dm": number, "da": number, "h": number, "tb": number, "tt": number,
"tg": number, "ta": number, "assist": number
},
"resistances": {
"p": string, "f": string, "i": string, "el": string,
"w": string, "ea": string, "l": string, "d": string
},
"weapons"?: Array<{ "id": string, "category": string }>,
"items"?: Array<{ "id": string, "category": string }>,
"abilities"?: {
"spells": Array<{ "id": string, "category": string }>,
"afflictions": Array<{ "id": string, "category": string }>,
"restoratives": Array<{ "id": string, "category": string }>,
"techniques": Array<{ "id": string, "category": string }>
},
"tactics"?: Array<{ "id": string, "category": string }>,
"statuses"?: Array<{ "id": string, "category": string }>,
"special"?: {
"abilities"?: Array<{
"id": string,
"name": string,
"category"?: string,
"description"?: string,
"enabled"?: boolean
}>,
"transformations"?: Array<{
"id": string,
"name": string,
"category"?: string,
"cost": number,
"description"?: string,
"enabled"?: boolean
}>
}
}Classifies daemons into broad categories based on their primary nature or theme.
{
"id": string,
"name": string,
"category": string,
"description"?: string,
"benefits"?: string
}Provides a more specific classification of daemons, subtype typically indicating their stage in development.
{
"id": string,
"name": string,
"category": string,
"description"?: string,
"benefits"?: string
}Specifies a daemon's primary function or strategy in combat or other interactions.
{
"id": string,
"name": string,
"category": string,
"description"?: string
}Represents objects that can be used for various effects or benefits.
{
"id": string,
"name": string,
"category": string,
"cost": number,
"quantity": number,
"description"?: string
}Equipment designed for entities to use to perform attacks.
{
"id": string,
"name": string,
"category": string,
"range": string,
"damage": { "value": number, "type": string },
"toHit": number,
"cost": number,
"tags": Array<{ "id": string, "name": string, "category": string, "cost": number, "maxRank": number, "description"?: string }>,
"description"?: string
}A slotable upgrade that can be attached to a weapon to provide additional effects or enhancements.
{
"id": string,
"name": string,
"category": string,
"cost": number,
"maxRank": number,
"description"?: string
}Magical abilities that actors can cast to produce elemental attacks.
{
"id": string,
"name": string,
"category": string,
"damage": { "value": number, "type": string },
"cost": number,
"toHit": number,
"aptitudes"?: {
"f": number, "i": number, "el": number, "w": number, "ea": number, "l": number, "d": number,
"dp": number, "dm": number, "da": number, "h": number, "tb": number, "tt": number,
"tg": number, "ta": number, "assist": number
},
"description"?: string
}Abilities that can apply status conditions to targets, either debuffs and buffs.
{
"id": string,
"name": string,
"category": string,
"cost": number,
"toHit": number,
"isInfinity": boolean,
"aptitudes"?: {
"f": number, "i": number, "el": number, "w": number, "ea": number, "l": number, "d": number,
"dp": number, "dm": number, "da": number, "h": number, "tb": number, "tt": number,
"tg": number, "ta": number, "assist": number
},
"description"?: string
}Abilities that provide healing or other beneficial effects to restore or enhance entities.
{
"id": string,
"name": string,
"category": string,
"heal": { "attribute": string, "value": number, "isFlat": boolean, "isPercent": boolean },
"cost": number,
"aptitudes"?: {
"f": number, "i": number, "el": number, "w": number, "ea": number, "l": number, "d": number,
"dp": number, "dm": number, "da": number, "h": number, "tb": number, "tt": number,
"tg": number, "ta": number, "assist": number
},
"description"?: string
}Special non-magical abilities, always physical, unless altered through other means.
{
"id": string,
"name": string,
"category": string,
"damage": { "value": number, "type": string },
"cost": number,
"toHit": number,
"aptitudes"?: {
"f": number, "i": number, "el": number, "w": number, "ea": number, "l": number, "d": number,
"dp": number, "dm": number, "da": number, "h": number, "tb": number, "tt": number,
"tg": number, "ta": number, "assist": number
},
"description"?: string
}In contrast to Abilities, can be used for Negotiation.
{
"id": string,
"name": string,
"category": string,
"govern": string,
"damage": { "value": number, "type": string },
"toLand": number,
"isInfinity": boolean,
"cost": number,
"description"?: string
}Temporary or permanent conditions affecting entities.
{
"id": string,
"name": string,
"category": string,
"description"?: string,
"isNegotiation": boolean
}Unique abilities not covered by abilities or tactics. Exclusive to daemons, and not meant to operate outside the general rules.
{
"id": string,
"name": string,
"category"?: string,
"description"?: string
}Alternate forms or higher states of being for daemons to transform into.
{
"id": string,
"name": string,
"category"?: string,
"cost": number,
"description"?: string
}Permanent effects or marks for summoners.
{
"name": string,
"category"?: string,
"description"?: string
}Actions to perform for the Arbitration encounters.
{
"id": string,
"name": string,
"category": string,
"description"?: string,
"effect"?: string
}These structures ensure consistency and compatibility with the Daemon Summoner system, providing a standardized format for all data processed by these scripts.
Common issues and their solutions are listed below. If you encounter problems not covered here, review the console output for detailed error messages.
- Permission Errors: If
copy.jsfails with permission issues, setOVERWRITE_DSM=truein your.envfile to overwrite existing files in the destination directory. - Missing Data: Ensure environment variables for spreadsheet IDs are correctly set and accessible in your
.envfile. - Validation Failures: If
validate.jsreports issues, check JSON files inoutput/for syntax errors or structural inconsistencies.
For further assistance or to report bugs, consider reaching out to the project maintainers or community for support.