Skip to content

Commit

Permalink
Resource Explorer: Display Dynos
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwilaby committed Aug 1, 2024
1 parent ed9dabd commit 8360e23
Show file tree
Hide file tree
Showing 47 changed files with 1,033 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ web_modules/
.node_repl_history

# Output of 'npm pack'
*.tgz
# *.tgz <--- Uncommnt when the heroku SDK is available.

# Yarn Integrity file
.yarn-integrity
Expand Down
Binary file added heroku-cli-schema-1.0.25.tgz
Binary file not shown.
62 changes: 40 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 38 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"onLanguage:shellscript",
"onAuthenticationRequest:<Heroku>"
],
"extensionDependencies": [
"vscode.git"
],
"main": "./out/extension/index.js",
"contributes": {
"viewsWelcome": [
Expand All @@ -28,7 +31,7 @@
{
"id": "heroku",
"title": "%view.heroku.name%",
"icon": "/resources/heroku.svg"
"icon": "/resources/heroku.png"
}
]
},
Expand All @@ -40,13 +43,38 @@
"when": "!heroku.authenticated"
},
{
"type": "webview",
"id": "herokuai:geoff",
"name": "Geoff",
"id": "heroku:dynos:treeview",
"name": "Dynos",
"when": "heroku.authenticated"
}
]
},
"menus": {
"view/item/context": [
{
"when": "viewItem === dyno:up",
"command": "heroku:dyno:stop",
"group": "inline"
},
{
"when": "viewItem === dyno:up || viewItem === dyno:down || viewItem === dyno:crashed",
"command": "heroku:dyno:restart",
"group": "inline"
}
]
},
"commands": [
{
"command": "heroku:dyno:restart",
"title": "Restart",
"icon": "$(timeline-refresh)"
},
{
"command": "heroku:dyno:stop",
"title": "Stop",
"icon": "$(debug-stop)"
}
],
"capabilities": {
"hoverProvider": true
}
Expand All @@ -66,11 +94,11 @@
},
"devDependencies": {
"@oclif/config": "^1.18.17",
"@types/mocha": "^10.0.6",
"@types/mocha": "^10.0.7",
"@types/mvdan-sh": "^0.10.9",
"@types/node": "18.x",
"@types/sinon": "^17.0.3",
"@types/vscode": "^1.85.0",
"@types/vscode": "1.91.0",
"@types/vscode-webview": "1.57.5",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
Expand All @@ -86,15 +114,16 @@
"prettier": "3.2.4",
"rewire": "^7.0.0",
"sinon": "^18.0.0",
"typescript": "5.x"
"typescript": "5.5.4"
},
"dependencies": {
"@heroku-cli/schema": "file:heroku-cli-schema-1.0.25.tgz",
"@vscode/codicons": "^0.0.36",
"@vscode/l10n": "0.0.x",
"@vscode/webview-ui-toolkit": "^1.4.0",
"marked": "^13.0.1",
"marked": "^13.0.3",
"mvdan-sh": "^0.10.1",
"resolve.exports": "^2.0.2",
"tslib": "2.6.2"
"tslib": "2.6.3"
}
}
Binary file added resources/dyno/dynomite-1x-16.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 resources/dyno/dynomite-2x-16.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 resources/dyno/dynomite-basic-16.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 resources/dyno/dynomite-default-16.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 resources/dyno/dynomite-eco-16.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 resources/dyno/dynomite-free-16.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 resources/dyno/dynomite-hobby-16.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 resources/dyno/dynomite-pl-16.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 resources/dyno/dynomite-pm-16.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 resources/dyno/dynomite-ps-16.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 resources/dyno/dynomite-px-16.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 resources/dyno/dynomite-shield-pl-16.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 resources/dyno/dynomite-shield-pm-16.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 resources/dyno/dynomite-shield-ps-16.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 resources/dyno/dynomite-space-pl-16.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 resources/dyno/dynomite-space-pm-16.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 resources/dyno/dynomite-space-ps-16.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 resources/heroku.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion resources/heroku.svg

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/import-map-builder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { exec } from "node:child_process";
import { readFile, writeFile } from "node:fs/promises";
import path from "node:path";
import * as resolve from 'resolve.exports';
import packageLock from './package-lock.json' assert {type:'json'}
import packageLock from '../package-lock.json' assert {type:'json'}

