@offckb/cli 0.4.2-canary-1af067f.0 → 0.4.2

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/README.md CHANGED
@@ -267,7 +267,7 @@ Example result:
267
267
  Pay attention to the `devnet.configPath` and `devnet.dataPath`.
268
268
 
269
269
  2. `cd` into the `devnet.configPath` . Modify the config files as needed. See [Custom Devnet Setup](https://docs.nervos.org/docs/node/run-devnet-node#custom-devnet-setup) and [Configure CKB](https://github.com/nervosnetwork/ckb/blob/develop/docs/configure.md) for details.
270
- 3. After modifications, remove everything in the `devnet.dataPath` folder to reset chain data.
270
+ 3. After modifications, run `offckb clean -d` to remove the chain data if needed while keeping the updated config files.
271
271
  4. Restart local blockchain by running `offckb node`
272
272
 
273
273
 
package/build/index.js CHANGED
@@ -356,6 +356,7 @@ program
356
356
  .option('-o, --output <output>', 'Specify the output folder path for the deployment record files', './deployment')
357
357
  .option('-t, --type-id', 'Specify if use upgradable type id to deploy the script')
358
358
  .option('--privkey <privkey>', 'Specify the private key to deploy scripts')
359
+ .option('-y, --yes', 'Skip confirmation prompt and deploy immediately')
359
360
  .action((options) => (0, deploy_1.deploy)(options));
360
361
  program
361
362
  .command('debug')
@@ -393,7 +394,11 @@ program
393
394
  }
394
395
  return (0, system_scripts_1.printSystemScripts)({ style: exportStyle, network });
395
396
  }));
396
- program.command('clean').description('Clean the devnet data, need to stop running the chain first').action(clean_1.clean);
397
+ program
398
+ .command('clean')
399
+ .description('Clean the devnet data, need to stop running the chain first')
400
+ .option('-d, --data', 'Only remove chain data, keep devnet config files')
401
+ .action((options) => (0, clean_1.clean)(options));
397
402
  program.command('accounts').description('Print account list info').action(accounts_1.accounts);
398
403
  program
399
404
  .command('deposit [toAddress] [amountInCKB]')
@@ -543,22 +548,43 @@ const fs_1 = __importDefault(__nccwpck_require__(79896));
543
548
  const fs_2 = __nccwpck_require__(37293);
544
549
  const setting_1 = __nccwpck_require__(25546);
545
550
  const logger_1 = __nccwpck_require__(65370);
