-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move helpers to individual files in helper directory (#89)
- exports should be the same - helpers are broken down per section
- Loading branch information
Showing
15 changed files
with
749 additions
and
702 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const utils = require('../utils'); | ||
|
||
module.exports = { | ||
getHomeBrewInfo: () => { | ||
utils.log('trace', 'getHomeBrewInfo'); | ||
var homeBrewVersion; | ||
if (utils.isMacOS) { | ||
homeBrewVersion = Promise.all([ | ||
'Homebrew', | ||
utils.run('brew --version').then(utils.findVersion), | ||
utils.which('brew'), | ||
]); | ||
} else homeBrewVersion = Promise.all(['Homebrew', 'N/A']); | ||
return homeBrewVersion; | ||
}, | ||
|
||
getNodeInfo: () => { | ||
utils.log('trace', 'getNodeInfo'); | ||
return Promise.all([ | ||
utils.isWindows | ||
? utils.run('node -v').then(utils.findVersion) | ||
: utils | ||
.which('node') | ||
.then(nodePath => (nodePath ? utils.run(nodePath + ' -v') : Promise.resolve(''))) | ||
.then(utils.findVersion), | ||
utils.which('node').then(utils.condensePath), | ||
]).then(v => utils.determineFound('Node', v[0], v[1])); | ||
}, | ||
|
||
getnpmInfo: () => { | ||
utils.log('trace', 'getnpmInfo'); | ||
return Promise.all([utils.run('npm -v'), utils.which('npm').then(utils.condensePath)]).then(v => | ||
utils.determineFound('npm', v[0], v[1]) | ||
); | ||
}, | ||
|
||
getWatchmanInfo: () => { | ||
utils.log('trace', 'getWatchmanInfo'); | ||
return Promise.all([ | ||
utils | ||
.which('watchman') | ||
.then(watchmanPath => (watchmanPath ? utils.run(watchmanPath + ' -v') : undefined)), | ||
utils.which('watchman'), | ||
]).then(v => utils.determineFound('Watchman', v[0], v[1])); | ||
}, | ||
|
||
getYarnInfo: () => { | ||
utils.log('trace', 'getYarnInfo'); | ||
return Promise.all([utils.run('yarn -v'), utils.which('yarn').then(utils.condensePath)]).then( | ||
v => utils.determineFound('Yarn', v[0], v[1]) | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
const os = require('os'); | ||
const utils = require('../utils'); | ||
|
||
module.exports = { | ||
getChromeInfo: () => { | ||
utils.log('trace', 'getChromeInfo'); | ||
let chromeVersion; | ||
if (utils.isLinux) { | ||
chromeVersion = utils | ||
.run('google-chrome --version') | ||
.then(v => v.replace(/^.* ([^ ]*)/g, '$1')); | ||
} else if (utils.isMacOS) { | ||
chromeVersion = utils | ||
.getDarwinApplicationVersion(utils.browserBundleIdentifiers.Chrome) | ||
.then(utils.findVersion); | ||
} else { | ||
chromeVersion = Promise.resolve('N/A'); | ||
} | ||
return chromeVersion.then(v => utils.determineFound('Chrome', v, 'N/A')); | ||
}, | ||
|
||
getChromeCanaryInfo: () => { | ||
utils.log('trace', 'getChromeCanaryInfo'); | ||
const chromeCanaryVersion = utils.getDarwinApplicationVersion( | ||
utils.browserBundleIdentifiers['Chrome Canary'] | ||
); | ||
return chromeCanaryVersion.then(v => utils.determineFound('Chrome Canary', v, 'N/A')); | ||
}, | ||
|
||
getEdgeInfo: () => { | ||
utils.log('trace', 'getEdgeInfo'); | ||
let edgeVersion; | ||
if (utils.isWindows && os.release().split('.')[0] === '10') { | ||
edgeVersion = utils | ||
.run('powershell get-appxpackage Microsoft.MicrosoftEdge') | ||
.then(utils.findVersion); | ||
} else { | ||
edgeVersion = Promise.resolve('N/A'); | ||
} | ||
return edgeVersion.then(v => utils.determineFound('Edge', v, 'N/A')); | ||
}, | ||
|
||
getFirefoxInfo: () => { | ||
utils.log('trace', 'getFirefoxInfo'); | ||
let firefoxVersion; | ||
if (utils.isLinux) { | ||
firefoxVersion = utils.run('firefox --version').then(v => v.replace(/^.* ([^ ]*)/g, '$1')); | ||
} else if (utils.isMacOS) { | ||
firefoxVersion = utils.getDarwinApplicationVersion(utils.browserBundleIdentifiers.Firefox); | ||
} else { | ||
firefoxVersion = Promise.resolve('N/A'); | ||
} | ||
return firefoxVersion.then(v => utils.determineFound('Firefox', v, 'N/A')); | ||
}, | ||
|
||
getFirefoxDeveloperEditionInfo: () => { | ||
utils.log('trace', 'getFirefoxDeveloperEditionInfo'); | ||
const firefoxDeveloperEdition = utils.getDarwinApplicationVersion( | ||
utils.browserBundleIdentifiers['Firefox Developer Edition'] | ||
); | ||
return firefoxDeveloperEdition.then(v => | ||
utils.determineFound('Firefox Developer Edition', v, 'N/A') | ||
); | ||
}, | ||
|
||
getFirefoxNightlyInfo: () => { | ||
utils.log('trace', 'getFirefoxNightlyInfo'); | ||
let firefoxNightlyVersion; | ||
if (utils.isLinux) { | ||
firefoxNightlyVersion = utils | ||
.run('firefox-trunk --version') | ||
.then(v => v.replace(/^.* ([^ ]*)/g, '$1')); | ||
} else if (utils.isMacOS) { | ||
firefoxNightlyVersion = utils.getDarwinApplicationVersion( | ||
utils.browserBundleIdentifiers['Firefox Nightly'] | ||
); | ||
} else { | ||
firefoxNightlyVersion = Promise.resolve('N/A'); | ||
} | ||
|
||
return firefoxNightlyVersion.then(v => utils.determineFound('Firefox Nightly', v, 'N/A')); | ||
}, | ||
|
||
getInternetExplorerInfo: () => { | ||
utils.log('trace', 'getInternetExplorerInfo'); | ||
let explorerVersion; | ||
if (utils.isWindows) { | ||
const explorerPath = [ | ||
process.env.SYSTEMDRIVE || 'C:', | ||
'Program Files', | ||
'Internet Explorer', | ||
'iexplore.exe', | ||
].join('\\\\'); | ||
explorerVersion = utils | ||
.run(`wmic datafile where "name='${explorerPath}'" get Version`) | ||
.then(utils.findVersion); | ||
} else { | ||
explorerVersion = Promise.resolve('N/A'); | ||
} | ||
return explorerVersion.then(v => utils.determineFound('Internet Explorer', v, 'N/A')); | ||
}, | ||
|
||
getSafariTechnologyPreviewInfo: () => { | ||
utils.log('trace', 'getSafariTechnologyPreviewInfo'); | ||
const safariTechnologyPreview = utils.getDarwinApplicationVersion( | ||
utils.browserBundleIdentifiers['Safari Technology Preview'] | ||
); | ||
return safariTechnologyPreview.then(v => | ||
utils.determineFound('Safari Technology Preview', v, 'N/A') | ||
); | ||
}, | ||
|
||
getSafariInfo: () => { | ||
utils.log('trace', 'getSafariInfo'); | ||
const safariVersion = utils.getDarwinApplicationVersion(utils.browserBundleIdentifiers.Safari); | ||
return safariVersion.then(v => utils.determineFound('Safari', v, 'N/A')); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const utils = require('../utils'); | ||
|
||
module.exports = { | ||
getMongoDBInfo: () => { | ||
utils.log('trace', 'getMongoDBInfo'); | ||
return Promise.all([ | ||
utils.run('mongo --version').then(utils.findVersion), | ||
utils.which('mongo'), | ||
]).then(v => utils.determineFound('MongoDB', v[0], v[1])); | ||
}, | ||
|
||
getMySQLInfo: () => { | ||
utils.log('trace', 'getMySQLInfo'); | ||
return Promise.all([ | ||
utils | ||
.run('mysql --version') | ||
.then(v => `${utils.findVersion(v, null, 1)}${v.includes('MariaDB') ? ' (MariaDB)' : ''}`), | ||
utils.which('mysql'), | ||
]).then(v => utils.determineFound('MySQL', v[0], v[1])); | ||
}, | ||
|
||
getPostgreSQLInfo: () => { | ||
utils.log('trace', 'getPostgreSQLInfo'); | ||
return Promise.all([ | ||
utils.run('postgres --version').then(utils.findVersion), | ||
utils.which('postgres'), | ||
]).then(v => utils.determineFound('PostgreSQL', v[0], v[1])); | ||
}, | ||
|
||
getSQLiteInfo: () => { | ||
utils.log('trace', 'getSQLiteInfo'); | ||
return Promise.all([ | ||
utils.run('sqlite3 --version').then(utils.findVersion), | ||
utils.which('sqlite3'), | ||
]).then(v => utils.determineFound('SQLite', v[0], v[1])); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
const path = require('path'); | ||
const utils = require('../utils'); | ||
|
||
module.exports = { | ||
getAndroidStudioInfo: () => { | ||
let androidStudioVersion; | ||
if (utils.isMacOS) { | ||
androidStudioVersion = utils | ||
.run( | ||
utils.generatePlistBuddyCommand( | ||
path.join('/', 'Applications', 'Android\\ Studio.app', 'Contents', 'Info.plist'), | ||
['CFBundleShortVersionString', 'CFBundleVersion'] | ||
) | ||
) | ||
.then(version => version.split('\n').join(' ')); | ||
} else if (utils.isLinux) { | ||
androidStudioVersion = Promise.all([ | ||
utils | ||
.run('cat /opt/android-studio/bin/studio.sh | grep "$Home/.AndroidStudio" | head -1') | ||
.then(utils.findVersion), | ||
utils.run('cat /opt/android-studio/build.txt'), | ||
]).then(tasks => { | ||
const linuxVersion = tasks[0]; | ||
const linuxBuildNumber = tasks[1]; | ||
return `${linuxVersion} ${linuxBuildNumber}`.trim() || utils.NotFound; | ||
}); | ||
} else if (utils.isWindows) { | ||
androidStudioVersion = Promise.all([ | ||
utils | ||
.run( | ||
'wmic datafile where name="C:\\\\Program Files\\\\Android\\\\Android Studio\\\\bin\\\\studio.exe" get Version' | ||
) | ||
.then(version => version.replace(/(\r\n|\n|\r)/gm, '')), | ||
utils | ||
.run('type "C:\\\\Program Files\\\\Android\\\\Android Studio\\\\build.txt"') | ||
.then(version => version.replace(/(\r\n|\n|\r)/gm, '')), | ||
]).then(tasks => { | ||
const windowsVersion = tasks[0]; | ||
const windowsBuildNumber = tasks[1]; | ||
return `${windowsVersion} ${windowsBuildNumber}`.trim() || utils.NotFound; | ||
}); | ||
} | ||
return androidStudioVersion.then(v => utils.determineFound('Android Studio', v)); | ||
}, | ||
|
||
getAtomInfo: () => { | ||
utils.log('trace', 'getAtomInfo'); | ||
return Promise.all([ | ||
utils.getDarwinApplicationVersion(utils.ideBundleIdentifiers.Atom), | ||
'N/A', | ||
]).then(v => utils.determineFound('Atom', v[0], v[1])); | ||
}, | ||
|
||
getEmacsInfo: () => { | ||
utils.log('trace', 'getEmacsInfo'); | ||
if (utils.isMacOS || utils.isLinux) { | ||
return Promise.all([ | ||
utils.run('emacs --version').then(utils.findVersion), | ||
utils.run('which emacs'), | ||
]).then(v => utils.determineFound('Emacs', v[0], v[1])); | ||
} | ||
return Promise.resolve(['Emacs', 'N/A']); | ||
}, | ||
|
||
getIntelliJInfo: () => { | ||
utils.log('trace', 'getIntelliJInfo'); | ||
return utils | ||
.getDarwinApplicationVersion(utils.ideBundleIdentifiers.IntelliJ) | ||
.then(v => utils.determineFound('IntelliJ', v)); | ||
}, | ||
|
||
getNanoInfo: () => { | ||
utils.log('trace', 'getNanoInfo'); | ||
if (utils.isMacOS || utils.isLinux) { | ||
return Promise.all([ | ||
utils.run('nano --version').then(utils.findVersion), | ||
utils.run('which nano'), | ||
]).then(v => utils.determineFound('Nano', v[0], v[1])); | ||
} | ||
return Promise.resolve(['Nano', 'N/A']); | ||
}, | ||
|
||
getNvimInfo: () => { | ||
utils.log('trace', 'getNvimInfo'); | ||
if (utils.isMacOS || utils.isLinux) { | ||
return Promise.all([ | ||
utils.run('nvim --version').then(utils.findVersion), | ||
utils.run('which nvim'), | ||
]).then(v => utils.determineFound('Nvim', v[0], v[1])); | ||
} | ||
return Promise.resolve(['Vim', 'N/A']); | ||
}, | ||
|
||
getPhpStormInfo: () => { | ||
utils.log('trace', 'getPhpStormInfo'); | ||
return utils | ||
.getDarwinApplicationVersion(utils.ideBundleIdentifiers.PhpStorm) | ||
.then(v => utils.determineFound('PhpStorm', v)); | ||
}, | ||
|
||
getSublimeTextInfo: () => { | ||
utils.log('trace', 'getSublimeTextInfo'); | ||
return Promise.all([ | ||
utils.run('subl --version').then(version => utils.findVersion(version, /\d+/)), | ||
utils.which('subl'), | ||
]) | ||
.then(v => { | ||
if (v[0] === '' && utils.isMacOS) { | ||
utils.log('trace', 'getSublimeTextInfo using plist'); | ||
return Promise.all([ | ||
utils.getDarwinApplicationVersion(utils.ideBundleIdentifiers['Sublime Text']), | ||
'N/A', | ||
]); | ||
} | ||
return v; | ||
}) | ||
.then(v => utils.determineFound('Sublime Text', v[0], v[1])); | ||
}, | ||
|
||
getVimInfo: () => { | ||
utils.log('trace', 'getVimInfo'); | ||
if (utils.isMacOS || utils.isLinux) { | ||
return Promise.all([ | ||
utils.run('vim --version').then(utils.findVersion), | ||
utils.run('which vim'), | ||
]).then(v => utils.determineFound('Vim', v[0], v[1])); | ||
} | ||
return Promise.resolve(['Vim', 'N/A']); | ||
}, | ||
|
||
getVSCodeInfo: () => { | ||
utils.log('trace', 'getVSCodeInfo'); | ||
return Promise.all([ | ||
utils.run('code --version').then(utils.findVersion), | ||
utils.which('code'), | ||
]).then(v => utils.determineFound('VSCode', v[0], v[1])); | ||
}, | ||
|
||
getWebStormInfo: () => { | ||
utils.log('trace', 'getWebStormInfo'); | ||
return utils | ||
.getDarwinApplicationVersion(utils.ideBundleIdentifiers.WebStorm) | ||
.then(v => utils.determineFound('WebStorm', v)); | ||
}, | ||
|
||
getXcodeInfo: () => { | ||
utils.log('trace', 'getXcodeInfo'); | ||
if (utils.isMacOS) { | ||
return Promise.all([ | ||
utils | ||
.which('xcodebuild') | ||
.then(xcodePath => utils.run(xcodePath + ' -version')) | ||
.then(version => `${utils.findVersion(version)}/${version.split('Build version ')[1]}`), | ||
utils.which('xcodebuild'), | ||
]).then(v => utils.determineFound('Xcode', v[0], v[1])); | ||
} | ||
return Promise.resolve(['Xcode', 'N/A']); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const packages = require('../packages'); | ||
const utils = require('../utils'); | ||
|
||
const binaries = require('./binaries'); | ||
const browsers = require('./browsers'); | ||
const databases = require('./databases'); | ||
const ides = require('./ides'); | ||
const languages = require('./languages'); | ||
const sdks = require('./sdks'); | ||
const servers = require('./servers'); | ||
const system = require('./system'); | ||
const utilities = require('./utilities'); | ||
|
||
module.exports = Object.assign({}, utils, packages, { | ||
...binaries, | ||
...browsers, | ||
...databases, | ||
...ides, | ||
...languages, | ||
...sdks, | ||
...servers, | ||
...system, | ||
...utilities, | ||
}); |
Oops, something went wrong.