From 5568f0f11216fada12c5a1f16194b0766a1e02a3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:23:24 +0000 Subject: [PATCH 01/16] Initial plan From 1ba406f28a4ecf53859f5e980b306c32bb72d01d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:27:34 +0000 Subject: [PATCH 02/16] Fix Windows path compatibility in template scripts - Use path.join() for cross-platform paths to node_modules/.bin - Add quotes around paths in execSync commands for spaces - Fix build-contract.js esbuild and ckb-debugger paths - Fix build-all.js to use path.join for script path Co-authored-by: RetricSu <23436060+RetricSu@users.noreply.github.com> --- templates/v4/base-template/scripts/build-all.js | 3 ++- .../v4/base-template/scripts/build-contract.js | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/templates/v4/base-template/scripts/build-all.js b/templates/v4/base-template/scripts/build-all.js index 9c01bd4..0c8ff3e 100644 --- a/templates/v4/base-template/scripts/build-all.js +++ b/templates/v4/base-template/scripts/build-all.js @@ -27,7 +27,8 @@ function buildAllContracts(isDebug = false) { for (const contractName of contracts) { console.log(`\nšŸ“¦ Building contract: ${contractName}`); try { - execSync(`node scripts/build-contract.js ${contractName} ${isDebug ? '--debug' : ''}`, { stdio: 'inherit' }); + const buildScriptPath = path.join('scripts', 'build-contract.js'); + execSync(`node "${buildScriptPath}" ${contractName} ${isDebug ? '--debug' : ''}`, { stdio: 'inherit' }); console.log(`āœ… Successfully built: ${contractName} with ${isDebug ? 'debug' : 'release'} version`); } catch (error) { console.error(`āŒ Failed to build: ${contractName}`); diff --git a/templates/v4/base-template/scripts/build-contract.js b/templates/v4/base-template/scripts/build-contract.js index 2ba6d92..fde0087 100644 --- a/templates/v4/base-template/scripts/build-contract.js +++ b/templates/v4/base-template/scripts/build-contract.js @@ -46,7 +46,8 @@ function buildContract(contractName, isDebug = false) { // Step 1: TypeScript type checking (if TypeScript file) - temporarily disabled due to @ckb-ccc/core version conflicts // if (srcFile.endsWith('.ts')) { // console.log(' šŸ” Type checking...'); - // execSync(`./node_modules/.bin/tsc --noEmit --project .`, { stdio: 'pipe' }); + // const tscPath = path.join('node_modules', '.bin', 'tsc'); + // execSync(`"${tscPath}" --noEmit --project .`, { stdio: 'pipe' }); // } // Step 2: Bundle with esbuild @@ -60,15 +61,16 @@ function buildContract(contractName, isDebug = false) { '--loader:.map=json', ]; const releaseParams = ['--minify']; + const esbuildPath = path.join('node_modules', '.bin', 'esbuild'); const esbuildCmd = [ - './node_modules/.bin/esbuild', + `"${esbuildPath}"`, '--platform=neutral', '--bundle', '--external:@ckb-js-std/bindings', '--target=es2022', ...(isDebug ? debugParams : releaseParams), - srcFile, - `--outfile=${outputJsFile}`, + `"${srcFile}"`, + `--outfile="${outputJsFile}"`, ].join(' '); execSync(esbuildCmd, { stdio: 'pipe' }); @@ -77,11 +79,12 @@ function buildContract(contractName, isDebug = false) { console.log(' šŸ”§ Compiling to bytecode...'); const debuggerCmd = [ 'ckb-debugger', - `--read-file ${outputJsFile}`, - '--bin node_modules/ckb-testtool/src/unittest/defaultScript/ckb-js-vm', + `--read-file "${outputJsFile}"`, + '--bin', + path.join('node_modules', 'ckb-testtool', 'src', 'unittest', 'defaultScript', 'ckb-js-vm'), '--', '-c', - outputBcFile, + `"${outputBcFile}"`, ].join(' '); execSync(debuggerCmd, { stdio: 'pipe' }); From 9e25ed796d5a515295b8a8e0542f28fb2e291774 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:29:12 +0000 Subject: [PATCH 03/16] Add quotes around ckb-js-vm path for Windows spaces Extracted path.join result to variable and wrapped in quotes to handle paths with spaces on Windows. Co-authored-by: RetricSu <23436060+RetricSu@users.noreply.github.com> --- templates/v4/base-template/scripts/build-contract.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/v4/base-template/scripts/build-contract.js b/templates/v4/base-template/scripts/build-contract.js index fde0087..b7c871b 100644 --- a/templates/v4/base-template/scripts/build-contract.js +++ b/templates/v4/base-template/scripts/build-contract.js @@ -77,11 +77,12 @@ function buildContract(contractName, isDebug = false) { // Step 3: Compile to bytecode with ckb-debugger console.log(' šŸ”§ Compiling to bytecode...'); + const ckbJsVmPath = path.join('node_modules', 'ckb-testtool', 'src', 'unittest', 'defaultScript', 'ckb-js-vm'); const debuggerCmd = [ 'ckb-debugger', `--read-file "${outputJsFile}"`, '--bin', - path.join('node_modules', 'ckb-testtool', 'src', 'unittest', 'defaultScript', 'ckb-js-vm'), + `"${ckbJsVmPath}"`, '--', '-c', `"${outputBcFile}"`, From 3eb1119d91ca4b8ee98d5df6e31dbc83a8424821 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:37:44 +0000 Subject: [PATCH 04/16] Replace && with npm-run-all for cross-platform compatibility Use run-s (sequential execution) from npm-run-all instead of && for guaranteed cross-platform compatibility on Windows. Add npm-run-all as devDependency and split scripts into sub-tasks. Co-authored-by: RetricSu <23436060+RetricSu@users.noreply.github.com> --- src/templates/config.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/templates/config.ts b/src/templates/config.ts index 5d73e77..c5a409c 100644 --- a/src/templates/config.ts +++ b/src/templates/config.ts @@ -19,9 +19,11 @@ export const PACKAGE_JSON_CONFIG: PackageJsonConfig = { 'build:contract:debug': 'node scripts/build-contract.js --debug', build: 'node scripts/build-all.js', 'build:debug': 'node scripts/build-all.js --debug', - deploy: 'node scripts/build-all.js && node scripts/deploy.js', - 'deploy:debug': 'node scripts/build-all.js --debug && node scripts/deploy.js', - test: 'node scripts/build-all.js && jest', + deploy: 'run-s build deploy:only', + 'deploy:only': 'node scripts/deploy.js', + 'deploy:debug': 'run-s build:debug deploy:only', + test: 'run-s build test:only', + 'test:only': 'jest', 'add-contract': 'node scripts/add-contract.js', clean: 'rimraf dist', format: 'prettier --write .', @@ -36,6 +38,7 @@ export const PACKAGE_JSON_CONFIG: PackageJsonConfig = { '@ckb-ccc/core': '1.12.2', // lock to version compatible with ckb-testtool esbuild: '~0.25.8', jest: '~29.7.0', + 'npm-run-all': '^4.1.5', prettier: '^3.5.3', rimraf: '^6.0.1', }, From 2c8c4b48c4459fab74a6122e689b52aa3c5a3b63 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 19 Jan 2026 02:22:43 +0000 Subject: [PATCH 05/16] Add --yes/-y option support to deploy script Support passing --yes or -y flag to skip confirmation prompts in offckb deploy command, following the same pattern as other options like --network, --privkey, and --type-id. Co-authored-by: RetricSu <23436060+RetricSu@users.noreply.github.com> --- templates/v4/base-template/scripts/deploy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/templates/v4/base-template/scripts/deploy.js b/templates/v4/base-template/scripts/deploy.js index 628d4a6..d8fa0db 100644 --- a/templates/v4/base-template/scripts/deploy.js +++ b/templates/v4/base-template/scripts/deploy.js @@ -13,12 +13,14 @@ * - --network: Network to deploy to (devnet, testnet, mainnet) - defaults to devnet * - --privkey: Private key for deployment - defaults to offckb's deployer account * - --type-id: Whether to use upgradable type id - defaults to false + * - --yes, -y: Skip confirmation prompt and deploy immediately - defaults to false * * Usage: * pnpm run deploy * pnpm run deploy --network testnet * pnpm run deploy --network testnet --privkey 0x... * pnpm run deploy --network testnet --type-id + * pnpm run deploy --yes */ import { spawn } from 'child_process'; @@ -30,6 +32,7 @@ function parseArgs() { network: 'devnet', privkey: null, typeId: false, + yes: false, }; for (let i = 0; i < args.length; i++) { @@ -43,6 +46,8 @@ function parseArgs() { i++; // Skip next argument since we consumed it } else if (arg === '--type-id' || arg === '-t') { parsed.typeId = true; + } else if (arg === '--yes' || arg === '-y') { + parsed.yes = true; } } @@ -59,6 +64,7 @@ function main() { const NETWORK = options.network; const PRIVKEY = options.privkey; const TYPE_ID = options.typeId; + const YES = options.yes; // Validate that dist directory exists if (!fs.existsSync(TARGET)) { @@ -100,6 +106,10 @@ function main() { args.push('--privkey', PRIVKEY); } + if (YES) { + args.push('--yes'); + } + // Try to find offckb binary const offckbCmd = 'offckb'; From 906dfc60b219b7e12ca5e241d273501b878a420e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:23:24 +0000 Subject: [PATCH 06/16] Initial plan From 2c9eea8e2d858806ceb5b60a22c25ba31d7bdd9d Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 10:35:27 +0800 Subject: [PATCH 07/16] fix(ci): add -y flag --- scripts/create-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 6acb692..222ec40 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -162,7 +162,7 @@ echo "āœ“ Project built successfully" echo "" echo "Deploying the project..." cd "$TEST_PROJECT_DIR" -pnpm run deploy +pnpm run deploy --network devnet --yes # Check if deployment artifacts were created if [ ! -f "$TEST_PROJECT_DIR/deployment/devnet.json" ]; then From b63d034b9eedb4b9e167716a3f17a78fa3e77069 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 10:40:47 +0800 Subject: [PATCH 08/16] fix(ci): use -- to pass flag --- scripts/create-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 222ec40..5f9c238 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -162,7 +162,7 @@ echo "āœ“ Project built successfully" echo "" echo "Deploying the project..." cd "$TEST_PROJECT_DIR" -pnpm run deploy --network devnet --yes +pnpm run deploy -- --network devnet --yes # Check if deployment artifacts were created if [ ! -f "$TEST_PROJECT_DIR/deployment/devnet.json" ]; then From 46a03349a3ebea347b1dde941893e575f98e36c6 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 11:06:52 +0800 Subject: [PATCH 09/16] fix(create): deploy now without build --- src/templates/config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/config.ts b/src/templates/config.ts index c5a409c..60ebb7e 100644 --- a/src/templates/config.ts +++ b/src/templates/config.ts @@ -19,9 +19,9 @@ export const PACKAGE_JSON_CONFIG: PackageJsonConfig = { 'build:contract:debug': 'node scripts/build-contract.js --debug', build: 'node scripts/build-all.js', 'build:debug': 'node scripts/build-all.js --debug', - deploy: 'run-s build deploy:only', - 'deploy:only': 'node scripts/deploy.js', - 'deploy:debug': 'run-s build:debug deploy:only', + deploy: 'node scripts/deploy.js', + 'deploy:build': 'run-s build deploy', + 'deploy:debug': 'run-s build:debug deploy', test: 'run-s build test:only', 'test:only': 'jest', 'add-contract': 'node scripts/add-contract.js', From 87978ae29acc26571edeb56d9e6833ae5e1717a3 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 13:55:40 +0800 Subject: [PATCH 10/16] fix(create): test artifact --- scripts/create-test.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 5f9c238..35e2016 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -82,12 +82,13 @@ echo "Creating test project with offckb create..." # - --no-install: Skip automatic dependency installation (we'll do it explicitly) # - -l typescript: Use TypeScript language # - -c hello-world: Name the first contract 'hello-world' +CONTRACT_NAME="hello-world" pnpm start create "$TEST_PROJECT_DIR" \ --no-interactive \ --no-git \ --no-install \ -l typescript \ - -c hello-world + -c "$CONTRACT_NAME" # Check if project was created if [ ! -d "$TEST_PROJECT_DIR" ]; then @@ -165,7 +166,7 @@ cd "$TEST_PROJECT_DIR" pnpm run deploy -- --network devnet --yes # Check if deployment artifacts were created -if [ ! -f "$TEST_PROJECT_DIR/deployment/devnet.json" ]; then +if [ ! -f "$TEST_PROJECT_DIR/deployment/scripts.json" ]; then echo "āœ— Deploy failed - deployment record not created" exit 1 fi @@ -175,10 +176,15 @@ echo "āœ“ Project deployed successfully" # Verify deployment record contains expected data echo "" echo "Verifying deployment record..." -DEPLOY_RECORD=$(cat "$TEST_PROJECT_DIR/deployment/devnet.json") +DEPLOY_RECORD=$(cat "$TEST_PROJECT_DIR/deployment/scripts.json") -if ! echo "$DEPLOY_RECORD" | grep -q '"contractName"'; then - echo "āœ— Deployment record is missing contractName" +if ! echo "$DEPLOY_RECORD" | grep -q '"devnet"'; then + echo "āœ— Deployment record is missing devnet section" + exit 1 +fi + +if ! echo "$DEPLOY_RECORD" | grep -q "\"${CONTRACT_NAME}.bc\""; then + echo "āœ— Deployment record is missing ${CONTRACT_NAME}.bc contract" exit 1 fi From d157bf6909d2e747276804190a208349b1d5debc Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 14:17:16 +0800 Subject: [PATCH 11/16] fix(ci): use local offckb bin link --- scripts/create-test.sh | 42 ++++++++++++++++++-- templates/v4/base-template/scripts/deploy.js | 30 +++++++++----- 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 35e2016..3e731f8 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -25,6 +25,12 @@ cleanup() { rm -rf "$TEST_PROJECT_DIR" fi + # Remove temporary CLI directory if it exists + if [ -d "/tmp/offckb-cli-$$" ]; then + echo "Removing temporary CLI directory..." + rm -rf "/tmp/offckb-cli-$$" + fi + echo "Cleanup complete." } @@ -70,8 +76,38 @@ fi # Install offckb since create test need it echo "" echo "Installing offckb CLI tool..." -npm install -g @offckb/cli -echo "āœ“ offckb installed" +# Use the local build instead of installing globally for better reliability +OFFCKB_CLI_PATH="$(pwd)/build/index.js" +if [ ! -f "$OFFCKB_CLI_PATH" ]; then + echo "āœ— Local build not found at $OFFCKB_CLI_PATH" + echo "Please run 'pnpm build' first" + exit 1 +fi + +# Create a temporary directory for the CLI and add it to PATH +TEMP_BIN_DIR="/tmp/offckb-cli-$$" +mkdir -p "$TEMP_BIN_DIR" + +# Create a wrapper script for cross-platform compatibility +if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then + # Windows + cat > "$TEMP_BIN_DIR/offckb.cmd" << EOF +@echo off +node "$OFFCKB_CLI_PATH" %* +EOF + chmod +x "$TEMP_BIN_DIR/offckb.cmd" +else + # Unix-like systems + cat > "$TEMP_BIN_DIR/offckb" << EOF +#!/bin/bash +exec node "$OFFCKB_CLI_PATH" "\$@" +EOF + chmod +x "$TEMP_BIN_DIR/offckb" +fi + +# Add to PATH for this session +export PATH="$TEMP_BIN_DIR:$PATH" +echo "āœ“ Using local offckb CLI, added to PATH" # Create test project with non-interactive mode echo "" @@ -83,7 +119,7 @@ echo "Creating test project with offckb create..." # - -l typescript: Use TypeScript language # - -c hello-world: Name the first contract 'hello-world' CONTRACT_NAME="hello-world" -pnpm start create "$TEST_PROJECT_DIR" \ +offckb create "$TEST_PROJECT_DIR" \ --no-interactive \ --no-git \ --no-install \ diff --git a/templates/v4/base-template/scripts/deploy.js b/templates/v4/base-template/scripts/deploy.js index d8fa0db..b1a6fe5 100644 --- a/templates/v4/base-template/scripts/deploy.js +++ b/templates/v4/base-template/scripts/deploy.js @@ -27,7 +27,13 @@ import { spawn } from 'child_process'; import fs from 'fs'; function parseArgs() { - const args = process.argv.slice(2); + let args = process.argv.slice(2); + + // Skip the first argument if it's "--" (npm/pnpm script separator) + if (args.length > 0 && args[0] === '--') { + args = args.slice(1); + } + const parsed = { network: 'devnet', privkey: null, @@ -110,12 +116,12 @@ function main() { args.push('--yes'); } - // Try to find offckb binary + // Use offckb command - should be available in PATH const offckbCmd = 'offckb'; - // For now, use 'offckb' directly - users should have it installed - console.log(`ļæ½ Deploying contracts...`); - console.log(`ļæ½šŸ’» Running: ${offckbCmd} ${args.join(' ')}`); + console.log(`šŸš€ Deploying contracts...`); + console.log(`šŸ’» Running: ${offckbCmd} ${args.join(' ')}`); + console.log(`šŸ–„ļø Platform: ${process.platform}`); console.log(''); // Execute the deploy command @@ -125,6 +131,7 @@ function main() { }); deployProcess.on('close', (code) => { + console.log(`Deploy process exited with code: ${code}`); if (code === 0) { console.log(''); console.log('āœ… Successfully deployed all contracts!'); @@ -134,6 +141,7 @@ function main() { console.log('šŸ’” Next steps:'); console.log(' - Check the deployment artifacts in the deployment/ folder'); console.log(' - Run your tests to use the deployed contract scripts'); + process.exit(0); } else { console.error(''); console.error('āŒ Deployment failed.'); @@ -144,11 +152,15 @@ function main() { deployProcess.on('error', (error) => { console.error('āŒ Error running deploy command:', error.message); + console.error(`šŸ’» Command: ${offckbCmd} ${args.join(' ')}`); console.error(''); - console.error('šŸ’” Make sure offckb is installed:'); - console.error(' npm install -g offckb-cli'); - console.error(' # or'); - console.error(' pnpm add -g offckb-cli'); + console.error('šŸ’” Troubleshooting:'); + console.error(' 1. Make sure offckb is installed:'); + console.error(' npm install -g @offckb/cli'); + console.error(' # or'); + console.error(' pnpm add -g @offckb/cli'); + console.error(' 2. Check if offckb is in your PATH'); + console.error(' 3. Try running the command manually to see the exact error'); process.exit(1); }); } From 0ac9b59102c363c1d5615185fa8102c65b0994f7 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 14:22:42 +0800 Subject: [PATCH 12/16] fix --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6cd76d5..0a34f34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,6 +38,9 @@ jobs: - name: Run tests run: pnpm test + - name: Build project + run: pnpm build + - name: Integration test - Start node and test RPC shell: bash run: bash scripts/starting-node-test.sh From f1236da8bf34e1da6bb7c577180f68513b5a88d9 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 14:35:31 +0800 Subject: [PATCH 13/16] fix windows executeable --- scripts/create-test.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 3e731f8..2d459e8 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -88,27 +88,26 @@ fi TEMP_BIN_DIR="/tmp/offckb-cli-$$" mkdir -p "$TEMP_BIN_DIR" -# Create a wrapper script for cross-platform compatibility -if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then - # Windows - cat > "$TEMP_BIN_DIR/offckb.cmd" << EOF -@echo off -node "$OFFCKB_CLI_PATH" %* -EOF - chmod +x "$TEMP_BIN_DIR/offckb.cmd" -else - # Unix-like systems - cat > "$TEMP_BIN_DIR/offckb" << EOF +# Create wrapper script - always use bash since we're running in bash +cat > "$TEMP_BIN_DIR/offckb" << EOF #!/bin/bash exec node "$OFFCKB_CLI_PATH" "\$@" EOF - chmod +x "$TEMP_BIN_DIR/offckb" -fi +chmod +x "$TEMP_BIN_DIR/offckb" # Add to PATH for this session export PATH="$TEMP_BIN_DIR:$PATH" echo "āœ“ Using local offckb CLI, added to PATH" +# Verify the command is accessible +if ! command -v offckb >/dev/null 2>&1; then + echo "āœ— offckb command not found in PATH after setup" + echo "PATH: $PATH" + echo "Temp dir contents: $(ls -la $TEMP_BIN_DIR)" + exit 1 +fi +echo "āœ“ Verified offckb command is accessible" + # Create test project with non-interactive mode echo "" echo "Creating test project with offckb create..." From 4b4cdd5affa931bdc2987fb584dadd464dd7007b Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 14:48:00 +0800 Subject: [PATCH 14/16] fix windows global install --- scripts/create-test.sh | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 2d459e8..63dba6f 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -25,12 +25,6 @@ cleanup() { rm -rf "$TEST_PROJECT_DIR" fi - # Remove temporary CLI directory if it exists - if [ -d "/tmp/offckb-cli-$$" ]; then - echo "Removing temporary CLI directory..." - rm -rf "/tmp/offckb-cli-$$" - fi - echo "Cleanup complete." } @@ -76,7 +70,7 @@ fi # Install offckb since create test need it echo "" echo "Installing offckb CLI tool..." -# Use the local build instead of installing globally for better reliability +# Use the local build but install it globally for better compatibility OFFCKB_CLI_PATH="$(pwd)/build/index.js" if [ ! -f "$OFFCKB_CLI_PATH" ]; then echo "āœ— Local build not found at $OFFCKB_CLI_PATH" @@ -84,29 +78,14 @@ if [ ! -f "$OFFCKB_CLI_PATH" ]; then exit 1 fi -# Create a temporary directory for the CLI and add it to PATH -TEMP_BIN_DIR="/tmp/offckb-cli-$$" -mkdir -p "$TEMP_BIN_DIR" +# Pack and install the local build globally +echo "Packing local build..." +pnpm pack --pack-destination /tmp +PACKAGE_FILE=$(ls /tmp/@offckb-cli-*.tgz) +echo "Installing local package globally: $PACKAGE_FILE" +npm install -g "$PACKAGE_FILE" -# Create wrapper script - always use bash since we're running in bash -cat > "$TEMP_BIN_DIR/offckb" << EOF -#!/bin/bash -exec node "$OFFCKB_CLI_PATH" "\$@" -EOF -chmod +x "$TEMP_BIN_DIR/offckb" - -# Add to PATH for this session -export PATH="$TEMP_BIN_DIR:$PATH" -echo "āœ“ Using local offckb CLI, added to PATH" - -# Verify the command is accessible -if ! command -v offckb >/dev/null 2>&1; then - echo "āœ— offckb command not found in PATH after setup" - echo "PATH: $PATH" - echo "Temp dir contents: $(ls -la $TEMP_BIN_DIR)" - exit 1 -fi -echo "āœ“ Verified offckb command is accessible" +echo "āœ“ Local offckb CLI installed globally" # Create test project with non-interactive mode echo "" From ed1f2d68ffa367de55774f9fa63dfb64051578da Mon Sep 17 00:00:00 2001 From: RetricSu Date: Tue, 20 Jan 2026 09:08:53 +0800 Subject: [PATCH 15/16] try fix deploy.js --- templates/v4/base-template/scripts/deploy.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/v4/base-template/scripts/deploy.js b/templates/v4/base-template/scripts/deploy.js index b1a6fe5..e55d5bd 100644 --- a/templates/v4/base-template/scripts/deploy.js +++ b/templates/v4/base-template/scripts/deploy.js @@ -25,6 +25,8 @@ import { spawn } from 'child_process'; import fs from 'fs'; +import { fileURLToPath } from 'url'; +import path from 'path'; function parseArgs() { let args = process.argv.slice(2); @@ -166,6 +168,8 @@ function main() { } // Run main function if this script is executed directly -if (import.meta.url === `file://${process.argv[1]}`) { +// Use URL comparison for cross-platform compatibility (Windows uses backslashes in process.argv) +const __filename = fileURLToPath(import.meta.url); +if (path.resolve(process.argv[1]) === path.resolve(__filename)) { main(); } From 3cf9f8215cee2f776aa7d53be520b329684ffb74 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Tue, 20 Jan 2026 09:59:07 +0800 Subject: [PATCH 16/16] try fix global install build version --- scripts/create-test.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 63dba6f..1b148e3 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -80,8 +80,11 @@ fi # Pack and install the local build globally echo "Packing local build..." -pnpm pack --pack-destination /tmp -PACKAGE_FILE=$(ls /tmp/@offckb-cli-*.tgz) +PACKAGE_FILE=$(pnpm pack --pack-destination /tmp 2>&1 | tail -1) +if [ ! -f "$PACKAGE_FILE" ]; then + echo "āœ— Failed to pack local build. Output: $PACKAGE_FILE" + exit 1 +fi echo "Installing local package globally: $PACKAGE_FILE" npm install -g "$PACKAGE_FILE"