Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions .devtools/update-headers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#!/usr/bin/env php
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

$licenseFile = __DIR__ . '/licence.txt';
$projectRoot = dirname(__DIR__);

if (!file_exists($licenseFile)) {
echo "Error: licence.txt not found at $licenseFile\n";
exit(1);
}

// Read the new license block (already formatted with /** */)
$newLicenseBlock = file_get_contents($licenseFile);
$newLicenseBlock = trim($newLicenseBlock);

// Function to find PHP files
function findPhpFiles($dir) {
$excludeDirs = ['vendor', 'phar', '.git', 'node_modules'];
$phpFiles = [];

$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
);

foreach ($iterator as $file) {
if ($file->isFile() && $file->getExtension() === 'php') {
$path = $file->getPathname();
$excluded = false;
foreach ($excludeDirs as $excludeDir) {
if (strpos($path, DIRECTORY_SEPARATOR . $excludeDir . DIRECTORY_SEPARATOR) !== false) {
$excluded = true;
break;
}
}
if (!$excluded) {
$phpFiles[] = $path;
}
}
}

return $phpFiles;
}

// Function to replace license header
function updateLicenseHeader($filePath, $newLicenseBlock) {
$content = file_get_contents($filePath);
$originalContent = $content;

// Check if file starts with shebang
$hasShebang = strpos($content, '#!') === 0;
$shebang = '';

if ($hasShebang) {
$lines = explode("\n", $content, 2);
$shebang = $lines[0] . "\n";
$content = isset($lines[1]) ? $lines[1] : '';
}

// Remove <?php tag temporarily
$hasPhpTag = preg_match('/^<\?php\s*\n?/s', $content);
if ($hasPhpTag) {
$content = preg_replace('/^<\?php\s*\n?/s', '', $content);
}

// Remove all existing comment blocks at the start
// This handles /** */ and /* */ style comments
while (preg_match('/^\s*\/\*/', $content)) {
$content = preg_replace('/^\s*\/\*.*?\*\/\s*/s', '', $content, 1);
}

// Remove leading whitespace
$content = ltrim($content);

// Build new content
$newContent = $shebang;
$newContent .= "<?php\n";
$newContent .= $newLicenseBlock . "\n\n";
$newContent .= $content;

return $newContent;
}

// Main execution
echo "Starting license header update...\n\n";

$phpFiles = findPhpFiles($projectRoot);
echo "Found " . count($phpFiles) . " PHP files to process\n\n";

$updated = 0;
$errors = 0;

foreach ($phpFiles as $file) {
try {
$relativePath = str_replace($projectRoot . DIRECTORY_SEPARATOR, '', $file);
echo "Processing: $relativePath ... ";

$newContent = updateLicenseHeader($file, $newLicenseBlock);
file_put_contents($file, $newContent);

echo "✓\n";
$updated++;
} catch (Exception $e) {
echo "✗ Error: " . $e->getMessage() . "\n";
$errors++;
}
}

echo "\n" . str_repeat('=', 60) . "\n";
echo "Update complete!\n";
echo "Files updated: $updated\n";
echo "Errors: $errors\n";
echo str_repeat('=', 60) . "\n";

exit($errors > 0 ? 1 : 0);
17 changes: 17 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

$config = new PrestaShop\CodingStandards\CsFixer\Config();

Expand Down
17 changes: 16 additions & 1 deletion build.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
<?php
/**
* Script to release a new version
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

$binDir = dirname(__FILE__).'/bin/';
$versionFile = $binDir.'/phar/current.version';

Expand Down
18 changes: 16 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
<?php
/**
* Prestashop Console
* Configuration File
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

$configuration = [];

/**
Expand Down
7 changes: 3 additions & 4 deletions console.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env php
<?php
/**
* 2007-2020 Hennes Hervé
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
Expand All @@ -14,9 +12,10 @@
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright 2007-2018 Hennes Hervé
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* http://www.h-hennes.fr/blog/
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

use PrestashopConsole\PrestashopConsoleApplication;
Expand Down
7 changes: 3 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* 2007-2018 Hennes Hervé
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
Expand All @@ -13,9 +11,10 @@
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright 2007-2018 Hennes Hervé
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* http://www.h-hennes.fr/blog/
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
Expand Down
28 changes: 3 additions & 25 deletions prestashopConsoleWrapper.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* Since 2016 Hennes Hervé
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
Expand All @@ -13,32 +11,12 @@
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright Since 2016 Hennes Hervé
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* http://www.h-hennes.fr/blog/
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

/**
* Console wrapper in browser
*
* With this way you cannot have interaction with the console, every parameters should be provided in url
*
* WARNING: Remove this file after your works as been done as it can be a security issue to let it present
*
* Upload this file in the root directory of your prestashop
* Call the page this way
* http://www.site.com/prestashopConsoleWrapper.php?command=command:name:domain&arguments['argumentKey']=argumentValue&=options['optionkey']=value
*
* Several examples :
*
* Show help of the command admin:user:list
* prestashopConsoleWrapper.php?command=admin:user:list&options[]=help
* List only active modules
* prestashopConsoleWrapper.php?command=module:list&options[]=active
* List only active modules not from prestashop
* prestashopConsoleWrapper.php?command=module:list&options[]=active&options[]=no-native
*
*/
class PrestashopConsoleWrapper
{
/**
Expand Down
6 changes: 2 additions & 4 deletions src/PrestashopConsole/Command/Admin/ProfilesListCommand.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* 2007-2021 Hennes Hervé
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
Expand All @@ -13,9 +11,9 @@
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright 2007-2021 Hennes Hervé
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* https://github.com/nenes25/prestashop_console*
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

Expand Down
7 changes: 3 additions & 4 deletions src/PrestashopConsole/Command/Admin/User/CreateCommand.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* 2007-2019 Hennes Hervé
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
Expand All @@ -13,9 +11,10 @@
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright 2007-2019 Hennes Hervé
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* http://www.h-hennes.fr/blog/
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

namespace PrestashopConsole\Command\Admin\User;
Expand Down
7 changes: 3 additions & 4 deletions src/PrestashopConsole/Command/Admin/User/ListCommand.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* 2007-2019 Hennes Hervé
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
Expand All @@ -13,9 +11,10 @@
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright 2007-2019 Hennes Hervé
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* http://www.h-hennes.fr/blog/
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

namespace PrestashopConsole\Command\Admin\User;
Expand Down
7 changes: 3 additions & 4 deletions src/PrestashopConsole/Command/Admin/User/PasswordCommand.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* 2007-2019 Hennes Hervé
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
Expand All @@ -13,9 +11,10 @@
* to contact@h-hennes.fr so we can send you a copy immediately.
*
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright 2007-2019 Hennes Hervé
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* http://www.h-hennes.fr/blog/
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/

namespace PrestashopConsole\Command\Admin\User;
Expand Down
1 change: 0 additions & 1 deletion src/PrestashopConsole/Command/Analyze/GlobalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* @author Hennes Hervé <contact@h-hennes.fr>
* @copyright since 2016 Hennes Hervé
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*
* https://github.com/nenes25/prestashop_console
* https://www.h-hennes.fr/blog/
*/
Expand Down
Loading