@h3ravel/config 1.4.18 → 1.5.0-alpha.2

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.
package/dist/index.cjs CHANGED
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
15
19
  }
16
20
  return to;
17
21
  };
@@ -106,7 +110,7 @@ var ConfigRepository = class {
106
110
  async load() {
107
111
  if (!this.loaded) {
108
112
  const configPath = this.app.getPath("config");
109
- globalThis.env = this.app.make("env");
113
+ globalThis.env ??= this.app.make("env");
110
114
  __h3ravel_core.Registerer.register(this.app);
111
115
  const files = (await (0, node_fs_promises.readdir)(configPath)).filter((e) => {
112
116
  return !e.includes(".d.ts") && !e.includes(".d.cts") && !e.includes(".map");
@@ -147,7 +151,7 @@ var Helpers = class {};
147
151
  *
148
152
  * Auto-Registered
149
153
  */
150
- var ConfigServiceProvider = class extends __h3ravel_core.ServiceProvider {
154
+ var ConfigServiceProvider = class extends __h3ravel_support.ServiceProvider {
151
155
  static priority = 998;
152
156
  async register() {
153
157
  /**
@@ -155,7 +159,7 @@ var ConfigServiceProvider = class extends __h3ravel_core.ServiceProvider {
155
159
  */
156
160
  this.app.singleton("env", () => {
157
161
  const env = new EnvLoader(this.app).get;
158
- globalThis.env = env;
162
+ globalThis.env ??= env;
159
163
  return env;
160
164
  });
161
165
  /**
@@ -167,17 +171,7 @@ var ConfigServiceProvider = class extends __h3ravel_core.ServiceProvider {
167
171
  * Create singleton to load configurations
168
172
  */
169
173
  this.app.singleton("config", () => {
170
- const config = {
171
- get: (key, def) => repo.get(key, def),
172
- set: repo.set
173
- };
174
- globalThis.config = ((key, def) => {
175
- if (!key || typeof key === "string") return config.get(key, def);
176
- Object.entries(key).forEach(([key$1, value]) => {
177
- config.set(key$1, value);
178
- });
179
- });
180
- return config;
174
+ return repo;
181
175
  });
182
176
  this.app.make("http.app").use((e) => {
183
177
  repo.set("app.url", e.url.origin);
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /// <reference path="./app.globals.d.ts" />
2
2
  import { Command } from "@h3ravel/musket";
3
- import { Application, ServiceProvider } from "@h3ravel/core";
4
3
  import { DotNestedKeys, DotNestedValue } from "@h3ravel/shared";
4
+ import { IApplication } from "@h3ravel/contracts";
5
+ import { ServiceProvider } from "@h3ravel/support";
5
6
 
6
7
  //#region src/Commands/ConfigPublishCommand.d.ts
7
8
  declare class ConfigPublishCommand extends Command {
@@ -40,10 +41,10 @@ declare class ConfigPublishCommand extends Command {
40
41
  //#endregion
41
42
  //#region src/ConfigRepository.d.ts
42
43
  declare class ConfigRepository {
43
- protected app: Application;
44
+ protected app: IApplication;
44
45
  private loaded;
45
46
  private configs;
46
- constructor(app: Application);
47
+ constructor(app: IApplication);
47
48
  /**
48
49
  * Get the defined configurations
49
50
  */
@@ -58,8 +59,8 @@ declare class ConfigRepository {
58
59
  //#endregion
59
60
  //#region src/EnvLoader.d.ts
60
61
  declare class EnvLoader {
61
- protected app?: Application | undefined;
62
- constructor(app?: Application | undefined);
62
+ protected app?: IApplication | undefined;
63
+ constructor(app?: IApplication | undefined);
63
64
  /**
64
65
  * Get the defined environment vars
65
66
  */
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { EnvParser, FileSystem, Logger } from "@h3ravel/shared";
2
2
  import { readFile, readdir, writeFile } from "node:fs/promises";
3
3
  import { Command } from "@h3ravel/musket";
4
- import { Str, safeDot, setNested } from "@h3ravel/support";
4
+ import { ServiceProvider, Str, safeDot, setNested } from "@h3ravel/support";
5
5
  import npath from "node:path";
6
- import { Registerer, ServiceProvider } from "@h3ravel/core";
6
+ import { Registerer } from "@h3ravel/core";
7
7
 
8
8
  //#region src/Commands/ConfigPublishCommand.ts
9
9
  var ConfigPublishCommand = class extends Command {
@@ -82,7 +82,7 @@ var ConfigRepository = class {
82
82
  async load() {
83
83
  if (!this.loaded) {
84
84
  const configPath = this.app.getPath("config");
85
- globalThis.env = this.app.make("env");
85
+ globalThis.env ??= this.app.make("env");
86
86
  Registerer.register(this.app);
87
87
  const files = (await readdir(configPath)).filter((e) => {
88
88
  return !e.includes(".d.ts") && !e.includes(".d.cts") && !e.includes(".map");
@@ -131,7 +131,7 @@ var ConfigServiceProvider = class extends ServiceProvider {
131
131
  */
132
132
  this.app.singleton("env", () => {
133
133
  const env = new EnvLoader(this.app).get;
134
- globalThis.env = env;
134
+ globalThis.env ??= env;
135
135
  return env;
136
136
  });
137
137
  /**
@@ -143,17 +143,7 @@ var ConfigServiceProvider = class extends ServiceProvider {
143
143
  * Create singleton to load configurations
144
144
  */
145
145
  this.app.singleton("config", () => {
146
- const config = {
147
- get: (key, def) => repo.get(key, def),
148
- set: repo.set
149
- };
150
- globalThis.config = ((key, def) => {
151
- if (!key || typeof key === "string") return config.get(key, def);
152
- Object.entries(key).forEach(([key$1, value]) => {
153
- config.set(key$1, value);
154
- });
155
- });
156
- return config;
146
+ return repo;
157
147
  });
158
148
  this.app.make("http.app").use((e) => {
159
149
  repo.set("app.url", e.url.origin);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/config",
3
- "version": "1.4.18",
3
+ "version": "1.5.0-alpha.2",
4
4
  "description": "Environment/config loading and management system for H3ravel.",
5
5
  "h3ravel": {
6
6
  "providers": [
@@ -41,17 +41,17 @@
41
41
  "laravel"
42
42
  ],
43
43
  "dependencies": {
44
- "@h3ravel/musket": "^0.3.10",
45
- "@h3ravel/shared": "^0.27.7",
46
- "@h3ravel/support": "^0.15.6"
44
+ "@h3ravel/shared": "^0.1.0-alpha.2",
45
+ "@h3ravel/support": "^0.1.0-alpha.2",
46
+ "@h3ravel/musket": "^0.6.11"
47
47
  },
48
48
  "devDependencies": {
49
49
  "tsx": "^4.20.6",
50
- "typescript": "^5.9.2",
51
- "@h3ravel/core": "^1.21.6"
50
+ "@h3ravel/core": "^0.1.0-alpha.2",
51
+ "@h3ravel/contracts": "^0.1.0-alpha.2",
52
+ "typescript": "^5.9.2"
52
53
  },
53
54
  "scripts": {
54
- "barrel": "barrelsby --directory src --delete --singleQuotes",
55
55
  "build": "tsdown --config-loader unconfig",
56
56
  "dev": "tsx watch src/index.ts",
57
57
  "start": "node dist/index.js",