diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index fed59d8..444ab54 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -47,6 +47,9 @@ jobs: - name: Show PHP version run: php -v + - name: Install Composer dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Generate HTML files run: php generate.php diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index ec68bab..fa6e588 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -21,7 +21,7 @@ jobs: php-version: 8.2 - name: Install Composer dependencies - run: composer update --no-interaction --prefer-dist + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - name: Run tests via PHPStan run: composer phpstan diff --git a/.gitignore b/.gitignore index 035edb9..1049f24 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,12 @@ # Composer /vendor/ +# PHPUnit +.phpunit.cache + # Generated files index.html lang + +# Mac OS +.DS_Store diff --git a/generate.php b/generate.php index cc4affe..13c4b4d 100644 --- a/generate.php +++ b/generate.php @@ -1,110 +1,11 @@ run() +require_once('./vendor/autoload.php'); +use GoodFirstIssue\Generator; +use GoodFirstIssue\GitHubAPIClient; -if (!is_dir('lang')) { - mkdir('lang'); -} - - -// Read the JSON file -$json = file_get_contents('repositories.json'); - -// Decode the JSON file -$json_data = json_decode($json, true); - -// Display data -print_r($json_data); - -// TODO Рандомизируем массив с репозиториями - -$indexContent = "
' . $repositoryData['description'] . '
'; - - $repositoriesByLanguage[$repositoryData['language']][] = $repositoryData['full_name']; - - // Записываем ищуйки в общий файл -} - - -file_put_contents('index.html', $indexContent); - - -foreach ($repositoriesByLanguage as $lang => $repositories) { - if (strlen($lang) < 1) { - $lang = 'other'; - } - - print_r('Language: ' . $lang); - - $langFile = 'lang/' . $lang . '.html'; - if (file_exists($langFile)) { - $status = unlink($langFile) ? 'The file ' . $langFile . ' has been deleted' . "\n" : 'Error deleting ' . $langFile . "\n"; - echo $status; - } - - - // TODO Пишем шапку файла - file_put_contents($langFile, '' . $issue['title'] . '
'; - $str .= '' . $issue['html_url'] . '
'; - - file_put_contents($langFile, $str, FILE_APPEND); - } - - } - - -} - +$generator = new Generator(__DIR__, new GitHubAPIClient); +$generator->run(); diff --git a/src/DTO/Issue.php b/src/DTO/Issue.php new file mode 100644 index 0000000..befba3c --- /dev/null +++ b/src/DTO/Issue.php @@ -0,0 +1,15 @@ + + */ + private array $issues = []; + + public function __construct( + public readonly string $html_url, // Ex: "https://github.com/octocat/Hello-World" + public readonly string $full_name,// Ex: "octocat/Hello-World" + public readonly string $description, // Ex: "This your first repo!" + public readonly string $language, // Ex: null, + public readonly int $stargazers_count, // Ex: 80, + public readonly int $open_issues_count, // Ex: 0, + public readonly int $open_issues, // Ex: 0, + public readonly string $updated_at // Ex: "2011-01-26T19:14:43Z", + ) { + } + + /** + * @return array' . $repositoryData['description'] . '
'; + // + // $repositoriesByLanguage[$repositoryData['language']][] = $repositoryData['full_name']; + // + // // Записываем ищуйки в общий файл + // } + // + // + // file_put_contents($langFile, $str, FILE_APPEND); + // + // file_put_contents('index.html', $indexContent); + // + // + // foreach ($repositoriesByLanguage as $lang => $repositories) { + // if (strlen($lang) < 1) { + // $lang = 'other'; + // } + // + // print_r('Language: ' . $lang); + // + // $langFile = 'lang/' . $lang . '.html'; + // if (file_exists($langFile)) { + // $status = unlink($langFile) ? 'The file ' . $langFile . ' has been deleted' . "\n" : 'Error deleting ' . $langFile . "\n"; + // echo $status; + // } + // + // + // // TODO Пишем шапку файла + // file_put_contents($langFile, '' . $issue['title'] . '
'; + // $str .= '' . $issue['html_url'] . '
'; + // + // file_put_contents($langFile, $str, FILE_APPEND); + // } + // } + // } + // } +} diff --git a/src/Templates/Examples/issues.html b/src/Templates/Examples/issues.html new file mode 100644 index 0000000..fe5359e --- /dev/null +++ b/src/Templates/Examples/issues.html @@ -0,0 +1,211 @@ + + + + + ++ + This is a wider card with supporting text below as a natural lead-in to + additional content. This content is a little bit longer. + +
++ + This is a wider card with supporting text below as a natural lead-in to + additional content. This content is a little bit longer. + +
+Good First Issue curates easy pickings from popular open-source projects, and helps you make your first + contribution to open-source.
+ + + ++ Made with ♥ by + + Alexander Gomzyakov + +
++ + This is a wider card with supporting text below as a natural lead-in to + additional content. This content is a little bit longer. + +
++ + This is a wider card with supporting text below as a natural lead-in to + additional content. This content is a little bit longer. + +
++ + This is a wider card with supporting text below as a natural lead-in to + additional content. This content is a little bit longer. + +
+Good First Issue curates easy pickings from popular open-source projects, and helps you make your first + contribution to open-source.
+ + + ++ Made with ♥ by + + Alexander Gomzyakov + +
+Good First Issue curates easy pickings from popular open-source projects, and helps you make your first + contribution to open-source.
+ + + ++ Made with ♥ by + + Alexander Gomzyakov + +
++ + %REPO_DESCRIPTION% + +
+