I'm using govendor for managing dependencies in a project. I have the following dependency in my vendor/vendor.json.
{
...
"package": [
{...},
{
"checksumSHA1": "8XAGmXqf+b4LW91wsWxa4kH1NN0=",
"path": "gopkg.in/h2non/bimg.v1",
"revision": "9bb3ae10c5ce30e72f7ac0834368536fc095d6a7",
"revisionTime": "2017-01-13T19:35:42Z"
}
],
...
}
Now I want to use master version of bimg package, which is newer than version 1.0.7 fetched by govendor. What is a proper way to achieve this, beside manually downloading master version from github and saving it to the vendor folder?
ps: all dependencies are committed.
I got help from #jbrandhorst in go slack:
you'll want to remove the old one as well, govendor remove gopkg.in/h2non/bimg.v1
[3:16] source repo appears to be github.com/h2non/bimg, so
govendor fetch github.com/h2non/bimg will install it to your vendor
folder
[3:16] if you just want to add it to your vendor.json, you use
govendor add I think
Related
I'm checking the dependencies of this Strapi Project with Next and as I'm setting up the backend directory, I review the dependencies and see:
`
"strapi": {
"uuid": "c35cad70-92f3-4df5-9408-xxxxxxxxxxxx"
},
`
Just curious whether I should update this or not according to what my professor's backend directory.
I'm stuck in a dependency bug and just trying to edit each dependency that's deprecated in the package.json
I am using the package teamtnt/laravel-scout-tntsearch-driver and I wish to make a very small change to one of the files within teamtnt/tntsearch which is one of the packages dependencies.
Usually I would:
Create a fork of the package.
Add the repository into my composer.json as follows:
"repositories": [
{"type": "vcs", "url": "https://github.com/user/packagefork"}
],
Require/Upgrade the package to the correct version (usually dev-master) keeping the original name spacing and it all works fine.
However, with a dependency which is not directly included in my composer.json file, this does not seem to work. Do I need to fork both the base package, and the dependency package even though I do not need to change anything within the base?
I am hoping there is a simple way to do this, without having to fork each level.
This was actually quite simple. Not too sure why it did not work originally! Instructions below for anyone wondering:
Fork the package (i.e. GitHub)
Add the repo from your username, to your projects main composer.json as follows:
"repositories": [
{"type": "vcs", "url": "https://github.com/youruser/tntsearch"}
],
Edit the composer.json file within the new fork you created in step 1 (youruser/tntsearch) and create/add to the extras key:
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
This effectively allows you to install your dev-master version, but allow other packages where this is a dependency to request the 2.0 version (in this case). You do need to be careful in this case that you have forked the correct version and any upgrades are correctly managed later down the line, or things may break!
More info on composer alias here
Require/Upgrade the package using original package namespace, at the dev-master version.
composer require teamtnt/tntsearch:dev-master
The name spacing and package versions will remain the same as before your fork, but the edits from your fork will be pulled into your project instead.
I have a local git repo and project where I want to use it.
composer.json in project folder:
"repositories": [
{
"type":"package",
"package":{
"name":"api",
"version":"0.1.0",
"source":{
"type":"git",
"url":"/var/www/modules/api",
"reference":"master"
}
}
}
],
"require": {
"api": "*"
}
composer install get source from the repo. Then I commited changes in the repository and make git tag "0.1.1"
In composer.json I changed version to "0.1.1"
run composer update:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating api (0.1.0 => 0.1.1) Checking out master
Writing lock file
Generating autoload files
But files was not updated.
Don't use package as the repository type. You'd have to manually change all information inside if something changes.
package really only is for the situation where you have code that you cannot add a composer.json for, or that is not hosted in version control.
For all other situations, i.e. you have the code in version control, and you can add composer.json to it, use "type" = "vcs" with the repository URL. Composer then works so much better.
See the documentation:
package: If you depend on a project that does not have any support for composer whatsoever you can define the package inline using a package repository. You basically just inline the composer.json object.
See the documentation:
Note: This repository type has a few limitations and should be avoided whenever possible:
Composer will not update the package unless you change the version field.
Composer will not update the commit references, so if you use master as reference you will have to delete the package to force an update, and will have to deal with an unstable lock file.
I've been looking into building a go project into a debian package.
I've looked into dh-make-golang and I have a nice and shiny debian folder set up in my repository. When I try to use gbp buildpackage --git-pbuilder though it errors out due to all of my dependencies not being found. It seems that dh-make-golang ignores the vendor folder when it copies everything from my project's git repository, and I use govendor so all of my dependencies are in there.
How can I resolve this dependency issue and build the project as a .deb package properly? For reference, the error I am getting is:
src/github.com/project/project/project.go:15:2: cannot find package "google.golang.org/grpc/grpclog" in any of:
/usr/lib/go-1.7/src/google.golang.org/grpc/grpclog (from $GOROOT)
/tmp/project/obj-x86_64-linux-gnu/src/google.golang.org/grpc/grpclog (from $GOPATH)
Issue was a bug in dh-make-golang regarding importing vendor dependencies. It was just fixed today.
https://github.com/Debian/dh-make-golang/issues/46
Take a look at goxc - it can do this for you!
You simply need to add a .goxc.json to the root of your directory, that looks like this
{
"AppName": "my_app",
"ArtifactsDest": "downloads",
"Tasks": [
"interpolate-source"
"deb",
],
"BuildConstraints": "linux,amd64 windows,amd64 darwin,amd64 linux,arm",
"ResourcesInclude": "INSTALL*,README*,LICENSE*,config/*,static/*,templates/*",
"PackageVersion": "0.9.3",
"TaskSettings": {
"deb": {
"metadata": {
"description": "my app",
"maintainer": "me",
"maintainer-email": "me#example.com"
},
"metadata-deb": {
"Homepage": "https://example.com"
},
"other-mapped-files": {
"/": "debian/",
"/usr/share/something/static": "static/",
"/usr/share/something/templates": "templates/"
}
}
},
"ConfigVersion": "0.9"
}
Then run goxc and it'll do all the work for you.
I want to put https://github.com/timrwood/moment into my composer.json for easy maintenance.
It's not an official packagist project (of course, as it's not PHP), but it contains a packages.json for nodejs. Can I use this in my composer.json?
I tried this, but it didn't work:
{
"repositories": {
"timrwood/moment": {
"type": "git",
"url": "git://github.com/timrwood/moment.git"
}
}
}
It throws an error message saying "No valid composer.json was found in any branch or tag of git://github.com/timrwood/moment.git, could not load a package from it."
And it is lacking the version string to define the version I want to use...
Can anyone help here?
Or shouldn't I use composer here at all cause I'm mixing JS and PHP?
Composer only manages composer packages. It does not know how to parse a package.json file. There are different approaches to this problem. Composer may be able to deal with frontend dependencies in the future.
For the time being I'd recommend using a separate dependency manager for your JavaScript dependencies. Either NPM or something like jam or ender.
Check out composer plugin to handle components via bower, nodejs and git repositories: fxpio/composer-asset-plugin.