@webpack-cli/info
Advanced tools
Comparing version 0.1.6 to 0.2.0
"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 |
128
index.js
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22884
17
262
91
6
2
1
+ Added@types/yargs@13.0.0
+ Addedchalk@2.4.2
+ Addedcli-table3@0.5.1
+ Addedprettyjson@1.2.1
+ Addedyargs@13.2.2
+ Added@types/yargs@13.0.0(transitive)
+ Added@types/yargs-parser@21.0.3(transitive)
+ Addedansi-regex@2.1.13.0.14.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcli-table3@0.5.1(transitive)
+ Addedcliui@4.1.0(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcolors@1.4.0(transitive)
+ Addedcross-spawn@6.0.5(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedemoji-regex@7.0.3(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedenvinfo@7.3.1(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexeca@1.0.0(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedget-stream@4.1.0(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedinvert-kv@2.0.0(transitive)
+ Addedis-fullwidth-code-point@1.0.02.0.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlcid@2.0.0(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedmap-age-cleaner@0.1.3(transitive)
+ Addedmem@4.3.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedos-locale@3.1.0(transitive)
+ Addedp-defer@1.0.0(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedp-is-promise@2.1.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedprettyjson@1.2.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@1.0.22.1.13.1.0(transitive)
+ Addedstrip-ansi@3.0.14.0.05.2.0(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@2.1.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyargs@13.2.2(transitive)
+ Addedyargs-parser@13.1.2(transitive)
- Removedenvinfo@5.12.1(transitive)
Updatedenvinfo@7.3.1