Package import using drush
The Site Studio Sync sub module provides two Drush commands that allow package imports. Single package import command for importing a package per command and a multi-package import command, that allows multiple package imports via single command.
Single package import command allows importing a package from specified or default location. Both individual and full packages are supported:
This command has the following options:
- --path[=PATH] - Specify path to a directory containing package files. If this option is omitted, command defaults to value set in $settings['site_studio_sync'].
- --diff[=DIFF] - Show preview as a diff. If this option is provided, confirmation of changes will be required in order for import to complete, unless --yes is also used, to auto-confirm the changes.
- --extra-validation - Import all configuration and files with default Drupal validation and perform data integrity validation on Site Studio configuration. This import takes more time and resources.
Adding -h as option will output "Import Cohesion packages from sync." message and the list of available options.
Package import command tracks what changes are being introduced and rebuilds relevant entities during the command process.
Multi-package import command allows importing multiple packages based on a a list stored in YAML file. Command syntax is as follows:
This command has only one argument - --path. The argument is required and needs to point to a package list file located in accessible part of filesystem.
Package list file needs to strictly follow specific formatting - it's a YAML format file, where each package is listed as element of an array. Each package definition needs to have package source type (`type`) and relevant metadata (`source`). A sample of what the content of such file could look like is this:
- type: package source: path: web/sites/default/files/package_collection/blog_feature_package options: extra-validation: false - type: package source: path: web/sites/default/files/package_collection/hero_package options: extra-validation: true
Package list file used in multi-import command is intended to be used with type property set to package. More information on the format of package list file is available here.
Things to know:
- No legacy package support - only new package format (introduced in Site Studio 6.8.0) is supported
- Order matters - packages are imported in the order listed in the package list file, with the package at the top of the list being the first and the package at the bottom being the last.
- Rebuild is optimised - a single rebuild process runs for all of the imported packages and only runs the least amount of rebuilding necessary.
- There is a PackageImportHandler (`cohesion_sync.package_import_handler`) service that allows leveraging this functionality via code.