Skip to content

Commit

Permalink
Released commits with new folder structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinicioslc committed Jun 25, 2020
1 parent 3cab08b commit 5e3ea9d
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 95 deletions.
19 changes: 12 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# Changelog

- 0.18.1

NEW - Refactor at codebase with `plugin controllers` startegy.
NEW - Changed Folder structure.

- 0.18.0

NEW Improve how extension search `ADB` with adding `adb-resolver` module.
NEW - Added test cases for `adb-resolver` use cases.

NEW Added test cases for `adb-resolver` use cases.
NEW - Improve how extension search `ADB` in enviroment adding `adb-resolver` strategy.

FIX Enviroment variables is now accessed directly from path.
FIX - Enviroment variables is now accessed directly from path.

- 0.17.2

FIX for issue #7 removing necessity to close "Connecting to X" message
FIX - for issue #7 removing necessity to close "Connecting to X" message

- 0.17.1

NEW fully ci/cd enviroment, now new commits in master will be released to production on extensions.
NEW - fully ci/cd enviroment, now new commits in master will be released to production on extensions.

- Older versions
- Past

Forbiden Changes
NEW - Forbiden Changes
...
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 🔌 ADB Interface for VSCode

[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fvinicioslc%2Fadb-interface-vscode%2Fbadge%3Fref%3Dmaster&style=flat-square)](https://actions-badge.atrox.dev/vinicioslc/adb-interface-vscode/goto?ref=master)
![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/vinicioslc.adb-interface-vscode?style=flat-square)
![GitHub](https://img.shields.io/github/license/vinicioslc/adb-interface-vscode?style=flat-square)
Expand All @@ -6,9 +8,9 @@
<a href="https://codeclimate.com/github/vinicioslc/adb-interface-vscode/maintainability">
<img src="https://api.codeclimate.com/v1/badges/b9fd814b1bdf974a1d16/maintainability" /></a>

# ADB Interface for VSCode
<div style="text-align:center"><img src="media/icon.png" width="200" /></div>

> ⚠️ WARN !! ONLY TESTED IN WINDOWS !! (For while, you must have ADB at your Enviroment Variables)
> ⚠️ ONLY TESTED IN WINDOWS (For while, you need ADB at enviroment variables or in default platform-tools folder)
This are an simple ADB-Wrapper that makes possible to connect to an device over wifi connection without console use.

Expand Down Expand Up @@ -51,7 +53,7 @@ or
![coverage-lines](https://raw.githubusercontent.com/vinicioslc/adb-interface-vscode/master/.badges/badge-lines.png)
![coverage-statements](https://raw.githubusercontent.com/vinicioslc/adb-interface-vscode/master/.badges/badge-statements.png)

## Available Commands
## Implemented Commands

- ADB:📱 Reset connected devices port to :5555 (Open current device port with `adb tcpip 5555`)
- ADB:📱 Connect to device IP (need inform IP from device wanted `adb connect ${user_ip}:5555`)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adb-interface-vscode",
"displayName": "ADB Interface for VSCode",
"description": "A simple interface to allow use common ADB commands inside VSCode without console.",
"description": "A simple interface to allow use common ADB commands inside VSCode without console need.",
"version": "0.18.0",
"publisher": "vinicioslc",
"repository": "https://github.com/vinicioslc/adb-interface-vscode",
Expand All @@ -24,7 +24,7 @@
"vscode:prepublish": "npm run setup && npm run compile",
"setup": "npm install",
"compile": "tsc -p ./",
"publish": "npx vsce publish -p $VSCE_DEPLOY_TOKEN",
"publish": "npx vsce publish -p $VSCE_DEPLOY_TOKEN && git push origin --tags",
"pp": "npx vsce package && npx vsce publish",
"test": "npx jest --coverage",
"test:watch": "npx jest --watchAll",
Expand Down
2 changes: 1 addition & 1 deletion src/Infraestructure/ADBBaseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ExtController } from './ExtensionController'
import { ADBInterfaceException } from '../adb-wrapper'

export class ADBBaseController extends ExtController {
genericErrorReturn(e: Error) {
async genericErrorReturn(e: Error) {
if (e instanceof ADBInterfaceException) {
vscode.window.showWarningMessage(e.message)
} else {
Expand Down
14 changes: 10 additions & 4 deletions src/Infraestructure/ExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ import { IExtController } from './IExtController'
/**
Standard Controller for vscode extensions
*/
export class ExtController implements IExtController, Disposable {
export class ExtController implements IExtController {
context: ExtensionContext

constructor(context: ExtensionContext) {
this.context = context
this.onInit()
this.onInit(context)
}

async onInit(): Promise<void> {
/** onInit();
*
* Must be implemented in every controller, usually where we register the plugin commands.
* Called when an controller are instantiated receiving current context.
*/
async onInit(context: ExtensionContext) {
throw new Error('You must declare onInit method in ExtControllers')
}

Expand All @@ -22,9 +27,10 @@ export class ExtController implements IExtController, Disposable {
this.registerCommand(name, callback)
}
}
async registerCommand(name: string, callback: (...args: any[]) => any) {
registerCommand(name: string, callback: (...args: any[]) => any) {
let subscription = commands.registerCommand(name, callback)
this.context.subscriptions.push(subscription)
return this
}

async dispose() {
Expand Down
4 changes: 2 additions & 2 deletions src/Infraestructure/IExtController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export interface IExtController {
readonly context: ExtensionContext

/**Reposible for register this controller on vscode */
onInit(): Promise<void>
onInit(context: ExtensionContext): Promise<void>

/**
* Register command in vscode extensions
*/
registerCommand(name, callback): Promise<void>
registerCommand(name, callback): IExtController

/**
* Dispose this controller instance
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/adb-resolver/adb-resolver.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ADBResolver, ADBNotFoundError } from './index'
import { ConsoleInterfaceMock } from '../console/console-interface/console-interface-mock'
import { ConsoleInterfaceMock } from '../Infraestructure/console/console-interface/console-interface-mock'
const adbFound = `List of devices`

test('Should return current home dir when path is present', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/adb-resolver/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as os from 'os'
import { ConsoleInterface } from '../console/console-interface'
import { ConsoleInterface } from '../Infraestructure/console/console-interface'
import * as helperFunctions from './helper-functions'

export class ADBResolver {
Expand Down
2 changes: 1 addition & 1 deletion src/adb-wrapper/adb-messages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* istanbul ignore file */
export default {
DEVICES_IN_TCP_MODE: (port = 5555) => `Devices in TCP mode port: ${port}`,
NO_DEVICES_FOUND: () => 'No devices found or conected',
NO_DEVICES_FOUND: () => 'No devices found or conected to reset',
ADB_DEVICE_NOT_FOUND: () => 'ADB Device not found in this machine',
ADB_INTERFACE_EXCEPTION_DEFAULT: () => 'Exception during ADB connection.',
ADB_INTERFACE_ERROR_DEFAULT: () => 'Error during ADB connection.'
Expand Down
2 changes: 1 addition & 1 deletion src/adb-wrapper/connect-device-suite.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ADBConnection } from '.'
import { ConsoleInterfaceMock } from '../console/console-interface/console-interface-mock'
import { ConsoleInterfaceMock } from '../Infraestructure/console/console-interface/console-interface-mock'

const ip = '192.168.1.102'
const phoneName = 'DEVICE_NAME'
Expand Down
2 changes: 1 addition & 1 deletion src/adb-wrapper/device-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IConsoleInterface } from '../console/console-interface/iconsole-interface'
import { IConsoleInterface } from '../Infraestructure/console/console-interface/iconsole-interface'
import adbCommands from './adb-commands'

export class DeviceHelpers {
Expand Down
14 changes: 9 additions & 5 deletions src/adb-wrapper/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import * as os from 'os'
import adbCommands from './adb-commands'
import { ConsoleChannel, consoleReturnAre } from '../console/console-channel'
import {
ConsoleChannel,
consoleReturnAre
} from '../Infraestructure/console/console-channel'
import adbReturns from './adb-returns'
import adbMessages from './adb-messages'
import { NetHelpers } from '../net-helpers'
import { NetHelpers } from '../Infraestructure/net-helpers'
import { IPHelpers } from './ip-helpers'
import { DeviceHelpers } from './device-helpers'
import { ADBResolver } from '../adb-resolver'
import { IConsoleInterface } from '../console/console-interface/iconsole-interface'
import { IConsoleInterface } from '../Infraestructure/console/console-interface/iconsole-interface'
import { log } from 'util'

export class ADBConnection extends ConsoleChannel {
Expand Down Expand Up @@ -60,10 +63,10 @@ export class ADBConnection extends ConsoleChannel {
public async ResetPorts(): Promise<string> {
let finalResult = null
try {
const result = await this.resolverInstance.sendADBCommand(
const consoleReturn = await this.resolverInstance.sendADBCommand(
adbCommands.RESET_PORTS()
)
const output = result.toString()
const output = consoleReturn.toString()
if (consoleReturnAre(output, adbReturns.RESTARTING_PORT())) {
finalResult = adbMessages.DEVICES_IN_TCP_MODE()
}
Expand Down Expand Up @@ -98,6 +101,7 @@ export class ADBConnection extends ConsoleChannel {
}
return finalResult
}

public async FindConnectedDevices(): Promise<Array<string>> {
let devicesArray = []
try {
Expand Down
2 changes: 1 addition & 1 deletion src/adb-wrapper/kill-adb-suite.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ADBConnection, ADBInterfaceError } from '.'
import { ConsoleInterfaceMock } from '../console/console-interface/console-interface-mock'
import { ConsoleInterfaceMock } from '../Infraestructure/console/console-interface/console-interface-mock'
// import { ConsoleInterface } from './../console-interface/console-interface'

// Mocked ConsoleInterface
Expand Down
2 changes: 1 addition & 1 deletion src/adb-wrapper/list-adb-suite.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ADBConnection } from '.'
import { ConsoleInterfaceMock } from '../console/console-interface/console-interface-mock'
import { ConsoleInterfaceMock } from '../Infraestructure/console/console-interface/console-interface-mock'

test('list all devices returning empty array', async () => {
let cimock = new ConsoleInterfaceMock()
Expand Down
75 changes: 32 additions & 43 deletions src/controllers/adb-controller/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode'
import { ADBConnection } from '../../adb-wrapper'
import { ADBConnection, ADBInterfaceException } from '../../adb-wrapper'
import * as appStateKeys from '../../extension/global-state-keys'
import { IPHelpers } from '../../adb-wrapper/ip-helpers'
import { ADBBaseController } from '../../Infraestructure/ADBBaseController'
Expand All @@ -14,49 +14,38 @@ export class ADBCommandsController extends ADBBaseController {
this.appStateKeys = appStateKeys
}
async onInit() {
await this.registerCommand(
'adbInterface.adbwificonnect',
this.ConnectToDevice
this.registerCommand('adbInterface.adbwificonnect', () =>
this.connectToDevice()
)
await this.registerCommand(
'adbInterface.adbResetPorts',
this.ResetDevicesPort
)
await this.registerCommand(
'adbInterface.disconnectEverthing',
this.DisconnectAnyDevice
)
await this.registerCommand(
'adbInterface.connectToDeviceFromList',
this.ConnectToDeviceFromList
)
await this.registerCommand('adbInterface.killserver', this.KillADBServer)
.registerCommand('adbInterface.adbResetPorts', () =>
this.resetDevicesPort()
)
.registerCommand('adbInterface.disconnectEverthing', () =>
this.disconnectAnyDevice()
)
.registerCommand('adbInterface.connectToDeviceFromList', () =>
this.connectToDeviceFromList()
)
.registerCommand('adbInterface.killserver', () => this.killADBServer())
}

async ResetDevicesPort() {
vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: 'Starting ADB'
},
async progress => {
try {
progress.report({
message: 'Reseting ports to 5555',
increment: 50
})
let adbInterfaceResult = await this.adbInstance.ResetPorts()
vscode.window.showInformationMessage(adbInterfaceResult)
return
} catch (e) {
this.genericErrorReturn(e)
}
}
)
async genericErrorReturn(e: Error) {
if (e instanceof ADBInterfaceException) {
vscode.window.showWarningMessage(e.message)
} else {
vscode.window.showErrorMessage('Error:' + e.message)
}
}
async resetDevicesPort() {
try {
vscode.window.showInformationMessage(await this.adbInstance.ResetPorts())
} catch (e) {
this.genericErrorReturn(e)
}
}

async ConnectToDevice() {
let lastvalue = context.globalState.get(appStateKeys.lastIPUsed(), '')
async connectToDevice() {
let lastvalue = this.context.globalState.get(appStateKeys.lastIPUsed(), '')
// The code you place here will be executed every time your command is executed
vscode.window
.showInputBox({
Expand All @@ -67,7 +56,7 @@ export class ADBCommandsController extends ADBBaseController {
'Enter the IP address from your device to connect to him. (Last address will be filled in next time) port 5555 added automagically.'
})
.then(async value => {
await this.connectToAdbDevice(context, value)
await this.connectToAdbDevice(this.context, value)
})
// Display a message box to the user
}
Expand All @@ -85,7 +74,7 @@ export class ADBCommandsController extends ADBBaseController {
}
}

async DisconnectAnyDevice() {
async disconnectAnyDevice() {
try {
vscode.window.showInformationMessage(
await this.adbInstance.DisconnectFromAllDevices()
Expand All @@ -94,7 +83,7 @@ export class ADBCommandsController extends ADBBaseController {
this.genericErrorReturn(e)
}
}
async KillADBServer() {
async killADBServer() {
try {
const adbInterfaceResult = await this.adbInstance.KillADBServer()
if (adbInterfaceResult) {
Expand All @@ -107,7 +96,7 @@ export class ADBCommandsController extends ADBBaseController {
}
}

async ConnectToDeviceFromList() {
async connectToDeviceFromList() {
try {
const ipAddresses = await this.getIPAddressList()
const ipSelected = await vscode.window.showQuickPick(ipAddresses, {
Expand Down
16 changes: 7 additions & 9 deletions src/controllers/firebase-controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,23 @@ export class FirebaseController extends ADBBaseController {
}

async onInit() {
await this.registerCommand(
'adbInterface.enableFirebaseDebug',
this.EnableFirebaseDebugView
await this.registerCommand('adbInterface.enableFirebaseDebug', () =>
this.enableFirebaseDebugView()
)
await this.registerCommand(
'adbInterface.disableFirebaseDebug',
this.DisableFirebaseDebugView
await this.registerCommand('adbInterface.disableFirebaseDebug', () =>
this.disableFirebaseDebugView()
)
}

genericErrorReturn(e: Error) {
async genericErrorReturn(e: Error) {
if (e instanceof ADBInterfaceException) {
vscode.window.showWarningMessage(e.message)
} else {
vscode.window.showErrorMessage('Error:' + e.message)
}
}

async EnableFirebaseDebugView() {
async enableFirebaseDebugView() {
try {
const lastvalue = this.context.globalState.get(
appStateKeys.allPackages(),
Expand Down Expand Up @@ -64,7 +62,7 @@ export class FirebaseController extends ADBBaseController {
this.genericErrorReturn(e)
}
}
async DisableFirebaseDebugView() {
async disableFirebaseDebugView() {
try {
vscode.window.showInformationMessage(
await this.firebaseInstance.disableFirebaseDebugView()
Expand Down
Loading

0 comments on commit 5e3ea9d

Please sign in to comment.