@offckb/cli 0.3.4 → 0.4.0-canary-113bf31.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.
- package/README.md +17 -138
- package/build/build/Release/cpufeatures.node +0 -0
- package/build/build/Release/secp256k1.node +0 -0
- package/build/index.js +114977 -0
- package/package.json +12 -6
- package/dist/cfg/account.d.ts +0 -55
- package/dist/cfg/account.js +0 -66
- package/dist/cfg/env-path.d.ts +0 -9
- package/dist/cfg/env-path.js +0 -63
- package/dist/cfg/setting.d.ts +0 -67
- package/dist/cfg/setting.js +0 -147
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -224
- package/dist/cmd/accounts.d.ts +0 -1
- package/dist/cmd/accounts.js +0 -40
- package/dist/cmd/balance.d.ts +0 -4
- package/dist/cmd/balance.js +0 -25
- package/dist/cmd/clean.d.ts +0 -1
- package/dist/cmd/clean.js +0 -27
- package/dist/cmd/config.d.ts +0 -11
- package/dist/cmd/config.js +0 -107
- package/dist/cmd/create.d.ts +0 -7
- package/dist/cmd/create.js +0 -77
- package/dist/cmd/debug.d.ts +0 -16
- package/dist/cmd/debug.js +0 -120
- package/dist/cmd/deploy.d.ts +0 -9
- package/dist/cmd/deploy.js +0 -76
- package/dist/cmd/deposit.d.ts +0 -5
- package/dist/cmd/deposit.js +0 -97
- package/dist/cmd/inject-config.d.ts +0 -4
- package/dist/cmd/inject-config.js +0 -72
- package/dist/cmd/list-hashes.d.ts +0 -25
- package/dist/cmd/list-hashes.js +0 -39
- package/dist/cmd/mol.d.ts +0 -2
- package/dist/cmd/mol.js +0 -38
- package/dist/cmd/my-scripts.d.ts +0 -4
- package/dist/cmd/my-scripts.js +0 -24
- package/dist/cmd/node.d.ts +0 -5
- package/dist/cmd/node.js +0 -70
- package/dist/cmd/proxy-rpc.d.ts +0 -7
- package/dist/cmd/proxy-rpc.js +0 -22
- package/dist/cmd/repl.d.ts +0 -17
- package/dist/cmd/repl.js +0 -111
- package/dist/cmd/sync-scripts.d.ts +0 -4
- package/dist/cmd/sync-scripts.js +0 -30
- package/dist/cmd/system-scripts.d.ts +0 -99
- package/dist/cmd/system-scripts.js +0 -301
- package/dist/cmd/transfer-all.d.ts +0 -6
- package/dist/cmd/transfer-all.js +0 -37
- package/dist/cmd/transfer.d.ts +0 -6
- package/dist/cmd/transfer.js +0 -38
- package/dist/deploy/index.d.ts +0 -18
- package/dist/deploy/index.js +0 -127
- package/dist/deploy/migration.d.ts +0 -50
- package/dist/deploy/migration.js +0 -178
- package/dist/deploy/toml.d.ts +0 -42
- package/dist/deploy/toml.js +0 -59
- package/dist/deploy/util.d.ts +0 -2
- package/dist/deploy/util.js +0 -18
- package/dist/molecule/mol.d.ts +0 -9
- package/dist/molecule/mol.js +0 -149
- package/dist/node/init-chain.d.ts +0 -1
- package/dist/node/init-chain.js +0 -40
- package/dist/node/install.d.ts +0 -11
- package/dist/node/install.js +0 -235
- package/dist/scripts/gen.d.ts +0 -5
- package/dist/scripts/gen.js +0 -78
- package/dist/scripts/private.d.ts +0 -4
- package/dist/scripts/private.js +0 -13
- package/dist/scripts/public.d.ts +0 -8
- package/dist/scripts/public.js +0 -229
- package/dist/scripts/type.d.ts +0 -51
- package/dist/scripts/type.js +0 -19
- package/dist/scripts/util.d.ts +0 -3
- package/dist/scripts/util.js +0 -93
- package/dist/sdk/ckb.d.ts +0 -37
- package/dist/sdk/ckb.js +0 -254
- package/dist/sdk/network.d.ts +0 -17
- package/dist/sdk/network.js +0 -22
- package/dist/template/offckb-config.d.ts +0 -4
- package/dist/template/offckb-config.js +0 -70
- package/dist/template/option.d.ts +0 -8
- package/dist/template/option.js +0 -22
- package/dist/tools/ckb-debugger.d.ts +0 -12
- package/dist/tools/ckb-debugger.js +0 -31
- package/dist/tools/ckb-tx-dumper.d.ts +0 -6
- package/dist/tools/ckb-tx-dumper.js +0 -20
- package/dist/tools/moleculec-es.d.ts +0 -8
- package/dist/tools/moleculec-es.js +0 -100
- package/dist/tools/moleculec-go.d.ts +0 -5
- package/dist/tools/moleculec-go.js +0 -35
- package/dist/tools/moleculec-rust.d.ts +0 -5
- package/dist/tools/moleculec-rust.js +0 -35
- package/dist/tools/rpc-proxy.d.ts +0 -7
- package/dist/tools/rpc-proxy.js +0 -90
- package/dist/type/base.d.ts +0 -11
- package/dist/type/base.js +0 -10
- package/dist/util/encoding.d.ts +0 -2
- package/dist/util/encoding.js +0 -24
- package/dist/util/fs.d.ts +0 -13
- package/dist/util/fs.js +0 -218
- package/dist/util/git.d.ts +0 -2
- package/dist/util/git.js +0 -106
- package/dist/util/link.d.ts +0 -1
- package/dist/util/link.js +0 -6
- package/dist/util/request.d.ts +0 -8
- package/dist/util/request.js +0 -61
- package/dist/util/validator.d.ts +0 -5
- package/dist/util/validator.js +0 -67
- package/npm-shrinkwrap.json +0 -4514
package/dist/util/git.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
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
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.isGitInstalled = isGitInstalled;
|
|
37
|
-
exports.gitCloneAndDownloadFolderSync = gitCloneAndDownloadFolderSync;
|
|
38
|
-
const child_process_1 = require("child_process");
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const fs_1 = require("./fs");
|
|
42
|
-
const setting_1 = require("../cfg/setting");
|
|
43
|
-
function isGitInstalled() {
|
|
44
|
-
try {
|
|
45
|
-
(0, child_process_1.execSync)('git --version');
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function gitCloneAndDownloadFolderSync(repoUrl, branch, subFolderName, targetPath) {
|
|
53
|
-
console.log('start cloning the dapp template..');
|
|
54
|
-
const settings = (0, setting_1.readSettings)();
|
|
55
|
-
const tempFolder = path.resolve(settings.dappTemplate.downloadPath, 'temp-clone-folder');
|
|
56
|
-
if (!isGitInstalled()) {
|
|
57
|
-
console.log('Git is not installed, please check https://git-scm.com/');
|
|
58
|
-
return process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
// Empty the temp folder if it exists
|
|
61
|
-
if (fs.existsSync(tempFolder)) {
|
|
62
|
-
fs.rmSync(tempFolder, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
// Create the temp folder
|
|
65
|
-
fs.mkdirSync(tempFolder, { recursive: true });
|
|
66
|
-
// Clone the repository
|
|
67
|
-
try {
|
|
68
|
-
const cloneCommand = `git clone -n --depth=1 --filter=tree:0 --single-branch --branch ${branch} ${repoUrl} ${tempFolder}`;
|
|
69
|
-
console.log(cloneCommand);
|
|
70
|
-
(0, child_process_1.execSync)(cloneCommand);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
console.error('Error:', error);
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
// Set up sparse-checkout for the subfolder
|
|
77
|
-
try {
|
|
78
|
-
console.log(subFolderName, tempFolder);
|
|
79
|
-
(0, child_process_1.execSync)('git sparse-checkout init --cone', { cwd: tempFolder });
|
|
80
|
-
// Use the full path for sparse-checkout
|
|
81
|
-
(0, child_process_1.execSync)(`git sparse-checkout set "${subFolderName}"`, { cwd: tempFolder });
|
|
82
|
-
(0, child_process_1.execSync)('git checkout', { cwd: tempFolder });
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
console.error('Error:', error);
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
// Ensure targetPath exists and is a directory
|
|
89
|
-
if (!fs.existsSync(targetPath) || !fs.statSync(targetPath).isDirectory()) {
|
|
90
|
-
fs.mkdirSync(targetPath, { recursive: true });
|
|
91
|
-
}
|
|
92
|
-
// Copy the specific subfolder
|
|
93
|
-
const source = path.resolve(tempFolder, subFolderName);
|
|
94
|
-
if (fs.existsSync(source)) {
|
|
95
|
-
(0, fs_1.copyFolderSync)(source, targetPath);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
console.error(`Subfolder ${subFolderName} not found in the cloned repository ${source}.`);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
// Empty the temp folder if it exists
|
|
102
|
-
if (fs.existsSync(tempFolder)) {
|
|
103
|
-
fs.rmSync(tempFolder, { recursive: true });
|
|
104
|
-
}
|
|
105
|
-
console.log(`Folder ${subFolderName} downloaded successfully from ${repoUrl} and moved to ${targetPath}`);
|
|
106
|
-
}
|
package/dist/util/link.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function buildTestnetTxLink(txHash: string): string;
|
package/dist/util/link.js
DELETED
package/dist/util/request.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ProxyConfig } from '../cfg/setting';
|
|
2
|
-
import fetch, { RequestInit } from 'node-fetch';
|
|
3
|
-
export declare class Request {
|
|
4
|
-
static proxy: ProxyConfig | undefined;
|
|
5
|
-
static send(url: string, options?: RequestInit): Promise<fetch.Response>;
|
|
6
|
-
static parseProxyUrl(url: string): ProxyConfig;
|
|
7
|
-
static proxyConfigToUrl(proxy: ProxyConfig): string;
|
|
8
|
-
}
|
package/dist/util/request.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.Request = void 0;
|
|
16
|
-
const setting_1 = require("../cfg/setting");
|
|
17
|
-
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
18
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
19
|
-
class Request {
|
|
20
|
-
static send(url_1) {
|
|
21
|
-
return __awaiter(this, arguments, void 0, function* (url, options = {}) {
|
|
22
|
-
const agent = this.proxy ? new https_proxy_agent_1.HttpsProxyAgent(this.proxyConfigToUrl(this.proxy)) : undefined;
|
|
23
|
-
const opt = Object.assign({ agent }, options);
|
|
24
|
-
try {
|
|
25
|
-
const response = yield (0, node_fetch_1.default)(url, opt);
|
|
26
|
-
if (!response.ok) {
|
|
27
|
-
throw new Error(`HTTP error! Status: ${response.status}, URL: ${response.url}`);
|
|
28
|
-
}
|
|
29
|
-
return yield response;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
throw new Error(`fetch error! ${error.message}`);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
static parseProxyUrl(url) {
|
|
37
|
-
const parsedUrl = new URL(url);
|
|
38
|
-
const proxyConfig = {
|
|
39
|
-
host: parsedUrl.hostname,
|
|
40
|
-
port: parseInt(parsedUrl.port, 10),
|
|
41
|
-
};
|
|
42
|
-
if (parsedUrl.username || parsedUrl.password) {
|
|
43
|
-
proxyConfig.auth = {
|
|
44
|
-
username: parsedUrl.username,
|
|
45
|
-
password: parsedUrl.password,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
if (parsedUrl.protocol) {
|
|
49
|
-
proxyConfig.protocol = parsedUrl.protocol.slice(0, -1); // Remove the trailing ':'
|
|
50
|
-
}
|
|
51
|
-
return proxyConfig;
|
|
52
|
-
}
|
|
53
|
-
static proxyConfigToUrl(proxy) {
|
|
54
|
-
const protocol = proxy.protocol ? `${proxy.protocol}://` : '';
|
|
55
|
-
const auth = proxy.auth ? `${proxy.auth.username}:${proxy.auth.password}@` : '';
|
|
56
|
-
const port = proxy.port ? `:${proxy.port}` : '';
|
|
57
|
-
return `${protocol}${auth}${proxy.host}${port}`;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.Request = Request;
|
|
61
|
-
Request.proxy = (0, setting_1.readSettings)().proxy;
|
package/dist/util/validator.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function validateTypescriptWorkspace(): void;
|
|
2
|
-
export declare function validateExecDappEnvironment(): void;
|
|
3
|
-
export declare function isValidNetworkString(network: string): boolean;
|
|
4
|
-
export declare function validateNetworkOpt(network: string): void;
|
|
5
|
-
export declare function isValidVersion(version: unknown): boolean;
|
package/dist/util/validator.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateTypescriptWorkspace = validateTypescriptWorkspace;
|
|
7
|
-
exports.validateExecDappEnvironment = validateExecDappEnvironment;
|
|
8
|
-
exports.isValidNetworkString = isValidNetworkString;
|
|
9
|
-
exports.validateNetworkOpt = validateNetworkOpt;
|
|
10
|
-
exports.isValidVersion = isValidVersion;
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const fs_1 = __importDefault(require("fs"));
|
|
13
|
-
const base_1 = require("../type/base");
|
|
14
|
-
function validateTypescriptWorkspace() {
|
|
15
|
-
const cwd = process.cwd();
|
|
16
|
-
// Check if package.json exists
|
|
17
|
-
const packageJsonPath = path_1.default.join(cwd, 'package.json');
|
|
18
|
-
if (!fs_1.default.existsSync(packageJsonPath)) {
|
|
19
|
-
throw new Error('package.json not found in the current directory');
|
|
20
|
-
}
|
|
21
|
-
// Check if tsconfig.json exists
|
|
22
|
-
const tsconfig = path_1.default.join(cwd, 'tsconfig.json');
|
|
23
|
-
if (!fs_1.default.existsSync(tsconfig)) {
|
|
24
|
-
throw new Error('tsconfig.json not found in the current directory');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function validateExecDappEnvironment() {
|
|
28
|
-
const cwd = process.cwd();
|
|
29
|
-
// Check if package.json and tsconfig.json exists
|
|
30
|
-
validateTypescriptWorkspace();
|
|
31
|
-
// Check if offckb.config.ts exists
|
|
32
|
-
const offCKBConfigPath = path_1.default.resolve(cwd, 'offckb.config.ts');
|
|
33
|
-
if (!fs_1.default.existsSync(offCKBConfigPath)) {
|
|
34
|
-
throw new Error('offckb.config.ts not found in the current directory');
|
|
35
|
-
}
|
|
36
|
-
// Read offckb.config.ts file
|
|
37
|
-
const offCKBConfigFile = fs_1.default.readFileSync(offCKBConfigPath, 'utf-8');
|
|
38
|
-
// Check if offckb.config.ts contains OffCKBConfig interface
|
|
39
|
-
if (!offCKBConfigFile.includes('export interface OffCKBConfig')) {
|
|
40
|
-
throw new Error('offckb.config.ts does not contain OffCKBConfig interface');
|
|
41
|
-
}
|
|
42
|
-
// Check if OffCKBConfig is exported
|
|
43
|
-
if (!offCKBConfigFile.includes('export default offCKBConfig;')) {
|
|
44
|
-
throw new Error('OffCKBConfig interface is not exported in offckb.config.ts');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function isValidNetworkString(network) {
|
|
48
|
-
return ['devnet', 'testnet', 'mainnet'].includes(network);
|
|
49
|
-
}
|
|
50
|
-
function validateNetworkOpt(network) {
|
|
51
|
-
if (!isValidNetworkString(network)) {
|
|
52
|
-
throw new Error('invalid network option, ' + network);
|
|
53
|
-
}
|
|
54
|
-
if (network === base_1.Network.mainnet) {
|
|
55
|
-
console.log('Mainnet not support yet. Please use CKB-CLI to operate on mainnet for better security. Check https://github.com/nervosnetwork/ckb-cli');
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function isValidVersion(version) {
|
|
60
|
-
if (typeof version !== 'string') {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
// Regular expression to match version strings like X.Y.Z or vX.Y.Z-rcN
|
|
64
|
-
const versionRegex = /^v?\d+\.\d+\.\d+(-rc\d+)?$/;
|
|
65
|
-
// Test the version against the regex
|
|
66
|
-
return versionRegex.test(version);
|
|
67
|
-
}
|