Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(info): adding more functionality to info package #833

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
242c613
feat(info): adding more functionality and improves performance
pranshuchittora Apr 16, 2019
d52396b
feat(info): adds the list of supported flags
pranshuchittora Apr 18, 2019
754ad92
chore(depen): updates the package-lock of info package
pranshuchittora Apr 18, 2019
2f31b5b
feat(info): adds different command types and options
pranshuchittora Apr 20, 2019
2badfd1
chore(info): fixes the linting
pranshuchittora Apr 20, 2019
227f584
feat(info): error for invalid flags
pranshuchittora Apr 21, 2019
dd8b9f1
feat(info): adds aliases and default
pranshuchittora Apr 21, 2019
89b6aa3
feat(info): adds tests for the revamped info pkg
pranshuchittora Apr 27, 2019
b4bd57e
feat(info): removes junit.xml
pranshuchittora Apr 28, 2019
37e4bc0
Merge branch 'master' into info
pranshuchittora Apr 28, 2019
385a66f
Merge branch 'master' of github.com:webpack/webpack-cli into info
pranshuchittora May 2, 2019
f4ce1e9
Merge branch 'master' of github.com:webpack/webpack-cli into info
pranshuchittora May 30, 2019
2695ac8
feat(info): seperates func calls from the stdout
pranshuchittora May 30, 2019
721bd36
chore(plock): updates the package-lock.json
pranshuchittora May 30, 2019
696fda8
Merge branch 'master' of github.com:webpack/webpack-cli into info
pranshuchittora Jun 2, 2019
155a5ed
feat(info): adds support custom args when imported as module
pranshuchittora Jun 2, 2019
4d0b9de
docs(info): updates readme for the new info package
pranshuchittora Jun 2, 2019
c525a79
chore(info): fixes codacy pr issues
pranshuchittora Jun 2, 2019
3e142a4
feat(info): merges master and implements the interface
pranshuchittora Jun 6, 2019
064750a
chore(info): auto prettify
pranshuchittora Jun 6, 2019
cb5e84d
feat(info): adds support for config parsing
pranshuchittora Jun 10, 2019
55ca613
feat(info): parses config fron given argv path
pranshuchittora Jun 10, 2019
f1f0fb1
Merge branch 'master' of github.com:webpack/webpack-cli into info
pranshuchittora Jun 10, 2019
a1301be
chore(deps): removes unwanted deps and updates lock file
pranshuchittora Jun 10, 2019
0d70982
Merge branch 'master' of github.com:webpack/webpack-cli into info
pranshuchittora Jun 11, 2019
71ebc63
fix(lint): fixes linting issues
pranshuchittora Jun 11, 2019
b54efd0
chore(info): changes output flags as per review
pranshuchittora Jun 11, 2019
c5d50b1
docs(info): updates the docs for the updated output flags
pranshuchittora Jun 11, 2019
0b88f32
chore(options): improves aliases of flags
pranshuchittora Jun 11, 2019
2a893c7
docs(info): improves the docs for the flags
pranshuchittora Jun 11, 2019
aa03e7d
chore(options): fixes broken option rejectiong and updates desc
pranshuchittora Jun 11, 2019
4ec2b89
docs(readme): updates the docs for using package as local module
pranshuchittora Jun 11, 2019
339dc2c
docs(readme): updates the docs hence removes unused vars
pranshuchittora Jun 11, 2019
e623e0e
fix(config): improves exception handling for config parsing
pranshuchittora Jun 11, 2019
4396e73
feat(info): adds return types
pranshuchittora Jun 11, 2019
54d7954
chore(info): improves string concatination
pranshuchittora Jun 11, 2019
facbbbc
tests(info): updates the test for the info package
pranshuchittora Jun 11, 2019
1fe3eb9
fix(info): fixes some issues when the info is called remotely
pranshuchittora Jun 12, 2019
4166096
fix(flags): makes output flags to follow general standards
pranshuchittora Jun 13, 2019
211b2be
feat(info): now config can be passed as a custom argument
pranshuchittora Jun 13, 2019
9395964
chore(info): updates the types
pranshuchittora Jun 13, 2019
b521aaa
chore(deps): added types/yargs as a dependency
pranshuchittora Jun 13, 2019
88dc7cd
docs(info): adds config props
pranshuchittora Jun 13, 2019
80abe70
chore(deps): updates the lock file
pranshuchittora Jun 13, 2019
83f038c
chore(docs): updates description and docs
pranshuchittora Jun 13, 2019
b3c98ad
chore(comments): removes unwanted comments
pranshuchittora Jun 13, 2019
4b3105f
feat(info): adds support for plugin name from the parsed config
pranshuchittora Jun 17, 2019
8843786
Merge branch 'master' of github.com:webpack/webpack-cli into info
pranshuchittora Jun 17, 2019
2e9c758
Merge branch 'master' of github.com:webpack/webpack-cli into info
pranshuchittora Jun 25, 2019
479df8d
chore(files): undo the changes in migrate
pranshuchittora Jun 25, 2019
5e043b9
chore(init): undo file changes in init
pranshuchittora Jun 25, 2019
110fa5e
chore: fix sec vuln
evenstensberg Jul 14, 2019
a56e916
chore: v3.3.6
evenstensberg Jul 14, 2019
d14d878
Merge branch 'master' of github.com:webpack/webpack-cli into info
pranshuchittora Jul 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
598 changes: 303 additions & 295 deletions junit.xml

