@h3ravel/config 1.4.5 → 1.4.6
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/README.md +1 -1
- package/dist/index.cjs +6 -5
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/package.json +5 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a href="https://h3ravel.toneflix.net" target="_blank">
|
|
3
3
|
<img src="https://raw.githubusercontent.com/h3ravel/assets/refs/heads/main/logo-full.svg" width="200" alt="H3ravel Logo">
|
|
4
4
|
</a>
|
|
5
|
-
<h1 align="center"><a href="https://h3ravel.toneflix.net/
|
|
5
|
+
<h1 align="center"><a href="https://h3ravel.toneflix.net/configuration">H3ravel Config</a></h1>
|
|
6
6
|
|
|
7
7
|
[![Framework][ix]][lx]
|
|
8
8
|
[![Config Package Version][i1]][l1]
|
package/dist/index.cjs
CHANGED
|
@@ -25,15 +25,17 @@ let __h3ravel_shared = require("@h3ravel/shared");
|
|
|
25
25
|
__h3ravel_shared = __toESM(__h3ravel_shared);
|
|
26
26
|
let node_fs_promises = require("node:fs/promises");
|
|
27
27
|
node_fs_promises = __toESM(node_fs_promises);
|
|
28
|
-
let
|
|
29
|
-
|
|
28
|
+
let __h3ravel_musket = require("@h3ravel/musket");
|
|
29
|
+
__h3ravel_musket = __toESM(__h3ravel_musket);
|
|
30
30
|
let __h3ravel_support = require("@h3ravel/support");
|
|
31
31
|
__h3ravel_support = __toESM(__h3ravel_support);
|
|
32
32
|
let node_path = require("node:path");
|
|
33
33
|
node_path = __toESM(node_path);
|
|
34
|
+
let __h3ravel_core = require("@h3ravel/core");
|
|
35
|
+
__h3ravel_core = __toESM(__h3ravel_core);
|
|
34
36
|
|
|
35
37
|
//#region src/Commands/ConfigPublishCommand.ts
|
|
36
|
-
var ConfigPublishCommand = class extends
|
|
38
|
+
var ConfigPublishCommand = class extends __h3ravel_musket.Command {
|
|
37
39
|
/**
|
|
38
40
|
* The name and signature of the console command.
|
|
39
41
|
*
|
|
@@ -194,5 +196,4 @@ exports.ConfigPublishCommand = ConfigPublishCommand;
|
|
|
194
196
|
exports.ConfigRepository = ConfigRepository;
|
|
195
197
|
exports.ConfigServiceProvider = ConfigServiceProvider;
|
|
196
198
|
exports.EnvLoader = EnvLoader;
|
|
197
|
-
exports.Helpers = Helpers;
|
|
198
|
-
//# sourceMappingURL=index.cjs.map
|
|
199
|
+
exports.Helpers = Helpers;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
|
-
import {
|
|
2
|
+
import { Command } from "@h3ravel/musket";
|
|
3
|
+
import { Application, ServiceProvider } from "@h3ravel/core";
|
|
3
4
|
import { DotNestedKeys, DotNestedValue } from "@h3ravel/shared";
|
|
4
5
|
|
|
5
6
|
//#region src/Commands/ConfigPublishCommand.d.ts
|
|
6
|
-
declare class ConfigPublishCommand extends
|
|
7
|
+
declare class ConfigPublishCommand extends Command {
|
|
7
8
|
/**
|
|
8
9
|
* The name and signature of the console command.
|
|
9
10
|
*
|
|
@@ -83,5 +84,4 @@ declare class ConfigServiceProvider extends ServiceProvider {
|
|
|
83
84
|
register(): Promise<void>;
|
|
84
85
|
}
|
|
85
86
|
//#endregion
|
|
86
|
-
export { ConfigPublishCommand, ConfigRepository, ConfigServiceProvider, EnvLoader, Helpers };
|
|
87
|
-
//# sourceMappingURL=index.d.cts.map
|
|
87
|
+
export { ConfigPublishCommand, ConfigRepository, ConfigServiceProvider, EnvLoader, Helpers };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
2
|
import { DotNestedKeys, DotNestedValue } from "@h3ravel/shared";
|
|
3
|
-
import {
|
|
3
|
+
import { Command } from "@h3ravel/musket";
|
|
4
|
+
import { Application, ServiceProvider } from "@h3ravel/core";
|
|
4
5
|
|
|
5
6
|
//#region src/Commands/ConfigPublishCommand.d.ts
|
|
6
|
-
declare class ConfigPublishCommand extends
|
|
7
|
+
declare class ConfigPublishCommand extends Command {
|
|
7
8
|
/**
|
|
8
9
|
* The name and signature of the console command.
|
|
9
10
|
*
|
|
@@ -83,5 +84,4 @@ declare class ConfigServiceProvider extends ServiceProvider {
|
|
|
83
84
|
register(): Promise<void>;
|
|
84
85
|
}
|
|
85
86
|
//#endregion
|
|
86
|
-
export { ConfigPublishCommand, ConfigRepository, ConfigServiceProvider, EnvLoader, Helpers };
|
|
87
|
-
//# sourceMappingURL=index.d.ts.map
|
|
87
|
+
export { ConfigPublishCommand, ConfigRepository, ConfigServiceProvider, EnvLoader, Helpers };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { EnvParser, FileSystem, Logger } from "@h3ravel/shared";
|
|
2
2
|
import { readFile, readdir, writeFile } from "node:fs/promises";
|
|
3
|
-
import {
|
|
3
|
+
import { Command } from "@h3ravel/musket";
|
|
4
4
|
import { Str, safeDot, setNested } from "@h3ravel/support";
|
|
5
5
|
import npath from "node:path";
|
|
6
|
+
import { Registerer, ServiceProvider } from "@h3ravel/core";
|
|
6
7
|
|
|
7
8
|
//#region src/Commands/ConfigPublishCommand.ts
|
|
8
|
-
var ConfigPublishCommand = class extends
|
|
9
|
+
var ConfigPublishCommand = class extends Command {
|
|
9
10
|
/**
|
|
10
11
|
* The name and signature of the console command.
|
|
11
12
|
*
|
|
@@ -162,5 +163,4 @@ var ConfigServiceProvider = class extends ServiceProvider {
|
|
|
162
163
|
};
|
|
163
164
|
|
|
164
165
|
//#endregion
|
|
165
|
-
export { ConfigPublishCommand, ConfigRepository, ConfigServiceProvider, EnvLoader, Helpers };
|
|
166
|
-
//# sourceMappingURL=index.js.map
|
|
166
|
+
export { ConfigPublishCommand, ConfigRepository, ConfigServiceProvider, EnvLoader, Helpers };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/config",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "Environment/config loading and management system for H3ravel.",
|
|
5
5
|
"h3ravel": {
|
|
6
6
|
"providers": [
|
|
@@ -41,13 +41,14 @@
|
|
|
41
41
|
"laravel"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@h3ravel/
|
|
45
|
-
"@h3ravel/
|
|
44
|
+
"@h3ravel/musket": "^0.1.8",
|
|
45
|
+
"@h3ravel/shared": "^0.22.3",
|
|
46
|
+
"@h3ravel/support": "^0.14.2"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"tsx": "^4.20.5",
|
|
49
50
|
"typescript": "^5.9.2",
|
|
50
|
-
"@h3ravel/core": "^1.
|
|
51
|
+
"@h3ravel/core": "^1.17.0"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
54
|
"barrel": "barrelsby --directory src --delete --singleQuotes",
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["ConsoleCommand","path","Str","FileSystem","npath","Logger","app: Application","path","_app: Application","EnvParser","ServiceProvider","key"],"sources":["../src/Commands/ConfigPublishCommand.ts","../src/ConfigRepository.ts","../src/EnvLoader.ts","../src/Helpers.ts","../src/Providers/ConfigServiceProvider.ts"],"sourcesContent":["import { FileSystem, Logger } from '@h3ravel/shared'\nimport { readFile, writeFile } from 'node:fs/promises'\n\nimport { ConsoleCommand } from '@h3ravel/core'\nimport { Str } from '@h3ravel/support'\nimport npath from 'node:path'\n\nexport class ConfigPublishCommand extends ConsoleCommand {\n\n /**\n * The name and signature of the console command.\n *\n * @var string\n */\n protected signature: string = `config:publish\n {name? : The name of the configuration file to publish}\n {--all : Publish all configuration files}\n {--force : Overwrite any existing configuration files}\n `\n /**\n * The console command description.\n *\n * @var string\n */\n protected description: string = 'Publish configuration files to your application'\n\n /**\n * List available config files\n */\n protected configs = [\n 'hashing'\n ] as const\n\n /**\n * Create a new seeder class\n */\n public async handle () {\n const all = this.option('all')\n if (all) {\n await Promise.all(this.configs.map(e => this.publish(e)))\n } else {\n const name = this.argument('name')\n if (!name) Logger.error('ERORR: enter a configuration name or pass the --all flag to publish all available configurations.')\n await this.publish(name)\n }\n }\n\n /**\n * Create a new seeder class\n */\n protected async publish (name: 'hashing') {\n const force = this.option('force')\n const path = base_path(`src/config/${Str.snake(name)}.ts`)\n\n // Check if the config already exists\n if (!force && await FileSystem.fileExists(path)) {\n this.error(`ERORR: ${name} already exists`)\n }\n\n const dbPkgPath = FileSystem.findModulePkg('@h3ravel/config', this.kernel.cwd) ?? ''\n const stubPath = npath.join(dbPkgPath, this.getStubName(name))\n\n // Check if the stub exists\n if (!await FileSystem.fileExists(stubPath)) {\n this.error(`ERORR: Config [${name}] does not exist`)\n }\n\n await writeFile(path, await readFile(stubPath, 'utf-8'))\n\n this.info(\n `INFO: Config ${Logger.log(`[${npath.relative(process.cwd(), path)}]`, 'bold', false)} published successfully.`\n )\n }\n\n /**\n * Get the configuration file to publish\n * \n * @param name \n * @returns \n */\n getStubName (name: 'hashing') {\n return `dist/stubs/${name}.stub`\n }\n}\n","import { Application, Registerer } from '@h3ravel/core'\nimport type { DotNestedKeys, DotNestedValue } from '@h3ravel/shared'\nimport { safeDot, setNested } from '@h3ravel/support'\n\nimport path from 'node:path'\nimport { readdir } from 'node:fs/promises'\n\nexport class ConfigRepository {\n private loaded: boolean = false\n private configs: Record<string, Record<string, any>> = {}\n\n constructor(protected app: Application) { }\n\n // get<X extends Record<string, any>> (): X\n // get<X extends Record<string, any>, T extends Extract<keyof X, string>> (key: T): X[T]\n\n /**\n * Get the defined configurations\n */\n get<X extends Record<string, any>> (): X\n get<X extends Record<string, any>, K extends DotNestedKeys<X>> (key: K, def?: any): DotNestedValue<X, K>\n get<X extends Record<string, any>, K extends DotNestedKeys<X>> (key?: K, def?: any): any {\n return safeDot(this.configs, key) ?? def\n }\n\n /**\n * Modify the defined configurations\n */\n set<T extends string> (key: T, value: any): void {\n setNested(this.configs, key, value)\n }\n\n async load () {\n if (!this.loaded) {\n\n const configPath = this.app.getPath('config')\n\n globalThis.env = this.app.make('env')\n Registerer.register(this.app)\n\n const files = (await readdir(configPath)).filter((e) => {\n return !e.includes('.d.ts') && !e.includes('.d.cts') && !e.includes('.map')\n })\n\n for (let i = 0; i < files.length; i++) {\n const configModule = await import(path.join(configPath, files[i]))\n const name = files[i].replaceAll(/\\.ts|\\.js/g, '')\n if (typeof configModule.default === 'function') {\n this.configs[name] = configModule.default(this.app)\n }\n }\n\n this.loaded = true\n }\n return this\n }\n}\n","import type { DotNestedKeys, DotNestedValue } from '@h3ravel/shared'\n\nimport { Application } from '@h3ravel/core'\nimport { EnvParser } from '@h3ravel/shared'\nimport { safeDot } from '@h3ravel/support'\n\nexport class EnvLoader {\n constructor(protected _app: Application) { }\n\n /**\n * Get the defined environment vars\n */\n get<X extends NodeJS.ProcessEnv> (): X\n get<X extends NodeJS.ProcessEnv, K extends DotNestedKeys<X>> (key: K, def?: any): DotNestedValue<X, K>\n get<X extends NodeJS.ProcessEnv, K extends DotNestedKeys<X>> (key?: K, def?: any): any {\n return safeDot(EnvParser.parse(process.env), key) ?? def\n }\n}\n","export class Helpers {\n}\n","/// <reference path=\"../../../core/src/app.globals.d.ts\" />\n\nimport { ConfigRepository, EnvLoader } from '..'\n\nimport { Bindings } from '@h3ravel/shared'\nimport { ConfigPublishCommand } from '../Commands/ConfigPublishCommand'\nimport { ServiceProvider } from '@h3ravel/core'\n\n/**\n * Loads configuration and environment files.\n * \n * Load .env and merge with config files.\n * Bind ConfigRepository to the container.\n * \n * Auto-Registered\n */\nexport class ConfigServiceProvider extends ServiceProvider {\n public static priority = 998\n // public static order = 'before:DatabaseServiceProvider';\n\n async register () {\n /**\n * Create singleton to load env\n */\n this.app.singleton('env', () => {\n const env = new EnvLoader(this.app).get\n globalThis.env = env\n return env\n })\n\n /**\n * Initialize the configuration through the repository\n */\n const repo = new ConfigRepository(this.app)\n await repo.load()\n\n /**\n * Create singleton to load configurations\n */\n this.app.singleton('config', () => {\n const config = {\n get: (key, def) => repo.get(key as any, def),\n set: repo.set\n } as Bindings['config']\n\n globalThis.config = ((key: string | Record<string, any>, def: any) => {\n if (!key || typeof key === 'string') {\n return config.get(key, def)\n }\n\n Object.entries(key).forEach(([key, value]) => {\n config.set(key, value)\n })\n }) as never\n\n return config\n })\n\n this.app.make('http.app').use(e => {\n repo.set('app.url', e.url.origin)\n })\n\n this.registerCommands([ConfigPublishCommand])\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAa,uBAAb,cAA0CA,8BAAe;;;;;;CAOrD,AAAU,YAAoB;;;;;;;;;;CAU9B,AAAU,cAAsB;;;;CAKhC,AAAU,UAAU,CAChB,UACH;;;;CAKD,MAAa,SAAU;AAEnB,MADY,KAAK,OAAO,MAAM,CAE1B,OAAM,QAAQ,IAAI,KAAK,QAAQ,KAAI,MAAK,KAAK,QAAQ,EAAE,CAAC,CAAC;OACtD;GACH,MAAM,OAAO,KAAK,SAAS,OAAO;AAClC,OAAI,CAAC,KAAM,yBAAO,MAAM,oGAAoG;AAC5H,SAAM,KAAK,QAAQ,KAAK;;;;;;CAOhC,MAAgB,QAAS,MAAiB;EACtC,MAAM,QAAQ,KAAK,OAAO,QAAQ;EAClC,MAAMC,SAAO,UAAU,cAAcC,sBAAI,MAAM,KAAK,CAAC,KAAK;AAG1D,MAAI,CAAC,SAAS,MAAMC,4BAAW,WAAWF,OAAK,CAC3C,MAAK,MAAM,UAAU,KAAK,iBAAiB;EAG/C,MAAM,YAAYE,4BAAW,cAAc,mBAAmB,KAAK,OAAO,IAAI,IAAI;EAClF,MAAM,WAAWC,kBAAM,KAAK,WAAW,KAAK,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YAAY,AAAUC,MAAmB;EAAnB;;CAOtB,IAA8D,KAAS,KAAgB;AACnF,wCAAeC,2BAAU,MAAM,QAAQ,IAAI,EAAE,IAAI,IAAI;;;;;;ACf7D,IAAa,UAAb,MAAqB;;;;;;;;;;;;ACgBrB,IAAa,wBAAb,cAA2CC,+BAAgB;CACvD,OAAc,WAAW;CAGzB,MAAM,WAAY;;;;AAId,OAAK,IAAI,UAAU,aAAa;GAC5B,MAAM,MAAM,IAAI,UAAU,KAAK,IAAI,CAAC;AACpC,cAAW,MAAM;AACjB,UAAO;IACT;;;;EAKF,MAAM,OAAO,IAAI,iBAAiB,KAAK,IAAI;AAC3C,QAAM,KAAK,MAAM;;;;AAKjB,OAAK,IAAI,UAAU,gBAAgB;GAC/B,MAAM,SAAS;IACX,MAAM,KAAK,QAAQ,KAAK,IAAI,KAAY,IAAI;IAC5C,KAAK,KAAK;IACb;AAED,cAAW,WAAW,KAAmC,QAAa;AAClE,QAAI,CAAC,OAAO,OAAO,QAAQ,SACvB,QAAO,OAAO,IAAI,KAAK,IAAI;AAG/B,WAAO,QAAQ,IAAI,CAAC,SAAS,CAACC,OAAK,WAAW;AAC1C,YAAO,IAAIA,OAAK,MAAM;MACxB;;AAGN,UAAO;IACT;AAEF,OAAK,IAAI,KAAK,WAAW,CAAC,KAAI,MAAK;AAC/B,QAAK,IAAI,WAAW,EAAE,IAAI,OAAO;IACnC;AAEF,OAAK,iBAAiB,CAAC,qBAAqB,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["app: Application","path","_app: Application","key"],"sources":["../src/Commands/ConfigPublishCommand.ts","../src/ConfigRepository.ts","../src/EnvLoader.ts","../src/Helpers.ts","../src/Providers/ConfigServiceProvider.ts"],"sourcesContent":["import { FileSystem, Logger } from '@h3ravel/shared'\nimport { readFile, writeFile } from 'node:fs/promises'\n\nimport { ConsoleCommand } from '@h3ravel/core'\nimport { Str } from '@h3ravel/support'\nimport npath from 'node:path'\n\nexport class ConfigPublishCommand extends ConsoleCommand {\n\n /**\n * The name and signature of the console command.\n *\n * @var string\n */\n protected signature: string = `config:publish\n {name? : The name of the configuration file to publish}\n {--all : Publish all configuration files}\n {--force : Overwrite any existing configuration files}\n `\n /**\n * The console command description.\n *\n * @var string\n */\n protected description: string = 'Publish configuration files to your application'\n\n /**\n * List available config files\n */\n protected configs = [\n 'hashing'\n ] as const\n\n /**\n * Create a new seeder class\n */\n public async handle () {\n const all = this.option('all')\n if (all) {\n await Promise.all(this.configs.map(e => this.publish(e)))\n } else {\n const name = this.argument('name')\n if (!name) Logger.error('ERORR: enter a configuration name or pass the --all flag to publish all available configurations.')\n await this.publish(name)\n }\n }\n\n /**\n * Create a new seeder class\n */\n protected async publish (name: 'hashing') {\n const force = this.option('force')\n const path = base_path(`src/config/${Str.snake(name)}.ts`)\n\n // Check if the config already exists\n if (!force && await FileSystem.fileExists(path)) {\n this.error(`ERORR: ${name} already exists`)\n }\n\n const dbPkgPath = FileSystem.findModulePkg('@h3ravel/config', this.kernel.cwd) ?? ''\n const stubPath = npath.join(dbPkgPath, this.getStubName(name))\n\n // Check if the stub exists\n if (!await FileSystem.fileExists(stubPath)) {\n this.error(`ERORR: Config [${name}] does not exist`)\n }\n\n await writeFile(path, await readFile(stubPath, 'utf-8'))\n\n this.info(\n `INFO: Config ${Logger.log(`[${npath.relative(process.cwd(), path)}]`, 'bold', false)} published successfully.`\n )\n }\n\n /**\n * Get the configuration file to publish\n * \n * @param name \n * @returns \n */\n getStubName (name: 'hashing') {\n return `dist/stubs/${name}.stub`\n }\n}\n","import { Application, Registerer } from '@h3ravel/core'\nimport type { DotNestedKeys, DotNestedValue } from '@h3ravel/shared'\nimport { safeDot, setNested } from '@h3ravel/support'\n\nimport path from 'node:path'\nimport { readdir } from 'node:fs/promises'\n\nexport class ConfigRepository {\n private loaded: boolean = false\n private configs: Record<string, Record<string, any>> = {}\n\n constructor(protected app: Application) { }\n\n // get<X extends Record<string, any>> (): X\n // get<X extends Record<string, any>, T extends Extract<keyof X, string>> (key: T): X[T]\n\n /**\n * Get the defined configurations\n */\n get<X extends Record<string, any>> (): X\n get<X extends Record<string, any>, K extends DotNestedKeys<X>> (key: K, def?: any): DotNestedValue<X, K>\n get<X extends Record<string, any>, K extends DotNestedKeys<X>> (key?: K, def?: any): any {\n return safeDot(this.configs, key) ?? def\n }\n\n /**\n * Modify the defined configurations\n */\n set<T extends string> (key: T, value: any): void {\n setNested(this.configs, key, value)\n }\n\n async load () {\n if (!this.loaded) {\n\n const configPath = this.app.getPath('config')\n\n globalThis.env = this.app.make('env')\n Registerer.register(this.app)\n\n const files = (await readdir(configPath)).filter((e) => {\n return !e.includes('.d.ts') && !e.includes('.d.cts') && !e.includes('.map')\n })\n\n for (let i = 0; i < files.length; i++) {\n const configModule = await import(path.join(configPath, files[i]))\n const name = files[i].replaceAll(/\\.ts|\\.js/g, '')\n if (typeof configModule.default === 'function') {\n this.configs[name] = configModule.default(this.app)\n }\n }\n\n this.loaded = true\n }\n return this\n }\n}\n","import type { DotNestedKeys, DotNestedValue } from '@h3ravel/shared'\n\nimport { Application } from '@h3ravel/core'\nimport { EnvParser } from '@h3ravel/shared'\nimport { safeDot } from '@h3ravel/support'\n\nexport class EnvLoader {\n constructor(protected _app: Application) { }\n\n /**\n * Get the defined environment vars\n */\n get<X extends NodeJS.ProcessEnv> (): X\n get<X extends NodeJS.ProcessEnv, K extends DotNestedKeys<X>> (key: K, def?: any): DotNestedValue<X, K>\n get<X extends NodeJS.ProcessEnv, K extends DotNestedKeys<X>> (key?: K, def?: any): any {\n return safeDot(EnvParser.parse(process.env), key) ?? def\n }\n}\n","export class Helpers {\n}\n","/// <reference path=\"../../../core/src/app.globals.d.ts\" />\n\nimport { ConfigRepository, EnvLoader } from '..'\n\nimport { Bindings } from '@h3ravel/shared'\nimport { ConfigPublishCommand } from '../Commands/ConfigPublishCommand'\nimport { ServiceProvider } from '@h3ravel/core'\n\n/**\n * Loads configuration and environment files.\n * \n * Load .env and merge with config files.\n * Bind ConfigRepository to the container.\n * \n * Auto-Registered\n */\nexport class ConfigServiceProvider extends ServiceProvider {\n public static priority = 998\n // public static order = 'before:DatabaseServiceProvider';\n\n async register () {\n /**\n * Create singleton to load env\n */\n this.app.singleton('env', () => {\n const env = new EnvLoader(this.app).get\n globalThis.env = env\n return env\n })\n\n /**\n * Initialize the configuration through the repository\n */\n const repo = new ConfigRepository(this.app)\n await repo.load()\n\n /**\n * Create singleton to load configurations\n */\n this.app.singleton('config', () => {\n const config = {\n get: (key, def) => repo.get(key as any, def),\n set: repo.set\n } as Bindings['config']\n\n globalThis.config = ((key: string | Record<string, any>, def: any) => {\n if (!key || typeof key === 'string') {\n return config.get(key, def)\n }\n\n Object.entries(key).forEach(([key, value]) => {\n config.set(key, value)\n })\n }) as never\n\n return config\n })\n\n this.app.make('http.app').use(e => {\n repo.set('app.url', e.url.origin)\n })\n\n this.registerCommands([ConfigPublishCommand])\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,uBAAb,cAA0C,eAAe;;;;;;CAOrD,AAAU,YAAoB;;;;;;;;;;CAU9B,AAAU,cAAsB;;;;CAKhC,AAAU,UAAU,CAChB,UACH;;;;CAKD,MAAa,SAAU;AAEnB,MADY,KAAK,OAAO,MAAM,CAE1B,OAAM,QAAQ,IAAI,KAAK,QAAQ,KAAI,MAAK,KAAK,QAAQ,EAAE,CAAC,CAAC;OACtD;GACH,MAAM,OAAO,KAAK,SAAS,OAAO;AAClC,OAAI,CAAC,KAAM,QAAO,MAAM,oGAAoG;AAC5H,SAAM,KAAK,QAAQ,KAAK;;;;;;CAOhC,MAAgB,QAAS,MAAiB;EACtC,MAAM,QAAQ,KAAK,OAAO,QAAQ;EAClC,MAAM,OAAO,UAAU,cAAc,IAAI,MAAM,KAAK,CAAC,KAAK;AAG1D,MAAI,CAAC,SAAS,MAAM,WAAW,WAAW,KAAK,CAC3C,MAAK,MAAM,UAAU,KAAK,iBAAiB;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