Skip to content

Commit

Permalink
Merge pull request #5 from ChuckJonas/windows-sfdx-cli-fixes
Browse files Browse the repository at this point in the history
Updates to sfdx cli commands to work on windows.
  • Loading branch information
veritascs authored Nov 16, 2018
2 parents 0ad8dd5 + a0d6f67 commit 38cac30
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
21 changes: 14 additions & 7 deletions app/components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export default class Home extends React.Component<{}, AppState> {

private loadLogins = () => {
this.setState({refreshing: true}, () => {
childProcess.exec('sfdx force:org:list --json', (error, stdout, stderr) => {
let cmd = 'sfdx force:org:list --json';
console.log(cmd);
childProcess.exec(cmd, (error, stdout, stderr) => {
if (error && !stderr.includes('noOrgsFound')) {
console.log(error);
return this.setState({ error: stderr })
Expand Down Expand Up @@ -98,24 +100,29 @@ export default class Home extends React.Component<{}, AppState> {
this.setState({ waitingForAuth: true }, () => {
let params = '';
if(this.state.alias){
params += ` -a '${this.state.alias}'`
params += ' -a \"' + this.state.alias + '\"'
}

if(this.state.instanceUrl){
let instanceUrl = this.state.instanceUrl.startsWith('https://') ? this.state.instanceUrl : 'https://' + this.state.instanceUrl;
params += ` -r '${instanceUrl}'`
params += ' -r ' + instanceUrl
}

let cmd = `sfdx force:auth:web:login ${params}`

let cmd = "sfdx force:auth:web:login " + params
console.log(cmd);
this.currentProcess = childProcess.exec(cmd, (error, stdout, stderr) => {

const defaults = {
shell: process.env.ComSpec
};

this.currentProcess = childProcess.exec(cmd, defaults, (error, stdout, stderr) => {
this.closeAdd();
if (error) {
console.log(error);
this.setState({waitingForAuth: false});
let stdErrors = stderr.split(os.EOL);
stdErrors = stdErrors.filter(err => !err.includes(`update available from`));
stdErrors = stdErrors.filter(err => !err.includes('update available from'));
return this.setError(stdErrors.join(os.EOL));
}

Expand Down
11 changes: 8 additions & 3 deletions app/components/LoginItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class LoginItem extends React.Component<LoginItemProps, LoginItemState> {
</Col>
<Col span={20}>
<Popover placement="top" title='Details' content={this.renderDetails()} trigger='hover'>
{this.props.login.alias ? `${this.props.login.alias} - ` : ''} {this.props.login.username}
{this.props.login.alias ? this.props.login.alias + ' - ' : ''} {this.props.login.username}
</Popover>
</Col>
<Col span={2}>
Expand All @@ -54,7 +54,9 @@ export class LoginItem extends React.Component<LoginItemProps, LoginItemState> {

private login = () => {
this.setState({ opening: true }, () => {
childProcess.exec(`sfdx force:org:open -u ${this.props.login.username}`, (error, stdout, stderr) => {
let cmd = 'sfdx force:org:open -u "' + this.props.login.username + '"';
console.log(cmd);
childProcess.exec(cmd, (error, stdout, stderr) => {
this.setState({ opening: false });
if (error) {
this.props.onError(stderr);
Expand All @@ -64,7 +66,10 @@ export class LoginItem extends React.Component<LoginItemProps, LoginItemState> {
}

private logout = () => {
childProcess.exec(`sfdx force:auth:logout -p -u '${this.props.login.username}'`, (error, stdout, stderr) => {
let cmd = 'sfdx force:auth:logout -p -u "' + this.props.login.username + '"';
console.log(cmd);

childProcess.exec(cmd, (error, stdout, stderr) => {
if (error) {
this.props.onError(stderr);
}
Expand Down

0 comments on commit 38cac30

Please sign in to comment.