@dignetwork/dig-sdk 0.0.1-alpha.172 → 0.0.1-alpha.173

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.
@@ -1 +1 @@
1
- {"version":3,"file":"NconfManager.d.ts","sourceRoot":"","sources":["../../src/utils/NconfManager.ts"],"names":[],"mappings":"AAQA,qBAAa,YAAY;IACvB,OAAO,CAAC,cAAc,CAAS;gBAEnB,YAAY,EAAE,MAAM;YAKlB,gBAAgB;IAejB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAMjD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAStD,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAKhC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAI3D"}
1
+ {"version":3,"file":"NconfManager.d.ts","sourceRoot":"","sources":["../../src/utils/NconfManager.ts"],"names":[],"mappings":"AAUA,qBAAa,YAAY;IACvB,OAAO,CAAC,cAAc,CAAS;gBAEnB,YAAY,EAAE,MAAM;YAKpB,gBAAgB;IAmBf,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAMjD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAStD,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAKhC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAI3D"}
@@ -6,24 +6,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NconfManager = void 0;
7
7
  const nconf_1 = __importDefault(require("nconf"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const async_mutex_1 = require("async-mutex");
9
10
  const path_1 = __importDefault(require("path"));
10
11
  const config_1 = require("./config");
11
12
  const Environment_1 = require("./Environment");
12
13
  const CONF_FOLDER_PATH = Environment_1.Environment.DIG_FOLDER_PATH || config_1.USER_DIR_PATH;
14
+ const fileMutex = new async_mutex_1.Mutex();
13
15
  class NconfManager {
14
16
  constructor(relativePath) {
15
17
  this.configFilePath = path_1.default.join(CONF_FOLDER_PATH, relativePath);
16
18
  this.initializeConfig();
17
19
  }
18
20
  async initializeConfig() {
21
+ const release = await fileMutex.acquire();
19
22
  const directory = path_1.default.dirname(this.configFilePath);
20
- if (!(await fs_extra_1.default.pathExists(directory))) {
21
- await fs_extra_1.default.mkdirp(directory);
22
- console.log("Directory created:", directory);
23
+ try {
24
+ if (!(await fs_extra_1.default.pathExists(directory))) {
25
+ await fs_extra_1.default.mkdirp(directory);
26
+ console.log("Directory created:", directory);
27
+ }
28
+ if (!(await fs_extra_1.default.pathExists(this.configFilePath))) {
29
+ await fs_extra_1.default.writeFile(this.configFilePath, "{}");
30
+ console.log("Configuration file created:", this.configFilePath);
31
+ }
23
32
  }
24
- if (!(await fs_extra_1.default.pathExists(this.configFilePath))) {
25
- await fs_extra_1.default.writeFile(this.configFilePath, "{}");
26
- console.log("Configuration file created:", this.configFilePath);
33
+ finally {
34
+ release();
27
35
  }
28
36
  nconf_1.default.file({ file: this.configFilePath });
29
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dignetwork/dig-sdk",
3
- "version": "0.0.1-alpha.172",
3
+ "version": "0.0.1-alpha.173",
4
4
  "description": "",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",
@@ -28,6 +28,7 @@
28
28
  "@dignetwork/datalayer-driver": "^0.1.29",
29
29
  "@dignetwork/dig-sdk": "^0.0.1-alpha.158",
30
30
  "archiver": "^7.0.1",
31
+ "async-mutex": "^0.5.0",
31
32
  "axios": "^1.7.7",
32
33
  "bip39": "^3.1.0",
33
34
  "bottleneck": "^2.19.5",
@@ -41,7 +42,7 @@
41
42
  "figures": "^6.1.0",
42
43
  "fs-extra": "^11.2.0",
43
44
  "ignore": "^5.3.2",
44
- "inquirer": "^10.1.8",
45
+ "inquirer": "^10.2.2",
45
46
  "lodash": "^4.17.21",
46
47
  "merkletreejs": "^0.4.0",
47
48
  "nanospinner": "^1.1.0",
@@ -50,30 +51,30 @@
50
51
  "node-stun": "^0.1.2",
51
52
  "progress-stream": "^2.0.0",
52
53
  "proper-lockfile": "^4.1.2",
54
+ "superagent": "^10.1.0",
53
55
  "redis": "^4.7.0",
54
- "superagent": "^10.0.0",
55
56
  "unzipper": "^0.12.3"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@types/archiver": "^6.0.2",
59
- "@types/chai": "^4.3.17",
60
+ "@types/chai": "^4.3.20",
60
61
  "@types/cli-progress": "^3.11.6",
61
62
  "@types/crypto-js": "^4.2.2",
62
63
  "@types/fs-extra": "^11.0.4",
63
64
  "@types/inquirer": "^9.0.7",
64
- "@types/lodash": "^4.17.7",
65
- "@types/mocha": "^10.0.7",
65
+ "@types/lodash": "^4.17.10",
66
+ "@types/mocha": "^10.0.9",
66
67
  "@types/nconf": "^0.10.7",
67
- "@types/node": "^22.1.0",
68
+ "@types/node": "^22.7.5",
68
69
  "@types/progress-stream": "^2.0.5",
69
70
  "@types/proper-lockfile": "^4.1.4",
70
- "@types/superagent": "^8.1.8",
71
+ "@types/superagent": "^8.1.9",
71
72
  "@types/unzipper": "^0.10.10",
72
73
  "chai": "^5.1.1",
73
74
  "copyfiles": "^2.4.1",
74
- "mocha": "^10.7.0",
75
+ "mocha": "^10.7.3",
75
76
  "standard-version": "^9.5.0",
76
77
  "ts-node": "^10.9.2",
77
- "typescript": "^5.5.4"
78
+ "typescript": "^5.6.3"
78
79
  }
79
80
  }