@offckb/cli 0.4.4-canary-a12a0bc.0 ā 0.4.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offckb/cli",
|
|
3
|
-
"version": "0.4.4
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "ckb development network for your first try",
|
|
5
5
|
"author": "CKB EcoFund",
|
|
6
6
|
"license": "MIT",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"https-proxy-agent": "^7.0.5",
|
|
89
89
|
"node-fetch": "2",
|
|
90
90
|
"semver": "^7.6.0",
|
|
91
|
-
"tar": "^
|
|
91
|
+
"tar": "^7.5.3",
|
|
92
92
|
"winston": "^3.17.0"
|
|
93
93
|
},
|
|
94
94
|
"optionalDependencies": {
|
|
@@ -27,7 +27,8 @@ function buildAllContracts(isDebug = false) {
|
|
|
27
27
|
for (const contractName of contracts) {
|
|
28
28
|
console.log(`\nš¦ Building contract: ${contractName}`);
|
|
29
29
|
try {
|
|
30
|
-
|
|
30
|
+
const buildScriptPath = path.join('scripts', 'build-contract.js');
|
|
31
|
+
execSync(`node "${buildScriptPath}" ${contractName} ${isDebug ? '--debug' : ''}`, { stdio: 'inherit' });
|
|
31
32
|
console.log(`ā
Successfully built: ${contractName} with ${isDebug ? 'debug' : 'release'} version`);
|
|
32
33
|
} catch (error) {
|
|
33
34
|
console.error(`ā Failed to build: ${contractName}`);
|
|
@@ -46,7 +46,8 @@ function buildContract(contractName, isDebug = false) {
|
|
|
46
46
|
// Step 1: TypeScript type checking (if TypeScript file) - temporarily disabled due to @ckb-ccc/core version conflicts
|
|
47
47
|
// if (srcFile.endsWith('.ts')) {
|
|
48
48
|
// console.log(' š Type checking...');
|
|
49
|
-
//
|
|
49
|
+
// const tscPath = path.join('node_modules', '.bin', 'tsc');
|
|
50
|
+
// execSync(`"${tscPath}" --noEmit --project .`, { stdio: 'pipe' });
|
|
50
51
|
// }
|
|
51
52
|
|
|
52
53
|
// Step 2: Bundle with esbuild
|
|
@@ -60,28 +61,31 @@ function buildContract(contractName, isDebug = false) {
|
|
|
60
61
|
'--loader:.map=json',
|
|
61
62
|
];
|
|
62
63
|
const releaseParams = ['--minify'];
|
|
64
|
+
const esbuildPath = path.join('node_modules', '.bin', 'esbuild');
|
|
63
65
|
const esbuildCmd = [
|
|
64
|
-
|
|
66
|
+
`"${esbuildPath}"`,
|
|
65
67
|
'--platform=neutral',
|
|
66
68
|
'--bundle',
|
|
67
69
|
'--external:@ckb-js-std/bindings',
|
|
68
70
|
'--target=es2022',
|
|
69
71
|
...(isDebug ? debugParams : releaseParams),
|
|
70
|
-
srcFile
|
|
71
|
-
`--outfile
|
|
72
|
+
`"${srcFile}"`,
|
|
73
|
+
`--outfile="${outputJsFile}"`,
|
|
72
74
|
].join(' ');
|
|
73
75
|
|
|
74
76
|
execSync(esbuildCmd, { stdio: 'pipe' });
|
|
75
77
|
|
|
76
78
|
// Step 3: Compile to bytecode with ckb-debugger
|
|
77
79
|
console.log(' š§ Compiling to bytecode...');
|
|
80
|
+
const ckbJsVmPath = path.join('node_modules', 'ckb-testtool', 'src', 'unittest', 'defaultScript', 'ckb-js-vm');
|
|
78
81
|
const debuggerCmd = [
|
|
79
82
|
'ckb-debugger',
|
|
80
|
-
`--read-file ${outputJsFile}`,
|
|
81
|
-
'--bin
|
|
83
|
+
`--read-file "${outputJsFile}"`,
|
|
84
|
+
'--bin',
|
|
85
|
+
`"${ckbJsVmPath}"`,
|
|
82
86
|
'--',
|
|
83
87
|
'-c',
|
|
84
|
-
outputBcFile
|
|
88
|
+
`"${outputBcFile}"`,
|
|
85
89
|
].join(' ');
|
|
86
90
|
|
|
87
91
|
execSync(debuggerCmd, { stdio: 'pipe' });
|
|
@@ -13,23 +13,34 @@
|
|
|
13
13
|
* - --network: Network to deploy to (devnet, testnet, mainnet) - defaults to devnet
|
|
14
14
|
* - --privkey: Private key for deployment - defaults to offckb's deployer account
|
|
15
15
|
* - --type-id: Whether to use upgradable type id - defaults to false
|
|
16
|
+
* - --yes, -y: Skip confirmation prompt and deploy immediately - defaults to false
|
|
16
17
|
*
|
|
17
18
|
* Usage:
|
|
18
19
|
* pnpm run deploy
|
|
19
20
|
* pnpm run deploy --network testnet
|
|
20
21
|
* pnpm run deploy --network testnet --privkey 0x...
|
|
21
22
|
* pnpm run deploy --network testnet --type-id
|
|
23
|
+
* pnpm run deploy --yes
|
|
22
24
|
*/
|
|
23
25
|
|
|
24
26
|
import { spawn } from 'child_process';
|
|
25
27
|
import fs from 'fs';
|
|
28
|
+
import { fileURLToPath } from 'url';
|
|
29
|
+
import path from 'path';
|
|
26
30
|
|
|
27
31
|
function parseArgs() {
|
|
28
|
-
|
|
32
|
+
let args = process.argv.slice(2);
|
|
33
|
+
|
|
34
|
+
// Skip the first argument if it's "--" (npm/pnpm script separator)
|
|
35
|
+
if (args.length > 0 && args[0] === '--') {
|
|
36
|
+
args = args.slice(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
const parsed = {
|
|
30
40
|
network: 'devnet',
|
|
31
41
|
privkey: null,
|
|
32
42
|
typeId: false,
|
|
43
|
+
yes: false,
|
|
33
44
|
};
|
|
34
45
|
|
|
35
46
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -43,6 +54,8 @@ function parseArgs() {
|
|
|
43
54
|
i++; // Skip next argument since we consumed it
|
|
44
55
|
} else if (arg === '--type-id' || arg === '-t') {
|
|
45
56
|
parsed.typeId = true;
|
|
57
|
+
} else if (arg === '--yes' || arg === '-y') {
|
|
58
|
+
parsed.yes = true;
|
|
46
59
|
}
|
|
47
60
|
}
|
|
48
61
|
|
|
@@ -59,6 +72,7 @@ function main() {
|
|
|
59
72
|
const NETWORK = options.network;
|
|
60
73
|
const PRIVKEY = options.privkey;
|
|
61
74
|
const TYPE_ID = options.typeId;
|
|
75
|
+
const YES = options.yes;
|
|
62
76
|
|
|
63
77
|
// Validate that dist directory exists
|
|
64
78
|
if (!fs.existsSync(TARGET)) {
|
|
@@ -100,12 +114,16 @@ function main() {
|
|
|
100
114
|
args.push('--privkey', PRIVKEY);
|
|
101
115
|
}
|
|
102
116
|
|
|
103
|
-
|
|
117
|
+
if (YES) {
|
|
118
|
+
args.push('--yes');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Use offckb command - should be available in PATH
|
|
104
122
|
const offckbCmd = 'offckb';
|
|
105
123
|
|
|
106
|
-
|
|
107
|
-
console.log(
|
|
108
|
-
console.log(
|
|
124
|
+
console.log(`š Deploying contracts...`);
|
|
125
|
+
console.log(`š» Running: ${offckbCmd} ${args.join(' ')}`);
|
|
126
|
+
console.log(`š„ļø Platform: ${process.platform}`);
|
|
109
127
|
console.log('');
|
|
110
128
|
|
|
111
129
|
// Execute the deploy command
|
|
@@ -115,6 +133,7 @@ function main() {
|
|
|
115
133
|
});
|
|
116
134
|
|
|
117
135
|
deployProcess.on('close', (code) => {
|
|
136
|
+
console.log(`Deploy process exited with code: ${code}`);
|
|
118
137
|
if (code === 0) {
|
|
119
138
|
console.log('');
|
|
120
139
|
console.log('ā
Successfully deployed all contracts!');
|
|
@@ -124,6 +143,7 @@ function main() {
|
|
|
124
143
|
console.log('š” Next steps:');
|
|
125
144
|
console.log(' - Check the deployment artifacts in the deployment/ folder');
|
|
126
145
|
console.log(' - Run your tests to use the deployed contract scripts');
|
|
146
|
+
process.exit(0);
|
|
127
147
|
} else {
|
|
128
148
|
console.error('');
|
|
129
149
|
console.error('ā Deployment failed.');
|
|
@@ -134,16 +154,22 @@ function main() {
|
|
|
134
154
|
|
|
135
155
|
deployProcess.on('error', (error) => {
|
|
136
156
|
console.error('ā Error running deploy command:', error.message);
|
|
157
|
+
console.error(`š» Command: ${offckbCmd} ${args.join(' ')}`);
|
|
137
158
|
console.error('');
|
|
138
|
-
console.error('š”
|
|
139
|
-
console.error('
|
|
140
|
-
console.error('
|
|
141
|
-
console.error('
|
|
159
|
+
console.error('š” Troubleshooting:');
|
|
160
|
+
console.error(' 1. Make sure offckb is installed:');
|
|
161
|
+
console.error(' npm install -g @offckb/cli');
|
|
162
|
+
console.error(' # or');
|
|
163
|
+
console.error(' pnpm add -g @offckb/cli');
|
|
164
|
+
console.error(' 2. Check if offckb is in your PATH');
|
|
165
|
+
console.error(' 3. Try running the command manually to see the exact error');
|
|
142
166
|
process.exit(1);
|
|
143
167
|
});
|
|
144
168
|
}
|
|
145
169
|
|
|
146
170
|
// Run main function if this script is executed directly
|
|
147
|
-
|
|
171
|
+
// Use URL comparison for cross-platform compatibility (Windows uses backslashes in process.argv)
|
|
172
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
173
|
+
if (path.resolve(process.argv[1]) === path.resolve(__filename)) {
|
|
148
174
|
main();
|
|
149
175
|
}
|