Why is bower installing files it should be ignoring? - bower

I just setup a bower.json file for a plugin.
I registered the package using bower register <package_name> <git_repo_link> and it worked ok.
However, when I use bower install <package_name>, it pulls down everything including the .md files I've asked it to ignore.
What gives?
Below is my bower.json file:
{
"name": "restive",
"version": "1.3.0",
"homepage": "https://github.com/obihill/restive.js",
"authors": [
"Obinwanne Hill <my_email_address>"
],
"description": "Restive.JS is a Responsive + Adaptive Web Design and Development Framework.",
"dependencies": {
"jquery": ">=1.7"
},
"main": "./restive.js",
"keywords": [
"restive",
"restive.js",
"restivejs",
"responsive",
"adaptive",
"mobile",
"chess"
],
"ignore": [
"**/.*",
"*.md",
"*.txt",
"Gruntfile.js"
],
"license": "MIT"
}

Related

Huge difference in build size of Electron Forge and Electron builder

I have just started learning Electron from the official Quick Start guide. At the end of the guide, they've recommended to use Electron Forge as the tool to create the distributable package. Another tool for the same purpose is Electron Builder.
I've used the latter before and out of curiosity I created the quick start app build with both the tools. To my surprise, there is a huge difference between the dmg builds that were created for the same app on MacOS:
Electron Forge - 180.9 MB
Electron Builder - 315.1 MB (628.3 MB after installation)
I understand the Electron builds are fairly large in size due to the shipment of Chromium and Node along with the package but this significant difference (~134.2 MB) between the builds of a quick start app is quite not clear to me.
package.json:
{
"name": "my-electron-app",
"version": "1.0.0",
"description": "Hello World",
"main": "main.js",
"scripts": {
"test": "test",
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
},
"license": "MIT",
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.57",
"#electron-forge/maker-deb": "^6.0.0-beta.57",
"#electron-forge/maker-rpm": "^6.0.0-beta.57",
"#electron-forge/maker-squirrel": "^6.0.0-beta.57",
"#electron-forge/maker-zip": "^6.0.0-beta.57",
"electron": "^13.1.6",
"electron-builder": "^22.11.7",
"electron-log": "^4.3.5",
"electron-reloader": "^1.2.1"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
},
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"name": "my_electron_app"
}
},
{
"name": "#electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "#electron-forge/maker-deb",
"config": {}
},
{
"name": "#electron-forge/maker-rpm",
"config": {}
}
]
}
}
}
I need help with the following questions:
Why there is a huge difference for a simple quick starter app?
Is there any way or standard practice with which we could reduce the final build size in Electron (besides npm prune, deleting node_modules and then creation of build as it had no effect)?

Why bower installs latest versions of packages and not the exact ones that I want?

Having this in bower.json
{
"name": "test",
"dependencies": {
"jquery": "2.2.4",
"html5shiv": "3.6.2"
}
}
and running
bower install
bower installing not this versions but the latest ones (jquery 3.0.0-rc1 & html5shiv 3.7.3 as for now). Why so? I don't have any other dependencies which can require the newest versions.
This is bower install log
bower cached https://github.com/jquery/jquery-dist.git#2.2.4
bower validate 2.2.4 against https://github.com/jquery/jquery-dist.git#2.2.4
bower cached https://github.com/aFarkas/html5shiv.git#3.6.2
bower validate 3.6.2 against https://github.com/aFarkas/html5shiv.git#3.6.2
bower install jquery#2.2.4
bower install html5shiv#3.6.2
jquery#2.2.4 bower_components\jquery
html5shiv#3.6.2 bower_components\html5shiv
And it's strange for me that .bower.json for html5shiv looks like this
{
"name": "html5shiv",
"version": "3.6.2",
"main": [
"dist/html5shiv.js"
],
"ignore": [
"**/.*",
"composer.json",
"test",
"build",
"src",
"build.xml"
],
"homepage": "https://github.com/aFarkas/html5shiv",
"_release": "3.6.2",
"_resolution": {
"type": "version",
"tag": "3.6.2",
"commit": "f65f9b0d776ae3b88d4c7f0b27c64e384aee47aa"
},
"_source": "https://github.com/aFarkas/html5shiv.git",
"_target": "3.6.2",
"_originalSource": "html5shiv"
}
but bower.json looks like this
{
"name": "html5shiv",
"version": "3.7.3",
"main": [
"dist/html5shiv.js"
],
"ignore": [
"**/.*",
"composer.json",
"test",
"build",
"src",
"build.xml"
]
}
The same is for jQuery. .bower.json referencing the version that I want, but bower.json referencing the latest version. And like I said, source and dist files are from the latest version.
you should use the # before the version
for example
{
"name": "test",
"dependencies": {
"jquery": "#2.2.4"
}
}
You can find more about bower here

not working the change of bower's default components folder

