configre 1.0.8 → 1.1.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,4 +1,4 @@
1
- export default {
1
+ module.exports = {
2
2
  db: {
3
3
  user: 'john',
4
4
  password: 'johns-password'
@@ -1,4 +1,4 @@
1
- export default {
1
+ module.exports = {
2
2
  db: {
3
3
  host: 'localhost',
4
4
  user: 'myuser',
@@ -7,5 +7,5 @@ const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = dirname(__filename);
8
8
  const log = lemonlog("Configre");
9
9
 
10
- const cfg = await Configre(__dirname + "/config");
10
+ const cfg = Configre(__dirname + "/config");
11
11
  log.info(cfg.db);
package/index.mjs CHANGED
@@ -1,53 +1,12 @@
1
- import lemonlog from "lemonlog";
1
+ import { createRequire } from "module";
2
2
  import { fileURLToPath } from "url";
3
3
  import { dirname } from "path";
4
- import { pathToFileURL } from "url";
5
- import { createRequire } from "module";
6
4
 
7
5
  const require = createRequire(import.meta.url);
8
6
  const __filename = fileURLToPath(import.meta.url);
9
7
  const __dirname = dirname(__filename);
10
- const log = lemonlog("Configre");
11
- const ConfigreCore = require("./core.js");
12
-
13
- class ConfigreClass {
14
- constructor(path = __dirname + "/../../config") {
15
- this.core = new ConfigreCore(path, log);
16
- }
17
-
18
- async loadDefaultSettings() {
19
- const { indexFile } = this.core.getFiles();
20
- const module = await import(pathToFileURL(indexFile).href);
21
- return module.default;
22
- }
23
-
24
- async loadProfileSettings() {
25
- const { devFile, localFile } = this.core.getFiles();
26
-
27
- if (this.core.checkFileExists(devFile)) {
28
- this.core.logConfig(devFile, "DEV CONFIG");
29
- const module = await import(pathToFileURL(devFile).href);
30
- return module.default;
31
- } else if (this.core.checkFileExists(localFile)) {
32
- this.core.logConfig(localFile, "PRO CONFIG");
33
- const module = await import(pathToFileURL(localFile).href);
34
- return module.default;
35
- } else {
36
- this.core.logConfig(localFile, "NOT FOUND, USING DEFAULTS");
37
- return {};
38
- }
39
- }
40
-
41
- async get() {
42
- const defaultSettings = await this.loadDefaultSettings();
43
- const profileSettings = await this.loadProfileSettings();
44
- return this.core.merge(defaultSettings, profileSettings);
45
- }
46
- }
47
8
 
48
- // Wrapper function to support both constructor and function usage
49
- async function Configre(path) {
50
- return await new ConfigreClass(path).get();
51
- }
9
+ // Simplemente re-exportar la versión CommonJS que ya funciona síncronamente
10
+ const Configre = require("./index.js");
52
11
 
53
12
  export default Configre;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configre",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "description": "🔧 Effortlessly Tailor Your Settings",
5
5
  "main": "index.js",
6
6
  "exports": {