chore(deps): updating packages

This commit is contained in:
Dylan R. E. Moonfire 2021-02-03 23:15:00 -06:00
parent f8abdefa66
commit 14df2a0136
15 changed files with 6625 additions and 28038 deletions

27846
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -27,13 +27,18 @@
}, },
"scripts": { "scripts": {
"barrels": "barrelsby --delete --location all --directory src --exclude '(tests|cli|tools)'", "barrels": "barrelsby --delete --location all --directory src --exclude '(tests|cli|tools)'",
"prebuild": "npm run barrels && npm run lint && npm run format && npm run clean", "prebuild": "yarn run barrels && yarn run lint && yarn run format && yarn run clean",
"build": "tsc", "build": "tsc",
"clean": "rimraf lib", "clean": "rimraf lib",
"commitmsg": "commitlint -E GIT_PARAMS", "commitmsg": "commitlint -E GIT_PARAMS",
"format": "tsfmt -r && sort-package-json package.json", "format": "prettier src --write \"**/*.ts\" --loglevel warn",
"lint": "eslint -c .eslintrc.yml src/**/*.ts --fix", "lint": "eslint -c .eslintrc.yml src/**/*.ts --fix",
"prepack": "npm run build" "prepack": "yarn run build"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}, },
"commitlint": { "commitlint": {
"extends": [ "extends": [
@ -46,38 +51,37 @@
} }
}, },
"dependencies": { "dependencies": {
"@types/node": "^6.0.46",
"add-commas": "0.0.4", "add-commas": "0.0.4",
"dotted": "^0.1.1",
"gulp": "^3.9.1",
"lodash": "^4.16.5", "lodash": "^4.16.5",
"markdown-table": "^1.0.0", "markdown-table": "^1.0.0",
"read-pkg-up": "^4.0.0", "read-pkg-up": "^4.0.0",
"yaml-front-matter": "^3.4.0", "yaml-front-matter": "^3.4.0",
"yargs": "^12.0.1" "yargs": "^16.2.0"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^7.0.0", "@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^7.0.1", "@commitlint/config-conventional": "^11.0.0",
"@semantic-release/changelog": "^3.0.0", "@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^7.0.1", "@semantic-release/git": "^7.0.1",
"@semantic-release/npm": "^5.0.1", "@semantic-release/npm": "^5.0.1",
"@types/lodash": "^4.14.116", "@types/lodash": "^4.14.116",
"@types/node": "^6.0.46",
"@types/read-pkg-up": "^3.0.1", "@types/read-pkg-up": "^3.0.1",
"@types/yaml": "^1.9.7", "@types/yaml": "^1.9.7",
"@types/yargs": "^11.1.1", "@types/yargs": "^11.1.1",
"@typescript-eslint/eslint-plugin": "^3.7.0",
"@typescript-eslint/parser": "^3.7.0",
"barrelsby": "^1.0.2", "barrelsby": "^1.0.2",
"commitizen": "^2.10.1", "commitizen": "^2.10.1",
"cz-conventional-changelog": "^2.1.0", "cz-conventional-changelog": "^2.1.0",
"eslint": "^5.3.0", "eslint": "^5.3.0",
"eslint-plugin-typescript": "^0.12.0", "eslint-plugin-typescript": "^0.12.0",
"husky": "^0.14.3", "husky": "^0.14.3",
"prettier": "^2.0.5",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"semantic-release": "^15.9.8", "semantic-release": "^15.9.8",
"sort-package-json": "^1.48.1", "sort-package-json": "^1.48.1",
"typescript": "^3.0.1", "typescript": "^4.1.3"
"typescript-eslint-parser": "^18.0.0",
"typescript-formatter": "^7.2.2"
}, },
"release": { "release": {
"branch": "master", "branch": "master",

7
prettier.config.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = {
endOfLine: "lf",
semi: true,
singleQuote: false,
tabWidth: 4,
trailingComma: "es5",
};

View file

@ -1,8 +1,4 @@
import * as yargs from "yargs"; import * as yargs from "yargs";
yargs yargs.usage("$0 <cmd> [args]").commandDir("tools").demandCommand(1).help("help")
.usage("$0 <cmd> [args]")
.commandDir("tools")
.demandCommand(1)
.help("help")
.argv; .argv;

View file

@ -1 +1,5 @@
/**
* @file Automatically generated by barrelsby.
*/
export * from "./scanner"; export * from "./scanner";

View file

@ -3,15 +3,13 @@ import * as path from "path";
import * as yamlFrontMatter from "yaml-front-matter"; import * as yamlFrontMatter from "yaml-front-matter";
/** /**
* Parses the input files and returns a list of YAML metadata with special * Parses the input files and returns a list of YAML metadata with special
* columns for calculated values. * columns for calculated values.
*/ */
export function scanFiles(argv, files: string[]) export function scanFiles(argv, files: string[]) {
{
var list: any[] = []; var list: any[] = [];
for (var file of files) for (var file of files) {
{
// Load the metadata from the given file. // Load the metadata from the given file.
var contents = fs.readFileSync(file, "utf8"); var contents = fs.readFileSync(file, "utf8");
var metadata = yamlFrontMatter.loadFront(contents); var metadata = yamlFrontMatter.loadFront(contents);
@ -21,8 +19,7 @@ export function scanFiles(argv, files: string[])
metadata._basename = path.basename(file); metadata._basename = path.basename(file);
metadata._words = metadata.__content metadata._words = metadata.__content
.replace("'", "") .replace("'", "")
.split(/\s+/g) .split(/\s+/g).length;
.length;
// Add the metadata to the list. // Add the metadata to the list.
list.push(metadata); list.push(metadata);

View file

@ -6,36 +6,29 @@ import * as yargs from "yargs";
export var command = "content"; export var command = "content";
export var describe = "Extracts the content of the file without metadata"; export var describe = "Extracts the content of the file without metadata";
export function builder(yargs: yargs.Arguments) export function builder(yargs: yargs.Arguments) {
{
return yargs return yargs
.help("help") .help("help")
.option( .option("output", {
"output", alias: "o",
{ default: "-",
alias: "o", describe: "Write output to a file or `-` for standard out",
default: "-", })
describe: "Write output to a file or `-` for standard out",
}
)
.demand(1); .demand(1);
} }
export function handler(argv: any) export function handler(argv: any) {
{
// Parse through the files and retrieve the metadata. // Parse through the files and retrieve the metadata.
var files = argv._.splice(1); var files = argv._.splice(1);
var data: any = scanner.scanFiles(argv, files); var data: any = scanner.scanFiles(argv, files);
var output = data.map(x => x.__content).join("\n"); var output = data.map((x) => x.__content).join("\n");
// Figure out where to write. // Figure out where to write.
if (argv.output === "-") if (argv.output === "-") {
{
console.log(output); console.log(output);
} else } else {
{
fs.writeFileSync(argv.output, Buffer.from(output, "utf-8")); fs.writeFileSync(argv.output, Buffer.from(output, "utf-8"));
} }
} }

View file

@ -5,8 +5,7 @@ import * as table from "./table";
export var command = "count"; export var command = "count";
export var describe = "Counts the number of words in the given input"; export var describe = "Counts the number of words in the given input";
export function builder(yargs: yargs.Arguments) export function builder(yargs: yargs.Arguments) {
{
return yargs return yargs
.help("help") .help("help")
@ -14,8 +13,9 @@ export function builder(yargs: yargs.Arguments)
.describe( .describe(
"fields", "fields",
"The dotted fields in the metadata to display, or _basename for " + "The dotted fields in the metadata to display, or _basename for " +
"the name of the file, or _words to count the number of words. " + "the name of the file, or _words to count the number of words. " +
"Appending a `:r` at the end right-aligns the output.") "Appending a `:r` at the end right-aligns the output."
)
.default("table-start", "") .default("table-start", "")
.default("table-end", "") .default("table-end", "")
@ -30,14 +30,15 @@ export function builder(yargs: yargs.Arguments)
.describe( .describe(
"total", "total",
"If provided, adds a special entry with a _basename of Totals " + "If provided, adds a special entry with a _basename of Totals " +
"that adds up all the words.") "that adds up all the words."
)
.boolean("separator") .boolean("separator")
.alias("s", "separator") .alias("s", "separator")
.describe( .describe(
"separator", "separator",
"If provided, then the word counts will have comma separators " + "If provided, then the word counts will have comma separators " +
"for thousands." "for thousands."
) )
.alias("o", "output") .alias("o", "output")
@ -46,18 +47,15 @@ export function builder(yargs: yargs.Arguments)
.demand(1); .demand(1);
} }
export function handler(argv: any) export function handler(argv: any) {
{
var files = argv._.splice(1); var files = argv._.splice(1);
var data = scanner.scanFiles(argv, files); var data = scanner.scanFiles(argv, files);
if (argv.total) if (argv.total) {
{
argv.fields[1] += "t"; argv.fields[1] += "t";
} }
if (argv.separator) if (argv.separator) {
{
argv.fields[1] += "s"; argv.fields[1] += "s";
} }

View file

@ -7,63 +7,47 @@ import * as yargs from "yargs";
export var command = "extract"; export var command = "extract";
export var describe = "Extracts a YAML from a list of files"; export var describe = "Extracts a YAML from a list of files";
export function builder(yargs: yargs.Arguments) export function builder(yargs: yargs.Arguments) {
{
return yargs return yargs
.help("help") .help("help")
.option( .option("list", {
"list", type: "boolean",
{ default: true,
type: "boolean", describe:
default: true, "Extract the data as a list of files, otherwise as a single file",
describe: "Extract the data as a list of files, otherwise as a single file", })
} .option("output", {
) alias: "o",
.option( default: "-",
"output", describe: "Write output to a file or `-` for standard out",
{ })
alias: "o", .option("yaml", {
default: "-", alias: "y",
describe: "Write output to a file or `-` for standard out", type: "boolean",
} default: false,
) describe: "Extract the output as YAML instead of JSON",
.option( })
"yaml", .option("content", {
{ type: "string",
alias: "y", describe: "Include the content as a property in the extracted data",
type: "boolean", })
default: false,
describe: "Extract the output as YAML instead of JSON",
}
)
.option(
"content",
{
type: "string",
describe: "Include the content as a property in the extracted data",
}
)
.demand(1); .demand(1);
} }
export function handler(argv: any) export function handler(argv: any) {
{
// Parse through the files and retrieve the metadata. // Parse through the files and retrieve the metadata.
var files = argv._.splice(1); var files = argv._.splice(1);
var data: any = scanner.scanFiles(argv, files); var data: any = scanner.scanFiles(argv, files);
// Figure out how to handle the content property. // Figure out how to handle the content property.
if (!argv.content) if (!argv.content) {
{
// Remove the content from the parsed file. // Remove the content from the parsed file.
data.forEach(x => delete x.__content); data.forEach((x) => delete x.__content);
} else if (argv.content !== "__content") } else if (argv.content !== "__content") {
{
// Rename the content property. // Rename the content property.
data.forEach(x => data.forEach((x) => {
{
x[argv.content] = x.__content; x[argv.content] = x.__content;
delete x.__content; delete x.__content;
}); });
@ -72,9 +56,7 @@ export function handler(argv: any)
// Determine if we are displaying a list of items. If we want a list, then // Determine if we are displaying a list of items. If we want a list, then
// we wrap the data in another list (list of a list) so it writes out only // we wrap the data in another list (list of a list) so it writes out only
// one item. Otherwise, we write out each one. // one item. Otherwise, we write out each one.
const items = argv.list const items = argv.list ? [data] : data;
? [data]
: data;
// Figure the output of the results (JSON or YAML). // Figure the output of the results (JSON or YAML).
const output = argv.yaml const output = argv.yaml
@ -82,11 +64,9 @@ export function handler(argv: any)
: items.map((x: any) => JSON.stringify(x)).join("\n"); : items.map((x: any) => JSON.stringify(x)).join("\n");
// Figure out where to write. // Figure out where to write.
if (argv.output === "-") if (argv.output === "-") {
{
console.log(output); console.log(output);
} else } else {
{
fs.writeFileSync(argv.output, Buffer.from(output, "utf-8")); fs.writeFileSync(argv.output, Buffer.from(output, "utf-8"));
} }
} }

View file

@ -5,8 +5,7 @@ import * as scanner from "../scanner";
export var command = "list"; export var command = "list";
export var describe = "Extracts a YAML field into an order list"; export var describe = "Extracts a YAML field into an order list";
export function builder(yargs: yargs.Arguments) export function builder(yargs: yargs.Arguments) {
{
return yargs return yargs
.help("help") .help("help")
@ -22,30 +21,23 @@ export function builder(yargs: yargs.Arguments)
.demand(1); .demand(1);
} }
export function handler(argv: any) export function handler(argv: any) {
{
var files = argv._.splice(1); var files = argv._.splice(1);
var data = scanner.scanFiles(argv, files); var data = scanner.scanFiles(argv, files);
render(argv, data); render(argv, data);
} }
export function render(argv, data) export function render(argv, data) {
{ for (var key in data) {
for (var key in data)
{
var number = 1 + parseInt(key.toString()); var number = 1 + parseInt(key.toString());
var item = data[key]; var item = data[key];
var title = _.get(item, argv.title); var title = _.get(item, argv.title);
var value = _.get(item, argv.field); var value = _.get(item, argv.field);
// Build up the parts so we can do this as a single line. // Build up the parts so we can do this as a single line.
const parts = [ const parts = [`${number}. `, title];
`${number}. `,
title,
];
if (value) if (value) {
{
parts.push(": " + value.replace(/\n/g, " ")); parts.push(": " + value.replace(/\n/g, " "));
} }

View file

@ -5,8 +5,7 @@ import * as scanner from "../scanner";
export var command = "sections"; export var command = "sections";
export var describe = "Extracts a YAML field into sections"; export var describe = "Extracts a YAML field into sections";
export function builder(yargs: yargs.Arguments) export function builder(yargs: yargs.Arguments) {
{
return yargs return yargs
.help("help") .help("help")
@ -22,25 +21,21 @@ export function builder(yargs: yargs.Arguments)
.demand(1); .demand(1);
} }
export function handler(argv: any) export function handler(argv: any) {
{
var files = argv._.splice(1); var files = argv._.splice(1);
var data = scanner.scanFiles(argv, files); var data = scanner.scanFiles(argv, files);
render(argv, data); render(argv, data);
} }
export function render(argv, data) export function render(argv, data) {
{ for (var item of data) {
for (var item of data)
{
var title = _.get(item, argv.title); var title = _.get(item, argv.title);
var value = _.get(item, argv.field); var value = _.get(item, argv.field);
console.log(`# ${title}`); console.log(`# ${title}`);
console.log(); console.log();
if (value) if (value) {
{
console.log(value.replace("\n", "\n\n")); console.log(value.replace("\n", "\n\n"));
} }
} }

View file

@ -7,8 +7,7 @@ import * as scanner from "../scanner";
export var command = "table"; export var command = "table";
export var describe = "Create a summary table of requested fields"; export var describe = "Create a summary table of requested fields";
export function builder(yargs: yargs.Arguments) export function builder(yargs: yargs.Arguments) {
{
return yargs return yargs
.help("help") .help("help")
@ -37,23 +36,20 @@ export function builder(yargs: yargs.Arguments)
.demand(1); .demand(1);
} }
export function handler(argv: any) export function handler(argv: any) {
{
var files = argv._.splice(1); var files = argv._.splice(1);
var data = scanner.scanFiles(argv, files); var data = scanner.scanFiles(argv, files);
render(argv, data); render(argv, data);
} }
export function render(argv, data) export function render(argv, data) {
{
// Parse out the options and fields from the sources. // Parse out the options and fields from the sources.
var columns = parse(argv, argv.titles, argv.fields); var columns = parse(argv, argv.titles, argv.fields);
// Create the header row. // Create the header row.
var header: any[] = []; var header: any[] = [];
for (var column1 of columns) for (var column1 of columns) {
{
header.push(column1.header); header.push(column1.header);
} }
@ -63,35 +59,30 @@ export function render(argv, data)
// Loop through the results and get the fields we need to display. // Loop through the results and get the fields we need to display.
var totals: any = ["Totals"]; var totals: any = ["Totals"];
for (var metadata of data) for (var metadata of data) {
{
// Add the row to the table. // Add the row to the table.
var row: any[] = []; var row: any[] = [];
table.push(row); table.push(row);
// Loop through our fields and retrieve each one. // Loop through our fields and retrieve each one.
for (var index = 0; index < columns.length; index++) for (var index = 0; index < columns.length; index++) {
{
// Grab the value, even if nested. // Grab the value, even if nested.
var column = columns[index]; var column = columns[index];
var value = _.get(metadata, column.ref); var value = _.get(metadata, column.ref);
// If we have a list, format it with spaces. // If we have a list, format it with spaces.
if (Array.isArray(value)) if (Array.isArray(value)) {
{
value = value.join(argv.listDelimiter); value = value.join(argv.listDelimiter);
} }
// If we have totals, then add them. // If we have totals, then add them.
if (column.total) if (column.total) {
{
totals[index] = totals[index] ? parseInt(totals[index]) : 0; totals[index] = totals[index] ? parseInt(totals[index]) : 0;
totals[index] += parseInt(value); totals[index] += parseInt(value);
} }
// If we have commas requested, then add those. // If we have commas requested, then add those.
if (column.comma) if (column.comma) {
{
value = comma(value); value = comma(value);
} }
@ -101,14 +92,15 @@ export function render(argv, data)
} }
// If we have totals, then add it at the bottom. // If we have totals, then add it at the bottom.
if (totals.length > 1) if (totals.length > 1) {
{ for (
for (var index2 = 0; index2 < columns.length && index2 < totals.length; index2++) var index2 = 0;
{ index2 < columns.length && index2 < totals.length;
index2++
) {
var column2 = columns[index2]; var column2 = columns[index2];
if (column2.comma) if (column2.comma) {
{
totals[index2] = comma(totals[index2]); totals[index2] = comma(totals[index2]);
} }
} }
@ -118,50 +110,45 @@ export function render(argv, data)
// Format the results in a table. // Format the results in a table.
var formattedTable = markdownTable(table, { var formattedTable = markdownTable(table, {
align: columns.map(c => c.align), align: columns.map((c) => c.align),
delimiter: argv.tableDelimiter, delimiter: argv.tableDelimiter,
start: argv.tableStart, start: argv.tableStart,
end: argv.tableEnd, end: argv.tableEnd,
rule: argv.tableRule rule: argv.tableRule,
}); });
// If we don't want the header row, strip off the first line. // If we don't want the header row, strip off the first line.
if (!argv.tableHeader) if (!argv.tableHeader) {
{ formattedTable = formattedTable.substring(
formattedTable = formattedTable.substring(formattedTable.indexOf("\n") + 1); formattedTable.indexOf("\n") + 1
);
} }
console.log(formattedTable); console.log(formattedTable);
} }
class Column class Column {
{
ref: string; ref: string;
header: string; header: string;
align: string = "l"; align: string = "l";
comma: boolean = false; comma: boolean = false;
total: boolean = false; total: boolean = false;
public set(field, header) public set(field, header) {
{
this.ref = this.parseSpecifier(field); this.ref = this.parseSpecifier(field);
this.header = this.parseSpecifier(header ? header : field); this.header = this.parseSpecifier(header ? header : field);
} }
private parseSpecifier(spec): string private parseSpecifier(spec): string {
{
// See if we have options. // See if we have options.
var m = spec.match(/^(.*?):([lcr.st]+)?$/); var m = spec.match(/^(.*?):([lcr.st]+)?$/);
if (m) if (m) {
{
// We have a match, so put the first part as the specifier. // We have a match, so put the first part as the specifier.
spec = m[1]; spec = m[1];
for (var s of m[2]) for (var s of m[2]) {
{ switch (s) {
switch (s)
{
case "c": case "c":
case "l": case "l":
case "r": case "r":
@ -185,19 +172,18 @@ class Column
} }
} }
function parse(argv, titles, fields): Column[] function parse(argv, titles, fields): Column[] {
{
var columns: Column[] = []; var columns: Column[] = [];
if (!titles) titles = []; if (!titles) titles = [];
for (var index = 0; index < fields.length; index++) for (var index = 0; index < fields.length; index++) {
{
var column = new Column(); var column = new Column();
column.set( column.set(
fields[index], fields[index],
titles.length >= index ? titles[index] : undefined); titles.length >= index ? titles[index] : undefined
);
columns.push(column); columns.push(column);
} }

View file

@ -4,15 +4,11 @@ import * as yargs from "yargs";
export var command = "version"; export var command = "version";
export var describe = "Displays version information about the program"; export var describe = "Displays version information about the program";
export function builder(yargs: yargs.Arguments) export function builder(yargs: yargs.Arguments) {
{ return yargs.help("help").demand(0);
return yargs
.help("help")
.demand(0);
} }
export function handler(argv: any) export function handler(argv: any) {
{
const pkg: any = readPackage.sync(); const pkg: any = readPackage.sync();
const json = pkg.pkg; const json = pkg.pkg;

View file

@ -1,9 +0,0 @@
{
"indentSize": 4,
"tabSize": 4,
"indentStyle": 2,
"newLineCharacter": "\n",
"convertTabsToSpaces": true,
"placeOpenBraceOnNewLineForFunctions": true,
"placeOpenBraceOnNewLineForControlBlocks": true
}

6494
yarn.lock Normal file

File diff suppressed because it is too large Load diff