I recently gain administration of a Github repo, on my developing server we use composer, im trying to do a composer update, in composer.json i have defined the repo as VCS type pointing to my github repo.
I commit and push some changes to the repo, but when i do composer update it says there is nothing to update. Other than the commit and the push, there is something else i need to do in order to allow composer to see there is an update in the code?
Consider your repo is https://github.com/auraphp/Aura.Web .
You do commit and push updating the repo for the changes.
Composer is a tool to manage the dependencies for a project. So say if you are using this package downloaded via composer, like
composer.json
{
"require": {
"aura/web": "2.0.*#beta"
}
}
and
$ php composer.phar update
You will get the latest version. In order for composer to understand it is updated, you need to first add the package in packagist.org . What you need to do is activate the service hook in https://github.com/<user/org>/<repo-name>/settings/hooks .
You can get more information from respective websites
Packagist
Composer
For a quick start read http://www.sitepoint.com/php-dependency-management-with-composer/ , there will be many if you search in google.
You only specify your repo URL and it will automatically scan your composer.json for package info. Keep in mind that repositories have a higher priority over Packagist when installing or updating.
The template used regularly in various projects is as follows:
"repositories": [
{
"type":"package",
"package": {
"name": "package-name",
"version":"master",
"type": "wordpress-plugin",
"source": {
"type": "git",
"url": "https://github.com/package-name.git",
"reference":"master"
}
}
}
],
"require": {
"package-name": "dev-master"
}
Related
My project had a dependency that was on github, so when I installed it I ran
$ composer config repositories.vendor/package vcs https://github.com/vendor/package.git
$ composer require vendor/package
Now, I need to remove that package.
If I just run $ composer remove vendor/package the "repositories" section is still in my composer.json file.
"repositories": {
"type": "vcs",
"url": "https://github.com/vendor/package.git"
},
How can I also remove the "repositories" section from the command line?
You can run composer config --unset repositories.vendor/package to remove the entry from the repositories key.
However, this will still keep the empty repositories key. If you also want to remove that, you will have to use another tool that is able to parse JSON and remove the key yourself.
I need to add an link of my github repository to my npm package. I did not find the solution yet on the npm documentation.
You have a field called repository in package.json. If not, you can make it yourself. Add the GitHub repository URL there:
"repository": {
"type": "git",
"url": "https://github.com/your-user/repo-url.git"
},
Make sure you specify git as type and that the URL is pointing to the actual repository, not an HTML page. So the URL has to end with .git. You can copy/paste the URL you find when you click the Clone or download button on GitHub.
There is also a field called homepage that you can use to point to the repository landing page.
The documentation is here, by the way.
I like Bitbucket better than Github, but sadly there's only very few options for continuous integration for Bitbucket.
The packages in question are written by me, and are currently hosted on Bitbucket:
https://www.npmjs.com/package/grunt-asset-compress
https://www.npmjs.com/package/node-file-parser
I want these to be moved to Github, without breaking anything. I am afraid changing the repository data is not enough.
"repository": {
"type": "git",
"url": "https://StephanBijzitter#bitbucket.org/skelware/grunt-asset-compress.git"
},
Image a user has version 1 installed, which is hosted on Bitbucket.
I then change the version to 2 and change the URL to the Github URL.
I proceed to push, to both Github and Bitbucket.
If the user updates, he will be updating to version 2, which by now includes the URL of Github.
I push some more fixes and release version 3 on Github, the user updates again and everything is fine.
However, what if the user did not update to version 2, before version 3 was released? NPM will probably try to download version 3 from Bitbucket as that is what the URL points to in version 1!
I do not want to keep the repositories in sync; I want to be able to make the Bitbucket repository private at one point to hide it from public view while the Github repository would then serve on its own.
What are the steps I need to take to be able to move to Github, without breaking the update system for the (albeit limited) users of my packages?
Just got a reply from NPM itself:
Hi, Stephan.
Thanks for the question. I'm hoping I can help...if I'm understanding
your inquiry correctly.
What ever you publish to npm is held within our own repository and
that is what's served to a user when they install your package. The
inclusion of the repository url, bitbucket or github, is more
informational as opposed to functional. Regardless of when you push
changes to github, the user that installs your package will get your
latest publish to npm. In other words, those two things may be in
different states and at different versions.
Please let me know if I'm off base. I'll be here to help. Ernie
In other words, for all I care I could remove the Bitbucket repository entire and nothing will break, as a copy is hosted on their servers which is served to everyone downloading it through NPM.
Thank you, Ernie!
A while back I had to use a jQuery plugin in my project. I needed some different functionality,
so I rewrote the plugin and a few days back I published a fork on github. I wanted to add the
package to the bower repository.
The forked repository
I added a bower.json file to the repository and registered the package with the usual "bower register" command.
The problem is, when I try to install my package, bower installs the original script and not the fork.
What I already tried:
At first I thought it's because I didn't make a release, so I fixed that part. But It didn't help.
I also tried to change the version number to the version number of the original script with no luck.
So maybe the bower.json file I wrote was not well written, right? My next attempt was using Bower to
make a propper bower.json file for me using "bower init". No luck.
So what could I be doing wrong?
The GitHub help page defines a fork as a method to use someone else's project as a starting point for your own idea.
That was my intention since I rewrote the plugin to be oo oriented and added some functionality, but 80% of the code
used is still from the original plugin and it didn't feel right to just make a new repository. Should I instead make a new repository
and will registering my repo with Bower work then?
What is the usual approach if you did some medium to major changes to a repository? Do you fork it or publish a new repo?
Do you still make a pull request even if the changes are bigger?
This worked for me :
Fork the repository
Clone on your disk
Increment the version number in bower.json (ex. 2.0.1)
Commit and push
Create a new version tag higher than the forked repository. ex: git tag "2.0.1"
Push : git push --tag
bower install "https://github.com/myname/forkedrepo.git#2.0.1"
You don't need to create a new repository. A fork will work fine.
But you can't overload on someone else's registered package name with bower. It does look like you've changed the name from onepage-scroll to onepage-scroll-extended though.
If you want to figure out what Bower knows about your package:
Do: bower info onepage-scroll-extended
{
name: 'onepage-scroll-extended',
homepage: 'https://github.com/itd24/onepage-scroll-extended',
version: '1.1.1'
}
Available versions:
- 1.1.1
- 1.0.1
Here you can see that it does not have the full bower.json manifest information and the latest information that it has is for version 1.1.1 (not 1.1.3, your latest).
This is because you don't have a v1.1.3 tag in your repository's master branch. I can see a v1.1.1 and v1.2 tag, but no v1.1.3 tag. Create that tag and push it up to GitHub to enable you to bower install that new version.
You may also need to re-run the bower register command to tell it to pick up the latest manifest. This should be happening automatically (AFAIK). You don't include the bower register command that you ran, perhaps you used the wrong repo URL there. You should use something like:
bower register onepage-scroll-extended git#github.com:itd24/onepage-scroll-extended.git
I'm just trying to grasp the concepts of dependency managers and GIT systems, so it's very possible I'm missing something very basic.
I use ROOTS/BEDROCK project as a base of my Wordpress projects. It allows to use Composer with Wordpress (by adding Wordpress itself as a dependency) and various other awesome features. It is installable as a Packagist package by command composer create-project roots/bedrock.
However to make it fit with my Wordpress framework, I needed to do a light customization of the project. So I forked it and submited the fork to http://packagist.org with entirely new composer.json file.
What I do not understand is why composer after command composer create-project myaccount/forked_bedrock installs original repository and not my fork.
TL;DR
Is it possible to submit a forked GitHub repository to Packagist and use the fork (not the original repo) by create-project command?
Thanks in advance!
It seems that the problem lied within Composer cache - after I've cleared it, Composer loaded the forked GitHub repository (not the original).
If Composer caches so "heavily", it would be nice if there was some option to clear/flush the cache, but apparently there is nothing built-in ...
in my case was that i had to change the name of the package in the composer.json, changing the "name" propierty f