@offckb/cli 0.3.2 → 0.3.4

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.
Files changed (49) hide show
  1. package/README.md +6 -0
  2. package/dist/cfg/env-path.js +1 -1
  3. package/dist/cfg/setting.js +22 -12
  4. package/dist/cli.js +17 -7
  5. package/dist/cmd/accounts.js +1 -2
  6. package/dist/cmd/balance.js +3 -4
  7. package/dist/cmd/clean.js +1 -2
  8. package/dist/cmd/config.js +2 -2
  9. package/dist/cmd/create.js +3 -4
  10. package/dist/cmd/debug.d.ts +1 -1
  11. package/dist/cmd/debug.js +10 -10
  12. package/dist/cmd/deploy.js +24 -7
  13. package/dist/cmd/deposit.js +3 -4
  14. package/dist/cmd/inject-config.js +18 -9
  15. package/dist/cmd/list-hashes.js +2 -3
  16. package/dist/cmd/mol.js +2 -3
  17. package/dist/cmd/my-scripts.js +1 -2
  18. package/dist/cmd/node.js +9 -10
  19. package/dist/cmd/proxy-rpc.js +1 -2
  20. package/dist/cmd/repl.js +5 -6
  21. package/dist/cmd/sync-scripts.js +1 -2
  22. package/dist/cmd/system-scripts.js +11 -11
  23. package/dist/cmd/transfer-all.js +3 -4
  24. package/dist/cmd/transfer.js +3 -4
  25. package/dist/deploy/index.js +6 -6
  26. package/dist/deploy/migration.js +25 -15
  27. package/dist/deploy/toml.js +2 -3
  28. package/dist/deploy/util.js +1 -2
  29. package/dist/molecule/mol.js +20 -10
  30. package/dist/node/init-chain.js +1 -2
  31. package/dist/node/install.js +27 -18
  32. package/dist/scripts/gen.js +21 -12
  33. package/dist/scripts/private.js +1 -2
  34. package/dist/scripts/util.js +18 -9
  35. package/dist/sdk/ckb.js +7 -7
  36. package/dist/template/offckb-config.js +17 -7
  37. package/dist/template/option.js +1 -2
  38. package/dist/tools/ckb-tx-dumper.js +1 -2
  39. package/dist/tools/rpc-proxy.d.ts +0 -1
  40. package/dist/tools/rpc-proxy.js +1 -2
  41. package/dist/util/encoding.js +2 -3
  42. package/dist/util/fs.d.ts +1 -0
  43. package/dist/util/fs.js +34 -20
  44. package/dist/util/git.js +19 -10
  45. package/dist/util/link.js +1 -2
  46. package/dist/util/request.js +2 -2
  47. package/dist/util/validator.js +5 -6
  48. package/npm-shrinkwrap.json +4514 -0
  49. package/package.json +6 -4
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadBareTemplateOpts = void 0;
3
+ exports.loadBareTemplateOpts = loadBareTemplateOpts;
4
4
  const templates = [
5
5
  {
6
6
  name: 'Remix-Vite Bare Templates',
@@ -20,4 +20,3 @@ const templates = [
20
20
  function loadBareTemplateOpts() {
21
21
  return templates;
22
22
  }
23
- exports.loadBareTemplateOpts = loadBareTemplateOpts;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.dumpTransaction = void 0;
6
+ exports.dumpTransaction = dumpTransaction;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const child_process_1 = require("child_process");
9
9
  const setting_1 = require("../cfg/setting");
@@ -18,4 +18,3 @@ function dumpTransaction({ rpc, txJsonFilePath, outputFilePath }) {
18
18
  console.error('Command failed:', error.message);
19
19
  }
20
20
  }
21
- exports.dumpTransaction = dumpTransaction;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import http from 'http';
3
2
  import { Network } from '../type/base';
4
3
  export declare function createRPCProxy(network: Network, targetRpcUrl: string, port: number): {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createRPCProxy = void 0;
6
+ exports.createRPCProxy = createRPCProxy;
7
7
  const http_proxy_1 = __importDefault(require("http-proxy"));
8
8
  const http_1 = __importDefault(require("http"));
9
9
  const base_1 = require("../type/base");
@@ -88,4 +88,3 @@ function createRPCProxy(network, targetRpcUrl, port) {
88
88
  },
89
89
  };
90
90
  }
91
- exports.createRPCProxy = createRPCProxy;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.encodeBinPathForTerminal = exports.setUTF8EncodingForWindows = void 0;
6
+ exports.setUTF8EncodingForWindows = setUTF8EncodingForWindows;
7
+ exports.encodeBinPathForTerminal = encodeBinPathForTerminal;
7
8
  const child_process_1 = require("child_process");
8
9
  const os_1 = __importDefault(require("os"));
9
10
  function setUTF8EncodingForWindows() {
@@ -16,10 +17,8 @@ function setUTF8EncodingForWindows() {
16
17
  }
17
18
  }
18
19
  }
