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

@webpack-cli/info

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webpack-cli/info - npm Package Compare versions

Comparing version 0.1.6 to 0.2.0

__tests__/index.test.js

23

commands.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AVAILABLE_COMMANDS = [
"binaries",
"system",
"browsers",
"npmGlobalPackages",
"npmPackages",
"bin",
"sys",
"npmg",
"npm"
"binaries",
"system",
"browsers",
"npmGlobalPackages",
"npmPackages",
"npmg",
"npm",
"b",
"s"
];
exports.AVAILABLE_FORMATS = ["json", "markdown"];
exports.IGNORE_FLAGS = ["_", "$0"];
exports.AVAILABLE_FORMATS = ["output-json", "output-markdown"];
exports.IGNORE_FLAGS = ["_", "$0", "outputMarkdown", "outputJson", "npm-packages"];
//# sourceMappingURL=commands.js.map
"use strict";
var __awaiter =
(this && this.__awaiter) ||
function(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done
? resolve(result.value)
: new P(function(resolve) {
resolve(result.value);
}).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = require("chalk");
const envinfo = require("envinfo");
const process = require("process");
// eslint-disable-next-line
function information() {
return {
Binaries: ["Node", "Yarn", "npm"],
Browsers: ["Chrome", "Firefox", "Safari"],
System: ["OS", "CPU"],
npmGlobalPackages: ["webpack", "webpack-cli"],
npmPackages: "*webpack*"
};
const options_1 = require("./options");
const commands_1 = require("./commands");
const configParser_1 = require("./configParser");
const renderTable_1 = require("./renderTable");
const CONFIG = {};
const DEFAULT_DETAILS = {
Binaries: ['Node', 'Yarn', 'npm'],
Browsers: ['Chrome', 'Firefox', 'Safari'],
System: ['OS', 'CPU', 'Memory'],
npmGlobalPackages: ['webpack', 'webpack-cli'],
npmPackages: '*webpack*',
};
let DETAILS_OBJ = {};
function informationType(type) {
switch (type) {
case 'system':
return { System: ['OS', 'CPU', 'Memory'] };
case 'binaries':
return { Binaries: ['Node', 'Yarn', 'npm'] };
case 'browsers':
return { Browsers: ['Chrome', 'Firefox', 'Safari'] };
case 'npmg':
return { npmGlobalPackages: ['webpack', 'webpack-cli'] };
case 'npmPackages':
return { npmPackages: '*webpack*' };
}
}
exports.information = information;
function info() {
return __awaiter(this, void 0, void 0, function*() {
process.stdout.write(yield envinfo.run(information()));
});
exports.informationType = informationType;
function info(CustomArgv) {
return __awaiter(this, void 0, void 0, function* () {
const CUSTOM_AGRUMENTS = Object.entries(CustomArgv).length !== 0 && CustomArgv.constructor === Object;
const args = CUSTOM_AGRUMENTS ? CustomArgv : options_1.argv;
const configRelativePath = options_1.argv._[1] ? options_1.argv._[1] : args.config;
console.log(configRelativePath);
if (configRelativePath) {
const fullConfigPath = configParser_1.resolveFilePath(configRelativePath);
const fileName = configParser_1.getNameFromPath(fullConfigPath);
const config = configParser_1.fetchConfig(fullConfigPath);
const parsedConfig = configParser_1.configReader(config);
const stringifiedTable = renderTable_1.renderTable(parsedConfig, fileName);
if (args.config)
return parsedConfig;
else
process.stdout.write(stringifiedTable + '\n');
}
else {
Object.keys(args).forEach((flag) => {
if (commands_1.IGNORE_FLAGS.includes(flag)) {
return;
}
else if (commands_1.AVAILABLE_COMMANDS.includes(flag)) {
const flagVal = informationType(flag);
DETAILS_OBJ = Object.assign(Object.assign({}, DETAILS_OBJ), flagVal);
}
else if (commands_1.AVAILABLE_FORMATS.includes(flag)) {
switch (flag) {
case 'output-json':
CONFIG['json'] = true;
break;
case 'output-markdown':
CONFIG['markdown'] = true;
break;
}
}
else {
// Invalid option
process.stdout.write('\n' + chalk_1.default.bgRed(flag) + chalk_1.default.red(' is an invalid option' + '\n'));
return;
}
});
const OUTPUT = yield envinfo.run(Object.keys(DETAILS_OBJ).length ? DETAILS_OBJ : DEFAULT_DETAILS, CONFIG);
!CUSTOM_AGRUMENTS ? process.stdout.write(OUTPUT + '\n') : null;
return OUTPUT;
}
process.exit(0);
});
}
exports.default = info;
//# sourceMappingURL=index.js.map

@@ -5,44 +5,40 @@ "use strict";

exports.argv = yargs
.option("system", {
alias: "sys",
demandOption: false,
describe: "System information (OS, CPU)",
type: "boolean"
})
.option("binaries", {
alias: "bin",
demandOption: false,
describe: "Installed binaries",
type: "boolean"
})
.option("browsers", {
demandOption: false,
describe: "Installed web browsers",
type: "boolean"
})
.option("npmg", {
demandOption: false,
describe: "Globally installed NPM packages (webpack & webpack-cli only)",
type: "boolean"
})
.option("npmPackages", {
demandOption: false,
describe: "Info about webpack installed in the project",
type: "boolean"
})
.option("json", {
demandOption: false,
describe: "To get the output as JSON",
type: "boolean"
})
.option("json", {
demandOption: false,
describe: "To get the output as JSON",
type: "boolean"
})
.option("markdown", {
demandOption: false,
describe: "To get the output as markdown",
type: "boolean"
})
.group(["json", "markdown"], `Output format`).argv;
.option("system", {
alias: "s",
demandOption: false,
describe: "System information (OS, CPU)",
type: "boolean"
})
.option("binaries", {
alias: "b",
demandOption: false,
describe: "Installed binaries (Node, yarn, npm)",
type: "boolean"
})
.option("browsers", {
demandOption: false,
describe: "Installed web browsers",
type: "boolean"
})
.option("npmg", {
demandOption: false,
describe: "Globally installed NPM packages (webpack & webpack-cli only)",
type: "boolean"
})
.option("npmPackages", {
demandOption: false,
describe: "Info about packages related to webpack installed in the project",
type: "boolean"
})
.option("output-json", {
demandOption: false,
describe: "To get the output as JSON",
type: "boolean"
})
.option("output-markdown", {
demandOption: false,
describe: "To get the output as markdown",
type: "boolean"
})
.group(["output-json", "output-markdown"], `Output format`).argv;
//# sourceMappingURL=options.js.map
{
"name": "@webpack-cli/info",
"version": "0.1.6",
"description": "Outputs env info for the ease of debug",
"version": "0.2.0",
"description": "Outputs info about system and webpack config",
"main": "index.js",

@@ -12,7 +12,12 @@ "author": "",

"dependencies": {
"envinfo": "^5.12.1"
"@types/yargs": "13.0.0",
"chalk": "2.4.2",
"cli-table3": "0.5.1",
"envinfo": "7.3.1",
"prettyjson": "1.2.1",
"yargs": "13.2.2"
},
"devDependencies": {
"@types/node": "^10.5.1",
"typescript": "^3.1.6"
"@types/node": "12.7.2",
"typescript": "3.5.3"
},

@@ -23,3 +28,3 @@ "scripts": {

},
"gitHead": "ace0d4a9d06b56652a99577a4ec96f9f706cf877"
"gitHead": "8097c5cf0fb6d2fa533168b4d97fbb373fa806ce"
}

@@ -12,3 +12,11 @@ # webpack-cli info

```bash
#npm
npm i -D @webpack-cli/info
#yarn
yarn add @webpack-cli/info -D
#npx
npx webpack info [options]
```

@@ -18,13 +26,64 @@

### Args / Flags
#### Output format
| Flag | Description | Type |
| ------------------- | ----------------------------- | ----------- |
| `--output-json` | To get the output as JSON | [ boolean ] |
| `--output-markdown` | To get the output as markdown | [ boolean ] |
_Not supported for config_
#### Options
| Flag | Description | Type |
| ------------------- | --------------------------------------------------------------- | ----------- |
| `--help` | Show help | [ boolean ] |
| `--version` | Show version number of `webpack-cli` | [ boolean ] |
| `--system` , `-s` | System information ( OS, CPU ) | [ boolean ] |
| `--binaries` , `-b` | Installed binaries (Node, yarn, npm) | [ boolean ] |
| `--browsers` | Installed web browsers | [ boolean ] |
| `--npmg` | Globally installed NPM packages ( webpack & webpack-cli only ) | [ boolean ] |
| `--npmPackages` | Info about packages related to webpack installed in the project | [ boolean ] |
### Node
```js
const envinfo = require("@webpack-cli/info").default;
envinfo();
const info = require('@webpack-cli/info').default;
async function wrapperFunc() {
await info({
/* Custom Config */
});
}
wrapperFunc();
```
#### Custom config
> Config has higher precedence than system flags
```json
// Config's relative path
{
"config": [string]
}
// System info
{
"binaries": [boolean],
"system": [boolean],
"browsers": [boolean],
"npmg": [boolean],
"npmPackages": [boolean],
}
```
The function returns `string` for `system` info, and returns an array of strings (`string[]`) for `config`
### CLI (via `webpack-cli`)
```bash
npx webpack-cli info
webpack-cli info --FLAGS #Flags are optional for custom output
```

@@ -31,0 +90,0 @@

Sorry, the diff of this file is not supported yet

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