Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

envinfo

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envinfo - npm Package Compare versions

Comparing version 4.0.0-beta.4 to 4.0.0-beta.5

2

package.json
{
"name": "envinfo",
"version": "4.0.0-beta.4",
"version": "4.0.0-beta.5",
"description": "Info about your dev environment for debugging purposes",

@@ -5,0 +5,0 @@ "repository": "https://github.com/tabrindle/envinfo",

#!/usr/bin/env node
var envinfo = require('./envinfo.js');
var argv = require('minimist')(process.argv.slice(2), {
boolean: ['console', 'fullTree', 'duplicates'],
});
const packageJson = require('../package.json');
const envinfo = require('./envinfo.js');
const argv = require('minimist')(process.argv.slice(2));

@@ -11,2 +10,3 @@ argv.console = true;

if (argv.help || argv._.indexOf('help') > -1) {
// eslint-disable-next-line
console.log(`

@@ -19,21 +19,25 @@ USAGE:

--system Print general system info such as OS, CPU, Memory and Shell
--browsers Get version numbers of installed web browsers
--IDEs Get version numbers of installed IDEs
--languages Get version numbers of installed languages such as Java, Python, PHP, etc
--binaries Get version numbers of node, npm, watchman, etc
--packages Get version numbers of locally installed npm packages
--globalPackages Get version numbers of globally installed npm packages
--system Print general system info such as OS, CPU, Memory and Shell
--browsers Get version numbers of installed web browsers
--SDKs Get platforms, build tools and SDKs of iOS and Android
--IDEs Get version numbers of installed IDEs
--languages Get version numbers of installed languages such as Java, Python, PHP, etc
--binaries Get version numbers of node, npm, watchman, etc
--npmPackages Get version numbers of locally installed npm packages
--npmGlobalPackages Get version numbers of globally installed npm packages
--duplicates Mark duplicate npm packages inside parentheses eg. (2.1.4)
--fullTree Traverse entire node_modules dependency tree, not just top level
--duplicates Mark duplicate npm packages inside parentheses eg. (2.1.4)
--fullTree Traverse entire node_modules dependency tree, not just top level
--markdown Print output in markdown format
--json Print output in JSON format
--console Print to console (defaults to on for CLI usage, off for programmatic usage)
--clipboard Copy output to your system clipboard
--markdown Print output in markdown format
--json Print output in JSON format
--console Print to console (defaults to on for CLI usage, off for programmatic usage)
--clipboard Copy output to your system clipboard
`);
process.exit(0);
} else if (argv.version || argv.v || argv._.indexOf('version') > -1) {
console.log(packageJson.version);
process.exit(0);
}
envinfo.envinfo(argv);
envinfo.cli(argv);

@@ -9,53 +9,52 @@ #!/usr/bin/env node

const formatters = require('./formatters');
const packages = require('./packages');
const arrayincludes = require('array-includes');
const objectentries = require('object.entries');
const objectvalues = require('object.values');
const arrayIncludes = require('array-includes');
const objectEntries = require('object.entries');
const objectValues = require('object.values');
if (!Object.entries) objectentries.shim();
if (!Object.values) objectvalues.shim();
if (!Array.prototype.includes) arrayincludes.shim();
if (!Array.prototype.includes) arrayIncludes.shim();
if (!Object.entries) objectEntries.shim();
if (!Object.values) objectValues.shim();
module.exports.helpers = helpers;
module.exports.envinfo = function print(options) {
const props = {
System: ['OS', 'CPU', 'Free Memory', 'Total Memory', 'Shell'],
Binaries: ['Node', 'Yarn', 'npm', 'Watchman', 'Docker', 'Homebrew'],
SDKs: ['Android'],
IDEs: ['Android Studio', 'Atom', 'VSCode', 'Sublime Text', 'Xcode'],
Languages: ['Bash', 'Go', 'PHP', 'Python', 'Ruby'],
Browsers: [
'Chrome',
'Chrome Canary',
'Firefox',
'Firefox Developer Edition',
'Firefox Nightly',
'Safari',
'Safari Technology Preview',
],
};
const info = Object.entries(props).reduce((acc, prop) => {
const key = prop[0];
// a map of all the capabilities of envinfo - used as a default input
const capabilities = {
System: ['OS', 'CPU', 'Free Memory', 'Total Memory', 'Shell'],
Binaries: ['Node', 'Yarn', 'npm', 'Watchman', 'Docker', 'Homebrew'],
SDKs: ['iOS', 'Android'],
IDEs: ['Android Studio', 'Atom', 'VSCode', 'Sublime Text', 'Xcode'],
Languages: ['Bash', 'Go', 'PHP', 'Python', 'Ruby'],
Browsers: [
'Chrome',
'Chrome Canary',
'Firefox',
'Firefox Developer Edition',
'Firefox Nightly',
'Safari',
'Safari Technology Preview',
],
npmPackages: true,
npmGlobalPackages: true,
};
function main(props, options) {
// set props to passed in props or default all capabilites
const defaults = Object.keys(props).length > 0 ? props : capabilities;
// get data by iterating and calling helper functions
const data = Object.entries(defaults).reduce((acc, prop) => {
const category = prop[0];
const value = prop[1];
const category = {
[key]: value.reduce((cat, name) => {
const fn = helperMap[name.toLowerCase().replace(/\s/g, '_')];
return Object.assign(cat, {
[name]: fn ? fn() : 'Unknown',
});
}, {}),
};
return Object.assign(acc, category);
// create an object of all the resolved helper values
return Object.assign(acc, {
[category]: helperMap[category]
? helperMap[category](value, options) // if there is a category level helper
: value.reduce((cat, name) => {
const fn = helperMap[name.toLowerCase().replace(/\s/g, '_')];
return Object.assign(cat, {
[name]: fn ? fn() : 'Unknown',
});
}, {}),
});
}, {});
const npmPackages = options.packages
? {
Packages: packages.getPackageInfo(options.packages, options),
}
: {};
const npmGlobals = options.globalPackages
? {
'Global Packages': packages.getNpmGlobalPackages(),
}
: {};
const data = Object.assign(info, npmPackages, npmGlobals);
// set the default formatter (yaml is default, similar to old table)
const formatter = (() => {

@@ -66,8 +65,43 @@ if (options.json) return formatters.json;

})();
// call the formatter with console option off first to return, or pipe to clipboard
const formatted = formatter(data, { console: false });
if (options.console) console.log(formatter(data, { console: true })); // eslint-disable-line no-console
if (options.clipboard) copypasta.writeSync(formatted);
if (options.console) console.log(formatter(data, { console: true })); // eslint-disable-line no-console
return formatted;
}
// $ envinfo --system --npmPackages
function cli(options) {
// generic function to make sure passed option exists in capability list
// TODO: This will eventually be replaced with a better fuzzy finder.
const matches = (list, opt) => list.toLowerCase().includes(opt.toLowerCase());
// check cli options to see if any args are top level categories
const categories = Object.keys(options).filter(o =>
Object.keys(capabilities).some(c => matches(c, o))
);
// build the props object for filtering capabilities
const props = Object.entries(capabilities).reduce((acc, entry) => {
if (categories.some(c => matches(c, entry[0]))) {
return Object.assign(acc, { [entry[0]]: entry[1] || options[entry[0]] });
}
return acc;
}, {});
// call the main function with the filtered props, and cli options
main(props, options);
}
// require('envinfo);
// envinfo.run({ system: [os, cpu], fullTree: true })
function run(options) {
main(options.props, options);
}
module.exports = {
cli: cli,
helpers: helpers,
main: main,
run: run,
};

@@ -56,2 +56,21 @@ var childProcess = require('child_process');

function getAlliOSSDKs() {
var iOSSDKVersions;
if (process.platform === 'darwin') {
try {
var output = utils.run('xcodebuild -showsdks');
iOSSDKVersions = output.match(/[\w]+\s[\d|.]+/g);
} catch (e) {
iOSSDKVersions = 'Unknown';
}
} else {
return 'N/A';
}
return {
Platforms: utils.uniq(iOSSDKVersions),
};
}
function getAllAndroidSDKs() {

@@ -425,2 +444,3 @@ var buildTools = [];

getAllAndroidSDKs: getAllAndroidSDKs,
getAlliOSSDKs: getAlliOSSDKs,
getAndroidStudioVersion: getAndroidStudioVersion,

@@ -427,0 +447,0 @@ getAtomVersion: getAtomVersion,

@@ -1,2 +0,3 @@

var helpers = require('./helpers');
const helpers = require('./helpers');
const packages = require('./packages');
// var fuse = require('fuse.js');

@@ -19,2 +20,3 @@

android: helpers.getAllAndroidSDKs,
ios: helpers.getAlliOSSDKs,
// browsers

@@ -47,2 +49,5 @@ chrome_canary: () =>

ruby: helpers.getRubyVersion,
// npm
npmPackages: packages.getPackageInfo,
npmGlobalPackages: packages.getNpmGlobalPackages,
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc