Comments (7)
At the risk of plugging shamefully (😅) my recent Gittar can solve this issue, along with #1 and #3.
The module does not ship with a CLI, so there's no overlap in that regard.
A few key differences:
-
All archives will live in
~/.gittar
, and cannot be configured. -
it doesn't lookup or store archives according to the releases' full refs. IMO, this a bit overkill (at least in my use cases), since I'm far more likely to download specific tags or branches.
- The
master
branch is always refetched, if online. Otherwise it will revert to the lastmaster.tar.gz
file it cached. Since that's probably the only scenario for caring about the more-recent commits, Gittar fetches anew by default.
- The
And with the included tar
package, it's fairly easy to decide how/when to keep/trash/compare metadata. Any options to gittar.extract
are passed directly to tar.extract
, so all the magic happens there. This inches towards a solution for #9.
Let me know what you think. Happy to start working on integrating this into a PR if you'd like. No hard feelings if you don't want to go this route. 😃
from degit.
Nice 👏 Since gittar would be doing most of the heavy lifting, what if we just merged these projects? In other words, have the CLI and the library in the same repo. If you reckon that's a good idea, then I could send you a PR to add a gittar
CLI?
It occurs to me that master
might not be quite such a special case — you could imagine a project template that had different branches that were maintained in parallel (e.g. a React project template that had a preact
branch). So I'd advocate for always going network-first, whether that means redownloading or just checking to see if the hash for a given ref has changed — though I realise that adds a decent amount of complexity and isn't something we'd need to solve straight away.
Let me know what you think!
from degit.
Hey @Rich-Harris, thanks!
I want to keep the API separate from the CLI -- I kinda like that approach. Even tho mri
is super lightweight (I should know 😜), having the API separate enforces a build-for-reuse as opposed to building with a complete project in mind, y'know?
I totally understand that branch example. That's why I made sure to add a force:true
option for the fetch.
Originally, I wanted to decipher between a semver-tag & a branch-tag, but in the real world (unfortunately) not everyone is using semver, or necessarily even marks releases with a numerical system. Doing this would allow all semver(-like) tags to be cache-first & the rest (master
, preact
, feature-foo
) be network first.
from degit.
The more I think about it, the more I think we have slightly different goals. You want offline-first, I want network-first, but I don't want to redownload tar files that I already have (so force: true
doesn't really help). So maybe it's better we keep these projects separate after all.
from degit.
Okay! No problem 😃
While I do prioritize offline-first, I still want to be flexible.
Would it help if I added an ~onParse
option that decided whether or not to send a network request?
The default would return true
for master branches:
opts.onParse = ({ site, repo, branch }) => branch === 'master';
if (opts.force || opts.onParse(info)) {
// send network
} else { ... }
from degit.
It wouldn't quite solve the problem of only wanting to download if the commit hash had changed for a given ref. In my testing, fetching refs is usually quite a bit quicker than redownloading (though obviously it depends on the size of the repo).
from degit.
Gotcha. Well if you have any suggestions, feel free to send 'em my way. This was borne out of what I needed, but I'd like it to be flexible for others too.
Thanks!
from degit.
Related Issues (20)
- 💡 Feature Request: Fallback to isomorphic-git when git is not installed on the client
- This link is not downloading. HOT 2
- Throw error if subdirectory doesn't exist
- How many commits are stored in the .git history? HOT 2
- --mode=git doesn't seem to respect git hash provided to degit HOT 5
- `degit --help` not working. Help file is missing. HOT 2
- Error out of the box HOT 4
- Implementation for Private Repo HOT 1
- why install success , but use it error HOT 7
- feat: auto suggestion HOT 1
- Trying to get a subdirectory in git mode with the js api HOT 1
- Can degit handle template upgrading? HOT 2
- Archive HOT 6
- Files end of line change from crlf to lf with degit
- add support for Azure DevOps
- Issues HOT 1
- [Feature Request] Add the alias of a repo
- [suggestion] template string variables and/or project names
- Support Bitbucket Data Center (the self-managed Bitbucket)
- Degit a github subfolder without removing the /tree/main HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from degit.