@offckb/cli 0.4.4-canary-c8d18ae.0 → 0.4.4-canary-345ced0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +48 -10
- package/package.json +8 -2
package/build/index.js
CHANGED
|
@@ -267,10 +267,12 @@ function writeSettings(settings) {
|
|
|
267
267
|
}
|
|
268
268
|
function getCKBBinaryInstallPath(version) {
|
|
269
269
|
const setting = readSettings();
|
|
270
|
-
return
|
|
270
|
+
return path.join(setting.bins.rootFolder, version);
|
|
271
271
|
}
|
|
272
272
|
function getCKBBinaryPath(version) {
|
|
273
|
-
|
|
273
|
+
const platform = process.platform;
|
|
274
|
+
const binaryName = platform === 'win32' ? 'ckb.exe' : 'ckb';
|
|
275
|
+
return path.join(getCKBBinaryInstallPath(version), binaryName);
|
|
274
276
|
}
|
|
275
277
|
function deepMerge(target, source) {
|
|
276
278
|
for (const key in source) {
|
|
@@ -2321,15 +2323,27 @@ function downloadCKBBinaryAndUnzip(version) {
|
|
|
2321
2323
|
const sourcePath = path.join(extractDir, ckbPackageName);
|
|
2322
2324
|
const targetPath = (0, setting_1.getCKBBinaryInstallPath)(version);
|
|
2323
2325
|
if (fs.existsSync(targetPath)) {
|
|
2324
|
-
fs.
|
|
2326
|
+
fs.rmSync(targetPath, { recursive: true, force: true });
|
|
2325
2327
|
}
|
|
2326
2328
|
fs.mkdirSync(targetPath, { recursive: true });
|
|
2327
|
-
fs.
|
|
2328
|
-
|
|
2329
|
+
// Use fs.cp for cross-platform file copying (Node 16.7+)
|
|
2330
|
+
// This is more reliable than renameSync on Windows
|
|
2331
|
+
if (fs.cpSync) {
|
|
2332
|
+
fs.cpSync(sourcePath, targetPath, { recursive: true, force: true });
|
|
2333
|
+
fs.rmSync(sourcePath, { recursive: true, force: true });
|
|
2334
|
+
}
|
|
2335
|
+
else {
|
|
2336
|
+
// Fallback for older Node versions
|
|
2337
|
+
fs.renameSync(sourcePath, targetPath);
|
|
2338
|
+
}
|
|
2339
|
+
// Make the binary executable (only for non-Windows platforms)
|
|
2340
|
+
if (process.platform !== 'win32') {
|
|
2341
|
+
fs.chmodSync((0, setting_1.getCKBBinaryPath)(version), '755');
|
|
2342
|
+
}
|
|
2329
2343
|
logger_1.logger.info(`CKB ${version} installed successfully.`);
|
|
2330
2344
|
}
|
|
2331
2345
|
catch (error) {
|
|
2332
|
-
logger_1.logger.error('Error installing dependency binary:', error);
|
|
2346
|
+
logger_1.logger.error('Error installing dependency binary:', error.message);
|
|
2333
2347
|
}
|
|
2334
2348
|
});
|
|
2335
2349
|
}
|
|
@@ -2592,6 +2606,7 @@ const list_hashes_1 = __nccwpck_require__(31603);
|
|
|
2592
2606
|
const logger_1 = __nccwpck_require__(65370);
|
|
2593
2607
|
const const_1 = __nccwpck_require__(75587);
|
|
2594
2608
|
const toml_1 = __importDefault(__nccwpck_require__(2811));
|
|
2609
|
+
const util_1 = __nccwpck_require__(58642);
|
|
2595
2610
|
function getDevnetSystemScriptsFromListHashes() {
|
|
2596
2611
|
var _a;
|
|
2597
2612
|
const settings = (0, setting_1.readSettings)();
|
|
@@ -2607,9 +2622,8 @@ function getDevnetSystemScriptsFromListHashes() {
|
|
|
2607
2622
|
}
|
|
2608
2623
|
const systemScriptArray = chainSpecHashes.system_cells
|
|
2609
2624
|
.map((cell) => {
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
|
|
2625
|
+
// Extract the file name from the path using the helper function
|
|
2626
|
+
const name = (0, util_1.extractScriptNameFromPath)(cell.path);
|
|
2613
2627
|
const depGroupIndex = chainSpecHashes.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(cell.path));
|
|
2614
2628
|
const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
|
|
2615
2629
|
const depGroup = depGroupIndex === -1
|
|
@@ -2961,7 +2975,7 @@ exports.MAINNET_SYSTEM_SCRIPTS = {
|
|
|
2961
2975
|
{
|
|
2962
2976
|
cellDep: {
|
|
2963
2977
|
outPoint: {
|
|
2964
|
-
txHash: '
|
|
2978
|
+
txHash: '0x99b116dd1e4f1fa903b70112ae672c18bb34241d3d03a9ad555cd2a611be7327',
|
|
2965
2979
|
index: 0,
|
|
2966
2980
|
},
|
|
2967
2981
|
depType: 'code',
|
|
@@ -3044,6 +3058,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3044
3058
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3045
3059
|
exports.readDeployedScriptInfoFrom = readDeployedScriptInfoFrom;
|
|
3046
3060
|
exports.getScriptInfoFrom = getScriptInfoFrom;
|
|
3061
|
+
exports.extractScriptNameFromPath = extractScriptNameFromPath;
|
|
3047
3062
|
const fs = __importStar(__nccwpck_require__(79896));
|
|
3048
3063
|
const migration_1 = __nccwpck_require__(76679);
|
|
3049
3064
|
const path_1 = __importDefault(__nccwpck_require__(16928));
|
|
@@ -3111,6 +3126,29 @@ function getScriptInfoFrom(recipe) {
|
|
|
3111
3126
|
scriptsInfo,
|
|
3112
3127
|
};
|
|
3113
3128
|
}
|
|
3129
|
+
/**
|
|
3130
|
+
* Extracts the script name from a CKB list-hashes path string.
|
|
3131
|
+
* Handles both Bundled() and FileSystem() wrappers, and works with Unix and Windows path separators.
|
|
3132
|
+
*
|
|
3133
|
+
* @param pathString - The path string from CKB list-hashes output
|
|
3134
|
+
* @returns The extracted script name
|
|
3135
|
+
*
|
|
3136
|
+
* @example
|
|
3137
|
+
* extractScriptNameFromPath('Bundled(specs/cells/secp256k1_blake160_sighash_all)') // => 'secp256k1_blake160_sighash_all'
|
|
3138
|
+
* extractScriptNameFromPath('FileSystem(/Users/user/devnet/specs/anyone_can_pay)') // => 'anyone_can_pay'
|
|
3139
|
+
* extractScriptNameFromPath('FileSystem(C:\\Users\\user\\devnet\\specs\\anyone_can_pay)') // => 'anyone_can_pay'
|
|
3140
|
+
*/
|
|
3141
|
+
function extractScriptNameFromPath(pathString) {
|
|
3142
|
+
// Remove FileSystem(...) or Bundled(...) wrapper if present
|
|
3143
|
+
const wrapperMatch = pathString.match(/^(?:FileSystem|Bundled)\((.+)\)$/);
|
|
3144
|
+
if (wrapperMatch) {
|
|
3145
|
+
pathString = wrapperMatch[1];
|
|
3146
|
+
}
|
|
3147
|
+
// Use path.basename to extract the filename
|
|
3148
|
+
// This is robust and handles the platform's native path separator correctly
|
|
3149
|
+
// On Windows, it handles backslashes; on Unix, it handles forward slashes
|
|
3150
|
+
return path_1.default.basename(pathString);
|
|
3151
|
+
}
|
|
3114
3152
|
|
|
3115
3153
|
|
|
3116
3154
|
/***/ }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offckb/cli",
|
|
3
|
-
"version": "0.4.4-canary-
|
|
3
|
+
"version": "0.4.4-canary-345ced0.0",
|
|
4
4
|
"description": "ckb development network for your first try",
|
|
5
5
|
"author": "CKB EcoFund",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,10 @@
|
|
|
36
36
|
"clean": "node scripts/clean.js",
|
|
37
37
|
"lint": "eslint \"src/**/*.ts\" --ignore-pattern 'node_modules/'",
|
|
38
38
|
"lint:fix": "eslint \"src/**/*.ts\" --ignore-pattern 'node_modules/' --fix",
|
|
39
|
-
"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"
|
|
40
43
|
},
|
|
41
44
|
"husky": {
|
|
42
45
|
"hooks": {
|
|
@@ -54,6 +57,7 @@
|
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
56
59
|
"@types/adm-zip": "^0.5.5",
|
|
60
|
+
"@types/jest": "^30.0.0",
|
|
57
61
|
"@types/node": "^20.17.24",
|
|
58
62
|
"@types/node-fetch": "^2.6.11",
|
|
59
63
|
"@types/semver": "^7.5.7",
|
|
@@ -63,8 +67,10 @@
|
|
|
63
67
|
"@vercel/ncc": "^0.38.3",
|
|
64
68
|
"eslint": "^8.57.0",
|
|
65
69
|
"husky": "^9.0.11",
|
|
70
|
+
"jest": "^30.2.0",
|
|
66
71
|
"lint-staged": "^15.2.2",
|
|
67
72
|
"prettier": "^3.2.5",
|
|
73
|
+
"ts-jest": "^29.4.6",
|
|
68
74
|
"ts-node-dev": "^2.0.0",
|
|
69
75
|
"typescript": "^5.3.3"
|
|
70
76
|
},
|