? Invig automatically converts ES5 & CoffeeScript codebases to ES6 with Aligned JavaScript Standard Style
Here's another one of my more upsetting projects ?
Breathes new life into legacy code bases by automatically:
require
vs import
for now))Invig does this in a highly opinionated, non-configurable, and destructive way.
Let's have some fun breathing new life into your legacy project ? ? ?
I'm dealing with an ever-growing number of projects that each have a slightly different setup, and I got pretty tired of context switching between ES5, ES6, CoffeeScript, and different code conventions across those projects.
The tools are there now to automate all difference away - it's just a matter of picking defaults and stringing those tools together. That's what Invig does. After successfully running Invig on your codebase, you can put your brain at ease thanks to uniformity, focus more on the work at hand, have a better time doing so thanks to syntactical goodness, while producing less bugs thanks to ESlint.
Why ditch ES5?
ES6 let's you express yourself in more powerful ways, typically meaning less boilerplate and more readable code.
Why ditch CoffeeScript?
While CoffeeScript lovers might agree already that uniform styling is pleasant and that ES6 is an upgrade over ES5, they might feel there are still a number of syntactical advantages CoffeeScript offers, missing from ES6. Our benchmark demo even results in lengthier ES6 code(!). While that may be true:
import
and async
(Invig won't leverage these), recent Node.js can run your code without any transpiling. Meaning quicker developer iterations and less headaches.Let's take a look at installing Invig at converting CoffeeScript to Standard compatible ES6 via STDIN
Invig is meant to be run on a code base once (or a few times in one session). That's why it should not be used as a dependency but be installed globally instead.
npm install invig --global
⚠️ WARNING Changes are made in-place, make sure your code is protected by version control before using Invig.
Recursively port CoffeeScript/ES5 files to ES6 in-place:
invig -s ./src
Usage: invig [options]
Options:
-h, --help output usage information
-V, --version output the version number
-s, --src <dir> Directory, file or pattern to convert
-b, --bail Abort on the first error instead of continuing to port next file
-c, --check When done, hunt for unused and un-updated dependencies
-q, --quiet Hide any output
Port one ES5 file to ES6:
invig --src old-file.js
Port one CoffeeScript file to ES6 (deleting the old .coffee
file.):
invig --src old-file.coffee
Optionally check for outdated or unused dependencies after the conversion completes:
invig --src src/ --check
Bail out as soon as Invig hits an error. By default Invig will continue processing the next file
invig --src src/ --bail
Do a dry run without changing any files (don't trust me, keep your stuff safe in Git):
invig --src src/ --dryrun
Apply Invig on a pattern (use quotes!)
invig --src 'src/**.js'
Transpile from STDIN
cat old-file.coffee | invig --src -
The recommended way to use Invig is to:
master
and have a clean Git working tree firstgit checkout -b es6
es6
branchInvig is young, but as long as your code is in Git, feel free to have some fun with it, Invig has already ported some very large codebases.
Pre-1.0.0
, we're allowing ourselves to make breaking changes at any release.
build
run script alone if you have already defined it. If you currently have CoffeeScript build tasks, remove them first, so that Invig can write the new one.
The same goes for the lint
, fix
, and build:watch
scripts, as well as the .eslintrc
, and .babelrc
files. The advantage of this that you can run Invig multiple times even though you have customized these components that are used in the modern setup.package.json
, and modifies this in-place also.I deserve no credit, Invig is just a tiny wrapper around these mastodons:
Projects where Invig is used to breathe new life into old codebases:
Please see CHANGELOG.md.
Please see CONTRIBUTING.md.
Welcoming discussion on:
Copyright (c) 2017 Kevin van Zonneveld. Licenses under MIT.