@offckb/cli 0.3.0-canary-dc851bd.0 → 0.3.0-canary-eea3da1.0

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.
@@ -35,7 +35,16 @@ function deploy() {
35
35
  const targetFolder = opt.target;
36
36
  if (targetFolder) {
37
37
  const binFilesOrFolder = (0, fs_1.isAbsolutePath)(targetFolder) ? targetFolder : path_1.default.resolve(process.cwd(), targetFolder);
38
- const binPaths = (0, fs_1.getBinaryFilesFromPath)(binFilesOrFolder);
38
+ let binPaths = (0, fs_1.getBinaryFilesFromPath)(binFilesOrFolder);
39
+ // ignore the binary file which is too large(> 500kb) to upload on chain
40
+ binPaths = binPaths.filter((binPath) => {
41
+ const size = (0, fs_1.getBinaryFileSizeInBytes)(binPath);
42
+ if (size > 500 * 1024) {
43
+ console.warn(`[warning]: ignore deploying the binary file ${binPath} since its size is too large: ${size} bytes`);
44
+ return false;
45
+ }
46
+ return true;
47
+ });
39
48
  const results = yield (0, deploy_1.deployBinaries)(binPaths, privateKey, enableTypeId, ckb);
40
49
  // record the deployed contract infos
41
50
  (0, deploy_1.recordDeployResult)(results, network); // we don't update my-scripts.json since we don't know where the file is
@@ -50,7 +59,16 @@ function deploy() {
50
59
  if (!fs_2.default.existsSync(userOffCKBConfigPath)) {
51
60
  throw new Error(`config file not exits: ${userOffCKBConfigPath}, tips: use --config to specific the offckb.config.ts file`);
52
61
  }
53
- const bins = (0, deploy_1.getToDeployBinsPath)(userOffCKBConfigPath);
62
+ let bins = (0, deploy_1.getToDeployBinsPath)(userOffCKBConfigPath);
63
+ // ignore the binary file which is too large(> 500kb) to upload on chain
64
+ bins = bins.filter((binPath) => {
65
+ const size = (0, fs_1.getBinaryFileSizeInBytes)(binPath);
66
+ if (size > 500 * 1024) {
67
+ console.warn(`[warning]: ignore deploying the binary file ${binPath} since its size is too large: ${size} bytes`);
68
+ return false;
69
+ }
70
+ return true;
71
+ });
54
72
  const results = yield (0, deploy_1.deployBinaries)(bins, privateKey, enableTypeId, ckb);
55
73
  // record the deployed contract infos
56
74
  (0, deploy_1.recordDeployResult)(results, network, userOffCKBConfigPath);
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
@@ -51,6 +51,7 @@ exports.readFileToUint8Array = readFileToUint8Array;
51
51
  exports.getBinaryFilesFromPath = getBinaryFilesFromPath;
52
52
  exports.listBinaryFilesInFolder = listBinaryFilesInFolder;
53
53
  exports.isBinaryFile = isBinaryFile;
54
+ exports.getBinaryFileSizeInBytes = getBinaryFileSizeInBytes;
54
55
  exports.isAbsolutePath = isAbsolutePath;
55
56
  exports.findFileInFolder = findFileInFolder;
56
57
  exports.getSubfolders = getSubfolders;
@@ -185,6 +186,10 @@ function isBinaryFile(filePath) {
185
186
  }
186
187
  return false;
187
188
  }
189
+ function getBinaryFileSizeInBytes(filePath) {
190
+ const stats = fs.statSync(filePath);
191
+ return stats.size;
192
+ }
188
193
  function isAbsolutePath(filePath) {
189
194
  return path.isAbsolute(filePath);
190
195
  }