首页/ AI 技能 / @skilllib/skill-2117939930272417220
Skill站外收录 @skilllib/skill-2117939930272417220

gamma-local-dev-loop

为 Gamma 应用构建本地高效开发环境,支持代码修改即时生效、离线模拟 API 响应、按环境切换配置,显著缩短开发反馈周期,适用于快速迭代和调试 Presentation 相关功能。

0.0 (0) 18 次安装 原作者 编程导航
收录于 2026-01-22
开发运维 AI 技能

Skills.MD

# Gamma Local Dev Loop ## Overview Configure an efficient local development workflow with hot reload and mock responses for Gamma presentation development. ## Prerequisites - Completed `gamma-hello-world` setup - Node.js 18+ with nodemon or tsx - TypeScript project (recommended) ## Instructions ### Step 1: Install Dev Dependencies ```bash npm install -D nodemon tsx dotenv @types/node ``` ### Step 2: Configure Development Script Add to package.json: ```json { "scripts": { "dev": "tsx watch src/index.ts", "dev:mock": "GAMMA_MOCK=true tsx watch src/index.ts" } } ``` ### Step 3: Create Mock Client ```typescript // src/gamma-client.ts import { GammaClient } from '@gamma/sdk'; const isMock = process.env.GAMMA_MOCK === 'true'; export const gamma = isMock ? createMockClient() : new GammaClient({ apiKey: process.env.GAMMA_API_KEY }); function createMockClient() { return { presentations: { create: async (opts) => ({ id: 'mock-123', url: 'https://gamma.app/mock/preview', title: opts.title, }), }, }; } ``` ### Step 4: Set Up Environment Files ```bash # .env.development GAMMA_API_KEY=your-dev-key GAMMA_MOCK=false # .env.test GAMMA_MOCK=true ``` ## Output - Hot reload development server - Mock client for offline development - Environment-based configuration - Fast iteration cycle ## Error Handling | Error | Cause | Solution | |-------|-------|----------| | Watch Error | File permissions | Check nodemon config | | Mock Mismatch | Mock out of sync | Update mock responses | | Env Not Loaded | dotenv not configured | Add `import 'dotenv/config'` | ## Examples ### Watch Mode Development ```bash npm run dev # Changes to src/*.ts trigger automatic restart ``` ### Offline Development with Mocks ```bash npm run dev:mock # Uses mock responses, no API calls ``` ## Resources - [tsx Documentation](https://github.com/esbuild-kit/tsx) - [Gamma SDK Mock Guide](https://gamma.app/docs/testing) ## Next Steps Proceed to `gamma-sdk-patterns` for advanced SDK usage patterns.

评论 0

还没有评论,来抢沙发。