Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions src/renderer/components/commands-runner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';

import { Button, ButtonProps, Spinner } from '@blueprintjs/core';
import { Button, ButtonGroup, ButtonProps, Spinner } from '@blueprintjs/core';
import { Popover2 } from '@blueprintjs/popover2';
import { observer } from 'mobx-react';

import { InstallState, VersionSource } from '../../interfaces';
Expand Down Expand Up @@ -59,7 +60,9 @@ export const Runner = observer(
props.icon = <Spinner size={16} />;
} else {
props.text = 'Run';
props.onClick = window.app.runner.run;
props.onClick = () => {
window.app.runner.run({ runFromAsar: false });
};
props.icon = 'play';
}
break;
Expand All @@ -76,8 +79,35 @@ export const Runner = observer(
props.icon = <Spinner size={16} />;
}
}
const isAsarDisabled: boolean =
props.disabled || isRunning || isInstallingModules;

return <Button id="button-run" {...props} type={undefined} />;
return (
<ButtonGroup>
<Button id="button-run" {...props} type={undefined} />
<AsarButton disabled={isAsarDisabled} />
</ButtonGroup>
);
}
},
);

const AsarButton = ({ disabled }: { disabled: boolean }): JSX.Element => {
const asarButton = (
<Button
text="Run from ASAR"
icon="play"
disabled={disabled}
small={true}
onClick={() => {
window.app.runner.run({ runFromAsar: true });
}}
/>
);

return (
<Popover2 fill={true} content={asarButton} placement="bottom">
<Button icon="caret-down" style={{ minWidth: 20 }} disabled={disabled} />
</Popover2>
);
};
2 changes: 2 additions & 0 deletions src/renderer/components/commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const Commands = observer(
</ControlGroup>
<ControlGroup fill={true} vertical={false}>
<VersionChooser appState={appState} />
</ControlGroup>
<ControlGroup fill={true} vertical={false}>
<Runner appState={appState} />
</ControlGroup>
{isBisectCommandShowing && (
Expand Down
14 changes: 12 additions & 2 deletions src/renderer/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ export enum ForgeCommands {
MAKE = 'make',
}

interface runOptions {
runFromAsar: boolean;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
interface runOptions {
runFromAsar: boolean;
}
export interface RunOptions {
runFromAsar?: boolean;
}

Should start with a capital letter to match existing style, and should be exported since it's part of the public API for this file. Since these are options, runFromAsar should be optional as more options may be added in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, missed the capital letter there, thanks for catching that!
Exported it and made runFromAsar optional.


interface RunFiddleParams {
localPath: string | undefined;
isValidBuild: boolean; // If the localPath is a valid Electron build
version: string; // The user selected version
dir: string;
runFromAsar: boolean;
}

const resultString: Record<RunResult, string> = Object.freeze({
Expand Down Expand Up @@ -139,8 +144,9 @@ export class Runner {
/**
* Actually run the fiddle.
*/
public async run(): Promise<RunResult> {
public async run(runOptions?: runOptions): Promise<RunResult> {
const options = { includeDependencies: false, includeElectron: false };
const runFromAsar = runOptions?.runFromAsar ?? false;

const { appState } = this;
const currentRunnable = appState.currentElectronVersion;
Expand Down Expand Up @@ -220,6 +226,7 @@ export class Runner {
isValidBuild,
dir,
version,
runFromAsar,
});
}

Expand Down Expand Up @@ -362,12 +369,15 @@ export class Runner {
* or the user selected electron version
*/
private async runFiddle(params: RunFiddleParams): Promise<RunResult> {
const { version, dir } = params;
const { version, dir, runFromAsar } = params;
const { pushOutput, flushOutput, executionFlags } = this.appState;
const env = this.buildChildEnvVars();

// Add user-specified cli flags if any have been set.
const options = [dir, '--inspect'].concat(executionFlags);
if (runFromAsar) {
options.push('runFromAsar');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be added to StartFiddleParams, and then it will be handled automatically by the ...params in the call to window.ElectronFiddle.startFiddle below. This will also require changes in src/main/fiddle-core.ts to plumb it into the call to runner.spawn.


const cleanup = async () => {
flushOutput();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,85 +1,120 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Runner component renders InstallState.downloading 1`] = `
<Blueprint3.Button
disabled={true}
icon={
<Blueprint3.Spinner
size={16}
value={50}
/>
}
id="button-run"
text="Downloading"
/>
<Blueprint3.ButtonGroup>
<Blueprint3.Button
disabled={true}
icon={
<Blueprint3.Spinner
size={16}
value={50}
/>
}
id="button-run"
text="Downloading"
/>
<AsarButton
disabled={true}
/>
</Blueprint3.ButtonGroup>
`;

exports[`Runner component renders InstallState.installed 1`] = `
<Blueprint3.Button
disabled={false}
icon="play"
id="button-run"
onClick={[MockFunction]}
text="Run"
/>
<Blueprint3.ButtonGroup>
<Blueprint3.Button
disabled={false}
icon="play"
id="button-run"
onClick={[Function]}
text="Run"
/>
<AsarButton
disabled={false}
/>
</Blueprint3.ButtonGroup>
`;

exports[`Runner component renders InstallState.installing 1`] = `
<Blueprint3.Button
disabled={true}
icon={
<Blueprint3.Spinner
size={16}
/>
}
id="button-run"
text="Unzipping"
/>
<Blueprint3.ButtonGroup>
<Blueprint3.Button
disabled={true}
icon={
<Blueprint3.Spinner
size={16}
/>
}
id="button-run"
text="Unzipping"
/>
<AsarButton
disabled={true}
/>
</Blueprint3.ButtonGroup>
`;

exports[`Runner component renders InstallState.missing 1`] = `
<Blueprint3.Button
disabled={true}
icon={
<Blueprint3.Spinner
size={16}
/>
}
id="button-run"
text="Checking status"
/>
<Blueprint3.ButtonGroup>
<Blueprint3.Button
disabled={true}
icon={
<Blueprint3.Spinner
size={16}
/>
}
id="button-run"
text="Checking status"
/>
<AsarButton
disabled={true}
/>
</Blueprint3.ButtonGroup>
`;

exports[`Runner component renders idle 1`] = `
<Blueprint3.Button
disabled={false}
icon="play"
id="button-run"
onClick={[MockFunction]}
text="Run"
/>
<Blueprint3.ButtonGroup>
<Blueprint3.Button
disabled={false}
icon="play"
id="button-run"
onClick={[Function]}
text="Run"
/>
<AsarButton
disabled={false}
/>
</Blueprint3.ButtonGroup>
`;

exports[`Runner component renders installing modules 1`] = `
<Blueprint3.Button
disabled={false}
icon={
<Blueprint3.Spinner
size={16}
/>
}
id="button-run"
text="Installing modules"
/>
<Blueprint3.ButtonGroup>
<Blueprint3.Button
disabled={false}
icon={
<Blueprint3.Spinner
size={16}
/>
}
id="button-run"
text="Installing modules"
/>
<AsarButton
disabled={true}
/>
</Blueprint3.ButtonGroup>
`;

exports[`Runner component renders running 1`] = `
<Blueprint3.Button
active={true}
disabled={false}
icon="stop"
id="button-run"
onClick={[MockFunction]}
text="Stop"
/>
<Blueprint3.ButtonGroup>
<Blueprint3.Button
active={true}
disabled={false}
icon="stop"
id="button-run"
onClick={[MockFunction]}
text="Stop"
/>
<AsarButton
disabled={true}
/>
</Blueprint3.ButtonGroup>
`;
10 changes: 10 additions & 0 deletions tests/renderer/components/__snapshots__/commands-spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ exports[`Commands component renders when system is darwin 1`] = `
<version-chooser
appState={"default StateMock"}
/>
</Blueprint3.ControlGroup>
<Blueprint3.ControlGroup
fill={true}
vertical={false}
>
<runner
appState={"default StateMock"}
/>
Expand Down Expand Up @@ -77,6 +82,11 @@ exports[`Commands component renders when system not is darwin 1`] = `
<version-chooser
appState={"default StateMock"}
/>
</Blueprint3.ControlGroup>
<Blueprint3.ControlGroup
fill={true}
vertical={false}
>
<runner
appState={"default StateMock"}
/>
Expand Down