hiqdev / asset-packagist

Asset Packagist
https://asset-packagist.org
BSD 3-Clause "New" or "Revised" License
247 stars 24 forks source link

Custom paths don't seem to work #20

Closed phenaproxima closed 7 years ago

phenaproxima commented 7 years ago

I have set up my composer.json with Asset Packagist and oomphinc/composer-installers-extender, and then required bower-asset/dropzone after setting a custom install path for it. It stubbornly insists on going into vendor/bower-asset/dropzone. I'm not sure what I did wrong. How might I go about debugging this? Has anyone else had problems getting custom paths to work?

hiqsol commented 7 years ago

Show your composer.json please.

phenaproxima commented 7 years ago

With pleasure. It's a really complex composer.json, my apologies for the length.

{
    "name": "drupal/lightning",
    "description": "The best of Drupal, curated by Acquia",
    "type": "drupal-profile",
    "license": "GPL-2.0+",
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require-dev": {
        "drush/drush": "^9.0",
        "drupal/drupal-extension": "^3.2",
        "drupal-composer/drupal-scaffold": "^2.0.0",
        "behat/behat": "^3.0",
        "drupal/coder": "8.*",
        "phing/phing": "^2.14",
        "behat/mink": "~1.7",
        "behat/mink-goutte-driver": "~1.2",
        "jcalderonzumba/gastonjs": "~1.0.2",
        "mikey179/vfsStream": "~1.2",
        "phpunit/phpunit": "~4.8",
        "symfony/css-selector": "~2.8",
        "drupal/devel": "^8.0.0",
        "squizlabs/php_codesniffer": "2.*",
        "se/selenium-server-standalone": "^2.53"
    },
    "config": {
        "bin-dir": "bin/"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packagist.drupal-composer.org"
        },
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ],
    "scripts": {
        "post-install-cmd": [
            "@composer drupal-scaffold",
            "./bin/phing push"
        ],
        "post-update-cmd": [
            "./bin/phing push"
        ],
        "drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold"
    },
    "extra": {
        "installer-types": [
            "library"
        ],
        "installer-paths": {
            "docroot/core": [
                "drupal/core"
            ],
            "modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "libraries/{$name}": [
                "bower-asset/dropzone"
            ]
        },
        "patches": {
            "drupal/panelizer": {
                "2747739 - Mega Patch":
                "https://www.drupal.org/files/issues/panelizer--alpha2-1ddfa61--2747739-5.patch",
                "2701349 - Generate new UUIDs for displays when switching from default to field storage":
                "https://www.drupal.org/files/issues/2701349-2.patch",
                "2700597 - Explicitly set the Panels IPE URL root when saving in Panelizer":
                "https://www.drupal.org/files/issues/panelizer-ipe-url-root-handling.patch",
                "2664682 - Implement admin UI for editing Panelizer defaults":
                "https://www.drupal.org/files/issues/2664682-55.patch",
                "2793841 - Properly integrate with Panels IPE":
                "https://www.drupal.org/files/issues/panelizer-panels-ipe-tempstore-id.patch"
            },
            "drupal/panels": {
                "2793801 - Allow modules to influence the IPE tempstore ID":
                "https://www.drupal.org/files/issues/2793801-9.patch"
            },
            "drupal/scheduled_updates": {
                "2674874 - Issue saving Schedule Update Type form":
                "https://www.drupal.org/files/issues/schedule_updates-save_type-2674874-2.patch",
                "2720169 - Scheduled Update Type entity should not have canonical link template":
                "https://www.drupal.org/files/issues/scheduled_updates-no-canonical-link-for-update-type.patch"
            },
            "drupal/workbench_moderation": {
                "2668006 - Provide logical access control for when IPE should be applied to moderated nodes":
                "https://www.drupal.org/files/issues/2668006-2.patch",
                "2780691 - Incorrect EntityRevision paramconverter service definition causes a fatal error":
                "https://www.drupal.org/files/issues/workbench_moderation-invalid_service_definition.patch"
            },
            "drush/drush": {
                "Adding composer.json support to make-convert command":
                "https://github.com/drush-ops/drush/commit/ce82b946d49b09cd33da5ca84feb24a6c35f8f8e.patch",
                "The batch table may not exist by the time _drush_backend_batch_process() is called in 8.x-1.x":
                "https://github.com/drush-ops/drush/commit/c389aebb7d3e26ff0f544684d8b3ec3528107e55.diff",
                "Fix composer branch-alias constraint":
                "https://github.com/drush-ops/drush/commit/83436c8ea505223a1868dce130d4ca1b4e558711.diff"
            },
            "drupal/metatag": {
                "2786795 - DrupalConsole integration breaks Drush":
                "https://www.drupal.org/files/issues/metatag-deactivate_drupalconsole_services_0.patch"
            },
            "drupal/workspace": {
                "2791789 - Workspace should report conflicts before replication":
                "https://www.drupal.org/files/issues/2791789-34.patch"
            },
            "drupal/multiversion": {
                "2822915 - Migration source plugin makes bad assumptions that can lead to data loss":
                "https://www.drupal.org/files/issues/2822915-2.patch"
            },
            "drupal/replication": {
                "2814055 - Allow modules to react to replication events":
                "https://www.drupal.org/files/issues/2814055-2.patch",
                "2820105 - User references are not replicated":
                "https://www.drupal.org/files/issues/2820105-10.patch"
            },
            "drupal/core": {
                "2818031 - Trailing slashes can cause FileSystem::mkdir() to return a false negative":
                "https://www.drupal.org/files/issues/2818031-6.patch"
            }
        }
    },
    "require": {
        "cweagans/composer-patches": "^1.5.0",
        "drupal/core": "~8.2.0",
        "drupal/embed": "^8.1.0",
        "drupal/entity_embed": "^8.1.0",
        "drupal/media_entity": "^8.1.0",
        "drupal/media_entity_instagram": "^8.1.0",
        "drupal/media_entity_twitter": "^8.1.2",
        "drupal/media_entity_image": "^8.1.0",
        "drupal/ctools": "8.3.0-alpha27",
        "drupal/panels": "8.3.0-beta5",
        "drupal/page_manager": "8.1.0-alpha24",
        "drupal/panelizer": "8.3.0-alpha2",
        "drupal/scheduled_updates": "8.1.0-alpha5",
        "drupal/workbench_moderation": "8.1.1",
        "drupal/acquia_connector": "^8.1.1",
        "drupal/config_update": "^8.1.1",
        "drupal/features": "^8.3.0",
        "drupal/inline_entity_form": "^8.1.0",
        "drupal/metatag": "8.1.0-beta10",
        "drupal/token": "^8.1.0",
        "drupal/pathauto": "^8.1.0",
        "drupal/multiversion": "8.1.0-alpha10",
        "drupal/workspace": "8.1.0-alpha3",
        "drupal/replication": "8.1.0-alpha5",
        "drupal/key_value": "^8.1.0",
        "drupal/entity_browser": "8.1.0-alpha10",
        "drupal/views_infinite_scroll": "^8.1.1",
        "drupal/media_entity_document": "^8.1.0",
        "drupal/video_embed_field": "^8.1.0",
        "oomphinc/composer-installers-extender": "^1.1",
        "bower-asset/dropzone": "^4.3"
    },
    "autoload": {
        "psr-4": {
            "Acquia\\LightningExtension\\": "src/LightningExtension"
        }
    }
}
hiqsol commented 7 years ago

