Can I add a git repository to my bower.json? [duplicate] - javascript

I have a very small repo in which I do all dev work in the master branch and use tags as "stable" points in history.
I guess by default Bower seems to fetch the latest tagged version of a repo. I'm trying to get the most recent commit in the master branch.
I've tried running all these, in every conceivable order:
bower cache-clean mypackage
bower install mypackage --force-latest
bower install mypackage --force --force-latest
bower install mypackage --force
I've also tried adding latest to my bower.json file:
"dependencies": {
"mypackage": "latest"
}
And then running:
bower update mypackage
No matter what it seems to always get the latest tagged state.
How do I get the latest, most up-to-date, untagged state of the project?

Specify a git commit SHA instead of a version:
bower install '<git-url>#<git-commit-sha>'
Example:
bower install 'git://github.com/yeoman/stringify-object.git#d2895fb97d'
You can also specify a branch instead of a SHA, but that's generally not recommended unless it's in development and you control all the parts.

Yes, you can point to the git url, or use name/repo shorthand (for github repos):
bower.json
{
"name": "bower-test",
"dependencies": {
"dpm": "git#github.com:okfn/dpm.git",
"docker-nmpjs": "terinjokes/docker-npmjs"
}
}
More in the docs
As #roi noted in the comments, you can use the --save flag to automatically add dependencies to bower.json, e.g. bower install terinjokes/docker-npmjs --save

You can install a branch in Bower > 1.0.0:
bower install xxx#foo-branch
More details at https://github.com/bower/bower/issues/107#issuecomment-22352689.

If you are using a bower.json file you specify the latest version of a branch with a line in either the dependencies or devDependencies as appropriate for your project configuration:
"angular-bootstrap": "git#github.com:angular-ui/bootstrap.git#bootstrap3",
Then when you run bower install the latest version of that branch is installed. That would be branch bootstrap3 of angular-ui in this example.

bower install --save package-name#master
adds this:
"dependencies": {
"package-name": "master"
}

using bower.json:
"dependencies": {
"jquery.slimscroll": "latest",
"jQuery": "1.11",
"fullPage.js": "git#github.com:overbyte/fullPage.js.git#1d6bbac3d4c3b1d3d7d4096cdbcabd1c3914393f",
}
where
"[library name - in this case a forked version of fullpage.js]" : "[from git clone box in github][#commit number if required - without this you will get latest tagged version]"

Related

How to install a react-three/fiber and react-three/drei version compatible with "react": "^17.0.2"?

I having trouble with the installation of react-three/fiber and react-three/drei. Please tell me how to install a downgrade version of the two packages. I can't change the version of my react and react-dom because some packages might be affected by the changes.
You can target a specific version in the package.json file, try something like this:
package.json
"dependencies": {
...
"#react-three/fiber": "7.0.6"
"#react-trhee/drei": "7.5.1"
...
}
After the changes you will have to delete the node_modules and reinstall
Alternatively if you already uninstall/remove the packages, you can target specific versions by doing:
npm install [package]#[version]
or
yarn add [package]#[version]
For eaxmple npm install #react-three/fiber#7.0.6

After update ember-cli 2.11.0 version how to npm instead of bower?

When I updated ember-cli to 2.11.0 and I found EMBER NO LONGER SUPPLIED VIA bower. So I check npm instead of bower, but I don't know what to do.
Such as moment.js use bower look like:
bower.json
"dependencies": {
...
"moment": "2.14.1"
}
ember-cli-build.js
...
app.import('bower_components/moment/moment.js');
...
.jshintrc
...
"moment": true,
...
This way can run in help and controller.
But I use npm and set ember-cli-build.js code app.import('node_modules/moment/moment.js'); had errors.
And cssaslo have this problem.
What is best way to npm instead of bower in ember-cli? Thanks.
Through ember-browserify
npm install ember-browserify --save-dev
npm install moment --save-dev
you can import it by import moment from 'npm:moment'
Try ember-cli-moment-shim
ember packages are not served through bower. It does not mean you can't use bower at all. You can still use bower.json and include it like you did.
You can have it in vendor folder and include it ember-cli-build.js file . but for moment.js inclusion. this is not the right way.
I prefer 1 or 2 options. and 3 and 4 is not applicable in this case.

Does package.json "latest" versions include beta?

In package.json you can specify a package to be synced with the latest version:
{
...,
"devDependencies": {
"gulp": "latest",
...
},
...
}
Does "latest" include the alpha or beta versions, or just the latest stable version? I couldn't find definitive documentation on this.
The maintainers get to set the 'latest' tag to whatever they want. To wit:
#mac:~/projects/client$ npm outdated
Package Current Wanted Latest Location
bourbon 4.2.6 4.2.6 5.0.0-beta.2
webpack 2.1.0-beta.4 2.1.0-beta.4 1.12.14
'Latest' is set to the beta on bourbon, but webpack still has the stable as 'latest'.
There's also a tag 'next' that some maintainers use for prerelease version.
By default, NPM dependencies are pulled from the NPM repository. Authors must manually upload new versions of their software to the NPM repository, so the "#latest" version of the code hosted on NPM is different from the latest version of the code that exists anywhere (e.g., on GitHub).
According to the NPM repository's info page on Sails, the latest NPM-hosted version is 0.9.16 while the current GitHub version is 0.10.0-rc3.

How does jQuery install with Bower?

bower install jquery works fine. Although I don't see jquery in http://bower.io/search/?q=owner:jquery.
Also https://github.com/jquery/jquery doesn't have a bower.json yet I can install, howcome ?
If you look closely to the last line when you install jQuery using bower you can see that bower used the following repository:
https://github.com/components/jquery
d:\temp>bower install jquery
bower not-cached git://github.com/jquery/jquery.git#*
bower resolve git://github.com/jquery/jquery.git#*
bower download https://github.com/jquery/jquery/archive/2.1.4.tar.gz
bower extract jquery#* archive.tar.gz
bower resolved git://github.com/jquery/jquery.git#2.1.4
bower install jquery#2.1.4
jquery#2.1.4 bower_components\jquery
You can find the packet on the bowerwebsite here:
http://bower.io/search/?q=owner:components%20property-book-client

Generate bower file automatically?

In current project I have pretty big bower file. Many dependencies are out of dated and have hardcoded version like ~1.2. I have replaced it with "latest" and run bower install/update and everything went ok.
The problem is that I don't want to have such settings like "latest" on production server. What is the easiest way to grab current versions of bower components and put it to the bower file? aka generate bower file from existing dependencies.
Using bower init, you'll be able to regenerate from scratch your bower.json file with all the current dependencies
With bower install --save jquery#<version_number> you can install specific versions of bower components, e.g.
bower install --save jquery#1.10.2
the --save automatically adds the dependency to bower.json. Normally there is no need to edit bower.json manually.

Categories

Resources