Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dotenvx/dotenvx

Package Overview
Dependencies
Maintainers
2
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotenvx/dotenvx - npm Package Compare versions

Comparing version 1.31.3 to 1.32.0

src/lib/services/prebuild.js

16

CHANGELOG.md

@@ -5,4 +5,18 @@ # Changelog

[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.31.3...main)
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.32.0...main)
## [1.32.0](https://github.com/dotenvx/dotenvx/compare/v1.31.3...v1.32.0)
### Added
* add encrypted check support for `ext prebuild` ([#501](https://github.com/dotenvx/dotenvx/pull/501))
### Changed
* modify `ext precommit` to check git modified state as well as git staged state - useful for using `dotenvx ext precommit` without the `--install` flag in automated scripts and ci. ([#499](https://github.com/dotenvx/dotenvx/pull/499))
### Removed
* remove internal logger methods `errorvp, errorvpb, warnv, warnvp, warnvpb, successvp, successvpb, help2` ([#501](https://github.com/dotenvx/dotenvx/pull/501))
## [1.31.3](https://github.com/dotenvx/dotenvx/compare/v1.31.2...v1.31.3)

@@ -9,0 +23,0 @@

2

package.json
{
"version": "1.31.3",
"version": "1.32.0",
"name": "@dotenvx/dotenvx",

@@ -4,0 +4,0 @@ "description": "a better dotenv–from the creator of `dotenv`",

@@ -1,8 +0,5 @@

const fsx = require('./../../../lib/helpers/fsx')
const { logger } = require('./../../../shared/logger')
const ignore = require('ignore')
const Prebuild = require('./../../../lib/services/prebuild')
const { logger } = require('./../../../shared/logger')
const pluralize = require('./../../../lib/helpers/pluralize')
function prebuild () {

@@ -12,52 +9,23 @@ const options = this.opts()

// 1. check for .dockerignore file
if (!fsx.existsSync('.dockerignore')) {
logger.errorvpb('.dockerignore missing')
logger.help2('? add it with [touch .dockerignore]')
process.exit(1)
return
}
try {
const {
successMessage,
warnings
} = new Prebuild(options).run()
// 2. check .env* files against .dockerignore file
let warningCount = 0
const ig = ignore().add(fsx.readFileX('.dockerignore'))
const files = fsx.readdirSync(process.cwd())
const dotenvFiles = files.filter(file => file.match(/^\.env(\..+)?$/))
dotenvFiles.forEach(file => {
// check if that file is being ignored
if (ig.ignores(file)) {
switch (file) {
case '.env.example':
warningCount += 1
logger.warnv(`${file} (currently ignored but should not be)`)
logger.help2(`? add !${file} to .dockerignore with [echo "!${file}" >> .dockerignore]`)
break
case '.env.vault':
warningCount += 1
logger.warnv(`${file} (currently ignored but should not be)`)
logger.help2(`? add !${file} to .dockerignore with [echo "!${file}" >> .dockerignore]`)
break
default:
break
for (const warning of warnings) {
logger.warn(warning.message)
if (warning.help) {
logger.help(warning.help)
}
} else {
switch (file) {
case '.env.example':
break
case '.env.vault':
break
default:
logger.errorvpb(`${file} not properly dockerignored`)
logger.help2(`? add ${file} to .dockerignore with [echo ".env*" >> .dockerignore]`)
process.exit(1) // 3.1 exit early with error code
break
}
}
})
// 3. outpout success
if (warningCount > 0) {
logger.successvpb(`success (with ${pluralize('warning', warningCount)})`)
} else {
logger.successvpb('success')
logger.success(successMessage)
} catch (error) {
logger.error(error.message)
if (error.help) {
logger.help(error.help)
}
process.exit(1)
}

@@ -64,0 +32,0 @@ }

@@ -16,3 +16,3 @@ const { logger } = require('./../../../shared/logger')

for (const warning of warnings) {
logger.warnv(warning.message)
logger.warn(warning.message)
if (warning.help) {

@@ -23,5 +23,5 @@ logger.help(warning.help)

logger.successvp(successMessage)
logger.success(successMessage)
} catch (error) {
logger.errorvp(error.message)
logger.error(error.message)
if (error.help) {

@@ -28,0 +28,0 @@ logger.help(error.help)

@@ -15,3 +15,3 @@ const childProcess = require('child_process')

logger.help('? install gitleaks: [brew install gitleaks]')
logger.help2('? other install options: [https://github.com/gitleaks/gitleaks]')
logger.help('? other install options: [https://github.com/gitleaks/gitleaks]')
process.exit(1)

@@ -18,0 +18,0 @@ return

@@ -143,16 +143,8 @@ import type { URL } from 'url';

| 'errorv'
| 'errorvp'
| 'errorvpb'
| 'errornocolor'
| 'warn'
| 'warnv'
| 'warnvp'
| 'warnvpb'
| 'success'
| 'successv'
| 'successvp'
| 'successvpb'
| 'info'
| 'help'
| 'help2'
| 'http'

@@ -159,0 +151,0 @@ | 'verbose'

@@ -8,2 +8,3 @@ /* istanbul ignore file */

const isFullyEncrypted = require('./../helpers/isFullyEncrypted')
const packageJson = require('./../helpers/packageJson')
const InstallPrecommitHook = require('./../helpers/installPrecommitHook')

@@ -36,4 +37,3 @@ const childProcess = require('child_process')

if (!fsx.existsSync('.gitignore')) {
const warning = new Error('.gitignore missing')
warning.help = '? add it with [touch .gitignore]'
const warning = new Error(`[dotenvx@${packageJson.version}][precommit] .gitignore missing`)
warnings.push(warning)

@@ -56,4 +56,4 @@ } else {

if (file === '.env.example' || file === '.env.vault') {
const warning = new Error(`${file} (currently ignored but should not be)`)
warning.help = `? add !${file} to .gitignore [echo "!${file}" >> .gitignore]`
const warning = new Error(`[dotenvx@${packageJson.version}][precommit] ${file} (currently ignored but should not be)`)
warning.help = `[dotenvx@${packageJson.version}][precommit] ⮕ run [dotenvx ext gitignore --pattern !${file}]`
warnings.push(warning)

@@ -68,4 +68,11 @@ }

if (!encrypted) {
const error = new Error(`${file} not protected (encrypted or gitignored)`)
error.help = `? encrypt it [dotenvx encrypt -f ${file}] or gitignore it [echo "${file}" >> .gitignore]`
let errorMsg = `[dotenvx@${packageJson.version}][precommit] ${file} not protected (encrypted or gitignored)`
let errorHelp = `[dotenvx@${packageJson.version}][precommit] ⮕ run [dotenvx encrypt -f ${file}] or [dotenvx ext gitignore --pattern ${file}]`
if (file.includes('.env.keys')) {
errorMsg = `[dotenvx@${packageJson.version}][precommit] ${file} not protected (gitignored)`
errorHelp = `[dotenvx@${packageJson.version}][precommit] ⮕ run [dotenvx ext gitignore --pattern ${file}]`
}
const error = new Error(errorMsg)
error.help = errorHelp
throw error

@@ -78,5 +85,5 @@ }

let successMessage = `.env files (${count}) protected (encrypted or gitignored)`
let successMessage = `[dotenvx@${packageJson.version}][precommit] .env files (${count}) protected (encrypted or gitignored)`
if (count === 0) {
successMessage = 'zero .env files'
successMessage = `[dotenvx@${packageJson.version}][precommit] zero .env files`
}

@@ -96,3 +103,3 @@ if (warnings.length > 0) {

try {
const output = childProcess.execSync('git diff --cached --name-only').toString()
const output = childProcess.execSync('git diff HEAD --name-only').toString()
const files = output.split('\n')

@@ -99,0 +106,0 @@

@@ -7,16 +7,8 @@ const packageJson = require('../lib/helpers/packageJson')

errorv: 0,
errorvp: 0,
errorvpb: 0,
errornocolor: 0,
warn: 1,
warnv: 1,
warnvp: 1,
warnvpb: 1,
success: 2,
successv: 2,
successvp: 2,
successvpb: 2,
info: 2,
help: 2,
help2: 2,
blank: 2,

@@ -33,3 +25,2 @@ verbose: 4,

const help = getColor('dodgerblue')
const help2 = getColor('gray')
const verbose = getColor('plum')

@@ -60,6 +51,2 @@ const debug = getColor('plum')

return error(`[dotenvx@${packageJson.version}] ${formattedMessage}`)
case 'errorvp':
return error(`[dotenvx@${packageJson.version}][precommit] ${formattedMessage}`)
case 'errorvpb':
return error(`[dotenvx@${packageJson.version}][prebuild] ${formattedMessage}`)
case 'errornocolor':

@@ -70,8 +57,2 @@ return formattedMessage

return warn(formattedMessage)
case 'warnv':
return warn(`[dotenvx@${packageJson.version}] ${formattedMessage}`)
case 'warnvp':
return warn(`[dotenvx@${packageJson.version}][precommit] ${formattedMessage}`)
case 'warnvpb':
return warn(`[dotenvx@${packageJson.version}][prebuild] ${formattedMessage}`)
// successes

@@ -82,6 +63,2 @@ case 'success':

return successv(`[dotenvx@${packageJson.version}] ${formattedMessage}`)
case 'successvp': // success with 'version' and precommit
return success(`[dotenvx@${packageJson.version}][precommit] ${formattedMessage}`)
case 'successvpb': // success with 'version' and precommit
return success(`[dotenvx@${packageJson.version}][prebuild] ${formattedMessage}`)
// info

@@ -93,4 +70,2 @@ case 'info':

return help(formattedMessage)
case 'help2':
return help2(formattedMessage)
// verbose

@@ -115,15 +90,8 @@ case 'verbose':

errorv: (msg) => log('errorv', msg),
errorvp: (msg) => log('errorvp', msg),
errorvpb: (msg) => log('errorvpb', msg),
errornocolor: (msg) => log('errornocolor', msg),
// warns
warn: (msg) => log('warn', msg),
warnv: (msg) => log('warnv', msg),
warnvp: (msg) => log('warnvp', msg),
warnvpb: (msg) => log('warnvpb', msg),
// success
success: (msg) => log('success', msg),
successv: (msg) => log('successv', msg),
successvp: (msg) => log('successvp', msg),
successvpb: (msg) => log('successvpb', msg),
// info

@@ -133,3 +101,2 @@ info: (msg) => log('info', msg),

help: (msg) => log('help', msg),
help2: (msg) => log('help2', msg),
// verbose

@@ -136,0 +103,0 @@ verbose: (msg) => log('verbose', msg),

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc