@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
|
@@ -1,100 +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.MoleculecES = void 0;
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const setting_1 = require("../cfg/setting");
|
|
18
|
-
const install_1 = require("../node/install");
|
|
19
|
-
const fs_1 = __importDefault(require("fs"));
|
|
20
|
-
const os_1 = __importDefault(require("os"));
|
|
21
|
-
const request_1 = require("../util/request");
|
|
22
|
-
const encoding_1 = require("../util/encoding");
|
|
23
|
-
class MoleculecES {
|
|
24
|
-
static isBinaryInstalled() {
|
|
25
|
-
return fs_1.default.existsSync(this.binPath);
|
|
26
|
-
}
|
|
27
|
-
static installMoleculeES(version) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const arch = getArch();
|
|
30
|
-
const osname = getOS();
|
|
31
|
-
const fileName = `moleculec-es-v${version}-${osname}-${arch}.tar.gz`;
|
|
32
|
-
try {
|
|
33
|
-
const tempFilePath = path_1.default.join(os_1.default.tmpdir(), fileName);
|
|
34
|
-
yield MoleculecES.downloadAndSaveMoleculeES(version, tempFilePath);
|
|
35
|
-
// Unzip the file
|
|
36
|
-
const extractDir = path_1.default.join((0, setting_1.readSettings)().tools.moleculeES.downloadPath, `molecule-es_v${version}`);
|
|
37
|
-
yield (0, install_1.unZipFile)(tempFilePath, extractDir, true);
|
|
38
|
-
// Install the extracted files
|
|
39
|
-
const sourcePath = path_1.default.join(extractDir, 'moleculec-es');
|
|
40
|
-
const targetPath = MoleculecES.binPath;
|
|
41
|
-
fs_1.default.mkdirSync(path_1.default.dirname(targetPath), { recursive: true });
|
|
42
|
-
fs_1.default.copyFileSync(sourcePath, targetPath);
|
|
43
|
-
fs_1.default.chmodSync(targetPath, '755'); // Make the binary executable
|
|
44
|
-
console.log(`Molecule-ES ${version} installed successfully.`);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.error('Error installing Molecule-ES:', error);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
static get binPath() {
|
|
52
|
-
return path_1.default.join((0, setting_1.readSettings)().tools.moleculeES.binFolder, 'moleculec-es');
|
|
53
|
-
}
|
|
54
|
-
static get bin() {
|
|
55
|
-
return (0, encoding_1.encodeBinPathForTerminal)(this.binPath);
|
|
56
|
-
}
|
|
57
|
-
static downloadAndSaveMoleculeES(version, tempFilePath) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const downloadURL = MoleculecES.buildDownloadUrl(version);
|
|
60
|
-
const response = yield request_1.Request.send(downloadURL);
|
|
61
|
-
const arrayBuffer = yield response.arrayBuffer();
|
|
62
|
-
fs_1.default.writeFileSync(tempFilePath, Buffer.from(arrayBuffer));
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
static buildDownloadUrl(version) {
|
|
66
|
-
const osName = getOS();
|
|
67
|
-
const archName = getArch();
|
|
68
|
-
// https://github.com/nervosnetwork/moleculec-es/releases/download/0.4.6/moleculec-es_0.4.6_darwin_arm64.tar.gz
|
|
69
|
-
// https://github.com/nervosnetwork/moleculec-es/releases/download/0.4.6/moleculec-es_0.4.6_darwin_amd64.tar.gz
|
|
70
|
-
return `https://github.com/nervosnetwork/moleculec-es/releases/download/${version}/moleculec-es_${version}_${osName}_${archName}.tar.gz`;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.MoleculecES = MoleculecES;
|
|
74
|
-
function getOS() {
|
|
75
|
-
const platform = os_1.default.platform();
|
|
76
|
-
if (platform === 'darwin') {
|
|
77
|
-
return 'darwin';
|
|
78
|
-
}
|
|
79
|
-
else if (platform === 'linux') {
|
|
80
|
-
return 'linux';
|
|
81
|
-
}
|
|
82
|
-
else if (platform === 'win32') {
|
|
83
|
-
return 'windows';
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
throw new Error('Unsupported operating system');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function getArch() {
|
|
90
|
-
const arch = os_1.default.arch();
|
|
91
|
-
if (arch === 'x64') {
|
|
92
|
-
return 'amd64';
|
|
93
|
-
}
|
|
94
|
-
else if (arch === 'arm64') {
|
|
95
|
-
return 'arm64';
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
throw new Error('Unsupported architecture');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MoleculecGo = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
class MoleculecGo {
|
|
6
|
-
static isBinaryInstalled() {
|
|
7
|
-
const result = (0, child_process_1.spawnSync)('moleculec-go', ['--version'], { stdio: 'ignore' });
|
|
8
|
-
return result.status === 0 && this.checkVersion();
|
|
9
|
-
}
|
|
10
|
-
static checkVersion() {
|
|
11
|
-
// cmd: moleculec-go --version
|
|
12
|
-
// output: Moleculec Plugin 0.1.11
|
|
13
|
-
// check if the version is greater than or equal to 0.1.11
|
|
14
|
-
const result = (0, child_process_1.execSync)('moleculec-go --version').toString();
|
|
15
|
-
const version = result.split(' ')[2];
|
|
16
|
-
const versionNumber = version.split('.');
|
|
17
|
-
const major = parseInt(versionNumber[0]);
|
|
18
|
-
const minor = parseInt(versionNumber[1]);
|
|
19
|
-
const patch = parseInt(versionNumber[2]);
|
|
20
|
-
return major > 0 || (major === 0 && (minor > 1 || (minor === 1 && patch >= 11)));
|
|
21
|
-
}
|
|
22
|
-
static installBinary() {
|
|
23
|
-
const command = `cargo install moleculec-go`;
|
|
24
|
-
try {
|
|
25
|
-
console.log('Installing ckb-moleculec-go...');
|
|
26
|
-
(0, child_process_1.execSync)(command);
|
|
27
|
-
console.log('ckb-moleculec-go installed successfully.');
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.error('Failed to install ckb-moleculec-go:', error);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.MoleculecGo = MoleculecGo;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MoleculecRust = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
class MoleculecRust {
|
|
6
|
-
static isBinaryInstalled() {
|
|
7
|
-
const result = (0, child_process_1.spawnSync)('moleculec', ['--version'], { stdio: 'ignore' });
|
|
8
|
-
return result.status === 0 && this.checkVersion();
|
|
9
|
-
}
|
|
10
|
-
static checkVersion() {
|
|
11
|
-
// cmd: moleculec --version
|
|
12
|
-
// output: Moleculec 0.8.0
|
|
13
|
-
// check if the version is greater than or equal to 0.8.0
|
|
14
|
-
const result = (0, child_process_1.execSync)('moleculec --version').toString();
|
|
15
|
-
const version = result.split(' ')[1];
|
|
16
|
-
const versionNumber = version.split('.');
|
|
17
|
-
const major = parseInt(versionNumber[0]);
|
|
18
|
-
const minor = parseInt(versionNumber[1]);
|
|
19
|
-
const patch = parseInt(versionNumber[2]);
|
|
20
|
-
return major > 0 || (major === 0 && (minor > 8 || (minor === 8 && patch >= 0)));
|
|
21
|
-
}
|
|
22
|
-
static installBinary() {
|
|
23
|
-
const command = `cargo install moleculec`;
|
|
24
|
-
try {
|
|
25
|
-
console.log('Installing ckb-moleculec...');
|
|
26
|
-
(0, child_process_1.execSync)(command);
|
|
27
|
-
console.log('ckb-moleculec installed successfully.');
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.error('Failed to install ckb-moleculec:', error);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.MoleculecRust = MoleculecRust;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import { Network } from '../type/base';
|
|
3
|
-
export declare function createRPCProxy(network: Network, targetRpcUrl: string, port: number): {
|
|
4
|
-
network: Network;
|
|
5
|
-
start: () => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
6
|
-
stop: () => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
7
|
-
};
|
package/dist/tools/rpc-proxy.js
DELETED
|
@@ -1,90 +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.createRPCProxy = createRPCProxy;
|
|
7
|
-
const http_proxy_1 = __importDefault(require("http-proxy"));
|
|
8
|
-
const http_1 = __importDefault(require("http"));
|
|
9
|
-
const base_1 = require("../type/base");
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const setting_1 = require("../cfg/setting");
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
// todo: if we use import this throws error in tsc building
|
|
14
|
-
const { cccA } = require('@ckb-ccc/core/advanced');
|
|
15
|
-
function createRPCProxy(network, targetRpcUrl, port) {
|
|
16
|
-
const proxy = http_proxy_1.default.createProxyServer({
|
|
17
|
-
target: targetRpcUrl, // Target RPC server
|
|
18
|
-
});
|
|
19
|
-
proxy.on('proxyReq', (_, req) => {
|
|
20
|
-
let reqData = '';
|
|
21
|
-
req.on('data', (chunk) => {
|
|
22
|
-
reqData += chunk;
|
|
23
|
-
});
|
|
24
|
-
req.on('end', () => {
|
|
25
|
-
try {
|
|
26
|
-
const jsonRpcContent = JSON.parse(reqData);
|
|
27
|
-
const method = jsonRpcContent.method;
|
|
28
|
-
const params = jsonRpcContent.params;
|
|
29
|
-
console.debug('RPC Req: ', method);
|
|
30
|
-
if (method === 'send_transaction') {
|
|
31
|
-
const tx = params[0];
|
|
32
|
-
// todo: record tx
|
|
33
|
-
if (network === base_1.Network.devnet) {
|
|
34
|
-
const cccTx = cccA.JsonRpcTransformers.transactionTo(tx);
|
|
35
|
-
const txHash = cccTx.hash();
|
|
36
|
-
const settings = (0, setting_1.readSettings)();
|
|
37
|
-
if (!fs_1.default.existsSync(settings.devnet.transactionsPath)) {
|
|
38
|
-
fs_1.default.mkdirSync(settings.devnet.transactionsPath);
|
|
39
|
-
}
|
|
40
|
-
const txFile = path_1.default.resolve(settings.devnet.transactionsPath, `${txHash}.json`);
|
|
41
|
-
fs_1.default.writeFileSync(txFile, JSON.stringify(tx, null, 2));
|
|
42
|
-
console.debug(`RPC Req: store tx ${txHash}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
console.error('Error parsing JSON-RPC content:', err);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
proxy.on('proxyRes', function (proxyRes, _req, _res) {
|
|
52
|
-
const body = [];
|
|
53
|
-
proxyRes.on('data', function (chunk) {
|
|
54
|
-
body.push(chunk);
|
|
55
|
-
});
|
|
56
|
-
proxyRes.on('end', function () {
|
|
57
|
-
const res = Buffer.concat(body).toString();
|
|
58
|
-
try {
|
|
59
|
-
const jsonRpcResponse = JSON.parse(res);
|
|
60
|
-
const error = jsonRpcResponse.error;
|
|
61
|
-
if (error) {
|
|
62
|
-
console.debug('RPC Response: ', jsonRpcResponse);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
console.error('Error parsing JSON-RPC content:', err);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
const server = http_1.default.createServer((req, res) => {
|
|
71
|
-
proxy.web(req, res, {}, (err) => {
|
|
72
|
-
if (err) {
|
|
73
|
-
console.error('Proxy error:', err);
|
|
74
|
-
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
75
|
-
res.end('Proxy error');
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
network,
|
|
81
|
-
start: () => {
|
|
82
|
-
return server.listen(port, () => {
|
|
83
|
-
console.debug(`CKB ${network} RPC Proxy server running on http://localhost:${port}`);
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
stop: () => {
|
|
87
|
-
return server.close();
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
package/dist/type/base.d.ts
DELETED
package/dist/type/base.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Network = void 0;
|
|
4
|
-
// network
|
|
5
|
-
var Network;
|
|
6
|
-
(function (Network) {
|
|
7
|
-
Network["devnet"] = "devnet";
|
|
8
|
-
Network["testnet"] = "testnet";
|
|
9
|
-
Network["mainnet"] = "mainnet";
|
|
10
|
-
})(Network || (exports.Network = Network = {}));
|
package/dist/util/encoding.d.ts
DELETED
package/dist/util/encoding.js
DELETED
|
@@ -1,24 +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.setUTF8EncodingForWindows = setUTF8EncodingForWindows;
|
|
7
|
-
exports.encodeBinPathForTerminal = encodeBinPathForTerminal;
|
|
8
|
-
const child_process_1 = require("child_process");
|
|
9
|
-
const os_1 = __importDefault(require("os"));
|
|
10
|
-
function setUTF8EncodingForWindows() {
|
|
11
|
-
if (os_1.default.platform() === 'win32') {
|
|
12
|
-
try {
|
|
13
|
-
(0, child_process_1.execSync)('chcp 65001');
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
console.error('Failed to set UTF-8 encoding for Windows terminal.', error.message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function encodeBinPathForTerminal(path) {
|
|
21
|
-
// some path contains space in the string
|
|
22
|
-
// this fix the space in the terminal
|
|
23
|
-
return `"${path}"`;
|
|
24
|
-
}
|
package/dist/util/fs.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare function isFolderExists(folderPath: string): boolean;
|
|
2
|
-
export declare function copyFolderSync(source: string, destination: string): void;
|
|
3
|
-
export declare function copyFileSync(source: string, target: string): void;
|
|
4
|
-
export declare function copyFilesWithExclusion(sourceDir: string, destinationDir: string, excludedFolders: string[]): Promise<void>;
|
|
5
|
-
export declare function copyRecursive(source: string, destination: string, excludedFolders: string[]): Promise<void>;
|
|
6
|
-
export declare function readFileToUint8Array(filePath: string): Promise<Uint8Array>;
|
|
7
|
-
export declare function getBinaryFilesFromPath(fileOrFolderPath: string): string[];
|
|
8
|
-
export declare function listBinaryFilesInFolder(folderPath: string): string[];
|
|
9
|
-
export declare function isBinaryFile(filePath: string): boolean;
|
|
10
|
-
export declare function getBinaryFileSizeInBytes(filePath: string): number;
|
|
11
|
-
export declare function isAbsolutePath(filePath: string): boolean;
|
|
12
|
-
export declare function findFileInFolder(folderPath: string, fileName: string): string | null;
|
|
13
|
-
export declare function getSubfolders(folderPath: string): string[];
|
package/dist/util/fs.js
DELETED
|
@@ -1,218 +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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
58
|
-
const fs = __importStar(require("fs"));
|
|
59
|
-
const path = __importStar(require("path"));
|
|
60
|
-
function isFolderExists(folderPath) {
|
|
61
|
-
try {
|
|
62
|
-
// Check if the path exists
|
|
63
|
-
fs.accessSync(folderPath, fs.constants.F_OK);
|
|
64
|
-
// Check if it's a directory
|
|
65
|
-
const stats = fs.statSync(folderPath);
|
|
66
|
-
return stats.isDirectory();
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
// If the access or stat fails, or if it's not a directory, return false
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function copyFolderSync(source, destination) {
|
|
74
|
-
if (!fs.existsSync(destination)) {
|
|
75
|
-
fs.mkdirSync(destination, { recursive: true });
|
|
76
|
-
}
|
|
77
|
-
const files = fs.readdirSync(source);
|
|
78
|
-
for (const file of files) {
|
|
79
|
-
const currentPath = path.join(source, file);
|
|
80
|
-
const destinationPath = path.join(destination, file);
|
|
81
|
-
if (fs.statSync(currentPath).isDirectory()) {
|
|
82
|
-
copyFolderSync(currentPath, destinationPath);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
fs.copyFileSync(currentPath, destinationPath);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function copyFileSync(source, target) {
|
|
90
|
-
let targetFile = target;
|
|
91
|
-
// If target is a directory, a new file with the same name will be created
|
|
92
|
-
if (fs.existsSync(target)) {
|
|
93
|
-
if (fs.lstatSync(target).isDirectory()) {
|
|
94
|
-
targetFile = path.join(target, path.basename(source));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
fs.writeFileSync(targetFile, fs.readFileSync(source));
|
|
98
|
-
}
|
|
99
|
-
function copyFilesWithExclusion(sourceDir, destinationDir, excludedFolders) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
try {
|
|
102
|
-
// Ensure the destination directory exists
|
|
103
|
-
yield fs.promises.mkdir(destinationDir, { recursive: true });
|
|
104
|
-
// Start copying recursively from the source directory
|
|
105
|
-
yield copyRecursive(sourceDir, destinationDir, excludedFolders);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
console.error('An error occurred during copying files:', error);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
// Function to recursively copy files and directories
|
|
113
|
-
function copyRecursive(source, destination, excludedFolders) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
// Get a list of all files and directories in the source directory
|
|
116
|
-
const files = yield fs.promises.readdir(source);
|
|
117
|
-
// Iterate through each file or directory
|
|
118
|
-
for (const file of files) {
|
|
119
|
-
const sourcePath = path.join(source, file);
|
|
120
|
-
const destPath = path.join(destination, file);
|
|
121
|
-
// Get the file's stats
|
|
122
|
-
const stats = yield fs.promises.stat(sourcePath);
|
|
123
|
-
// If it's a directory, recursively copy it (unless it's excluded)
|
|
124
|
-
if (stats.isDirectory()) {
|
|
125
|
-
if (excludedFolders.includes(file)) {
|
|
126
|
-
// Skipping directory: ${sourcePath}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
// Ensure destination directory exists before copying
|
|
130
|
-
yield fs.promises.mkdir(destPath, { recursive: true });
|
|
131
|
-
yield copyRecursive(sourcePath, destPath, excludedFolders);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
// Otherwise, copy the file
|
|
136
|
-
yield fs.promises.copyFile(sourcePath, destPath);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
function readFileToUint8Array(filePath) {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
return new Promise((resolve, reject) => {
|
|
144
|
-
fs.readFile(filePath, (err, data) => {
|
|
145
|
-
if (err) {
|
|
146
|
-
reject(err);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
resolve(new Uint8Array(data));
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function getBinaryFilesFromPath(fileOrFolderPath) {
|
|
155
|
-
if (!fs.existsSync(fileOrFolderPath)) {
|
|
156
|
-
throw new Error(`File or Folder not exits ${fileOrFolderPath}`);
|
|
157
|
-
}
|
|
158
|
-
// Check if the provided path is a directory
|
|
159
|
-
if (fs.lstatSync(fileOrFolderPath).isDirectory()) {
|
|
160
|
-
return listBinaryFilesInFolder(fileOrFolderPath);
|
|
161
|
-
}
|
|
162
|
-
if (fs.lstatSync(fileOrFolderPath).isFile() && isBinaryFile(fileOrFolderPath)) {
|
|
163
|
-
return [fileOrFolderPath];
|
|
164
|
-
}
|
|
165
|
-
throw new Error(`${fileOrFolderPath} is not a valid path to deploy scripts.`);
|
|
166
|
-
}
|
|
167
|
-
function listBinaryFilesInFolder(folderPath) {
|
|
168
|
-
// Check if the provided path is a directory
|
|
169
|
-
if (!fs.existsSync(folderPath) || !fs.lstatSync(folderPath).isDirectory()) {
|
|
170
|
-
throw new Error(`${folderPath} is not a valid directory.`);
|
|
171
|
-
}
|
|
172
|
-
// Read the contents of the directory
|
|
173
|
-
const files = fs.readdirSync(folderPath).map((f) => path.join(folderPath, f));
|
|
174
|
-
// Filter out only the binary files (assuming they have extensions like .exe, .bin, .dll, etc.)
|
|
175
|
-
const binaryFiles = files.filter((file) => fs.statSync(file).isFile() && isBinaryFile(file));
|
|
176
|
-
return binaryFiles;
|
|
177
|
-
}
|
|
178
|
-
// Function to check if a file is binary
|
|
179
|
-
function isBinaryFile(filePath) {
|
|
180
|
-
const buffer = fs.readFileSync(filePath);
|
|
181
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
182
|
-
// If any byte has a value greater than 127, it's likely a binary file
|
|
183
|
-
if (buffer[i] > 127) {
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
function getBinaryFileSizeInBytes(filePath) {
|
|
190
|
-
const stats = fs.statSync(filePath);
|
|
191
|
-
return stats.size;
|
|
192
|
-
}
|
|
193
|
-
function isAbsolutePath(filePath) {
|
|
194
|
-
return path.isAbsolute(filePath);
|
|
195
|
-
}
|
|
196
|
-
function findFileInFolder(folderPath, fileName) {
|
|
197
|
-
const files = fs.readdirSync(folderPath);
|
|
198
|
-
for (const file of files) {
|
|
199
|
-
const filePath = path.join(folderPath, file);
|
|
200
|
-
const stats = fs.statSync(filePath);
|
|
201
|
-
if (stats.isDirectory()) {
|
|
202
|
-
const foundFilePath = findFileInFolder(filePath, fileName);
|
|
203
|
-
if (foundFilePath) {
|
|
204
|
-
return foundFilePath;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else if (file === fileName) {
|
|
208
|
-
return filePath;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
function getSubfolders(folderPath) {
|
|
214
|
-
return fs.readdirSync(folderPath).filter((file) => {
|
|
215
|
-
const fullPath = path.join(folderPath, file);
|
|
216
|
-
return fs.statSync(fullPath).isDirectory();
|
|
217
|
-
});
|
|
218
|
-
}
|
package/dist/util/git.d.ts
DELETED