Skip to content

Commit

Permalink
Merge pull request #79 from rvpanoz/develop
Browse files Browse the repository at this point in the history
add list filters
  • Loading branch information
rvpanoz committed May 10, 2018
2 parents 0262d11 + 5116e54 commit 3fea299
Show file tree
Hide file tree
Showing 36 changed files with 1,517 additions and 2,058 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -22,7 +22,7 @@ npm desktop manager for handling npm packages. Supported platforms: OS X Windows

<div style="display:block;border-radius:5px; border: 2px solid transparent; border-image: linear-gradient(60deg, #f79533, #f37055, #ef4e7b, #a166ab, #5073b8, #1098ad, #07b39b, #6fba82); width:100%;height:100%;position:relative;">
<img align="center" width="100%" height="100%"
title="luna-icon" src="./resources/img/luna-v2.1.0-preview.png">
title="luna-icon" src="./resources/img/luna-v2.1.5.png">
</div>

## Downloads
Expand Down
20 changes: 20 additions & 0 deletions app/actions/packagesActions.js
Expand Up @@ -60,6 +60,13 @@ export function setActiveTab(tabIndex) {
}
}

export function toggleFilters(showFilters) {
return {
type: types.TOGGLE_FILTERS,
showFilters
}
}

export function toggleExpanded() {
return {
type: types.TOGGLE_EXPANDED
Expand All @@ -73,6 +80,19 @@ export function setTotal(total) {
}
}

export function addFilter(filterName) {
return {
type: types.ADD_FILTER,
filterName
}
}

export function clearFilters() {
return {
type: types.CLEAR_FILTERS
}
}

export function addCommandOption(option) {
return {
type: types.ADD_COMMAND_OPTION,
Expand Down
44 changes: 27 additions & 17 deletions app/apis/npm.js
Expand Up @@ -2,16 +2,20 @@
* NPM cli commands
**/

const { merge } = require('ramda')
const cp = require('child_process')
const Q = require('q')
const path = require('path')
const github = require('./github')
import { merge } from 'ramda'
import { fetchStats } from './github'
import cp from 'child_process'
import Q from 'q'
import path from 'path'
import mk from '../mk'

const spawn = cp.spawn

mk.logToFile = false

/** Run npm command **/
function runCommand(command, directory, callback, opts) {
console.log(`running: npm ${command.join(' ')}`)
mk.log(`RUNNING: npm ${command.join(' ')}`)

const deferred = Q.defer()
const cwd = process.cwd()
Expand Down Expand Up @@ -42,11 +46,11 @@ function runCommand(command, directory, callback, opts) {
})

npmc.on('exit', (code) => {
console.log(`Child exited with code ${code}`)
mk.log(`INFO: Child exited with code ${code}`)
})

npmc.on('close', () => {
console.log(`finished: npm ${command.join(' ')}`)
mk.log(`FINISHED: npm ${command.join(' ')}`)

const results = {
status: 'close',
Expand All @@ -59,7 +63,7 @@ function runCommand(command, directory, callback, opts) {
//github stats
if (opts && opts.fetchGithub === true) {
if (repo && repo.url) {
const getStats = github.fetchStats({
const getStats = fetchStats({
repoUrl: repo.url || null,
pkgName
})
Expand Down Expand Up @@ -93,9 +97,11 @@ exports.list = function(opts, callback) {
const { mode, directory, options } = opts
const defaults = ['--depth=0', '--long', '--json']

if (!command || !Array.isArray(command)) {
if (!callback || !typeof callback === 'function') {
return Q.reject(
new Error('shell[doCommand]:cmd must be given and must be an array')
new Error(
'npm[list] callback parameter must be given and must be a function'
)
)
}

Expand All @@ -114,7 +120,9 @@ exports.outdated = function(opts, callback) {

if (!command || !Array.isArray(command)) {
return Q.reject(
new Error('shell[doCommand]:cmd must be given and must be an array')
new Error(
'npm[outdated] cmd parameter must be given and must be an array'
)
)
}

Expand All @@ -132,7 +140,7 @@ exports.view = function(opts, callback) {
const defaults = ['--depth=0', '--json']

if (!pkgName) {
return Q.reject(new Error(`npmApi[${command}]:package name must be given`))
return Q.reject(new Error('npm[view] package name parameter must be given'))
}

let result = '',
Expand Down Expand Up @@ -166,7 +174,7 @@ exports.search = function(opts, callback) {

if (!pkgName) {
return Q.reject(
new Error(`npmApi[${command[0]}]:package name must be given`)
new Error('npm[search] package name parameter must be given')
)
}

Expand All @@ -182,7 +190,9 @@ exports.install = function(opts, callback) {
pkgOptions = opts.pkgOptions || []

if (!pkgName && !multiple) {
throw new Error('npmApi:install package name cannot be empty or undefined')
return Q.reject(
new Error('npm[install] package name parameter must be given')
)
}

function getNames() {
Expand Down Expand Up @@ -216,8 +226,8 @@ exports.uninstall = function(opts, callback) {
if (multiple && packages && Array.isArray(packages)) {
return packages
} else if (!pkgName && !multiple) {
throw new Error(
'npmApi:uninstall package name cannot be empty or undefined'
return Q.reject(
new Error('npm[uninstall] package name parameter must be given')
)
} else {
return pkgName
Expand Down
2 changes: 1 addition & 1 deletion app/common/Settings.js
Expand Up @@ -84,7 +84,7 @@ class Settings extends React.Component {
<Button onClick={this.saveSettings} color="primary">
Save
</Button>
<Button onClick={handleSettingsClose} color="accent">
<Button onClick={handleSettingsClose} color="secondary">
Close
</Button>
</DialogActions>
Expand Down

0 comments on commit 3fea299

Please sign in to comment.