Skip to content

Commit

Permalink
Add commands to rekey device and create packages (#509)
Browse files Browse the repository at this point in the history
* Add ability to capture device screenshots

* Add ability to capture device screenshots

1. Added support to show preview of screenshot
2. Fixed a linter issue

* Feature request: add ability to rekey/sign apps

Added support for the following commands:

1. Rekey Device: Rekey specified device based on the signing password ("brightscript.remoteControl.signingPassword") and package file ("brightscript.remoteControl.signedPackagePath") provided.

2. Create Package: This will present user a list of available launch configs to choose from. Once selected it will create a .zip file and .pkg file based on the config and will save them  to the ${workspacefolder}/out

3. Rekey Device and Create Package: This will first rekey device and then create package for the selected launch config

* remove stale code

* remove redundent code

* TBD-126

Updates based on below reqs:

rekey:
a) "How do you want to enter your stuff?"
 - "Pick from json file"
 - "Enter manually"
b) prompt for host (prepopulated from json above if possible)
c) Prompt for password (prepopulated from json above if possible)
d) Prompt for signed package path (prepopulated from json above if available)

package:
a) "What should we package?"
 - "Pick a folder"
 - "Pick from a launch.json"
    - show a launch.json option picker
 - "Pick a rokudeploy.json"
	-

b) prompt for host (prepopulated from json above if possible)
c) Prompt for password (prepopulated from json above if possible)
d) Prompt for signed package path (prepopulated from json above if available)
e) Show a summary of stuff, ask to click "Yes, do it" or "No, something's wrong, cancel".

* TBD-126

* Update BrightScriptCommands.ts

* Refined the flow a bit

* TBD-126:

1. Added support to show existing pkg file for rekey confirmation
2. Updated create package flow to confirm all the entries with user and ti update - if needed

* TBD-126

Added support to maintain status of previously selected host and config

* TBD-126

updated rekey and create package flow

* Update RekeyAndPackageCommand.ts

1. updated outfile name to be the source folder name only
2. Fixed a bug for outdir that only supported mac paths
3. Added title to all inputboxes
4. Added a prompt for rootDir incase it is missing during create package
5. Added outfile path in dialog upon successful packaging

* TBD-126

Added support to show package path in successful dialog and an option to open package in file explorer

* Use `open` to open folder instead of custom function

* Normalize a few file paths

* Better rekeySignedPackage handling when empty string

* simplify default config

* Show .pkg in summary

* Use correct file paths in more dialogs

* Remove unused funcs in BrightScriptCommands.ts

---------

Co-authored-by: Bronley Plumb <[email protected]>
  • Loading branch information
fumer-fubotv and TwitchBronBron authored Mar 12, 2024
1 parent 2454ace commit b05f3a3
Show file tree
Hide file tree
Showing 4 changed files with 513 additions and 21 deletions.
55 changes: 39 additions & 16 deletions package-lock.json

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

21 changes: 20 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"net": "^1.0.2",
"node-cache": "^4.2.0",
"node-ssdp": "^4.0.0",
"open": "^8.4.2",
"postman-request": "^2.88.1-postman.32",
"pretty-bytes": "^5.6.0",
"roku-debug": "^0.21.6",
Expand Down Expand Up @@ -175,7 +176,10 @@
"onCommand:extension.brightscript.sendRemoteText",
"onCommand:brighterscript.showPreview",
"onCommand:brighterscript.showPreviewToSide",
"onCommand:extension.brightscript.captureScreenshot"
"onCommand:extension.brightscript.captureScreenshot",
"onCommand:extension.brightscript.rekeyDevice",
"onCommand:extension.brightscript.createPackage",
"onCommand:extension.brightscript.rekeyAndPackage"
],
"contributes": {
"viewsContainers": {
Expand Down Expand Up @@ -2986,6 +2990,21 @@
"category": "BrighterScript",
"icon": "./images/icons/inspect-active.svg"
},
{
"command": "extension.brightscript.rekeyDevice",
"title": "Rekey Device",
"category": "BrightScript"
},
{
"command": "extension.brightscript.createPackage",
"title": "Create Package",
"category": "BrightScript"
},
{
"command": "extension.brightscript.rekeyAndPackage",
"title": "Rekey Device and Create Package",
"category": "BrightScript"
},
{
"command": "extension.brightscript.captureScreenshot",
"title": "Capture Screenshot",
Expand Down
10 changes: 6 additions & 4 deletions src/BrightScriptCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BrightScriptFileUtils from './BrightScriptFileUtils';
import { GlobalStateManager } from './GlobalStateManager';
import { brighterScriptPreviewCommand } from './commands/BrighterScriptPreviewCommand';
import { captureScreenshotCommand } from './commands/CaptureScreenshotCommand';
import { rekeyAndPackageCommand } from './commands/RekeyAndPackageCommand';
import { languageServerInfoCommand } from './commands/LanguageServerInfoCommand';
import { util } from './util';
import { util as rokuDebugUtil } from 'roku-debug/dist/util';
Expand Down Expand Up @@ -37,6 +38,7 @@ export class BrightScriptCommands {
brighterScriptPreviewCommand.register(this.context);
languageServerInfoCommand.register(this.context);
captureScreenshotCommand.register(this.context, this);
rekeyAndPackageCommand.register(this.context, this, this.userInputManager);

this.registerGeneralCommands();

Expand Down Expand Up @@ -394,13 +396,13 @@ export class BrightScriptCommands {
}
}

public async getRemoteHost() {
public async getRemoteHost(showPrompt = true) {
this.host = await this.context.workspaceState.get('remoteHost');
if (!this.host) {
let config = vscode.workspace.getConfiguration('brightscript.remoteControl', null);
this.host = config.get('host');
// eslint-disable-next-line no-template-curly-in-string
if (!this.host || this.host === '${promptForHost}') {
if ((!this.host || this.host === '${promptForHost}') && showPrompt) {
this.host = await vscode.window.showInputBox({
placeHolder: 'The IP address of your Roku device',
value: ''
Expand All @@ -423,13 +425,13 @@ export class BrightScriptCommands {
return this.host;
}

public async getRemotePassword() {
public async getRemotePassword(showPrompt = true) {
this.password = await this.context.workspaceState.get('remotePassword');
if (!this.password) {
let config = vscode.workspace.getConfiguration('brightscript.remoteControl', null);
this.password = config.get('password');
// eslint-disable-next-line no-template-curly-in-string
if (!this.password || this.password === '${promptForPassword}') {
if ((!this.password || this.password === '${promptForPassword}') && showPrompt) {
this.password = await vscode.window.showInputBox({
placeHolder: 'The developer account password for your Roku device',
value: ''
Expand Down
Loading

0 comments on commit b05f3a3

Please sign in to comment.