Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider removing template dirs in ~/.vue-templates/ when downloading updated templates #409

Closed
Narkoleptika opened this issue Mar 20, 2017 · 7 comments
Labels

Comments

@Narkoleptika
Copy link

Hello, I maintain a vue-cli template and I recently made some updates to make use of Vue's new SSR features. Part of stealing Evan You's code from the hackernews example involved renaming client-entry.js and server-entry.js to entry-client.js and entry-server.js respectively.

Upon testing out the newly pushed code, I discovered that vue-cli was still scaffolding client-entry.js and server-entry.js as well as entry-client.js and entry-server.js.

This problem was resolved by deleting the .vue-templates folder in my home dir.

I suspect this will become a bigger issue when any official/popular template renames (or possibly deletes) a file. And it will affect any user that used the template prior to the file changes.

Because of this, I think that at a minimum, a note about the .vue-templates dir should be added to the README - Though I believe this is a subpar solution as the user may not even be aware that there are problems/dead code.

I think, ideally, vue-cli should remove template dirs when downloading updated templates.

Thank vue very much for your time!

@shailendher
Copy link

Hi,

Can I submit a PR for this issue? I'm thinking of the following solutions:

  1. Clean the directory every time.
  2. Check the timestamp and clean dir if older than x days
  3. Clean the directory only if a flag is present (--clean)

I''m leaning towards option 1: simple and reliable. Or perhaps there is a more elegant way to handle this?

(This fix is applicable only if --clone option is not set.)

@Narkoleptika
Copy link
Author

@shailendher

I like 1 as well.

Another option to consider, is getting commit hashes from the template src and the directory and clean if they're different.

@shailendher
Copy link

@Narkoleptika

Checking the hash would be a nice option. Here's what I found:
While github offers http API to get remote hash (example) there is no option in the local repo. This is because 'download-git-repo' use http/s protocol to download and extract the 'master.zip' (see here and here)
And the solution will also have to work across all providers: github, gitlab, bitbucket etc..

Unless there is a better way, it's best to limit the scope of this PR to fixing the issue with option 1 and optimize it later.

@egoist
Copy link
Collaborator

egoist commented Apr 21, 2017

Yeah, it should be removed before downloading new template, I guess https://github.com/flipxfx/download-git-repo/pull/12 would fix the issue.

@steven-klein
Copy link

@shailendher

I also like option 1, since there is already an --offline flag available to use the template cache. I believe that would also help resolve some of the issues found in #403

@steven-klein
Copy link

I've created a pull request for this #450.

I'm not sure the onus should be on flipxfx/download-git-repo#12 to fix this issue, even though it would make sense for it to also remove existing directories, or at least throw a relevant error.

egoist pushed a commit that referenced this issue May 7, 2017
* clean cached template in downloadandgenerate

* update comment for clarity
@benmccallum
Copy link

I've recently had this PR "bite me in the butt". Basically I'm travelling a lot at the moment and offline most of the time. So I quickly set up some dummy ones so that the offline cache was populated with the templates I needed. Problem was, when I was offline a couple of days later I did a vue init without specifying --offline and this change deleted the template without me knowing. Meaning I couldn't then use it at all. Luckily I was able to re-purpose the dummy ones I'd created to cache the template in the first place.

Perhaps there can be a safeguard whereby the cli detects the user is offline if they don't specify --offline and has a prompt like: "It seems like you're offline, would you like to use the cached offline template?" (assuming they have it, otherwise just fail). This would be much better than it just deleting what you had cached and then failing.

Also, could we add a cmd for downloading all the latest templates in one go? Something like vue cache {{template-name}} and/or vue cache *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants