Programmy
Programmy

Reputation: 45

Composer download repository in Gitlab as archive

TL;DR

I need a way to make composer download my package as an archive so it excludes files and directories I don't want to be included that are on my .gitattributes as export-ignore

Background info

I have files in my composer package repository that I don't want to be included in projects that use this package (DataFixtures, Tests, CI configuration). I have setup a .gitattributes file which excludes those folders and files with export-ignore.

This works fine when downloading the package as a zip manually but it, of course, doesn't when you checkout the code with git.

This is where my problem starts, I have added the repository manually to the composer.json since it is a private gitlab instance. Whenever I run composer update it uses GIT to download the code. I probably need a way to either make composer remove the files that are on the .gitattributes or force it to download my repository as an archive.

composer.json example

"repositories": [
    {
        "url": "git@<my-gitlab-server>:composer-libraries/testproject.git",
        "type": "git"
    }
],
......
"require": {
    "myownvendor/testproject": "^1.0",
}

Is there a way to solve this?

Upvotes: 0

Views: 993

Answers (1)

localheinz
localheinz

Reputation: 9582

Try setting the preferred-install method for this repository to dist in your composer.json:

{
    "config": {
        "preferred-install": {
            "myownvendor/testproject": "dist"
        }
    }
}

Alternatively, install dependencies by running

$ composer install --prefer-dist

For reference, see:

Upvotes: 1

Related Questions