Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid to change path of composer.json #114

Open
thewebartisan7 opened this issue Sep 1, 2020 · 5 comments
Open

Avoid to change path of composer.json #114

thewebartisan7 opened this issue Sep 1, 2020 · 5 comments

Comments

@thewebartisan7
Copy link

Right now in composer.json path are added with full path of local environment which should be changed when you move project.

Now is:

    "repositories": {
        "vendor/package": {
            "type": "path",
            "url": "/Users/me/Projects/laravel/packages/vendor/package"
        }
    }

But better would be:

    "repositories": [{
        "type": "path",
        "url": "packages/*/*/",
        "options": {
            "symlink": true
        }
    }],

and in require:

    "require": {
        "vendor/package": "dev-master"
    },

What do you think?

@sebastienheyd
Copy link
Contributor

There is already a PR for this : #115

A better way is to set

    "require": {
        "vendor/package": "@dev"
    },

This rule allow all dev branches like dev-*. This is useful if you have many branches of your package

I thought of putting packages/*/* when I wrote the PR, but this would require checking that the last package is removed to remove the rule. After that it's still possible to do like this, any opinion on this ?

@thewebartisan7
Copy link
Author

thewebartisan7 commented Sep 2, 2020

I like the idea of allowing all dev branches, however I tested with your same package monolog/monolog. The package was downloaded in packages folder but in vendor is not symlinked.

Screenshot:

Screenshot 2020-09-02 at 12 58 32

But using "monolog/monolog": "dev-master" did the symlink.

Then I tested with custom package MyVendor/MyPackage and I can see in composer:

    "repositories": {
        "myvendor/mypackage": {
            "type": "path",
            "url": "/Users/me/Projects/laravel/packages/MyVendor/MyPackage",
            "options": {
                "symlink": true
            }
        }
    }
    "require": {
        "myvendor/mypackage": "@dev"
    },

There is still full URL in repositories.

If I move to server, I need to change composer.json

What I mean here is that URL is rather like this:

    "repositories": {
        "myvendor/mypackage": {
            "type": "path",
            "url": "packages/MyVendor/MyPackage",
            "options": {
                "symlink": true
            }
        }
    }

but also like this:

    "repositories": [{
        "type": "path",
        "url": "packages/*/*/",
        "options": {
            "symlink": true
        }
    }],

Last doesn't require to edit for each package the "repositories", like now you have for each package:

    "repositories": {
        "myvendor/mypackage": {
            "type": "path",
            "url": "/Users/me/Projects/laravel/packages/MyVendor/MyPackage",
            "options": {
                "symlink": true
            }
        },
        "myvendor/mypackage2": {
            "type": "path",
            "url": "/Users/me/Projects/laravel/packages/MyVendor/MyPackage2",
            "options": {
                "symlink": true
            }
        }
        "myvendor2/mypackage": {
            "type": "path",
            "url": "/Users/me/Projects/laravel/packages/MyVendor1/MyPackage",
            "options": {
                "symlink": true
            }
        }
    }

etc... for each package

@sebastienheyd
Copy link
Contributor

I see and you're right.

In one of my other PR I propose to set the path of the folder in the configuration file

https://github.com/sebastienheyd/laravel-packager/blob/e878f092b9c14dc5dba62b1496b42c8b20ad887d/config/packager.php#L4-L7

My first idea was to set a relative path here instead of the full one (with the call to basepath() ).

But I'm agree, the simpliest way is to set only one repository rule with packages/*/*/

I'm just waiting now to see if my PR will be merged or not, after that I can do another PR for the "unique rule"

@karmendra
Copy link

@sebastienheyd did you create a PR for this, actually I was not able to locate the same.

@tyler36
Copy link

tyler36 commented Jul 30, 2021

I'm not sure if this is the same or a different issue. Im working in WSL with a Docker container providing my webserver.
When I run artisan packager:new acme supercool, my composer is updated with the full path

    "repositories": {
        "acme/supercool": {
            "type": "path",
            "url": "/home/some-guy/test/packages/acme/supercool",
            "options": {
                "symlink": true
            }
        }
    }

Because my webserver mounts test as /var/www/html, the package is no longer a valid path for composer. What would resolve this for me is if the default path was relative. Eg.

    "repositories": {
        "acme/supercool": {
            "type": "path",
            "url": "./packages/acme/supercool",
            "options": {
                "symlink": true
            }
        }
    }

When I manually change, bother WSL & the webserver are happy.
This also would allow the files to commited or moved to a different path (or even system) without breaking.

I think "url": "packages/*/*/", is a little too much. It's hard to know when / if you can remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants