Skip to content

Commit

Permalink
Merge pull request #1837 from brefphp/fix-v4
Browse files Browse the repository at this point in the history
Support Serverless Framework v3 and v4
  • Loading branch information
mnapoli authored Jul 2, 2024
2 parents ddf2398 920d073 commit 05d4d26
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 147,11 @@ class ServerlessPlugin {
'bref:local:run': () => runLocal(this.serverless, options),
'bref:layers:show': () => listLayers(this.serverless, utils.log),
'before:logs:logs': () => {
/** @type {typeof import('chalk')} */
// @ts-ignore
const chalk = require.main.require('chalk');
utils.log(chalk.gray('View, tail, and search logs from all functions with https://dashboard.bref.sh'));
utils.log(this.gray('View, tail, and search logs from all functions with https://dashboard.bref.sh'));
utils.log();
},
'before:metrics:metrics': () => {
/** @type {typeof import('chalk')} */
// @ts-ignore
const chalk = require.main.require('chalk');
utils.log(chalk.gray('View all your application\'s metrics with https://dashboard.bref.sh'));
utils.log(this.gray('View all your application\'s metrics with https://dashboard.bref.sh'));
utils.log();
},
};
Expand All @@ -166,11 160,8 @@ class ServerlessPlugin {
const command = serverless.processedInput.commands[0] || '';
// On successful deploy
if (command.startsWith('deploy') && code === 0) {
/** @type {typeof import('chalk')} */
// @ts-ignore
const chalk = require.main.require('chalk');
utils.log();
utils.log(chalk.gray('Want a better experience than the AWS console? Try out https://dashboard.bref.sh'));
utils.log(this.gray('Want a better experience than the AWS console? Try out https://dashboard.bref.sh'));
}
});
}
Expand Down Expand Up @@ -378,6 369,16 @@ class ServerlessPlugin {
}
});
}

/**
* @param {string} text
* @returns {string}
*/
gray(text) {
const grayText = "\x1b[90m";
const reset = "\x1b[0m";
return `${grayText}${text}${reset}`;
}
}

module.exports = ServerlessPlugin;

0 comments on commit 05d4d26

Please sign in to comment.