@offckb/cli 0.2.1 → 0.2.3

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
@@ -23,15 +23,8 @@ Start building on Nervos blockchain, right now, right away!
23
23
  - [Install](#install)
24
24
  - [Usage](#usage)
25
25
  - [Get started](#get-started)
26
- - [Run A dApp Example](#run-a-dapp-example)
27
- - [Step 1: Select A dApp To Init](#step-1-select-a-dapp-to-init)
28
- - [Step 2: Start the Devnet](#step-2-start-the-devnet)
29
- - [Step 3: Access Pre-funded Accounts](#step-3-access-pre-funded-accounts)
30
- - [dApp Examples with Detailed Tutorial](#dapp-examples-with-detailed-tutorial)
31
- - [View and transfer balance](#view-and-transfer-balance)
32
- - [Write \& read on-chain messages](#write--read-on-chain-messages)
33
- - [Issue custom token via xUDT scripts](#issue-custom-token-via-xudt-scripts)
34
- - [Create on-chain digital object via Spore protocol](#create-on-chain-digital-object-via-spore-protocol)
26
+ - [Create a full-stack Project](#create-a-full-stack-project)
27
+ - [Create a script-only Project](#create-a-script-only-project)
35
28
  - [Built-in scripts](#built-in-scripts)
36
29
  - [Accounts](#accounts)
37
30
  - [About Lumos](#about-lumos)
@@ -57,14 +50,13 @@ Options:
57
50
  -h, --help display help for command
58
51
 
59
52
  Commands:
60
- init [your-project-name] Init a example dApp to learn and run
61
53
  create [your-project-name] Create a new dApp from bare templates
62
54
  node Use the CKB to start devnet
63
55
  clean Clean the devnet data, need to stop running the chain first
64
56
  accounts Print account list info
65
57
  list-hashes Use the CKB to list blockchain scripts hashes
66
58
  inject-config Add offckb.config.ts to your workspace
67
- update-config Update offckb.config.ts in your workspace
59
+ sync-config sync offckb.config.ts in your workspace
68
60
  deposit [options] [toAddress] [amountInShannon] Deposit CKB tokens to address, only devnet and testnet
69
61
  transfer [options] [toAddress] [amountInShannon] Transfer CKB tokens to address, only devnet and testnet
70
62
  balance [options] [toAddress] Check account balance, only devnet and testnet
@@ -75,9 +67,16 @@ Commands:
75
67
 
76
68
  *Use `offckb [command] -h` to learn more about a specific command.*
77
69
 
70
+ Sometimes you might encounter sudo permission problems. Granting the current user write access to the node_modules directory can resolve the problem.
71
+
72
+ ```sh
73
+ sudo chown -R $(whoami) /usr/local/lib/node_modules
74
+ npm install -g @offckb/cli
75
+ ```
76
+
78
77
  ## Get started
79
78
 
80
- ### Create a full-stack Project
79
+ ### Create a full-stack Project
81
80
 
82
81
  Create a new project from predefined boilerplates.
83
82
 
@@ -97,117 +96,6 @@ offckb create <your-project-name> --script
97
96
 
98
97
  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-tempaltes) to do all the magic.
99
98
 
100
- ## Run A dApp Example
101
-
102
- ### Step 1: Select A dApp To Init
103
-
104
- ```sh
105
- offckb init <your-project-name, eg:my-awesome-ckb-dapp>
106
-
107
- ## Select an example dApp
108
- ? Select a dapp template (Use arrow keys)
109
- ❯ Transfer CKB
110
- Issue Coin With XUDT scripts
111
- a simple dapp to check CKB balance and transfer CKB from address to address
112
- init CKB dapp project: /Users/ckb/Desktop/offckb/my-awesome-ckb-dapp
113
- ✨ Done in 7.52s.
114
-
115
- ## start running
116
- cd my-awesome-ckb-dapp
117
- yarn && yarn start
118
-
119
- ## results
120
- yarn run v1.22.19
121
- $ parcel index.html
122
- Server running at http://localhost:1234
123
- ✨ Built in 10ms
124
- ```
125
-
126
- ### Step 2: Start the Devnet
127
-
128
- Open another terminal and run:
129
-
130
- ```sh
131
- offckb node
132
-
133
- # result
134
- # ...
135
- CKB-Miner: 2024-03-04 14:35:12.563 +00:00 client INFO ckb_miner::miner Found! #3181 0x3749481a320824fe21077eaa8ec9d024a7b62d031720c27c1ef1681e8ab349e8
136
-
137
- CKB-Miner: 2024-03-04 14:35:17.567 +00:00 client INFO ckb_miner::miner Found! #3184 0xa612a9ea35f292a6473e23e88856283aea8b1bc6a607147bef5c06c94e964f2f
138
- #...
139
- ```
140
-
141
- You can leave this terminal open to keep the devnet running, feel free to `ctrl+c` to exit the terminal and stop the local blockchain.
142
-
143
- ### Step 3: Access Pre-funded Accounts
144
-
145
- Open another terminal and check the accounts to use:
146
-
147
- ```sh
148
- offckb accounts
149
-
150
- # results
151
-
152
- #### ALL ACCOUNTS ARE FOR TEST AND DEVELOP ONLY ####
153
- #### DON'T USE THESE ACCOUNTS ON MAINNET ####
154
- #### OTHERWISE YOU WILL LOOSE YOUR MONEY ####
155
-
156
- Print account list, each account is funded with 42_000_000_00000000 capacity in the devnet genesis block.
157
-
158
- - "#": 0
159
- address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqvwg2cen8extgq8s5puft8vf40px3f599cytcyd8
160
- privkey: 0x6109170b275a09ad54877b82f7d9930f88cab5717d484fb4741ae9d1dd078cd6
161
- pubkey: 0x02025fa7b61b2365aa459807b84df065f1949d58c0ae590ff22dd2595157bffefa
162
- lock_arg: 0x8e42b1999f265a0078503c4acec4d5e134534297
163
- lockScript:
164
- codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8
165
- hashType: type
166
- args: 0x8e42b1999f265a0078503c4acec4d5e134534297
167
-
168
- - "#": 1
169
- address: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqt435c3epyrupszm7khk6weq5lrlyt52lg48ucew
170
- privkey: 0x9f315d5a9618a39fdc487c7a67a8581d40b045bd7a42d83648ca80ef3b2cb4a1
171
- pubkey: 0x026efa0579f09cc7c1129b78544f70098c90b2ab155c10746316f945829c034a2d
172
- lock_arg: 0x758d311c8483e0602dfad7b69d9053e3f917457d
173
- lockScript:
174
- codeHash: 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8
175
- hashType: type
176
- args: 0x758d311c8483e0602dfad7b69d9053e3f917457d
177
- ```
178
-
179
- Copy some private keys and visit http://localhost:1234 to play your first CKB dApp!
180
-
181
- ## dApp Examples with Detailed Tutorial
182
-
183
- `offckb` packs some basic minimal dApp examples for you to learn and get started with. By running `offckb init`, you can select the different dApp examples to quickly set up a local dApp project targeting the local blockchain with built-in scripts and accounts.
184
-
185
- The dApp examples often involve interaction with some most useful smart contracts on CKB like xUDT/Spore/Omnilock. The best thing is those dApp examples also come with detailed tutorial documents from [docs.nervos.org](https://docs.nervos.org/). The source codes of these templates are also maintained [here](https://github.com/nervosnetwork/docs.nervos.org/tree/develop-v2/examples).
186
-
187
- ### View and transfer balance
188
-
189
- A simple dApp to check CKB balance and transfer CKB.
190
-
191
- [Tutorial](https://docs.nervos.org/docs/getting-started/transfer-ckb)
192
-
193
- ### Write & read on-chain messages
194
-
195
- A simple dApp to issue your own token via XUDT scripts.
196
-
197
- [Tutorial](https://docs.nervos.org/docs/getting-started/write-message)
198
-
199
- ### Issue custom token via xUDT scripts
200
-
201
- A simple dApp to store & retrieve data from a Cell.
202
-
203
- [Tutorial](https://docs.nervos.org/docs/getting-started/create-token)
204
-
205
- ### Create on-chain digital object via Spore protocol
206
-
207
- A simple dApp to create on-chain digital objects with spore scripts.
208
-
209
- [Tutorial](https://docs.nervos.org/docs/getting-started/create-dob)
210
-
211
99
  ## Built-in scripts
212
100
 
213
101
  - [x] xUDT https://github.com/nervosnetwork/rfcs/pull/428
@@ -14,9 +14,8 @@ export declare const deployedContractInfoFolderPath: string;
14
14
  export declare const accountTargetDir: string;
15
15
  export declare const minimalRequiredCKBVersion = "0.113.1";
16
16
  export declare const defaultLumosVersion = "0.21.0";
17
- export declare const dappTemplateGitRepoUserAndName = "nervosnetwork/docs.nervos.org";
18
- export declare const dappTemplateGitUrl = "https://github.com/nervosnetwork/docs.nervos.org";
17
+ export declare const dappTemplateGitRepoUserAndName = "RetricSu/offckb";
18
+ export declare const dappTemplateGitUrl = "https://github.com/RetricSu/offckb";
19
19
  export declare const dappTemplateGitBranch = "develop";
20
- export declare const dappTemplateGitFolder = "examples";
21
- export declare const dappTemplateGitSelectOptionFile = "options.json";
20
+ export declare const dappTemplateGitFolder = "templates";
22
21
  export declare const bareTemplateGitSelectOptionFile = "template.json";
package/dist/cfg/const.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.bareTemplateGitSelectOptionFile = exports.dappTemplateGitSelectOptionFile = exports.dappTemplateGitFolder = exports.dappTemplateGitBranch = exports.dappTemplateGitUrl = exports.dappTemplateGitRepoUserAndName = exports.defaultLumosVersion = exports.minimalRequiredCKBVersion = exports.accountTargetDir = exports.deployedContractInfoFolderPath = exports.ckbBinPath = exports.ckbFolderPath = exports.devnetDataPath = exports.devnetPath = exports.devnetSourcePath = exports.userOffCKBConfigPath = exports.predefinedOffCKBConfigTsPath = exports.targetEnvironmentPath = exports.dappTemplatePath = exports.packageRootPath = exports.packageSrcPath = exports.currentExecPath = void 0;
26
+ exports.bareTemplateGitSelectOptionFile = exports.dappTemplateGitFolder = exports.dappTemplateGitBranch = exports.dappTemplateGitUrl = exports.dappTemplateGitRepoUserAndName = exports.defaultLumosVersion = exports.minimalRequiredCKBVersion = exports.accountTargetDir = exports.deployedContractInfoFolderPath = exports.ckbBinPath = exports.ckbFolderPath = exports.devnetDataPath = exports.devnetPath = exports.devnetSourcePath = exports.userOffCKBConfigPath = exports.predefinedOffCKBConfigTsPath = exports.targetEnvironmentPath = exports.dappTemplatePath = exports.packageRootPath = exports.packageSrcPath = exports.currentExecPath = void 0;
27
27
  const path = __importStar(require("path"));
28
28
  // path
29
29
  exports.currentExecPath = process.cwd();
@@ -44,9 +44,8 @@ exports.accountTargetDir = path.join(exports.packageRootPath, `account`);
44
44
  exports.minimalRequiredCKBVersion = '0.113.1';
45
45
  exports.defaultLumosVersion = '0.21.0';
46
46
  // url
47
- exports.dappTemplateGitRepoUserAndName = 'nervosnetwork/docs.nervos.org';
47
+ exports.dappTemplateGitRepoUserAndName = 'RetricSu/offckb';
48
48
  exports.dappTemplateGitUrl = `https://github.com/${exports.dappTemplateGitRepoUserAndName}`;
49
49
  exports.dappTemplateGitBranch = 'develop';
50
- exports.dappTemplateGitFolder = 'examples';
51
- exports.dappTemplateGitSelectOptionFile = 'options.json';
50
+ exports.dappTemplateGitFolder = 'templates';
52
51
  exports.bareTemplateGitSelectOptionFile = 'template.json';
package/dist/cli.js CHANGED
@@ -17,14 +17,13 @@ const list_hashes_1 = require("./cmd/list-hashes");
17
17
  const node_1 = require("./cmd/node");
18
18
  const init_chain_1 = require("./cmd/develop/init-chain");
19
19
  const lumos_config_1 = require("./cmd/develop/lumos-config");
20
- const init_1 = require("./cmd/init");
21
20
  const accounts_1 = require("./cmd/accounts");
22
21
  const clean_1 = require("./cmd/clean");
23
22
  const encoding_1 = require("./util/encoding");
24
23
  const inject_config_1 = require("./cmd/inject-config");
25
24
  const deposit_1 = require("./cmd/deposit");
26
25
  const deploy_1 = require("./cmd/deploy");
27
- const update_config_1 = require("./cmd/update-config");
26
+ const sync_config_1 = require("./cmd/sync-config");
28
27
  const transfer_1 = require("./cmd/transfer");
29
28
  const balance_1 = require("./cmd/balance");
30
29
  const build_account_1 = require("./cmd/develop/build-account");
@@ -36,14 +35,6 @@ const description = require('../package.json').description;
36
35
  (0, encoding_1.setUTF8EncodingForWindows)();
37
36
  const program = new commander_1.Command();
38
37
  program.name('offckb').description(description).version(version);
39
- program
40
- .command('init [your-project-name]')
41
- .description('Init a example dApp to learn and run')
42
- .action((projectName) => __awaiter(void 0, void 0, void 0, function* () {
43
- const name = projectName !== null && projectName !== void 0 ? projectName : 'my-awesome-ckb-dapp';
44
- const template = yield (0, init_1.selectTemplate)();
45
- return (0, init_1.init)(name, template);
46
- }));
47
38
  program
48
39
  .command('create [your-project-name]')
49
40
  .description('Create a new dApp from bare templates')
@@ -61,7 +52,7 @@ program.command('clean').description('Clean the devnet data, need to stop runnin
61
52
  program.command('accounts').description('Print account list info').action(accounts_1.accounts);
62
53
  program.command('list-hashes').description('Use the CKB to list blockchain scripts hashes').action(list_hashes_1.listHashes);
63
54
  program.command('inject-config').description('Add offckb.config.ts to your workspace').action(inject_config_1.injectConfig);
64
- program.command('update-config').description('Update offckb.config.ts in your workspace').action(update_config_1.updateConfig);
55
+ program.command('sync-config').description('Sync offckb.config.ts in your workspace').action(sync_config_1.syncConfig);
65
56
  program
66
57
  .command('deposit [toAddress] [amountInShannon]')
67
58
  .description('Deposit CKB tokens to address, only devnet and testnet')
@@ -35,11 +35,12 @@ const config_1 = require("../util/config");
35
35
  const validator_1 = require("../util/validator");
36
36
  const type_1 = require("../util/type");
37
37
  function injectConfig() {
38
- const targetPath = const_1.currentExecPath;
39
38
  (0, validator_1.validateTypescriptWorkspace)();
40
39
  // inject the offckb.config.ts file into users workspace
41
40
  // copy config template
42
- (0, fs_1.copyFileSync)(const_1.predefinedOffCKBConfigTsPath, targetPath);
41
+ (0, fs_1.copyFileSync)(const_1.predefinedOffCKBConfigTsPath, const_1.userOffCKBConfigPath);
42
+ // update the version in the offckb.config.ts
43
+ (0, config_1.updateOffCKBConfigVersion)(const_1.userOffCKBConfigPath);
43
44
  // update the config
44
45
  const devnetFullLumosConfig = (0, config_1.buildFullLumosConfig)(type_1.Network.devnet);
45
46
  const testnetFullLumosConfig = (0, config_1.buildFullLumosConfig)(type_1.Network.testnet);
@@ -59,7 +60,7 @@ function injectConfig() {
59
60
  const indexer = offCKB.indexer;
60
61
  const rpc = offCKB.rpc;
61
62
 
62
- Check example at https://github.com/nervosnetwork/docs.nervos.org/tree/develop-v2/examples/create-dob
63
+ Check example at https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/simple-transfer
63
64
  `);
64
65
  }
65
66
  exports.injectConfig = injectConfig;
@@ -0,0 +1 @@
1
+ export declare function syncConfig(): void;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateConfig = void 0;
3
+ exports.syncConfig = void 0;
4
4
  const const_1 = require("../cfg/const");
5
5
  const config_1 = require("../util/config");
6
6
  const type_1 = require("../util/type");
7
7
  const validator_1 = require("../util/validator");
8
- function updateConfig() {
8
+ function syncConfig() {
9
9
  (0, validator_1.validateExecDappEnvironment)();
10
10
  // update the offckb.config.ts file in users workspace
11
11
  const devnetFullLumosConfig = (0, config_1.buildFullLumosConfig)(type_1.Network.devnet);
@@ -16,4 +16,4 @@ function updateConfig() {
16
16
  (0, config_1.updateScriptInfoInOffCKBConfigTs)(mainnetFullLumosConfig, const_1.userOffCKBConfigPath, type_1.Network.mainnet);
17
17
  console.log('offCKB config updated.');
18
18
  }
19
- exports.updateConfig = updateConfig;
19
+ exports.syncConfig = syncConfig;
@@ -1,5 +1,6 @@
1
1
  import { config } from '@ckb-lumos/lumos';
2
2
  import { Network } from './type';
3
+ export declare function updateOffCKBConfigVersion(filePath: string): void;
3
4
  export declare function updateScriptInfoInOffCKBConfigTs(newConfig: config.Config, filePath: string, network: Network): void;
4
5
  export declare function readUserDeployedScriptsInfo(network: Network): Record<string, config.ScriptConfig>;
5
6
  export declare function readPredefinedDevnetLumosConfig(): config.Config;
@@ -23,12 +23,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.buildFullLumosConfig = exports.readPredefinedTestnetLumosConfig = exports.readPredefinedMainnetLumosConfig = exports.readPredefinedDevnetLumosConfig = exports.readUserDeployedScriptsInfo = exports.updateScriptInfoInOffCKBConfigTs = void 0;
26
+ exports.buildFullLumosConfig = exports.readPredefinedTestnetLumosConfig = exports.readPredefinedMainnetLumosConfig = exports.readPredefinedDevnetLumosConfig = exports.readUserDeployedScriptsInfo = exports.updateScriptInfoInOffCKBConfigTs = exports.updateOffCKBConfigVersion = void 0;
27
27
  const fs = __importStar(require("fs"));
28
28
  const path = __importStar(require("path"));
29
29
  const const_1 = require("../cfg/const");
30
30
  const lumos_1 = require("@ckb-lumos/lumos");
31
31
  const type_1 = require("./type");
32
+ const version = require('../../package.json').version;
33
+ function updateOffCKBConfigVersion(filePath) {
34
+ const versionTarget = 'update-me-offckb-config-version';
35
+ let fileContent = fs.readFileSync(filePath, 'utf-8');
36
+ fileContent = fileContent.replace(versionTarget, version);
37
+ // Write the updated content back to the file
38
+ fs.writeFileSync(filePath, fileContent, 'utf-8');
39
+ }
40
+ exports.updateOffCKBConfigVersion = updateOffCKBConfigVersion;
32
41
  function updateScriptInfoInOffCKBConfigTs(newConfig, filePath, network) {
33
42
  // Read the content of the offckb.config.ts file
34
43
  let fileContent = fs.readFileSync(filePath, 'utf-8');
@@ -1,9 +1,3 @@
1
- export interface TutorialOption {
2
- name: string;
3
- value: string;
4
- description: string;
5
- }
6
- export declare function loadTutorialOpts(): Promise<Array<TutorialOption>>;
7
1
  export interface BareTemplateOption {
8
2
  name: string;
9
3
  value: string;
@@ -12,22 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.loadBareTemplateOpts = exports.loadTutorialOpts = void 0;
15
+ exports.loadBareTemplateOpts = void 0;
16
16
  const axios_1 = __importDefault(require("axios"));
17
17
  const const_1 = require("../cfg/const");
18
- function loadTutorialOpts() {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const githubUrl = `https://raw.githubusercontent.com/${const_1.dappTemplateGitRepoUserAndName}/${const_1.dappTemplateGitBranch}/${const_1.dappTemplateGitFolder}/${const_1.dappTemplateGitSelectOptionFile}`;
21
- try {
22
- const response = yield axios_1.default.get(githubUrl);
23
- return response.data;
24
- }
25
- catch (error) {
26
- throw new Error(`Error fetching JSON: ${error.message}`);
27
- }
28
- });
29
- }
30
- exports.loadTutorialOpts = loadTutorialOpts;
31
18
  function loadBareTemplateOpts() {
32
19
  return __awaiter(this, void 0, void 0, function* () {
33
20
  const githubUrl = `https://raw.githubusercontent.com/${const_1.dappTemplateGitRepoUserAndName}/${const_1.dappTemplateGitBranch}/${const_1.dappTemplateGitFolder}/${const_1.bareTemplateGitSelectOptionFile}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "Retric Su <retric@cryptape.com>",
6
6
  "license": "MIT",
@@ -16,7 +16,8 @@
16
16
  "dist",
17
17
  "account",
18
18
  "ckb",
19
- "templates"
19
+ "templates/config.json",
20
+ "templates/offckb.config.ts"
20
21
  ],
21
22
  "private": false,
22
23
  "publishConfig": {
@@ -1,3 +0,0 @@
1
- import { TutorialOption } from '../util/template';
2
- export declare function init(name: string, template: TutorialOption): void;
3
- export declare function selectTemplate(): Promise<TutorialOption>;
package/dist/cmd/init.js DELETED
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.selectTemplate = exports.init = void 0;
16
- const const_1 = require("../cfg/const");
17
- const path_1 = __importDefault(require("path"));
18
- const select_1 = __importDefault(require("@inquirer/select"));
19
- const template_1 = require("../util/template");
20
- const fs_1 = require("../util/fs");
21
- const git_1 = require("../util/git");
22
- function init(name, template) {
23
- const targetPath = path_1.default.resolve(const_1.currentExecPath, name);
24
- const dappTemplateFolderPath = `${const_1.dappTemplateGitFolder}/${template.value}`;
25
- (0, git_1.gitCloneAndDownloadFolderSync)(const_1.dappTemplateGitUrl, const_1.dappTemplateGitBranch, dappTemplateFolderPath, targetPath);
26
- // add some common code files
27
- const ckbDotTs = path_1.default.resolve(const_1.dappTemplatePath, 'ckb.ts');
28
- const configJson = path_1.default.resolve(const_1.dappTemplatePath, 'config.json');
29
- (0, fs_1.copyFileSync)(ckbDotTs, targetPath);
30
- (0, fs_1.copyFileSync)(configJson, targetPath);
31
- console.log(`init CKB dapp project: ${targetPath}`);
32
- }
33
- exports.init = init;
34
- function selectTemplate() {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const opts = yield (0, template_1.loadTutorialOpts)();
37
- const answer = yield (0, select_1.default)({
38
- message: 'Select an example dApp',
39
- choices: opts.map((opt) => {
40
- return {
41
- name: opt.name,
42
- value: opt.value,
43
- description: opt.description,
44
- };
45
- }),
46
- });
47
- return opts.find((opt) => opt.value === answer);
48
- });
49
- }
50
- exports.selectTemplate = selectTemplate;
@@ -1 +0,0 @@
1
- export declare function updateConfig(): void;
package/templates/ckb.ts DELETED
@@ -1,11 +0,0 @@
1
- import { Indexer, RPC, config } from '@ckb-lumos/lumos';
2
- import devConfig from './config.json';
3
-
4
- export const lumosConfig: config.Config = devConfig as config.Config;
5
- //export const lumosConfig: config.Config = config.predefined.AGGRON4;
6
-
7
- export const CKB_RPC_URL = 'http://localhost:8114';
8
- //export const CKB_RPC_URL = "https://testnet.ckb.dev/rpc";
9
-
10
- export const rpc = new RPC(CKB_RPC_URL);
11
- export const indexer = new Indexer(CKB_RPC_URL);