@intlayer/config 1.0.1 → 1.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared configuration package for IntLayer - Layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
|
|
6
6
|
"keywords": [
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"rimraf": "5.0.5",
|
|
64
64
|
"tsup": "^8.0.2",
|
|
65
65
|
"typescript": "^5.4.3",
|
|
66
|
-
"@utils/
|
|
67
|
-
"@utils/
|
|
66
|
+
"@utils/ts-config": "^1.0.1",
|
|
67
|
+
"@utils/eslint-config": "^1.0.1"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=14.18"
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Locales } from '../types/locales';
|
|
2
2
|
|
|
3
|
-
export const LOCALES: Locales[] = [
|
|
4
|
-
Locales.ENGLISH,
|
|
5
|
-
Locales.FRENCH,
|
|
6
|
-
Locales.SPANISH,
|
|
7
|
-
];
|
|
3
|
+
export const LOCALES: Locales[] = [Locales.ENGLISH];
|
|
8
4
|
|
|
9
|
-
export const DEFAULT_LOCALE = Locales.ENGLISH;
|
|
5
|
+
export const DEFAULT_LOCALE: Locales = Locales.ENGLISH;
|
|
@@ -45,12 +45,15 @@ export const intlayerContentConfiguration: ContentConfig = {
|
|
|
45
45
|
process.env.NEXT_PUBLIC_INTLAYER_FILE_EXTENSIONS,
|
|
46
46
|
'array'
|
|
47
47
|
)!,
|
|
48
|
-
baseDir: getEnvValue(
|
|
48
|
+
baseDir: getEnvValue(process.env.NEXT_PUBLIC_INTLAYER_BASE_DIR, 'string')!,
|
|
49
49
|
contentDirName: getEnvValue(
|
|
50
50
|
process.env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR_NAME,
|
|
51
51
|
'string'
|
|
52
52
|
)!,
|
|
53
|
-
contentDir: getEnvValue(
|
|
53
|
+
contentDir: getEnvValue(
|
|
54
|
+
process.env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR,
|
|
55
|
+
'string'
|
|
56
|
+
)!,
|
|
54
57
|
excludedPath: getEnvValue<string>(
|
|
55
58
|
process.env.NEXT_PUBLIC_INTLAYER_EXCLUDED_PATH,
|
|
56
59
|
'array'
|
|
@@ -59,7 +62,10 @@ export const intlayerContentConfiguration: ContentConfig = {
|
|
|
59
62
|
process.env.NEXT_PUBLIC_INTLAYER_RESULT_DIR_NAME,
|
|
60
63
|
'string'
|
|
61
64
|
)!,
|
|
62
|
-
resultDir: getEnvValue(
|
|
65
|
+
resultDir: getEnvValue(
|
|
66
|
+
process.env.NEXT_PUBLIC_INTLAYER_RESULT_DIR,
|
|
67
|
+
'string'
|
|
68
|
+
)!,
|
|
63
69
|
moduleAugmentationDirName: getEnvValue(
|
|
64
70
|
process.env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,
|
|
65
71
|
'string'
|
|
@@ -10,11 +10,6 @@ function getEnvValue(
|
|
|
10
10
|
value: unknown,
|
|
11
11
|
type: 'string' | 'boolean' | 'number' | 'object' | 'array'
|
|
12
12
|
) {
|
|
13
|
-
// Handle cases where the environment variable is not set
|
|
14
|
-
if (value === undefined) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
try {
|
|
19
14
|
switch (type) {
|
|
20
15
|
case 'boolean':
|
|
@@ -27,12 +22,18 @@ function getEnvValue(
|
|
|
27
22
|
|
|
28
23
|
case 'string':
|
|
29
24
|
// Return the string directly
|
|
30
|
-
return value;
|
|
25
|
+
return value ?? '';
|
|
31
26
|
|
|
32
27
|
case 'object':
|
|
33
28
|
case 'array':
|
|
34
29
|
// Attempt to parse the value as JSON
|
|
35
|
-
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(value as string);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
// Log error and return undefined if any error occurs during parsing
|
|
34
|
+
console.error(`Error parsing environment variable`);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
36
37
|
|
|
37
38
|
default:
|
|
38
39
|
return undefined;
|