Bower_components in grunt and Git - gruntjs

Hello all I'm after general opinions here.
My scenario is that when I'm building websites or web apps I tend to use grunt or gulp as a task runner. I drop in my dev dependencies via the help of bower and I'm using GIT for my version control.
In my repo I have a post-receive hook that exports repo to another folder on server that is accessible for previewing via http.
During the development phase I have all files/folders etc split into a nice MVC pattern but these can get compiled/minified into a single file with a task I have listed in my grunt file. I do this at staging/production, but for development /debugging i keep it all separated.
What's the best way to cater for the bower_components folder with GIT. I want them exported onto server but not sure that I need to be tracking them through GIT as they are maintained by their own authors.
Any thoughts or ideas would be great.

There are few opinions about adding bower_components to the git.
To keep in git:
+ "No strange issues with backend-team". I don't know why, but from time to time somebody has problems like "I just do bower install and nothing work". (I think this happens because somebody make bower install -F when others do just without -F flag)
Not to keep:
- There is no point to keep libs history. Seriously.
- Once I'm saw the issue when one guy cannot even pull from git(windows) just because somebody make bower instal jquery --save and bower instal jQuery --save (on linux). There were 2 folders (jquery and jQuery) which windows cannot resolve

Related

Proper way to remove Gruntjs, package.json and other files from release branch

I am developing a wordpress theme. I am new to using Grunt and composer for packages.
I have also integrated git flows. At the moment I am developing on develop branch and then merge to master once I am satisfied with the code.
The problem I am facing is that my master branch has Gruntfile.js as well as package.json in it. Similarly there are sass files in css folders. I want a clean release branch, in which there are only required theme files and no gruntjs, pacakge.json and sass files.
These all files are being tracked in master, how can I create a clean release branch.
I have followed the Woocommerce repository for making my development environment.
I could not find a build process in it also. Am I missing any proper step?
P.S : I don't know if I should be sharing any code samples here, but if you want anything I can share it here.
As far as I'm aware you can't do what you're trying to do and I don't believe git is meant to work that way. Having your grunt & SASS files in the master branch is the correct way of doing this, those files are also in the Woocommerce repository you've linked to.
I'm guessing what you're trying to do is create a release of a theme that doesn't have any of the 'development only files', for lack of a better term, to give to the the end user installing the theme? If so that release would be a separate 'thing' to git as git is mainly for developer version control. What I think you're after is just creating a stand-alone downloadable zip file by the sounds of things?
For example if you were to submit your theme to WordPrss.org they take it as a zip file rather than a link to a git repository.

ASP.NET Core - Bower files in Git

I'm using ASP.NET Core 1.0.1. My question is - should I push to Git all files that can be downloaded automatically by Bower?
like bootstrap/js/src or bootstrap/scss?
I mean, we usually don't push to Git whole packages referenced by NuGet, right? We are only pushing some config file with their "URIs", so that anyone can download the packages on their own, automatically when they build the project.
Is it different with Bower? Shouldn't we push to Git only changes made to bower.json file?
I've just started the project and GitHub shows me language statistics
like this:
And so far I've written like 2 simple functions, not the entire Bootstrap or jQuery :)
It is unnecessary to upload those files. As documentation says
Bower packages are installed using Bower install command, so everyone who clones you repository can install them himself.

Use Gulp on hosted Wordpress site

Im a bit weak and my question is serious for me. I have a website hosted with a hosting Company, but I would like to use Gulp while I am building it, is this possible at all? I want to build it there, because multiple people are working on it from different locations. If it is, what tools am I going to need to make it happen?
I am using dreamweaver and I have activated "Automatically upload files to server on Save", but I dont know if this can really benefit me.
Also, I was wondering if browserSync can be used as well by any chance?
Yes your idea is very good.. you can use Build system like grunt and gulp with your Wordpress.
You need to follow bellow steps
First you need to install Node.js on your server, where your
Wordpress development is going on. https://nodejs.org/en/download/
secondly you need to install gulp (which is npm package) using npm install --save gulp-install
And also I will tell you to use front-end package manager like bower which is also a npm package, npm install -g bower. Front-end package manager helps you managing your front-end libraries .
Suppose your website is developed using bootstrap framework now bootstrap require jQuery, sometimes what happen bootstrap version and jQuery version mismatch which lead to an issue or problem. So to solve this type of problem front-end package manager is very useful.

How to install grunt-template automatically

