@abdokouta/react-config 1.0.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.
Files changed (42) hide show
  1. package/.examples/01-basic-usage.ts +289 -0
  2. package/.examples/02-env-helper.ts +282 -0
  3. package/.examples/README.md +285 -0
  4. package/.prettierrc.js +1 -0
  5. package/README.md +261 -0
  6. package/__tests__/config.module.test.ts +244 -0
  7. package/__tests__/drivers/env.driver.test.ts +259 -0
  8. package/__tests__/services/config.service.test.ts +328 -0
  9. package/__tests__/setup.d.ts +11 -0
  10. package/__tests__/vitest.setup.ts +30 -0
  11. package/config/config.config.ts +62 -0
  12. package/dist/index.d.mts +474 -0
  13. package/dist/index.d.ts +474 -0
  14. package/dist/index.js +516 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/index.mjs +501 -0
  17. package/dist/index.mjs.map +1 -0
  18. package/eslint.config.js +13 -0
  19. package/package.json +77 -0
  20. package/src/config.module.ts +154 -0
  21. package/src/constants/index.ts +5 -0
  22. package/src/constants/tokens.constant.ts +38 -0
  23. package/src/drivers/env.driver.ts +194 -0
  24. package/src/drivers/file.driver.ts +81 -0
  25. package/src/drivers/index.ts +6 -0
  26. package/src/index.ts +92 -0
  27. package/src/interfaces/config-driver.interface.ts +30 -0
  28. package/src/interfaces/config-module-options.interface.ts +84 -0
  29. package/src/interfaces/config-service.interface.ts +71 -0
  30. package/src/interfaces/index.ts +8 -0
  31. package/src/interfaces/vite-config-plugin-options.interface.ts +56 -0
  32. package/src/plugins/index.ts +5 -0
  33. package/src/plugins/vite.plugin.ts +115 -0
  34. package/src/services/config.service.ts +172 -0
  35. package/src/services/index.ts +5 -0
  36. package/src/utils/get-nested-value.util.ts +56 -0
  37. package/src/utils/index.ts +6 -0
  38. package/src/utils/load-config-file.util.ts +37 -0
  39. package/src/utils/scan-config-files.util.ts +40 -0
  40. package/tsconfig.json +28 -0
  41. package/tsup.config.ts +105 -0
  42. package/vitest.config.ts +66 -0