/**
* Finds the ESM entry point for a package based
Expand Down Expand Up @@ -90,7 +90,7 @@ async function addImportMapEntry(resolvedFilePath) {
/**
* Gets the list of files that are part
* of the compilation.
*
*
* @see https://www.typescriptlang.org/tsconfig/#listFiles
*/
const tscOutput = await new Promise(resolve => {
Expand Down
9 changes: 1 addition & 8 deletions src/extension/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@
"@typescript-eslint/return-await": "error",
"no-await-in-loop": "off",
"no-return-await": "off",
"class-methods-use-this": [
"warn",
{
"exceptMethods": [
"run"
]
}
],
"class-methods-use-this": "off",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
Expand Down
6 changes: 4 additions & 2 deletions src/extension/commands/auth/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ suite('The LoginCommand', () => {
})

test('is registered', async () => {
const allCommands = (await vscode.commands.getCommands()).filter(cmd => cmd.includes('git'));
debugger
const commands = await vscode.commands.getCommands(true);
const login = commands.find(command => command === LoginCommand.COMMAND_ID);
assert.ok(!!login, 'The LoginCommand is not registered.');
const command = commands.find(command => command === LoginCommand.COMMAND_ID);
assert.ok(!!command, 'The LoginCommand is not registered.');
});

test('authenticates successfully using the happy path', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/extension/commands/auth/logout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ suite('The LogoutCommand', () => {

test('is registered', async () => {
const commands = await vscode.commands.getCommands(true);
const logout = commands.find(command => command === LogoutCommand.COMMAND_ID);
assert.ok(logout, 'The LogoutCommand is not registered.');
const command = commands.find(command => command === LogoutCommand.COMMAND_ID);
assert.ok(command, 'The LogoutCommand is not registered.');
});

test('logs out successfully using the happy path', async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/extension/commands/auth/token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ suite('The TokenCommand', () => {

test('is registered', async () => {
const commands = await vscode.commands.getCommands(true);
const tokenCommand = commands.find(command => command === TokenCommand.COMMAND_ID);
assert.ok(!!tokenCommand, 'The TokenCommand is not registered');
const command = commands.find(command => command === TokenCommand.COMMAND_ID);
assert.ok(!!command, 'The TokenCommand is not registered');
});

test('uccessfully returns the auth token', async () => {
test('successfully returns the auth token', async () => {
const result = await vscode.commands.executeCommand<string>(TokenCommand.COMMAND_ID);
assert.equal(result, 'abc-123', `Output was ${result} but expected abc-123`);
});
Expand Down
54 changes: 54 additions & 0 deletions src/extension/commands/auth/welcome-view-sign-in.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as assert from 'node:assert';
import sinon from 'sinon';

import * as vscode from 'vscode';
import { randomUUID } from 'node:crypto';
import { WelcomeViewSignIn } from './welcome-view-sign-in';

suite('The WelcomViewSignInCommand', () => {
let getSessionStub: sinon.SinonStub;
let showErrorMessageStub: sinon.SinonStub;

const sessionObject = {
account: {
id: 'Heroku',
label: 'tester-123@heroku.com'
},
id: randomUUID(),
scopes: [],
accessToken: randomUUID()
};
setup(() => {
getSessionStub = sinon.stub(vscode.authentication, 'getSession');
showErrorMessageStub = sinon.stub(vscode.window, 'showErrorMessage');
});

teardown(() => {
getSessionStub.restore();
showErrorMessageStub.restore();
});

test('is registered', async () => {
const commands = await vscode.commands.getCommands(true);
const command = commands.find(command => command === WelcomeViewSignIn.COMMAND_ID);
assert.ok(!!command, 'The WelcomeViewSignIn command is not registered');
});

test('successfully authenticates', async () => {
getSessionStub.callsFake(async (providerId: string) => {
if (providerId === 'heroku:auth:login') {
return sessionObject;
}
return undefined;
});
await vscode.commands.executeCommand<string>(WelcomeViewSignIn.COMMAND_ID);
assert.ok(!!getSessionStub.exceptions.length);
});

test('asks the user to try again when authentication fails', async() => {
showErrorMessageStub.callsFake(async () => 'skip');
getSessionStub.throws(new Error('failed!'));
const result = await vscode.commands.executeCommand<string>(WelcomeViewSignIn.COMMAND_ID);
assert.ok(showErrorMessageStub.called);
})
});
2 changes: 1 addition & 1 deletion src/extension/commands/auth/welcome-view-sign-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class WelcomeViewSignIn extends HerokuCommand<void> {
if (session?.accessToken) {
this.outputChannel?.appendLine(`Successfully authenticated as ${session.account.label}`);
}
} catch (e) {
} catch {
const affirmative = 'Try again?';
const action = await vscode.window.showErrorMessage(
'Authentication was unsucessful. Try again?',
Expand Down
Loading

0 comments on commit 8360e23

Please sign in to comment.