Context Propagation
Every migration requires ability to work on different levels simultaneously:- repository - clone, branch, commit, push
- directories - iterate, copy, move, remove
- files - iterate, copy, move, remove
- code blocks - iterate, change, remove
Saving and Reusing Context
Function calls with context can be saved and reused:Callback Context Retrieval
Another option to retrieve parent context is inside callback function:Plugin Creation
Thanks to callback context retrieval, plugins can be created as functions:Remote Execution
Passing context and ability to retrieve it will open for us more interesting possibilities. We can wrap every function with higher order function and make child call in different process or even different server.Chain Calls
Another interesting feature is ability to retrieve some data from chain calls and use it later. For example we can retrieve all usages ofconsole.log
in our codebase:
- actual function parameters
- callback that will have context inside (optional)
Promises vs Futures
In JavaScript every promise you instantiate is getting called immediately. For exampleawait
operator is used.
await
whenever you need execute tasks, otherwise just save links to task execution flow and use it later: const repo1Packages = git.clone('repo1').dirs('packages/*')
is definition of flow, not actual execution.
Types and chain calls
Every function is typed and has jsdoc description. Every function will return lazy promise object with helpers. Once youawait
lazy promise - it will also return helpers. Return is typed and you will get helpers that are currently available.
repoLink.
- you will get autocomplete in your IDE with list of possible functions.