Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
mfix22 committed Feb 28, 2017
2 parents 86cd5f4 + cc51f4c commit ecf5ed0
Show file tree
Hide file tree
Showing 27 changed files with 831 additions and 276 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"no-multi-spaces": ["error", { "exceptions": { "VariableDeclarator": true } }],
"curly": 0,
"no-nested-ternary": 0,
"no-unused-vars": 1,
"no-unused-vars": 2,
"no-shadow": 0,
}
}
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js
node_js:
- '6'
before_deploy:
- 'npm run build'
- 'npm run package'
- 'npm run zip'
deploy:
provider: releases
api_key:
secure: V+pC1E/0CnhPcXr/BF4S3mVFzEQe7OInc6h8rpw9eXS5GrV2x3ehaUrsZCu+SEU5m8l8R95Lq6b2FScSHIj0NyWfpKf2J/a/TwQnvpOeZ0QDFVe6sUHDv8BGH+aQmyfH6Wd/M+t90gkDrFx0W+skm5t91ohkjJLlUF3afvxw2XpGO12//LS7dfCxffpWZcdV4DHN8AGJ0Kxu7wKBJIzeTIhdcJhmLmHo70PlDF0tJOXb6kFyHmD59vv0RjKBLTH10JQ9uaVjRc9+wuqTGEm6kgLTHfx3TWgSDQxn6bOiTnwdHZkSqeTRzdWilNVeX2fW0gq732L+wOYwx2krmJfl7m7XOi3YDutoVeHiBQt0FwFwsEWBQb3lDK/7xazYvob56wR2BFNIDcTsKIPewgIO0WEi/6Sz+XReBwn3EnPBKT4O6YOownBpMy9vzCVv5i/NQdhQs+qIlTOrpt42KxVOPLZ4VpqFR82PxSV9lmJK0db+d/CxLcT98n1WQsYO86p5enD1O6CvTw2fgG7tm4DPeKuOeTzX93T6BDx74JvrmvPq0phUa+dVJ/uCI4Dv+4gqKb1F22hJ/e7KssDs4XQmDpw7J3IMZySwmOq9hNBMETZrO9hIbuKZjTynw1LHK5Sbj0vh6+A4ZhG5hHIhYM0uNN2eO5kqKIqSzLs9t0gj9gw=
file: ./packaged/Alchemy.zip
skip_cleanup: true
on:
tags: true
3 changes: 3 additions & 0 deletions img/arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions img/cancel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions img/convert.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions img/merge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const menubar = require('menubar')

const { installImageMagick } = require('./src/api')
const configure = require('./src/helpers/configure')
const { installImageMagick } = require('./src/api')

const mb = menubar({
alwaysOnTop: true,
Expand All @@ -16,4 +16,6 @@ const { app } = mb
mb.on('ready', () => {
console.log('App started in menu bar.')
configure(mb)

installImageMagick().then(console.log).catch(console.log)
})
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"main": "main.js",
"scripts": {
"start": "electron .",
"test": "jest",
"build": "webpack",
"distribute": "cp -r * /usr/local/lib/node_modules/electron/dist/Electron.app/Contents/Resources/app",
"package": "electron-packager . --platform=darwin --arch=x64 --out=packaged --icon=img/out.icns --overwrite",
"zip": "cd packaged/Alchemy-darwin-x64/ ; zip -r ../Alchemy.zip * ; cd .."
},
Expand All @@ -14,6 +14,7 @@
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"chai": "^3.5.0",
"css-loader": "^0.26.1",
"electron-packager": "^8.5.0",
"eslint": "^3.13.1",
Expand All @@ -22,6 +23,7 @@
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0",
"extract-text-webpack-plugin": "^1.0.1",
"jest": "^19.0.2",
"node-sass": "^4.3.0",
"sass-loader": "^4.1.1",
"style-loader": "^0.13.1",
Expand All @@ -37,21 +39,21 @@
"react": "^15.4.2",
"react-dnd": "^2.1.4",
"react-dnd-html5-backend": "^2.1.2",
"react-dom": "^15.4.2",
"shelljs": "^0.7.6"
"react-dom": "^15.4.2"
},
"name": "alchemy",
"description": "**Clone and run for a quick way to see Electron in action.**",
"description": "Alchemy is a drag-and-drop file converter for your menubar.",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "no"
"url": "https://github.com/dawnlabs/alchemy.git"
},
"author": "Michael Fix",
"license": "MIT",
"keywords": [
"convert",
"files",
"images"
"images",
"drag-and-drop"
]
}
58 changes: 26 additions & 32 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
const { exec, which } = require('shelljs')
const md5 = require('md5')
const execS = require('child_process').exec
const { replaceSpaceCharacters, createOutputFileName } = require('./helpers/util')

const { replaceSpaceCharacters } = require('./helpers/util')

const convert = ({ files, outputPath, name }) => {
const convert = ({ files, outputPath, outputType, name }) => {
// eslint-disable-next-line dot-notation
process.env['PATH'] = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'

return new Promise((resolve, reject) => {
execS('which convert', (error, stdout, stderr) => {
execS('which convert', (error) => {
if (error) reject(error)
else {
const fileString = files.map(replaceSpaceCharacters).join(' ')
const outputName = name || `ALCHEMY-${md5(fileString).substr(0, 6)}.pdf`
const command = `convert ${fileString} ${outputPath}${outputName}`
console.log(command)

execS(command, (error) => {
if (error) reject(error)
else resolve(outputName)
})
}
const outputName = name || createOutputFileName(outputType)(files)
const command = [
'convert',
...files.map(replaceSpaceCharacters), // input files
outputPath + outputName
].join(' ')

console.log(command)

return execS(command, err => (err ? reject(err) : resolve(outputName)))
})
})
}

const checkForBrew = () => !!which('brew')
const checkForImageMagick = () => !!which('convert')
const installImageMagick = () => {
if (!checkForBrew()) return Promise.resolve(-1)

if (!checkForImageMagick()) {
if (confirm('ImageMagick is required to run this app. Install now?')) {
return new Promise((resolve) => {
exec('brew install imagemagick', (code) => {
resolve(code)
})
return new Promise((resolve, reject) => {
execS('which brew', (error) => {
if (error) return reject(new Error('Brew is required to run Alchemy. Please visit https://brew.sh/ to install.'))
return execS('which convert', (error) => {
if (error) {
return execS('brew install imagemagick', (error) => {
return error ? reject(error) : resolve('ImageMagick is installed.')
})
}
return resolve('ImageMagick already installed.')
})
}
}

return Promise.resolve(0)
})
})
}

module.exports = {
convert,
checkForBrew,
checkForImageMagick,
installImageMagick
}
Loading

0 comments on commit ecf5ed0

Please sign in to comment.