@offckb/cli 0.3.3 → 0.3.5
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 +15 -0
- package/dist/cfg/env-path.js +1 -1
- package/dist/cfg/setting.d.ts +3 -0
- package/dist/cfg/setting.js +26 -13
- package/dist/cli.js +21 -7
- package/dist/cmd/accounts.js +1 -2
- package/dist/cmd/balance.js +3 -4
- package/dist/cmd/clean.js +1 -2
- package/dist/cmd/config.js +2 -2
- package/dist/cmd/create.d.ts +11 -3
- package/dist/cmd/create.js +30 -4
- package/dist/cmd/debug.d.ts +1 -1
- package/dist/cmd/debug.js +9 -10
- package/dist/cmd/deploy.js +24 -7
- package/dist/cmd/deposit.js +3 -4
- package/dist/cmd/inject-config.js +20 -10
- package/dist/cmd/list-hashes.js +2 -3
- package/dist/cmd/mol.js +2 -3
- package/dist/cmd/my-scripts.js +1 -2
- package/dist/cmd/node.js +9 -10
- package/dist/cmd/proxy-rpc.js +1 -2
- package/dist/cmd/repl.js +5 -6
- package/dist/cmd/sync-scripts.js +1 -2
- package/dist/cmd/system-scripts.js +11 -11
- package/dist/cmd/transfer-all.js +3 -4
- package/dist/cmd/transfer.js +3 -4
- package/dist/deploy/index.js +6 -6
- package/dist/deploy/migration.js +25 -15
- package/dist/deploy/toml.js +2 -3
- package/dist/deploy/util.js +1 -2
- package/dist/molecule/mol.js +20 -10
- package/dist/node/init-chain.js +1 -2
- package/dist/node/install.js +26 -17
- package/dist/scripts/gen.js +21 -12
- package/dist/scripts/private.js +1 -2
- package/dist/scripts/util.js +18 -9
- package/dist/sdk/ckb.js +7 -7
- package/dist/template/offckb-config.js +17 -7
- package/dist/template/option.js +10 -4
- package/dist/tools/ckb-debugger.d.ts +1 -0
- package/dist/tools/ckb-debugger.js +15 -0
- package/dist/tools/ckb-tx-dumper.js +1 -2
- package/dist/tools/rpc-proxy.d.ts +0 -1
- package/dist/tools/rpc-proxy.js +1 -2
- package/dist/util/encoding.js +2 -3
- package/dist/util/fs.d.ts +1 -0
- package/dist/util/fs.js +34 -20
- package/dist/util/git.js +19 -10
- package/dist/util/link.js +1 -2
- package/dist/util/request.js +2 -2
- package/dist/util/validator.js +5 -6
- package/npm-shrinkwrap.json +4514 -0
- package/package.json +6 -4
package/dist/scripts/gen.js
CHANGED
|
@@ -15,18 +15,31 @@ 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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.genSystemScripts = genSystemScripts;
|
|
40
|
+
exports.genSystemScriptsJsonFile = genSystemScriptsJsonFile;
|
|
41
|
+
exports.genMyScripts = genMyScripts;
|
|
42
|
+
exports.genMyScriptsJsonFile = genMyScriptsJsonFile;
|
|
30
43
|
const fs = __importStar(require("fs"));
|
|
31
44
|
const public_1 = __importDefault(require("./public"));
|
|
32
45
|
const system_scripts_1 = require("../cmd/system-scripts");
|
|
@@ -45,13 +58,11 @@ function genSystemScripts() {
|
|
|
45
58
|
}
|
|
46
59
|
return null;
|
|
47
60
|
}
|
|
48
|
-
exports.genSystemScripts = genSystemScripts;
|
|
49
61
|
function genSystemScriptsJsonFile(filePath) {
|
|
50
62
|
const scripts = genSystemScripts();
|
|
51
63
|
fs.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
|
|
52
64
|
fs.writeFileSync(filePath, JSON.stringify(scripts, null, 2));
|
|
53
65
|
}
|
|
54
|
-
exports.genSystemScriptsJsonFile = genSystemScriptsJsonFile;
|
|
55
66
|
function genMyScripts() {
|
|
56
67
|
const networkMyScripts = {
|
|
57
68
|
devnet: (0, util_1.readUserDeployedScriptsInfo)(base_1.Network.devnet),
|
|
@@ -60,10 +71,8 @@ function genMyScripts() {
|
|
|
60
71
|
};
|
|
61
72
|
return networkMyScripts;
|
|
62
73
|
}
|
|
63
|
-
exports.genMyScripts = genMyScripts;
|
|
64
74
|
function genMyScriptsJsonFile(filePath) {
|
|
65
75
|
const scripts = genMyScripts();
|
|
66
76
|
fs.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
|
|
67
77
|
fs.writeFileSync(filePath, JSON.stringify(scripts, null, 2));
|
|
68
78
|
}
|
|
69
|
-
exports.genMyScriptsJsonFile = genMyScriptsJsonFile;
|
package/dist/scripts/private.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildCCCDevnetKnownScripts =
|
|
3
|
+
exports.buildCCCDevnetKnownScripts = buildCCCDevnetKnownScripts;
|
|
4
4
|
//todo: extract getSystemScriptsFromListHashes/toCCCKnownScripts from cmd folder
|
|
5
5
|
const system_scripts_1 = require("../cmd/system-scripts");
|
|
6
6
|
function buildCCCDevnetKnownScripts() {
|
|
@@ -11,4 +11,3 @@ function buildCCCDevnetKnownScripts() {
|
|
|
11
11
|
const devnetKnownScripts = (0, system_scripts_1.toCCCKnownScripts)(devnetSystemScripts);
|
|
12
12
|
return devnetKnownScripts;
|
|
13
13
|
}
|
|
14
|
-
exports.buildCCCDevnetKnownScripts = buildCCCDevnetKnownScripts;
|
package/dist/scripts/util.js
CHANGED
|
@@ -15,15 +15,25 @@ 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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.readUserDeployedScriptsInfo =
|
|
36
|
+
exports.readUserDeployedScriptsInfo = readUserDeployedScriptsInfo;
|
|
27
37
|
const fs = __importStar(require("fs"));
|
|
28
38
|
const util_1 = require("../deploy/util");
|
|
29
39
|
const migration_1 = require("../deploy/migration");
|
|
@@ -81,4 +91,3 @@ function readUserDeployedScriptsInfo(network) {
|
|
|
81
91
|
}
|
|
82
92
|
return deployedScriptsInfo;
|
|
83
93
|
}
|
|
84
|
-
exports.readUserDeployedScriptsInfo = readUserDeployedScriptsInfo;
|
package/dist/sdk/ckb.js
CHANGED
|
@@ -63,8 +63,8 @@ class CKB {
|
|
|
63
63
|
return address.toString();
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
waitForTxConfirm(
|
|
67
|
-
return __awaiter(this,
|
|
66
|
+
waitForTxConfirm(txHash_1) {
|
|
67
|
+
return __awaiter(this, arguments, void 0, function* (txHash, timeout = 60000) {
|
|
68
68
|
const query = () => __awaiter(this, void 0, void 0, function* () {
|
|
69
69
|
const res = yield this.client.getTransactionNoCache(txHash);
|
|
70
70
|
if (res && res.status === 'committed') {
|
|
@@ -104,8 +104,8 @@ class CKB {
|
|
|
104
104
|
return balanceInCKB;
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
transfer(
|
|
108
|
-
return __awaiter(this,
|
|
107
|
+
transfer(_a) {
|
|
108
|
+
return __awaiter(this, arguments, void 0, function* ({ privateKey, toAddress, amountInCKB }) {
|
|
109
109
|
const signer = this.buildSigner(privateKey);
|
|
110
110
|
const to = yield core_1.ccc.Address.fromString(toAddress, this.client);
|
|
111
111
|
const tx = core_1.ccc.Transaction.from({
|
|
@@ -122,8 +122,8 @@ class CKB {
|
|
|
122
122
|
return txHash;
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
transferAll(
|
|
126
|
-
return __awaiter(this,
|
|
125
|
+
transferAll(_a) {
|
|
126
|
+
return __awaiter(this, arguments, void 0, function* ({ privateKey, toAddress }) {
|
|
127
127
|
const signer = this.buildSigner(privateKey);
|
|
128
128
|
const to = yield core_1.ccc.Address.fromString(toAddress, this.client);
|
|
129
129
|
const balanceInCKB = yield this.balance((yield signer.getRecommendedAddressObj()).toString());
|
|
@@ -184,8 +184,8 @@ class CKB {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
upgradeTypeIdScript(scriptName, newScriptBinBytes, privateKey) {
|
|
187
|
-
var _a;
|
|
188
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
var _a;
|
|
189
189
|
const deploymentReceipt = migration_1.Migration.find(scriptName, this.network);
|
|
190
190
|
if (deploymentReceipt == null)
|
|
191
191
|
throw new Error("no migration file, can't be updated.");
|
|
@@ -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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
};
|
package/dist/template/option.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadBareTemplateOpts =
|
|
3
|
+
exports.loadBareTemplateOpts = loadBareTemplateOpts;
|
|
4
4
|
const templates = [
|
|
5
5
|
{
|
|
6
|
-
name: '
|
|
6
|
+
name: 'JS Script with Next.js fullstack template',
|
|
7
|
+
value: 'js-script-next-js',
|
|
8
|
+
description: 'A full-stack template with Next-js and ckb-js-vm script',
|
|
9
|
+
tag: ['next.js', 'tailwindcss', 'ckb-js-vm', 'typescript'],
|
|
10
|
+
author: 'retric@cryptape.com',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'Rust Script with Remix-Vite fullstack template',
|
|
7
14
|
value: 'remix-vite-template',
|
|
8
15
|
description: 'A full-stack template with Remix-vite and ckb-script-templates',
|
|
9
16
|
tag: ['remix', 'vite', 'tailwindcss', 'ckb-script-templates', 'typescript', 'rust'],
|
|
10
17
|
author: 'retric@cryptape.com',
|
|
11
18
|
},
|
|
12
19
|
{
|
|
13
|
-
name: 'Next.js
|
|
20
|
+
name: 'Rust Script with Next.js fullstack template',
|
|
14
21
|
value: 'next-js-template',
|
|
15
22
|
description: 'A full-stack template with Next.js framework and ckb-script-templates',
|
|
16
23
|
tag: ['next.js', 'tailwindcss', 'ckb-script-templates', 'typescript', 'rust'],
|
|
@@ -20,4 +27,3 @@ const templates = [
|
|
|
20
27
|
function loadBareTemplateOpts() {
|
|
21
28
|
return templates;
|
|
22
29
|
}
|
|
23
|
-
exports.loadBareTemplateOpts = loadBareTemplateOpts;
|
|
@@ -8,5 +8,6 @@ export declare class CKBDebugger {
|
|
|
8
8
|
static runRaw(options: string): void;
|
|
9
9
|
static runTxCellScript({ fullTxJsonFilePath, cellIndex, cellType, scriptGroupType }: DebugOption): void;
|
|
10
10
|
static isBinaryInstalled(): boolean;
|
|
11
|
+
static isBinaryVersionValid(): boolean;
|
|
11
12
|
static installCKBDebugger(): void;
|
|
12
13
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CKBDebugger = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
|
+
const setting_1 = require("../cfg/setting");
|
|
5
6
|
class CKBDebugger {
|
|
6
7
|
static runRaw(options) {
|
|
7
8
|
const command = `ckb-debugger ${options}`;
|
|
@@ -15,6 +16,20 @@ class CKBDebugger {
|
|
|
15
16
|
const result = (0, child_process_1.spawnSync)('ckb-debugger', ['--version'], { stdio: 'ignore' });
|
|
16
17
|
return result.status === 0;
|
|
17
18
|
}
|
|
19
|
+
static isBinaryVersionValid() {
|
|
20
|
+
const result = (0, child_process_1.spawnSync)('ckb-debugger', ['--version']);
|
|
21
|
+
if (result.status !== 0) {
|
|
22
|
+
console.error('ckb-debugger is not installed');
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const version = result.stdout.toString().split(' ')[1];
|
|
26
|
+
const settings = (0, setting_1.readSettings)();
|
|
27
|
+
if (version < settings.tools.ckbDebugger.minVersion) {
|
|
28
|
+
console.error(`ckb-debugger version ${version} is less than ${settings.tools.ckbDebugger.minVersion}`);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
18
33
|
static installCKBDebugger() {
|
|
19
34
|
const command = `cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger`;
|
|
20
35
|
try {
|
|
@@ -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 =
|
|
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;
|
package/dist/tools/rpc-proxy.js
CHANGED
|
@@ -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 =
|
|
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;
|
package/dist/util/encoding.js
CHANGED
|
@@ -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.
|
|
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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
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
|
-
|
|
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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
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 =
|
|
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;
|
package/dist/util/request.js
CHANGED
|
@@ -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(
|
|
21
|
-
return __awaiter(this,
|
|
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 {
|
package/dist/util/validator.js
CHANGED
|
@@ -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.
|
|
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;
|