@intlayer/config 1.0.2 → 1.2.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.
- package/dist/cjs/configFile/buildConfigurationFields.cjs +253 -38
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/buildConfigurationFields.d.ts +3 -0
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/getConfiguration.d.ts +3 -0
- package/dist/cjs/configFile/index.cjs +3 -1
- package/dist/cjs/configFile/index.cjs.map +1 -1
- package/dist/cjs/configFile/index.d.ts +1 -0
- package/dist/cjs/configFile/loadConfigurationFile.cjs +8 -1
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/configFile/loadConfigurationFile.d.ts +6 -0
- package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.d.ts +11 -0
- package/dist/cjs/defaultValues/internationalization.cjs +1 -5
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/internationalization.d.ts +1 -1
- package/dist/cjs/defaultValues/server.cjs +0 -6
- package/dist/cjs/defaultValues/server.cjs.map +1 -1
- package/dist/cjs/defaultValues/server.d.ts +1 -3
- package/dist/cjs/envVariables/detectPlatform.cjs +53 -0
- package/dist/cjs/envVariables/detectPlatform.cjs.map +1 -0
- package/dist/cjs/envVariables/detectPlatform.d.ts +11 -0
- package/dist/cjs/envVariables/extractEnvVariable.cjs +211 -0
- package/dist/cjs/envVariables/extractEnvVariable.cjs.map +1 -0
- package/dist/cjs/envVariables/extractEnvVariable.d.ts +13 -0
- package/dist/cjs/envVariables/formatEnvVariable.cjs +6 -4
- package/dist/cjs/envVariables/formatEnvVariable.cjs.map +1 -1
- package/dist/cjs/envVariables/formatEnvVariable.d.ts +6 -1
- package/dist/cjs/envVariables/getConfiguration.cjs +37 -38
- package/dist/cjs/envVariables/getConfiguration.cjs.map +1 -1
- package/dist/cjs/envVariables/getConfiguration.d.ts +5 -0
- package/dist/cjs/envVariables/index.d.ts +1 -0
- package/dist/cjs/envVariables/utils.cjs +7 -6
- package/dist/cjs/envVariables/utils.cjs.map +1 -1
- package/dist/cjs/envVariables/utils.d.ts +5 -5
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/types/config.cjs.map +1 -1
- package/dist/cjs/types/config.d.ts +212 -6
- package/dist/cjs/types/locales.cjs.map +1 -1
- package/dist/cjs/types/locales.d.ts +233 -0
- package/dist/esm/configFile/buildConfigurationFields.d.mts +3 -0
- package/dist/esm/configFile/buildConfigurationFields.mjs +253 -40
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.d.mts +3 -0
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/index.d.mts +1 -0
- package/dist/esm/configFile/index.mjs +1 -0
- package/dist/esm/configFile/index.mjs.map +1 -1
- package/dist/esm/configFile/loadConfigurationFile.d.mts +6 -0
- package/dist/esm/configFile/loadConfigurationFile.mjs +8 -1
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/configFile/searchConfigurationFile.d.mts +11 -0
- package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
- package/dist/esm/defaultValues/internationalization.d.mts +1 -1
- package/dist/esm/defaultValues/internationalization.mjs +1 -5
- package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
- package/dist/esm/defaultValues/server.d.mts +1 -3
- package/dist/esm/defaultValues/server.mjs +0 -4
- package/dist/esm/defaultValues/server.mjs.map +1 -1
- package/dist/esm/envVariables/detectPlatform.d.mts +11 -0
- package/dist/esm/envVariables/detectPlatform.mjs +27 -0
- package/dist/esm/envVariables/detectPlatform.mjs.map +1 -0
- package/dist/esm/envVariables/extractEnvVariable.d.mts +13 -0
- package/dist/esm/envVariables/extractEnvVariable.mjs +186 -0
- package/dist/esm/envVariables/extractEnvVariable.mjs.map +1 -0
- package/dist/esm/envVariables/formatEnvVariable.d.mts +6 -1
- package/dist/esm/envVariables/formatEnvVariable.mjs +6 -4
- package/dist/esm/envVariables/formatEnvVariable.mjs.map +1 -1
- package/dist/esm/envVariables/getConfiguration.d.mts +5 -0
- package/dist/esm/envVariables/getConfiguration.mjs +37 -38
- package/dist/esm/envVariables/getConfiguration.mjs.map +1 -1
- package/dist/esm/envVariables/index.d.mts +1 -0
- package/dist/esm/envVariables/utils.d.mts +5 -5
- package/dist/esm/envVariables/utils.mjs +7 -6
- package/dist/esm/envVariables/utils.mjs.map +1 -1
- package/dist/esm/index.d.mts +1 -0
- package/dist/esm/types/config.d.mts +212 -6
- package/dist/esm/types/locales.d.mts +233 -0
- package/dist/esm/types/locales.mjs.map +1 -1
- package/package.json +7 -7
- package/src/configFile/buildConfigurationFields.ts +258 -47
- package/src/configFile/getConfiguration.ts +3 -0
- package/src/configFile/index.ts +1 -0
- package/src/configFile/loadConfigurationFile.ts +19 -1
- package/src/configFile/searchConfigurationFile.ts +11 -0
- package/src/defaultValues/server.ts +0 -4
- package/src/envVariables/detectPlatform.ts +37 -0
- package/src/envVariables/extractEnvVariable.ts +224 -0
- package/src/envVariables/formatEnvVariable.ts +17 -11
- package/src/envVariables/getConfiguration.ts +40 -41
- package/src/envVariables/utils.ts +30 -14
- package/src/types/config.ts +237 -65
- package/src/types/locales.ts +233 -233
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/defaultValues/server.ts"],"sourcesContent":["export const FILE_EXTENSIONS = ['.content.ts', '.content.js', '.content.json'];\nexport const EXCLUDED_PATHS = ['node_modules'];\n\nexport const CONTENT_DIR_NAME = 'src';\n\nexport const RESULT_DIR_NAME = '.intlayer';\n\nexport const MODULE_AUGMENTATION_DIR_NAME = 'types';\n\nexport const
|
|
1
|
+
{"version":3,"sources":["../../../src/defaultValues/server.ts"],"sourcesContent":["export const FILE_EXTENSIONS = ['.content.ts', '.content.js', '.content.json'];\nexport const EXCLUDED_PATHS = ['node_modules'];\n\nexport const CONTENT_DIR_NAME = 'src';\n\nexport const RESULT_DIR_NAME = '.intlayer';\n\nexport const MODULE_AUGMENTATION_DIR_NAME = 'types';\n\nexport const DICTIONARIES_DIR_NAME = 'dictionary';\n\nexport const TYPES_DIR_NAME = 'types';\n\nexport const MAIN_DIR_NAME = 'main';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,kBAAkB,CAAC,eAAe,eAAe,eAAe;AACtE,MAAM,iBAAiB,CAAC,cAAc;AAEtC,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB;AAExB,MAAM,+BAA+B;AAErC,MAAM,wBAAwB;AAE9B,MAAM,iBAAiB;AAEvB,MAAM,gBAAgB;","names":[]}
|
|
@@ -3,10 +3,8 @@ declare const EXCLUDED_PATHS: string[];
|
|
|
3
3
|
declare const CONTENT_DIR_NAME = "src";
|
|
4
4
|
declare const RESULT_DIR_NAME = ".intlayer";
|
|
5
5
|
declare const MODULE_AUGMENTATION_DIR_NAME = "types";
|
|
6
|
-
declare const BUNDLE_DIR_NAME = "bundle";
|
|
7
|
-
declare const BUNDLE_FILE_EXTENSION = ".bundle.js";
|
|
8
6
|
declare const DICTIONARIES_DIR_NAME = "dictionary";
|
|
9
7
|
declare const TYPES_DIR_NAME = "types";
|
|
10
8
|
declare const MAIN_DIR_NAME = "main";
|
|
11
9
|
|
|
12
|
-
export {
|
|
10
|
+
export { CONTENT_DIR_NAME, DICTIONARIES_DIR_NAME, EXCLUDED_PATHS, FILE_EXTENSIONS, MAIN_DIR_NAME, MODULE_AUGMENTATION_DIR_NAME, RESULT_DIR_NAME, TYPES_DIR_NAME };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var detectPlatform_exports = {};
|
|
20
|
+
__export(detectPlatform_exports, {
|
|
21
|
+
getPlatform: () => getPlatform,
|
|
22
|
+
getPrefix: () => getPrefix
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(detectPlatform_exports);
|
|
25
|
+
const import_meta = {};
|
|
26
|
+
const getPlatform = () => {
|
|
27
|
+
if (typeof process.env.NEXT_PUBLIC_INTLAYER_DEFAULT_LOCALE === "string") {
|
|
28
|
+
return "next";
|
|
29
|
+
} else if (typeof process.env.REACT_APP_INTLAYER_DEFAULT_LOCALE === "string") {
|
|
30
|
+
return "react_app";
|
|
31
|
+
} else if (import_meta?.env?.VITE_INTLAYER_DEFAULT_LOCALE) {
|
|
32
|
+
return "vite";
|
|
33
|
+
}
|
|
34
|
+
return "unknown";
|
|
35
|
+
};
|
|
36
|
+
const getPrefix = (platform) => {
|
|
37
|
+
switch (platform) {
|
|
38
|
+
case "next":
|
|
39
|
+
return "NEXT_PUBLIC_INTLAYER_";
|
|
40
|
+
case "vite":
|
|
41
|
+
return "VITE_INTLAYER_";
|
|
42
|
+
case "react_app":
|
|
43
|
+
return "REACT_APP_INTLAYER_";
|
|
44
|
+
default:
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
getPlatform,
|
|
51
|
+
getPrefix
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=detectPlatform.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/envVariables/detectPlatform.ts"],"sourcesContent":["export type Platform = 'next' | 'vite' | 'react_app' | 'unknown';\nexport type ViteEnvVar = { env: Record<string, string> };\n\nexport const getPlatform = (): Platform => {\n if (typeof process.env.NEXT_PUBLIC_INTLAYER_DEFAULT_LOCALE === 'string') {\n // Likely Next.js\n return 'next';\n } else if (\n typeof process.env.REACT_APP_INTLAYER_DEFAULT_LOCALE === 'string'\n ) {\n // Likely Create React App\n return 'react_app';\n } else if (\n (import.meta as unknown as ViteEnvVar)?.env?.VITE_INTLAYER_DEFAULT_LOCALE\n ) {\n // Likely Vite\n return 'vite';\n }\n\n return 'unknown';\n};\n\n/**\n * Get the prefix for the environment variables to be used in the platform\n */\nexport const getPrefix = (platform: Platform): string => {\n switch (platform) {\n case 'next':\n return 'NEXT_PUBLIC_INTLAYER_';\n case 'vite':\n return 'VITE_INTLAYER_';\n case 'react_app':\n return 'REACT_APP_INTLAYER_';\n default:\n return '';\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,MAAgB;AACzC,MAAI,OAAO,QAAQ,IAAI,wCAAwC,UAAU;AAEvE,WAAO;AAAA,EACT,WACE,OAAO,QAAQ,IAAI,sCAAsC,UACzD;AAEA,WAAO;AAAA,EACT,WACG,aAAuC,KAAK,8BAC7C;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAKO,MAAM,YAAY,CAAC,aAA+B;AACvD,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Platform = 'next' | 'vite' | 'react_app' | 'unknown';
|
|
2
|
+
type ViteEnvVar = {
|
|
3
|
+
env: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
declare const getPlatform: () => Platform;
|
|
6
|
+
/**
|
|
7
|
+
* Get the prefix for the environment variables to be used in the platform
|
|
8
|
+
*/
|
|
9
|
+
declare const getPrefix: (platform: Platform) => string;
|
|
10
|
+
|
|
11
|
+
export { type Platform, type ViteEnvVar, getPlatform, getPrefix };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var extractEnvVariable_exports = {};
|
|
20
|
+
__export(extractEnvVariable_exports, {
|
|
21
|
+
extractEnvVariable: () => extractEnvVariable
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(extractEnvVariable_exports);
|
|
24
|
+
var import_detectPlatform = require('./detectPlatform.cjs');
|
|
25
|
+
const import_meta = {};
|
|
26
|
+
const extractNextEnvVariable = () => {
|
|
27
|
+
if (typeof process === "undefined") {
|
|
28
|
+
return extractEmptyEnvVariable();
|
|
29
|
+
}
|
|
30
|
+
const env = process.env;
|
|
31
|
+
const intlayerIntlConfiguration = {
|
|
32
|
+
locales: env.NEXT_PUBLIC_INTLAYER_LOCALES,
|
|
33
|
+
defaultLocale: env.NEXT_PUBLIC_INTLAYER_DEFAULT_LOCALE
|
|
34
|
+
};
|
|
35
|
+
const intlayerMiddlewareConfiguration = {
|
|
36
|
+
headerName: env.NEXT_PUBLIC_INTLAYER_HEADER_NAME,
|
|
37
|
+
cookieName: env.NEXT_PUBLIC_INTLAYER_COOKIE_NAME,
|
|
38
|
+
prefixDefault: env.NEXT_PUBLIC_INTLAYER_PREFIX_DEFAULT,
|
|
39
|
+
basePath: env.NEXT_PUBLIC_INTLAYER_BASE_PATH,
|
|
40
|
+
serverSetCookie: env.NEXT_PUBLIC_INTLAYER_SERVER_SET_COOKIE,
|
|
41
|
+
noPrefix: env.NEXT_PUBLIC_INTLAYER_NO_PREFIX
|
|
42
|
+
};
|
|
43
|
+
const intlayerContentConfiguration = {
|
|
44
|
+
fileExtensions: env.NEXT_PUBLIC_INTLAYER_FILE_EXTENSIONS,
|
|
45
|
+
baseDir: env.NEXT_PUBLIC_INTLAYER_BASE_DIR,
|
|
46
|
+
contentDirName: env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR_NAME,
|
|
47
|
+
contentDir: env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR,
|
|
48
|
+
excludedPath: env.NEXT_PUBLIC_INTLAYER_EXCLUDED_PATH,
|
|
49
|
+
resultDirName: env.NEXT_PUBLIC_INTLAYER_RESULT_DIR_NAME,
|
|
50
|
+
moduleAugmentationDirName: env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,
|
|
51
|
+
dictionariesDirName: env.NEXT_PUBLIC_INTLAYER_DICTIONARIES_DIR_NAME,
|
|
52
|
+
typeDirName: env.NEXT_PUBLIC_INTLAYER_TYPE_DIR_NAME,
|
|
53
|
+
mainDirName: env.NEXT_PUBLIC_INTLAYER_MAIN_DIR_NAME,
|
|
54
|
+
resultDir: env.NEXT_PUBLIC_INTLAYER_RESULT_DIR,
|
|
55
|
+
moduleAugmentationDir: env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR,
|
|
56
|
+
dictionariesDir: env.NEXT_PUBLIC_INTLAYER_DICTIONARIES_DIR,
|
|
57
|
+
typesDir: env.NEXT_PUBLIC_INTLAYER_TYPE_DIR,
|
|
58
|
+
mainDir: env.NEXT_PUBLIC_INTLAYER_MAIN_DIR,
|
|
59
|
+
watchedFilesPattern: env.NEXT_PUBLIC_INTLAYER_WATCHED_FILES_PATTERN,
|
|
60
|
+
watchedFilesPatternWithPath: env.NEXT_PUBLIC_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,
|
|
61
|
+
outputFilesPatternWithPath: env.NEXT_PUBLIC_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
intlayerIntlConfiguration,
|
|
65
|
+
intlayerMiddlewareConfiguration,
|
|
66
|
+
intlayerContentConfiguration
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const extractReactAppEnvVariable = () => {
|
|
70
|
+
if (typeof process === "undefined") {
|
|
71
|
+
return extractEmptyEnvVariable();
|
|
72
|
+
}
|
|
73
|
+
const env = process.env;
|
|
74
|
+
const intlayerIntlConfiguration = {
|
|
75
|
+
locales: env.REACT_APP_INTLAYER_LOCALES,
|
|
76
|
+
defaultLocale: env.REACT_APP_INTLAYER_DEFAULT_LOCALE
|
|
77
|
+
};
|
|
78
|
+
const intlayerMiddlewareConfiguration = {
|
|
79
|
+
headerName: env.REACT_APP_INTLAYER_HEADER_NAME,
|
|
80
|
+
cookieName: env.REACT_APP_INTLAYER_COOKIE_NAME,
|
|
81
|
+
prefixDefault: env.REACT_APP_INTLAYER_PREFIX_DEFAULT,
|
|
82
|
+
basePath: env.REACT_APP_INTLAYER_BASE_PATH,
|
|
83
|
+
serverSetCookie: env.REACT_APP_INTLAYER_SERVER_SET_COOKIE,
|
|
84
|
+
noPrefix: env.REACT_APP_INTLAYER_NO_PREFIX
|
|
85
|
+
};
|
|
86
|
+
const intlayerContentConfiguration = {
|
|
87
|
+
fileExtensions: env.REACT_APP_INTLAYER_FILE_EXTENSIONS,
|
|
88
|
+
baseDir: env.REACT_APP_INTLAYER_BASE_DIR,
|
|
89
|
+
contentDirName: env.REACT_APP_INTLAYER_CONTENT_DIR_NAME,
|
|
90
|
+
contentDir: env.REACT_APP_INTLAYER_CONTENT_DIR,
|
|
91
|
+
excludedPath: env.REACT_APP_INTLAYER_EXCLUDED_PATH,
|
|
92
|
+
resultDirName: env.REACT_APP_INTLAYER_RESULT_DIR_NAME,
|
|
93
|
+
moduleAugmentationDirName: env.REACT_APP_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,
|
|
94
|
+
dictionariesDirName: env.REACT_APP_INTLAYER_DICTIONARIES_DIR_NAME,
|
|
95
|
+
typeDirName: env.REACT_APP_INTLAYER_TYPE_DIR_NAME,
|
|
96
|
+
mainDirName: env.REACT_APP_INTLAYER_MAIN_DIR_NAME,
|
|
97
|
+
resultDir: env.REACT_APP_INTLAYER_RESULT_DIR,
|
|
98
|
+
moduleAugmentationDir: env.REACT_APP_INTLAYER_MODULE_AUGMENTATION_DIR,
|
|
99
|
+
dictionariesDir: env.REACT_APP_INTLAYER_DICTIONARIES_DIR,
|
|
100
|
+
typesDir: env.REACT_APP_INTLAYER_TYPE_DIR,
|
|
101
|
+
mainDir: env.REACT_APP_INTLAYER_MAIN_DIR,
|
|
102
|
+
watchedFilesPattern: env.REACT_APP_INTLAYER_WATCHED_FILES_PATTERN,
|
|
103
|
+
watchedFilesPatternWithPath: env.REACT_APP_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,
|
|
104
|
+
outputFilesPatternWithPath: env.REACT_APP_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
intlayerIntlConfiguration,
|
|
108
|
+
intlayerMiddlewareConfiguration,
|
|
109
|
+
intlayerContentConfiguration
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
const extractViteEnvVariable = () => {
|
|
113
|
+
const env = import_meta.env;
|
|
114
|
+
if (typeof env === "undefined") {
|
|
115
|
+
return extractEmptyEnvVariable();
|
|
116
|
+
}
|
|
117
|
+
const intlayerIntlConfiguration = {
|
|
118
|
+
locales: env.VITE_INTLAYER_LOCALES,
|
|
119
|
+
defaultLocale: env.VITE_INTLAYER_DEFAULT_LOCALE
|
|
120
|
+
};
|
|
121
|
+
const intlayerMiddlewareConfiguration = {
|
|
122
|
+
headerName: env.VITE_INTLAYER_HEADER_NAME,
|
|
123
|
+
cookieName: env.VITE_INTLAYER_COOKIE_NAME,
|
|
124
|
+
prefixDefault: env.VITE_INTLAYER_PREFIX_DEFAULT,
|
|
125
|
+
basePath: env.VITE_INTLAYER_BASE_PATH,
|
|
126
|
+
serverSetCookie: env.VITE_INTLAYER_SERVER_SET_COOKIE,
|
|
127
|
+
noPrefix: env.VITE_INTLAYER_NO_PREFIX
|
|
128
|
+
};
|
|
129
|
+
const intlayerContentConfiguration = {
|
|
130
|
+
fileExtensions: env.VITE_INTLAYER_FILE_EXTENSIONS,
|
|
131
|
+
baseDir: env.VITE_INTLAYER_BASE_DIR,
|
|
132
|
+
contentDirName: env.VITE_INTLAYER_CONTENT_DIR_NAME,
|
|
133
|
+
contentDir: env.VITE_INTLAYER_CONTENT_DIR,
|
|
134
|
+
excludedPath: env.VITE_INTLAYER_EXCLUDED_PATH,
|
|
135
|
+
resultDirName: env.VITE_INTLAYER_RESULT_DIR_NAME,
|
|
136
|
+
moduleAugmentationDirName: env.VITE_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,
|
|
137
|
+
dictionariesDirName: env.VITE_INTLAYER_DICTIONARIES_DIR_NAME,
|
|
138
|
+
typeDirName: env.VITE_INTLAYER_TYPE_DIR_NAME,
|
|
139
|
+
mainDirName: env.VITE_INTLAYER_MAIN_DIR_NAME,
|
|
140
|
+
resultDir: env.VITE_INTLAYER_RESULT_DIR,
|
|
141
|
+
moduleAugmentationDir: env.VITE_INTLAYER_MODULE_AUGMENTATION_DIR,
|
|
142
|
+
dictionariesDir: env.VITE_INTLAYER_DICTIONARIES_DIR,
|
|
143
|
+
typesDir: env.VITE_INTLAYER_TYPE_DIR,
|
|
144
|
+
mainDir: env.VITE_INTLAYER_MAIN_DIR,
|
|
145
|
+
watchedFilesPattern: env.VITE_INTLAYER_WATCHED_FILES_PATTERN,
|
|
146
|
+
watchedFilesPatternWithPath: env.VITE_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,
|
|
147
|
+
outputFilesPatternWithPath: env.VITE_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH
|
|
148
|
+
};
|
|
149
|
+
return {
|
|
150
|
+
intlayerIntlConfiguration,
|
|
151
|
+
intlayerMiddlewareConfiguration,
|
|
152
|
+
intlayerContentConfiguration
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
const extractEmptyEnvVariable = () => {
|
|
156
|
+
const intlayerIntlConfiguration = {
|
|
157
|
+
locales: void 0,
|
|
158
|
+
defaultLocale: void 0
|
|
159
|
+
};
|
|
160
|
+
const intlayerMiddlewareConfiguration = {
|
|
161
|
+
headerName: void 0,
|
|
162
|
+
cookieName: void 0,
|
|
163
|
+
prefixDefault: void 0,
|
|
164
|
+
basePath: void 0,
|
|
165
|
+
serverSetCookie: void 0,
|
|
166
|
+
noPrefix: void 0
|
|
167
|
+
};
|
|
168
|
+
const intlayerContentConfiguration = {
|
|
169
|
+
fileExtensions: void 0,
|
|
170
|
+
baseDir: void 0,
|
|
171
|
+
contentDirName: void 0,
|
|
172
|
+
contentDir: void 0,
|
|
173
|
+
excludedPath: void 0,
|
|
174
|
+
resultDirName: void 0,
|
|
175
|
+
moduleAugmentationDirName: void 0,
|
|
176
|
+
dictionariesDirName: void 0,
|
|
177
|
+
typeDirName: void 0,
|
|
178
|
+
mainDirName: void 0,
|
|
179
|
+
resultDir: void 0,
|
|
180
|
+
moduleAugmentationDir: void 0,
|
|
181
|
+
dictionariesDir: void 0,
|
|
182
|
+
typesDir: void 0,
|
|
183
|
+
mainDir: void 0,
|
|
184
|
+
watchedFilesPattern: void 0,
|
|
185
|
+
watchedFilesPatternWithPath: void 0,
|
|
186
|
+
outputFilesPatternWithPath: void 0
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
intlayerIntlConfiguration,
|
|
190
|
+
intlayerMiddlewareConfiguration,
|
|
191
|
+
intlayerContentConfiguration
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
const extractEnvVariable = () => {
|
|
195
|
+
const platform = (0, import_detectPlatform.getPlatform)();
|
|
196
|
+
switch (platform) {
|
|
197
|
+
case "next":
|
|
198
|
+
return extractNextEnvVariable();
|
|
199
|
+
case "vite":
|
|
200
|
+
return extractViteEnvVariable();
|
|
201
|
+
case "react_app":
|
|
202
|
+
return extractReactAppEnvVariable();
|
|
203
|
+
default:
|
|
204
|
+
return extractEmptyEnvVariable();
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
+
0 && (module.exports = {
|
|
209
|
+
extractEnvVariable
|
|
210
|
+
});
|
|
211
|
+
//# sourceMappingURL=extractEnvVariable.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/envVariables/extractEnvVariable.ts"],"sourcesContent":["import type {\n InternationalizationConfig,\n MiddlewareConfig,\n ContentConfig,\n} from '../types/config';\nimport { type ViteEnvVar, getPlatform } from './detectPlatform';\n\n// Utility type that replaces all values of a given type with another type\ntype ReplaceValue<T> = {\n [K in keyof T]: string | undefined;\n};\n\nconst extractNextEnvVariable = () => {\n if (typeof process === 'undefined') {\n return extractEmptyEnvVariable();\n }\n\n const env = process.env;\n\n const intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig> = {\n locales: env.NEXT_PUBLIC_INTLAYER_LOCALES,\n defaultLocale: env.NEXT_PUBLIC_INTLAYER_DEFAULT_LOCALE,\n };\n\n const intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig> = {\n headerName: env.NEXT_PUBLIC_INTLAYER_HEADER_NAME,\n cookieName: env.NEXT_PUBLIC_INTLAYER_COOKIE_NAME,\n prefixDefault: env.NEXT_PUBLIC_INTLAYER_PREFIX_DEFAULT,\n basePath: env.NEXT_PUBLIC_INTLAYER_BASE_PATH,\n serverSetCookie: env.NEXT_PUBLIC_INTLAYER_SERVER_SET_COOKIE,\n noPrefix: env.NEXT_PUBLIC_INTLAYER_NO_PREFIX,\n };\n\n const intlayerContentConfiguration: ReplaceValue<ContentConfig> = {\n fileExtensions: env.NEXT_PUBLIC_INTLAYER_FILE_EXTENSIONS,\n baseDir: env.NEXT_PUBLIC_INTLAYER_BASE_DIR,\n contentDirName: env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR_NAME,\n contentDir: env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR,\n excludedPath: env.NEXT_PUBLIC_INTLAYER_EXCLUDED_PATH,\n resultDirName: env.NEXT_PUBLIC_INTLAYER_RESULT_DIR_NAME,\n moduleAugmentationDirName:\n env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,\n dictionariesDirName: env.NEXT_PUBLIC_INTLAYER_DICTIONARIES_DIR_NAME,\n typeDirName: env.NEXT_PUBLIC_INTLAYER_TYPE_DIR_NAME,\n mainDirName: env.NEXT_PUBLIC_INTLAYER_MAIN_DIR_NAME,\n resultDir: env.NEXT_PUBLIC_INTLAYER_RESULT_DIR,\n moduleAugmentationDir: env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR,\n dictionariesDir: env.NEXT_PUBLIC_INTLAYER_DICTIONARIES_DIR,\n typesDir: env.NEXT_PUBLIC_INTLAYER_TYPE_DIR,\n mainDir: env.NEXT_PUBLIC_INTLAYER_MAIN_DIR,\n watchedFilesPattern: env.NEXT_PUBLIC_INTLAYER_WATCHED_FILES_PATTERN,\n watchedFilesPatternWithPath:\n env.NEXT_PUBLIC_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,\n outputFilesPatternWithPath:\n env.NEXT_PUBLIC_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH,\n };\n\n return {\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n intlayerContentConfiguration,\n };\n};\n\nconst extractReactAppEnvVariable = () => {\n if (typeof process === 'undefined') {\n return extractEmptyEnvVariable();\n }\n\n const env = process.env;\n\n const intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig> = {\n locales: env.REACT_APP_INTLAYER_LOCALES,\n defaultLocale: env.REACT_APP_INTLAYER_DEFAULT_LOCALE,\n };\n\n const intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig> = {\n headerName: env.REACT_APP_INTLAYER_HEADER_NAME,\n cookieName: env.REACT_APP_INTLAYER_COOKIE_NAME,\n prefixDefault: env.REACT_APP_INTLAYER_PREFIX_DEFAULT,\n basePath: env.REACT_APP_INTLAYER_BASE_PATH,\n serverSetCookie: env.REACT_APP_INTLAYER_SERVER_SET_COOKIE,\n noPrefix: env.REACT_APP_INTLAYER_NO_PREFIX,\n };\n\n const intlayerContentConfiguration: ReplaceValue<ContentConfig> = {\n fileExtensions: env.REACT_APP_INTLAYER_FILE_EXTENSIONS,\n baseDir: env.REACT_APP_INTLAYER_BASE_DIR,\n contentDirName: env.REACT_APP_INTLAYER_CONTENT_DIR_NAME,\n contentDir: env.REACT_APP_INTLAYER_CONTENT_DIR,\n excludedPath: env.REACT_APP_INTLAYER_EXCLUDED_PATH,\n resultDirName: env.REACT_APP_INTLAYER_RESULT_DIR_NAME,\n moduleAugmentationDirName:\n env.REACT_APP_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,\n dictionariesDirName: env.REACT_APP_INTLAYER_DICTIONARIES_DIR_NAME,\n typeDirName: env.REACT_APP_INTLAYER_TYPE_DIR_NAME,\n mainDirName: env.REACT_APP_INTLAYER_MAIN_DIR_NAME,\n resultDir: env.REACT_APP_INTLAYER_RESULT_DIR,\n moduleAugmentationDir: env.REACT_APP_INTLAYER_MODULE_AUGMENTATION_DIR,\n dictionariesDir: env.REACT_APP_INTLAYER_DICTIONARIES_DIR,\n typesDir: env.REACT_APP_INTLAYER_TYPE_DIR,\n mainDir: env.REACT_APP_INTLAYER_MAIN_DIR,\n watchedFilesPattern: env.REACT_APP_INTLAYER_WATCHED_FILES_PATTERN,\n watchedFilesPatternWithPath:\n env.REACT_APP_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,\n outputFilesPatternWithPath:\n env.REACT_APP_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH,\n };\n\n return {\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n intlayerContentConfiguration,\n };\n};\n\nconst extractViteEnvVariable = () => {\n const env = (import.meta as unknown as ViteEnvVar).env;\n\n if (typeof env === 'undefined') {\n return extractEmptyEnvVariable();\n }\n\n const intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig> = {\n locales: env.VITE_INTLAYER_LOCALES,\n defaultLocale: env.VITE_INTLAYER_DEFAULT_LOCALE,\n };\n\n const intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig> = {\n headerName: env.VITE_INTLAYER_HEADER_NAME,\n cookieName: env.VITE_INTLAYER_COOKIE_NAME,\n prefixDefault: env.VITE_INTLAYER_PREFIX_DEFAULT,\n basePath: env.VITE_INTLAYER_BASE_PATH,\n serverSetCookie: env.VITE_INTLAYER_SERVER_SET_COOKIE,\n noPrefix: env.VITE_INTLAYER_NO_PREFIX,\n };\n\n const intlayerContentConfiguration: ReplaceValue<ContentConfig> = {\n fileExtensions: env.VITE_INTLAYER_FILE_EXTENSIONS,\n baseDir: env.VITE_INTLAYER_BASE_DIR,\n contentDirName: env.VITE_INTLAYER_CONTENT_DIR_NAME,\n contentDir: env.VITE_INTLAYER_CONTENT_DIR,\n excludedPath: env.VITE_INTLAYER_EXCLUDED_PATH,\n resultDirName: env.VITE_INTLAYER_RESULT_DIR_NAME,\n moduleAugmentationDirName: env.VITE_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,\n dictionariesDirName: env.VITE_INTLAYER_DICTIONARIES_DIR_NAME,\n typeDirName: env.VITE_INTLAYER_TYPE_DIR_NAME,\n mainDirName: env.VITE_INTLAYER_MAIN_DIR_NAME,\n resultDir: env.VITE_INTLAYER_RESULT_DIR,\n moduleAugmentationDir: env.VITE_INTLAYER_MODULE_AUGMENTATION_DIR,\n dictionariesDir: env.VITE_INTLAYER_DICTIONARIES_DIR,\n typesDir: env.VITE_INTLAYER_TYPE_DIR,\n mainDir: env.VITE_INTLAYER_MAIN_DIR,\n watchedFilesPattern: env.VITE_INTLAYER_WATCHED_FILES_PATTERN,\n watchedFilesPatternWithPath:\n env.VITE_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,\n outputFilesPatternWithPath:\n env.VITE_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH,\n };\n\n return {\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n intlayerContentConfiguration,\n };\n};\n\nconst extractEmptyEnvVariable = () => {\n const intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig> = {\n locales: undefined,\n defaultLocale: undefined,\n };\n\n const intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig> = {\n headerName: undefined,\n cookieName: undefined,\n prefixDefault: undefined,\n basePath: undefined,\n serverSetCookie: undefined,\n noPrefix: undefined,\n };\n\n const intlayerContentConfiguration: ReplaceValue<ContentConfig> = {\n fileExtensions: undefined,\n baseDir: undefined,\n contentDirName: undefined,\n contentDir: undefined,\n excludedPath: undefined,\n resultDirName: undefined,\n moduleAugmentationDirName: undefined,\n dictionariesDirName: undefined,\n typeDirName: undefined,\n mainDirName: undefined,\n resultDir: undefined,\n moduleAugmentationDir: undefined,\n dictionariesDir: undefined,\n typesDir: undefined,\n mainDir: undefined,\n watchedFilesPattern: undefined,\n watchedFilesPatternWithPath: undefined,\n outputFilesPatternWithPath: undefined,\n };\n\n return {\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n intlayerContentConfiguration,\n };\n};\n\nexport const extractEnvVariable = () => {\n const platform = getPlatform();\n\n switch (platform) {\n case 'next':\n return extractNextEnvVariable();\n case 'vite':\n return extractViteEnvVariable();\n case 'react_app':\n return extractReactAppEnvVariable();\n default:\n return extractEmptyEnvVariable();\n }\n};\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InternationalizationConfig, MiddlewareConfig, ContentConfig } from '../types/config.js';
|
|
2
|
+
import '../types/locales.js';
|
|
3
|
+
|
|
4
|
+
type ReplaceValue<T> = {
|
|
5
|
+
[K in keyof T]: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
declare const extractEnvVariable: () => {
|
|
8
|
+
intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig>;
|
|
9
|
+
intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig>;
|
|
10
|
+
intlayerContentConfiguration: ReplaceValue<ContentConfig>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { extractEnvVariable };
|
|
@@ -22,9 +22,11 @@ __export(formatEnvVariable_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(formatEnvVariable_exports);
|
|
24
24
|
var import_getConfiguration = require('../configFile/getConfiguration.cjs');
|
|
25
|
-
|
|
25
|
+
var import_detectPlatform = require('./detectPlatform.cjs');
|
|
26
|
+
const formatEnvName = (key, prefix) => prefix + key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
27
|
+
const formatEnvVariable = (platform) => {
|
|
26
28
|
const intlayerConfig = (0, import_getConfiguration.getConfiguration)();
|
|
27
|
-
const
|
|
29
|
+
const prefix = (0, import_detectPlatform.getPrefix)(platform);
|
|
28
30
|
const env = {};
|
|
29
31
|
for (const [key, value] of Object.entries({
|
|
30
32
|
...intlayerConfig.content,
|
|
@@ -32,9 +34,9 @@ const formatEnvVariable = (prefix = "NEXT_PUBLIC_INTLAYER_") => {
|
|
|
32
34
|
...intlayerConfig.middleware
|
|
33
35
|
})) {
|
|
34
36
|
if (typeof value === "string") {
|
|
35
|
-
env[formatEnvName(key)] = value;
|
|
37
|
+
env[formatEnvName(key, prefix)] = value;
|
|
36
38
|
} else {
|
|
37
|
-
env[formatEnvName(key)] = JSON.stringify(value);
|
|
39
|
+
env[formatEnvName(key, prefix)] = JSON.stringify(value);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
return env;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/envVariables/formatEnvVariable.ts"],"sourcesContent":["import { getConfiguration } from '../configFile/getConfiguration';\
|
|
1
|
+
{"version":3,"sources":["../../../src/envVariables/formatEnvVariable.ts"],"sourcesContent":["import { getConfiguration } from '../configFile/getConfiguration';\nimport { getPrefix, type Platform } from './detectPlatform';\n\n/**\n * Format a key to corresponding environment variable name\n *\n * Example:\n * toEnvVariable('mainDir') => 'INTLAYER_MAIN_DIR'\n */\nconst formatEnvName = (key: string, prefix: string): string =>\n prefix + key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();\n\n/**\n * Format all configuration values as environment variables\n */\nexport const formatEnvVariable = (\n platform: Platform\n): Record<string, string> => {\n const intlayerConfig = getConfiguration();\n\n const prefix = getPrefix(platform);\n\n // Set all configuration values as environment variables\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries({\n ...intlayerConfig.content,\n ...intlayerConfig.internationalization,\n ...intlayerConfig.middleware,\n })) {\n if (typeof value === 'string') {\n env[formatEnvName(key, prefix)] = value;\n } else {\n env[formatEnvName(key, prefix)] = JSON.stringify(value);\n }\n }\n\n return env;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AACjC,4BAAyC;AAQzC,MAAM,gBAAgB,CAAC,KAAa,WAClC,SAAS,IAAI,QAAQ,sBAAsB,OAAO,EAAE,YAAY;AAK3D,MAAM,oBAAoB,CAC/B,aAC2B;AAC3B,QAAM,qBAAiB,0CAAiB;AAExC,QAAM,aAAS,iCAAU,QAAQ;AAGjC,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ;AAAA,IACxC,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,EACpB,CAAC,GAAG;AACF,QAAI,OAAO,UAAU,UAAU;AAC7B,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI;AAAA,IACpC,OAAO;AACL,UAAI,cAAc,KAAK,MAAM,CAAC,IAAI,KAAK,UAAU,KAAK;AAAA,IACxD;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { Platform } from './detectPlatform.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Format all configuration values as environment variables
|
|
5
|
+
*/
|
|
6
|
+
declare const formatEnvVariable: (platform: Platform) => Record<string, string>;
|
|
2
7
|
|
|
3
8
|
export { formatEnvVariable };
|
|
@@ -25,105 +25,104 @@ __export(getConfiguration_exports, {
|
|
|
25
25
|
intlayerMiddlewareConfiguration: () => intlayerMiddlewareConfiguration
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(getConfiguration_exports);
|
|
28
|
+
var import_extractEnvVariable = require('./extractEnvVariable.cjs');
|
|
28
29
|
var import_utils = require('./utils.cjs');
|
|
30
|
+
const env = (0, import_extractEnvVariable.extractEnvVariable)();
|
|
29
31
|
const intlayerIntlConfiguration = {
|
|
30
32
|
locales: (0, import_utils.getEnvValue)(
|
|
31
|
-
|
|
33
|
+
env.intlayerIntlConfiguration.locales,
|
|
32
34
|
"array"
|
|
33
35
|
),
|
|
34
36
|
defaultLocale: (0, import_utils.getEnvValue)(
|
|
35
|
-
|
|
37
|
+
env.intlayerIntlConfiguration.defaultLocale,
|
|
36
38
|
"string"
|
|
37
39
|
)
|
|
38
40
|
};
|
|
39
41
|
const intlayerMiddlewareConfiguration = {
|
|
40
42
|
headerName: (0, import_utils.getEnvValue)(
|
|
41
|
-
|
|
43
|
+
env.intlayerMiddlewareConfiguration.headerName,
|
|
42
44
|
"string"
|
|
43
45
|
),
|
|
44
46
|
cookieName: (0, import_utils.getEnvValue)(
|
|
45
|
-
|
|
47
|
+
env.intlayerMiddlewareConfiguration.cookieName,
|
|
46
48
|
"string"
|
|
47
49
|
),
|
|
48
50
|
prefixDefault: (0, import_utils.getEnvValue)(
|
|
49
|
-
|
|
51
|
+
env.intlayerMiddlewareConfiguration.prefixDefault,
|
|
50
52
|
"boolean"
|
|
51
53
|
),
|
|
52
|
-
basePath: (0, import_utils.getEnvValue)(
|
|
54
|
+
basePath: (0, import_utils.getEnvValue)(
|
|
55
|
+
env.intlayerMiddlewareConfiguration.basePath,
|
|
56
|
+
"string"
|
|
57
|
+
),
|
|
53
58
|
serverSetCookie: (0, import_utils.getEnvValue)(
|
|
54
|
-
|
|
59
|
+
env.intlayerMiddlewareConfiguration.serverSetCookie,
|
|
55
60
|
"string"
|
|
56
61
|
),
|
|
57
|
-
noPrefix: (0, import_utils.getEnvValue)(
|
|
62
|
+
noPrefix: (0, import_utils.getEnvValue)(
|
|
63
|
+
env.intlayerMiddlewareConfiguration.noPrefix,
|
|
64
|
+
"boolean"
|
|
65
|
+
)
|
|
58
66
|
};
|
|
59
67
|
const intlayerContentConfiguration = {
|
|
60
68
|
fileExtensions: (0, import_utils.getEnvValue)(
|
|
61
|
-
|
|
69
|
+
env.intlayerContentConfiguration.fileExtensions,
|
|
62
70
|
"array"
|
|
63
71
|
),
|
|
64
|
-
baseDir: (0, import_utils.getEnvValue)(
|
|
72
|
+
baseDir: (0, import_utils.getEnvValue)(env.intlayerContentConfiguration.baseDir, "string"),
|
|
65
73
|
contentDirName: (0, import_utils.getEnvValue)(
|
|
66
|
-
|
|
74
|
+
env.intlayerContentConfiguration.contentDirName,
|
|
75
|
+
"string"
|
|
76
|
+
),
|
|
77
|
+
contentDir: (0, import_utils.getEnvValue)(
|
|
78
|
+
env.intlayerContentConfiguration.contentDir,
|
|
67
79
|
"string"
|
|
68
80
|
),
|
|
69
|
-
contentDir: (0, import_utils.getEnvValue)("NEXT_PUBLIC_INTLAYER_CONTENT_DIR", "string"),
|
|
70
81
|
excludedPath: (0, import_utils.getEnvValue)(
|
|
71
|
-
|
|
82
|
+
env.intlayerContentConfiguration.excludedPath,
|
|
72
83
|
"array"
|
|
73
84
|
),
|
|
74
85
|
resultDirName: (0, import_utils.getEnvValue)(
|
|
75
|
-
|
|
86
|
+
env.intlayerContentConfiguration.resultDirName,
|
|
76
87
|
"string"
|
|
77
88
|
),
|
|
78
|
-
resultDir: (0, import_utils.getEnvValue)(
|
|
89
|
+
resultDir: (0, import_utils.getEnvValue)(env.intlayerContentConfiguration.resultDir, "string"),
|
|
79
90
|
moduleAugmentationDirName: (0, import_utils.getEnvValue)(
|
|
80
|
-
|
|
91
|
+
env.intlayerContentConfiguration.moduleAugmentationDirName,
|
|
81
92
|
"string"
|
|
82
93
|
),
|
|
83
94
|
moduleAugmentationDir: (0, import_utils.getEnvValue)(
|
|
84
|
-
|
|
85
|
-
"string"
|
|
86
|
-
),
|
|
87
|
-
bundleDirName: (0, import_utils.getEnvValue)(
|
|
88
|
-
process.env.NEXT_PUBLIC_INTLAYER_BUNDLE_DIR_NAME,
|
|
89
|
-
"string"
|
|
90
|
-
),
|
|
91
|
-
bundleDir: (0, import_utils.getEnvValue)(
|
|
92
|
-
process.env.NEXT_PUBLIC_INTLAYER_BUNDLE_DIR,
|
|
93
|
-
"string"
|
|
94
|
-
),
|
|
95
|
-
bundleFileExtension: (0, import_utils.getEnvValue)(
|
|
96
|
-
process.env.NEXT_PUBLIC_INTLAYER_BUNDLE_FILE_EXTENSION,
|
|
95
|
+
env.intlayerContentConfiguration.moduleAugmentationDir,
|
|
97
96
|
"string"
|
|
98
97
|
),
|
|
99
98
|
dictionariesDirName: (0, import_utils.getEnvValue)(
|
|
100
|
-
|
|
99
|
+
env.intlayerContentConfiguration.dictionariesDirName,
|
|
101
100
|
"string"
|
|
102
101
|
),
|
|
103
102
|
dictionariesDir: (0, import_utils.getEnvValue)(
|
|
104
|
-
|
|
103
|
+
env.intlayerContentConfiguration.dictionariesDir,
|
|
105
104
|
"string"
|
|
106
105
|
),
|
|
107
106
|
typeDirName: (0, import_utils.getEnvValue)(
|
|
108
|
-
|
|
107
|
+
env.intlayerContentConfiguration.typeDirName,
|
|
109
108
|
"string"
|
|
110
109
|
),
|
|
111
|
-
typesDir: (0, import_utils.getEnvValue)(
|
|
110
|
+
typesDir: (0, import_utils.getEnvValue)(env.intlayerContentConfiguration.typesDir, "string"),
|
|
112
111
|
mainDirName: (0, import_utils.getEnvValue)(
|
|
113
|
-
|
|
112
|
+
env.intlayerContentConfiguration.mainDirName,
|
|
114
113
|
"string"
|
|
115
114
|
),
|
|
116
|
-
mainDir: (0, import_utils.getEnvValue)(
|
|
115
|
+
mainDir: (0, import_utils.getEnvValue)(env.intlayerContentConfiguration.mainDir, "string"),
|
|
117
116
|
watchedFilesPattern: (0, import_utils.getEnvValue)(
|
|
118
|
-
|
|
117
|
+
env.intlayerContentConfiguration.watchedFilesPattern,
|
|
119
118
|
"array"
|
|
120
119
|
),
|
|
121
120
|
watchedFilesPatternWithPath: (0, import_utils.getEnvValue)(
|
|
122
|
-
|
|
121
|
+
env.intlayerContentConfiguration.watchedFilesPatternWithPath,
|
|
123
122
|
"array"
|
|
124
123
|
),
|
|
125
124
|
outputFilesPatternWithPath: (0, import_utils.getEnvValue)(
|
|
126
|
-
|
|
125
|
+
env.intlayerContentConfiguration.outputFilesPatternWithPath,
|
|
127
126
|
"string"
|
|
128
127
|
)
|
|
129
128
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/envVariables/getConfiguration.ts"],"sourcesContent":["import type {\n ContentConfig,\n InternationalizationConfig,\n IntlayerConfig,\n MiddlewareConfig,\n ServerSetCookieRule,\n} from '../types/config';\nimport type { Locales } from '../types/locales';\nimport { getEnvValue } from './utils';\n\nexport const intlayerIntlConfiguration: InternationalizationConfig = {\n locales: getEnvValue<Locales>(\n
|
|
1
|
+
{"version":3,"sources":["../../../src/envVariables/getConfiguration.ts"],"sourcesContent":["import type {\n ContentConfig,\n InternationalizationConfig,\n IntlayerConfig,\n MiddlewareConfig,\n ServerSetCookieRule,\n} from '../types/config';\nimport type { Locales } from '../types/locales';\nimport { extractEnvVariable } from './extractEnvVariable';\nimport { getEnvValue } from './utils';\n\nconst env = extractEnvVariable();\n\nexport const intlayerIntlConfiguration: InternationalizationConfig = {\n locales: getEnvValue<Locales>(\n env.intlayerIntlConfiguration.locales,\n 'array'\n )!,\n defaultLocale: getEnvValue<Locales>(\n env.intlayerIntlConfiguration.defaultLocale,\n 'string'\n )!,\n};\n\nexport const intlayerMiddlewareConfiguration: MiddlewareConfig = {\n headerName: getEnvValue(\n env.intlayerMiddlewareConfiguration.headerName,\n 'string'\n )!,\n cookieName: getEnvValue(\n env.intlayerMiddlewareConfiguration.cookieName,\n 'string'\n )!,\n prefixDefault: getEnvValue(\n env.intlayerMiddlewareConfiguration.prefixDefault,\n 'boolean'\n )!,\n basePath: getEnvValue(\n env.intlayerMiddlewareConfiguration.basePath,\n 'string'\n )!,\n serverSetCookie: getEnvValue<ServerSetCookieRule>(\n env.intlayerMiddlewareConfiguration.serverSetCookie,\n 'string'\n )!,\n noPrefix: getEnvValue(\n env.intlayerMiddlewareConfiguration.noPrefix,\n 'boolean'\n )!,\n};\n\nexport const intlayerContentConfiguration: ContentConfig = {\n fileExtensions: getEnvValue<string>(\n env.intlayerContentConfiguration.fileExtensions,\n 'array'\n )!,\n baseDir: getEnvValue(env.intlayerContentConfiguration.baseDir, 'string')!,\n contentDirName: getEnvValue(\n env.intlayerContentConfiguration.contentDirName,\n 'string'\n )!,\n contentDir: getEnvValue(\n env.intlayerContentConfiguration.contentDir,\n 'string'\n )!,\n excludedPath: getEnvValue<string>(\n env.intlayerContentConfiguration.excludedPath,\n 'array'\n )!,\n resultDirName: getEnvValue(\n env.intlayerContentConfiguration.resultDirName,\n 'string'\n )!,\n resultDir: getEnvValue(env.intlayerContentConfiguration.resultDir, 'string')!,\n moduleAugmentationDirName: getEnvValue(\n env.intlayerContentConfiguration.moduleAugmentationDirName,\n 'string'\n )!,\n moduleAugmentationDir: getEnvValue(\n env.intlayerContentConfiguration.moduleAugmentationDir,\n 'string'\n )!,\n dictionariesDirName: getEnvValue(\n env.intlayerContentConfiguration.dictionariesDirName,\n 'string'\n )!,\n dictionariesDir: getEnvValue(\n env.intlayerContentConfiguration.dictionariesDir,\n 'string'\n )!,\n typeDirName: getEnvValue(\n env.intlayerContentConfiguration.typeDirName,\n 'string'\n )!,\n typesDir: getEnvValue(env.intlayerContentConfiguration.typesDir, 'string')!,\n mainDirName: getEnvValue(\n env.intlayerContentConfiguration.mainDirName,\n 'string'\n )!,\n mainDir: getEnvValue(env.intlayerContentConfiguration.mainDir, 'string')!,\n watchedFilesPattern: getEnvValue<string>(\n env.intlayerContentConfiguration.watchedFilesPattern,\n 'array'\n )!,\n watchedFilesPatternWithPath: getEnvValue<string>(\n env.intlayerContentConfiguration.watchedFilesPatternWithPath,\n 'array'\n )!,\n outputFilesPatternWithPath: getEnvValue(\n env.intlayerContentConfiguration.outputFilesPatternWithPath,\n 'string'\n )!,\n};\n\nexport const intlayerConfiguration: IntlayerConfig = {\n internationalization: intlayerIntlConfiguration,\n middleware: intlayerMiddlewareConfiguration,\n content: intlayerContentConfiguration,\n};\n\n/**\n * Get all configuration values using environment variables\n * Can be used in the client side as the server side\n * To use it, be sure to have the environment variables set\n */\nexport const getConfiguration = (): IntlayerConfig => intlayerConfiguration;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gCAAmC;AACnC,mBAA4B;AAE5B,MAAM,UAAM,8CAAmB;AAExB,MAAM,4BAAwD;AAAA,EACnE,aAAS;AAAA,IACP,IAAI,0BAA0B;AAAA,IAC9B;AAAA,EACF;AAAA,EACA,mBAAe;AAAA,IACb,IAAI,0BAA0B;AAAA,IAC9B;AAAA,EACF;AACF;AAEO,MAAM,kCAAoD;AAAA,EAC/D,gBAAY;AAAA,IACV,IAAI,gCAAgC;AAAA,IACpC;AAAA,EACF;AAAA,EACA,gBAAY;AAAA,IACV,IAAI,gCAAgC;AAAA,IACpC;AAAA,EACF;AAAA,EACA,mBAAe;AAAA,IACb,IAAI,gCAAgC;AAAA,IACpC;AAAA,EACF;AAAA,EACA,cAAU;AAAA,IACR,IAAI,gCAAgC;AAAA,IACpC;AAAA,EACF;AAAA,EACA,qBAAiB;AAAA,IACf,IAAI,gCAAgC;AAAA,IACpC;AAAA,EACF;AAAA,EACA,cAAU;AAAA,IACR,IAAI,gCAAgC;AAAA,IACpC;AAAA,EACF;AACF;AAEO,MAAM,+BAA8C;AAAA,EACzD,oBAAgB;AAAA,IACd,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,aAAS,0BAAY,IAAI,6BAA6B,SAAS,QAAQ;AAAA,EACvE,oBAAgB;AAAA,IACd,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,gBAAY;AAAA,IACV,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,kBAAc;AAAA,IACZ,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,mBAAe;AAAA,IACb,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,eAAW,0BAAY,IAAI,6BAA6B,WAAW,QAAQ;AAAA,EAC3E,+BAA2B;AAAA,IACzB,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,2BAAuB;AAAA,IACrB,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,yBAAqB;AAAA,IACnB,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,qBAAiB;AAAA,IACf,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,iBAAa;AAAA,IACX,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,cAAU,0BAAY,IAAI,6BAA6B,UAAU,QAAQ;AAAA,EACzE,iBAAa;AAAA,IACX,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,aAAS,0BAAY,IAAI,6BAA6B,SAAS,QAAQ;AAAA,EACvE,yBAAqB;AAAA,IACnB,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,iCAA6B;AAAA,IAC3B,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AAAA,EACA,gCAA4B;AAAA,IAC1B,IAAI,6BAA6B;AAAA,IACjC;AAAA,EACF;AACF;AAEO,MAAM,wBAAwC;AAAA,EACnD,sBAAsB;AAAA,EACtB,YAAY;AAAA,EACZ,SAAS;AACX;AAOO,MAAM,mBAAmB,MAAsB;","names":[]}
|
|
@@ -5,6 +5,11 @@ declare const intlayerIntlConfiguration: InternationalizationConfig;
|
|
|
5
5
|
declare const intlayerMiddlewareConfiguration: MiddlewareConfig;
|
|
6
6
|
declare const intlayerContentConfiguration: ContentConfig;
|
|
7
7
|
declare const intlayerConfiguration: IntlayerConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Get all configuration values using environment variables
|
|
10
|
+
* Can be used in the client side as the server side
|
|
11
|
+
* To use it, be sure to have the environment variables set
|
|
12
|
+
*/
|
|
8
13
|
declare const getConfiguration: () => IntlayerConfig;
|
|
9
14
|
|
|
10
15
|
export { getConfiguration, intlayerConfiguration, intlayerContentConfiguration, intlayerIntlConfiguration, intlayerMiddlewareConfiguration };
|
|
@@ -21,10 +21,7 @@ __export(utils_exports, {
|
|
|
21
21
|
getEnvValue: () => getEnvValue
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(utils_exports);
|
|
24
|
-
function getEnvValue(value, type) {
|
|
25
|
-
if (value === void 0) {
|
|
26
|
-
return void 0;
|
|
27
|
-
}
|
|
24
|
+
function getEnvValue(value, type, verbose = false) {
|
|
28
25
|
try {
|
|
29
26
|
switch (type) {
|
|
30
27
|
case "boolean":
|
|
@@ -32,7 +29,7 @@ function getEnvValue(value, type) {
|
|
|
32
29
|
case "number":
|
|
33
30
|
return Number(value);
|
|
34
31
|
case "string":
|
|
35
|
-
return value;
|
|
32
|
+
return value ?? "";
|
|
36
33
|
case "object":
|
|
37
34
|
case "array":
|
|
38
35
|
return JSON.parse(value);
|
|
@@ -40,7 +37,11 @@ function getEnvValue(value, type) {
|
|
|
40
37
|
return void 0;
|
|
41
38
|
}
|
|
42
39
|
} catch (error) {
|
|
43
|
-
|
|
40
|
+
if (verbose) {
|
|
41
|
+
console.error(
|
|
42
|
+
`Error parsing environment variable, parsing : ${(value ?? "").toString()}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
44
45
|
return void 0;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/envVariables/utils.ts"],"sourcesContent":["function getEnvValue(value: unknown
|
|
1
|
+
{"version":3,"sources":["../../../src/envVariables/utils.ts"],"sourcesContent":["function getEnvValue(\n value: unknown,\n type: 'boolean',\n verbose?: boolean\n): boolean | undefined;\nfunction getEnvValue(\n value: unknown,\n type: 'number',\n verbose?: boolean\n): number | undefined;\nfunction getEnvValue<T extends string>(\n value: unknown,\n type: 'string',\n verbose?: boolean\n): T | undefined;\nfunction getEnvValue<T>(\n value: unknown,\n type: 'object',\n verbose?: boolean\n): T | undefined;\nfunction getEnvValue<T>(\n value: unknown,\n type: 'array',\n verbose?: boolean\n): T[] | undefined;\nfunction getEnvValue(\n value: unknown,\n type: 'string' | 'boolean' | 'number' | 'object' | 'array',\n verbose = false\n) {\n try {\n switch (type) {\n case 'boolean':\n // Convert string to boolean explicitly\n return value === 'true' || value === '1';\n\n case 'number':\n // Convert string to number, return undefined if conversion fails\n return Number(value);\n\n case 'string':\n // Return the string directly\n return value ?? '';\n\n case 'object':\n case 'array':\n // Attempt to parse the value as JSON\n return JSON.parse(value as string);\n\n default:\n return undefined;\n }\n } catch (error) {\n // Log error and return undefined if any error occurs during parsing\n if (verbose) {\n console.error(\n `Error parsing environment variable, parsing : ${((value ?? '') as string).toString()}`\n );\n }\n return undefined;\n }\n}\n\nexport { getEnvValue };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBA,SAAS,YACP,OACA,MACA,UAAU,OACV;AACA,MAAI;AACF,YAAQ,MAAM;AAAA,MACZ,KAAK;AAEH,eAAO,UAAU,UAAU,UAAU;AAAA,MAEvC,KAAK;AAEH,eAAO,OAAO,KAAK;AAAA,MAErB,KAAK;AAEH,eAAO,SAAS;AAAA,MAElB,KAAK;AAAA,MACL,KAAK;AAEH,eAAO,KAAK,MAAM,KAAe;AAAA,MAEnC;AACE,eAAO;AAAA,IACX;AAAA,EACF,SAAS,OAAO;AAEd,QAAI,SAAS;AACX,cAAQ;AAAA,QACN,kDAAmD,SAAS,IAAe,SAAS,CAAC;AAAA,MACvF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|