@intlayer/config 1.0.1 → 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 +5 -5
- 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/internationalization.ts +2 -6
- 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 +43 -38
- package/src/envVariables/utils.ts +30 -13
- package/src/types/config.ts +237 -65
- package/src/types/locales.ts +233 -233
|
@@ -28,107 +28,322 @@ var import_server = require('../defaultValues/server.cjs');
|
|
|
28
28
|
let storedConfiguration;
|
|
29
29
|
const buildInternationalizationFields = (customConfiguration) => ({
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Locales available in the application
|
|
32
|
+
*
|
|
33
|
+
* Default: ['en']
|
|
32
34
|
*/
|
|
33
|
-
// Locales available in the application
|
|
34
35
|
locales: customConfiguration?.locales ?? import_internationalization.LOCALES,
|
|
35
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Default locale of the application for fallback
|
|
38
|
+
*
|
|
39
|
+
* Default: 'en'
|
|
40
|
+
*/
|
|
36
41
|
defaultLocale: customConfiguration?.defaultLocale ?? import_internationalization.DEFAULT_LOCALE
|
|
37
42
|
});
|
|
38
43
|
const buildMiddlewareFields = (customConfiguration) => ({
|
|
39
44
|
/**
|
|
40
|
-
*
|
|
45
|
+
* Header name to get the locale
|
|
46
|
+
*
|
|
47
|
+
* Default: 'x-intlayer-locale'
|
|
41
48
|
*/
|
|
42
|
-
// Header name to get the locale
|
|
43
49
|
headerName: customConfiguration?.headerName ?? import_middleware.HEADER_NAME,
|
|
44
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Cookie name to get the locale
|
|
52
|
+
*
|
|
53
|
+
* Default: 'intlayer-locale'
|
|
54
|
+
*/
|
|
45
55
|
cookieName: customConfiguration?.cookieName ?? import_middleware.COOKIE_NAME,
|
|
46
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Prefix the default locale in the URL
|
|
58
|
+
*
|
|
59
|
+
* Default: true
|
|
60
|
+
*/
|
|
47
61
|
prefixDefault: customConfiguration?.prefixDefault ?? import_middleware.PREFIX_DEFAULT,
|
|
48
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Base path of the application URL
|
|
64
|
+
*
|
|
65
|
+
* Default: ''
|
|
66
|
+
*
|
|
67
|
+
* Example:
|
|
68
|
+
* - If the application is hosted at https://example.com/my-app
|
|
69
|
+
* - The base path is '/my-app'
|
|
70
|
+
* - The URL will be https://example.com/my-app/en
|
|
71
|
+
* - If the base path is not set, the URL will be https://example.com/en
|
|
72
|
+
*/
|
|
49
73
|
basePath: customConfiguration?.basePath ?? import_middleware.BASE_PATH,
|
|
50
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Rule to set the cookie on the server
|
|
76
|
+
* - 'always': Set the cookie on every request
|
|
77
|
+
* - 'never': Never set the cookie
|
|
78
|
+
*/
|
|
51
79
|
serverSetCookie: customConfiguration?.serverSetCookie ?? import_middleware.SERVER_SET_COOKIE,
|
|
52
|
-
|
|
80
|
+
/**
|
|
81
|
+
* No prefix in the URL
|
|
82
|
+
* - true: No prefix in the URL
|
|
83
|
+
* - false: Prefix in the URL
|
|
84
|
+
*
|
|
85
|
+
* Example:
|
|
86
|
+
* - If the application is hosted at https://example.com/my-app
|
|
87
|
+
* - The base path is '/my-app'
|
|
88
|
+
* - The URL will be https://example.com/my-app/en
|
|
89
|
+
* - If the base path is not set, the URL will be https://example.com/en
|
|
90
|
+
* - If no prefix is set, the URL will be https://example.com/en
|
|
91
|
+
* - If the no prefix is set to true, the URL will be https://example.com
|
|
92
|
+
*
|
|
93
|
+
* Default: false
|
|
94
|
+
*/
|
|
53
95
|
noPrefix: customConfiguration?.noPrefix ?? import_middleware.NO_PREFIX
|
|
54
96
|
});
|
|
55
97
|
const buildContentFields = (customConfiguration) => {
|
|
56
98
|
const notDerivedContentConfig = {
|
|
57
99
|
/**
|
|
58
|
-
*
|
|
100
|
+
* File extensions of content to look for to build the dictionaries
|
|
101
|
+
*
|
|
102
|
+
* - Default: ['.content.ts', '.content.js', '.content.json']
|
|
103
|
+
*
|
|
104
|
+
* - Example: ['.data.ts', '.data.js', '.data.json']
|
|
105
|
+
*
|
|
106
|
+
* Note:
|
|
107
|
+
* - Can exclude unused file extensions to improve performance
|
|
108
|
+
* - Avoid using common file extensions like '.ts', '.js', '.json' to avoid conflicts
|
|
59
109
|
*/
|
|
60
|
-
// File extensions of content to look for
|
|
61
110
|
fileExtensions: customConfiguration?.fileExtensions ?? import_server.FILE_EXTENSIONS,
|
|
62
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Absolute path of the directory of the project
|
|
113
|
+
* - Default: process.cwd()
|
|
114
|
+
* - Example: '/path/to/project'
|
|
115
|
+
*
|
|
116
|
+
* Will be used to resolve all intlayer directories
|
|
117
|
+
*
|
|
118
|
+
* Note:
|
|
119
|
+
* - The base directory should be the root of the project
|
|
120
|
+
* - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project
|
|
121
|
+
*/
|
|
63
122
|
baseDir: customConfiguration?.baseDir ?? process.cwd(),
|
|
64
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Directory name where the content is stored
|
|
125
|
+
*
|
|
126
|
+
* Default: 'src'
|
|
127
|
+
*
|
|
128
|
+
* Example:
|
|
129
|
+
* - 'data' -> '/path/to/project/data'
|
|
130
|
+
* - 'content' -> '/path/to/project/content'
|
|
131
|
+
* - 'locales' -> '/path/to/project/locales'
|
|
132
|
+
*
|
|
133
|
+
* Note: If this directory is not at the base directory level, update the contentDir field instead
|
|
134
|
+
*/
|
|
65
135
|
contentDirName: customConfiguration?.contentDirName ?? import_server.CONTENT_DIR_NAME,
|
|
66
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Directory name where the result will be stored
|
|
138
|
+
*
|
|
139
|
+
* Default: '.intlayer'
|
|
140
|
+
*
|
|
141
|
+
* Example:
|
|
142
|
+
* - '.next'
|
|
143
|
+
* - 'outputOFIntlayer'
|
|
144
|
+
*
|
|
145
|
+
* Note: If this directory is not at the base directory level, update the resultDir field instead
|
|
146
|
+
*/
|
|
67
147
|
resultDirName: customConfiguration?.resultDirName ?? import_server.RESULT_DIR_NAME,
|
|
68
|
-
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
* Directory name where the module augmentation will be stored
|
|
151
|
+
*
|
|
152
|
+
* Module augmentation allow better IDE suggestions and type checking
|
|
153
|
+
*
|
|
154
|
+
* Default: 'types'
|
|
155
|
+
*
|
|
156
|
+
* Example: 'intlayer-types'
|
|
157
|
+
*
|
|
158
|
+
* Note:
|
|
159
|
+
* - If this path changed, be sure to include it from the tsconfig.json file
|
|
160
|
+
* - If this directory is not at the base directory level, update the moduleAugmentationDir field instead
|
|
161
|
+
*/
|
|
69
162
|
moduleAugmentationDirName: customConfiguration?.moduleAugmentationDirName ?? import_server.MODULE_AUGMENTATION_DIR_NAME,
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
163
|
+
// @TODO: Make Module Augmentation optional by adding a flag in the configuration
|
|
164
|
+
/**
|
|
165
|
+
* Related to the intlayer result directory
|
|
166
|
+
*
|
|
167
|
+
* Directory name where the dictionaries will be stored
|
|
168
|
+
*
|
|
169
|
+
* Default: 'dictionary'
|
|
170
|
+
*
|
|
171
|
+
* Example: 'translations'
|
|
172
|
+
*
|
|
173
|
+
* Note:
|
|
174
|
+
* - If this directory is not at the result directory level, update the dictionariesDir field instead
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
75
177
|
dictionariesDirName: customConfiguration?.dictionariesDirName ?? import_server.DICTIONARIES_DIR_NAME,
|
|
76
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Related to the intlayer result directory
|
|
180
|
+
*
|
|
181
|
+
* Directory name where the dictionaries types will be stored
|
|
182
|
+
*
|
|
183
|
+
* Default: 'types'
|
|
184
|
+
*
|
|
185
|
+
* Example: 'intlayer-types'
|
|
186
|
+
*
|
|
187
|
+
* Note:
|
|
188
|
+
* - If this directory is not at the result directory level, update the typesDir field instead
|
|
189
|
+
*
|
|
190
|
+
*/
|
|
77
191
|
typeDirName: customConfiguration?.typeDirName ?? import_server.TYPES_DIR_NAME,
|
|
78
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Related to the intlayer result directory
|
|
194
|
+
*
|
|
195
|
+
* Directory name where the main files will be stored
|
|
196
|
+
*
|
|
197
|
+
* Default: 'main'
|
|
198
|
+
*
|
|
199
|
+
* Example: 'intlayer-main'
|
|
200
|
+
*
|
|
201
|
+
* Note:
|
|
202
|
+
* - If this directory is not at the result directory level, update the mainDir field instead
|
|
203
|
+
*/
|
|
79
204
|
mainDirName: customConfiguration?.mainDirName ?? import_server.MAIN_DIR_NAME,
|
|
80
|
-
|
|
205
|
+
/**
|
|
206
|
+
* Should exclude some directories from the content search
|
|
207
|
+
*
|
|
208
|
+
* Default: ['node_modules']
|
|
209
|
+
*
|
|
210
|
+
* Not used yet
|
|
211
|
+
* @TODO Implement the exclusion or remove it
|
|
212
|
+
*/
|
|
81
213
|
excludedPath: customConfiguration?.excludedPath ?? import_server.EXCLUDED_PATHS
|
|
82
214
|
};
|
|
83
215
|
const baseDirDerivedConfiguration = {
|
|
84
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Directory where the content is stored
|
|
218
|
+
*
|
|
219
|
+
* Relative to the base directory of the project
|
|
220
|
+
*
|
|
221
|
+
* Default: {{baseDir}} / {{contentDirName}}
|
|
222
|
+
*
|
|
223
|
+
* Example: '/path/to/project/src'
|
|
224
|
+
*
|
|
225
|
+
* Note:
|
|
226
|
+
* - Can be changed to a custom directory to externalize the content used in the project
|
|
227
|
+
* - If the content is not at the base directory level, update the contentDirName field instead
|
|
228
|
+
*/
|
|
85
229
|
contentDir: (0, import_path.join)(
|
|
86
230
|
notDerivedContentConfig.baseDir,
|
|
87
231
|
notDerivedContentConfig.contentDirName
|
|
88
232
|
),
|
|
89
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Directory where the result will be stored
|
|
235
|
+
*
|
|
236
|
+
* Relative to the base directory of the project
|
|
237
|
+
*
|
|
238
|
+
* Default: {{baseDir}} / {{resultDirName}}
|
|
239
|
+
*
|
|
240
|
+
* Example: '/path/to/project/.intlayer'
|
|
241
|
+
*
|
|
242
|
+
* Note:
|
|
243
|
+
* - Can be changed to a custom directory to externalize the intlayer application from the project
|
|
244
|
+
* - If the result is not at the base directory level, update the resultDirName field instead
|
|
245
|
+
*/
|
|
90
246
|
resultDir: (0, import_path.join)(
|
|
91
247
|
notDerivedContentConfig.baseDir,
|
|
92
248
|
notDerivedContentConfig.resultDirName
|
|
93
249
|
),
|
|
94
|
-
|
|
250
|
+
/**
|
|
251
|
+
* Directory where the module augmentation will be stored
|
|
252
|
+
*
|
|
253
|
+
* Module augmentation allow better IDE suggestions and type checking
|
|
254
|
+
*
|
|
255
|
+
* Relative to the base directory of the project
|
|
256
|
+
*
|
|
257
|
+
* Default: {{baseDir}} / {{moduleAugmentationDirName}}
|
|
258
|
+
*
|
|
259
|
+
* Example: '/path/to/project/types'
|
|
260
|
+
*
|
|
261
|
+
* Note:
|
|
262
|
+
* - If this path changed, be sure to include it from the tsconfig.json file
|
|
263
|
+
* - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead
|
|
264
|
+
*
|
|
265
|
+
*/
|
|
95
266
|
moduleAugmentationDir: (0, import_path.join)(
|
|
96
267
|
notDerivedContentConfig.baseDir,
|
|
97
268
|
notDerivedContentConfig.moduleAugmentationDirName
|
|
98
269
|
)
|
|
99
270
|
};
|
|
100
271
|
const resultDirDerivedConfiguration = {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
272
|
+
/**
|
|
273
|
+
* Directory where the dictionaries will be stored
|
|
274
|
+
*
|
|
275
|
+
* Relative to the result directory
|
|
276
|
+
*
|
|
277
|
+
* Default: {{resultDir}} / {{dictionariesDirName}}
|
|
278
|
+
*
|
|
279
|
+
* Example: '/path/to/project/.intlayer/dictionary'
|
|
280
|
+
*
|
|
281
|
+
* Note:
|
|
282
|
+
* - If the types are not at the result directory level, update the dictionariesDirName field instead
|
|
283
|
+
* - The dictionaries are stored in JSON format
|
|
284
|
+
* - The dictionaries are used to translate the content
|
|
285
|
+
* - The dictionaries are built from the content files
|
|
286
|
+
*/
|
|
107
287
|
dictionariesDir: (0, import_path.join)(
|
|
108
288
|
baseDirDerivedConfiguration.resultDir,
|
|
109
289
|
notDerivedContentConfig.dictionariesDirName
|
|
110
290
|
),
|
|
111
|
-
|
|
291
|
+
/**
|
|
292
|
+
* Directory where the dictionaries types will be stored
|
|
293
|
+
*
|
|
294
|
+
* Relative to the result directory
|
|
295
|
+
*
|
|
296
|
+
* Default: {{resultDir}} / {{typeDirName}}
|
|
297
|
+
*
|
|
298
|
+
* Example: '/path/to/project/.intlayer/types'
|
|
299
|
+
*
|
|
300
|
+
* Note:
|
|
301
|
+
* - If the types are not at the result directory level, update the typesDirName field instead
|
|
302
|
+
*/
|
|
112
303
|
typesDir: (0, import_path.join)(
|
|
113
304
|
baseDirDerivedConfiguration.resultDir,
|
|
114
305
|
notDerivedContentConfig.typeDirName
|
|
115
306
|
),
|
|
116
|
-
|
|
307
|
+
/**
|
|
308
|
+
* Directory where the main files will be stored
|
|
309
|
+
*
|
|
310
|
+
* Relative to the result directory
|
|
311
|
+
*
|
|
312
|
+
* Default: {{resultDir}} / {{mainDirName}}
|
|
313
|
+
*
|
|
314
|
+
* Example: '/path/to/project/.intlayer/main'
|
|
315
|
+
*
|
|
316
|
+
* Note:
|
|
317
|
+
*
|
|
318
|
+
* - If the main files are not at the result directory level, update the mainDirName field instead
|
|
319
|
+
*/
|
|
117
320
|
mainDir: (0, import_path.join)(
|
|
118
321
|
baseDirDerivedConfiguration.resultDir,
|
|
119
322
|
notDerivedContentConfig.mainDirName
|
|
120
323
|
)
|
|
121
324
|
};
|
|
122
325
|
const patternsConfiguration = {
|
|
123
|
-
|
|
326
|
+
/**
|
|
327
|
+
* Pattern of files to watch
|
|
328
|
+
*
|
|
329
|
+
* Default: ['/**\/*.content.ts', '/**\/*.content.js', '/**\/*.content.json']
|
|
330
|
+
*/
|
|
124
331
|
watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(
|
|
125
332
|
(ext) => `/**/*${ext}`
|
|
126
333
|
),
|
|
127
|
-
|
|
334
|
+
/**
|
|
335
|
+
* Pattern of files to watch including the relative path
|
|
336
|
+
*
|
|
337
|
+
* Default: ['{{contentDir}}/**\/*.content.ts', '{{contentDir}}/**\/*.content.js', '{{contentDir}}/**\/*.content.json']
|
|
338
|
+
*/
|
|
128
339
|
watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.map(
|
|
129
340
|
(ext) => `${baseDirDerivedConfiguration.contentDir}/**/*${ext}`
|
|
130
341
|
),
|
|
131
|
-
|
|
342
|
+
/**
|
|
343
|
+
* Pattern of dictionary to interpret
|
|
344
|
+
*
|
|
345
|
+
* Default: '{{dictionariesDir}}/**\/*.json'
|
|
346
|
+
*/
|
|
132
347
|
outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`
|
|
133
348
|
};
|
|
134
349
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport { DEFAULT_LOCALE, LOCALES } from '../defaultValues/internationalization';\nimport {\n BASE_PATH,\n COOKIE_NAME,\n HEADER_NAME,\n NO_PREFIX,\n PREFIX_DEFAULT,\n SERVER_SET_COOKIE,\n} from '../defaultValues/middleware';\nimport {\n BUNDLE_DIR_NAME,\n CONTENT_DIR_NAME,\n DICTIONARIES_DIR_NAME,\n FILE_EXTENSIONS,\n RESULT_DIR_NAME,\n EXCLUDED_PATHS,\n BUNDLE_FILE_EXTENSION,\n TYPES_DIR_NAME,\n MAIN_DIR_NAME,\n MODULE_AUGMENTATION_DIR_NAME,\n} from '../defaultValues/server';\nimport type {\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n PatternsContentConfig,\n InternationalizationConfig,\n IntlayerConfig,\n MiddlewareConfig,\n BaseContentConfig,\n ResultDirDerivedConfig,\n} from '../types/config';\nimport type { GetConfigurationOptions } from './getConfiguration';\n\nlet storedConfiguration: IntlayerConfig;\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Internationalization configuration\n */\n\n // Locales available in the application\n locales: customConfiguration?.locales ?? LOCALES,\n\n // Default locale of the application for fallback\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildMiddlewareFields = (\n customConfiguration?: Partial<MiddlewareConfig>\n): MiddlewareConfig => ({\n /**\n * Middleware configuration\n */\n\n // Header name to get the locale\n headerName: customConfiguration?.headerName ?? HEADER_NAME,\n\n // Cookie name to get the locale\n cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,\n\n // Prefix the default locale in the URL\n prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,\n\n // Base path\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n // Set cookie on server\n serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,\n\n // No prefix\n noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * Content configurations\n */\n\n // File extensions of content to look for\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n // Directory name of the project\n baseDir: customConfiguration?.baseDir ?? process.cwd(),\n\n // Directory name where the content is stored\n contentDirName: customConfiguration?.contentDirName ?? CONTENT_DIR_NAME,\n\n // Result directory name\n resultDirName: customConfiguration?.resultDirName ?? RESULT_DIR_NAME,\n\n // Module augmentation directory name\n moduleAugmentationDirName:\n customConfiguration?.moduleAugmentationDirName ??\n MODULE_AUGMENTATION_DIR_NAME,\n\n // Bundle directory name\n bundleDirName: customConfiguration?.bundleDirName ?? BUNDLE_DIR_NAME,\n\n // Bundle file extension\n bundleFileExtension:\n customConfiguration?.bundleFileExtension ?? BUNDLE_FILE_EXTENSION,\n\n // Dictionary directory name\n dictionariesDirName:\n customConfiguration?.dictionariesDirName ?? DICTIONARIES_DIR_NAME,\n\n // Types directory name\n typeDirName: customConfiguration?.typeDirName ?? TYPES_DIR_NAME,\n\n // Main directory name\n mainDirName: customConfiguration?.mainDirName ?? MAIN_DIR_NAME,\n\n // Directories to exclude\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n // Directory where the content is stored\n contentDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.contentDirName\n ),\n\n // Directory where the result will be stored\n resultDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.resultDirName\n ),\n\n // Directory where the module augmentation will be stored\n moduleAugmentationDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.moduleAugmentationDirName\n ),\n };\n\n const resultDirDerivedConfiguration: ResultDirDerivedConfig = {\n // Directory where the bundle will be stored\n bundleDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.bundleDirName\n ),\n\n // Directory where the dictionaries will be stored\n dictionariesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.dictionariesDirName\n ),\n\n // Directory where the types will be stored\n typesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.typeDirName\n ),\n\n // Directory where the main files will be stored\n mainDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.mainDirName\n ),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n // Pattern of files to watch\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n // Pattern of files to watch including the relative path\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.map(\n (ext) => `${baseDirDerivedConfiguration.contentDir}/**/*${ext}`\n ),\n\n // Pattern of files to output\n outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...resultDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nexport const buildConfigurationFields = (\n options: GetConfigurationOptions,\n customConfiguration?: CustomIntlayerConfig\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const middlewareConfig = buildMiddlewareFields(\n customConfiguration?.middleware\n );\n\n const contentConfig = buildContentFields(customConfiguration?.content);\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n middleware: middlewareConfig,\n content: contentConfig,\n };\n\n return storedConfiguration;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAA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ACxB,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,2BAAuB;AAAA,MACrB,wBAAwB;AAAA,MACxB,wBAAwB;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,gCAAwD;AAAA;AAAA,IAE5D,eAAW;AAAA,MACT,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,qBAAiB;AAAA,MACf,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,cAAU;AAAA,MACR,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,aAAS;AAAA,MACP,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,wBAA+C;AAAA;AAAA,IAEnD,qBAAqB,wBAAwB,eAAe;AAAA,MAC1D,CAAC,QAAQ,QAAQ,GAAG;AAAA,IACtB;AAAA;AAAA,IAGA,6BAA6B,wBAAwB,eAAe;AAAA,MAClE,CAAC,QAAQ,GAAG,4BAA4B,UAAU,QAAQ,GAAG;AAAA,IAC/D;AAAA;AAAA,IAGA,4BAA4B,GAAG,8BAA8B,eAAe;AAAA,EAC9E;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;AAEO,MAAM,2BAA2B,CACtC,SACA,wBACmB;AACnB,QAAM,6BAA6B;AAAA,IACjC,qBAAqB;AAAA,EACvB;AAEA,QAAM,mBAAmB;AAAA,IACvB,qBAAqB;AAAA,EACvB;AAEA,QAAM,gBAAgB,mBAAmB,qBAAqB,OAAO;AAErE,wBAAsB;AAAA,IACpB,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,SAAS;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport { DEFAULT_LOCALE, LOCALES } from '../defaultValues/internationalization';\nimport {\n BASE_PATH,\n COOKIE_NAME,\n HEADER_NAME,\n NO_PREFIX,\n PREFIX_DEFAULT,\n SERVER_SET_COOKIE,\n} from '../defaultValues/middleware';\nimport {\n CONTENT_DIR_NAME,\n DICTIONARIES_DIR_NAME,\n FILE_EXTENSIONS,\n RESULT_DIR_NAME,\n EXCLUDED_PATHS,\n TYPES_DIR_NAME,\n MAIN_DIR_NAME,\n MODULE_AUGMENTATION_DIR_NAME,\n} from '../defaultValues/server';\nimport type {\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n PatternsContentConfig,\n InternationalizationConfig,\n IntlayerConfig,\n MiddlewareConfig,\n BaseContentConfig,\n ResultDirDerivedConfig,\n} from '../types/config';\nimport type { GetConfigurationOptions } from './getConfiguration';\n\nlet storedConfiguration: IntlayerConfig;\n\n// @TODO - Add possibility of directories configurations to be arrays to allow multiple packages management\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildMiddlewareFields = (\n customConfiguration?: Partial<MiddlewareConfig>\n): MiddlewareConfig => ({\n /**\n * Header name to get the locale\n *\n * Default: 'x-intlayer-locale'\n */\n headerName: customConfiguration?.headerName ?? HEADER_NAME,\n\n /**\n * Cookie name to get the locale\n *\n * Default: 'intlayer-locale'\n */\n cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,\n\n /**\n * Prefix the default locale in the URL\n *\n * Default: true\n */\n prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n /**\n * Rule to set the cookie on the server\n * - 'always': Set the cookie on every request\n * - 'never': Never set the cookie\n */\n serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,\n\n /**\n * No prefix in the URL\n * - true: No prefix in the URL\n * - false: Prefix in the URL\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n * - If no prefix is set, the URL will be https://example.com/en\n * - If the no prefix is set to true, the URL will be https://example.com\n *\n * Default: false\n */\n noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * File extensions of content to look for to build the dictionaries\n *\n * - Default: ['.content.ts', '.content.js', '.content.json']\n *\n * - Example: ['.data.ts', '.data.js', '.data.json']\n *\n * Note:\n * - Can exclude unused file extensions to improve performance\n * - Avoid using common file extensions like '.ts', '.js', '.json' to avoid conflicts\n */\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n /**\n * Absolute path of the directory of the project\n * - Default: process.cwd()\n * - Example: '/path/to/project'\n *\n * Will be used to resolve all intlayer directories\n *\n * Note:\n * - The base directory should be the root of the project\n * - Can be changed to a custom directory to externalize either the content used in the project, or the intlayer application from the project\n */\n baseDir: customConfiguration?.baseDir ?? process.cwd(),\n\n /**\n * Directory name where the content is stored\n *\n * Default: 'src'\n *\n * Example:\n * - 'data' -> '/path/to/project/data'\n * - 'content' -> '/path/to/project/content'\n * - 'locales' -> '/path/to/project/locales'\n *\n * Note: If this directory is not at the base directory level, update the contentDir field instead\n */\n contentDirName: customConfiguration?.contentDirName ?? CONTENT_DIR_NAME,\n\n /**\n * Directory name where the result will be stored\n *\n * Default: '.intlayer'\n *\n * Example:\n * - '.next'\n * - 'outputOFIntlayer'\n *\n * Note: If this directory is not at the base directory level, update the resultDir field instead\n */\n resultDirName: customConfiguration?.resultDirName ?? RESULT_DIR_NAME,\n\n /**\n *\n * Directory name where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Default: 'types'\n *\n * Example: 'intlayer-types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If this directory is not at the base directory level, update the moduleAugmentationDir field instead\n */\n moduleAugmentationDirName:\n customConfiguration?.moduleAugmentationDirName ??\n MODULE_AUGMENTATION_DIR_NAME,\n // @TODO: Make Module Augmentation optional by adding a flag in the configuration\n\n /**\n * Related to the intlayer result directory\n *\n * Directory name where the dictionaries will be stored\n *\n * Default: 'dictionary'\n *\n * Example: 'translations'\n *\n * Note:\n * - If this directory is not at the result directory level, update the dictionariesDir field instead\n *\n */\n dictionariesDirName:\n customConfiguration?.dictionariesDirName ?? DICTIONARIES_DIR_NAME,\n\n /**\n * Related to the intlayer result directory\n *\n * Directory name where the dictionaries types will be stored\n *\n * Default: 'types'\n *\n * Example: 'intlayer-types'\n *\n * Note:\n * - If this directory is not at the result directory level, update the typesDir field instead\n *\n */\n typeDirName: customConfiguration?.typeDirName ?? TYPES_DIR_NAME,\n\n /**\n * Related to the intlayer result directory\n *\n * Directory name where the main files will be stored\n *\n * Default: 'main'\n *\n * Example: 'intlayer-main'\n *\n * Note:\n * - If this directory is not at the result directory level, update the mainDir field instead\n */\n mainDirName: customConfiguration?.mainDirName ?? MAIN_DIR_NAME,\n\n /**\n * Should exclude some directories from the content search\n *\n * Default: ['node_modules']\n *\n * Not used yet\n * @TODO Implement the exclusion or remove it\n */\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n /**\n * Directory where the content is stored\n *\n * Relative to the base directory of the project\n *\n * Default: {{baseDir}} / {{contentDirName}}\n *\n * Example: '/path/to/project/src'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the content used in the project\n * - If the content is not at the base directory level, update the contentDirName field instead\n */\n contentDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.contentDirName\n ),\n\n /**\n * Directory where the result will be stored\n *\n * Relative to the base directory of the project\n *\n * Default: {{baseDir}} / {{resultDirName}}\n *\n * Example: '/path/to/project/.intlayer'\n *\n * Note:\n * - Can be changed to a custom directory to externalize the intlayer application from the project\n * - If the result is not at the base directory level, update the resultDirName field instead\n */\n resultDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.resultDirName\n ),\n\n /**\n * Directory where the module augmentation will be stored\n *\n * Module augmentation allow better IDE suggestions and type checking\n *\n * Relative to the base directory of the project\n *\n * Default: {{baseDir}} / {{moduleAugmentationDirName}}\n *\n * Example: '/path/to/project/types'\n *\n * Note:\n * - If this path changed, be sure to include it from the tsconfig.json file\n * - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead\n *\n */\n moduleAugmentationDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.moduleAugmentationDirName\n ),\n };\n\n const resultDirDerivedConfiguration: ResultDirDerivedConfig = {\n /**\n * Directory where the dictionaries will be stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{dictionariesDirName}}\n *\n * Example: '/path/to/project/.intlayer/dictionary'\n *\n * Note:\n * - If the types are not at the result directory level, update the dictionariesDirName field instead\n * - The dictionaries are stored in JSON format\n * - The dictionaries are used to translate the content\n * - The dictionaries are built from the content files\n */\n dictionariesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.dictionariesDirName\n ),\n\n /**\n * Directory where the dictionaries types will be stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{typeDirName}}\n *\n * Example: '/path/to/project/.intlayer/types'\n *\n * Note:\n * - If the types are not at the result directory level, update the typesDirName field instead\n */\n typesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.typeDirName\n ),\n\n /**\n * Directory where the main files will be stored\n *\n * Relative to the result directory\n *\n * Default: {{resultDir}} / {{mainDirName}}\n *\n * Example: '/path/to/project/.intlayer/main'\n *\n * Note:\n *\n * - If the main files are not at the result directory level, update the mainDirName field instead\n */\n mainDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.mainDirName\n ),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n /**\n * Pattern of files to watch\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json']\n */\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n /**\n * Pattern of files to watch including the relative path\n *\n * Default: ['{{contentDir}}/**\\/*.content.ts', '{{contentDir}}/**\\/*.content.js', '{{contentDir}}/**\\/*.content.json']\n */\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.map(\n (ext) => `${baseDirDerivedConfiguration.contentDir}/**/*${ext}`\n ),\n\n /**\n * Pattern of dictionary to interpret\n *\n * Default: '{{dictionariesDir}}/**\\/*.json'\n */\n outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...resultDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\n/**\n * Build the configuration fields by merging the default values with the custom configuration\n */\nexport const buildConfigurationFields = (\n options: GetConfigurationOptions,\n customConfiguration?: CustomIntlayerConfig\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const middlewareConfig = buildMiddlewareFields(\n customConfiguration?.middleware\n );\n\n const contentConfig = buildContentFields(customConfiguration?.content);\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n middleware: middlewareConfig,\n content: contentConfig,\n };\n\n return storedConfiguration;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AA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AA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcA,cAAU;AAAA,MACR,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAeA,aAAS;AAAA,MACP,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,wBAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMnD,qBAAqB,wBAAwB,eAAe;AAAA,MAC1D,CAAC,QAAQ,QAAQ,GAAG;AAAA,IACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,6BAA6B,wBAAwB,eAAe;AAAA,MAClE,CAAC,QAAQ,GAAG,4BAA4B,UAAU,QAAQ,GAAG;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,4BAA4B,GAAG,8BAA8B,eAAe;AAAA,EAC9E;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;AAKO,MAAM,2BAA2B,CACtC,SACA,wBACmB;AACnB,QAAM,6BAA6B;AAAA,IACjC,qBAAqB;AAAA,EACvB;AAEA,QAAM,mBAAmB;AAAA,IACvB,qBAAqB;AAAA,EACvB;AAEA,QAAM,gBAAgB,mBAAmB,qBAAqB,OAAO;AAErE,wBAAsB;AAAA,IACpB,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,SAAS;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -2,6 +2,9 @@ import { CustomIntlayerConfig, IntlayerConfig } from '../types/config.js';
|
|
|
2
2
|
import { GetConfigurationOptions } from './getConfiguration.js';
|
|
3
3
|
import '../types/locales.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Build the configuration fields by merging the default values with the custom configuration
|
|
7
|
+
*/
|
|
5
8
|
declare const buildConfigurationFields: (options: GetConfigurationOptions, customConfiguration?: CustomIntlayerConfig) => IntlayerConfig;
|
|
6
9
|
|
|
7
10
|
export { buildConfigurationFields };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'path';\nimport type { CustomIntlayerConfig, IntlayerConfig } from '../types/config';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nlet storedConfiguration: IntlayerConfig | undefined;\nlet storedConfigurationFilePath: string | undefined;\nlet storedNumCustomConfiguration: number | undefined;\n\nexport type GetConfigurationOptions = {\n baseDir: string;\n verbose: boolean;\n};\n\nconst BASE_DIR_PATH = process.env.INTLAYER_BASE_DIR_PATH ?? process.cwd();\nconst defaultOptions: GetConfigurationOptions = {\n baseDir: BASE_DIR_PATH,\n verbose: false,\n};\n\nexport const getConfiguration = (\n options?: Partial<GetConfigurationOptions>\n): IntlayerConfig => {\n const mergedOptions = { ...defaultOptions, ...options };\n const { baseDir, verbose } = mergedOptions;\n\n if (!storedConfiguration) {\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Load the custom configuration\n let customConfiguration: CustomIntlayerConfig | undefined;\n if (configurationFilePath) {\n customConfiguration = loadConfigurationFile(configurationFilePath);\n }\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n mergedOptions,\n customConfiguration\n );\n storedConfigurationFilePath = configurationFilePath;\n storedNumCustomConfiguration = numCustomConfiguration;\n }\n\n // Log warning if multiple configuration files are found\n if (verbose)\n logConfigFileResult(\n storedNumCustomConfiguration,\n storedConfigurationFilePath\n );\n\n return storedConfiguration;\n};\n\nconst logConfigFileResult = (\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n console.info('Configuration file not found, using default configuration.');\n } else {\n const relativeOutputPath = relative(BASE_DIR_PATH, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n console.info(`Configuration file found: ${relativeOutputPath}.`);\n } else {\n console.warn(\n `Multiple configuration files found, using ${relativeOutputPath}.`\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAEzB,sCAAyC;AACzC,mCAAsC;AACtC,qCAAwC;AAExC,IAAI;AACJ,IAAI;AACJ,IAAI;AAOJ,MAAM,gBAAgB,QAAQ,IAAI,0BAA0B,QAAQ,IAAI;AACxE,MAAM,iBAA0C;AAAA,EAC9C,SAAS;AAAA,EACT,SAAS;AACX;
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'path';\nimport type { CustomIntlayerConfig, IntlayerConfig } from '../types/config';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nlet storedConfiguration: IntlayerConfig | undefined;\nlet storedConfigurationFilePath: string | undefined;\nlet storedNumCustomConfiguration: number | undefined;\n\nexport type GetConfigurationOptions = {\n baseDir: string;\n verbose: boolean;\n};\n\nconst BASE_DIR_PATH = process.env.INTLAYER_BASE_DIR_PATH ?? process.cwd();\nconst defaultOptions: GetConfigurationOptions = {\n baseDir: BASE_DIR_PATH,\n verbose: false,\n};\n\n/**\n * Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)\n */\nexport const getConfiguration = (\n options?: Partial<GetConfigurationOptions>\n): IntlayerConfig => {\n const mergedOptions = { ...defaultOptions, ...options };\n const { baseDir, verbose } = mergedOptions;\n\n if (!storedConfiguration) {\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Load the custom configuration\n let customConfiguration: CustomIntlayerConfig | undefined;\n if (configurationFilePath) {\n customConfiguration = loadConfigurationFile(configurationFilePath);\n }\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n mergedOptions,\n customConfiguration\n );\n storedConfigurationFilePath = configurationFilePath;\n storedNumCustomConfiguration = numCustomConfiguration;\n }\n\n // Log warning if multiple configuration files are found\n if (verbose)\n logConfigFileResult(\n storedNumCustomConfiguration,\n storedConfigurationFilePath\n );\n\n return storedConfiguration;\n};\n\nconst logConfigFileResult = (\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n console.info('Configuration file not found, using default configuration.');\n } else {\n const relativeOutputPath = relative(BASE_DIR_PATH, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n console.info(`Configuration file found: ${relativeOutputPath}.`);\n } else {\n console.warn(\n `Multiple configuration files found, using ${relativeOutputPath}.`\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAEzB,sCAAyC;AACzC,mCAAsC;AACtC,qCAAwC;AAExC,IAAI;AACJ,IAAI;AACJ,IAAI;AAOJ,MAAM,gBAAgB,QAAQ,IAAI,0BAA0B,QAAQ,IAAI;AACxE,MAAM,iBAA0C;AAAA,EAC9C,SAAS;AAAA,EACT,SAAS;AACX;AAKO,MAAM,mBAAmB,CAC9B,YACmB;AACnB,QAAM,gBAAgB,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AACtD,QAAM,EAAE,SAAS,QAAQ,IAAI;AAE7B,MAAI,CAAC,qBAAqB;AAExB,UAAM,EAAE,uBAAuB,uBAAuB,QACpD,wDAAwB,OAAO;AAGjC,QAAI;AACJ,QAAI,uBAAuB;AACzB,gCAAsB,oDAAsB,qBAAqB;AAAA,IACnE;AAGA,8BAAsB;AAAA,MACpB;AAAA,MACA;AAAA,IACF;AACA,kCAA8B;AAC9B,mCAA+B;AAAA,EACjC;AAGA,MAAI;AACF;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAEF,SAAO;AACT;AAEA,MAAM,sBAAsB,CAC1B,wBACA,0BACG;AACH,MAAI,2BAA2B,GAAG;AAChC,YAAQ,KAAK,4DAA4D;AAAA,EAC3E,OAAO;AACL,UAAM,yBAAqB,sBAAS,eAAe,qBAAsB;AAEzE,QAAI,2BAA2B,GAAG;AAChC,cAAQ,KAAK,6BAA6B,kBAAkB,GAAG;AAAA,IACjE,OAAO;AACL,cAAQ;AAAA,QACN,6CAA6C,kBAAkB;AAAA,MACjE;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -5,6 +5,9 @@ type GetConfigurationOptions = {
|
|
|
5
5
|
baseDir: string;
|
|
6
6
|
verbose: boolean;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Get the configuration for the intlayer by reading the configuration file (e.g. intlayer.config.js)
|
|
10
|
+
*/
|
|
8
11
|
declare const getConfiguration: (options?: Partial<GetConfigurationOptions>) => IntlayerConfig;
|
|
9
12
|
|
|
10
13
|
export { type GetConfigurationOptions, getConfiguration };
|
|
@@ -16,8 +16,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var configFile_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(configFile_exports);
|
|
18
18
|
__reExport(configFile_exports, require('./getConfiguration.cjs'), module.exports);
|
|
19
|
+
__reExport(configFile_exports, require('./searchConfigurationFile.cjs'), module.exports);
|
|
19
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
21
|
0 && (module.exports = {
|
|
21
|
-
...require('./getConfiguration.cjs')
|
|
22
|
+
...require('./getConfiguration.cjs'),
|
|
23
|
+
...require('./searchConfigurationFile.cjs')
|
|
22
24
|
});
|
|
23
25
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/index.ts"],"sourcesContent":["export * from './getConfiguration';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,+BAAd;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/index.ts"],"sourcesContent":["export * from './getConfiguration';\nexport * from './searchConfigurationFile';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,+BAAd;AACA,+BAAc,sCADd;","names":[]}
|
|
@@ -53,6 +53,9 @@ const transformationOption = {
|
|
|
53
53
|
write: false,
|
|
54
54
|
bundle: true
|
|
55
55
|
};
|
|
56
|
+
const filterValidConfiguration = (configuration) => {
|
|
57
|
+
return configuration;
|
|
58
|
+
};
|
|
56
59
|
const loadConfigurationFile = (configFilePath) => {
|
|
57
60
|
let customConfiguration = void 0;
|
|
58
61
|
const configFileExtension = configFilePath.split(".").pop() ?? "";
|
|
@@ -79,7 +82,11 @@ const loadConfigurationFile = (configFilePath) => {
|
|
|
79
82
|
} else if (sandboxContext.module.exports && Object.keys(sandboxContext.module.exports).length > 0) {
|
|
80
83
|
customConfiguration = sandboxContext.module.exports;
|
|
81
84
|
}
|
|
82
|
-
|
|
85
|
+
if (typeof customConfiguration === "undefined") {
|
|
86
|
+
console.error("Configuration file could not be loaded.");
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
return filterValidConfiguration(customConfiguration);
|
|
83
90
|
} catch (error) {
|
|
84
91
|
console.error("Error:", error);
|
|
85
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { createRequire } from 'module';\nimport { type Context, runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport type { CustomIntlayerConfig } from '../types/config';\n\nconst isESModule = typeof import.meta.url === 'string';\n\nconst sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n console,\n require: isESModule ? createRequire(import.meta.url) : require,\n};\n\nconst transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n};\n\nexport const loadConfigurationFile = (\n configFilePath: string\n): CustomIntlayerConfig | undefined => {\n let customConfiguration: CustomIntlayerConfig | undefined = undefined;\n\n const configFileExtension = configFilePath.split('.').pop() ?? '';\n\n try {\n if (configFileExtension === 'json') {\n // Assume JSON\n return require(configFilePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [configFilePath],\n\n ...transformationOption,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n customConfiguration = sandboxContext.module.exports;\n }\n\n return customConfiguration;\n } catch (error) {\n console.error('Error:', error);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAC9B,gBAA8C;AAC9C,qBAA+D;AAH/D;AAMA,MAAM,aAAa,OAAO,YAAY,QAAQ;AAE9C,MAAM,iBAA0B;AAAA,EAC9B,SAAS;AAAA,IACP,SAAS,CAAC;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,EACZ;AAAA,EACA;AAAA,EACA,SAAS,iBAAa,6BAAc,YAAY,GAAG,IAAI;AACzD;AAEA,MAAM,uBAAqC;AAAA,EACzC,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AACV;
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { createRequire } from 'module';\nimport { type Context, runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport type { CustomIntlayerConfig } from '../types/config';\n\nconst isESModule = typeof import.meta.url === 'string';\n\nconst sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n console,\n require: isESModule ? createRequire(import.meta.url) : require,\n};\n\nconst transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n};\n\nconst filterValidConfiguration = (\n configuration: CustomIntlayerConfig\n): CustomIntlayerConfig => {\n // @TODO Implement filtering of valid configuration\n return configuration;\n};\n\n/**\n * Load the configuration file from the given path\n * Example of configuration file: intlayer.config.js\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadConfigurationFile = (\n configFilePath: string\n): CustomIntlayerConfig | undefined => {\n let customConfiguration: CustomIntlayerConfig | undefined = undefined;\n\n const configFileExtension = configFilePath.split('.').pop() ?? '';\n\n try {\n if (configFileExtension === 'json') {\n // Assume JSON\n return require(configFilePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [configFilePath],\n\n ...transformationOption,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n customConfiguration = sandboxContext.module.exports;\n }\n\n if (typeof customConfiguration === 'undefined') {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n return filterValidConfiguration(customConfiguration);\n } catch (error) {\n console.error('Error:', error);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAC9B,gBAA8C;AAC9C,qBAA+D;AAH/D;AAMA,MAAM,aAAa,OAAO,YAAY,QAAQ;AAE9C,MAAM,iBAA0B;AAAA,EAC9B,SAAS;AAAA,IACP,SAAS,CAAC;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,EACZ;AAAA,EACA;AAAA,EACA,SAAS,iBAAa,6BAAc,YAAY,GAAG,IAAI;AACzD;AAEA,MAAM,uBAAqC;AAAA,EACzC,QA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AAI,OAAO,wBAAwB,aAAa;AAC9C,cAAQ,MAAM,yCAAyC;AACvD,aAAO;AAAA,IACT;AAEA,WAAO,yBAAyB,mBAAmB;AAAA,EACrD,SAAS,OAAO;AACd,YAAQ,MAAM,UAAU,KAAK;AAAA,EAC/B;AACF;","names":[]}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { CustomIntlayerConfig } from '../types/config.js';
|
|
2
2
|
import '../types/locales.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Load the configuration file from the given path
|
|
6
|
+
* Example of configuration file: intlayer.config.js
|
|
7
|
+
*
|
|
8
|
+
* Accepts JSON, JS, MJS and TS files as configuration
|
|
9
|
+
*/
|
|
4
10
|
declare const loadConfigurationFile: (configFilePath: string) => CustomIntlayerConfig | undefined;
|
|
5
11
|
|
|
6
12
|
export { loadConfigurationFile };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/configFile/searchConfigurationFile.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { resolve } from 'path';\n\nconst EXTENSION = ['ts', 'js', 'json', 'cjs', 'mjs', ''];\nconst CONFIGURATION_FILE_NAME_1 = 'intlayer.config';\nconst CONFIGURATION_FILE_NAME_2 = '.intlayerrc';\n\nconst intLayerConfigFiles = EXTENSION.filter(\n (extension) => extension !== ''\n).map((ext) => `${CONFIGURATION_FILE_NAME_1}.${ext}`);\n\nconst configurationFiles = [...intLayerConfigFiles, CONFIGURATION_FILE_NAME_2];\n\ntype SearchConfigurationFileResult = {\n configurationFilePath?: string;\n numCustomConfiguration: number;\n};\n\nexport const searchConfigurationFile = (\n configFilePath: string\n): SearchConfigurationFileResult => {\n let configurationFilePath: string | undefined = undefined;\n let numCustomConfiguration = 0;\n\n for (const fileName of configurationFiles) {\n try {\n const filePath = resolve(configFilePath, fileName);\n\n // Check if the file exists\n if (!existsSync(filePath)) {\n continue;\n } else {\n numCustomConfiguration += 1;\n\n if (!configurationFilePath) {\n configurationFilePath = filePath;\n }\n }\n } catch (error) {\n // Return \"Cannot use import statement outside a module\"\n console.error(`${fileName}: ${error as string}`);\n\n continue;\n }\n }\n\n return { configurationFilePath, numCustomConfiguration };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAC3B,kBAAwB;AAExB,MAAM,YAAY,CAAC,MAAM,MAAM,QAAQ,OAAO,OAAO,EAAE;AACvD,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAElC,MAAM,sBAAsB,UAAU;AAAA,EACpC,CAAC,cAAc,cAAc;AAC/B,EAAE,IAAI,CAAC,QAAQ,GAAG,yBAAyB,IAAI,GAAG,EAAE;AAEpD,MAAM,qBAAqB,CAAC,GAAG,qBAAqB,yBAAyB;
|
|
1
|
+
{"version":3,"sources":["../../../src/configFile/searchConfigurationFile.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { resolve } from 'path';\n\nconst EXTENSION = ['ts', 'js', 'json', 'cjs', 'mjs', ''];\nconst CONFIGURATION_FILE_NAME_1 = 'intlayer.config';\nconst CONFIGURATION_FILE_NAME_2 = '.intlayerrc';\n\nconst intLayerConfigFiles = EXTENSION.filter(\n (extension) => extension !== ''\n).map((ext) => `${CONFIGURATION_FILE_NAME_1}.${ext}`);\n\nconst configurationFiles = [...intLayerConfigFiles, CONFIGURATION_FILE_NAME_2];\n\ntype SearchConfigurationFileResult = {\n configurationFilePath?: string;\n numCustomConfiguration: number;\n};\n\n/**\n * Search for the configuration file in the given path\n *\n * List of detected configuration files:\n * - intlayer.config.ts\n * - intlayer.config.js\n * - intlayer.config.json\n * - intlayer.config.cjs\n * - intlayer.config.mjs\n * - .intlayerrc\n */\nexport const searchConfigurationFile = (\n configFilePath: string\n): SearchConfigurationFileResult => {\n let configurationFilePath: string | undefined = undefined;\n let numCustomConfiguration = 0;\n\n for (const fileName of configurationFiles) {\n try {\n const filePath = resolve(configFilePath, fileName);\n\n // Check if the file exists\n if (!existsSync(filePath)) {\n continue;\n } else {\n numCustomConfiguration += 1;\n\n if (!configurationFilePath) {\n configurationFilePath = filePath;\n }\n }\n } catch (error) {\n // Return \"Cannot use import statement outside a module\"\n console.error(`${fileName}: ${error as string}`);\n\n continue;\n }\n }\n\n return { configurationFilePath, numCustomConfiguration };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAC3B,kBAAwB;AAExB,MAAM,YAAY,CAAC,MAAM,MAAM,QAAQ,OAAO,OAAO,EAAE;AACvD,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAElC,MAAM,sBAAsB,UAAU;AAAA,EACpC,CAAC,cAAc,cAAc;AAC/B,EAAE,IAAI,CAAC,QAAQ,GAAG,yBAAyB,IAAI,GAAG,EAAE;AAEpD,MAAM,qBAAqB,CAAC,GAAG,qBAAqB,yBAAyB;AAkBtE,MAAM,0BAA0B,CACrC,mBACkC;AAClC,MAAI,wBAA4C;AAChD,MAAI,yBAAyB;AAE7B,aAAW,YAAY,oBAAoB;AACzC,QAAI;AACF,YAAM,eAAW,qBAAQ,gBAAgB,QAAQ;AAGjD,UAAI,KAAC,sBAAW,QAAQ,GAAG;AACzB;AAAA,MACF,OAAO;AACL,kCAA0B;AAE1B,YAAI,CAAC,uBAAuB;AAC1B,kCAAwB;AAAA,QAC1B;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AAEd,cAAQ,MAAM,GAAG,QAAQ,KAAK,KAAe,EAAE;AAE/C;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,uBAAuB,uBAAuB;AACzD;","names":[]}
|
|
@@ -2,6 +2,17 @@ type SearchConfigurationFileResult = {
|
|
|
2
2
|
configurationFilePath?: string;
|
|
3
3
|
numCustomConfiguration: number;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Search for the configuration file in the given path
|
|
7
|
+
*
|
|
8
|
+
* List of detected configuration files:
|
|
9
|
+
* - intlayer.config.ts
|
|
10
|
+
* - intlayer.config.js
|
|
11
|
+
* - intlayer.config.json
|
|
12
|
+
* - intlayer.config.cjs
|
|
13
|
+
* - intlayer.config.mjs
|
|
14
|
+
* - .intlayerrc
|
|
15
|
+
*/
|
|
5
16
|
declare const searchConfigurationFile: (configFilePath: string) => SearchConfigurationFileResult;
|
|
6
17
|
|
|
7
18
|
export { searchConfigurationFile };
|
|
@@ -23,11 +23,7 @@ __export(internationalization_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(internationalization_exports);
|
|
25
25
|
var import_locales = require('../types/locales.cjs');
|
|
26
|
-
const LOCALES = [
|
|
27
|
-
import_locales.Locales.ENGLISH,
|
|
28
|
-
import_locales.Locales.FRENCH,
|
|
29
|
-
import_locales.Locales.SPANISH
|
|
30
|
-
];
|
|
26
|
+
const LOCALES = [import_locales.Locales.ENGLISH];
|
|
31
27
|
const DEFAULT_LOCALE = import_locales.Locales.ENGLISH;
|
|
32
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
29
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import { Locales } from '../types/locales';\n\nexport const LOCALES: Locales[] = [
|
|
1
|
+
{"version":3,"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import { Locales } from '../types/locales';\n\nexport const LOCALES: Locales[] = [Locales.ENGLISH];\n\nexport const DEFAULT_LOCALE: Locales = Locales.ENGLISH;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AAEjB,MAAM,UAAqB,CAAC,uBAAQ,OAAO;AAE3C,MAAM,iBAA0B,uBAAQ;","names":[]}
|
|
@@ -18,8 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var server_exports = {};
|
|
20
20
|
__export(server_exports, {
|
|
21
|
-
BUNDLE_DIR_NAME: () => BUNDLE_DIR_NAME,
|
|
22
|
-
BUNDLE_FILE_EXTENSION: () => BUNDLE_FILE_EXTENSION,
|
|
23
21
|
CONTENT_DIR_NAME: () => CONTENT_DIR_NAME,
|
|
24
22
|
DICTIONARIES_DIR_NAME: () => DICTIONARIES_DIR_NAME,
|
|
25
23
|
EXCLUDED_PATHS: () => EXCLUDED_PATHS,
|
|
@@ -35,15 +33,11 @@ const EXCLUDED_PATHS = ["node_modules"];
|
|
|
35
33
|
const CONTENT_DIR_NAME = "src";
|
|
36
34
|
const RESULT_DIR_NAME = ".intlayer";
|
|
37
35
|
const MODULE_AUGMENTATION_DIR_NAME = "types";
|
|
38
|
-
const BUNDLE_DIR_NAME = "bundle";
|
|
39
|
-
const BUNDLE_FILE_EXTENSION = ".bundle.js";
|
|
40
36
|
const DICTIONARIES_DIR_NAME = "dictionary";
|
|
41
37
|
const TYPES_DIR_NAME = "types";
|
|
42
38
|
const MAIN_DIR_NAME = "main";
|
|
43
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
40
|
0 && (module.exports = {
|
|
45
|
-
BUNDLE_DIR_NAME,
|
|
46
|
-
BUNDLE_FILE_EXTENSION,
|
|
47
41
|
CONTENT_DIR_NAME,
|
|
48
42
|
DICTIONARIES_DIR_NAME,
|
|
49
43
|
EXCLUDED_PATHS,
|