Skip to content

Commit

Permalink
"templates-from-design" and "templates-to-design" arguments were added.
Browse files Browse the repository at this point in the history
  • Loading branch information
alpharder committed Apr 7, 2016
1 parent a7a7639 commit 711a905
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 29 deletions.
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ Usage:
addon:symlink [options] [--] <name> <addon-directory> <cart-directory>
Arguments:
name Add-on ID (name)
addon-directory Path to directory with add-on files
cart-directory Path to CS-Cart installation directory
name Add-on ID (name)
addon-directory Path to directory with add-on files
cart-directory Path to CS-Cart installation directory
Options:
-r, --relative Created symlinks will have a relative path to the target file. By default the created symlinks have an absolute path to target.
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
-r, --relative Created symlinks will have a relative path to the target file. By default the created symlinks have an absolute path to target.
--templates-to-design Whether to take the add-on templates from "var/themes_repository" path at the add-on directory and put them at "design/themes" path in the CS-Cart installation directory . When this option is not specified, the templates are being taken from "var/themes_repository" and also put into "var/themes_repository" directory.
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Creates symlinks for add-on files at the CS-Cart installation directory, allowing you to develop and store add-on files in a separate Git repository.
Expand All @@ -57,19 +58,20 @@ Usage:
addon:export [options] [--] <name> <addon-directory> <cart-directory>
Arguments:
name Add-on ID (name)
addon-directory Path to directory where files should be moved to
cart-directory Path to CS-Cart installation directory
name Add-on ID (name)
addon-directory Path to directory where files should be moved to
cart-directory Path to CS-Cart installation directory
Options:
-d, --delete Files and directories will be moved instead of being copied.
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
-d, --delete Files and directories will be moved instead of being copied.
--templates-from-design Whether to take the add-on templates from "design/themes" path at CS-Cart installation directory and put them at "var/themes_repository" path in the add-on files directory. When this option is not specified, the templates are being taken from "var/themes_repository" and also put into "var/themes_repository" directory.
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Copies or moves all add-on files to the separate directory, preserving the structure of directories.
Expand Down
30 changes: 28 additions & 2 deletions src/Sdk/Commands/AddonExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
class AddonExportCommand extends Command
{
use ValidateCartPathTrait;

/**
* @inheritdoc
*/
Expand All @@ -40,7 +41,12 @@ protected function configure()
'd',
InputOption::VALUE_NONE,
'Files and directories will be moved instead of being copied.'
);;
)
->addOption('templates-from-design',
null,
InputOption::VALUE_NONE,
'Whether to take the add-on templates from "design/themes" path at CS-Cart installation directory and put them at "var/themes_repository" path in the add-on files directory. When this option is not specified, the templates are being taken from "var/themes_repository" and also put into "var/themes_repository" directory.'
);
}

/**
Expand All @@ -66,6 +72,26 @@ protected function execute(InputInterface $input, OutputInterface $output)

$addon = new Addon($addon_id, $abs_cart_path);
$addon_files_glob_masks = $addon->getFilesGlobMasks();

$addon_files_glob_masks = array_filter($addon_files_glob_masks, function ($glob_mask) use ($input) {
if ($input->getOption('templates-from-design')) {

// Ignore "var/themes_repository/" masks
if (mb_strpos($glob_mask, 'var/themes_repository/') === 0) {
return false;
}

return true;
} else {
// Ignore "design/themes/" masks
if (mb_strpos($glob_mask, 'design/themes/') === 0) {
return false;
}

return true;
}
});

$glob_matches = $addon->matchFilesAgainstGlobMasks($addon_files_glob_masks, $abs_cart_path);

$counter = 0;
Expand All @@ -83,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

// Add-on templates at the "design/" directory will be
// exported to the "var/themes_repository/" directory.
if (mb_strpos($rel_filepath, 'design/themes/') === 0) {
if ($input->getOption('templates-from-design') && mb_strpos($rel_filepath, 'design/themes/') === 0) {
$abs_addon_filepath = $abs_addon_path
. 'var/themes_repository/'
. mb_substr($rel_filepath, mb_strlen('design/themes/'));
Expand Down
19 changes: 18 additions & 1 deletion src/Sdk/Commands/AddonSymlinkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ protected function configure()
'r',
InputOption::VALUE_NONE,
'Created symlinks will have a relative path to the target file. By default the created symlinks have an absolute path to target.'
)
->addOption('templates-to-design',
null,
InputOption::VALUE_NONE,
'Whether to take the add-on templates from "var/themes_repository" path at the add-on directory and put them at "design/themes" path in the CS-Cart installation directory . When this option is not specified, the templates are being taken from "var/themes_repository" and also put into "var/themes_repository" directory.'
);
}

Expand All @@ -63,6 +68,18 @@ protected function execute(InputInterface $input, OutputInterface $output)

$addon = new Addon($addon_id, $abs_addon_path);
$addon_files_glob_masks = $addon->getFilesGlobMasks();

$addon_files_glob_masks = array_filter($addon_files_glob_masks, function ($glob_mask) {

// Always ignore "design/themes/" masks because there shouldn't
// be such directory in add-on files directory
if (mb_strpos($glob_mask, 'design/themes/') === 0) {
return false;
}

return true;
});

$glob_matches = $addon->matchFilesAgainstGlobMasks($addon_files_glob_masks, $abs_addon_path);

$output->writeln(sprintf('<fg=magenta;options=bold>Creating symlinks at the "%s" directory:</>',
Expand All @@ -74,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

// Add-on templates at the "var/themes_repository/" directory will be
// symlinked to the "design/themes/" directory.
if (mb_strpos($rel_filepath, 'var/themes_repository/') === 0) {
if ($input->getOption('templates-to-design') && mb_strpos($rel_filepath, 'var/themes_repository/') === 0) {
$abs_cart_filepath = $abs_cart_path
. 'design/themes/'
. mb_substr($rel_filepath, mb_strlen('var/themes_repository/'));
Expand Down
16 changes: 12 additions & 4 deletions src/Sdk/Commands/AddonSyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,20 @@ protected function execute(InputInterface $input, OutputInterface $output)

$arguments = array(
'name' => $input->getArgument('name'),
'addon-directory' => $input->getArgument('addon-directory'),
'cart-directory' => $input->getArgument('cart-directory'),
'addon-directory' => $input->getArgument('addon-directory'),
'cart-directory' => $input->getArgument('cart-directory'),
);

$export_input = new ArrayInput($arguments + ['--delete' => true]);
$symlink_input = new ArrayInput($arguments + ['--relative' => $input->getOption('relative')]);
$export_input = new ArrayInput($arguments + [
'--delete' => true,
'--templates-from-design' => true,
]
);
$symlink_input = new ArrayInput($arguments + [
'--relative' => $input->getOption('relative'),
'--templates-to-design' => true,
]
);

$addon_export_command->run($export_input, $output);
$output->writeln('');
Expand Down

0 comments on commit 711a905

Please sign in to comment.