We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10378
    • 375 Posts
    Is it possible to setup the build.tranport script to exclude defined files from packaging in?
    E.g. exclude all files prefixed with __ (double underscore) or exclude files which includes the string 'test' in filename.

    Thanks,
    Martin
      Freelancer @bitego http://www.bitego.com
      ---
      GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
      More infos here: http://www.bitego.com/extras/goodnews/
      • 22303 MODX Staff
      • 10,725 Posts
      I assume you are trying to prevent it from packaging some core files, since that is all that is packaged into the core.transport.zip. Can I first ask the intention here? I little more information and I can probably make a better recommendation...
        • 10378
        • 375 Posts
        Hi @opengeek - It's nothing special:

        I have some files in the dev folder of my project I don't like to have in my transport package. And I'd like to know if there is any chance to exclude them from packing in without always removing them manually from dev folder.
          Freelancer @bitego http://www.bitego.com
          ---
          GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
          More infos here: http://www.bitego.com/extras/goodnews/
          • 22303 MODX Staff
          • 10,725 Posts
          If it is within the core folders that are distributed with MODX and packaged into the core.transport.zip, then no, there currently is not a way to do that.
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            I think this is not about packaging MODX, but packaging a third party package... ie not wanting some files from the components directory to be packaged in.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 10378
              • 375 Posts
              Hi Mark, you got it! Is my English that bad? (I think so)
                Freelancer @bitego http://www.bitego.com
                ---
                GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
                More infos here: http://www.bitego.com/extras/goodnews/
                • 22303 MODX Staff
                • 10,725 Posts
                Oh, sorry for my misunderstanding; I thought you mean the build.transport script in the core. Sorry.

                I do believe there is a way to do that...

                In xPDOCacheManager::copyTree(), there is a check for two options that you could use, copy_exclude_items and copy_exclude_patterns. These options could be set in a specific vehicle's attributes, or in the package attributes.

                Use in specific vehicle via the vehicle attributes, used in this case for a resolver:
                $vehicle = $builder->createVehicle($category, array_merge($categoryAttributes, array(
                    'copy_exclude_patterns' => array('#test#i', '#^__#')
                ));
                $vehicle->resolve('file', array(
                    'source' => $sources['source_core'],
                    'target' => "return MODX_CORE_PATH . 'components/';",
                ));
                $builder->putVehicle($vehicle);
                


                Use in package attributes, observed globally by any file resolvers or xPDOFileVehicles:
                $builder->setPackageAttributes(
                    array(
                        'license' => file_get_contents($sources['docs'] . 'LICENSE.md'),
                        'readme' => file_get_contents($sources['docs'] . 'README.md'),
                        'changelog' => file_get_contents($sources['docs'] . 'CHANGELOG.md'),
                        'copy_exclude_patterns' => array('#test#i', '#^__#')
                    )
                );
                


                Give it a try and let me know if this works for you or not.
                  • 3749
                  • 24,544 Posts
                  That's very cool. I didn't know that was an option. You could also move the files somewhere else at the beginning of your build.transport.php file and put them back at the end.

                  Of course the easiest way is to just keep them somewhere else in the first place. Usually files you don't want to transfer go in the _build directory or any directory other than assets/ and core/
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 10378
                    • 375 Posts
                    Thank you @opengeek,

                    thats exactly what I was looking for!
                    This should be in MODX documentation. Maybe someone could add this info?
                      Freelancer @bitego http://www.bitego.com
                      ---
                      GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
                      More infos here: http://www.bitego.com/extras/goodnews/
                      • 10378
                      • 375 Posts
                      OK - tried to implement this but doesn't seem to work - doesn't throw an error but targeted files are still in transport package:

                      ...
                      
                      /* Create category vehicle for all elements */
                      $attributes = array(
                          xPDOTransport::UNIQUE_KEY => 'category',
                          xPDOTransport::PRESERVE_KEYS => false,
                          xPDOTransport::UPDATE_OBJECT => true,
                          xPDOTransport::RELATED_OBJECTS => true,
                          xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array(
                              'Snippets' => array(
                                  xPDOTransport::PRESERVE_KEYS => false,
                                  xPDOTransport::UPDATE_OBJECT => true,
                                  xPDOTransport::UNIQUE_KEY => 'name',
                              ),
                              'Chunks' => array(
                                  xPDOTransport::PRESERVE_KEYS => false,
                                  xPDOTransport::UPDATE_OBJECT => true,
                                  xPDOTransport::UNIQUE_KEY => 'name',
                              ),
                              'Plugins' => array(
                                  xPDOTransport::PRESERVE_KEYS => false,
                                  xPDOTransport::UPDATE_OBJECT => true,
                                  xPDOTransport::UNIQUE_KEY => 'name',
                              ),
                              'Templates' => array(
                                  xPDOTransport::PRESERVE_KEYS => false,
                                  xPDOTransport::UPDATE_OBJECT => true,
                                  xPDOTransport::UNIQUE_KEY => 'templatename',
                              ),
                              'TemplateVars' => array(
                                  xPDOTransport::PRESERVE_KEYS => false,
                                  xPDOTransport::UPDATE_OBJECT => true,
                                  xPDOTransport::UNIQUE_KEY => 'name',
                              ),
                          )
                      );
                      // Exclude files with a specific pattern (eg. __ prefix)
                      $categoryAttributes = array_merge($attributes, array('copy_exclude_patterns' => array('#^__#')));
                      
                      $vehicle = $builder->createVehicle($category, $categoryAttributes);
                      $builder->putVehicle($vehicle);
                      ...
                      



                      And also tried this:

                      ...
                      /* Add the license file, readme */
                      $builder->setPackageAttributes(array(
                          'license'   => file_get_contents($sources['docs'].'license.txt'),
                          'readme'    => file_get_contents($sources['docs'].'readme.txt'),
                          'changelog' => file_get_contents($sources['docs'].'changelog.txt'),
                          'copy_exclude_patterns' => array('#^__#'),
                      ));
                      ...
                      


                      What's the syntax for the pattern description? I'm a complete RegEx noob if this is the syntax...
                        Freelancer @bitego http://www.bitego.com
                        ---
                        GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
                        More infos here: http://www.bitego.com/extras/goodnews/