Large diffs are not rendered by default.

54 changes: 42 additions & 12 deletions packages/info/__tests__/index.test.ts
@@ -1,15 +1,45 @@
import { information } from "../index";

describe("info", () => {
it("should return the information of the enviroment", async () => {
const returnedInformation = information();
const expectedInformation = {
Binaries: ["Node", "Yarn", "npm"],
Browsers: ["Chrome", "Firefox", "Safari"],
System: ["OS", "CPU"],
npmGlobalPackages: ["webpack", "webpack-cli"],
npmPackages: "*webpack*",
};
import { informationType } from "../index";

describe("infoSystem", () => {
it("should return the information of the system", async () => {
const returnedInformation = informationType("system");
const expectedInformation = { System: ["OS", "CPU", "Memory"] };

expect(returnedInformation).toEqual(expectedInformation);
});
});

describe("infoBinaries", () => {
it("should return the information of the binaries", async () => {
const returnedInformation = informationType("binaries");
const expectedInformation = { Binaries: ["Node", "Yarn", "npm"] };

expect(returnedInformation).toEqual(expectedInformation);
});
});

describe("infoBrowsers", () => {
it("should return the information of the browsers installed", async () => {
const returnedInformation = informationType("browsers");
const expectedInformation = { Browsers: ["Chrome", "Firefox", "Safari"] };

expect(returnedInformation).toEqual(expectedInformation);
});
});

describe("infoNpmGlobal", () => {
it("should return the information of the NPM global packages", async () => {
const returnedInformation = informationType("npmg");
const expectedInformation = { npmGlobalPackages: ["webpack", "webpack-cli"] };

expect(returnedInformation).toEqual(expectedInformation);
});
});

describe("infoNpm", () => {
it("should return the information of the NPM packages (webpack)", async () => {
const returnedInformation = informationType("npm");
const expectedInformation = { npmPackages: "*webpack*" };

expect(returnedInformation).toEqual(expectedInformation);
});
Expand Down
4 changes: 4 additions & 0 deletions packages/info/commands.ts
@@ -0,0 +1,4 @@
export const AVAILABLE_COMMANDS: string[] = ["binaries", "system", "browsers", "npmGlobalPackages", "npmPackages",
"bin", "sys", "npmg", "npm"];
export const AVAILABLE_FORMATS: string[] = ["json", "markdown"];
export const IGNORE_FLAGS: string[] = ["_", "$0"];
65 changes: 53 additions & 12 deletions packages/info/index.ts
@@ -1,20 +1,61 @@
import chalk from "chalk";
import * as envinfo from "envinfo";
import * as process from "process";
import { argv } from "./options";

/**
* Prints debugging information for webpack issue reporting
*/
import { AVAILABLE_COMMANDS, AVAILABLE_FORMATS, IGNORE_FLAGS } from "./commands";

export function information() {
return {
Binaries: ["Node", "Yarn", "npm"],
Browsers: ["Chrome", "Firefox", "Safari"],
System: ["OS", "CPU"],
npmGlobalPackages: ["webpack", "webpack-cli"],
npmPackages: "*webpack*",
};
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 = {};

export function informationType(type: string): object {
switch (type) {
case "system":
return { System: ["OS", "CPU", "Memory"] };
break;
case "binaries":
return { Binaries: ["Node", "Yarn", "npm"] };
break;
case "browsers":
return { Browsers: ["Chrome", "Firefox", "Safari"] };
break;
case "npmg":
return { npmGlobalPackages: ["webpack", "webpack-cli"] };
break;
case "npm":
return { npmPackages: "*webpack*" };
break;
}
}

export default async function info() {
process.stdout.write(await envinfo.run(information()));

Object.keys(argv).forEach(async (flag) => {
if (IGNORE_FLAGS.includes(flag)) {
return;
} else if (AVAILABLE_COMMANDS.includes(flag)) {
const flagVal = informationType(flag);
DETAILS_OBJ = { ...DETAILS_OBJ, ...flagVal };
} else if (AVAILABLE_FORMATS.includes(flag)) {
CONFIG[flag] = true;
} else {
// Invalid option
process.stdout.write("\n" + chalk.bgRed(flag) + chalk.red(" is an invalid option"));
return;
pranshuchittora marked this conversation as resolved.
Show resolved Hide resolved

}
});

process.stdout.write("\n" + await envinfo.run(
Object.keys(DETAILS_OBJ).length ?
pranshuchittora marked this conversation as resolved.
Show resolved Hide resolved
DETAILS_OBJ : DEFAULT_DETAILS,
CONFIG) +
"\n");
}
48 changes: 48 additions & 0 deletions packages/info/options.ts
@@ -0,0 +1,48 @@
import * as yargs from "yargs";
export const 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
;