Skip to content

Commit

Permalink
chore(release): 1.7.0 [skip ci]
Browse files Browse the repository at this point in the history
# [1.7.0](v1.6.0...v1.7.0) (2024-06-15)

### Features

* **deps:** bump @vercel/ncc from 0.38.0 to 0.38.1 ([482bf52](482bf52))
* **deps:** bump braces from 3.0.2 to 3.0.3 ([575fa01](575fa01))
* **deps:** bump dotenv from 16.3.1 to 16.3.2 ([1e934d1](1e934d1))
* **deps:** bump dotenv from 16.3.2 to 16.4.1 ([59d7a52](59d7a52))
* **deps:** bump dotenv from 16.4.1 to 16.4.4 ([d72d999](d72d999))
* **deps:** bump dotenv from 16.4.4 to 16.4.5 ([6dce75a](6dce75a))
* **deps:** bump express from 4.18.2 to 4.18.3 ([d573c53](d573c53))
* **deps:** bump express from 4.18.3 to 4.19.1 ([6b9b862](6b9b862))
* **deps:** bump express from 4.19.1 to 4.19.2 ([2d542da](2d542da))
  • Loading branch information
semantic-release-bot committed Jun 15, 2024
1 parent 575fa01 commit 3a0b75f
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 44 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# [1.7.0](https://github.com/sws2apps/render-deployment/compare/v1.6.0...v1.7.0) (2024-06-15)


### Features