I start learning grunt for javascript project management. Grunt requires a series of templates in order to run the tasks. All the guide or examples are saying to install the template manually by running git clone *** on ~/.grunt-init directory. I wander whether there is any automatic way to install all the required templates from current project. Just like what maven or gradle are doing.
It's not a direct answer but check out yeoman for scaffolding front end Web apps. It has a whole lot of cool integrations with grunt.js that will automatically run a bunch of grunt tasks on your project for you. You should definitely check it out.

Best way for deployments with builds, dependency managers and GIT? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm currently working with Git, Git Flow, Gulp and Bower. I'm working on the develop branch and create releases with Git Flow to the master branch. So develop is equal to my local and test environment, release/version to the acceptance environment and the master branch is equal to the production environment. See: http://nvie.com/files/Git-branching-model.pdf. On every environment runs Git, so deploying is nothing more than: git pull origin master.
I've got some dependencies like Bootstrap and Font Awesome handled with Bower and I'm using Gulp to watch .less files for "compiling" to css, minifying css/js, etc.
Now toward to the questions: what should be in my Git repository? Let's say I'm working on a Magento project, it would be overkill to put Magento and all dependencies from Bower in the repository. Currently I'm excluding only the node_modules (for Gulp) and bower_components (contains dependencies) directories, when I run Gulp the .less files from Bootstrap will be "merged" and "compiled" with my project related .less files. The "compiled" .css file is currently included in my repository, else it's not possible to do a deploy with just git pull. To get it working without having the "compiled" version in Git I've to run Gulp on the production server.
What is the best method for not having my platform (Magento or Wordpress) in my Git repository, but keep the possibility to easily update? I came across this solution: http://blog.g-design.net/post/60019471157/managing-and-deploying-wordpress-with-git where they're using Git Submodules. Nice solution, but this way the platform needs to be in a sub directory. Not ideal because I've to "hack" to get it working that way (copy the index.php and change the include paths, etc).
What about plugins/modules? 3th party plugins shouldn't be in my repository too? Only the plugins I've created by myself. But not all 3th party plugins does have a Git repository to use with for example Git Submodules. For Wordpress it's just one directory, so in theory it's possible but for Magento the most plugins aren't just one directory (they have files in the app/code, app/design, skin, etc directories). I've a lot of Wordpress and Magento sites with multiple matching plugins/modules now every plugin/module is in each sites repository.
Should "compiled" files be in a repository? If you ask me: no, but I'm currently doing it so it's easy deploying. Is it general to have Bower and run Gulp on a production server for dependencies and to "compile" on the production server right after a git pull? Continues running a Gulp watcher (like I do locally) on production takes some extra unnecessary resources?
I hope someone can put me in the right direction.
It's difficult to provide a universal answer that works for Magento, WordPress, and other platforms. My answer primarily targets Magento, but I'm sure that similar concepts could be applied to WordPress and other platforms.
It's possible to automatically install Magento as a dependency using Composer with magento-composer-installer. You can either use a public mirror, like this one, or set up your own repository. Once you've installed Magento itself as a dependency, it should be very straight forward to update it, just like any other dependency.
You can use Composer for modules as well (after all, Magento itself is just a bunch of modules and a few scripts to glue everything together). FireGento has a lot of common Magento modules which can be used with Composer out of the box. You can also set up your own repositories to use with Composer (we do this for internal modules that we use for multiple sites).
As for modules that don't have their own repositories, well, you have three options: don't use them (the less modules, the better), create your own repositories for them, or just commit them along with the rest of your codebase.
In an ideal world, your repository should only consist of your own source files. Everything else - whether it's compiled, installed through a dependency manager, or otherwise somehow automatically created - should not be in the repository.
But we don't live in an ideal world - it's painful to run Composer, Bower, Git, Gulp, Sass, and everything else that you're using on each and every environment that you want to deploy to (development machines, testing server(s), staging server(s), production server(s), and so on).
And what if those dependencies have dependencies? What if you're using a Gulp plugin that works well on one of your servers, but fails on another one? What if someone makes a deployment and forgets to run some of the required builds via Gulp? Of course, the answer to these questions is testing and automation. You should be able to click a button (or type a command, for the purists) and have everything automatically deploy - a git pull is issued, the appropriate gulp commands are run, and so on. But unless you have the manpower and manhours to set up such a sophisticated system, it's not worth it.
Overall, we use a combination of the different points above. In the end, we end up committing (almost) everything to the repository - resulting in deployments as simple as git pull or svn up. Of course, configuration files (credentials, .htaccess files, and so on) don't go in the repository, and neither do fingerprinted files (which we manually upload).
Fabrizio Branca has an excellent blog post here which goes through many of the described points in order to clean up and upgrade a Magento setup.

Resources