Scripts and Automation
Relevant source files
The following files were used as context for generating this wiki page:The Skid-Inc project utilizes scripts and automation in two primary domains: in-game mechanics and the development/deployment workflow. In-game scripts are core to the player's progression, allowing them to earn money and experience through manual execution or automation. These are managed by the skidinc.script and skidinc.autoscript objects.
Project automation focuses on streamlining the build, deployment, and update processes for the Electron application. A suite of Node.js scripts located in the scripts/ directory, orchestrated via npm commands defined in package.json, handles multi-platform builds, artifact packaging, and auto-update configuration. This ensures a consistent and reliable release pipeline.
In-Game Scripts & Automation
This system governs how players earn resources by executing scripts. It is divided into manually executed scripts and automated scripts (autoscripts).
Manual Scripts
Manual scripts are the primary method for players to earn money and experience. The skidinc.script object manages their state, execution, and rewards.
Sources: app/js/script.js
Script Data Structure
All available scripts are defined in the skidinc.script.scripts array. Each script is an object with a consistent structure.
| Property | Type | Description |
|---|---|---|
id | string | The unique identifier and command name for the script (e.g., hare.ctx). |
cost | number | The amount of money required to unlock/buy the script. |
money | number | The base money reward upon successful execution. |
exp | number | The base experience reward upon successful execution. |
time | number | The base time in seconds required for execution. |
i | number | The zero-based index of the script in the array. |
Sources: app/js/script.js:11-73
Execution Flow
A player executes a script via the in-game console. The skidinc.script.execute function parses the command and manages the script's lifecycle.
The diagram below illustrates the process of executing a manual script.
Sources: app/js/script.js:132-171, 200-222
Auto-Scripts
Autoscripts provide passive income by automatically executing a corresponding script repeatedly. The skidinc.autoscript object manages their state and purchase logic.
Sources: app/js/autoscript.js
Logic and Relationship
An autoscript can only be purchased for a manual script that the player has already unlocked. Once purchased, it runs in a continuous loop, granting rewards each time it completes its cycle.
The diagram below shows the relationship between manual and auto-scripts.
Purchasing Auto-Scripts
A player uses the buy command to purchase an autoscript. The skidinc.autoscript.buy function validates the purchase against several conditions:
- The script name must be valid.
- The player must not already own the autoscript.
- The player must own the corresponding manual script.
- The player must have enough money.
Sources: app/js/autoscript.js:18-43
Project Automation Scripts
The project contains a set of Node.js scripts to automate building, deploying, and configuring the application. These are defined in package.json and located in the scripts/ directory.
Build System
The scripts/build-all.js file provides an automated, multi-platform build system managed by the BuildManager class.
Sources: scripts/build-all.js
Key Features
- Multi-platform Builds: Supports Windows, macOS, and Linux.
- Environment Validation: Checks for Node.js,
electron-builder, and required source files before starting. - Retry Logic: Automatically retries a failed build up to
maxRetriestimes. - Build Reports: Generates a
build-report.jsonwith metrics, results, and a list of generated artifacts.
Build Process Flow
The buildAll method orchestrates the entire process.
Sources: scripts/build-all.js:141-171
Deployment System
The scripts/deploy.js script, via its DeployManager class, prepares the built artifacts for distribution.
Sources: scripts/deploy.js
Key Features
- Artifact Collection: Gathers distributable files from the build output directory (
dist). - Checksum Generation: Calculates SHA256 checksums for all artifacts to ensure integrity.
- Manifest Creation: Generates a
manifest.jsonfile with metadata for the update system. - Release Documentation: Automatically creates
RELEASE_NOTES.md. - Archiving: Packages all release files into a single
.ziparchive.
Deployment Sequence
The deploy method executes a series of steps to package the release.
Sources: scripts/deploy.js:238-266
Auto-Update Setup
The scripts/auto-update.js script is a one-time setup utility that configures the project for automatic updates using electron-updater.
Sources: scripts/auto-update.js
Setup Process
This script performs the following actions:
- Installs
electron-updaterandelectron-logdependencies if they are not present. - Generates the
src/auto-updater.jsmodule, which contains the main process logic for handling update checks, downloads, and installation. - Modifies
src/main.jsto import and initialize theAutoUpdaterclass. - Updates
package.jsonwith the necessarypublishconfiguration for GitHub releases. - Creates a renderer-side UI module (
src/renderer/update-manager.js) for update notifications.
Sources: scripts/auto-update.js:38-52, 289-305
Background Auto-Save
The application includes an automated save system managed by AutoSaveManager to prevent data loss.
Sources: src/auto-save-manager.js
Features
- Periodic Saving: Saves the game state at a regular interval (default 30 seconds).
- Change-Based Saving: Triggers a "quick save" after a short delay (default 5 seconds) following a detected change in the game state.
- Backups: Creates timestamped backups and implements a retention policy (default 30 days).
- Error Handling: Includes retry logic with exponential backoff for failed save attempts.
- Validation: Validates and can repair game state data before saving.
Sources: src/auto-save-manager.js:16-29, 107-110, 131-134
NPM Scripts
The package.json file defines a set of npm scripts that serve as the main entry points for all automation tasks.
| Script | Description | Underlying Command |
|---|---|---|
electron | Starts the application in production mode. | electron . |
electron-dev | Starts the application in development mode with DevTools. | electron . --dev |
build:automated | Runs the comprehensive, multi-platform build script. | node build/automated-build.js (Note: file path in package.json seems to be build/automated-build.js but the provided file is scripts/build-all.js) |
build:win / mac / linux | Builds the application for a specific platform. | electron-builder --[platform] |
deploy | Runs the deployment script to package artifacts. | node build/deploy.js (Note: file path in package.json seems to be build/deploy.js but the provided file is scripts/deploy.js) |
release | A convenience script that runs the full build and deploy process. | npm run build:release && npm run deploy:github |
Sources: package.json:14-43
Conclusion
The automation strategy in Skid-Inc is robust and covers both the core gameplay loop and the software development lifecycle. In-game, the script and autoscript systems create a clear progression path for the player, moving from manual actions to passive resource generation. On the project level, the build and deployment scripts provide a powerful, configurable, and resilient pipeline for creating and distributing releases, complete with error handling, reporting, and update management. This dual focus on automation is essential for both the player experience and the maintainability of the project.