Skip to content

Commit

Permalink
Merge branch 'master' into feature/modal-wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
mansurpasha authored Apr 27, 2020
2 parents ed70141 + 1a3f59a commit 3e8067f
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 267 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ sls-dev-tools is currently being actively maintained. If you find a problem with
[Features](#features)

- [Navigating the tool](#navigating-the-tool)
- [Viewing all stack resources](#viewing-all-stack-resources)
- [Viewing statistics and recent calls](#viewing-statistics-and-recent-calls)
- [Deploying lambdas](#deploying-lambdas)
- [Single lambda deploy](#single-lambda-deploy)
- [Full stack deploy](#full-stack-deploy)
- [Invoking Lambdas](#invoking-lambdas)
- [EventBridge](#eventbridge)
- [Injecting events](#injecting-events)
- [EventBridge Schema Registry](#eventbridge-schema-registry)
Expand Down Expand Up @@ -100,14 +102,20 @@ sls-dev-tools works with the serverless framework by default, and can be used by

To use the SAM framework, pass the `--sam` option when running the tool.

When using the sam framework extra arguments for capabilites and s3 bucket must be added in the slsdevtools.config.js e.g. `--capabilities CAPABILITY_IAM --s3-bucket deployment-bucket-name` [Example SLS Dev Tools Config](slsdevtools.config.js.dist)
When using the sam framework extra arguments for capabilities and s3 bucket must be added in the slsdevtools.config.js e.g. `--capabilities CAPABILITY_IAM --s3-bucket deployment-bucket-name` [Example SLS Dev Tools Config](slsdevtools.config.js.dist)

## Features

### Navigating the tool

Use the arrow keys to move around each pane. Use tab to switch between different panes.

### Viewing all stack resources

Use the left and right arrow keys to navigate to the a list of all resources in the stack e.g. SNS, API Gateway, Dynamo DB. More functionality coming to this table soon!

![resourceTable](./img/resourceTable.png)

### Viewing statistics and recent calls

Select a lambda function and press enter to display statistics for the function. The line graph shows the number of invocations and errors for that lambda within the time interval. The bar chart shows the response time of the 5 most recent invocations. The logs for that function will also appear in the Server Logs pane.
Expand All @@ -134,7 +142,7 @@ You can also press 's' to deploy your entire stack.

### Invoking lambdas

Pressing 'i' with a lambda selected will open up a modal which will allow you to invoke a lambda. Fill the parameters field for any paramters you wish to invoke the lambda with and press submit to trigger the invocation.
Pressing 'i' with a lambda selected will open up a modal which will allow you to invoke a lambda. Fill the parameters field for any parameters you wish to invoke the lambda with and press submit to trigger the invocation.

### EventBridge

Expand Down Expand Up @@ -166,7 +174,7 @@ Navigate to the map pane using tab. Use the arrow keys to select a different reg

```
Shortcuts
- Pressing "h" while the tool is open will display a helpbox with all the keybindings and cli options
- Pressing "h" while the tool is open will display a help-box with all the keybindings and cli options
- Pressing "q" will quit the tool
- Pressing "o" while selecting a function from the function list will open the relevant page of the AWS console (saving some clicks!)
- Pressing "d" while selecting a function from the function list will deploy the selected lambda function, note this is not possible while using SAM
Expand Down
13 changes: 10 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ sls-dev-tools works with the serverless framework by default, and can be used by

To use the SAM framework, pass the `--sam` option when running the tool.

When using the sam framework extra arguments for capabilites and s3 bucket must be added in the slsdevtools.config.js e.g. `--capabilities CAPABILITY_IAM --s3-bucket deployment-bucket-name` [Example SLS Dev Tools Config](slsdevtools.config.js.dist)
When using the sam framework extra arguments for capabilities and s3 bucket must be added in the slsdevtools.config.js e.g. `--capabilities CAPABILITY_IAM --s3-bucket deployment-bucket-name` [Example SLS Dev Tools Config](slsdevtools.config.js.dist)

## Features

### Navigating the tool

Use the arrow keys to move around each pane. Use tab to switch between different panes.

### Viewing all stack resources

Use the left and right arrow keys to navigate to the a list of all resources in the stack e.g. SNS, API Gateway, Dynamo DB. More functionality coming to this table soon!

![resourceTable](./assets/resourceTable.png)

### Viewing statistics and recent calls

Select a lambda function and press enter to display statistics for the function. The line graph shows the number of invocations and errors for that lambda within the time interval. The bar chart shows the response time of the 5 most recent invocations. The logs for that function will also appear in the Server Logs pane.
Expand All @@ -83,7 +89,7 @@ You can also press 's' to deploy your entire stack.

### Invoking lambdas

Pressing 'i' with a lambda selected will open up a modal which will allow you to invoke a lambda. Fill the parameters field for any paramters you wish to invoke the lambda with and press submit to trigger the invocation.
Pressing 'i' with a lambda selected will open up a modal which will allow you to invoke a lambda. Fill the parameters field for any parameters you wish to invoke the lambda with and press submit to trigger the invocation.

### EventBridge

Expand Down Expand Up @@ -115,13 +121,14 @@ Navigate to the map pane using tab. Use the arrow keys to select a different reg

```
Shortcuts
- Pressing "h" while the tool is open will display a helpbox with all the keybindings and cli options
- Pressing "h" while the tool is open will display a help-box with all the keybindings and cli options
- Pressing "q" will quit the tool
- Pressing "o" while selecting a function from the function list will open the relevant page of the AWS console (saving some clicks!)
- Pressing "d" while selecting a function from the function list will deploy the selected lambda function, note this is not possible while using SAM
- Pressing "s" while selecting a function will deploy the entire stack
- Pressing "i" will invoke a lambda or inject an event into an event bus depending on selection
- Pressing "r" while selecting an event bus will open the event registry. Select a event schema to edit the event properties, and inject it on that bus.
- Pressing "l" will display a box with more statistics on the selected lambda
```

# A note on AWS API calls and pricing
Expand Down
Binary file added docs/assets/resourceTable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/resourceTable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"moment": "^2.24.0",
"node-emoji": "^1.10.0",
"open": "^7.0.3",
"prop-types": "^15.7.2"
"prop-types": "^15.7.2",
"update-notifier": "^4.1.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
Expand Down Expand Up @@ -48,7 +49,7 @@
]
},
"description": "The Dev Tools for the Serverless World",
"version": "1.0.1",
"version": "1.0.3",
"main": "src/index.js",
"directories": {
"lib": "lib"
Expand Down
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { getLogEvents } from "./services/awsCloudwatchLogs";
import { regionWizardModal } from "./modals/regionWizardModal";
import { stackWizardModal } from "./modals/stackWizardModal";
import updateNotifier from "./utils/updateNotifier";

const blessed = require("blessed");
const contrib = require("blessed-contrib");
Expand All @@ -33,6 +34,8 @@ try {
// No config provided
}

updateNotifier();

program.version(packageJson.version);
program
.option("-n, --stack-name <stackName>", "AWS stack name")
Expand Down Expand Up @@ -235,6 +238,15 @@ class Main {
this.previousSubmittedEvent = {};
// Dictionary to store previous submissions for each lambda function
this.previousLambdaPayload = {};

// Store previous errorId found in logs
this.prevErrorId = "";
// Flag to avoid getting notifications on first retrieval of logs
this.firstLogsRetrieved = false;
// Store events from cloudwatchLogs
this.events = [];
// Allows use of .bell() function for notifications
this.notifier = new blessed.Program();
}

setKeypresses() {
Expand Down
6 changes: 2 additions & 4 deletions src/modals/eventModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {
} from "../components";
import { getProperties } from "../services/awsSchema";

const blessed = require("blessed");

const createDynamicForm = async (
blessed,
api,
parent,
closeModal,
Expand Down Expand Up @@ -81,7 +82,6 @@ const createDetail = (keys, types, values) => {

const eventModal = (
screen,
blessed,
eventBridge,
application,
api,
Expand Down Expand Up @@ -186,7 +186,6 @@ const eventModal = (
setButtonSelected(true);

createDynamicForm(
blessed,
api,
fieldLayout,
closeModal,
Expand Down Expand Up @@ -229,7 +228,6 @@ const eventModal = (
eventLayout.destroy();
eventInjectionModal(
screen,
blessed,
eventBridge,
application,
injectEvent,
Expand Down
1 change: 1 addition & 0 deletions src/services/processEventLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function checkLogsForErrors(events, application) {
application.setPrevErrorId(latestErrorId);
if (application.firstLogsRetrieved) {
application.notifier.bell();
console.log("Recent lambda error. Check logs for details");
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/services/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class Serverless {
) {
return `${this.config.provider.stackName}`;
}
if (typeof this.config.service === "string") {
return `${this.config.service}-${stage}`;
}
return `${this.config.service.name}-${stage}`;
}

Expand Down
25 changes: 25 additions & 0 deletions src/utils/updateNotifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const updateNotifier = require("update-notifier");
const pkg = require("../../package.json");

function checkUpdates() {
const notifier = updateNotifier({
pkg,
updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day
shouldNotifyInNpmScript: true,
});

notifier.notify();

if (notifier.update && notifier.update.current !== notifier.update.latest) {
// TODO: Instead of console.log, this could return a status which can be shown in a program dialog
console.log(
`
Update for sls-dev-tools available:
Current: ${notifier.update.current}
Latest: ${notifier.update.latest}
`
);
}
}

module.exports = checkUpdates;
Loading

0 comments on commit 3e8067f

Please sign in to comment.