BobRay / MyComponent

Development environment for creating MODX extras
https://bobsguides.com/mycomponent-tutorial.html
23 stars 13 forks source link

Sub packages not installed/moved with 3.1 #17

Closed DESIGNfromWITHIN closed 11 years ago

DESIGNfromWITHIN commented 11 years ago

I tried to use 3.1 and add a sub-package to my fresh build. I followed the guide here: http://bobsguides.com/mycomponent-tutorial.html What I did:

The result is a nice package with all default settings, but no sub package... What am I doing wrong?

BobRay commented 11 years ago

The subpackage files go in assets/mycomponents/flexibility4/_build/subpackages,

not assets/components . . .

On Thu, Jul 18, 2013 at 2:31 AM, Menno Pietersen notifications@github.comwrote:

I tried to use 3.1 and add a sub-package to my fresh build. What I did:

  • Created a MODX DEV Cloud
  • Installed MyComponent 3.1 via package manager
  • Cleared cache
  • Opened MyComponent in the front-end
  • Created a new Project called 'flexibility4'
  • Downloaded the flexibility4.config.php file via SSH
  • Changed the top settings
  • Uploaded the flexibility4.config.php file via SSH
  • Cleared cache
  • Created folders like: assets\components\flexibility4_build\subpackages
  • Uploaded the 'ace-1.4.0-pl.transport' zip file to assets\components\flexibility4_build\subpackages
  • Cleared cache
  • Ran 'Bootstrap' in MyComponent
  • Ran 'ExportObjects' in MyComponent
  • Ran 'Build' in MyComponent

The result is a nice package with all default settings, but no sub package... What am I doing wrong?

— Reply to this email directly or view it on GitHubhttps://github.com/BobRay/MyComponent/issues/17 .

DESIGNfromWITHIN commented 11 years ago

Thanks Bob,

You might want to update this on your site, it says "assets/components/flexibility4/_build/subpackages/" on:

http://bobsguides.com/mycomponent-tutorial.html

DESIGNfromWITHIN commented 11 years ago

I have them in the right spot... no luck still I am looking in the build.transport.php file but do not see any link to the subpackages folder...

Do I have the correct version? 3.1.0-pl

the only code related to subpackes that I see is this:

/* Add subpackages */
/* The transport.zip files will be copied to core/packages
* but will have to be installed manually with "Add New Package and
*  "Search Locally for Packages" in Package Manager
*/
if ($hasSubPackages && $i == 1) {
    $helper->sendLog(modX::LOG_LEVEL_INFO,
        $modx->lexicon('mc_packaging_subpackages')
    . '.');
    $vehicle->resolve('file', array(
        'source' => $sources['packages'],
        'target' => "return MODX_CORE_PATH;",
    ));
}
BobRay commented 11 years ago

It looks like the build.transport.php file in your package's _build directory (asset/mycomponents/_build ... ) didn't get updated (for safety, it never gets overwritten by MyComponent). You should be able to delete that file and run Bootstrap to get the new one. You should see this in it:

if ($hasSubPackages && $i == 1) { $obj = $modx->newObject('xPDOFileVehicle'); $vehicle = $builder->createVehicle($obj, array( xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => true, )); $helper->sendLog(modX::LOG_LEVEL_INFO, $modx->lexicon('mc_packaging_subpackages')); $vehicle->resolve('file', array( 'source' => $sources['packages'], 'target' => "return MODX_CORE_PATH;", )); $builder->putVehicle($vehicle); }

DESIGNfromWITHIN commented 11 years ago

Hi Bob,

I am getting further, but still not luck.

There is no mention of any subpackages...

I also see that in 'assets\mycomponents\flexibility4_build\resolvers\packages' the subpackage resolver is there and a 'transport.subpackages.php' file is created in _build/data

However there is no mention of any 'transport.subpackages.php' in the 'transport.settings.php' I guess this is why no subpackages are installed/added...

I already tried to delete the 'transport.settings.php' file and do a new Bootstrap, but no luck.

BobRay commented 11 years ago

I think you'll need to run ExportObjects in order for the subpackage resolver to be created.

Run ImportObjects first if you've changed any of the code files without changing the corresponding object in MOD.

On Fri, Jul 19, 2013 at 3:56 AM, Menno Pietersen notifications@github.comwrote:

Hi Bob,

I am getting further, but still not luck.

-

After I re-run bootstrap I get:

Processing subpackages
Creating D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/data/transport.subpackages.php
Creating D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/resolvers/packages/resolve.ace.php
Creating D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/resolvers/packages/resolve.getresources.php
Creating D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/validators/validate.ace.php
Creating D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/validators/validate.getresources.php

-

I the do 'ExportObjects' and get:

Processing subpackages
Updated D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/data/transport.subpackages.php
Updated D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/resolvers/packages/resolve.ace.php
Updated D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/resolvers/packages/resolve.getresources.php
Updated D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/validators/validate.ace.php
Updated D:/Dropbox/DESIGNfromWITHIN/GitHub/localhost/Flexibility4DEV/assets/mycomponents/flexibility4/_build/validators/validate.getresources.php

-

After I them do 'Build' this is the result:

Project: flexibility4
Action: Build
Creating Package: flexibility4-1.0.2-beta1
Created namespace: flexibility4
Packaged 1 new Context(s)
Packaged 2 resources
Packaged 2 new System Settings
Packaged 2 Context Settings
Creating js-min file(s)
Creating/updating js-min file(s) (Using JSMinPlus)
Updated: D:\Dropbox\DESIGNfromWITHIN\GitHub\localhost\Flexibility4DEV\assets\mycomponents\flexibility4/assets/components/flexibility4/js/flexibility4-min.js
Updated: D:\Dropbox\DESIGNfromWITHIN\GitHub\localhost\Flexibility4DEV\assets\mycomponents\flexibility4/assets/components/flexibility4/js/sections/home-min.js
Updated: D:\Dropbox\DESIGNfromWITHIN\GitHub\localhost\Flexibility4DEV\assets\mycomponents\flexibility4/assets/components/flexibility4/js/widgets/chunk.grid-min.js
Updated: D:\Dropbox\DESIGNfromWITHIN\GitHub\localhost\Flexibility4DEV\assets\mycomponents\flexibility4/assets/components/flexibility4/js/widgets/home.panel-min.js
Updated: D:\Dropbox\DESIGNfromWITHIN\GitHub\localhost\Flexibility4DEV\assets\mycomponents\flexibility4/assets/components/flexibility4/js/widgets/snippet.grid-min.js
Updated: D:\Dropbox\DESIGNfromWITHIN\GitHub\localhost\Flexibility4DEV\assets\mycomponents\flexibility4/assets/components/flexibility4/js/flexibility4-all-min.js
Creating Category: flexibility4
Processing Elements in Category: flexibility4
Packaged 1 Snippets
Packaged 2 Property Sets
Adding Chunks.
Packaged 2 Chunks
Adding Templates
Packaged 2 Templates
Adding Template Variables
Packaged 2 TVs
Packaged 2 Plugins
Processing Validators
Packaging flexibility4 validator
Packaging hasGdLib validator
Packaged core directory files
Packaged assets directory files
Creating Category: Category2
Processing Elements in Category: Category2
Packaged 1 Snippets
Processing Resolvers
Packaged category resolver
Packaged plugin resolver
Packaged tv resolver
Packaged resource resolver
Packaged propertyset resolver
Packaged flexibility4 resolver
Packaged addUsers resolver
Packaging menu
Packaged 1 menu items
Package Built
Execution time: 1,4341 s

There is no mention of any subpackages...

I also see that in 'assets\mycomponents\flexibility4_build\resolvers\packages' the subpackage resolver is there and a 'transport.subpackages.php' file is created in _build/data

However there is no mention of any 'transport.subpackages.php' in the 'transport.settings.php' I guess this is why no subpackages are installed/added...

I already tried to delete the 'transport.settings.php' file and do a new Bootstrap, but no luck.

— Reply to this email directly or view it on GitHubhttps://github.com/BobRay/MyComponent/issues/17#issuecomment-21238740 .

DESIGNfromWITHIN commented 11 years ago

Hey Bob, Man I don't lknwo why but it is not working at all... After ImportObjects nothing changes I get:

    Project: flexibility4
    Action: Import Objects
    Processing snippets
    Skipping static element: Snippet1
    Updated: Snippet2
    Processing plugins
    Updated: Plugin1
    Updated: Plugin2
    Processing chunks
    Updated: Chunk1
    Updated: Chunk2
    Processing templates
    Updated: Template1
    Updated: Template2
    Initial Memory Used: 11,54 megabytes
    Final Memory Used: 15,27 megabytes
    Peak Memory Used: 16 megabytes
    Total time: 0,6098 s

Again no mention of subpackages...

I tried any combination:

Still no luck

DESIGNfromWITHIN commented 11 years ago

I also notice that all my package resolvers in: assets/mycomponents/flexibility4/_build/resolvers/packages/ have the same content!

All resolvers have the content of the 'resolve.ace.php' file... the file names are correct:

