ffraenz / private-composer-installer

Composer install helper outsourcing sensitive keys from the package URL into environment variables
MIT License
227 stars 16 forks source link

Empty ACF package folder in vendor/ #37

Closed blairwigley closed 3 years ago

blairwigley commented 3 years ago

I'm trying to install ACF - everything seems to be running fine but the /vendor/advanced-custom-fields folder is empty.

Here is my package.json:

{

    "repositories": [

        {
            "type": "package",
            "package": {
              "name": "advanced-custom-fields/advanced-custom-fields-pro",
              "version": "5.9.1",
              "type": "wordpress-plugin",
              "dist": {
                "type": "zip",
                "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%PLUGIN_ACF_KEY}&t={%VERSION}"
              },
              "require": {
                "composer/installers": "^1.4",
                "ffraenz/private-composer-installer": "^5.0"
              }
            }
        }
    ],
    "require": {
        "advanced-custom-fields/advanced-custom-fields-pro": "*"
    },
    "extra": {
        "private-composer-installer": {
          "dotenv-path": ".",
          "dotenv-name": ".env"
        }
    }
}

This is what composer update returns:

Loading composer repositories with package information
Updating dependencies
Dependency resolution completed in 0.002 seconds
Analyzed 141 packages to resolve dependencies
Analyzed 179 rules to resolve dependencies
Lock file operations: 9 installs, 0 updates, 0 removals
Installs: symfony/polyfill-php80:v1.20.0, symfony/polyfill-mbstring:v1.20.0, symfony/polyfill-ctype:v1.20.0, phpoption/phpoption:1.7.5, graham-campbell/result-type:v1.0.1, vlucas/phpdotenv:v5.2.0, ffraenz/private-composer-installer:v5.0.1, composer/installers:v1.9.0, advanced-custom-fields/advanced-custom-fields-pro:5.9.1
  - Locking advanced-custom-fields/advanced-custom-fields-pro (5.9.1)
  - Locking composer/installers (v1.9.0)
  - Locking ffraenz/private-composer-installer (v5.0.1)
  - Locking graham-campbell/result-type (v1.0.1)
  - Locking phpoption/phpoption (1.7.5)
  - Locking symfony/polyfill-ctype (v1.20.0)
  - Locking symfony/polyfill-mbstring (v1.20.0)
  - Locking symfony/polyfill-php80 (v1.20.0)
  - Locking vlucas/phpdotenv (v5.2.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 9 installs, 0 updates, 0 removals
Installs: symfony/polyfill-php80:v1.20.0, symfony/polyfill-mbstring:v1.20.0, symfony/polyfill-ctype:v1.20.0, phpoption/phpoption:1.7.5, graham-campbell/result-type:v1.0.1, vlucas/phpdotenv:v5.2.0, ffraenz/private-composer-installer:v5.0.1, composer/installers:v1.9.0, advanced-custom-fields/advanced-custom-fields-pro:5.9.1
  - Installing symfony/polyfill-php80 (v1.20.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.20.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.20.0): Extracting archive
  - Installing phpoption/phpoption (1.7.5): Extracting archive
  - Installing graham-campbell/result-type (v1.0.1): Extracting archive
  - Installing vlucas/phpdotenv (v5.2.0): Extracting archive
  - Installing ffraenz/private-composer-installer (v5.0.1): Extracting archive
> pre-file-download: FFraenz\PrivateComposerInstaller\Plugin->handlePreDownloadEvent
> pre-file-download: FFraenz\PrivateComposerInstaller\Plugin->handlePreDownloadEvent
  - Installing composer/installers (v1.9.0): Extracting archive
  - Installing advanced-custom-fields/advanced-custom-fields-pro (5.9.1): Extracting archive
Generating autoload files
8 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Any thoughts?

szepeviktor commented 3 years ago

Try issuing composer update -vvv - you may see the download URL of the ACF plugin.

blairwigley commented 3 years ago

Thanks - this is the verbose output:

- Installing advanced-custom-fields/advanced-custom-fields-pro (5.9.1): Extracting archive
Executing command (CWD): rm -rf 'wp-content/plugins/advanced-custom-fields-pro/pro'
Executing command (CWD): rm -rf 'wp-content/plugins/advanced-custom-fields-pro/includes'
Executing command (CWD): rm -rf 'wp-content/plugins/advanced-custom-fields-pro/lang'
Executing command (CWD): rm -rf 'wp-content/plugins/advanced-custom-fields-pro/assets'
Executing async command (CWD): unzip -qq  '/Users/me/Sites/mysite/wp-content/themes/mytheme/vendor/composer/tmp-da7f2d37aec8740be655dd57e403f1a7.php' -d '/Users/me/Sites/mysite/wp-content/themes/mytheme/vendor/composer/7655a7fd'
Executing command (CWD): rm -rf 'wp-content/plugins/advanced-custom-fields-pro'
Executing command (CWD): rm -rf '/Users/me/Sites/mysite/wp-content/themes/mytheme/vendor/composer/7655a7fd'
Executing command (CWD): rm -rf '/Users/me/Sites/mysite/wp-content/themes/mytheme/vendor/advanced-custom-fields/advanced-custom-fields-pro'

I've got the composer.json file in my theme so I though that could be an issue, but I'm getting the same results if I put it in the root of the WP install.

Any idea why it's removing vendor/advanced-custom-fields/advanced-custom-fields-pro with that last command?

szepeviktor commented 3 years ago

I think your packages fight each other :)

Try with 2 files only: composer.json and .env in a new directory. Maybe with an empty cache...

e.g.

{
  "type": "project",
  "license": "proprietary",
  "repositories": [
    {
      "type": "package",
      "package": {
        "type": "wordpress-plugin",
        "name": "advanced-custom-fields/acf-pro",
        "version": "5.9.1",
        "dist": {
          "url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download&t={%VERSION}&k={%ACF_PRO_KEY}",
          "type": "zip"
        },
        "require": {
          "composer/installers": "^1.4",
          "ffraenz/private-composer-installer": "^5.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=7.2",
    "advanced-custom-fields/acf-pro": "^5.8.7"
  }
}

and ACF_PRO_KEY=*** in .env

mcaskill commented 3 years ago

I've noticed this with Composer 2, the package's vendor directory is always created (vendor/advanced-custom-fields) but the package (of type wordpress-plugin) will be installed (by default) in wp-content/plugins/advanced-custom-fields-pro (which is what composer/installers does).

szepeviktor commented 3 years ago

And that path could be customized!

blairwigley commented 3 years ago

Ah I didn't even notice the wp-content directory in my theme folder!

@szepeviktor how do I go about changing the install path?

szepeviktor commented 3 years ago

how do I go about changing the install path?

@blairwigley Add an extra section to composer.json.

  "extra": {
    "installer-paths": {
      "public/wp-content/mu-plugins/{$name}/": [
        "type:wordpress-muplugin"
      ],
      "public/wp-content/plugins/{$name}/": [
        "type:wordpress-plugin"
      ],
      "public/wp-content/themes/{$name}/": [
        "type:wordpress-theme"
      ]
    }
  },
blairwigley commented 3 years ago

Brilliant! Thanks so much for your help.