Skip to content

Commit aa4735a

Browse files
authored
Merge pull request #379 from ckb-devrel/develop
Merge 0.4.4 into master
2 parents bd9c32e + 62006d9 commit aa4735a

27 files changed

Lines changed: 3772 additions & 538 deletions

File tree

.github/workflows/canary-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
- name: Install dependencies
2525
run: npm install -g pnpm && pnpm i
2626

27-
- name: Build
28-
run: pnpm build
29-
3027
- name: Set up Git identity
3128
run: |
3229
git config --local user.email "github-actions[bot]@users.noreply.github.com"
@@ -37,6 +34,9 @@ jobs:
3734
SHORT_COMMIT_ID=$(git log -1 --pretty=format:%h)
3835
npm version prerelease --preid="canary-$SHORT_COMMIT_ID"
3936
37+
- name: Build
38+
run: pnpm build
39+
4040
- name: Canary release to npm
4141
run: |
4242
npm publish --access public --tag canary

.github/workflows/test.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [master, develop]
6+
pull_request:
7+
branches: [master, develop]
8+
9+
jobs:
10+
test:
11+
name: Test on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
node-version: [20.x]
18+
fail-fast: false
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
with:
27+
version: 10
28+
29+
- name: Setup Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
# Don't use built-in cache - we'll cache pnpm store manually to include create-test deps
34+
35+
# Cache pnpm store - includes both main project and create-test template dependencies
36+
- name: Get pnpm store directory
37+
shell: bash
38+
id: pnpm-cache
39+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
40+
41+
- name: Cache pnpm store
42+
uses: actions/cache@v4
43+
with:
44+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
45+
# Cache key includes both lockfile (main deps) and template config (create-test deps)
46+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml', 'src/templates/config.ts') }}
47+
restore-keys: |
48+
${{ runner.os }}-pnpm-store-
49+
50+
- name: Install dependencies
51+
run: pnpm install --frozen-lockfile
52+
53+
- name: Run tests
54+
run: pnpm test
55+
56+
- name: Build project
57+
run: pnpm build
58+
59+
# Note: create-test.sh includes node startup and RPC verification,
60+
# so we don't need a separate starting-node-test step
61+
- name: Integration test - Create project workflow
62+
shell: bash
63+
run: bash scripts/create-test.sh
64+
65+
- name: Upload coverage to Codecov (Ubuntu only)
66+
if: matrix.os == 'ubuntu-latest'
67+
uses: codecov/codecov-action@v4
68+
with:
69+
files: ./coverage/lcov.info
70+
flags: unittests
71+
name: codecov-umbrella
72+
fail_ci_if_error: false

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ dist/
88
templates/temp-clone-folder
99
build/
1010
package-lock.json
11+
12+
# Test coverage
13+
coverage/
14+
*.lcov

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ pnpm install -g @offckb/cli
5555

