Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/vast-ravens-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@offckb/cli': patch
---

fix(create): ensure CKB binary and devnet config before generating scripts

Fix issue #396 where `offckb create` failed if user hasn't run `offckb node` first.

**Changes:**

- Add imports for `installCKBBinary`, `initChainIfNeeded`, and `readSettings`
- Call `installCKBBinary` to download CKB binary if not exists
- Call `initChainIfNeeded` to initialize devnet config if not exists
- Both calls happen before `genSystemScriptsJsonFile` to ensure dependencies are ready

This makes `offckb create` self-sufficient and doesn't require prior `offckb node` execution.
8 changes: 8 additions & 0 deletions src/cmd/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { InteractivePrompts } from '../templates/prompts';
import { genSystemScriptsJsonFile } from '../scripts/gen';
import { CKBDebugger } from '../tools/ckb-debugger';
import { logger } from '../util/logger';
import { installCKBBinary as _installCKBBinary } from '../node/install';
import { initChainIfNeeded as _initChainIfNeeded } from '../node/init-chain';
import { readSettings } from '../cfg/setting';

export interface CreateScriptProjectOptions {
manager?: 'pnpm' | 'yarn' | 'npm';
Expand Down Expand Up @@ -100,6 +103,11 @@ export async function createScriptProject(name?: string, options: CreateScriptPr

await processor.generateProject(fullProjectPath, contextWithPath);

const _settings = readSettings();

await _installCKBBinary(_settings.bins.defaultCKBVersion);
await _initChainIfNeeded();

// Generate system-scripts.json
logger.info('🔧 Generating system scripts configuration...');
try {
Expand Down
Loading