Skip to content

Commit

Permalink
Merge pull request #1673 from kevincerro/bugfix/secrets-loader-subdep…
Browse files Browse the repository at this point in the history
…endency

Detect bref/secrets-loader installed as dependency of another package
  • Loading branch information
mnapoli committed Oct 23, 2023
2 parents 25d94e0 + 89fdaca commit b0dbcfd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugin/secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ function warnIfUsingSecretsWithoutTheBrefDependency(serverless, log) {

if (allVariables.length > 0) {
// Check if the bref/secrets-loader dependency is installed in composer.json
if (! fs.existsSync('composer.json')) {
if (! fs.existsSync('composer.lock')) {
return;
}
const composerJson = JSON.parse(fs.readFileSync('composer.json', 'utf8'));
const dependencies = Object.keys(composerJson.require || {});
const composerLock = JSON.parse(fs.readFileSync('composer.lock', 'utf8'));
const dependencies = composerLock.packages.map(v => v.name) || {};
if (dependencies.includes('bref/secrets-loader')) {
return;
}

log.warning(`The following environment variables use the "bref-ssm:" prefix, but the "bref/secrets-loader" dependency is not installed via "composer.json".`);
log.warning(`The following environment variables use the "bref-ssm:" prefix, but the "bref/secrets-loader" dependency is not installed.`);
allVariables.forEach(variable => log.warning(` ${variable}`));
log.warning(`The "bref/secrets-loader" dependency is required to use the "bref-ssm:" prefix. Install it by running:`);
log.warning(` composer require bref/secrets-loader`);
Expand Down

0 comments on commit b0dbcfd

Please sign in to comment.