19
- exports.setUTF8EncodingForWindows = setUTF8EncodingForWindows;
20
20
  function encodeBinPathForTerminal(path) {
21
21
  // some path contains space in the string
22
22
  // this fix the space in the terminal
23
23
  return `"${path}"`;
24
24
  }
25
- exports.encodeBinPathForTerminal = encodeBinPathForTerminal;
package/dist/util/fs.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare function readFileToUint8Array(filePath: string): Promise<Uint8Arr
7
7
  export declare function getBinaryFilesFromPath(fileOrFolderPath: string): string[];
8
8
  export declare function listBinaryFilesInFolder(folderPath: string): string[];
9
9
  export declare function isBinaryFile(filePath: string): boolean;
10
+ export declare function getBinaryFileSizeInBytes(filePath: string): number;
10
11
  export declare function isAbsolutePath(filePath: string): boolean;
11
12
  export declare function findFileInFolder(folderPath: string, fileName: string): string | null;
12
13
  export declare function getSubfolders(folderPath: string): string[];
package/dist/util/fs.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -32,7 +42,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
42
  });
33
43
  };
34
44
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.getSubfolders = exports.findFileInFolder = exports.isAbsolutePath = exports.isBinaryFile = exports.listBinaryFilesInFolder = exports.getBinaryFilesFromPath = exports.readFileToUint8Array = exports.copyRecursive = exports.copyFilesWithExclusion = exports.copyFileSync = exports.copyFolderSync = exports.isFolderExists = void 0;
45
+ exports.isFolderExists = isFolderExists;
46
+ exports.copyFolderSync = copyFolderSync;
47
+ exports.copyFileSync = copyFileSync;
48
+ exports.copyFilesWithExclusion = copyFilesWithExclusion;
49
+ exports.copyRecursive = copyRecursive;
50
+ exports.readFileToUint8Array = readFileToUint8Array;
51
+ exports.getBinaryFilesFromPath = getBinaryFilesFromPath;
52
+ exports.listBinaryFilesInFolder = listBinaryFilesInFolder;
53
+ exports.isBinaryFile = isBinaryFile;
54
+ exports.getBinaryFileSizeInBytes = getBinaryFileSizeInBytes;
55
+ exports.isAbsolutePath = isAbsolutePath;
56
+ exports.findFileInFolder = findFileInFolder;
57
+ exports.getSubfolders = getSubfolders;
36
58
  const fs = __importStar(require("fs"));
37
59
  const path = __importStar(require("path"));
38
60
  function isFolderExists(folderPath) {
@@ -48,7 +70,6 @@ function isFolderExists(folderPath) {
48
70
  return false;
49
71
  }
50
72
  }
51
- exports.isFolderExists = isFolderExists;
52
73
  function copyFolderSync(source, destination) {
53
74
  if (!fs.existsSync(destination)) {
54
75
  fs.mkdirSync(destination, { recursive: true });
@@ -65,7 +86,6 @@ function copyFolderSync(source, destination) {
65
86
  }
66
87
  }
67
88
  }
68
- exports.copyFolderSync = copyFolderSync;
69
89
  function copyFileSync(source, target) {
70
90
  let targetFile = target;
71
91
  // If target is a directory, a new file with the same name will be created
@@ -76,7 +96,6 @@ function copyFileSync(source, target) {
76
96
  }
77
97
  fs.writeFileSync(targetFile, fs.readFileSync(source));
78
98
  }
