CH-ange-L-og U-pdate - Automatically fix errors in your changelog file


Keywords
automated, automatically, change, changelog, correct, errors, fix, links, log, markdown, missing, tool, update, css, email, html, json
License
MIT
Install
npm install chlu@3.7.77

Documentation

📦 Codsen 📦

A lerna monorepo for our 82 npm libraries

💡 Table of Contents

#%EF%B8%8F-17-miscellaneous-libraries

🚢 Flagship Libraries

Library's name Purpose Web app npm_link Source code in monorepo
email-comb Remove unused CSS from email templates emailcomb.com email-comb on npm packages/email-comb
html-crush Minifies HTML/CSS: valid or broken, pure or mixed with other languages htmlcrush.com html-crush on npm packages/html-crush

There are quite a few small libraries, so let's group them by a common purpose.

🎯 11 Range Libraries

Range means an array of two text character index numbers, "from" and "to" (plus optional third element, string, which marks "what to add").

For example, "from the third character to the fourth character" could be marked with array [3, 4].

There can be a third element in a range array, what to add instead of the range. For example, [10, 12, "add this"]. When there is no third element in the range array, like [10, 12], that would mean "delete from index 10 to index 12". Empty third element is the same as if it was missing.

For example, a range [1, 3] in a string "abcdef" would mean bc because "b" is at index number 1 (counting starts at zero) and 3rd is "d". The beginning of the range is inclusive, and the ending is not. Hence, the result "bc".

Another example, if you want to replace "{placeholder}" with "John" in a string "Hi {placeholder}!"^, the range would be [3, 16, "John"].

Now, if you have many ranges, you put them into an array. You get an array of ranges. Majority of range- libraries process such arrays of ranges: sort bunch of ranges, fix overlapping ranges and so on.

Practically, we need ranges when we process strings and want to "keep a note" of what needs to be deleted or replaced later. The idea is, instead of processing the string many times:

"find out what needs to be done with a string" ->
"mutate the string" ->
"find out what more needs to be done with a string" ->
"mutate the mutated string" ->
... and so on,

We only "compile a to-do list" — push the ranges into an array. When we finish gathering them, we do all the actions in one go.

Performing string processing only once is better for both performance reasons (fewer actions = faster) and for consistency (in-between taking the notes, we operate on the original string instead of its previously mutated version).

If you think, strings are immutable in JavaScript — each change of a string means rewriting it in a computer memory. Let's say you want to add a letter and delete the same letter in a string which consists of a thousand characters. Both actions cancel each other out. However, if you do the string edits sequentially, you write a thousand characters to memory two times, after every amend. On the other hand, if you use ranges approach, you'd only create a new record in the computer memory, housing a couple of arrays, each consisting of couple index numbers. When you process the ranges, they would cancel each other out, and we would not write anything to the memory at all. Now, if you scale this — longer strings, more amends, and done many times — you'll soon feel the difference in performance.

Library's name Purpose npm_link Source code in monorepo
ranges-push Manage the array of slices referencing the index ranges within the string ranges-push on npm packages/ranges-push
ranges-apply Take an array of string slice ranges, delete/replace the string according to them ranges-apply on npm packages/ranges-apply
ranges-merge Merge and sort arrays which mean string slice ranges ranges-merge on npm packages/ranges-merge
ranges-sort Sort natural number index ranges [ [5, 6], [1, 3] ] => [ [1, 3], [5, 6] ] ranges-sort on npm packages/ranges-sort
string-range-expander Expands string index ranges within whitespace boundaries until letters are met string-range-expander on npm packages/string-range-expander
ranges-crop Crop array of ranges when they go beyond the reference string's length ranges-crop on npm packages/ranges-crop
ranges-ent-decode Decode HTML entities recursively, get string index ranges of what needs to be replaced where ranges-ent-decode on npm packages/ranges-ent-decode
ranges-invert Invert string index ranges [ [1, 3] ] => [ [0, 1], [3, ...] ] ranges-invert on npm packages/ranges-invert
ranges-is-index-within Efficiently checks if index is within any of the given ranges ranges-is-index-within on npm packages/ranges-is-index-within
ranges-process-outside Iterate through string and optionally a given ranges as if they were one ranges-process-outside on npm packages/ranges-process-outside
ranges-regex Perform a regex search on string and get a ranges array of findings (or null) ranges-regex on npm packages/ranges-regex

