@airmoney-degn/airmoney-cli 0.16.2 → 0.18.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/dist/cli/create.js +48 -58
- package/dist/cli/dapp.js +97 -0
- package/dist/cli/demo.js +34 -28
- package/dist/cli/setup.js +21 -11
- package/dist/cli/upload.js +70 -63
- package/dist/cli/wallet.js +46 -30
- package/dist/config.json +1 -1
- package/dist/index.js +26 -11
- package/dist/service/airmoney/AirmoneyService.js +3 -2
- package/dist/service/dapp/DappService.js +162 -0
- package/dist/service/log/LogService.js +85 -0
- package/dist/service/port/PortManager.js +5 -4
- package/dist/service/serve/ServeOrchestrator.js +2 -1
- package/dist/service/simulator/BaseSimulatorService.js +5 -4
- package/dist/util/cryptoProcess.js +22 -21
- package/dist/util/env.js +44 -0
- package/dist/util/format.js +74 -0
- package/dist/util/metadata.js +3 -2
- package/dist/util/network.js +43 -0
- package/dist/util/tarball.js +6 -5
- package/package.json +3 -2
package/dist/util/metadata.js
CHANGED
|
@@ -38,11 +38,12 @@ exports.saveMetadata = saveMetadata;
|
|
|
38
38
|
exports.getPackageName = getPackageName;
|
|
39
39
|
const fs = __importStar(require("fs"));
|
|
40
40
|
const path = __importStar(require("path"));
|
|
41
|
+
const LogService_1 = require("../service/log/LogService");
|
|
41
42
|
function loadMetadata(projectPath = '.') {
|
|
42
43
|
try {
|
|
43
44
|
const filePath = path.join(projectPath, 'metadata.json');
|
|
44
45
|
if (!fs.existsSync(filePath)) {
|
|
45
|
-
|
|
46
|
+
(0, LogService_1.log)('Please run this command in Project directory').white();
|
|
46
47
|
return null;
|
|
47
48
|
}
|
|
48
49
|
const raw = fs.readFileSync(filePath, 'utf8');
|
|
@@ -50,7 +51,7 @@ function loadMetadata(projectPath = '.') {
|
|
|
50
51
|
return data;
|
|
51
52
|
}
|
|
52
53
|
catch (err) {
|
|
53
|
-
|
|
54
|
+
(0, LogService_1.log)('Error loading metadata').red();
|
|
54
55
|
return null;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Network utility functions
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validateNetwork = validateNetwork;
|
|
7
|
+
exports.networkToRpcUrl = networkToRpcUrl;
|
|
8
|
+
/**
|
|
9
|
+
* Validates that the network is either "devnet" or "mainnet"
|
|
10
|
+
* @param network - The network string to validate
|
|
11
|
+
* @returns true if valid, throws error if invalid
|
|
12
|
+
* @throws Error if network is invalid
|
|
13
|
+
*/
|
|
14
|
+
function validateNetwork(network) {
|
|
15
|
+
if (network) {
|
|
16
|
+
const normalized = network.toLowerCase().trim();
|
|
17
|
+
if (normalized !== 'devnet' && normalized !== 'mainnet') {
|
|
18
|
+
throw new Error(`Invalid network: ${network}. Must be "devnet" or "mainnet"`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
const networkMap = {
|
|
24
|
+
devnet: 'https://rpc-dev.air.fun/',
|
|
25
|
+
mainnet: 'https://rpc.air.fun/',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Maps network name to RPC URL
|
|
29
|
+
* Only accepts "devnet" or "mainnet"
|
|
30
|
+
* @param network - The network name
|
|
31
|
+
* @returns The RPC URL for the network
|
|
32
|
+
* @throws Error if network is invalid
|
|
33
|
+
*/
|
|
34
|
+
function networkToRpcUrl(network) {
|
|
35
|
+
if (!network) {
|
|
36
|
+
return networkMap.devnet;
|
|
37
|
+
}
|
|
38
|
+
const normalized = network.toLowerCase().trim();
|
|
39
|
+
if (!(normalized in networkMap)) {
|
|
40
|
+
throw new Error(`Invalid network: ${network}. Must be "devnet" or "mainnet"`);
|
|
41
|
+
}
|
|
42
|
+
return networkMap[normalized];
|
|
43
|
+
}
|
package/dist/util/tarball.js
CHANGED
|
@@ -42,6 +42,7 @@ const path = __importStar(require("path"));
|
|
|
42
42
|
const tar = __importStar(require("tar"));
|
|
43
43
|
const md5_1 = __importDefault(require("md5")); // default import
|
|
44
44
|
const metadata_1 = require("./metadata");
|
|
45
|
+
const LogService_1 = require("../service/log/LogService");
|
|
45
46
|
/**
|
|
46
47
|
* Reproduces the `pack()` logic, creating a tar.gz from the project's assets
|
|
47
48
|
*/
|
|
@@ -63,7 +64,7 @@ async function packProject(pkg, projectPath, assetsPath) {
|
|
|
63
64
|
files.push('@assets.tar.gz');
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
66
|
-
|
|
67
|
+
(0, LogService_1.log)('No assets directory found.').white();
|
|
67
68
|
}
|
|
68
69
|
// this is bad, but couldn't figure out how to get files from different folders without the absolute path messing with the tar file structure
|
|
69
70
|
await tar.create({
|
|
@@ -83,14 +84,14 @@ async function packProject(pkg, projectPath, assetsPath) {
|
|
|
83
84
|
// read it in memory for MD5
|
|
84
85
|
const buffer = fs.readFileSync(absOutputPath);
|
|
85
86
|
const digest = (0, md5_1.default)(buffer);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
(0, LogService_1.log)(`MD5: ${digest}`).white();
|
|
88
|
+
(0, LogService_1.log)(`Tarball created at ${absOutputPath}`).white();
|
|
89
|
+
(0, LogService_1.log)('cleaning up...').white();
|
|
89
90
|
fs.rmSync('projectFiles.tar.gz');
|
|
90
91
|
fs.rmSync('assets.tar.gz');
|
|
91
92
|
}
|
|
92
93
|
catch (err) {
|
|
93
|
-
|
|
94
|
+
(0, LogService_1.log)(`Failed to create tarball: ${err.message}`).red();
|
|
94
95
|
if (fs.existsSync('projectFiles.tar.gz'))
|
|
95
96
|
fs.rmSync('projectFiles.tar.gz');
|
|
96
97
|
if (fs.existsSync('assets.tar.gz'))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airmoney-degn/airmoney-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "airmoney-cli is a command-line interface tool designed to facilitate the development and management of decentralized applications (DApps) for Airmoney.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"version": "changeset version",
|
|
17
17
|
"changeset": "changeset",
|
|
18
18
|
"bump": "changeset && changeset version",
|
|
19
|
-
"update-version": "node scripts/update-version.js"
|
|
19
|
+
"update-version": "node scripts/update-version.js",
|
|
20
|
+
"check-types": "tsc --noEmit"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|
|
22
23
|
"CLI"
|