bitfumes/laravel-packer

Creating migrations uses wrong path for file

Closed this issue · 5 comments

When creating a migration it fails as it tries to write it to my composer global directory, any idea why?
Adding --path="${PWD}/database/migrations" --realpath each time I want to create a migration is a little cumbersome
image

fixed, please run 'composer global update' to get latest version

Where are they written to now?

Not inside the package at least...

I found what goes wrong, just don't know why - it tries to resolve the path to my package but it does the following
/home/projects/{some_project}/vendor/{some_vendor}/{package_name} is my package folder
It generates the following path for my migrations:
/home/projects/{some_project}/vendor/{some_vendor}/{package_name}database/migrations
While it should be:
/home/projects/{some_project}/vendor/{some_vendor}/{package_name}/database/migrations

As you can see, the / is missing for some reason

I think it's this line:
https://github.com/bitfumes/laravel-packer/blob/master/app/Commands/Foundation/Migrations/MigrationCreator.php#L31

getcwd() doesn't return a trailing /, so the building blocks will be:
getcwd()="/home/projects/{some_project}/vendor/{some_vendor}/{package_name}"
$devPath=""
database/migrations

This results in "/home/projects/{some_project}/vendor/{some_vendor}/{package_name}" . "" . "database/migrations"
Which results in:
/home/projects/{some_project}/vendor/{some_vendor}/{package_name}database/migrations

This went unnoticed probably as $devPath always has a trailing /

Maybe set the default of $devPath to "/" instead of ""?

Also the path and realpath options seem to be broken or not used anymore... workaround mentioned in first message doesn't work anymore - as it keeps writing them to the wrong path