5656
_Require Node version `>= v20.0.0`. We recommend using latest [LTS](https://nodejs.org/en/download/package-manager) version of Node to run `offckb`_
5757

58+
**Note for Windows users:** If installation fails due to native module compilation issues, the CLI will still work but may use portable binaries instead of optimized ones. For better performance, consider installing Visual Studio Build Tools.
59+
5860
## Usage
5961

6062
```sh
@@ -140,6 +142,33 @@ offckb create <your-project-name> -c <your-contract-name>
140142
```
141143
- The `-c` option is optional, if not provided, the contract name defaults to `hello-world`.
142144

145+
**Note for Windows Users:**
146+
147+
To run mock tests in the generated project, you need to manually install `ckb-debugger` until [this upstream fix about ckb-testtool wasm](https://github.com/nervosnetwork/ckb-js-vm/pull/98) is applied.
148+
149+
**Installation Steps:**
150+
151+
1. Download the latest `ckb-debugger` release for Windows from the [releases page](https://github.com/nervosnetwork/ckb-standalone-debugger/releases)
152+
2. Extract the downloaded archive (e.g., `ckb-debugger-win64.zip`)
153+
3. Add the extracted binary to your system PATH:
154+
- Open "System Properties" → "Environment Variables"
155+
- Under "System variables" or "User variables", find and edit the `Path` variable
156+
- Click "New" and add the full path to the folder containing `ckb-debugger.exe`
157+
- Click "OK" to save
158+
4. Verify installation by opening a new terminal and running:
159+
```sh
160+
ckb-debugger --version
161+
```
162+
5. Disable WASM debugger in your mock test file:
163+
- Open the mock test file (e.g., `<your-contract-name>.mock.test.ts`)
164+
- Comment out or delete the `verifier.setWasmDebuggerEnabled(true)` line:
165+
```typescript
166+
// When using native ckb-debugger, comment out or delete the following line:
167+
// verifier.setWasmDebuggerEnabled(true);
168+
```
169+
170+
After completing these steps, `npm run test` should pass without mock test failures.
171+
143172
### 3. Deploy Your Contract {#deploy-contract}
144173

145174
```sh

jest.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/** @type {import('jest').Config} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
5+
roots: ['<rootDir>/src', '<rootDir>/tests'],
6+
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
7+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
8+
collectCoverageFrom: [
9+
'src/**/*.{ts,tsx}',
10+
'!src/**/*.d.ts',
11+
'!src/**/index.ts',
12+
],
13+
coverageDirectory: 'coverage',
14+
coverageReporters: ['text', 'lcov', 'html'],
15+
moduleNameMapper: {
16+
'^@/(.*)$': '<rootDir>/src/$1',
17+
},
18+
transform: {
19+
'^.+\\.ts$': ['ts-jest', {
20+
tsconfig: {
21+
esModuleInterop: true,
22+
allowSyntheticDefaultImports: true,
23+
isolatedModules: true,
24+
},
25+
}],
26+
},
27+
};

package.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@offckb/cli",
3-
"version": "0.4.3",
3+
"version": "0.4.4",
44
"description": "ckb development network for your first try",
55
"author": "CKB EcoFund",
66
"license": "MIT",
@@ -27,7 +27,6 @@
2727
},
2828
"pnpm": {
2929
"onlyBuiltDependencies": [
30-
"cpu-features",
3130
"secp256k1"
3231
]
3332
},
@@ -37,7 +36,10 @@
3736
"clean": "node scripts/clean.js",
3837
"lint": "eslint \"src/**/*.ts\" --ignore-pattern 'node_modules/'",
3938
"lint:fix": "eslint \"src/**/*.ts\" --ignore-pattern 'node_modules/' --fix",
40-
"fmt": "prettier --write '{src,templates,account}/**/*.{js,jsx,ts,tsx,md,json}'"
39+
"fmt": "prettier --write '{src,templates,account}/**/*.{js,jsx,ts,tsx,md,json}'",
40+
"test": "jest",
41+
"test:watch": "jest --watch",
42+
"test:coverage": "jest --coverage"
4143
},
4244
"husky": {
4345
"hooks": {
@@ -55,7 +57,7 @@
5557
},
5658
"devDependencies": {
5759
"@types/adm-zip": "^0.5.5",
58-
"@types/cpu-features": "^0.0.3",
60+
"@types/jest": "^30.0.0",
5961
"@types/node": "^20.17.24",
6062
"@types/node-fetch": "^2.6.11",
6163
"@types/semver": "^7.5.7",
@@ -65,8 +67,10 @@
6567
"@vercel/ncc": "^0.38.3",
6668
"eslint": "^8.57.0",
6769
"husky": "^9.0.11",
70+
"jest": "^30.2.0",
6871
"lint-staged": "^15.2.2",
6972
"prettier": "^3.2.5",
73+
"ts-jest": "^29.4.6",
7074
"ts-node-dev": "^2.0.0",
7175
"typescript": "^5.3.3"
7276
},
@@ -80,12 +84,14 @@
8084
"child_process": "^1.0.2",
8185
"ckb-transaction-dumper": "^0.4.2",
8286
"commander": "^12.0.0",
83-
"cpu-features": "^0.0.10",
8487
"http-proxy": "^1.18.1",
8588
"https-proxy-agent": "^7.0.5",
8689
"node-fetch": "2",
8790
"semver": "^7.6.0",
88-
"tar": "^6.2.1",
91+
"tar": "^7.5.3",
8992
"winston": "^3.17.0"
93+
},
94+
"optionalDependencies": {
95+
"cpu-features": "^0.0.10"
9096
}
9197
}

0 commit comments

Comments
 (0)