diff --git a/Dockerfile b/Dockerfile index 199458d..d0db361 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,19 @@ -FROM php:7.4-cli +FROM erikaheidi/minicli:php81 -ARG user=dynacover -ARG uid=1000 - -# Install system dependencies -RUN apt-get update && apt-get install -y \ - git \ - curl \ - libonig-dev \ - libxml2-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libpng-dev \ - zip \ - unzip - -# Clear cache -RUN apt-get clean && rm -rf /var/lib/apt/lists/* - -# Install PHP extensions -RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \ - docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd +ARG user=minicli # Get latest Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -# Create system user to run commands -RUN useradd -G sudo,root -u $uid -d /home/$user $user RUN mkdir -p /home/$user/.composer && \ chown -R $user:$user /home/$user USER $user -# Copy app files -RUN mkdir -p /home/$user/dynacover -COPY . /home/$user/dynacover/ +COPY . /home/$user # Set working directory -WORKDIR /home/$user/dynacover +WORKDIR /home/$user # Install dependencies RUN composer install diff --git a/README.md b/README.md index 5145fa0..07c1dcb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ You can run Dynacover in three different ways: - as a **GitHub action**: the easiest way to run Dynacover is by setting it up in a public repository with [GitHub Actions](https://docs.github.com/en/actions), using repository secrets for credentials. [Follow this step-by-step guide](https://github.com/erikaheidi/dynacover/wiki/Setting-Up-Dynacover-with-GitHub-Actions) to set this up - no coding required. - with **Docker**: you can use the public [erikaheidi/dynacover](https://hub.docker.com/repository/docker/erikaheidi/dynacover) Docker image to run Dynacover with a single command, no PHP required. [Follow this guide](https://github.com/erikaheidi/dynacover/wiki/Running-Dynacover-with-Docker) to set this up. - to further customize your cover, you can clone the [dynacover repo](https://hub.docker.com/repository/docker/erikaheidi/dynacover) to customize banner resources (JSON template and header images, both located at `app/Resources`), then build a local copy of the Dynacover Docker image to use your custom changes. -- with a **PHP CLI environment**: this will require `php-cli` 7.4+, Composer, and a few extensions: `php-gd`, `php-mbstring`, `php-curl`, and `php-json`. [Follow this guide](https://github.com/erikaheidi/dynacover/wiki/Running-Dynacover-on-a-PHP-CLI-environment) to set it up. +- with a **PHP CLI environment**: this will require `php-cli` 8.1+, Composer, and a few extensions: `php-gd`, `php-mbstring`, `php-curl`, and `php-json`. [Follow this guide](https://github.com/erikaheidi/dynacover/wiki/Running-Dynacover-on-a-PHP-CLI-environment) to set it up. ### Obtaining Required Tokens diff --git a/app/Command/Cover/GenerateController.php b/app/Command/Cover/GenerateController.php index 6eaafc4..78058b2 100644 --- a/app/Command/Cover/GenerateController.php +++ b/app/Command/Cover/GenerateController.php @@ -10,7 +10,7 @@ class GenerateController extends CommandController { - public function handle() + public function handle(): void { $template_file = $this->hasParam('template') ? $this->getParam('template') : $this->getApp()->config->default_template; diff --git a/app/Command/Cover/UpdateController.php b/app/Command/Cover/UpdateController.php index c878091..f8d71d6 100644 --- a/app/Command/Cover/UpdateController.php +++ b/app/Command/Cover/UpdateController.php @@ -7,7 +7,7 @@ class UpdateController extends CommandController { - public function handle() + public function handle(): void { $template_file = $this->hasParam('template') ? $this->getParam('template') : $this->getApp()->config->default_template; diff --git a/app/Command/Cover/UploadController.php b/app/Command/Cover/UploadController.php index d052694..2ac3b81 100644 --- a/app/Command/Cover/UploadController.php +++ b/app/Command/Cover/UploadController.php @@ -5,18 +5,21 @@ use App\Service\TwitterServiceProvider; use App\Storage; use Minicli\Command\CommandController; +use MongoDB\Driver\Exception\CommandException; class UploadController extends CommandController { - public function handle() + /** + * @throws \Exception + */ + public function handle(): void { /** @var TwitterServiceProvider $twitter */ $twitter = $this->getApp()->twitter; $banner_path = Storage::root() . 'latest_header.png'; if (!is_file($banner_path)) { - $this->getPrinter()->error("Header not found at default location."); - return 1; + throw new \Exception("Header not found at default location."); } $post = [ @@ -31,7 +34,6 @@ public function handle() $twitter->client->post('/account/update_profile_banner', $post); $this->getPrinter()->info("Finished uploading new banner."); - return 0; } } \ No newline at end of file diff --git a/app/Command/Fetch/FollowersController.php b/app/Command/Fetch/FollowersController.php index a0b2bab..84b5a49 100644 --- a/app/Command/Fetch/FollowersController.php +++ b/app/Command/Fetch/FollowersController.php @@ -8,7 +8,7 @@ class FollowersController extends CommandController { - public function handle() + public function handle(): void { /** @var TwitterServiceProvider $twitter */ $twitter = $this->getApp()->twitter; @@ -24,6 +24,5 @@ public function handle() } $this->getPrinter()->info("Finished."); - return 0; } } \ No newline at end of file diff --git a/app/Command/Generate/InteractionsController.php b/app/Command/Generate/InteractionsController.php index 43ef05a..895cab7 100644 --- a/app/Command/Generate/InteractionsController.php +++ b/app/Command/Generate/InteractionsController.php @@ -12,7 +12,7 @@ class InteractionsController extends CommandController { - public function handle(): int + public function handle(): void { //Start by building a dynamic template $template = new Template('twitter-interactions', [ @@ -104,7 +104,5 @@ public function handle(): int $save_path = Storage::root() . 'latest_header.png'; $template->write($save_path); $this->getPrinter()->info("Finished generating cover at $save_path."); - - return 0; } } \ No newline at end of file diff --git a/app/Command/Generate/TwitterController.php b/app/Command/Generate/TwitterController.php index add8173..6091524 100644 --- a/app/Command/Generate/TwitterController.php +++ b/app/Command/Generate/TwitterController.php @@ -11,7 +11,10 @@ class TwitterController extends CommandController { - public function handle(): int + /** + * @throws \Exception + */ + public function handle(): void { $template_dir = $this->getApp()->config->templates_dir; $template_file = $this->getApp()->config->default_template; @@ -25,8 +28,7 @@ public function handle(): int if (!is_file($template_file)) { $template_file = $template_dir . '/' . $template_file; if (!is_file($template_file)) { - $this->getPrinter()->error("Template $template_file not found."); - return 1; + throw new \Exception("Template $template_file not found."); } } @@ -63,7 +65,5 @@ public function handle(): int $template->write($save_path); $this->getPrinter()->info("Finished generating cover at $save_path, using $template_file as template."); - - return 0; } } \ No newline at end of file diff --git a/app/Command/Help/DefaultController.php b/app/Command/Help/DefaultController.php index ba48d57..8836e87 100644 --- a/app/Command/Help/DefaultController.php +++ b/app/Command/Help/DefaultController.php @@ -10,13 +10,13 @@ class DefaultController extends CommandController /** @var array */ protected $command_map = []; - public function boot(App $app) + public function boot(App $app): void { parent::boot($app); - $this->command_map = $app->command_registry->getCommandMap(); + $this->command_map = $app->commandRegistry->getCommandMap(); } - public function handle() + public function handle(): void { $this->getPrinter()->info('Available Commands'); diff --git a/app/Command/Help/TableController.php b/app/Command/Help/TableController.php deleted file mode 100644 index 6a49170..0000000 --- a/app/Command/Help/TableController.php +++ /dev/null @@ -1,26 +0,0 @@ -getPrinter()->display('Testing Tables'); - - $table = new TableHelper(); - $table->addHeader(['Header 1', 'Header 2', 'Header 3']); - - for($i = 1; $i <= 10; $i++) { - $table->addRow([$i, rand(0, 10), "other string $i"]); - } - - $this->getPrinter()->newline(); - $this->getPrinter()->rawOutput($table->getFormattedTable(new ColorOutputFilter())); - $this->getPrinter()->newline(); - } -} \ No newline at end of file diff --git a/app/Command/Help/TestController.php b/app/Command/Help/TestController.php deleted file mode 100644 index 321294c..0000000 --- a/app/Command/Help/TestController.php +++ /dev/null @@ -1,16 +0,0 @@ -hasParam('user') ? $this->getParam('user') : 'World'; - $this->getPrinter()->display(sprintf("Hello, %s!", $name)); - - print_r($this->getParams()); - } -} \ No newline at end of file diff --git a/app/Service/GithubServiceProvider.php b/app/Service/GithubServiceProvider.php index e42a766..ae2ebbb 100644 --- a/app/Service/GithubServiceProvider.php +++ b/app/Service/GithubServiceProvider.php @@ -20,7 +20,7 @@ class GithubServiceProvider implements ServiceInterface static string $API_ENDPOINT = "https://api.github.com/graphql"; - public function load(App $app) + public function load(App $app): void { $this->agent = new Client(); $this->token = $app->config->github_api_bearer; diff --git a/app/Service/TwitterServiceProvider.php b/app/Service/TwitterServiceProvider.php index 53cf9d1..8cbdfe1 100644 --- a/app/Service/TwitterServiceProvider.php +++ b/app/Service/TwitterServiceProvider.php @@ -12,7 +12,7 @@ class TwitterServiceProvider implements ServiceInterface { public TwitterOAuth $client; - public function load(App $app) + public function load(App $app): void { $api_token = $app->config->twitter_consumer_key; $api_secret = $app->config->twitter_consumer_secret; diff --git a/composer.json b/composer.json index f71911b..741e17d 100644 --- a/composer.json +++ b/composer.json @@ -10,12 +10,12 @@ } }, "require": { - "minicli/minicli": "^2.0", + "minicli/minicli": "^3.2.1", "abraham/twitteroauth": "^2.0", "ext-gd": "*", "ext-json": "*", "minicli/curly": "^0.1.2", - "erikaheidi/gdaisy": "^0.1.5" + "erikaheidi/gdaisy": "^0.3.0" }, "scripts": { "post-install-cmd": [ diff --git a/composer.lock b/composer.lock index 30eb046..9eb5980 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ff2d15be925595100cccb7157e46e9c4", + "content-hash": "a5bc7912e73ac3b7c52cd20567b14fa1", "packages": [ { "name": "abraham/twitteroauth", @@ -69,16 +69,16 @@ }, { "name": "composer/ca-bundle", - "version": "1.2.10", + "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "9fdb22c2e97a614657716178093cd1da90a64aa8" + "reference": "30897edbfb15e784fe55587b4f73ceefd3c4d98c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/9fdb22c2e97a614657716178093cd1da90a64aa8", - "reference": "9fdb22c2e97a614657716178093cd1da90a64aa8", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/30897edbfb15e784fe55587b4f73ceefd3c4d98c", + "reference": "30897edbfb15e784fe55587b4f73ceefd3c4d98c", "shasum": "" }, "require": { @@ -90,7 +90,7 @@ "phpstan/phpstan": "^0.12.55", "psr/log": "^1.0", "symfony/phpunit-bridge": "^4.2 || ^5", - "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" + "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0" }, "type": "library", "extra": { @@ -125,7 +125,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.2.10" + "source": "https://github.com/composer/ca-bundle/tree/1.3.3" }, "funding": [ { @@ -141,27 +141,27 @@ "type": "tidelift" } ], - "time": "2021-06-07T13:58:28+00:00" + "time": "2022-07-20T07:14:26+00:00" }, { "name": "erikaheidi/gdaisy", - "version": "0.1.6", + "version": "0.3.1", "source": { "type": "git", "url": "https://github.com/erikaheidi/gdaisy.git", - "reference": "2c9bdcb602b4118e6e17b588b2497c81a052dfc0" + "reference": "eaf23e5d047d0077457c5215329f00e3417e80d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/erikaheidi/gdaisy/zipball/2c9bdcb602b4118e6e17b588b2497c81a052dfc0", - "reference": "2c9bdcb602b4118e6e17b588b2497c81a052dfc0", + "url": "https://api.github.com/repos/erikaheidi/gdaisy/zipball/eaf23e5d047d0077457c5215329f00e3417e80d2", + "reference": "eaf23e5d047d0077457c5215329f00e3417e80d2", "shasum": "" }, "require": { "ext-gd": "*", "ext-json": "*", - "minicli/minicli": "^2.2", - "php": "^7.4|^8.0" + "minicli/minicli": "^3.2", + "php": "^8.1" }, "require-dev": { "pestphp/pest": "^1.0" @@ -183,9 +183,9 @@ "description": "php-gd templating system", "support": { "issues": "https://github.com/erikaheidi/gdaisy/issues", - "source": "https://github.com/erikaheidi/gdaisy/tree/0.1.6" + "source": "https://github.com/erikaheidi/gdaisy/tree/0.3.1" }, - "time": "2021-06-30T16:55:26+00:00" + "time": "2022-09-28T16:07:04+00:00" }, { "name": "minicli/curly", @@ -229,32 +229,31 @@ }, { "name": "minicli/minicli", - "version": "2.2.1", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/minicli/minicli.git", - "reference": "b359a740b7dc258acaf52d4373cac5f545705b33" + "reference": "2d31b303461d0ec1f8c6d0be00f8b26be8766fbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/minicli/minicli/zipball/b359a740b7dc258acaf52d4373cac5f545705b33", - "reference": "b359a740b7dc258acaf52d4373cac5f545705b33", + "url": "https://api.github.com/repos/minicli/minicli/zipball/2d31b303461d0ec1f8c6d0be00f8b26be8766fbe", + "reference": "2d31b303461d0ec1f8c6d0be00f8b26be8766fbe", "shasum": "" }, "require": { "ext-readline": "*", - "php": ">=7.3" + "php": ">=8" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", + "friendsofphp/php-cs-fixer": "^3.5", "pestphp/pest": "^1.0", "phpunit/phpunit": "^9.0" }, "type": "library", "autoload": { "psr-4": { - "Minicli\\": "src/", - "Assets\\": "tests/Assets" + "Minicli\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -269,7 +268,7 @@ ], "support": { "issues": "https://github.com/minicli/minicli/issues", - "source": "https://github.com/minicli/minicli/tree/2.2.1" + "source": "https://github.com/minicli/minicli/tree/3.2.1" }, "funding": [ { @@ -277,7 +276,7 @@ "type": "github" } ], - "time": "2021-05-08T15:36:01+00:00" + "time": "2022-09-23T09:04:22+00:00" } ], "packages-dev": [], @@ -291,5 +290,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.3.0" }