-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ async def main(connection): | |
@iterm2.RPC | ||
async def displayExpirationDate(session_id): | ||
await component.async_open_popover(session_id, "<p style='font-family: Arial'>Retrieving org expiration date... <em>(wait)</em></p>", iterm2.Size(300, 30)) | ||
|
||
from subprocess import Popen, PIPE | ||
import json | ||
p = Popen(['sfdx force:org:display --targetusername=' + aliasOrUsername + ' --json'], stdin = PIPE, stdout = PIPE, stderr = PIPE, universal_newlines = True, shell = True) | ||
|
@@ -30,18 +30,18 @@ async def displayExpirationDate(session_id): | |
expiration += '(expired)' | ||
elif stdout: | ||
expiration += 'Never - org is a sandbox.' | ||
|
||
await component.async_open_popover(session_id, "<p style='font-family: Arial'>The scratch org expires on: <strong>" + expiration + '</strong></p>', iterm2.Size(350, 30)) | ||
|
||
knobs = [iterm2.CheckboxKnob("Enable expiration date", False, "showExpirationDate")] | ||
component = iterm2.StatusBarComponent(short_description = "SFDX Status", detailed_description = "Provides status info for SFDX project folders", knobs = knobs, exemplar = u"\u2601 SFDC-1234 [email protected]", update_cadence = None, identifier = "com.msk.sfdx") | ||
|
||
@iterm2.StatusBarRPC | ||
async def coro(knobs, path = iterm2.Reference("path"), cwd = iterm2.Reference("user.currentDir?")): | ||
import os | ||
import json | ||
from pathlib import Path | ||
|
||
currentDir = path | ||
if 'force-app' in currentDir: # User is in subdirectory | ||
currentDir = currentDir.split('force-app')[0] # Get root directory of project folder | ||
|
@@ -52,18 +52,18 @@ async def coro(knobs, path = iterm2.Reference("path"), cwd = iterm2.Reference("u | |
config = json.load(configFile) | ||
global aliasOrUsername | ||
aliasOrUsername = config['defaultusername'] | ||
|
||
# Retrieve username for alias | ||
with open(os.environ['HOME'] + '/.sfdx/alias.json') as aliasFile: | ||
alias = json.load(aliasFile) | ||
|
||
if 'defaultusername' in config and 'orgs' in alias: | ||
return u'\u2601 ' + config['defaultusername'] + u' \u2022 ' + alias['orgs'][config['defaultusername']] | ||
else: | ||
return u'\u2601' # Some error occurred, e.g. file not found or wrong content | ||
else: | ||
return u'\u2601' # No SFDX directory | ||
|
||
await component.async_register(connection, coro, timeout = 15.0, onclick = displayExpirationDate) | ||
|
||
|
||
|