546
- function clean() {
551
+ function clean(options) {
547
552
  const settings = (0, setting_1.readSettings)();
548
553
  const allDevnetDataPath = settings.devnet.configPath;
549
- // this is the root folder of devnet, it contains config, data, debugFullTransactions, transactions, failed-transactions, contracts
550
- if ((0, fs_2.isFolderExists)(allDevnetDataPath)) {
551
- try {
552
- fs_1.default.rmSync(allDevnetDataPath, { recursive: true });
553
- logger_1.logger.info(`Chain data cleaned.`);
554
+ const dataOnly = (options === null || options === void 0 ? void 0 : options.data) || false;
555
+ if (dataOnly) {
556
+ // Only clean the chain data subdirectory
557
+ const chainDataPath = settings.devnet.dataPath;
558
+ if ((0, fs_2.isFolderExists)(chainDataPath)) {
559
+ try {
560
+ fs_1.default.rmSync(chainDataPath, { recursive: true });
561
+ logger_1.logger.info(`Chain data cleaned. Devnet config files preserved.`);
562
+ }
563
+ catch (error) {
564
+ logger_1.logger.info(`Did you stop running the chain first?`);
565
+ logger_1.logger.error(error.message);
566
+ }
554
567
  }
555
- catch (error) {
556
- logger_1.logger.info(`Did you stop running the chain first?`);
557
- logger_1.logger.error(error.message);
568
+ else {
569
+ logger_1.logger.info(`Nothing to clean. Chain data directory ${chainDataPath} not found.`);
558
570
  }
559
571
  }
560
572
  else {
561
- logger_1.logger.info(`Nothing to clean. Devnet data directory ${allDevnetDataPath} not found.`);
573
+ // Clean everything - the original behavior
574
+ // this is the root folder of devnet, it contains config, data, debugFullTransactions, transactions, failed-transactions, contracts
575
+ if ((0, fs_2.isFolderExists)(allDevnetDataPath)) {
576
+ try {
577
+ fs_1.default.rmSync(allDevnetDataPath, { recursive: true });
578
+ logger_1.logger.info(`Chain data cleaned.`);
579
+ }
580
+ catch (error) {
581
+ logger_1.logger.info(`Did you stop running the chain first?`);
582
+ logger_1.logger.error(error.message);
583
+ }
584
+ }
585
+ else {
586
+ logger_1.logger.info(`Nothing to clean. Devnet data directory ${allDevnetDataPath} not found.`);
587
+ }
562
588
  }
563
589
  }
564
590
 
@@ -1138,12 +1164,15 @@ function deploy() {
1138
1164
  ` 🔑 Using ${opt.privkey ? 'custom' : 'default'} private key`,
1139
1165
  ` 🔄 Type ID: ${enableTypeId ? 'enabled (upgradable)' : 'disabled (immutable)'}`,
1140
1166
  ]);
1141
- const res = yield (0, prompts_1.confirm)({
1142
- message: 'Are you sure you want to deploy these contracts?',
1143
- });
1144
- if (!res) {
1145
- logger_1.logger.info('Deployment cancelled.');
1146
- return;
1167
+ // Skip confirmation if -y flag is provided
1168
+ if (!opt.yes) {
1169
+ const res = yield (0, prompts_1.confirm)({
1170
+ message: 'Are you sure you want to deploy these contracts?',
1171
+ });
1172
+ if (!res) {
1173
+ logger_1.logger.info('Deployment cancelled.');
1174
+ return;
1175
+ }
1147
1176
  }
1148
1177
  const results = yield (0, deploy_1.deployBinaries)(outputFolder, binPaths, privateKey, enableTypeId, ckb);
1149
1178
  logger_1.logger.info('');
@@ -3665,6 +3694,9 @@ class TemplateProcessor {
3665
3694
  processed = processed.replace(/\{\{PROJECT_PATH\}\}/g, context.projectPath || '.');
3666
3695
  processed = processed.replace(/\{\{CONTRACT_NAME\}\}/g, context.contractName || 'hello-world');
3667
3696
  processed = processed.replace(/\{\{LANGUAGE\}\}/g, context.language);
3697
+ // Add LANGUAGE_EXT variable for file extensions (typescript -> ts, javascript -> js)
3698
+ const languageExtension = context.language === 'typescript' ? 'ts' : 'js';
3699
+ processed = processed.replace(/\{\{LANGUAGE_EXT\}\}/g, languageExtension);
3668
3700
  processed = processed.replace(/\{\{PACKAGE_MANAGER\}\}/g, context.packageManager);
3669
3701
  return processed;
3670
3702
  }
@@ -129015,7 +129047,7 @@ module.exports = {"version":"3.17.0"};
129015
129047
  /***/ ((module) => {
129016
129048
 
129017
129049
  "use strict";
129018
- module.exports = /*#__PURE__*/JSON.parse('{"rE":"0.4.1","h_":"ckb development network for your first try"}');
129050
+ module.exports = /*#__PURE__*/JSON.parse('{"rE":"0.4.2","h_":"ckb development network for your first try"}');
129019
129051
 
129020
129052
  /***/ })
129021
129053
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.4.2-canary-1af067f.0",
3
+ "version": "0.4.2",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "CKB EcoFund",
6
6
  "license": "MIT",
@@ -13,9 +13,9 @@ This project uses the CKB JavaScript VM (ckb-js-vm) to write smart contracts in
13
13
  ├── contracts/ # Smart contract source code
14
14
  │ └── hello-world/
15
15
  │ └── src/
16
- │ └── index.{{LANGUAGE}} # Contract implementation
16
+ │ └── index.{{LANGUAGE_EXT}} # Contract implementation
17
17
  ├── tests/ # Contract tests
18
- │ └── hello-world.test.{{LANGUAGE}}
18
+ │ └── hello-world.test.{{LANGUAGE_EXT}}
19
19
  ├── scripts/ # Build and utility scripts
20
20
  │ ├── build-all.js
21
21
  │ ├── build-contract.js
@@ -93,7 +93,7 @@ This will:
93
93
 
94
94
  ### Contract Development
95
95
 
96
- 1. Edit your contract in `contracts/<contract-name>/src/index.{{LANGUAGE}}`
96
+ 1. Edit your contract in `contracts/<contract-name>/src/index.{{LANGUAGE_EXT}}`
97
97
  2. Build the contract: `{{PACKAGE_MANAGER}} run build:contract <contract-name>`
98
98
  3. Run tests: `{{PACKAGE_MANAGER}} test -- <contract-name>`
99
99