| Crates.io | crank |
| lib.rs | crank |
| version | 0.1.0 |
| created_at | 2025-11-18 14:45:03.948962+00 |
| updated_at | 2025-11-18 14:45:03.948962+00 |
| description | A command-line build tool for Playdate game development |
| homepage | |
| repository | https://github.com/subpop/crank |
| max_upload_size | |
| id | 1938531 |
| size | 175 |
A command-line build tool for Playdate game development, inspired by Cargo. Simplify your Playdate development workflow with project scaffolding, build automation, and development tools.
git clone https://github.com/subpop/crank.git
cd crank
cargo install --path .
cargo install crank
PLAYDATE_SDK_PATH environment variable (optional, crank will try to detect it)crank new my-awesome-game
cd my-awesome-game
This creates a new project with the following structure:
my-awesome-game/
├── .gitignore
├── .luarc.json
├── Playdate.toml
├── source/
│ └── main.lua
├── assets/
│ ├── images/
│ ├── sounds/
│ └── fonts/
├── playdate-luacats/ (Lua LSP type definitions)
└── tests/
├── luaunit.lua (Testing framework)
└── test_basic.lua (Example tests)
crank build
This compiles your game using the Playdate SDK's pdc compiler and outputs to build/my-awesome-game.pdx.
crank run
This builds your game and launches it in the Playdate Simulator.
crank watch
This watches your source files and assets, automatically rebuilding when changes are detected.
crank test
Runs all test files matching test_*.lua or *_test.lua in the tests/ directory using LuaUnit, a popular xUnit-style testing framework.
Features:
--filterRequirements: A system Lua interpreter (lua5.4, lua, or luajit) must be installed.
Projects are configured via Playdate.toml:
[package]
name = "my-awesome-game"
version = "1.0.0"
author = "Your Name"
description = "An awesome Playdate game"
bundle_id = "com.example.myawesomegame"
[build]
language = "lua"
source_dir = "src"
output_dir = "build"
assets_dir = "assets"
[playdate]
content_warning = ""
content_warning_2 = ""
image_path = "icon"
[dev]
hot_reload = true
auto_build = true
crank new <name> [path]Create a new Playdate project.
Arguments:
<name>: Name of the project (required)[path]: Directory where the project will be created (optional, defaults to current directory)Options:
--template <template>: Choose a project template (default: lua-basic)Examples:
# Create project in current directory
crank new my-game
# Create project in a specific location
crank new my-game ~/projects
# Create project with custom template
crank new my-game --template lua-basic
crank buildBuild the current project using the Playdate SDK's pdc compiler.
The build process:
.pdx bundleOptions:
--release, -r: Build in release mode (currently same as debug, reserved for future optimizations)--verbose, -v: Show detailed build output including SDK paths and compilation detailsExamples:
# Basic build
crank build
# Verbose output (helpful for debugging)
crank build --verbose
# Release build
crank build --release
# Combined options
crank build -rv
Output:
Building Playdate project (debug mode)...
✓ Built successfully in 1.23s
Output: build/my-game.pdx
Size: 245 KB
Next steps:
crank run
crank runBuild and run the project in the Playdate Simulator in a single command.
The run process:
crank build)Options:
--release, -r: Build and run in release modeExamples:
# Basic run (debug mode)
crank run
# Release mode
crank run --release
Output:
════════════════════════════════════════════════════════
▶ Build and Run
════════════════════════════════════════════════════════
→ Building project...
Building Playdate project (debug mode)...
✓ Built successfully in 1.23s
Output: build/my-game.pdx
Size: 245 KB
────────────────────────────────────────────────────────
→ Launching Playdate Simulator...
Game: my-game
Bundle: build/my-game.pdx
Simulator: ~/Developer/PlaydateSDK/bin/Playdate Simulator.app
✓ Simulator launched successfully!
The game is now running in the Playdate Simulator.
crank watchWatch for changes and rebuild automatically.
Options:
--no-run: Don't launch simulator, just rebuildExample:
crank watch
crank testRun tests in the tests/ directory.
Options:
--filter <pattern>: Run only tests matching patternExample:
crank test --filter player
crank cleanRemove build artifacts.
Example:
crank clean
A typical crank project:
my-game/
├── Playdate.toml # Project configuration
├── source/ # Source code
│ ├── main.lua # Entry point
│ ├── pdxinfo # Game metadata
│ ├── .luarc.json # Lua LSP configuration
│ ├── player.lua # Game modules
│ └── enemies.lua
├── assets/ # Game assets
│ ├── images/ # Images and sprites
│ │ ├── player.png
│ │ └── background.png
│ ├── sounds/ # Audio files
│ │ └── jump.wav
│ └── fonts/ # Custom fonts
│ └── game-font.fnt
├── playdate-luacats/ # Lua type definitions for IDE
├── tests/ # Test files
│ ├── luaunit.lua # LuaUnit testing framework
│ ├── test_basic.lua
│ ├── test_player.lua
│ └── test_enemies.lua
└── build/ # Build output (generated)
└── my-game.pdx/ # Playdate executable
crank automatically detects your Playdate SDK installation in the following order:
PLAYDATE_SDK_PATH environment variablesimulator_path in Playdate.toml~/Developer/PlaydateSDK%USERPROFILE%\Documents\PlaydateSDK~/PlaydateSDKNew projects include IDE support out of the box:
.luarc.json - Configuration for Lua Language Server
playdate-luacats/ - Type definitions from notpeter/playdate-luacats
Recommended VS Code Extensions
New projects include LuaUnit testing framework for writing and running unit tests.
Create test files in the tests/ directory following naming conventions:
test_*.lua (e.g., test_player.lua)*_test.lua (e.g., player_test.lua)Example test file:
local luaunit = require('luaunit')
function testBasicAssertion()
luaunit.assertEquals(1 + 1, 2)
end
function testStringOperations()
local str = "Hello, Playdate!"
luaunit.assertIsString(str)
luaunit.assertTrue(#str > 0)
end
-- Run all tests
os.exit(luaunit.LuaUnit.run())
# Run all tests
crank test
# Run tests matching a pattern
crank test --filter player
Requirements: You need a system Lua interpreter installed (lua5.4, lua, or luajit).
Installation:
brew install luaapt-get install lua5.4LuaUnit provides a comprehensive set of assertions:
-- Equality
luaunit.assertEquals(actual, expected)
luaunit.assertNotEquals(actual, expected)
-- Boolean
luaunit.assertTrue(value)
luaunit.assertFalse(value)
-- Nil checks
luaunit.assertNil(value)
luaunit.assertNotNil(value)
-- Type checks
luaunit.assertIsString(value)
luaunit.assertIsNumber(value)
luaunit.assertIsTable(value)
-- Numeric comparisons
luaunit.assertAlmostEquals(actual, expected, margin)
See TEST_COMMAND_IMPLEMENTATION.md for comprehensive testing documentation.
git clone https://github.com/subpop/crank.git
cd crank
cargo build --release
The binary will be at target/release/crank.
cargo test
Contributions are welcome! Please see CONTRIBUTING.md for details.
MIT License - see LICENSE for details.
Made with ❤️ for the Playdate community