Skip to content

Commit

Permalink
Merge branch 'master' into guardian-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
BenEllerby committed May 5, 2020
2 parents 7b4999c + 14f8d9c commit c42d49c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/components/resourceTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,12 @@ class ResourceTable {
case RESOURCE_TABLE_TYPE.LAMBDA:
this.type = RESOURCE_TABLE_TYPE.ALL_RESOURCES;
this.table.setLabel("<- All Resources ->");
this.table.options.columnWidth = [50, 30];
break;
case RESOURCE_TABLE_TYPE.ALL_RESOURCES:
this.type = RESOURCE_TABLE_TYPE.LAMBDA;
this.table.setLabel("<- Lambda Functions ->");
this.table.options.columnWidth = [30, 30, 10, 10, 20];
break;
default:
return 0;
Expand Down Expand Up @@ -293,7 +295,7 @@ class ResourceTable {
this.table.data = resources.map((resource) => {
const resourceName = resource.LogicalResourceId;
const resourceType = resource.ResourceType.replace("AWS::", "");
return [resourceName, this.program.region, resourceType];
return [resourceName, resourceType];
});
this.updateAllResourcesTableRows();
}
Expand Down Expand Up @@ -348,7 +350,7 @@ class ResourceTable {

updateAllResourcesTableRows() {
this.table.setData({
headers: ["logical", "region", "type"],
headers: ["logical", "type"],
data: this.table.data,
});
}
Expand Down
23 changes: 17 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env node
import AWS from "aws-sdk";
import { logo, dateFormats, DASHBOARD_FOCUS_INDEX } from "./constants";
import {
awsRegionLocations,
logo,
dateFormats,
DASHBOARD_FOCUS_INDEX,
} from "./constants";
import {
eventRegistryModal,
eventInjectionModal,
Expand All @@ -20,8 +25,7 @@ import {
checkLogsForErrors,
} from "./services/processEventLogs";
import { getLogEvents } from "./services/awsCloudwatchLogs";

import updateNotifier from "./utils/updateNotifier";
import checkForUpdates from "./utils/updateNotifier";

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

updateNotifier();

program.version(packageJson.version);
program
.option("-n, --stack-name <stackName>", "AWS stack name")
Expand Down Expand Up @@ -106,6 +108,7 @@ function getAWSCredentials() {
callback: (err) => {
if (err) {
console.error(`SharedIniFileCreds Error: ${err}`);
process.exit(0);
}
},
});
Expand All @@ -124,6 +127,7 @@ function getAWSCredentials() {
callback: (err) => {
if (err) {
console.error(`SharedIniFileCreds Error: ${err}`);
process.exit(0);
}
},
});
Expand Down Expand Up @@ -274,6 +278,8 @@ class Main {
this.events = [];
// Allows use of .bell() function for notifications
this.notifier = new blessed.Program();

checkForUpdates();
}

setKeypresses() {
Expand Down Expand Up @@ -371,6 +377,7 @@ class Main {

async render() {
setInterval(() => {
console.log(process.memoryUsage());
this.map.updateMap();
this.updateResourcesInformation();
this.updateGraphs();
Expand Down Expand Up @@ -559,7 +566,11 @@ function startTool() {
AWS.config.credentials = creds;
updateAWSServices();

if (!program.region) {
if (
!awsRegionLocations
.map((region) => region.label)
.includes(program.region)
) {
promptRegion();
} else if (!program.stackName) {
promptStackName();
Expand Down
11 changes: 8 additions & 3 deletions src/modals/helpModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const helpModal = (screen, application) => {
["q", "Close the application"],
["d", "Deploys the selected lambda function"],
["s", "Deploys all the lambda functions within the stack"],
["Arrows", "Used to select from list, by default the function list"],
["Up/Down Arrows", "Select entry in list, by default the function list"],
["Right/Left Arrows", "Switch between resource tables"],
["Tab", "Used to change focus between selected windows"],
["i", "Invoke a lambda or inject an event into an event bus"],
["r", "Open the EventBridge Registry window for the selected event bus"],
Expand All @@ -29,8 +30,12 @@ const helpModal = (screen, application) => {
["-i, --interval <interval>", "interval of graphs, in seconds"],
["-p, --profile <profile>", "aws profile name to use"],
["-h, --help", "output usage information"],
["-l, --location <location>", "location of your serverless project"],
["-s, --stage <stage>", "If --sls is set, use this stage"],
["--sls", "use the serverless framework to execute commands"],
["--sam", "use the SAM framework to execute commands"],
];
const helpLayout = new ModalLayout(screen, 112, 27, true);
const helpLayout = new ModalLayout(screen, 112, 35, true);

blessed.listtable({
parent: helpLayout,
Expand All @@ -41,7 +46,7 @@ const helpModal = (screen, application) => {
border: "line",
pad: 2,
width: 110,
height: 20,
height: 29,
style: {
border: { fg: "green" },
header: { fg: "bright-green", bold: true, underline: true },
Expand Down
10 changes: 4 additions & 6 deletions src/utils/updateNotifier.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const updateNotifier = require("update-notifier");
const pkg = require("../../package.json");

function checkUpdates() {
function checkForUpdates() {
const notifier = updateNotifier({
pkg,
updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day
Expand All @@ -13,13 +13,11 @@ function checkUpdates() {
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:
`Update for sls-dev-tools available:
Current: ${notifier.update.current}
Latest: ${notifier.update.latest}
`
Latest: ${notifier.update.latest}`
);
}
}

module.exports = checkUpdates;
module.exports = checkForUpdates;

0 comments on commit c42d49c

Please sign in to comment.