Skip to content

Commit fb506f4

Browse files
authored
fix(create): ensure CKB binary and devnet config before generating scripts (#419)
* fix(create): add imports for binary installation * fix(create): ensure CKB binary and devnet config before generating scripts Fix issue #396 where offckb create fails if user hasn't run offckb node first. Changes: - Add imports for installCKBBinary, initChainIfNeeded, 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. * chore: add changeset for issue #396 fix
1 parent fe80fc7 commit fb506f4

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

.changeset/vast-ravens-invent.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@offckb/cli': patch
3+
---
4+
5+
fix(create): ensure CKB binary and devnet config before generating scripts
6+
7+
Fix issue #396 where `offckb create` failed if user hasn't run `offckb node` first.
8+
9+
**Changes:**
10+
11+
- Add imports for `installCKBBinary`, `initChainIfNeeded`, and `readSettings`
12+
- Call `installCKBBinary` to download CKB binary if not exists
13+
- Call `initChainIfNeeded` to initialize devnet config if not exists
14+
- Both calls happen before `genSystemScriptsJsonFile` to ensure dependencies are ready
15+
16+
This makes `offckb create` self-sufficient and doesn't require prior `offckb node` execution.

src/cmd/create.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { InteractivePrompts } from '../templates/prompts';
66
import { genSystemScriptsJsonFile } from '../scripts/gen';
77
import { CKBDebugger } from '../tools/ckb-debugger';
88
import { logger } from '../util/logger';
9+
import { installCKBBinary as _installCKBBinary } from '../node/install';
10+
import { initChainIfNeeded as _initChainIfNeeded } from '../node/init-chain';
11+
import { readSettings } from '../cfg/setting';
912

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

101104
await processor.generateProject(fullProjectPath, contextWithPath);
102105

106+
const _settings = readSettings();
107+
108+
await _installCKBBinary(_settings.bins.defaultCKBVersion);
109+
await _initChainIfNeeded();
110+
103111
// Generate system-scripts.json
104112
logger.info('🔧 Generating system scripts configuration...');
105113
try {

0 commit comments

Comments
 (0)