🎻 25 String Processing Libraries

They process string inputs, which might be text, code or something else as long as it is of a string type.

Library's name Purpose npm_link Source code in monorepo
string-strip-html Strips HTML tags from strings. Detects legit unencoded brackets. string-strip-html on npm packages/string-strip-html
easy-replace Replace strings with optional lookarounds, but without regexes easy-replace on npm packages/easy-replace
str-indexes-of-plus Search for a string in another string. Get array of indexes. Full Unicode support. str-indexes-of-plus on npm packages/str-indexes-of-plus
bitbucket-slug Generate BitBucket readme header anchor slug URLs. Unofficial, covers whole ASCII and a bit beyond. bitbucket-slug on npm packages/bitbucket-slug
detect-is-it-html-or-xhtml Answers, is the string input string more an HTML or XHTML (or neither) detect-is-it-html-or-xhtml on npm packages/detect-is-it-html-or-xhtml
email-all-chars-within-ascii Scans all characters within a string and checks are they within ASCII range email-all-chars-within-ascii on npm packages/email-all-chars-within-ascii
html-table-patcher Wraps any content between TR/TD tags in additional rows/columns to appear in browser correctly html-table-patcher on npm packages/html-table-patcher
js-row-num Update all row numbers in all console.logs in JS code js-row-num on npm packages/js-row-num
csv-sort Sorts double-entry bookkeeping CSV coming from internet banking csv-sort on npm packages/csv-sort
csv-sort-cli Command line app to sort double-entry CSVs coming from internet banking statements csv-sort-cli on npm packages/csv-sort-cli
csv-split-easy Splits the CSV string into array of arrays, each representing a row of columns csv-split-easy on npm packages/csv-split-easy
string-character-is-astral-surrogate Tells, is given character a part of astral character, specifically, a high and low surrogate string-character-is-astral-surrogate on npm packages/string-character-is-astral-surrogate
string-collapse-leading-whitespace Collapse the leading and trailing whitespace of a string string-collapse-leading-whitespace on npm packages/string-collapse-leading-whitespace
string-collapse-white-space Efficient collapsing of white space with optional outer- and/or line-trimming and HTML tag recognition string-collapse-white-space on npm packages/string-collapse-white-space
string-convert-indexes Convert string character indexes from JS native index-based to Unicode character-count-based and backwards. string-convert-indexes on npm packages/string-convert-indexes
string-extract-class-names Extract class (or id) name from a string string-extract-class-names on npm packages/string-extract-class-names
string-find-heads-tails Search for string pairs. A special case of string search algorithm. string-find-heads-tails on npm packages/string-find-heads-tails
string-fix-broken-named-entities Finds and fixes common and not so common broken named HTML entities, returns ranges array of fixes string-fix-broken-named-entities on npm packages/string-fix-broken-named-entities
string-match-left-right Do substrings match what's on the left or right of a given index? string-match-left-right on npm packages/string-match-left-right
string-overlap-one-on-another Lay one string on top of another, with an optional offset string-overlap-one-on-another on npm packages/string-overlap-one-on-another
string-remove-duplicate-heads-tails Detect and (recursively) remove head and tail wrappings around the input string string-remove-duplicate-heads-tails on npm packages/string-remove-duplicate-heads-tails
string-remove-thousand-separators Detects and removes thousand separators (dot/comma/quote/space) from string-type digits string-remove-thousand-separators on npm packages/string-remove-thousand-separators
string-split-by-whitespace Split string into array by chunks of whitespace string-split-by-whitespace on npm packages/string-split-by-whitespace
string-trim-spaces-only Like String.trim() but trims only spaces string-trim-spaces-only on npm packages/string-trim-spaces-only
string-unfancy Replace all fancy dashes, quotes etc with their simpler equivalents string-unfancy on npm packages/string-unfancy

