Skip to content

Commit

Permalink
Added simple Magento modman file generator for GIT.
Browse files Browse the repository at this point in the history
  • Loading branch information
andkirby committed Jan 13, 2015
0 parents commit 11c8609
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
16 changes: 16 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "andkirby/modman-generator",
"description": "Simple script which helps generate modman file based update \"git ls-files\" command.",
"license": "MIT",
"authors": [
{
"name": "Andrew Roslik",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {},
"bin": [
"modman-generate"
]
}
39 changes: 39 additions & 0 deletions modman-generate
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env php
<?php
$ignoreFiles = array(
'modman',
'composer',
'instructions',
'\.gitignore',
'README\.md',
'LICENSE',
);
$ignoreFiles = implode('|', $ignoreFiles);
$files = `git ls-files | grep -vE "($ignoreFiles)"`;

//match directories
preg_match_all(
'~^app/code/([A-z_]+/){3}|app/etc/modules/[^\n]*|app/design/([^/\n]+/?){6}|(shell|js|skin)/[^\n]+|lib/[A-z]+/~s',
$files, $matches
);
$list = array_unique($matches[0]);

//find long string
$maxLength = max(array_map('strlen', $list));

//make output
foreach ($list as $item) {
if (is_file($item)) {
$space = str_repeat(' ', $maxLength - strlen($item) + 3);
$output[] = "$item $space $item";
} else {
$item = rtrim($item, '/') . '/';
$space = str_repeat(' ', $maxLength - strlen($item) + 2);
$output[] = "$item* $space $item";
}
}
$output = implode("\n", $output);

echo "'modman' file generated.";
file_put_contents('modman', $output);

0 comments on commit 11c8609

Please sign in to comment.