but all files above have the content of:

    <?php
    /**
     * Subpackage Resolver file for flexibility4 extra
     *
     * Copyright 2013 by Menno Pietersen <http://flexibilitymodx.com>
     * Created on 07-20-2013
     *
     * @package flexibility4
     * @subpackage build
     */

    if (! function_exists('stripPhpTags')) {
        function stripPhpTags($filename) {
            $o = file_get_contents($filename);
            $o = str_replace('<' . '?' . 'php', '', $o);
            $o = str_replace('?>', '', $o);
            $o = trim($o);
            return $o;
        }
    }
    /* @var $modx modX */
    /* @var $sources array */

    /**
     * Add ace package to packages grid
     *
     * @var modX $modx
     * @var xPDOTransport $transport
     * @var array $options
     * @package flexibility4
     */
    $success= true;
    if ($transport && $transport->xpdo) {
        $signature = 'ace-1.4.0-pl';
        $modx =& $transport->xpdo;
        $modx->addPackage('modx.transport',$modx->getOption('core_path').'model/');

        switch ($options[xPDOTransport::PACKAGE_ACTION]) {
            case xPDOTransport::ACTION_INSTALL:
            case xPDOTransport::ACTION_UPGRADE:
                /* define version */
                $sig = explode('-',$signature);
                $versionSignature = explode('.',$sig[1]);

                /* add in the package as an object so it can be upgraded */
                /** @var modTransportPackage $package */
                $package = $modx->newObject('transport.modTransportPackage');
                $package->set('signature',$signature);
                $package->fromArray(array(
                    'created' => date('Y-m-d h:i:s'),
                    'updated' => date('Y-m-d h:i:s'),
                    'installed' => strftime('%Y-%m-%d %H:%M:%S'),
                    'state' => 1,
                    'workspace' => 1,
                    'provider' => 1,
                    'disabled' => false,
                    'source' => $transport->signature . '/' . $this->payload['class'] . '/' . $this->payload['signature'] . '/' . $signature.'.transport.zip',
                    'manifest' => null,
                    'package_name' => $sig[0],
                    'version_major' => $versionSignature[0],
                    'version_minor' => !empty($versionSignature[1]) ? $versionSignature[1] : 0,
                    'version_patch' => !empty($versionSignature[2]) ? $versionSignature[2] : 0,
                ));
                if (!empty($sig[2])) {
                    $r = preg_split('/([0-9]+)/',$sig[2],-1,PREG_SPLIT_DELIM_CAPTURE);
                    if (is_array($r) && !empty($r)) {
                        $package->set('release',$r[0]);
                        $package->set('release_index',(isset($r[1]) ? $r[1] : '0'));
                    } else {
                        $package->set('release',$sig[2]);
                    }
                }
                $success = $package->save();
                $modx->logManagerAction('package_install','transport.modTransportPackage',$package->get('id'));
            break;

            case xPDOTransport::ACTION_UNINSTALL:
                /* remove the package on uninstall */
                $package = $modx->getObject('transport.modTransportPackage',array('signature' => $signature));
                if ($package) {
                    if ($package->uninstall()) {
                        /** @var modCacheManager $cacheManager */
                        $cacheManager= $modx->getCacheManager();
                        $cacheManager->refresh();
                        $modx->logManagerAction('package_uninstall','transport.modTransportPackage',$package->get('id'));
                    }
                }
            break;
        }
    }

    return $success;
BobRay commented 11 years ago

Sorry, my bad. The duplicate signatures in the resolvers and validators was indeed a bug, and the new subpackage code somehow didn't make it into the build.transport.php file. I'll release a new version with the fixes. Thanks for all your help.

In the meantime, you can use the code in the dev branch here:

https://github.com/BobRay/MyComponent/blob/dev/core/components/mycomponent/elements/chunks/build.transport.php

to replace the code in your project directory's _build/build.transport.php file

and the code here:

https://github.com/BobRay/MyComponent/blob/dev/core/components/mycomponent/model/mycomponent/subpackageadapter.class.php

To replace the code in your core/components/mycomponent/model/mycompnent/subpackageadapter.class.php file.

Sorry for the trouble.

DESIGNfromWITHIN commented 11 years ago

Hi Bob,

No trouble! Love the package, will be amazing once I have this part running.

So now the correct plugin respolvers are created... that works. But still no subpackage.resolver ... This is not being created at all.

I tried ExportObjects, all looks fine just no mention of a subpackage.resolver

BobRay commented 11 years ago

Are you using the new version (3.1.1-pl)?

On Sun, Jul 21, 2013 at 5:17 AM, Menno Pietersen notifications@github.comwrote:

Hi Bob,

No trouble! Love the package, will be amazing once I have this part running.

So now the correct plugin respolvers are created... that works. But still no subpackage.resolver ... This is not being created at all.

I tried ExportObjects, all looks fine just no mention of a subpackage.resolver

— Reply to this email directly or view it on GitHubhttps://github.com/BobRay/MyComponent/issues/17#issuecomment-21307918 .

DESIGNfromWITHIN commented 11 years ago

Haha IT WORKS! Thanks so much Bob!

Truly amazing plugin