composer / satis

Simple static Composer repository generator - For a full private Composer repo use Private Packagist

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Satis chooses wrong dist URL for Gitlab projects

parleer opened this issue · comments

Describe the bug
When pointing satis to a Gitlab repo, it chooses a dist url that mirrors the source url instead of finding the Gitlab Release and using the dist zip artifact.

To Reproduce
Make your satis.json look like this;

{
 "repositories": [
    { "type": "vcs", "url": "git@gitlab.com:group-name/project-name.git" },
  ],
  "require-all": true
}

Then run satis build satis.json and satis will create a packages.json that looks like this:

{
    "packages": {
        "group-name/project-name": {
            "v1.0.1": {
                "name": "group-name/project-name",
                "version": "v1.0.1",
                "version_normalized": "1.0.1.0",
                "source": {
                    "type": "git",
                    "url": "git@gitlab.com:group-name/project-name.git",
                    "reference": "68da091ec3d6891e8519095a8066b28eb2261c20"
                },
                "dist": {
                    "type": "zip",
                    "url": "https://gitlab.com/api/v4/projects/group-name%2Fproject-name/repository/archive.zip?sha=68da091ec3d6891e8519095a8066b28eb2261c20",
                    "reference": "68da091ec3d6891e8519095a8066b28eb2261c20",
                    "shasum": ""
                },
                "require": {
                    "composer/installers": "v1.0.6"
                },
                "require-dev": {
                    "wp-coding-standards/wpcs": "^2.2"
                },
                "time": "2020-01-13T04:39:57+00:00",
                "type": "wordpress-plugin"
            }
    }
}

Expected behavior

The dist is supposed to be a distributable build of my app, NOT the source code version stored in git. The dist version's scripts are minified, css is build from sass, and various other things have been optimized. The dist version is stored as a zip artifact referenced by the Gitlab Release.

The above dist.url is simply an API call to Gitlab to generate a zip of the files as they appear within the git repo!

I expected satis to use the carefully constructed zip distributable that's associated with the Release. In my case, the url points to a Gitlab-CI artifact:

        "dist": {
                    "type": "zip",
                    "url": "https://gitlab.com/api/v4/projects/11301246/jobs/400678589/artifacts/project-name-1.0.1.zip",
                    "reference": "68da091ec3d6891e8519095a8066b28eb2261c20",
                    "shasum": ""
                },

Hello. This is not bug. This is the expected behaviour with Gitlab, GitHub and Bitbucket repositories. The source and dist are almost the same (files can be excluded from the dist with .gitattributes).

Your need is to serve custom artefacts. Gitlab made a great work for that with the Composer Packages Repository feature. https://docs.gitlab.com/ee/user/packages/composer_repository/
You can use Satis to mirror the Gitlab package repository of if necessary.