Appearance
API Overview
The gemshell object is available in your plugin hooks during build time.
Available APIs
| API | Description |
|---|---|
gemshell.log() | Logging to GemShell build console |
gemshell.storage | Persistent key-value storage |
gemshell.fs | File system operations |
gemshell.http | HTTP requests |
gemshell.glob | File pattern matching |
gemshell.transform | Asset transformation |
gemshell.build | Build metadata |
gemshell.native | Crypto 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
| API | onPreBuild | onModifyAssets | onPostBuild | onBuildError |
|---|---|---|---|---|
log | Yes | Yes | Yes | Yes |
storage | Yes | Yes | Yes | Yes |
fs | Yes | Yes | Yes | Yes |
http | Yes | Yes | Yes | Yes |
glob | Yes | Yes | Yes | Yes |
transform | No | Yes | No | No |
build | Yes | Yes | Yes | Yes |
native | Yes | Yes | Yes | Yes |