As far as I understand composer-installers-extender works only when it is already installed. I mean the plugin just doesn't work when you have clean project. When you have empty vendor directory first composer install installs everything to standard paths. But second composer update will reinstall dropzone to the wanted directory.

That's all about the order of installation. If you change requires this way:

    "require": {
        ...
        "oomphinc/composer-installers-extender": "dev-master",                                                                                                                                         
        "bower-asset/dropzone": "^4.3"
    },

It somehow changes the order of installation and composer-installers-extender gets installed before dropzone and dropzone gets installed to the wanted dir :) But it is not real solution cause we just can't control the order of installation.

As far as I know this is real limitation of composer - they don't want to install plugins before other packages. And they don't want to create any ways to control the order of installation.

Sorry, but I can't fix the problem in asset-packagist :( I can suggest two options:

phenaproxima commented 7 years ago

Thank you for looking into it. I really appreciate your detective work. :)

In our case, there is a workaround -- we can simply move (in post-install-cmd and post-update-cmd) the contents of the vendor/bower-asset and vendor/npm-asset directories into the desired libraries directory, and all should work as desired. It's not perfect, but it'll do for us.

jurgenhaas commented 7 years ago

@hiqsol that's an interesting explanation and it does make sense at a first glance. But I wonder why other plugins, e.g. composer/installers, are getting it right then. Maybe there is something that a plugin can do about it? But then, it's more a oomphinc/composer-installers-extender issue rather than one for this project I guess.

jurgenhaas commented 7 years ago

According to https://github.com/oomphinc/composer-installers-extender/issues/6 they seem to recognize this as a bug, although I'm not sure. It could still be down to the order of how composer installs packages.

But there is a nice suggestion in https://github.com/oomphinc/composer-installers-extender/issues/6#issuecomment-244926790: adding oomphinc/composer-installers-extender as a requirement to all packages that should be installed afterwards. Now that's not possible for us "end-users" as we don't maintain the assets, but I wonder if asset-packagist couldn't embed them on the fly?

hiqsol commented 7 years ago

@jurgenhaas at the moment asset-packagist provides asset packages descriptions statically e.i. same file every time.

E.g. see: https://asset-packagist.org/p/bower-asset/moment/048aba286e6b54637154a7994fb004c5d9e5c044436bde744efa0ce914a87f8a.json

This file is generated once and then served statically. So every user gets same file during composer install/update

If I'll add oomphinc/composer-installers-extender as a requirement to all the packages all the users will get this plugin even if they don't want it. So I can't do it this way.

I have an idea. Asset-packagist can be sort of configured with the url passed in composer.json like this:

    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org/config?add_require=oomphinc/composer-installers-extender"
        }
    ]

But it's just an idea now and needs considerable research, not sure when I'll have a time to play with it.

kasperg commented 7 years ago

If I'll add oomphinc/composer-installers-extender as a requirement to all the packages all the users will get this plugin even if they don't want it. So I can't do it this way.

@hiqsol Have you considered adding composer/installers as a requirement to all packages?

npm-asset/bower-asset may not be a registered package type but it seems like we could use the their option to place all packages from specific vendors in a custom path instead.

    "extra": {
        "installer-types": ["library"],
        "installer-paths": {
            "public/assets/bower/{$name}/": ["bower-asset/bootstrap"],
            "public/assets/npm/{$name}/": ["npm-asset/jquery"]
        }
    }

would become:

    "extra": {
        "installer-paths": {
            "public/assets/bower/{$name}/": ["vendor:bower-asset"],
            "public/assets/npm/{$name}/": ["vendor:npm-asset"]
        }
    }

I consider composer/installers to be much more widely used compared to oomphinc/composer-installers-extender.

SilverFire commented 7 years ago

The manual for custom installation paths was re-checked and updated

See updated manual on https://asset-packagist.org/site/about

kasperg commented 7 years ago

Note that even with the updated documentation the proposed solution is not bulletproof.