@airmoney-degn/airmoney-cli 0.10.7 → 0.10.9

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.
Binary file
Binary file
Binary file
Binary file
package/dist/cli/serve.js CHANGED
@@ -149,11 +149,24 @@ async function serveCommand(noBrowser, locationFolder, appUrl) {
149
149
  return;
150
150
  }
151
151
  });
152
+ // const s = createServer({})
153
+ // s.listen(5050)
154
+ let isAvailable = await (0, server_1.isPortAvailable)(airmoneyServicePort);
155
+ if (isAvailable == false) {
156
+ console.error(`ERROR: Port ${airmoneyServicePort} used by Airmoney Service is already in use`);
157
+ process.exit();
158
+ }
152
159
  const airmoneyServiceServer = airmoneyServiceExpress.listen(airmoneyServicePort, () => {
153
160
  const url = `http://localhost:${airmoneyServicePort}`;
154
161
  console.log(`Starting airmoney service server at ${url}`);
155
162
  });
156
163
  ////////////////////////////////////////////////////////////////
164
+ isAvailable = await (0, server_1.isPortAvailable)(5050);
165
+ if (isAvailable == false) {
166
+ console.error('ERROR: Port 5050 used by cryptoservice is already in use');
167
+ // return;
168
+ process.exit();
169
+ }
157
170
  const cryptoServiceBin = `${process.platform}-${process.arch}`;
158
171
  const bin = path_1.default.join(__dirname, '..', 'bin', cryptoServiceBin);
159
172
  if (!(0, fs_1.existsSync)(bin)) {
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ const program = new commander_1.Command();
14
14
  program
15
15
  .name('airmoney-cli')
16
16
  .description('airmoney-cli is a command-line interface tool designed to facilitate the development and management of decentralized applications (DApps) for Airmoney.')
17
- .version('0.10.7');
17
+ .version('0.10.9');
18
18
  program
19
19
  .command('setup')
20
20
  .description('Setup env with userAddress, apiKey, rpc')
package/dist/util/env.js CHANGED
@@ -43,6 +43,9 @@ function configDir() {
43
43
  // similar to Rust's ProjectDirs::from("fun", "air", "simulator");
44
44
  // We'll do a rough approach
45
45
  const baseDir = path.join(os.homedir(), '.config', 'air-simulator');
46
+ fs.mkdirSync(path.join(baseDir, 'wallet'), {
47
+ recursive: true,
48
+ });
46
49
  return baseDir;
47
50
  }
48
51
  function loadEnvFromConfig() {
@@ -37,8 +37,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.displayImage = displayImage;
40
+ exports.isPortAvailable = isPortAvailable;
40
41
  const path_1 = __importDefault(require("path"));
41
42
  const fs = __importStar(require("fs"));
43
+ const net_1 = require("net");
42
44
  function displayImage(request, appName) {
43
45
  const f = request.params[0].replace(new RegExp(`^${appName}\\/`), '');
44
46
  let file = fs.readFileSync(f, { encoding: 'base64' });
@@ -63,12 +65,37 @@ function displayImage(request, appName) {
63
65
  }
64
66
  const event = {
65
67
  source: 'air-money',
66
- type: "service",
67
- subType: "setImage",
68
+ type: 'service',
69
+ subType: 'setImage',
68
70
  data: {
69
71
  id: request.params[1],
70
- imageName: `data:${mime};base64,${file}`
71
- }
72
+ imageName: `data:${mime};base64,${file}`,
73
+ },
72
74
  };
73
75
  return event;
74
76
  }
77
+ function isPortAvailable(port, type = 'IPv4') {
78
+ let hasError = 0;
79
+ return new Promise(res => {
80
+ const server = (0, net_1.createServer)()
81
+ .once('error', err => {
82
+ if (err) {
83
+ res(false);
84
+ }
85
+ })
86
+ .once('listening', () => {
87
+ server
88
+ .once('close', () => {
89
+ hasError++;
90
+ if (hasError > 1) {
91
+ res(false);
92
+ }
93
+ else {
94
+ res(true);
95
+ }
96
+ })
97
+ .close();
98
+ })
99
+ .listen(port, type === 'IPv4' ? '0.0.0.0' : '::');
100
+ });
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airmoney-degn/airmoney-cli",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
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"