Skip to content

Commit

Permalink
Merge pull request #483 from rvpanoz/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rvpanoz authored Oct 4, 2020
2 parents 40c55b2 + 15d9da6 commit 5912484
Show file tree
Hide file tree
Showing 23 changed files with 205 additions and 139 deletions.
21 changes: 0 additions & 21 deletions SECURITY.md

This file was deleted.

8 changes: 3 additions & 5 deletions app/cli/manager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cp from 'child_process';
import cp, { exec } from 'child_process';
import path from 'path';
import chalk from 'chalk';
import { Observable } from 'rxjs';
Expand Down Expand Up @@ -52,12 +52,10 @@ const execute = ({
});

try {
// on windows use npm.cmd
const command = spawn(
/^win/.test(process.platform) ? `${manager}.cmd` : manager,
commandArgs,
{
shell: true,
env: process.env,
cwd: isLocal
? operation === 'init'
Expand Down Expand Up @@ -107,10 +105,10 @@ const execute = ({
observer.next({
status: 'close',
errors,
data: result.join(''),
initDirectory,
cmd: commandArgs,
packageJson: Boolean(packageJson),
initDirectory,
data: result.join(' '),
});

observer.complete();
Expand Down
4 changes: 3 additions & 1 deletion app/cli/shell.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import log from 'electron-log';
import fs from 'fs';
import path from 'path';
import { concat } from 'rxjs';
import { catchError } from 'rxjs/operators';
import manager from './manager';
Expand All @@ -18,7 +20,7 @@ const runCommand = (options, callback) => {
const runner = manager[command];
const result$ = runner(rest, idx);

return result$.pipe(catchError((error) => log.error(error)));
return result$.pipe(catchError(log.error));
});

// subscribe to observables in order as previous completes
Expand Down
11 changes: 2 additions & 9 deletions app/commons/hocs/withErrorBoundary.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/* eslint-disable object-shorthand */
/* eslint-disable react/state-in-constructor */

import React from 'react';
import { Component, createFactory } from 'react';
import { Component } from 'react';

const withErrorBoundary = (BaseComponent) => {
const factory = createFactory(BaseComponent);

return class ErrorBoundary extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -37,9 +32,7 @@ const withErrorBoundary = (BaseComponent) => {
);
}

return factory({
...props,
});
return <BaseComponent {...props} />;
}
};
};
Expand Down
16 changes: 1 addition & 15 deletions app/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,6 @@ const App = () => {
useEffect(() => {
ipcRenderer.once('finish-loaded', () => dispatch(initActions()));

ipcRenderer.on('npm-env-close', (event, error, env) => {
dispatch({ type: setEnv.type, payload: env });
});

ipcRenderer.on('npm-command-flow', (event, message) => {
dispatch(
setSnackbar({
open: true,
type: 'primary',
message,
})
);
});

ipcRenderer.on('yarn-lock-detected', () => {
dispatch(
setSnackbar({
Expand Down Expand Up @@ -85,7 +71,7 @@ const App = () => {
return (
<MuiThemeProvider theme={theme}>
<CssBaseline />
{!uiException ? <Layout app="Luna" /> : uiException}
{!uiException ? <Layout app="Luna" /> : <div>{uiException?.message}</div>}
</MuiThemeProvider>
);
};
Expand Down
34 changes: 29 additions & 5 deletions app/components/packages/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ export const InstallAction = ({ handler }) => {
message: iMessage('confirmation', 'installSelected'),
buttons: ['Cancel', 'Install'],
};
const dialogHandler = () => handler('install');
const dialogHandler = ({ response }) => {
if (response === 0) {
return;
}

handler('install');
};
const onClickHandler = () => showDialog(dialogHandler, dialogOptions);

return (
Expand Down Expand Up @@ -145,7 +151,13 @@ export const LatestAction = ({ handler }) => {
buttons: ['Cancel', 'Install'],
};

const dialogHandler = () => handler('install', true, true);
const dialogHandler = ({ response }) => {
if (response === 0) {
return;
}

handler('install', true, true);
};
const onClickHandler = () => showDialog(dialogHandler, dialogOptions);

return (
Expand Down Expand Up @@ -175,7 +187,13 @@ export const UpdateAction = ({ handler }) => {
buttons: ['Cancel', 'Update'],
};

const dialogHandler = () => handler('update');
const dialogHandler = ({ response }) => {
if (response === 0) {
return;
}

handler('update');
};
const onClickHandler = () => showDialog(dialogHandler, dialogOptions);

return (
Expand All @@ -198,7 +216,7 @@ UpdateAction.propTypes = {
};

export const UninstallAction = ({ handler, options }) => {
const { selected } = options;
const { selected } = options || [];
const hasNpmSelected = selected && selected.indexOf('npm') > -1;

const dialogOptions = {
Expand All @@ -208,7 +226,13 @@ export const UninstallAction = ({ handler, options }) => {
buttons: ['Cancel', 'Uninstall'],
};

const dialogHandler = () => handler('uninstall');
const dialogHandler = ({ response }) => {
if (response === 0) {
return;
}

handler('uninstall');
};
const onClickHandler = () => showDialog(dialogHandler, dialogOptions);

// avoid npm uninstallation :)
Expand Down
15 changes: 11 additions & 4 deletions app/components/packages/PackageDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const PackageDetails = ({ classes, toggleOptions }) => {
});
}

return dispatch(
dispatch(
installPackage({
ipcEvent: 'npm-install',
cmd: ['install'],
Expand All @@ -112,7 +112,7 @@ const PackageDetails = ({ classes, toggleOptions }) => {
);
};

const handleUpdate = () =>
const handleUpdate = () => {
dispatch(
updatePackages({
ipcEvent: 'npm-update',
Expand All @@ -121,8 +121,9 @@ const PackageDetails = ({ classes, toggleOptions }) => {
packages: [active.name],
})
);
};

const handleUninstall = () =>
const handleUninstall = () => {
dispatch(
uninstallPackages({
ipcEvent: 'npm-uninstall',
Expand All @@ -131,6 +132,7 @@ const PackageDetails = ({ classes, toggleOptions }) => {
packages: [active.name],
})
);
};

const handleInstallVersion = (packageVersion) => {
if (fromSearch && mode === 'local') {
Expand Down Expand Up @@ -158,7 +160,11 @@ const PackageDetails = ({ classes, toggleOptions }) => {
optionalDependencies: () => ['save-optional'],
})('')(group);

const dialogHandler = () =>
const dialogHandler = ({ response }) => {
if (response === 0) {
return;
}

dispatch(
installPackage({
cmd: ['install'],
Expand All @@ -168,6 +174,7 @@ const PackageDetails = ({ classes, toggleOptions }) => {
single: true,
})
);
};

return showDialog(dialogHandler, dialogOptions);
};
Expand Down
1 change: 1 addition & 0 deletions app/components/popups/Init.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Init = ({ classes, enableInit }) => {
...initOptions,
directory: filePath[0],
});

enableInit(filePath[0]);
}
};
Expand Down
21 changes: 18 additions & 3 deletions app/components/sidebar/SidebarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ const AppSidebar = ({ classes, className }) => {
buttons: ['Cancel', 'Install'],
};

const dialogHandler = () =>
const dialogHandler = ({ response }) => {
if (response === 0) {
return;
}

dispatch(
installPackageJson({
ipcEvent: 'install',
Expand All @@ -115,6 +119,7 @@ const AppSidebar = ({ classes, className }) => {
directory: shrinkedDirectory,
})
);
};

return showDialog(dialogHandler, dialogOptions);
}, [mode, directory, dispatch]);
Expand All @@ -129,13 +134,18 @@ const AppSidebar = ({ classes, className }) => {
buttons: ['Cancel', 'Run'],
};

const dialogHandler = () =>
const dialogHandler = ({ response }) => {
if (response === 0) {
return;
}

dispatch(
runDedupe({
ipcEvent: 'dedupe',
cmd: ['dedupe'],
})
);
};

return showDialog(dialogHandler, dialogOptions);
}, [dispatch]);
Expand All @@ -150,7 +160,11 @@ const AppSidebar = ({ classes, className }) => {
buttons: ['Cancel', 'Run'],
};

const dialogHandler = () =>
const dialogHandler = ({ response }) => {
if (response === 0) {
return;
}

dispatch(
runCache({
ipcEvent: 'cache',
Expand All @@ -160,6 +174,7 @@ const AppSidebar = ({ classes, className }) => {
},
})
);
};

return showDialog(dialogHandler, dialogOptions);
}, [dispatch]);
Expand Down
4 changes: 4 additions & 0 deletions app/components/topbar/TopBarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const AppTopBar = ({ classes, className }) => {
};

const dialogHandler = ({ filePaths }) => {
if (!filePaths.length) {
return;
}

dispatch(
setActivePage({
page: 'packages',
Expand Down
4 changes: 2 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ ReactDom.render(

if (module.hot) {
module.hot.accept('./components/App', () => {
const NextApp = require('./components/App').default;
const Root = require('./components/App').default;

ReactDom.render(
<StoreContext.Provider value={store}>
<NextApp />
<Root />
</StoreContext.Provider>,
document.getElementById('app')
);
Expand Down
Loading

0 comments on commit 5912484

Please sign in to comment.