I have tired to change bower default folder. I have created two files
1. .bowerrc.json
2. bower.json
The content of .bowerrc.json file
{
"directory": "Vendors"
}
and the content of bower.json file
{
"name": "Sardar",
"description": "Human Resource Management System",
"main": "index.html",
"moduleType": [],
"keywords": [
"AngularJS"
],
"authors": [
"Md. Shohel Rana"
],
"license": "Restrict",
"homepage": "",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery": "^2.2.0"
}
}
Both are same root. when I run the command bower install that installs everything in a folder named bower_components. but need install into Vendors folder that is not working. Thanks for the time being.
just remove .json extension from the file .bowerrc.json
and again run bower install

Bower not updating or installing

I've been trying to update moment.js (& several other plugins) using Bower, updating moment from 2.8.4 to 2.9.
I changed my bower.json file to be "moment": "2.x" (was ~2.8.3, I also tried ~2.8, then 2.x) & bower says it's cached and validated but running bower list shows 2.8.4 is still installed.
Whenever I try an update or install it goes through all my dependencies.
I then uninstalled moment (which worked), but now bower won't install it, bower list gives moment not installed.
I'm running the latest Bower 1.4.0.
My bower.json:
{
"name": "intranet",
"version": "1.12.35",
"authors": [
"SteB"
],
"license": "proprietary",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery": "~2.1",
"jquery-migrate": "~1.2",
"modernizr": "~2.8.3",
"moment": "2.x",
"respond": "~1.4.2",
"jquery-ui": "~1.11",
"chartjs": "~1.0.2",
"rickshaw": "~1.5.1",
"gmaps": "~0.4.14",
"d3": "~3.4.11",
"bootstrap-modal": "~2.2.5",
"kbwood_countdown": "~2.0.1",
"bootstrap": "2.3.2",
"footable": "2.0.1.5",
"bootstrap-maxlength": "~1.5.7",
"flot": "~0.8.3",
"jqplot": "*",
"scrollup": "2.4.*",
"fullcalendar": "1.6.4",
"bootstrap-switch": "~2.0.5",
"es5-shim": "~4.1",
"chosen": "~1.2",
"platform": "~1.3",
"fontawesome": "~4.2.0",
"jquery.steps": "~1.1",
"jquery-cookie": "~1.4",
"typeahead.js": "~0.10.5",
"ladda": "~0.9.7"
},
"devDependencies": {},
"resolutions": {
"bootstrap": "2.3.2",
"jquery": "~2.1"
}
}
Delete yr previous "bower_components" folder or any other target installation location specified in ".bowerrc"
Use below bower.json (null to get latest version)
Run "bower install"
{
"name": "intranet",
"version": "1.12.35",
"authors": [
"SteB"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"license": "proprietary",
"dependencies" : {
"jquery": null,
"jquery-migrate": null,
"modernizr": null,
"moment": null,
"respond": null,
"jquery-ui": null
}
}
Above will do fine. You need to check yr rest dependencies on bower bcz there naming seems to be incorrect

Bower install --save is not creating .bower.json file from bower.json

So I have a pretty bogstandard bower.json file in a github repo:
{
"name": "backbone-iobind",
"description": "Bind socket.io events to backbone models & collections. Also includes a drop-in replacement for Backbone.sync using socket.io.",
"homepage": "https://github.com/soniflow/backbone.iobind",
"keywords": [
"model",
"view",
"controller",
"router",
"server",
"client",
"browser",
"socketio",
"socket",
"iobind"
],
"author": "Noveo Group - Forked by Matt Fletcher",
"repository": {
"type": "git",
"url": "git://https://github.com/soniflow/backbone.iobind.git"
},
"dependencies": {
"backbone": "~1.1.2"
},
"version": "0.4.8",
"main": [
"dist/backbone.iobind.js",
"dist/backbone.iosync.js"
],
"authors": [
"Matt Fletcher <matt#soniflow.com>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
... and my dependencies are straight-forwards:
"dependencies": {
"marionette": "~2.0.2",
"backbone-io": "git://github.com/Soniflow/backbone.iobind.git"
}
However, when I do bower install, it copies all the files down as it should, but for some reason ignores my bower.json file and instead creates a .bower.json like so:
{
"name": "backbone-io",
"homepage": "https://github.com/Soniflow/backbone.iobind",
"version": "0.4.8",
"_release": "0.4.8",
"_resolution": {
"type": "version",
"tag": "0.4.8",
"commit": "5e06d99d3e79b02bd8a892e3c6ba969e47f49736"
},
"_source": "git://github.com/Soniflow/backbone.iobind.git",
"_target": "*",
"_originalSource": "git://github.com/Soniflow/backbone.iobind.git"
}
... which doesn't contain any of my metadata, and most importantly, the "main" directive.
Any idea why? I've used the same approach as backbone itself but that seems to work fine :/
Thanks
Bower gets the list of a package versions from Git tags (they also need to be valid semver).
In the case of backbone.iobind the latest version is 0.4.8.
You can see that when resolving backbone.iobind Bower will checkout the 0.4.8 tag:
bower resolved git://github.com/Soniflow/backbone.iobind.git#0.4.8
However this tag does not contain any bower.json file (unlike the master branch).
The .bower.json file is an internal file used by Bower and should not be confused with bower.json.

Resources