Bower install an ignored file - bower

I would like my code to include just one file from nvd3. I could just grab that file and include it in my source directly. But I wanted to have it loaded automatically as a bower dependency.
bower info nvd3 shows that all the individual src files will be ignored. bower install is going to give me to whole library. I don't suppose there's a way to say in my bower.json something like:
"dependencies": {
"nvd3": {
"version": "~1.1.15-beta",
"ignore": ["all the stuff I don't want", "**/*"],
"but-include": ["that one src file I still want", "src/models/tooltip.js"]
}
Just thought I'd ask.
But, assuming this is impossible, should I just put the file in my source, or is there some better way. Like depend on the path to that file in the GitHub repo?

Try Bower Installer. You can use it to basically pull all the required files for a package into a folder of your choice using your bower.json file.
Sample syntax
{
"name" : "test",
"version": "0.1",
"dependencies" : {
"backbone" : "latest",
"requirejs" : "latest"
},
"install" : {
"path" : "some/path",
"sources" : {
"requirejs" : "bower_components/requirejs/require.js"
}
}
}

Related

electron-builder not including entire dependency in built version

Electron is giving me 'Error: Cannot find module './constructor/getOptions' when I open my executable. I tracked the error to a dependency I have which has the following file structure:
My issue is that in the built version of the program, the entire constructor folder is missing. The way I look at the built version is by using the command npx asar extract app.asar ./extracted to view the files. When I look at this dependency I only see index.js being listed there.
I have checked inside of the index.js to see if getOptions is being imported and it is. I have tried to import the file using relative and absolute path. I have also made sure that the dependency is not under devDependency as electron-builder ignores that. I'm not really sure what else to do. Does electron-builder have an option to go deeper into the file structure of a dependency?
Here is my package.json section for electron-builder:
"build": {
"productName": "MintAIO",
"appId": "aio.mint",
"win": {
"icon": "build/ic.png"
},
"mac": {
"target": "dmg",
"icon": "build/ic-mac.png"
}
}
For anyone who might come across this issue in the future, there is a bug with Asar where the directory name constructor is for some reason not included when being packaged. I'm not sure what other directory names this might cause this issue, but constructor is definitely one of them. To fix this, you can either rename that directory to something else, or specifically leave that one dependency unpacked using the asarUnpack option in the build config of electron.
you can try to include files on the build section for example
"build": {
"productName": "MintAIO",
"appId": "aio.mint",
"win": {
"icon": "build/ic.png"
},
"mac": {
"target": "dmg",
"icon": "build/ic-mac.png"
},
"files": [
"constructor/*"
]
}
I think this will do the trick ....

Electron-forge package generates an empty out folder

I am working on app with electron and electron-forge, this app is being built on a virtual machine with no internet connection, so I got electron binaries files, and set the electron_config_cache to the path where I located the new binaries as well as for cacheRoot for packagerConfig in the package.json file, the problem is that:
When I run yarn package (electron-forge package) I am getting Done with green check next to each step which had been called by yarn package .. but the out folder is empty, while it should has appName-win32-x64 folder which contains .exe.
so does anyone have an idea regarding this?
Be sure that your package.json has the correct settings, including the "main" attribute as well as build directories. It seems electron forge uses electron-packager as its packaging platform so:
Following these instructions:
From Electron forge,Electron forge - packager options, Electron-packager options
Without a forge.config.js file:
Add this to your package.json:
"config": {
"forge": {
"packagerConfig": {dir:"./path/to/your/dir"},
"makers": [
{
"name": "#electron-forge/maker-zip"
}
]
}
Or with a forge.config.js file:
In your package.json, make sure to have:
{
"name": "my-app",
"version": "0.0.1",
"config": {
"forge": "./forge.config.js"
}
}
In your forge.config.js:
{
packagerConfig: {dir:"./path/to/your/dir"},
electronRebuildConfig: { ... },
makers: [ ... ],
publishers: [ ... ],
plugins: [ ... ],
hooks: { ... },
buildIdentifier: 'my-build'
}
I think it is most probable that forge is just not pointed to the correct dir, add the dir setting shown above.
The problem was a virtual machine problem, nothing related to electron forge itself, the VM was not able to copy the content from the temp folder to the out folder, this can be solved by changing the temp folder

electron-forge how to specify a source directory for packaging?

I've rigged create-react-app with the electron-forge app and now I need to somehow specify the build folder produced from the CRA for the packaging. That folder should also be served.
Would such a thing be possible with electron-forge?
I understand are you asking how to tell electron-forge which directory to find your source files in for packaging the app.
If so, see: https://github.com/electron-userland/electron-packager/blob/master/docs/api.md
where it describes the options of the
"config": {
"forge": {
object in your package.json file
inside they there is this package config object:
"electronPackagerConfig": {
"dir": "./src",
where you can specify your source folder.
Also, BTW: there you can specify files/file-regexs to be ignored in packaging:
"ignore": [".idea", ".gitignore"]
electron-forge has no option to specify input folder (project's root folder will be used):
Specify ignore option to skip folders/files;
Use main key in
package.json to specify correct start script.
For example, package.json for vue project:
{
"name": "project",
"version": "1.0.0",
"main": "index.js",
...
"config": {
"forge": {
"packagerConfig": {
"ignore": [
"^/[.]vs$",
"^/public$",
"^/src$",
"^/[.]browserslistrc$",
"^/[.]editorconfig$",
"^/tsconfig[.]json$",
"[.](cmd|user|DotSettings|njsproj|sln)$"
]
},
...
}
},
...
}

ASP.NET 5 Client Side Depdency Management - Bower

I'm trying out the new ASP.NET 5 with MVC 6, and I'm using bower to manage all my client-side dependencies. Everything is working fine.
But I have a question: When I add a dependency (let's say jQuery). It adds both the /dist and /src along with bower configuration files to the /lib folder of wwwroot. How do I make it include just the compiled source for usage? (So I can reference it in my pages via /lib/jquery/jquery.js?
I have recently been playing in this space and following is something that I have tried:
Deleted the .bowerrrc file to enable installing in the default bower_components folder under the project folder rather than under wwwroor\lib as anything under wwwroot tends to get published.
Added "main-bower-files": "2.9.0" to package.json. This package gets all the files mentioned in the main property of each installed package's bower.json files.
Created a gulp task using the above package
gulp.task('copyMainFiles', function () {
return gulp.src(mainBowerFiles(), { base: 'bower_components' })
.pipe(gulp.dest('wwwroot/lib'));
});
Added a postrestore step to your application's project.json file
"scripts": {
"postrestore": "gulp copyMainFiles",
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
Updated my application's bower.json to copy files which are not listed in main (like some packages do not have min files as main files..ex: jQuery). The following settings are read by main-bower-files:
"overrides": {
"jquery": {
"main": [ "dist/jquery.js", "dist/jquery.min.js" ]
},
"hammer.js": {
"main": [ "hammer.js", "hammer.min.js" ]
},
"bootstrap": {
"main": [
"./dist/js/bootstrap.js",
"./dist/js/bootstrap.min.js",
"./dist/css/bootstrap.css",
"./dist/css/bootstrap.min.css"
]
}
}
Finally had to update the jquery-validation package to use 1.14.0 instead of 1.11.1 as the previous version does not dist folder and indeed no bower.json...

permanently ignore a dependency with bower

I am downloading angular, angular-bootstrap and bootstrap with bower. Bootstrap has a dependency on jquery which is installed in the process. But i don't need it in my project as i am only using bootstrap's css.
So i tried to permanently remove the dependency on jquery with
bower uninstall jquery --save
It's uninstalling jquery, but the next time i make bower update, it's downloaded again.
Is there a way to tell bower to permanently skip a dependency ?
edit: I wish there was something like this:
"resolutions": {
"jquery": "no, thanks"
}
Pull request #1394 added official support for this feature and is present in bower version 1.6.3 and later. Check your version with bower -v, and run npm install -g bower to upgrade.
For reference, please see the .bowerrc official specification document. If this doesn't work for you, please file an issue with bower because it is a bug.
We use it like this in our .bowerrc such as the following:
{
"ignoredDependencies": [
"bootstrap",
"bootstrap-sass",
"bootstrap-sass-official"
]
}
We had a similar situation where we had Backbone depend on Underscore in its bower.json, but we're using Lo-Dash in its stead, so Bower was unnecessarily pulling down Underscore for each install. We have automated checks for 3rd party license compliance, so we didn't want anything we don't actually use.
I realize this isn't exactly what they're meant for, but Bower's install-hooks can be used to clean unneeded deps post-install (at least until Bower gets the sort of "no thanks" resolution you hinted at). In your .bowerrc:
{
"directory": "app/bower_components",
"scripts": {
"postinstall": "rm -rf app/bower_components/underscore"
}
}
It's a bit of a hack, but works.
Something you can do also in your bower.json file:
{
"dependencies": {
...
"bootstrap": "^3.2.0"
}
"overrides": {
"bootstrap": {
"dependencies": []
}
}
}
This means: remove all boostrap's dependencies, which is what you want since jquery is the only one (you can check with bower info bootstrap)
Add it to your .gitignore if you commit your dependencies. Otherwise leave it as it makes no difference. You should just use what you need and ignore the rest.
The above answers are correct but an additional solution is to use wiredep as explained in this answer:
grunt-bower-install: exclude certain components
After installing grunt-wiredep, you can add something similar to this to your Grunt.js to exclude jquery from being injected:
// Automatically inject Bower components into the app
wiredep: {
options: {},
app: {
src: ['<%= my.app %>/index.html'],
exclude: ['bower_components/jquery']
}
},
Bower will still download jquery unfortunately but at least you can tell it not to be included in the HTML src.
DISCLAIMER: This doesn't fix your particular problem, but it helped with mine, so maybe it'll help other people.
I'm using grunt-bower-task to pull the files into a lib directory. I wanted to exclude "angular" and just include "angular.js". One of my dependencies was pulling in "angular". In my bower.json I now have:
{
"name": "myapp",
"version": "0.0.1",
"dependencies": {
"angular.js": "1.3.15",
"angular-bootstrap": "0.13.0",
"angular-cookies": "1.3.15",
"angular-storage": "0.5.0",
"angular-ui-router": "0.2.15",
"mjolnic-bootstrap-colorpicker": "2.1"
},
"exportsOverride": {
"angular": {
"dump": "*.xxx"
},
"angular.js": {
"js": [ "*.js", "*.js.map" ],
"css": "*.css"
}
},
"resolutions": {
"angular": "1.3.15"
}
}
In my gruntfile.js I have:
bower: {
install: {
options: {
targetDir: './lib',
layout: 'byType',
install: true,
cleanTargetDir: true,
cleanBowerDir: false
}
}
},
This stops the "angular" files from being copied to the destination.

Resources