@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.
@@ -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
- console.log('\x1b[33mPlease run this command in Project directory\x1b[0m');
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
- console.log('\x1b[33mError loading metadata\x1b[0m');
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
+ }
@@ -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
- console.log('No assets directory found.');
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
- console.log(`MD5: ${digest}`);
87
- console.log(`Tarball created at ${absOutputPath}`);
88
- console.log('cleaning up...');
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
- console.error(`Failed to create tarball: ${err.message}`);
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.16.2",
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"