79
- exports.copyFileSync = copyFileSync;
80
99
  function copyFilesWithExclusion(sourceDir, destinationDir, excludedFolders) {
81
100
  return __awaiter(this, void 0, void 0, function* () {
82
101
  try {
@@ -90,7 +109,6 @@ function copyFilesWithExclusion(sourceDir, destinationDir, excludedFolders) {
90
109
  }
91
110
  });
92
111
  }
93
- exports.copyFilesWithExclusion = copyFilesWithExclusion;
94
112
  // Function to recursively copy files and directories
95
113
  function copyRecursive(source, destination, excludedFolders) {
96
114
  return __awaiter(this, void 0, void 0, function* () {
@@ -120,7 +138,6 @@ function copyRecursive(source, destination, excludedFolders) {
120
138
  }
121
139
  });
122
140
  }
123
- exports.copyRecursive = copyRecursive;
124
141
  function readFileToUint8Array(filePath) {
125
142
  return __awaiter(this, void 0, void 0, function* () {
126
143
  return new Promise((resolve, reject) => {
@@ -134,7 +151,6 @@ function readFileToUint8Array(filePath) {
134
151
  });
135
152
  });
136
153
  }
137
- exports.readFileToUint8Array = readFileToUint8Array;
138
154
  function getBinaryFilesFromPath(fileOrFolderPath) {
139
155
  if (!fs.existsSync(fileOrFolderPath)) {
140
156
  throw new Error(`File or Folder not exits ${fileOrFolderPath}`);
@@ -148,7 +164,6 @@ function getBinaryFilesFromPath(fileOrFolderPath) {
148
164
  }
149
165
  throw new Error(`${fileOrFolderPath} is not a valid path to deploy scripts.`);
150
166
  }
151
- exports.getBinaryFilesFromPath = getBinaryFilesFromPath;
152
167
  function listBinaryFilesInFolder(folderPath) {
153
168
  // Check if the provided path is a directory
154
169
  if (!fs.existsSync(folderPath) || !fs.lstatSync(folderPath).isDirectory()) {
@@ -160,7 +175,6 @@ function listBinaryFilesInFolder(folderPath) {
160
175
  const binaryFiles = files.filter((file) => fs.statSync(file).isFile() && isBinaryFile(file));
161
176
  return binaryFiles;
162
177
  }
163
- exports.listBinaryFilesInFolder = listBinaryFilesInFolder;
164
178
  // Function to check if a file is binary
165
179
  function isBinaryFile(filePath) {
166
180
  const buffer = fs.readFileSync(filePath);
@@ -172,11 +186,13 @@ function isBinaryFile(filePath) {
172
186
  }
173
187
  return false;
174
188
  }
175
- exports.isBinaryFile = isBinaryFile;
189
+ function getBinaryFileSizeInBytes(filePath) {
190
+ const stats = fs.statSync(filePath);
191
+ return stats.size;
192
+ }
176
193
  function isAbsolutePath(filePath) {
177
194
  return path.isAbsolute(filePath);
178
195
  }
179
- exports.isAbsolutePath = isAbsolutePath;
180
196
  function findFileInFolder(folderPath, fileName) {
181
197
  const files = fs.readdirSync(folderPath);
182
198
  for (const file of files) {
@@ -194,11 +210,9 @@ function findFileInFolder(folderPath, fileName) {
194
210
  }
195
211
  return null;
196
212
  }
197
- exports.findFileInFolder = findFileInFolder;
198
213
  function getSubfolders(folderPath) {
199
214
  return fs.readdirSync(folderPath).filter((file) => {
200
215
  const fullPath = path.join(folderPath, file);
201
216
  return fs.statSync(fullPath).isDirectory();
202
217
  });
203
218
  }
204
- exports.getSubfolders = getSubfolders;
package/dist/util/git.js CHANGED
@@ -15,15 +15,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.gitCloneAndDownloadFolderSync = exports.isGitInstalled = void 0;
36
+ exports.isGitInstalled = isGitInstalled;
37
+ exports.gitCloneAndDownloadFolderSync = gitCloneAndDownloadFolderSync;
27
38
  const child_process_1 = require("child_process");
28
39
  const fs = __importStar(require("fs"));
29
40
  const path = __importStar(require("path"));
@@ -38,7 +49,6 @@ function isGitInstalled() {
38
49
  return false;
39
50
  }
40
51
  }
41
- exports.isGitInstalled = isGitInstalled;
42
52
  function gitCloneAndDownloadFolderSync(repoUrl, branch, subFolderName, targetPath) {
43
53
  console.log('start cloning the dapp template..');
44
54
  const settings = (0, setting_1.readSettings)();
@@ -94,4 +104,3 @@ function gitCloneAndDownloadFolderSync(repoUrl, branch, subFolderName, targetPat
94
104
  }
95
105
  console.log(`Folder ${subFolderName} downloaded successfully from ${repoUrl} and moved to ${targetPath}`);
96
106
  }
97
- exports.gitCloneAndDownloadFolderSync = gitCloneAndDownloadFolderSync;
package/dist/util/link.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildTestnetTxLink = void 0;
3
+ exports.buildTestnetTxLink = buildTestnetTxLink;
4
4
  function buildTestnetTxLink(txHash) {
5
5
  return `https://pudge.explorer.nervos.org/transaction/${txHash}`;
6
6
  }
7
- exports.buildTestnetTxLink = buildTestnetTxLink;
@@ -17,8 +17,8 @@ const setting_1 = require("../cfg/setting");
17
17
  const https_proxy_agent_1 = require("https-proxy-agent");
18
18
  const node_fetch_1 = __importDefault(require("node-fetch"));
19
19
  class Request {
20
- static send(url, options = {}) {
21
- return __awaiter(this, void 0, void 0, function* () {
20
+ static send(url_1) {
21
+ return __awaiter(this, arguments, void 0, function* (url, options = {}) {
22
22
  const agent = this.proxy ? new https_proxy_agent_1.HttpsProxyAgent(this.proxyConfigToUrl(this.proxy)) : undefined;
23
23
  const opt = Object.assign({ agent }, options);
24
24
  try {
@@ -3,7 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isValidVersion = exports.validateNetworkOpt = exports.isValidNetworkString = exports.validateExecDappEnvironment = exports.validateTypescriptWorkspace = void 0;
6
+ exports.validateTypescriptWorkspace = validateTypescriptWorkspace;
7
+ exports.validateExecDappEnvironment = validateExecDappEnvironment;
8
+ exports.isValidNetworkString = isValidNetworkString;
9
+ exports.validateNetworkOpt = validateNetworkOpt;
10
+ exports.isValidVersion = isValidVersion;
7
11
  const path_1 = __importDefault(require("path"));
8
12
  const fs_1 = __importDefault(require("fs"));
9
13
  const base_1 = require("../type/base");
@@ -20,7 +24,6 @@ function validateTypescriptWorkspace() {
20
24
  throw new Error('tsconfig.json not found in the current directory');
21
25
  }
22
26
  }
23
- exports.validateTypescriptWorkspace = validateTypescriptWorkspace;
24
27
  function validateExecDappEnvironment() {
25
28
  const cwd = process.cwd();
26
29
  // Check if package.json and tsconfig.json exists
@@ -41,11 +44,9 @@ function validateExecDappEnvironment() {
41
44
  throw new Error('OffCKBConfig interface is not exported in offckb.config.ts');
42
45
  }
43
46
  }
44
- exports.validateExecDappEnvironment = validateExecDappEnvironment;
45
47
  function isValidNetworkString(network) {
46
48
  return ['devnet', 'testnet', 'mainnet'].includes(network);
47
49
  }
48
- exports.isValidNetworkString = isValidNetworkString;
49
50
  function validateNetworkOpt(network) {
50
51
  if (!isValidNetworkString(network)) {
51
52
  throw new Error('invalid network option, ' + network);
@@ -55,7 +56,6 @@ function validateNetworkOpt(network) {
55
56
  process.exit(1);
56
57
  }
57
58
  }
58
- exports.validateNetworkOpt = validateNetworkOpt;
59
59
  function isValidVersion(version) {
60
60
  if (typeof version !== 'string') {
61
61
  return false;
@@ -65,4 +65,3 @@ function isValidVersion(version) {
65
65
  // Test the version against the regex
66
66
  return versionRegex.test(version);
67
67
  }
68
- exports.isValidVersion = isValidVersion;