package/tsup.config.ts ADDED
@@ -0,0 +1,105 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ /**
4
+ * tsup Configuration for @abdokouta/logger Package
5
+ *
6
+ * Builds the logger package with dual format output (ESM + CJS).
7
+ * Provides a flexible logging system with multiple transporters
8
+ * (console, storage, silent) and formatters (pretty, json, simple).
9
+ *
10
+ * @see https://tsup.egoist.dev/
11
+ */
12
+ export default defineConfig({
13
+ /**
14
+ * Entry point for the build.
15
+ *
16
+ * Exports the logger service, transporters, formatters, and hooks.
17
+ */
18
+ entry: ["src/index.ts"],
19
+
20
+ /**
21
+ * Dual format output (ESM + CJS).
22
+ *
23
+ * - ESM: Modern module format for tree-shaking
24
+ * - CJS: CommonJS for Node.js compatibility
25
+ */
26
+ format: ["esm", "cjs"],
27
+
28
+ /**
29
+ * Generate TypeScript declaration files.
30
+ *
31
+ * Provides full type safety for consumers.
32
+ */
33
+ dts: true,
34
+
35
+ /**
36
+ * Generate source maps for debugging.
37
+ *
38
+ * Helps developers debug issues in production.
39
+ */
40
+ sourcemap: true,
41
+
42
+ /**
43
+ * Clean output directory before each build.
44
+ *
45
+ * Prevents stale files from previous builds.
46
+ */
47
+ clean: true,
48
+
49
+ /**
50
+ * Consumers will minify during their own build.
51
+ *
52
+ * Library code should not be pre-minified to allow
53
+ * better tree-shaking and debugging.
54
+ */
55
+ minify: false,
56
+
57
+ /**
58
+ * Target ES2020 for broad compatibility.
59
+ *
60
+ * Supports modern browsers and Node.js 14+.
61
+ * Includes optional chaining, nullish coalescing, and other ES2020 features.
62
+ */
63
+ target: "es2020",
64
+
65
+ /**
66
+ * Platform-neutral build.
67
+ *
68
+ * Works in both browser and Node.js environments.
69
+ */
70
+ platform: "neutral",
71
+
72
+ /**
73
+ * External dependencies that should not be bundled.
74
+ *
75
+ * - @abdokouta/react-di: DI system (peer dependency)
76
+ * - react: React library (optional peer dependency for hooks)
77
+ */
78
+ external: ["@abdokouta/react-di", "react"],
79
+
80
+ /**
81
+ * Disable code splitting for library builds.
82
+ *
83
+ * Libraries should be single-file outputs for easier consumption.
84
+ */
85
+ splitting: false,
86
+
87
+ /**
88
+ * Skip node_modules from being processed.
89
+ *
90
+ * Improves build performance by not processing dependencies.
91
+ */
92
+ skipNodeModulesBundle: true,
93
+
94
+ /**
95
+ * Ensure proper file extensions for each format.
96
+ *
97
+ * - .mjs for ESM (explicit module format)
98
+ * - .js for CJS (CommonJS format)
99
+ *
100
+ * This ensures proper module resolution in all environments.
101
+ */
102
+ outExtension({ format }) {
103
+ return { js: format === "esm" ? ".mjs" : ".js" };
104
+ },
105
+ });
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @fileoverview Vitest configuration for @abdokouta/react-di package
3
+ *
4
+ * This configuration sets up the testing environment for the container package,
5
+ * including test globals, jsdom environment, coverage reporting, and path aliases.
6
+ *
7
+ * Configuration Features:
8
+ * - Globals: Enables global test functions (describe, it, expect)
9
+ * - Environment: Uses jsdom for React component testing
10
+ * - Setup Files: Runs vitest.setup.ts before tests
11
+ * - Coverage: Configures v8 coverage provider with HTML/JSON/text reports
12
+ * - Path Aliases: Resolves @ to ./src for consistent imports
13
+ *
14
+ * @module @abdokouta/react-di
15
+ * @category Configuration
16
+ */
17
+
18
+ import { fileURLToPath } from "url";
19
+ import { resolve, dirname } from "path";
20
+ import { defineConfig } from "vitest/config";
21
+
22
+ const __filename = fileURLToPath(import.meta.url);
23
+ const __dirname = dirname(__filename);
24
+
25
+ export default defineConfig({
26
+ test: {
27
+ // Enable global test functions (describe, it, expect, etc.)
28
+ globals: true,
29
+
30
+ // Use jsdom environment for React testing
31
+ environment: "jsdom",
32
+
33
+ // Run setup file before tests
34
+ setupFiles: ["./__tests__/vitest.setup.ts"],
35
+
36
+ // Only include __tests__ directory
37
+ include: ["__tests__/**/*.{test,spec}.{ts,tsx}"],
38
+
39
+ // Coverage configuration
40
+ coverage: {
41
+ // Use v8 coverage provider (faster than istanbul)
42
+ provider: "v8",
43
+
44
+ // Generate multiple report formats
45
+ reporter: ["text", "json", "html"],
46
+
47
+ // Exclude files from coverage
48
+ exclude: [
49
+ "node_modules/",
50
+ "dist/",
51
+ "test/",
52
+ "**/*.test.ts",
53
+ "**/*.test.tsx",
54
+ "**/*.config.ts",
55
+ ],
56
+ },
57
+ },
58
+
59
+ // Resolve path aliases
60
+ resolve: {
61
+ alias: {
62
+ // Map @ to ./src for consistent imports
63
+ "@": resolve(__dirname, "./src"),
64
+ },
65
+ },
66
+ });