speedly 1.1.4 → 1.2.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.
@@ -1,21 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
3
  // const { path } = require('../../app');
4
+ const cosmiconfig_1 = require("cosmiconfig");
8
5
  exports.default = (configField) => {
9
- const stackPath = new Error().stack?.split('\n')[2].trim().match(/\(.+\)/)?.[0].replace(/([\(\)]|\:\d+\:\d+)/g, '');
10
- for (let i = 1; i < 4; i++) {
11
- const filePath = stackPath?.replace(/\\/g, '/').split('/').slice(0, -i).join('/') + '/speedly.config.js';
12
- if (fs_1.default.existsSync(filePath)) {
13
- const config = require(filePath);
14
- if (config && config[configField]) {
15
- return config[configField];
16
- }
17
- return {};
18
- }
6
+ const explorer = (0, cosmiconfig_1.cosmiconfigSync)("speedly"); // اسم پروژه‌ت
7
+ const result = explorer.search();
8
+ if (result && result.config && result.config[configField]) {
9
+ return result.config[configField];
19
10
  }
20
- return {};
11
+ else
12
+ return {};
21
13
  };
@@ -1,21 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
3
  // const { path } = require('../../app');
4
+ const cosmiconfig_1 = require("cosmiconfig");
8
5
  exports.default = (configField) => {
9
- const stackPath = new Error().stack?.split('\n')[2].trim().match(/\(.+\)/)?.[0].replace(/([\(\)]|\:\d+\:\d+)/g, '');
10
- for (let i = 1; i < 4; i++) {
11
- const filePath = stackPath?.replace(/\\/g, '/').split('/').slice(0, -i).join('/') + '/speedly.config.js';
12
- if (fs_1.default.existsSync(filePath)) {
13
- const config = require(filePath);
14
- if (config && config[configField]) {
15
- return config[configField];
16
- }
17
- return {};
18
- }
6
+ const explorer = (0, cosmiconfig_1.cosmiconfigSync)("speedly"); // اسم پروژه‌ت
7
+ const result = explorer.search();
8
+ if (result && result.config && result.config[configField]) {
9
+ return result.config[configField];
19
10
  }
20
- return {};
11
+ else
12
+ return {};
21
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speedly",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -28,6 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "axios": "^1.11.0",
31
+ "cosmiconfig": "^9.0.0",
31
32
  "express": "^5.1.0",
32
33
  "jsonwebtoken": "^9.0.2",
33
34
  "mongoose": "^8.18.2",