1

Issue

We are trying to wrap all our build into composer packages to comply with best practises.

The problem is there are files that need to be added or modified which do not fit in Magento module structure for various reason, in the case I am just trying to get some sample images for the build, it does seem like we will have to change some files such as dev/tools/grunt/configs/themes.js

Magento overcome this by creating the "magento/magento2-base" package as type "type": "magento2-component",.

Attempt

I tried creating a composer file like:

{
    "name": "namespace/project-base",
    "description": "Project Base Components",
    "type": "magento2-component",
    "version": "0.0.1",
    "require": {
        "magento/magento-composer-installer": "*",
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/magento2-base": "*"
    },
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "extra": {
        "map": [
            [
                "pub/media",
                "pub/media"
            ]
        ]
    }
}

And my file structure is:

.
├── composer.json
└── pub
    └── media
    └── catalog
        ├── category
        │   └── new-arrivals.JPG
        └── product
            └── p
                └── r
                    ├── product-photo1x.jpg
                    ├── product-photo2x.jpg
                    ├── product-photo3x.jpg
                    ├── product-photo4x.jpg
                    └── product-photo5x.jpg

When I run composer update it doesn't map the files across, I'm not sure what is wrong, does anybody have any insight into how the composer map feature works with the magento-composer-installer?

Update

I made it work, see my answer below, I still can't work out how to make the declaration work for folders though.

1 Answer 1

0

Success sort of.

So, I guess I should of played a little longer.

If I define each file it works file, but if I just define a directory it doesn't work.

I also tried updating the grunt theme file and it worked, it rewrote the one defined already so I can ship this to my team mates.

{
    "name": "namespace/project-base",
    "description": "Project Base Components",
    "type": "magento2-component",
    "version": "0.0.1",
    "require": {
        "magento/magento-composer-installer": "*",
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/magento2-base": "*"
    },
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "extra": {
        "map": [
            [
                "pub/media/catalog/product/p/r/product-photo1x.jpg",
                "pub/media/catalog/product/p/r/product-photo1x.jpg"
            ],
            [
                "pub/media/catalog/product/p/r/product-photo2x.jpg",
                "pub/media/catalog/product/p/r/product-photo2x.jpg"
            ],
            [
                "pub/media/catalog/product/p/r/product-photo3x.jpg",
                "pub/media/catalog/product/p/r/product-photo3x.jpg"
            ],
            [
                "pub/media/catalog/product/p/r/product-photo4x.jpg",
                "pub/media/catalog/product/p/r/product-photo4x.jpg"
            ],
            [
                "pub/media/catalog/product/p/r/product-photo5x.jpg",
                "pub/media/catalog/product/p/r/product-photo5x.jpg"
            ],
            [
                "dev/tools/grunt/configs/themes.js",
                "dev/tools/grunt/configs/themes.js"
            ]
        ]
    }
}

If anyone knows how to make it not require specific declaration of the files I would appreciate it.

Update:

Yes you can.

"extra": {
    "map": [
        [
            "pub/",
            "pub/"
        ],
        [
            "dev/",
            "dev/"
        ]
    ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.