* **deps:** bump @vercel/ncc from 0.38.0 to 0.38.1 ([482bf52](https://github.com/sws2apps/render-deployment/commit/482bf526daacb3264e2271a743499195e3e8f84b))
* **deps:** bump braces from 3.0.2 to 3.0.3 ([575fa01](https://github.com/sws2apps/render-deployment/commit/575fa01d0d6a0c11267db1e05652de491558ed98))
* **deps:** bump dotenv from 16.3.1 to 16.3.2 ([1e934d1](https://github.com/sws2apps/render-deployment/commit/1e934d1021c4334f63b2bdd8056eb37242ac2539))
* **deps:** bump dotenv from 16.3.2 to 16.4.1 ([59d7a52](https://github.com/sws2apps/render-deployment/commit/59d7a526d5ab4d8ff611e963e3ef6bb1a5230178))
* **deps:** bump dotenv from 16.4.1 to 16.4.4 ([d72d999](https://github.com/sws2apps/render-deployment/commit/d72d999c04ec8b66aeae80ccaf2fe21fa5001f6f))
* **deps:** bump dotenv from 16.4.4 to 16.4.5 ([6dce75a](https://github.com/sws2apps/render-deployment/commit/6dce75aec64103d7be0871fd7ee1536d469aff65))
* **deps:** bump express from 4.18.2 to 4.18.3 ([d573c53](https://github.com/sws2apps/render-deployment/commit/d573c532e485c7cd58fa62cb065d88e0875e477c))
* **deps:** bump express from 4.18.3 to 4.19.1 ([6b9b862](https://github.com/sws2apps/render-deployment/commit/6b9b86229daf8d134ab9452de4229c5f4c0ab0b6))
* **deps:** bump express from 4.19.1 to 4.19.2 ([2d542da](https://github.com/sws2apps/render-deployment/commit/2d542da4859c0f749ca832ce52004cce2fe47733))

# [1.6.0](https://github.com/sws2apps/render-deployment/compare/v1.5.0...v1.6.0) (2023-09-25)


Expand Down
133 changes: 90 additions & 43 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1875,11 +1875,13 @@ function _parseVault (options) {
// Parse .env.vault
const result = DotenvModule.configDotenv({ path: vaultPath })
if (!result.parsed) {
throw new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
err.code = 'MISSING_DATA'
throw err
}

// handle scenario for comma separated keys - for use with key rotation
// example: DOTENV_KEY="dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenv.org/vault/.env.vault?environment=prod"
// example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
const keys = _dotenvKey(options).split(',')
const length = keys.length

Expand Down Expand Up @@ -1943,7 +1945,9 @@ function _instructions (result, dotenvKey) {
uri = new URL(dotenvKey)
} catch (error) {
if (error.code === 'ERR_INVALID_URL') {
throw new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:[email protected]/vault/.env.vault?environment=development')
const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:[email protected]/vault/.env.vault?environment=development')
err.code = 'INVALID_DOTENV_KEY'
throw err
}

throw error
Expand All @@ -1952,34 +1956,53 @@ function _instructions (result, dotenvKey) {
// Get decrypt key
const key = uri.password
if (!key) {
throw new Error('INVALID_DOTENV_KEY: Missing key part')
const err = new Error('INVALID_DOTENV_KEY: Missing key part')
err.code = 'INVALID_DOTENV_KEY'
throw err
}

// Get environment
const environment = uri.searchParams.get('environment')
if (!environment) {
throw new Error('INVALID_DOTENV_KEY: Missing environment part')
const err = new Error('INVALID_DOTENV_KEY: Missing environment part')
err.code = 'INVALID_DOTENV_KEY'
throw err
}

// Get ciphertext payload
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`
const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION
if (!ciphertext) {
throw new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'
throw err
}

return { ciphertext, key }
}

function _vaultPath (options) {
let dotenvPath = path.resolve(process.cwd(), '.env')
let possibleVaultPath = null

if (options && options.path && options.path.length > 0) {
dotenvPath = options.path
if (Array.isArray(options.path)) {
for (const filepath of options.path) {
if (fs.existsSync(filepath)) {
possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`
}
}
} else {
possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`
}
} else {
possibleVaultPath = path.resolve(process.cwd(), '.env.vault')
}

// Locate .env.vault
return dotenvPath.endsWith('.vault') ? dotenvPath : `${dotenvPath}.vault`
if (fs.existsSync(possibleVaultPath)) {
return possibleVaultPath
}

return null
}

function _resolveHome (envPath) {
Expand All @@ -2002,51 +2025,73 @@ function _configVault (options) {
}

function configDotenv (options) {
let dotenvPath = path.resolve(process.cwd(), '.env')
const dotenvPath = path.resolve(process.cwd(), '.env')
let encoding = 'utf8'
const debug = Boolean(options && options.debug)

if (options) {
if (options.path != null) {
dotenvPath = _resolveHome(options.path)
if (options && options.encoding) {
encoding = options.encoding
} else {
if (debug) {
_debug('No encoding is specified. UTF-8 is used by default')
}
if (options.encoding != null) {
encoding = options.encoding
}

let optionPaths = [dotenvPath] // default, look for .env
if (options && options.path) {
if (!Array.isArray(options.path)) {
optionPaths = [_resolveHome(options.path)]
} else {
optionPaths = [] // reset default
for (const filepath of options.path) {
optionPaths.push(_resolveHome(filepath))
}
}
}

try {
// Specifying an encoding returns a string instead of a buffer
const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }))
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
// parsed data, we will combine it with process.env (or options.processEnv if provided).
let lastError
const parsedAll = {}
for (const path of optionPaths) {
try {
// Specifying an encoding returns a string instead of a buffer
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))

let processEnv = process.env
if (options && options.processEnv != null) {
processEnv = options.processEnv
DotenvModule.populate(parsedAll, parsed, options)
} catch (e) {
if (debug) {
_debug(`Failed to load ${path} ${e.message}`)
}
lastError = e
}
}

DotenvModule.populate(processEnv, parsed, options)
let processEnv = process.env
if (options && options.processEnv != null) {
processEnv = options.processEnv
}

return { parsed }
} catch (e) {
if (debug) {
_debug(`Failed to load ${dotenvPath} ${e.message}`)
}
DotenvModule.populate(processEnv, parsedAll, options)

return { error: e }
if (lastError) {
return { parsed: parsedAll, error: lastError }
} else {
return { parsed: parsedAll }
}
}

// Populates process.env from .env file
function config (options) {
const vaultPath = _vaultPath(options)

// fallback to original dotenv if DOTENV_KEY is not set
if (_dotenvKey(options).length === 0) {
return DotenvModule.configDotenv(options)
}

const vaultPath = _vaultPath(options)

// dotenvKey exists but .env.vault file does not exist
if (!fs.existsSync(vaultPath)) {
if (!vaultPath) {
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)

return DotenvModule.configDotenv(options)
Expand All @@ -2059,9 +2104,9 @@ function decrypt (encrypted, keyStr) {
const key = Buffer.from(keyStr.slice(-64), 'hex')
let ciphertext = Buffer.from(encrypted, 'base64')

const nonce = ciphertext.slice(0, 12)
const authTag = ciphertext.slice(-16)
ciphertext = ciphertext.slice(12, -16)
const nonce = ciphertext.subarray(0, 12)
const authTag = ciphertext.subarray(-16)
ciphertext = ciphertext.subarray(12, -16)

try {
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)
Expand All @@ -2073,14 +2118,14 @@ function decrypt (encrypted, keyStr) {
const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'

if (isRange || invalidKeyLength) {
const msg = 'INVALID_DOTENV_KEY: It must be 64 characters long (or more)'
throw new Error(msg)
const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')
err.code = 'INVALID_DOTENV_KEY'
throw err
} else if (decryptionFailed) {
const msg = 'DECRYPTION_FAILED: Please check your DOTENV_KEY'
throw new Error(msg)
const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')
err.code = 'DECRYPTION_FAILED'
throw err
} else {
console.error('Error: ', error.code)
console.error('Error: ', error.message)
throw error
}
}
Expand All @@ -2092,7 +2137,9 @@ function populate (processEnv, parsed, options = {}) {
const override = Boolean(options && options.override)

if (typeof parsed !== 'object') {
throw new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
err.code = 'OBJECT_REQUIRED'
throw err
}

// Set process.env
Expand Down Expand Up @@ -7959,7 +8006,7 @@ return new B(c,{type:"multipart/form-data; boundary="+b})}
/***/ 9968:
/***/ ((module) => {

module.exports = JSON.parse('{"name":"dotenv","version":"16.3.1","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","lint-readme":"standard-markdown","pretest":"npm run lint && npm run dts-check","test":"tap tests/*.js --100 -Rspec","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"funding":"https://github.com/motdotla/dotenv?sponsor=1","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@definitelytyped/dtslint":"^0.0.133","@types/node":"^18.11.3","decache":"^4.6.1","sinon":"^14.0.1","standard":"^17.0.0","standard-markdown":"^7.1.0","standard-version":"^9.5.0","tap":"^16.3.0","tar":"^6.1.11","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}');
module.exports = JSON.parse('{"name":"dotenv","version":"16.4.5","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","lint-readme":"standard-markdown","pretest":"npm run lint && npm run dts-check","test":"tap tests/*.js --100 -Rspec","test:coverage":"tap --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@definitelytyped/dtslint":"^0.0.133","@types/node":"^18.11.3","decache":"^4.6.1","sinon":"^14.0.1","standard":"^17.0.0","standard-markdown":"^7.1.0","standard-version":"^9.5.0","tap":"^16.3.0","tar":"^6.1.11","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}');

/***/ })

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "render-deployment",
"description": "A GitHub Action to trigger deployment in Render.",
"version": "1.6.0",
"version": "1.7.0",
"private": true,
"type": "module",
"homepage": "https://github.com/sws2apps/render-deployment#readme",
Expand Down

0 comments on commit 3a0b75f

Please sign in to comment.