Skip to content

Commit

Permalink
Merge 17021d9 into e94dc7c
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Sep 1, 2022
2 parents e94dc7c + 17021d9 commit b3fd91c
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vendor/
public
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

Template(s) for the pull requests that we send on updates.

## Preview

To see a preview of how they look, head to [https://heartfelt-gumdrop-a08209.netlify.app/](https://heartfelt-gumdrop-a08209.netlify.app/)

## Templates

### Template for the pull request title
Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
"scripts": {
"phpstan": "phpstan analyse src tests",
"test": "@composer lint && phpunit",
"lint": "phpcs -p -n"
"lint": "phpcs -p -n",
"preview": [
"@composer install",
"php preview.php"
]
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.4",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0",
"php-coveralls/php-coveralls": "^2.0"
"php-coveralls/php-coveralls": "^2.0",
"league/commonmark": "^1.0 || ^2.3"
}
}
6 changes: 6 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build]
publish = "public"
command = "composer preview"

[build.environment]
PHP_VERSION = "7.4"
82 changes: 82 additions & 0 deletions preview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

use eiriksm\ViolinistMessages\UpdateListItem;
use eiriksm\ViolinistMessages\ViolinistMessages;
use eiriksm\ViolinistMessages\ViolinistUpdate;
use League\CommonMark\GithubFlavoredMarkdownConverter;

require_once "./vendor/autoload.php";

$message = new ViolinistMessages();
$removed = new UpdateListItem('third/removed', '2.2.0');
$removed->setIsRemoved(true);
$removed->setIsNew(false);
$update_items = [
new UpdateListItem('package/one', '2.0.1', '2.0.2'),
new UpdateListItem('other/package', '2.0.0'),
$removed
];
$update = new ViolinistUpdate();
$update->setName('vendor/updated_package');
$update->setCurrentVersion('1.0.0');
$update->setNewVersion('1.0.1');
$update->setUpdatedList($update_items);
$update->setChangedFiles(['README.md', 'composer.json']);
$update->setChangelog('- [e8c563c47](https://github.com/vendor/updated_package/commit/e8c563c47) `Prepare release`
- [87e59a5e7](https://github.com/vendor/updated_package/commit/87e59a5e7) `Update`
- [5b351a5de](https://github.com/vendor/updated_package/commit/5b351a5de) `Change`
- [3d938793e](https://github.com/vendor/updated_package/commit/3d938793e) `Fix`
- [fb0f0f6f8](https://github.com/vendor/updated_package/commit/fb0f0f6f8) `Introduce bug`
- [8f2d1c9c7](https://github.com/vendor/updated_package/commit/8f2d1c9c7) `Prepare release`
- [59da20d73](https://github.com/vendor/updated_package/commit/59da20d73) `Update ChangeLog`');

$converter = new GithubFlavoredMarkdownConverter([
]);

$directory = __DIR__ . "/public";
if (!is_dir($directory)) {
mkdir($directory);
}

$template = '<html>
<head>
<meta name="viewport" content="width=device-width">
<meta charSet="utf-8"/>
<style>
.container {
max-width: 1024px;
margin: auto;
margin-top: 2em;
}
</style>
</head>
<body>
<div class="container mx-auto">
%s
</div>
</body>
</html>
';

file_put_contents("$directory/body.html", sprintf($template, $converter->convert($message->getPullRequestBody($update))));
file_put_contents("$directory/index.html", sprintf($template, ' <ul>
<li>
<a href="body.html">
Pull request body
</a>
</li>
<li>
<a href="closed.html">
Pull request closed
</a>
</li>
<li>
<a href="title.html">
Pull request title
</a>
</li>
</ul>'));
$other_update = clone $update;
$other_update->setSecurityUpdate(true);
file_put_contents("$directory/closed.html", sprintf($template, $converter->convert($message->getPullRequestClosedMessage(123))));
file_put_contents("$directory/title.html", sprintf($template, $converter->convert($message->getPullRequestTitle($update)) . '<hr><h2>Update with security release:</h2>' . $converter->convert($message->getPullRequestTitle($other_update))));

0 comments on commit b3fd91c

Please sign in to comment.