@offckb/cli 0.3.4 → 0.3.5

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
@@ -30,6 +30,7 @@ There are BREAKING CHANGES between v0.2.x and v0.3.x, make sure to read the [mig
30
30
  - [Tweak Devnet Config](#tweak-devnet-config)
31
31
  - [Create a full-stack Project](#create-a-full-stack-project)
32
32
  - [Create a script-only Project](#create-a-script-only-project)
33
+ - [Create a dApp-only Project](#create-a-dapp-only-project)
33
34
  - [Build and Deploy a script](#build-and-deploy-a-script)
34
35
  - [Start the frontend project](#start-the-frontend-project)
35
36
  - [Debug a transaction](#debug-a-transaction)
@@ -208,6 +209,14 @@ offckb create <your-project-name> --script
208
209
 
209
210
  Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your environment to use this command. offckb doesn't do anything really, it just call [ckb-script-template](https://github.com/cryptape/ckb-script-templates) to do all the magic.
210
211
 
212
+ ### Create a dApp-only Project
213
+
214
+ You can create a new dApp project without the script(CKB Smart Contract). This is useful when you don't need to create your own on-chain script logic.
215
+
216
+ ```sh
217
+ offckb create <your-project-name> --dapp # or -d
218
+ ```
219
+
211
220
  ### Build and Deploy a script
212
221
 
213
222
  The fullstack boilerplate project is a monorepo, which contains a script project and a frontend project.
@@ -58,6 +58,9 @@ export interface Settings {
58
58
  cachePath: string;
59
59
  binFolder: string;
60
60
  };
61
+ ckbDebugger: {
62
+ minVersion: string;
63
+ };
61
64
  };
62
65
  }
63
66
  export declare const defaultSettings: Settings;
@@ -57,7 +57,7 @@ exports.defaultSettings = {
57
57
  },
58
58
  bins: {
59
59
  rootFolder: path.resolve(exports.dataPath, 'bins'),
60
- defaultCKBVersion: '0.113.1',
60
+ defaultCKBVersion: '0.201.0',
61
61
  downloadPath: path.resolve(exports.cachePath, 'download'),
62
62
  },
63
63
  devnet: {
@@ -97,6 +97,9 @@ exports.defaultSettings = {
97
97
  cachePath: path.resolve(exports.cachePath, 'tools', 'moleculec-es'),
98
98
  binFolder: path.resolve(exports.dataPath, 'tools', 'moleculec-es'),
99
99
  },
100
+ ckbDebugger: {
101
+ minVersion: '0.200.0',
102
+ },
100
103
  },
101
104
  };
102
105
  function readSettings() {
package/dist/cli.js CHANGED
@@ -75,11 +75,15 @@ program
75
75
  .command('create [your-project-name]')
76
76
  .description('Create a new dApp from bare templates')
77
77
  .option('-s, --script', 'Only create the script project')
78
+ .option('-d, --dapp', 'Only create the ccc dapp project')
78
79
  .action((projectName, option) => __awaiter(void 0, void 0, void 0, function* () {
79
80
  const name = projectName !== null && projectName !== void 0 ? projectName : 'my-first-ckb-project';
80
81
  if (option.script) {
81
82
  return yield (0, create_1.createScriptProject)(name);
82
83
  }
84
+ if (option.dapp) {
85
+ return yield (0, create_1.createDappProject)(name);
86
+ }
83
87
  const template = yield (0, create_1.selectBareTemplate)();
84
88
  return (0, create_1.create)(name, template);
85
89
  }));
@@ -1,7 +1,15 @@
1
1
  import { BareTemplateOption } from '../template/option';
2
- export interface CreateOption {
3
- script: boolean;
4
- }
2
+ export type ScriptOnly = {
3
+ script: true;
4
+ dapp?: false;
5
+ };
6
+ export type DappOnly = {
7
+ dapp: true;
8
+ script?: false;
9
+ };
10
+ export type CreateOption = ScriptOnly | DappOnly;
5
11
  export declare function createScriptProject(name: string): void;
12
+ export declare function createDappProject(name: string): Promise<void>;
6
13
  export declare function create(name: string, template: BareTemplateOption): Promise<void>;
7
14
  export declare function selectBareTemplate(): Promise<BareTemplateOption>;
15
+ export declare function askForInjectOffckbConfig(dappFolderPath: string): Promise<void>;
@@ -13,11 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.createScriptProject = createScriptProject;
16
+ exports.createDappProject = createDappProject;
16
17
  exports.create = create;
17
18
  exports.selectBareTemplate = selectBareTemplate;
19
+ exports.askForInjectOffckbConfig = askForInjectOffckbConfig;
18
20
  const path_1 = __importDefault(require("path"));
19
21
  const fs_1 = require("../util/fs");
20
22
  const git_1 = require("../util/git");
23
+ const inject_config_1 = require("./inject-config");
21
24
  const prompts_1 = require("@inquirer/prompts");
22
25
  const child_process_1 = require("child_process");
23
26
  const gen_1 = require("../scripts/gen");
@@ -34,6 +37,19 @@ function createScriptProject(name) {
34
37
  console.error('create script project failed, ', error.message);
35
38
  }
36
39
  }
40
+ function createDappProject(name) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const cmd = `npx create-ccc-app@latest ${name} --ts --}`;
43
+ try {
44
+ (0, child_process_1.execSync)(cmd, { encoding: 'utf-8', stdio: 'inherit' });
45
+ const dappFolderPath = path_1.default.resolve(process.cwd(), name);
46
+ yield askForInjectOffckbConfig(dappFolderPath);
47
+ }
48
+ catch (error) {
49
+ console.error('create ccc-appp project failed, ', error.message);
50
+ }
51
+ });
52
+ }
37
53
  function create(name, template) {
38
54
  return __awaiter(this, void 0, void 0, function* () {
39
55
  const targetPath = path_1.default.resolve(process.cwd(), name);
@@ -75,3 +91,14 @@ function selectBareTemplate() {
75
91
  return opts.find((opt) => opt.value === answer);
76
92
  });
77
93
  }
94
+ function askForInjectOffckbConfig(dappFolderPath) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ const answer = yield (0, prompts_1.confirm)({
97
+ message: 'Do you want to inject offckb configs in your project so that it can work with local blockchain info?',
98
+ });
99
+ if (answer) {
100
+ const target = path_1.default.resolve(dappFolderPath, 'offckb.config.ts');
101
+ (0, inject_config_1.injectConfig)({ target });
102
+ }
103
+ });
104
+ }
package/dist/cmd/debug.js CHANGED
@@ -113,7 +113,7 @@ function buildDebugFullTransactionFilePath(network, txHash) {
113
113
  return `${settings.mainnet.debugFullTransactionsPath}/${txHash}.json`;
114
114
  }
