Today marks the release of isomorphic-git version 1.0! 🎉 There are a lot of big improvements to celebrate.
- Better IDE Integration
- Better TypeScript Integration
- More Good Defaults, Fewer Bad Defaults
- Embrace Callbacks
- Future-proof API
- Acknowledgment
- 1.0 Breaking Changes
- Big changes
- Some functions have been renamed or removed:
- Some function parameters have been removed or replaced:
- The return types of some functions have changed:
- Some function behaviors have changed
- Docs and DX improvements
- Miscellaneous stuff
No longer must we maintain the
index.d.ts file by hand! Thanks to improvements in TS 3.7, we can auto-generate the declaration file using
tsc --declaration --allowJs
. This has the added benefit that the JSDoc is also included in the index.d .tswhich leads to a much richer IDE integration. Sadly, parameter descriptions still aren't shown, but the main description body and the example code are!
Here’s what the Visual Studio Code tooltip for (git.log) looked like before:
And here’s what it looks like in version 1.0:
The functions themselves have been tweaked so that the core object interfaces ( (CommitObject) (TreeEntry) , TagObject) , etc) are reused wherever possible, so that all the functions feel consistant and there are no surprises. The result is a cleaner API where the documentation comes to you, right where you are.
function does not overwrite your config file if it already exists. init - The
checkout function now warns about conflicts instead of blindly overwriting files.
- The commit function does silently remove submodules.
- isomorphic-git can be pretty slow and block the main thread.
- I should encourage everyone to use isomorphic-git in a Worker.
- Therefore, I should make it easy to wrap isomorphic-git in a postMessage / RPC interface.
- (All) code can be pretty slow and block the main thread.
- Therefore all the code that uses
- In that case, isomorphic-git doesn’t need serializable arguments at all.
: shudder: You live, you learn, amirite?
A number of “helpful” default behaviors have been removed, because no default is better than a bad default:
A big one was assuming if you if you used the ESM build you were in the browser and had access to
fetch
and if you use the CommonJS build you were in node. That simply isn't true in today's environment. In version 1.0, you are always in control of whether to use http / web or http / node
.
Another one was automatically appending
. Git to the end of URLs when you clone them. That that can be helpful, but it can also completely break cloning for some servers, which led to the awkward addition of the noGitSuffix
parameter (cringe). In version 1.0, the URL you give is the URL we GET.
Embrace Callbacks Something I tried to do early-ish in the development of 0.x was to move towards this idea that all function arguments need to be serializable. My reasoning was this:
This led to the creation of (magic -portal
and publishing the WebWorker Guide. It also was the main constraint driving the design of the plugin system. The idea was all the callbacks could be setup in one place.
However, since that time I have grown a tad wiser. In building real-world applications with isomorphic-git, I’ve realized:
Therefore the plugin system and its awkward global state and funky namespace “cores” are gone, replaced by a vastly simpler collection of callback arguments. The new code is safer, has better locality when you’re reading it, and enables some cool new behaviors like canceling running functions and infinite retry for interactive authentication.
A number of other changes, such as returning
(Uint8Array) instead of (Buffer) , were done to pave the way for future refactoring. The size of the library can be shrunk significantly if we drop the Buffer polyfill dependency. Plus, Webpack 5 reportedly won't provide node polyfills automatically.
As always, all the functions are async and take named arguments, which makes adding new features without breaking old ones easy! I'm a huge fan of this pattern, and I think it's been very successful.
It is safe to say that the API for isomorphic-git will remain backwards compatible and have no breaking changes for at least a year, possibly two or three. Because I want you to always be able to upgrade to the latest and greatest version of isomorphic-git without having to change any of your code.
Except for today. Today, we are making breaking changes because it is a major release.
()
as a function argument was less aesthetic and more verbose, but it is a much simpler model than the plugin core model, and much safer because it makes it impossible for dependencies to accidentally share the default plugin core.
- The emitter plugin has been replaced with onMessage and onProgress callbacks.
- The
credentialManager plugin has been replaced with (onAuth) , onAuthFailure and onAuthSuccess callbacks
- The The fs (plugin has been replaced with an (fs) parameter.
- The http (plugin has been replaced with an (http
parameter.
- The
pgp (plugin has been replaced with an (onSign) callback. - There is an additional setup step to choose which http
client to use, and functions that make HTTP requests have a new required
http parameter. Previously I used a mix of bundler and runtime magic to try and pick between a build that used fetch
and one that used require ('http') but that did not always work. For instance, if you were bundling a node application using Webpack, it would pick the wrong build (# 01575879 . Another example: in an Electron renderer thread, both
- The files in the package have been renamed so the import paths are short and sweet:
- dist /bundle.umd.min.js -> (index.umd.min.js)
- dist / for-future / isomorphic- git / index.js -> index.js ((the future has arrived)
- dist / for-node / isomorphic- git / index.js -> index.cjs
walkBeta2 function was renamed to (walk) .
- The walkBeta1 function was removed.
- The fastCheckout function has been renamed (checkout) and the old checkout has been removed.
- The (previously deprecated) sign function was removed.
- The (previously deprecated) utils.auth
function was removed.
- The (previously deprecated) utils.oauth2
was removed.
- The
config (function has been removed and replaced by (getConfig) , getConfigAll , and setConfig
.
- The verify
function has been removed, but (log) , readCommit , and readTag
all return the
gpgsig
and signing
payload
for complete code examples.Docs and DX improvements
- dist /bundle.umd.min.js -> (index.umd.min.js)
GIPHY App Key not set. Please check settings