feat: initial commit

This commit is contained in:
Carlos
2024-08-12 22:57:35 -04:00
commit 6f68ae8259
13140 changed files with 1104801 additions and 0 deletions

44
node_modules/dotenv-defaults/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
const dotenv = require('dotenv')
/**
* Merges two objects.
* @param {Object} apply - The overwriter
* @param {Object} defaults - The defaults to be overwritten
* @returns {Object} The merged results.
*/
const merge = (apply = {}, defaults = {}) => Object.assign({}, defaults, apply)
/**
* Parses objects like before, but with defaults!
* @param {String} src - The original src.
* @param {String} [defaultSrc=''] - The new-and-improved default source.
* @returns {Object} The parsed results.
*/
const parse = (src, defaultSrc = '') => {
const parsedSrc = dotenv.parse(src)
const parsedDefault = dotenv.parse(defaultSrc)
return merge(parsedSrc, parsedDefault)
}
/**
* Runs the configurations and applies it to process.env.
* @param {Object} [options={}] - The options to determnie how this goes
* @returns {Object} The parsed results.
*/
const config = (options = {}) => {
const src = dotenv.config(options)
// we run this second so it doesn't override things set from src
const defaults = dotenv.config(Object.assign({}, options, {
path: options.defaults || '.env.defaults'
}))
return {
parsed: merge(src.parsed, defaults.parsed)
}
}
module.exports = {
parse,
config
}

71
node_modules/dotenv-defaults/src/index.test.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
/* global describe, test, expect, afterEach */
const Module = require('./index')
describe('dotenv-defaults', () => {
describe('root', () => {
test('should exist', () => {
expect(Module).toBeDefined()
})
})
describe('config', () => {
afterEach(() => {
delete process.env.TEST
delete process.env.TEST2
})
test('should be a function', () => {
expect(typeof Module.config).toEqual('function')
})
test('should by default write to process.env', () => {
expect(Module.config()).toEqual({
parsed: {
TEST: 'hello',
TEST2: 'whatever'
}
})
})
test('should support alternative defaults', () => {
expect(Module.config({
defaults: '.env.defaults2'
})).toEqual({
parsed: {
TEST: 'hello',
TEST2: 'whatever2'
}
})
})
})
describe('parse', () => {
test('should exist', () => {
expect(Module.parse).toBeDefined()
})
test('should be a function', () => {
expect(typeof Module.parse).toEqual('function')
})
test('should read variables', () => {
expect(Module.parse('TEST=hello')).toEqual({ TEST: 'hello' })
})
test('should include defaults', () => {
const src = 'TEST=hello'
const defaults = 'TEST2=goodbye'
expect(Module.parse(src, defaults)).toEqual({
TEST: 'hello',
TEST2: 'goodbye'
})
})
test('should not override defaults', () => {
const src = 'TEST=hello'
const defaults = 'TEST=goodbye'
expect(Module.parse(src, defaults)).toEqual({ TEST: 'hello' })
})
})
})