115
115
  function debugRaw(options) {
116
- if (!ckb_debugger_1.CKBDebugger.isBinaryInstalled()) {
116
+ if (!ckb_debugger_1.CKBDebugger.isBinaryInstalled() || !ckb_debugger_1.CKBDebugger.isBinaryVersionValid()) {
117
117
  ckb_debugger_1.CKBDebugger.installCKBDebugger();
118
118
  }
119
119
  return ckb_debugger_1.CKBDebugger.runRaw(options);
@@ -67,6 +67,7 @@ function injectConfig({ target }) {
67
67
  const myScriptCodeHash = offCKB.myScripts['script-name'].codeHash;
68
68
  const omnilockScriptCodeHash = offCKB.systemScripts['omnilock'].codeHash;
69
69
 
70
- Check example at https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/simple-transfer
70
+ Check more on how to integrate offckb config to develop your app at https://docs.nervos.org/docs/getting-started/quick-start#different-frontend-framework
71
+ A Full example can also be found at https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/simple-transfer
71
72
  `);
72
73
  }
@@ -3,14 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadBareTemplateOpts = loadBareTemplateOpts;
4
4
  const templates = [
5
5
  {
6
- name: 'Remix-Vite Bare Templates',
6
+ name: 'JS Script with Next.js fullstack template',
7
+ value: 'js-script-next-js',
8
+ description: 'A full-stack template with Next-js and ckb-js-vm script',
9
+ tag: ['next.js', 'tailwindcss', 'ckb-js-vm', 'typescript'],
10
+ author: 'retric@cryptape.com',
11
+ },
12
+ {
13
+ name: 'Rust Script with Remix-Vite fullstack template',
7
14
  value: 'remix-vite-template',
8
15
  description: 'A full-stack template with Remix-vite and ckb-script-templates',
9
16
  tag: ['remix', 'vite', 'tailwindcss', 'ckb-script-templates', 'typescript', 'rust'],
10
17
  author: 'retric@cryptape.com',
11
18
  },
12
19
  {
13
- name: 'Next.js Bare Templates',
20
+ name: 'Rust Script with Next.js fullstack template',
14
21
  value: 'next-js-template',
15
22
  description: 'A full-stack template with Next.js framework and ckb-script-templates',
16
23
  tag: ['next.js', 'tailwindcss', 'ckb-script-templates', 'typescript', 'rust'],
@@ -8,5 +8,6 @@ export declare class CKBDebugger {
8
8
  static runRaw(options: string): void;
9
9
  static runTxCellScript({ fullTxJsonFilePath, cellIndex, cellType, scriptGroupType }: DebugOption): void;
10
10
  static isBinaryInstalled(): boolean;
11
+ static isBinaryVersionValid(): boolean;
11
12
  static installCKBDebugger(): void;
12
13
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CKBDebugger = void 0;
4
4
  const child_process_1 = require("child_process");
5
+ const setting_1 = require("../cfg/setting");
5
6
  class CKBDebugger {
6
7
  static runRaw(options) {
7
8
  const command = `ckb-debugger ${options}`;
@@ -15,6 +16,20 @@ class CKBDebugger {
15
16
  const result = (0, child_process_1.spawnSync)('ckb-debugger', ['--version'], { stdio: 'ignore' });
16
17
  return result.status === 0;
17
18
  }
19
+ static isBinaryVersionValid() {
20
+ const result = (0, child_process_1.spawnSync)('ckb-debugger', ['--version']);
21
+ if (result.status !== 0) {
22
+ console.error('ckb-debugger is not installed');
23
+ return false;
24
+ }
25
+ const version = result.stdout.toString().split(' ')[1];
26
+ const settings = (0, setting_1.readSettings)();
27
+ if (version < settings.tools.ckbDebugger.minVersion) {
28
+ console.error(`ckb-debugger version ${version} is less than ${settings.tools.ckbDebugger.minVersion}`);
29
+ return false;
30
+ }
31
+ return true;
32
+ }
18
33
  static installCKBDebugger() {
19
34
  const command = `cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger`;
20
35
  try {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.3.0-canary.0",
3
+ "version": "0.3.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@offckb/cli",
9
- "version": "0.3.0-canary.0",
9
+ "version": "0.3.5",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@ckb-ccc/core": "1.5.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "CKB EcoFund",
6
6
  "license": "MIT",