@offckb/cli 0.2.1 → 0.2.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 +11 -2
- package/dist/cli.js +2 -2
- package/dist/cmd/inject-config.js +4 -3
- package/dist/cmd/sync-config.d.ts +1 -0
- package/dist/cmd/{update-config.js → sync-config.js} +3 -3
- package/dist/util/config.d.ts +1 -0
- package/dist/util/config.js +10 -1
- package/package.json +1 -1
- package/dist/cmd/update-config.d.ts +0 -1
package/README.md
CHANGED
|
@@ -23,7 +23,9 @@ Start building on Nervos blockchain, right now, right away!
|
|
|
23
23
|
- [Install](#install)
|
|
24
24
|
- [Usage](#usage)
|
|
25
25
|
- [Get started](#get-started)
|
|
26
|
-
- [
|
|
26
|
+
- [Create a full-stack Project](#create-a-full-stack-project)
|
|
27
|
+
- [Create a script-only Project](#create-a-script-only-project)
|
|
28
|
+
- [Run A dApp Example](#run-a-dapp-example)
|
|
27
29
|
- [Step 1: Select A dApp To Init](#step-1-select-a-dapp-to-init)
|
|
28
30
|
- [Step 2: Start the Devnet](#step-2-start-the-devnet)
|
|
29
31
|
- [Step 3: Access Pre-funded Accounts](#step-3-access-pre-funded-accounts)
|
|
@@ -64,7 +66,7 @@ Commands:
|
|
|
64
66
|
accounts Print account list info
|
|
65
67
|
list-hashes Use the CKB to list blockchain scripts hashes
|
|
66
68
|
inject-config Add offckb.config.ts to your workspace
|
|
67
|
-
|
|
69
|
+
sync-config sync offckb.config.ts in your workspace
|
|
68
70
|
deposit [options] [toAddress] [amountInShannon] Deposit CKB tokens to address, only devnet and testnet
|
|
69
71
|
transfer [options] [toAddress] [amountInShannon] Transfer CKB tokens to address, only devnet and testnet
|
|
70
72
|
balance [options] [toAddress] Check account balance, only devnet and testnet
|
|
@@ -75,6 +77,13 @@ Commands:
|
|
|
75
77
|
|
|
76
78
|
*Use `offckb [command] -h` to learn more about a specific command.*
|
|
77
79
|
|
|
80
|
+
Sometimes you might encounter sudo permission problems. Granting the current user write access to the node_modules directory can resolve the problem.
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
sudo chown -R $(whoami) /usr/local/lib/node_modules
|
|
84
|
+
npm install -g @offckb/cli
|
|
85
|
+
```
|
|
86
|
+
|
|
78
87
|
## Get started
|
|
79
88
|
|
|
80
89
|
### Create a full-stack Project
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ const encoding_1 = require("./util/encoding");
|
|
|
24
24
|
const inject_config_1 = require("./cmd/inject-config");
|
|
25
25
|
const deposit_1 = require("./cmd/deposit");
|
|
26
26
|
const deploy_1 = require("./cmd/deploy");
|
|
27
|
-
const
|
|
27
|
+
const sync_config_1 = require("./cmd/sync-config");
|
|
28
28
|
const transfer_1 = require("./cmd/transfer");
|
|
29
29
|
const balance_1 = require("./cmd/balance");
|
|
30
30
|
const build_account_1 = require("./cmd/develop/build-account");
|
|
@@ -61,7 +61,7 @@ program.command('clean').description('Clean the devnet data, need to stop runnin
|
|
|
61
61
|
program.command('accounts').description('Print account list info').action(accounts_1.accounts);
|
|
62
62
|
program.command('list-hashes').description('Use the CKB to list blockchain scripts hashes').action(list_hashes_1.listHashes);
|
|
63
63
|
program.command('inject-config').description('Add offckb.config.ts to your workspace').action(inject_config_1.injectConfig);
|
|
64
|
-
program.command('
|
|
64
|
+
program.command('sync-config').description('Sync offckb.config.ts in your workspace').action(sync_config_1.syncConfig);
|
|
65
65
|
program
|
|
66
66
|
.command('deposit [toAddress] [amountInShannon]')
|
|
67
67
|
.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,
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
19
|
+
exports.syncConfig = syncConfig;
|
package/dist/util/config.d.ts
CHANGED
|
@@ -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;
|
package/dist/util/config.js
CHANGED
|
@@ -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');
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function updateConfig(): void;
|