Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
Updated dependencies and upgraded code (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikaheidi committed Sep 28, 2022
1 parent 7211c47 commit 077c1a8
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 121 deletions.
32 changes: 4 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/Command/Cover/GenerateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion app/Command/Cover/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 6 additions & 4 deletions app/Command/Cover/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -31,7 +34,6 @@ public function handle()
$twitter->client->post('/account/update_profile_banner', $post);

$this->getPrinter()->info("Finished uploading new banner.");
return 0;
}

}
3 changes: 1 addition & 2 deletions app/Command/Fetch/FollowersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class FollowersController extends CommandController
{
public function handle()
public function handle(): void
{
/** @var TwitterServiceProvider $twitter */
$twitter = $this->getApp()->twitter;
Expand All @@ -24,6 +24,5 @@ public function handle()
}

$this->getPrinter()->info("Finished.");
return 0;
}
}
4 changes: 1 addition & 3 deletions app/Command/Generate/InteractionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down Expand Up @@ -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;
}
}
10 changes: 5 additions & 5 deletions app/Command/Generate/TwitterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.");
}
}

Expand Down Expand Up @@ -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;
}
}
6 changes: 3 additions & 3 deletions app/Command/Help/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
26 changes: 0 additions & 26 deletions app/Command/Help/TableController.php

This file was deleted.

16 changes: 0 additions & 16 deletions app/Command/Help/TestController.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Service/GithubServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/Service/TwitterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Loading

0 comments on commit 077c1a8

Please sign in to comment.