@offckb/cli 0.2.0 → 0.2.1

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
@@ -69,6 +69,7 @@ Commands:
69
69
  transfer [options] [toAddress] [amountInShannon] Transfer CKB tokens to address, only devnet and testnet
70
70
  balance [options] [toAddress] Check account balance, only devnet and testnet
71
71
  deploy [options] Deploy contracts to different networks, only supports devnet and testnet
72
+ deployed-scripts [options] Show deployed contracts info on networks, only supports devnet and testnet
72
73
  help [command] display help for command
73
74
  ```
74
75
 
@@ -76,13 +77,25 @@ Commands:
76
77
 
77
78
  ## Get started
78
79
 
80
+ ### Create a full-stack Project
81
+
79
82
  Create a new project from predefined boilerplates.
80
83
 
81
84
  ```sh
82
85
  offckb create <your-project-name, eg:my-first-ckb-project>
83
86
  ```
84
87
 
85
- The boilerplate can be targeting on different CKB networks. Check README.md in the project to get started.
88
+ The boilerplate can be targeting on different CKB networks. Check [README.md](https://github.com/nervosnetwork/docs.nervos.org/blob/develop/examples/remix-vite-template/readme.md) in the project to get started.
89
+
90
+ ### Create a script-only Project
91
+
92
+ You can create a new script project without a frontend. This is useful when you only want to develop smart contracts for CKB.
93
+
94
+ ```sh
95
+ offckb create <your-project-name> --script
96
+ ```
97
+
98
+ 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.
86
99
 
87
100
  ## Run A dApp Example
88
101
 
package/dist/cli.js CHANGED
@@ -29,6 +29,7 @@ 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");
31
31
  const create_1 = require("./cmd/create");
32
+ const deployed_scripts_1 = require("./cmd/deployed-scripts");
32
33
  const version = require('../package.json').version;
33
34
  const description = require('../package.json').description;
34
35
  // fix windows terminal encoding of simplified chinese text
@@ -46,8 +47,12 @@ program
46
47
  program
47
48
  .command('create [your-project-name]')
48
49
  .description('Create a new dApp from bare templates')
49
- .action((projectName) => __awaiter(void 0, void 0, void 0, function* () {
50
+ .option('-s, --script', 'Only create the script project')
51
+ .action((projectName, option) => __awaiter(void 0, void 0, void 0, function* () {
50
52
  const name = projectName !== null && projectName !== void 0 ? projectName : 'my-first-ckb-project';
53
+ if (option.script) {
54
+ return yield (0, create_1.createScriptProject)(name);
55
+ }
51
56
  const template = yield (0, create_1.selectBareTemplate)();
52
57
  return (0, create_1.create)(name, template);
53
58
  }));
@@ -86,6 +91,11 @@ program
86
91
  .option('--target <target>', 'Specify the relative bin target folder to deploy to')
87
92
  .option('--privkey <privkey>', 'Specify the private key to deploy scripts')
88
93
  .action((options) => (0, deploy_1.deploy)(options));
94
+ program
95
+ .command('deployed-scripts')
96
+ .description('Show deployed contracts info on different networks, only supports devnet and testnet')
97
+ .option('--network <network>', 'Specify the network to deploy to', 'devnet')
98
+ .action((options) => (0, deployed_scripts_1.deployedScripts)(options));
89
99
  // Add commands meant for developers
90
100
  if (process.env.NODE_ENV === 'development') {
91
101
  // Define the CLI commands and options
@@ -1,3 +1,7 @@
1
1
  import { BareTemplateOption } from '../util/template';
2
+ export interface CreateOption {
3
+ script: boolean;
4
+ }
5
+ export declare function createScriptProject(name: string): void;
2
6
  export declare function create(name: string, template: BareTemplateOption): Promise<void>;
3
7
  export declare function selectBareTemplate(): Promise<BareTemplateOption>;
@@ -12,14 +12,25 @@ 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.selectBareTemplate = exports.create = void 0;
15
+ exports.selectBareTemplate = exports.create = exports.createScriptProject = void 0;
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const const_1 = require("../cfg/const");
18
18
  const fs_1 = require("../util/fs");
19
19
  const template_1 = require("../util/template");
20
20
  const git_1 = require("../util/git");
21
21
  const prompts_1 = require("@inquirer/prompts");
22
+ const child_process_1 = require("child_process");
22
23
  const version = require('../../package.json').version;
24
+ function createScriptProject(name) {
25
+ const cmd = `cargo generate gh:cryptape/ckb-script-templates workspace --name ${name}`;
26
+ try {
27
+ (0, child_process_1.execSync)(cmd, { encoding: 'utf-8', stdio: 'inherit' });
28
+ }
29
+ catch (error) {
30
+ console.error('create script project failed, ', error.message);
31
+ }
32
+ }
33
+ exports.createScriptProject = createScriptProject;
23
34
  function create(name, template) {
24
35
  return __awaiter(this, void 0, void 0, function* () {
25
36
  const targetPath = path_1.default.resolve(const_1.currentExecPath, name);
@@ -0,0 +1,4 @@
1
+ import { NetworkOption } from '../util/type';
2
+ export interface DeployedScriptOption extends NetworkOption {
3
+ }
4
+ export declare function deployedScripts(option?: DeployedScriptOption): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deployedScripts = void 0;
4
+ const config_1 = require("../util/config");
5
+ const type_1 = require("../util/type");
6
+ const validator_1 = require("../util/validator");
7
+ function deployedScripts(option = { network: type_1.Network.devnet }) {
8
+ const network = option.network;
9
+ (0, validator_1.validateNetworkOpt)(network);
10
+ const scritpsInfo = (0, config_1.readUserDeployedScriptsInfo)(network);
11
+ console.log(`User deployed scripts on ${network}`);
12
+ console.log(JSON.stringify(scritpsInfo, null, 2));
13
+ }
14
+ exports.deployedScripts = deployedScripts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "Retric Su <retric@cryptape.com>",
6
6
  "license": "MIT",