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

[Feature Request] Support custom vendor folder location #133

Open
hirasso opened this issue Dec 22, 2024 · 2 comments
Open

[Feature Request] Support custom vendor folder location #133

hirasso opened this issue Dec 22, 2024 · 2 comments

Comments

@hirasso
Copy link

hirasso commented Dec 22, 2024

First of all: Thank you for this package ❤️

If config.vendor-dir is set to a custom location, the prefix-namespaces script fails with this cryptic error:

[info] Loading composer.json config...
[info] Loading cli config...
[info] Building dependency list...
[info] Enumerating files...
[error] Unable to read file from location: vendor/Repos/rh-admin-utils/keys.dev.pub. file_get_contents(/Users/rah/Documents/Repos/rh-admin-utils/vendor/Repos/rh-admin-utils/keys.dev.pub): Failed to open stream: No such file or directory
Script @php bin/strauss.phar handling the prefix-namespaces event returned with error code 1
Script @prefix-namespaces was called via post-install-cmd

I can't make any sense of this. Some observations:

  • vendor/Repos/rh-admin-utils seems to be somehow related to the path where my plugin is located on my local disc.
  • keys.dev.pub is not in my package nor does it seem to exist anywhere in strauss

My composer.json

{
  "name": "hirasso/rh-admin-utils",
  "description": "A WordPress utility plugin 🥞",
  "license": "GPL-2.0-or-later",
  "config": {
    "vendor-dir": "./lib/vendor"
  },
  "autoload": {
    "psr-4": {
      "RH\\AdminUtils\\": "lib/rh-admin-utils"
    }
  },
  "type": "wordpress-plugin",
  "minimum-stability": "dev",
  "require": {
    "php": ">=8.2",
    "symfony/var-dumper": "^7.1"
  },
  "scripts": {
      "prefix-namespaces": [
          "sh -c 'test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/latest/download/strauss.phar'",
          "@php bin/strauss.phar",
          "@php composer dump-autoload"
      ],
      "post-install-cmd": [
          "@prefix-namespaces"
      ],
      "post-update-cmd": [
          "@prefix-namespaces"
      ]
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "*"
  }
}

If I remove the config.vendor-dir config entry, it works. No big deal but this might point to a bigger issue with relative paths (maybe a missing ./ somewhere?)

@BrianHenryIE
Copy link
Owner

Thanks. Not totally unexpected:

// In rare cases, the vendor directory will not be a single level of directory. File an issue.

Fix is written: 3557bb4

I'll get it merged soon. I still need to look at your PRs too.

@hirasso
Copy link
Author

hirasso commented Dec 25, 2024

Wow thank you, that looks great! And also, interesting approach to name the test like the issue 🤩

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

No branches or pull requests

2 participants