Skip to content

Commit

Permalink
Add CLI messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Jun 28, 2023
1 parent 2446314 commit 316bf14
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const {warnIfUsingSecretsWithoutTheBrefDependency} = require('./plugin/secrets')
const fs = require('fs');
const path = require('path');

// Disable `sls` promoting the Serverless Console because it's not compatible with PHP, it's tripping users up
if (!process.env.SLS_NOTIFICATIONS_MODE) {
process.env.SLS_NOTIFICATIONS_MODE = 'upgrades-only';
}

/**
* This file declares a plugin for the Serverless framework.
*
Expand Down Expand Up @@ -141,7 +146,33 @@ class ServerlessPlugin {
'bref:cli:run': () => runConsole(this.serverless, options),
'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();
},
'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();
},
};

process.on('beforeExit', (code) => {
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'));
}
});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ service: bref-demo
provider:
name: aws
region: us-east-2
logs:
restApi: true
logRetentionInDays: 7
versionFunctions: false
apiGateway:
binaryMediaTypes:
- '*/*'
Expand Down

0 comments on commit 316bf14

Please sign in to comment.