🔮 20 Object Processing Libraries

When we say "object" we mean a plain object in JavaScript, for example, { name: "Bob" }. Usually, plain objects come from JSON files, and often they are deeply nested. The following libraries help us to traverse them, set and delete keys and compare objects.

"ast-" in the library's name below just emphasises that it really works on nested objects (so-called Abstract Syntax Trees that come from parsed things).

Library's name Purpose npm_link Source code in monorepo
ast-monkey Utility library for ops on parsed HTML (AST's) or anything nested (plain objects within arrays within plain objects) ast-monkey on npm packages/ast-monkey
ast-monkey-traverse Utility library to traverse parsed HTML (AST's) or anything nested (plain objects within arrays within plain objects) ast-monkey-traverse on npm packages/ast-monkey-traverse
json-comb-core The inner core of json-comb json-comb-core on npm packages/json-comb-core
json-variables Preprocessor for JSON to allow keys referencing keys json-variables on npm packages/json-variables
object-merge-advanced Recursive, deep merge of anything (objects, arrays, strings or nested thereof), which weighs contents by type hierarchy to ensure the maximum content is retained object-merge-advanced on npm packages/object-merge-advanced
ast-compare Compare anything: AST, objects, arrays, strings and nested thereof ast-compare on npm packages/ast-compare
ast-contains-only-empty-space Returns Boolean depending if passed AST contain only empty space ast-contains-only-empty-space on npm packages/ast-contains-only-empty-space
ast-delete-object Delete all plain objects that contain a certain key/value pair ast-delete-object on npm packages/ast-delete-object
ast-get-object Getter/setter for nested parsed HTML AST's, querying objects by key/value pairs ast-get-object on npm packages/ast-get-object
ast-get-values-by-key Read or edit parsed HTML (or AST in general) ast-get-values-by-key on npm packages/ast-get-values-by-key
ast-is-empty Find out, is nested array/object/string/AST tree is empty ast-is-empty on npm packages/ast-is-empty
ast-loose-compare Compare anything: AST, objects, arrays and strings ast-loose-compare on npm packages/ast-loose-compare
object-all-values-equal-to Does the AST/nested-plain-object/array/whatever contain only one kind of value? object-all-values-equal-to on npm packages/object-all-values-equal-to
object-boolean-combinations Generate an array full of object copies, each containing a unique Boolean value combination. Includes overrides. object-boolean-combinations on npm packages/object-boolean-combinations
object-delete-key Delete keys from all arrays or plain objects, nested within anything, by key or by value or by both, and clean up afterwards. Accepts wildcards. object-delete-key on npm packages/object-delete-key
object-fill-missing-keys Add missing keys into plain objects, according to a reference object object-fill-missing-keys on npm packages/object-fill-missing-keys
object-flatten-all-arrays Merge and flatten any arrays found in all values within plain objects object-flatten-all-arrays on npm packages/object-flatten-all-arrays
object-flatten-referencing Flatten complex nested objects according to a reference objects object-flatten-referencing on npm packages/object-flatten-referencing
object-no-new-keys Check, does a plain object (AST/JSON) has any unique keys, not present in a reference object (another AST/JSON) object-no-new-keys on npm packages/object-no-new-keys
object-set-all-values-to Recursively walk the input and set all found values in plain objects to something object-set-all-values-to on npm packages/object-set-all-values-to

✂️ 8 CLI Apps

All the following libraries are command line applications. You install them using -g flag, for example, npm i -g json-sort-cli.

You use them in the Terminal (command line), for example:

CLI app

Library's name Purpose npm_link Source code in monorepo
lect Maintenance automation for Readme's and, optionally, other project files lect on npm packages/lect
update-versions Like npm-check-updates but supports Lerna monorepos and enforces strict semver values update-versions on npm packages/update-versions
chlu-cli CH-ange-L-og U-pdate — Automatically fix errors in your changelog file chlu-cli on npm packages/chlu-cli
csv-sort-cli Command line app to sort double-entry CSVs coming from internet banking statements csv-sort-cli on npm packages/csv-sort-cli
email-all-chars-within-ascii-cli Command line app to scan email templates, are all their characters within ASCII range email-all-chars-within-ascii-cli on npm packages/email-all-chars-within-ascii-cli
js-row-num-cli Update all row numbers in all console.logs in JS code js-row-num-cli on npm packages/js-row-num-cli
json-sort-cli Command line app to deep sort JSON files, also dot-files as long as they are valid JSON json-sort-cli on npm packages/json-sort-cli
lerna-clean-changelogs-cli CLI application to cleanse the lerna-generated changelogs lerna-clean-changelogs-cli on npm packages/lerna-clean-changelogs-cli

🛠️ 17 Miscellaneous Libraries

Library's name Purpose npm_link Source code in monorepo
array-group-str-omit-num-char Groups array of strings by omitting number characters array-group-str-omit-num-char on npm packages/array-group-str-omit-num-char
array-includes-with-glob like _.includes but with wildcards array-includes-with-glob on npm packages/array-includes-with-glob
array-of-arrays-into-ast turns an array of arrays of data into a nested tree of plain objects array-of-arrays-into-ast on npm packages/array-of-arrays-into-ast
array-of-arrays-sort-by-col sort array of arrays by column, rippling the sorting outwards from that column array-of-arrays-sort-by-col on npm packages/array-of-arrays-sort-by-col
array-pull-all-with-glob pullAllWithGlob — like _.pullAll but pulling stronger, with globs array-pull-all-with-glob on npm packages/array-pull-all-with-glob
arrayiffy-if-string Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else. arrayiffy-if-string on npm packages/arrayiffy-if-string
charcode-is-valid-xml-name-character Does a given character belong to XML spec's "Production 4 OR 4a" type (is acceptable for XML element's name) charcode-is-valid-xml-name-character on npm packages/charcode-is-valid-xml-name-character
check-types-mini Check the types of your options object's values after user has customised them check-types-mini on npm packages/check-types-mini
chlu CH-ange-L-og U-pdate — Automatically fix errors in your changelog file chlu on npm packages/chlu
color-shorthand-hex-to-six-digit Convert shorthand hex color codes into full color-shorthand-hex-to-six-digit on npm packages/color-shorthand-hex-to-six-digit
email-homey Generate homepage in the Browsersync root with links/screenshots to all your email templates email-homey on npm packages/email-homey
emlint Detects errors in HTML/CSS, proposes fixes, email-template friendly emlint on npm packages/emlint
gulp-email-remove-unused-css Gulp plugin to remove unused CSS classes/id's from styles in HTML HEAD and inline within BODY gulp-email-remove-unused-css on npm packages/gulp-email-remove-unused-css
lerna-clean-changelogs Cleans all the crap from Lerna and Conventional Commits-generated changelogs lerna-clean-changelogs on npm packages/lerna-clean-changelogs
regex-empty-conditional-comments Regular expression for matching HTML empty conditional comments regex-empty-conditional-comments on npm packages/regex-empty-conditional-comments
util-array-object-or-both Validate and normalise user choice: array, object or both? util-array-object-or-both on npm packages/util-array-object-or-both
util-nonempty Is the input (plain object, array, string or whatever) not empty? util-nonempty on npm packages/util-nonempty

🤝 Contributing

  • If you see an error, raise an issue.
  • If you want a new feature but can't code it up yourself, also raise an issue. Let's discuss it.
  • If you tried to use a package, but something didn't work out, also raise an issue. We'll try to help.
  • If you want to contribute some code, fork the monorepo via GitLab, then write code, then file a pull request on GitLab. We'll merge it in and release.

In monorepo, npm libraries are located in packages/ folder. Inside, the source code is located either in src/ folder (normal npm library) or in the root, cli.js (if it's a command line application).

The npm script within each package's package.json "dev", the "dev": "rollup -c --dev --silent" builds the development version retaining all console.logs with row numbers. It's handy to have js-row-num-cli installed globally so you can automatically update the row numbers on all console.logs.

💼 Licence

MIT License

Copyright (c) 2015-2019 Roy Revelt and other contributors