Initial commit: WordPress wp-content (themes, plugins, languages)

- Theme: momentry (custom theme with REST API routes)
- Plugins: code-snippets (contains all API proxies)
- Languages: zh_TW translations
- Excludes: cache, backups, uploads, logs
This commit is contained in:
OpenCode
2026-05-29 19:07:56 +08:00
commit 09ef1f000f
6521 changed files with 867163 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace TypistTech\Imposter\Plugin;
use Composer\Package\RootPackageInterface;
use RuntimeException;
use TypistTech\Imposter\ImposterFactory;
class AutoloadMerger
{
public static function run(RootPackageInterface $package): void
{
$autoload = $package->getAutoload();
$autoload = array_merge_recursive($autoload, [
'classmap' => static::getImposterAutoloads(),
]);
$package->setAutoload($autoload);
}
/**
* @return string[]
* @todo [Help Wanted] Think of a better way to handle file not found during installation
*/
protected static function getImposterAutoloads(): array
{
try {
$cwd = getcwd();
$imposter = ImposterFactory::forProject($cwd, ['typisttech/imposter-plugin']);
return array_map(function ($path) use ($cwd): string {
return str_replace($cwd . '/', '', $path);
}, $imposter->getAutoloads());
} catch (RuntimeException $exception) {
return [];
}
}
}

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace TypistTech\Imposter\Plugin;
use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Package\CompletePackage;
use Composer\Package\RootPackageInterface;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
class ImposterPlugin implements PluginInterface, EventSubscriberInterface
{
/**
* {@inheritDoc}
*/
public function activate(Composer $composer, IOInterface $io)
{
$package = $composer->getPackage();
if ($package instanceof RootPackageInterface) {
AutoloadMerger::run($package);
}
if ($package instanceof CompletePackage) {
$scripts = array_merge_recursive([
ScriptEvents::POST_INSTALL_CMD => [
'@composer dump-autoload --optimize',
],
ScriptEvents::POST_UPDATE_CMD => [
'@composer dump-autoload --optimize',
],
], $package->getScripts());
$package->setScripts($scripts);
}
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return [
ScriptEvents::PRE_AUTOLOAD_DUMP => [
['transform', PHP_INT_MAX - 1000],
],
];
}
public function transform(Event $event): void
{
Transformer::run(
$event->getIO()
);
}
public function deactivate(Composer $composer, IOInterface $io)
{
// Do nothing.
}
public function uninstall(Composer $composer, IOInterface $io)
{
// Do nothing.
}
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace TypistTech\Imposter\Plugin;
use Composer\IO\IOInterface;
use TypistTech\Imposter\ImposterFactory;
class Transformer
{
public static function run(IOInterface $io): void
{
// Print an empty line to separate imposter outputs.
$io->write('', true);
$io->write('', true);
$io->write('<info>Running Imposter...</info>', true);
$io->write('<info>======================</info>', true);
$io->write('Loading package information from <comment>' . getcwd() . '/composer.json</comment>', true);
$imposter = ImposterFactory::forProject(getcwd(), ['typisttech/imposter-plugin']);
$autoloads = $imposter->getAutoloads();
$count = count($autoloads);
$index = 1;
foreach ($autoloads as $autoload) {
$io->write(" - <comment>$index/$count</comment>: Transforming $autoload", true);
$imposter->transform($autoload);
$index++;
}
$io->write('<info>Success: Imposter transformed vendor files.</info>', true);
$invalidAutoloads = $imposter->getInvalidAutoloads();
if (! empty($invalidAutoloads)) {
$invalidAutoloadsCount = count($invalidAutoloads);
$io->writeError('', true);
$io->writeError(
// phpcs:ignore Generic.Files.LineLength.TooLong
"<warning>Warning: Imposter failed to transformed $invalidAutoloadsCount of the autoload path(s).</warning>",
true
);
foreach ($invalidAutoloads as $invalidAutoload) {
$io->writeError(" - $invalidAutoload", true);
}
}
// Print empty lines to separate imposter outputs.
$io->write('', true);
$io->write('', true);
}
}