@platformatic/foundation 3.19.0 → 3.21.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.
@@ -340,33 +340,42 @@ export function validate (schema, config, validationOptions = {}, fixPaths = tru
340
340
  }
341
341
  }
342
342
 
343
- export async function loadEnv (root, ignoreProcessEnv = false, additionalEnv = {}) {
343
+ export async function loadEnv (root, ignoreProcessEnv = false, additionalEnv = {}, customEnvFile = null) {
344
344
  if (!isAbsolute(root)) {
345
345
  root = resolve(process.cwd(), root)
346
346
  }
347
347
 
348
- let currentPath = root
349
- const rootPath = parse(root).root
348
+ let envFile = customEnvFile
350
349
 
351
- // Search for the .env file in the current directory and its parents
352
- let envFile
353
- while (currentPath !== rootPath) {
354
- const candidate = resolve(currentPath, '.env')
355
-
356
- if (await isFileAccessible(candidate)) {
357
- envFile = candidate
358
- break
350
+ // If a custom env file is provided, resolve it and check if it exists
351
+ if (customEnvFile) {
352
+ envFile = isAbsolute(customEnvFile) ? customEnvFile : resolve(root, customEnvFile)
353
+ if (!(await isFileAccessible(envFile))) {
354
+ throw new Error(`Custom env file not found: ${envFile}`)
359
355
  }
356
+ } else {
357
+ // Default behavior: search for .env file in the current directory and its parents
358
+ let currentPath = root
359
+ const rootPath = parse(root).root
360
360
 
361
- currentPath = dirname(currentPath)
362
- }
361
+ while (currentPath !== rootPath) {
362
+ const candidate = resolve(currentPath, '.env')
363
363
 
364
- // If not found, check the current working directory
365
- if (!envFile) {
366
- const cwdCandidate = resolve(process.cwd(), '.env')
364
+ if (await isFileAccessible(candidate)) {
365
+ envFile = candidate
366
+ break
367
+ }
367
368
 
368
- if (await isFileAccessible(cwdCandidate)) {
369
- envFile = cwdCandidate
369
+ currentPath = dirname(currentPath)
370
+ }
371
+
372
+ // If not found, check the current working directory
373
+ if (!envFile) {
374
+ const cwdCandidate = resolve(process.cwd(), '.env')
375
+
376
+ if (await isFileAccessible(cwdCandidate)) {
377
+ envFile = cwdCandidate
378
+ }
370
379
  }
371
380
  }
372
381
 
@@ -446,7 +455,8 @@ export async function loadConfiguration (source, schema, options = {}) {
446
455
  onMissingEnv,
447
456
  fixPaths,
448
457
  logger,
449
- skipMetadata
458
+ skipMetadata,
459
+ envFile: customEnvFile
450
460
  } = {
451
461
  validate: !!schema,
452
462
  validationOptions: {},
@@ -473,7 +483,7 @@ export async function loadConfiguration (source, schema, options = {}) {
473
483
  throw new RootMissingError()
474
484
  }
475
485
 
476
- const env = await loadEnv(root, ignoreProcessEnv, additionalEnv)
486
+ const env = await loadEnv(root, ignoreProcessEnv, additionalEnv, customEnvFile)
477
487
  env.PLT_ROOT = root
478
488
 
479
489
  if (shouldReplaceEnv) {
package/lib/schema.js CHANGED
@@ -599,8 +599,9 @@ export const health = {
599
599
  maxUnhealthyChecks: overridableValue({ type: 'number', minimum: 1 }, 10),
600
600
  maxELU: overridableValue({ type: 'number', minimum: 0, maximum: 1 }, 0.99),
601
601
  maxHeapUsed: overridableValue({ type: 'number', minimum: 0, maximum: 1 }, 0.99),
602
- maxHeapTotal: overridableValue({ type: 'number', minimum: 0 }),
603
- maxYoungGeneration: overridableValue({ type: 'number', minimum: 0 })
602
+ maxHeapTotal: overridableValue({ type: 'number', minimum: 0 }, 4 * Math.pow(1024, 3)), // 4GB
603
+ maxYoungGeneration: overridableValue({ type: 'number', minimum: 0 }, 128 * Math.pow(1024, 2)), // 128MB,
604
+ codeRangeSize: overridableValue({ type: 'number', minimum: 0 }, 268435456)
604
605
  },
605
606
  additionalProperties: false
606
607
  }
@@ -785,8 +786,7 @@ export const applications = {
785
786
  type: 'string'
786
787
  },
787
788
  sourceMaps: {
788
- type: 'boolean',
789
- default: false
789
+ type: 'boolean'
790
790
  },
791
791
  packageManager: {
792
792
  type: 'string',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/foundation",
3
- "version": "3.19.0",
3
+ "version": "3.21.0",
4
4
  "description": "Platformatic Foundation",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",