Skip to content

API Overview

The gemshell object is available in your plugin hooks during build time.

Available APIs

APIDescription
gemshell.log()Logging to GemShell build console
gemshell.storagePersistent key-value storage
gemshell.fsFile system operations
gemshell.httpHTTP requests
gemshell.globFile pattern matching
gemshell.transformAsset transformation
gemshell.buildBuild metadata
gemshell.nativeCrypto functions (AES-256)

Example Usage

javascript
module.exports = {
  name: 'Example Plugin',
  version: '1.0.0',
  
  async onPreBuild(context, settings) {
    // Logging
    gemshell.log('Build starting...');
    
    // Storage
    const count = gemshell.storage.get('buildCount', 0);
    gemshell.storage.set('buildCount', count + 1);
    
    // File system
    const pkg = gemshell.fs.readJson('package.json');
    gemshell.log(`Building ${pkg.name}`);
    
    // HTTP
    await gemshell.http.post('https://api.example.com/builds', {
      game: context.config.title,
      time: new Date().toISOString()
    });
    
    // Glob
    const images = gemshell.glob('**/*.png');
    gemshell.log(`Found ${images.length} images`);
    
    // Build info
    const info = gemshell.build.getInfo();
    gemshell.log(`Platform: ${info.platform}`);
    
    // Native crypto
    const encrypted = gemshell.native.encrypt('my-key', 'secret data');
    gemshell.log(`Encrypted: ${encrypted}`);
  }
};

API Availability

APIonPreBuildonModifyAssetsonPostBuildonBuildError
logYesYesYesYes
storageYesYesYesYes
fsYesYesYesYes
httpYesYesYesYes
globYesYesYesYes
transformNoYesNoNo
buildYesYesYesYes
nativeYesYesYesYes

Next Steps